@nexus-cross/crossx-sdk-core 1.3.8 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts +4 -0
- package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts.map +1 -1
- package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts +10 -3
- package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts.map +1 -1
- package/dist/core/i18n/messages.en.d.ts.map +1 -1
- package/dist/core/i18n/messages.ko.d.ts.map +1 -1
- package/dist/core/i18n/types.d.ts +15 -0
- package/dist/core/i18n/types.d.ts.map +1 -1
- package/dist/core/ports/ConfirmationPort.d.ts +8 -1
- package/dist/core/ports/ConfirmationPort.d.ts.map +1 -1
- package/dist/core/types/errors.d.ts +4 -0
- package/dist/core/types/errors.d.ts.map +1 -1
- package/dist/core/usecases/SignInUseCase.d.ts.map +1 -1
- package/dist/crossx.global +133 -90
- package/dist/index.cjs +129 -86
- package/dist/index.js +1331 -1094
- package/dist/sdk/CROSSxSDK.d.ts +38 -0
- package/dist/sdk/CROSSxSDK.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { createRemoteJWKSet as
|
|
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 || {});
|
|
1
|
+
var Ms = Object.defineProperty;
|
|
2
|
+
var $s = (r, e, s) => e in r ? Ms(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
|
|
3
|
+
var T = (r, e, s) => $s(r, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import { createRemoteJWKSet as Bs, jwtVerify as Us, decodeJwt as Hs } from "jose";
|
|
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.SESSION_EXPIRED = "SESSION_EXPIRED", r.OAUTH_POPUP_BLOCKED = "OAUTH_POPUP_BLOCKED", 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 {
|
|
7
7
|
constructor(e, s, t) {
|
|
8
8
|
super(s), this.code = e, this.details = t, this.name = "CROSSxError", Object.setPrototypeOf(this, m.prototype);
|
|
@@ -16,7 +16,7 @@ class m extends Error {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const ze = {
|
|
20
20
|
// ─── CROSS ────────────────────────────────────────────
|
|
21
21
|
CROSS_MAINNET: {
|
|
22
22
|
caipId: "eip155:612055",
|
|
@@ -65,20 +65,20 @@ const Ve = {
|
|
|
65
65
|
rpcUrl: "https://saigon-testnet.roninchain.com/rpc",
|
|
66
66
|
testnet: !0
|
|
67
67
|
}
|
|
68
|
-
},
|
|
69
|
-
Object.entries(
|
|
70
|
-
),
|
|
71
|
-
Object.values(
|
|
68
|
+
}, co = Object.fromEntries(
|
|
69
|
+
Object.entries(ze).map(([r, e]) => [r, e.caipId])
|
|
70
|
+
), Fs = new Map(
|
|
71
|
+
Object.values(ze).map((r) => [r.caipId, r])
|
|
72
72
|
);
|
|
73
73
|
new Map(
|
|
74
|
-
Object.values(
|
|
74
|
+
Object.values(ze).map((r) => [r.chainId, r])
|
|
75
75
|
);
|
|
76
|
-
const
|
|
76
|
+
const Gs = { symbol: "", decimals: 18 };
|
|
77
77
|
function Je(r) {
|
|
78
78
|
var e;
|
|
79
|
-
return ((e =
|
|
79
|
+
return ((e = Fs.get(r)) == null ? void 0 : e.nativeCurrency) ?? Gs;
|
|
80
80
|
}
|
|
81
|
-
class
|
|
81
|
+
class Ws {
|
|
82
82
|
constructor(e, s) {
|
|
83
83
|
this.sdk = e, this.chainId = s, this._listeners = /* @__PURE__ */ new Map();
|
|
84
84
|
}
|
|
@@ -168,7 +168,7 @@ class Fs {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
let _e = null;
|
|
171
|
-
function
|
|
171
|
+
function Et(r) {
|
|
172
172
|
_e = r;
|
|
173
173
|
}
|
|
174
174
|
const d = {
|
|
@@ -198,7 +198,7 @@ const d = {
|
|
|
198
198
|
return;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
},
|
|
201
|
+
}, qs = {
|
|
202
202
|
// ── 공통 버튼 ────────────────────────────────────────────────
|
|
203
203
|
confirm: "확인",
|
|
204
204
|
cancel: "취소",
|
|
@@ -264,8 +264,19 @@ const d = {
|
|
|
264
264
|
verifyPin_subtitle: "계속하려면 PIN을 확인해 주세요.",
|
|
265
265
|
// ── PIN 잠금 안내 ─────────────────────────────────────────────
|
|
266
266
|
pinLocked_message: "잠금이 해제된 후 다시 시도해 주세요.",
|
|
267
|
-
pinLocked_availableFrom: "이용 가능 시간"
|
|
268
|
-
|
|
267
|
+
pinLocked_availableFrom: "이용 가능 시간",
|
|
268
|
+
pinLocked_failureWarning: "PIN이 올바르지 않습니다. 추가 실패 시 계정이 잠금됩니다.",
|
|
269
|
+
pinLocked_permanent: "너무 많은 시도 실패로 계정이 영구 잠금되었습니다.",
|
|
270
|
+
alert_sessionExpired: "인증이 만료되었습니다. 확인을 누른 뒤 다시 로그인해 주세요.",
|
|
271
|
+
alert_accountWithdrawn: "계정이 탈퇴 처리되었거나 더 이상 사용할 수 없습니다. 확인 후 다시 로그인해 주세요.",
|
|
272
|
+
alert_walletNotFound: "지갑 정보를 찾을 수 없습니다. 확인 후 다시 로그인해 주세요.",
|
|
273
|
+
alert_differentAccount: `이전에 사용하던 계정이 아닌 다른 계정으로 로그인되었습니다.
|
|
274
|
+
|
|
275
|
+
보안을 위해 동일한 Google/Apple 계정으로만 이어서 사용할 수 있습니다.
|
|
276
|
+
|
|
277
|
+
[확인] 이전과 같은 계정으로 다시 로그인 시도
|
|
278
|
+
[취소] 로그아웃하고 닫기`
|
|
279
|
+
}, ts = {
|
|
269
280
|
// ── Common buttons ───────────────────────────────────────────
|
|
270
281
|
confirm: "Confirm",
|
|
271
282
|
cancel: "Cancel",
|
|
@@ -331,16 +342,27 @@ const d = {
|
|
|
331
342
|
verifyPin_subtitle: "To continue, please confirm your PIN.",
|
|
332
343
|
// ── PIN lock message ─────────────────────────────────────────
|
|
333
344
|
pinLocked_message: "Please try again after the lock expires.",
|
|
334
|
-
pinLocked_availableFrom: "Available from"
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
345
|
+
pinLocked_availableFrom: "Available from",
|
|
346
|
+
pinLocked_failureWarning: "Incorrect PIN. Your account will be locked after further failures.",
|
|
347
|
+
pinLocked_permanent: "Your account has been permanently locked due to too many failed attempts.",
|
|
348
|
+
alert_sessionExpired: "Your session has expired. Tap OK and sign in again.",
|
|
349
|
+
alert_accountWithdrawn: "This account is no longer available or has been withdrawn. Tap OK and sign in again.",
|
|
350
|
+
alert_walletNotFound: "Wallet data could not be found. Tap OK and sign in again.",
|
|
351
|
+
alert_differentAccount: `You signed in with a different Google/Apple account than before.
|
|
352
|
+
|
|
353
|
+
For security, you must continue with the same account.
|
|
354
|
+
|
|
355
|
+
OK → Try signing in again with the correct account
|
|
356
|
+
Cancel → Sign out and close`
|
|
357
|
+
}, Ks = {
|
|
358
|
+
ko: qs,
|
|
359
|
+
en: ts
|
|
338
360
|
};
|
|
339
|
-
function
|
|
340
|
-
return
|
|
361
|
+
function ve(r = "en", e) {
|
|
362
|
+
return Ks[r] ?? ts;
|
|
341
363
|
}
|
|
342
|
-
const
|
|
343
|
-
class
|
|
364
|
+
const It = "crossx_access_token", At = "crossx_refresh_token", Tt = "crossx_user_info";
|
|
365
|
+
class Vs {
|
|
344
366
|
constructor(e, s, t, n, o, i, a) {
|
|
345
367
|
this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null, this._migrated = !1;
|
|
346
368
|
const c = e.projectId;
|
|
@@ -382,10 +404,12 @@ class qs {
|
|
|
382
404
|
expectedOrigin: new URL(o).origin
|
|
383
405
|
}), d.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", s.length, ")");
|
|
384
406
|
} catch (t) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
407
|
+
d.error("[CROSSx] SignIn 에러 (OAuth 단계):", t);
|
|
408
|
+
const n = t instanceof Error ? t.message : "Sign in failed";
|
|
409
|
+
throw /팝업|popup/i.test(n) ? new m(
|
|
410
|
+
p.OAUTH_POPUP_BLOCKED,
|
|
411
|
+
n
|
|
412
|
+
) : new m(p.AUTH_FAILED, n);
|
|
389
413
|
}
|
|
390
414
|
return this.processFirebaseToken(s);
|
|
391
415
|
}
|
|
@@ -414,18 +438,18 @@ class qs {
|
|
|
414
438
|
try {
|
|
415
439
|
const w = this.crypto.decodeJWT(e);
|
|
416
440
|
_ = (n = w.firebase) == null ? void 0 : n.sign_in_provider;
|
|
417
|
-
const
|
|
418
|
-
_ === "google.com" ? h = (i =
|
|
441
|
+
const E = ((o = w.firebase) == null ? void 0 : o.identities) ?? {};
|
|
442
|
+
_ === "google.com" ? h = (i = E["google.com"]) == null ? void 0 : i[0] : _ === "apple.com" && (h = (a = E["apple.com"]) == null ? void 0 : a[0]), d.log("[CROSSx] OAuth provider sub 추출 — provider:", _, "hasProviderSub:", !!h);
|
|
419
443
|
} catch {
|
|
420
444
|
d.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
|
|
421
445
|
}
|
|
422
446
|
if (l) {
|
|
423
447
|
const w = this.crypto.decodeJWT(l);
|
|
424
448
|
d.log("[CROSSx] access_token 디코딩 — sub:", w.sub, "exp:", w.exp);
|
|
425
|
-
const
|
|
426
|
-
if (t =
|
|
449
|
+
const E = await this.crypto.verifyJWT(l);
|
|
450
|
+
if (t = E.signatureVerified ?? !1, !E.valid)
|
|
427
451
|
throw d.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
|
|
428
|
-
const y =
|
|
452
|
+
const y = E.payload;
|
|
429
453
|
s = {
|
|
430
454
|
id: y.sub,
|
|
431
455
|
email: y.email,
|
|
@@ -676,10 +700,10 @@ class qs {
|
|
|
676
700
|
const e = await this.storage.get(Tt);
|
|
677
701
|
if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
|
|
678
702
|
await this.storage.set(this.STORAGE_KEY_USER, e);
|
|
679
|
-
const t = await this.storage.get(
|
|
703
|
+
const t = await this.storage.get(It);
|
|
680
704
|
t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
|
|
681
|
-
const n = await this.storage.get(
|
|
682
|
-
n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(Tt), await this.storage.remove(
|
|
705
|
+
const n = await this.storage.get(At);
|
|
706
|
+
n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(Tt), await this.storage.remove(It), await this.storage.remove(At), d.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
|
|
683
707
|
} catch (e) {
|
|
684
708
|
d.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
|
|
685
709
|
}
|
|
@@ -714,7 +738,7 @@ class qs {
|
|
|
714
738
|
return d.log("[CROSSx] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
|
|
715
739
|
}
|
|
716
740
|
}
|
|
717
|
-
class
|
|
741
|
+
class zs {
|
|
718
742
|
constructor(e, s, t) {
|
|
719
743
|
this.config = e, this.storage = s, this.tokenStore = t;
|
|
720
744
|
const n = e.projectId;
|
|
@@ -724,7 +748,7 @@ class Ks {
|
|
|
724
748
|
this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove(this.STORAGE_KEY_ACCESS_TOKEN), await this.storage.remove(this.STORAGE_KEY_REFRESH_TOKEN)), await this.storage.remove(this.STORAGE_KEY_USER), await this.storage.clear();
|
|
725
749
|
}
|
|
726
750
|
}
|
|
727
|
-
class
|
|
751
|
+
class js {
|
|
728
752
|
constructor(e, s) {
|
|
729
753
|
this.storage = e, this.walletProvider = s;
|
|
730
754
|
}
|
|
@@ -741,7 +765,7 @@ class Vs {
|
|
|
741
765
|
};
|
|
742
766
|
}
|
|
743
767
|
}
|
|
744
|
-
class
|
|
768
|
+
class ss {
|
|
745
769
|
constructor() {
|
|
746
770
|
this.encryptedBytes = null, this.xorKey = null;
|
|
747
771
|
}
|
|
@@ -782,7 +806,7 @@ class es {
|
|
|
782
806
|
return this.encryptedBytes !== null;
|
|
783
807
|
}
|
|
784
808
|
}
|
|
785
|
-
class
|
|
809
|
+
class Ys {
|
|
786
810
|
constructor(e, s) {
|
|
787
811
|
this.chainRegistry = e, this.transport = s, this._nextId = 1;
|
|
788
812
|
}
|
|
@@ -814,7 +838,7 @@ class zs {
|
|
|
814
838
|
return a == null ? void 0 : a.result;
|
|
815
839
|
}
|
|
816
840
|
}
|
|
817
|
-
class
|
|
841
|
+
class Xs {
|
|
818
842
|
constructor() {
|
|
819
843
|
this.listeners = /* @__PURE__ */ new Map();
|
|
820
844
|
}
|
|
@@ -837,7 +861,7 @@ class js {
|
|
|
837
861
|
this.listeners.clear();
|
|
838
862
|
}
|
|
839
863
|
}
|
|
840
|
-
const
|
|
864
|
+
const We = {
|
|
841
865
|
// TODO(v2.0.0-BEFORE-RELEASE): 아래 블록으로 교체
|
|
842
866
|
// production: {
|
|
843
867
|
// oauthServiceUrl: 'https://cross-wallet-oauth.crosstoken.io',
|
|
@@ -860,24 +884,24 @@ const Ge = {
|
|
|
860
884
|
walletGatewayUrl: "https://dev-embedded-wallet-gateway.crosstoken.io/api/v1"
|
|
861
885
|
}
|
|
862
886
|
};
|
|
863
|
-
function
|
|
887
|
+
function Js(r) {
|
|
864
888
|
const e = r.environment;
|
|
865
|
-
return e && e in
|
|
889
|
+
return e && e in We ? We[e] : null;
|
|
866
890
|
}
|
|
867
|
-
function
|
|
891
|
+
function Zs() {
|
|
868
892
|
try {
|
|
869
893
|
if (typeof __CROSSX_CONFIG__ < "u") {
|
|
870
|
-
const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e =
|
|
894
|
+
const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = Js(r);
|
|
871
895
|
if (e) return e;
|
|
872
896
|
}
|
|
873
897
|
} catch {
|
|
874
898
|
}
|
|
875
|
-
return
|
|
899
|
+
return We.production;
|
|
876
900
|
}
|
|
877
|
-
const
|
|
901
|
+
const Qs = 2e3, Rt = 6e4, er = 1e3, tr = 1e4, sr = "0x77359400", kt = "0x3B9ACA00", Pt = 130, Ot = 6, Ct = 18, Nt = 3e4, rr = 5 * 60 * 1e3, nr = 30 * 1e3, ee = class ee extends Xs {
|
|
878
902
|
constructor(e, s, t, n, o, i, a, c, l, u, h) {
|
|
879
903
|
var _, f;
|
|
880
|
-
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._themeMediaCleanup = null, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger &&
|
|
904
|
+
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._themeMediaCleanup = null, this._isRecoveringSession = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && Et(e.logger), this.confirmation = l, this.pinStore = h ?? new ss(), this.chainRegistry = u, this.jsonRpc = new Ys(u, o), this.signInUseCase = new Vs(
|
|
881
905
|
this.internalConfig,
|
|
882
906
|
t,
|
|
883
907
|
n,
|
|
@@ -885,7 +909,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
885
909
|
o,
|
|
886
910
|
a,
|
|
887
911
|
c
|
|
888
|
-
), this.signOutUseCase = new
|
|
912
|
+
), this.signOutUseCase = new zs(this.internalConfig, t, c), this.migrateWalletUseCase = new js(t, a), (_ = a.setOnUnauthorized) == null || _.call(a, () => this.forceLogout()), (f = a.setTokenRefresher) == null || f.call(
|
|
889
913
|
a,
|
|
890
914
|
() => this.signInUseCase.refreshAccessToken()
|
|
891
915
|
), e.autoDetectTheme && this._setupAutoDetectTheme();
|
|
@@ -914,9 +938,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
914
938
|
}
|
|
915
939
|
async _doInitialize(e) {
|
|
916
940
|
var s, t;
|
|
917
|
-
d.log("[CROSSx SDK] v1.3.
|
|
941
|
+
d.log("[CROSSx SDK] v1.3.10 초기화 중..."), this.confirmation.setMessages(ve(this._config.locale));
|
|
918
942
|
try {
|
|
919
|
-
const n =
|
|
943
|
+
const n = Zs();
|
|
920
944
|
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`);
|
|
921
945
|
const o = await this.signInUseCase.restoreSession();
|
|
922
946
|
if (o != null && o.success) {
|
|
@@ -929,7 +953,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
929
953
|
d.log("[CROSSx] initialize: 비밀번호 입력 취소 — 지갑 미로드 상태로 계속");
|
|
930
954
|
}
|
|
931
955
|
}
|
|
932
|
-
return this.initialized = !0, d.info("[CROSSx SDK] v1.3.
|
|
956
|
+
return this.initialized = !0, d.info("[CROSSx SDK] v1.3.10 초기화 완료"), this.emit("initialized", { restored: !!(o != null && o.success) }), o ?? null;
|
|
933
957
|
} catch (n) {
|
|
934
958
|
throw new m(p.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", n);
|
|
935
959
|
}
|
|
@@ -958,7 +982,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
958
982
|
const t = await this.signInUseCase.execute(s);
|
|
959
983
|
return t.success && this.applyAuthResult(t), t;
|
|
960
984
|
} catch (t) {
|
|
961
|
-
throw new m(p.AUTH_FAILED, "로그인에 실패했습니다", t);
|
|
985
|
+
throw t instanceof m ? t : new m(p.AUTH_FAILED, "로그인에 실패했습니다", t);
|
|
962
986
|
}
|
|
963
987
|
}
|
|
964
988
|
/**
|
|
@@ -1205,7 +1229,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1205
1229
|
*/
|
|
1206
1230
|
async getAddresses() {
|
|
1207
1231
|
if (this.ensureAuthenticated(), !this.userId) return [];
|
|
1208
|
-
const e = await this.
|
|
1232
|
+
const e = await this.withSessionRecovery(
|
|
1233
|
+
() => this.walletProvider.getAddresses(this.userId)
|
|
1234
|
+
);
|
|
1209
1235
|
return e.length === 0 && this.address ? [{ address: this.address, index: 0 }] : e;
|
|
1210
1236
|
}
|
|
1211
1237
|
/**
|
|
@@ -1230,14 +1256,18 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1230
1256
|
async selectWallet(e) {
|
|
1231
1257
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1232
1258
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1233
|
-
let s = await this.
|
|
1259
|
+
let s = await this.withSessionRecovery(
|
|
1260
|
+
() => this.walletProvider.getAddresses(this.userId)
|
|
1261
|
+
);
|
|
1234
1262
|
s.length === 0 && this.address && (s = [{ address: this.address, index: 0 }]);
|
|
1235
1263
|
const t = await this.confirmation.showWalletSelector(
|
|
1236
1264
|
s,
|
|
1237
1265
|
async () => {
|
|
1238
1266
|
await this.ensurePinForSigning();
|
|
1239
1267
|
const n = s.length, i = { address: (await this.withPinRetry(
|
|
1240
|
-
() => this.
|
|
1268
|
+
() => this.withSessionRecovery(
|
|
1269
|
+
() => this.walletProvider.getAddress(this.userId, n)
|
|
1270
|
+
)
|
|
1241
1271
|
)).address, index: n };
|
|
1242
1272
|
return s.push(i), i;
|
|
1243
1273
|
},
|
|
@@ -1337,7 +1367,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1337
1367
|
* sdk.applyLocale('ko');
|
|
1338
1368
|
*/
|
|
1339
1369
|
applyLocale(e = this._config.locale ?? "en") {
|
|
1340
|
-
this._config = Object.freeze({ ...this._config, locale: e }), this.confirmation.setMessages(
|
|
1370
|
+
this._config = Object.freeze({ ...this._config, locale: e }), this.confirmation.setMessages(ve(e));
|
|
1341
1371
|
}
|
|
1342
1372
|
/**
|
|
1343
1373
|
* 지갑 생성/로드 (로그인 후 address가 없는 경우)
|
|
@@ -1346,6 +1376,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1346
1376
|
* - migration_required: 마이그레이션 플로우 실행
|
|
1347
1377
|
*/
|
|
1348
1378
|
async createWallet() {
|
|
1379
|
+
return this.withSessionRecovery(() => this._createWallet());
|
|
1380
|
+
}
|
|
1381
|
+
async _createWallet() {
|
|
1349
1382
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1350
1383
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1351
1384
|
d.log("[CROSSx] createWallet 시작");
|
|
@@ -1423,6 +1456,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1423
1456
|
* @todo 백엔드 메시지 서명 전용 엔드포인트 추가 후 구현
|
|
1424
1457
|
*/
|
|
1425
1458
|
async signMessage(e, s, t) {
|
|
1459
|
+
return this.withSessionRecovery(() => this._signMessage(e, s, t));
|
|
1460
|
+
}
|
|
1461
|
+
async _signMessage(e, s, t) {
|
|
1426
1462
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1427
1463
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1428
1464
|
const n = await this.resolveAddress(t == null ? void 0 : t.index);
|
|
@@ -1479,11 +1515,14 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1479
1515
|
* });
|
|
1480
1516
|
*/
|
|
1481
1517
|
async signTypedData(e, s, t) {
|
|
1518
|
+
return this.withSessionRecovery(() => this._signTypedData(e, s, t));
|
|
1519
|
+
}
|
|
1520
|
+
async _signTypedData(e, s, t) {
|
|
1482
1521
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1483
1522
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1484
1523
|
if (!this.walletProvider.signTypedData)
|
|
1485
1524
|
throw new m(p.NOT_IMPLEMENTED, "signTypedData가 구현되어 있지 않습니다");
|
|
1486
|
-
|
|
1525
|
+
ee.validateTypedDataChainId(e, s);
|
|
1487
1526
|
const n = await this.resolveAddress(t == null ? void 0 : t.index);
|
|
1488
1527
|
if (!await this.confirmation.requestConfirmation({
|
|
1489
1528
|
type: "sign-typed-data",
|
|
@@ -1506,7 +1545,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1506
1545
|
n.address
|
|
1507
1546
|
);
|
|
1508
1547
|
});
|
|
1509
|
-
return
|
|
1548
|
+
return ee.validateSignatureFormat(i.signature), {
|
|
1510
1549
|
chainId: e,
|
|
1511
1550
|
signature: i.signature,
|
|
1512
1551
|
address: n.address
|
|
@@ -1535,7 +1574,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1535
1574
|
* });
|
|
1536
1575
|
*/
|
|
1537
1576
|
async signTypedDataOffchain(e, s) {
|
|
1538
|
-
return this.signTypedData(
|
|
1577
|
+
return this.signTypedData(ee.OFFCHAIN_CHAIN_ID, e, s);
|
|
1539
1578
|
}
|
|
1540
1579
|
// ============================================================================
|
|
1541
1580
|
// 트랜잭션
|
|
@@ -1547,6 +1586,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1547
1586
|
* @param opts 서명 옵션 (index, dappName, accountName)
|
|
1548
1587
|
*/
|
|
1549
1588
|
async signTransaction(e, s, t) {
|
|
1589
|
+
return this.withSessionRecovery(() => this._signTransaction(e, s, t));
|
|
1590
|
+
}
|
|
1591
|
+
async _signTransaction(e, s, t) {
|
|
1550
1592
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1551
1593
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1552
1594
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
@@ -1580,7 +1622,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1580
1622
|
c
|
|
1581
1623
|
);
|
|
1582
1624
|
});
|
|
1583
|
-
return
|
|
1625
|
+
return ee.validateSignedTxFormat(a.signature), {
|
|
1584
1626
|
chainId: e,
|
|
1585
1627
|
signedTx: a.signature,
|
|
1586
1628
|
txHash: a.txHash ?? ""
|
|
@@ -1602,6 +1644,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1602
1644
|
* @param opts 서명 옵션 (index, dappName, accountName)
|
|
1603
1645
|
*/
|
|
1604
1646
|
async sendTransaction(e, s, t) {
|
|
1647
|
+
return this.withSessionRecovery(() => this._sendTransaction(e, s, t));
|
|
1648
|
+
}
|
|
1649
|
+
async _sendTransaction(e, s, t) {
|
|
1605
1650
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1606
1651
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1607
1652
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
@@ -1673,7 +1718,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1673
1718
|
* @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
|
|
1674
1719
|
*/
|
|
1675
1720
|
async waitForTxAndGetReceipt(e, s, t = {}) {
|
|
1676
|
-
const n = t.intervalMs ??
|
|
1721
|
+
const n = t.intervalMs ?? er, o = tr, i = t.timeoutMs ?? Rt, a = Date.now() + i;
|
|
1677
1722
|
let c = n;
|
|
1678
1723
|
for (; Date.now() < a; ) {
|
|
1679
1724
|
const l = await this.getTransactionReceipt(e, s);
|
|
@@ -1701,29 +1746,29 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1701
1746
|
* logger.log(receipt.status); // '0x1' | '0x0'
|
|
1702
1747
|
*/
|
|
1703
1748
|
async sendTransactionWithWaitForReceipt(e, s, t = {}) {
|
|
1704
|
-
var
|
|
1705
|
-
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((
|
|
1749
|
+
var E, y;
|
|
1750
|
+
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((E = this._config.receiptPolling) == null ? void 0 : E.intervalMs) ?? Qs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? Rt, u = Je(e), h = s.from ?? "";
|
|
1706
1751
|
let _, f;
|
|
1707
|
-
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((
|
|
1708
|
-
_ =
|
|
1709
|
-
const N = BigInt(
|
|
1752
|
+
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((R) => {
|
|
1753
|
+
_ = R;
|
|
1754
|
+
const N = BigInt(R.gasUsed) * BigInt(R.effectiveGasPrice), F = s.value ? BigInt(s.value) : 0n, M = ee.formatTxAmount(s.value, u.symbol, u.decimals), V = ee.formatTxAmount("0x" + N.toString(16), u.symbol, u.decimals), G = ee.formatTxAmount("0x" + (F + N).toString(16), u.symbol, u.decimals);
|
|
1710
1755
|
return {
|
|
1711
1756
|
chainId: e,
|
|
1712
1757
|
txHash: a,
|
|
1713
|
-
from:
|
|
1714
|
-
to:
|
|
1715
|
-
amount:
|
|
1716
|
-
fees:
|
|
1717
|
-
total:
|
|
1758
|
+
from: R.from,
|
|
1759
|
+
to: R.to ?? s.to,
|
|
1760
|
+
amount: M,
|
|
1761
|
+
fees: V,
|
|
1762
|
+
total: G,
|
|
1718
1763
|
nativeSymbol: u.symbol,
|
|
1719
|
-
status:
|
|
1764
|
+
status: R.status === "0x1" ? "success" : "reverted"
|
|
1720
1765
|
};
|
|
1721
|
-
}).catch((
|
|
1766
|
+
}).catch((R) => (f = R instanceof Error ? R : new Error(String(R)), {
|
|
1722
1767
|
chainId: e,
|
|
1723
1768
|
txHash: a,
|
|
1724
1769
|
from: h,
|
|
1725
1770
|
to: s.to,
|
|
1726
|
-
amount:
|
|
1771
|
+
amount: ee.formatTxAmount(s.value, u.symbol, u.decimals),
|
|
1727
1772
|
nativeSymbol: u.symbol,
|
|
1728
1773
|
status: "timeout"
|
|
1729
1774
|
}));
|
|
@@ -1901,7 +1946,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1901
1946
|
return { wei: "0x0", formatted: "0", chainId: e };
|
|
1902
1947
|
try {
|
|
1903
1948
|
const n = await this.jsonRpc.call("eth_getBalance", [s, "latest"], e) ?? "0x0";
|
|
1904
|
-
return { wei: n, formatted:
|
|
1949
|
+
return { wei: n, formatted: ee.formatWei(n), chainId: e };
|
|
1905
1950
|
} catch (t) {
|
|
1906
1951
|
if (t instanceof m) throw t;
|
|
1907
1952
|
const n = t instanceof Error ? t.message : String(t);
|
|
@@ -1913,7 +1958,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1913
1958
|
try {
|
|
1914
1959
|
const s = BigInt(e);
|
|
1915
1960
|
if (s === 0n) return "0";
|
|
1916
|
-
const t = 10n ** BigInt(
|
|
1961
|
+
const t = 10n ** BigInt(Ct), n = s / t, i = (s % t).toString().padStart(Ct, "0").replace(/0+$/, "").slice(0, Ot);
|
|
1917
1962
|
return i ? `${n}.${i}` : `${n}`;
|
|
1918
1963
|
} catch {
|
|
1919
1964
|
return "?";
|
|
@@ -1938,7 +1983,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1938
1983
|
* const client = createWalletClient({ transport: custom(provider) });
|
|
1939
1984
|
*/
|
|
1940
1985
|
getProvider(e) {
|
|
1941
|
-
return this.ensureAuthenticated(), new
|
|
1986
|
+
return this.ensureAuthenticated(), new Ws(this, e);
|
|
1942
1987
|
}
|
|
1943
1988
|
/**
|
|
1944
1989
|
* 범용 JSON-RPC 요청 — 노드에 직접 연결.
|
|
@@ -1972,7 +2017,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1972
2017
|
try {
|
|
1973
2018
|
const n = BigInt(e);
|
|
1974
2019
|
if (n === 0n) return;
|
|
1975
|
-
const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0,
|
|
2020
|
+
const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, Ot).replace(/0+$/, "");
|
|
1976
2021
|
return `${c ? `${i}.${c}` : `${i}`} ${s}`;
|
|
1977
2022
|
} catch {
|
|
1978
2023
|
return;
|
|
@@ -2017,8 +2062,8 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2017
2062
|
}
|
|
2018
2063
|
const f = _.pinStatus;
|
|
2019
2064
|
if (i = f.maxAttempts, o = i - f.remainingAttempts, f.remainingAttempts === 0 && f.lockExpiresAt) {
|
|
2020
|
-
const w = f.lockExpiresAt * 1e3,
|
|
2021
|
-
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${
|
|
2065
|
+
const w = f.lockExpiresAt * 1e3, E = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = E <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
2066
|
+
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${E}초, 메시지: ${y}`), await this.confirmation.showRecoveryPinLockedPrompt(E, y), o = 0, n = "Your account lock has been lifted. You may try again.";
|
|
2022
2067
|
} else
|
|
2023
2068
|
d.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 ${o}/${i})`), n = "Incorrect PIN.";
|
|
2024
2069
|
} catch (_) {
|
|
@@ -2027,8 +2072,8 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2027
2072
|
const f = _.details;
|
|
2028
2073
|
if (i = (f == null ? void 0 : f.maxAttempts) ?? 5, (f == null ? void 0 : f.permanent) === !0)
|
|
2029
2074
|
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;
|
|
2030
|
-
const w = ((f == null ? void 0 : f.lockExpiresAt) ?? 0) * 1e3,
|
|
2031
|
-
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${
|
|
2075
|
+
const w = ((f == null ? void 0 : f.lockExpiresAt) ?? 0) * 1e3, E = Math.max(1, Math.round((w - Date.now()) / 1e3)), y = E <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
|
|
2076
|
+
d.warn(`[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${E}초`), await this.confirmation.showRecoveryPinLockedPrompt(E, y), o = 0, n = "Your account lock has been lifted. You may try again.";
|
|
2032
2077
|
} else
|
|
2033
2078
|
throw d.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):", _), _;
|
|
2034
2079
|
}
|
|
@@ -2069,12 +2114,12 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2069
2114
|
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) {
|
|
2070
2115
|
const f = _;
|
|
2071
2116
|
if (f) {
|
|
2072
|
-
const w =
|
|
2117
|
+
const w = kt;
|
|
2073
2118
|
c.maxFeePerGas = "0x" + (BigInt(f) + BigInt(w)).toString(16), c.maxPriorityFeePerGas = w, d.log("[CROSSx] Dynamic 체인 감지 — baseFee:", f, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
|
|
2074
2119
|
} else
|
|
2075
|
-
c.gasPrice =
|
|
2120
|
+
c.gasPrice = sr, d.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
|
|
2076
2121
|
}
|
|
2077
|
-
return !i && a && (c.maxPriorityFeePerGas =
|
|
2122
|
+
return !i && a && (c.maxPriorityFeePerGas = kt, d.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
|
|
2078
2123
|
}
|
|
2079
2124
|
/**
|
|
2080
2125
|
* EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
|
|
@@ -2083,7 +2128,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2083
2128
|
* - chainId가 '0' → domain.chainId가 없거나 0이어야 함
|
|
2084
2129
|
*/
|
|
2085
2130
|
static validateTypedDataChainId(e, s) {
|
|
2086
|
-
const t =
|
|
2131
|
+
const t = ee.extractDomainChainId(s);
|
|
2087
2132
|
if (e === "0") {
|
|
2088
2133
|
if (t !== void 0 && t !== 0)
|
|
2089
2134
|
throw new m(
|
|
@@ -2121,10 +2166,10 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2121
2166
|
const s = e.startsWith("0x") ? e.slice(2) : e;
|
|
2122
2167
|
if (!/^[0-9a-fA-F]+$/.test(s))
|
|
2123
2168
|
throw new m(p.SIGNATURE_FAILED, "유효하지 않은 서명: 올바른 hex 문자열이 아닙니다");
|
|
2124
|
-
if (s.length !==
|
|
2169
|
+
if (s.length !== Pt)
|
|
2125
2170
|
throw new m(
|
|
2126
2171
|
p.SIGNATURE_FAILED,
|
|
2127
|
-
`서명 길이가 유효하지 않습니다: ${
|
|
2172
|
+
`서명 길이가 유효하지 않습니다: ${Pt} hex 문자(65 바이트) 예상, 현재 ${s.length}`
|
|
2128
2173
|
);
|
|
2129
2174
|
}
|
|
2130
2175
|
/** RLP-encoded signed transaction 형식 검증 */
|
|
@@ -2162,7 +2207,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2162
2207
|
/** AuthResult를 내부 상태에 반영합니다. */
|
|
2163
2208
|
applyAuthResult(e) {
|
|
2164
2209
|
var s, t, n, o;
|
|
2165
|
-
this.authenticated = e.success, this.userId = ((s = e.user) == null ? void 0 : s.id) ?? null, this.address = e.address ?? null, this.activeWalletIndex = 0, this.userEmail = ((t = e.user) == null ? void 0 : t.email) ?? null, this.providerSub = ((n = e.user) == null ? void 0 : n.providerSub) ?? null, this.loginType =
|
|
2210
|
+
this.authenticated = e.success, this.userId = ((s = e.user) == null ? void 0 : s.id) ?? null, this.address = e.address ?? null, this.activeWalletIndex = 0, this.userEmail = ((t = e.user) == null ? void 0 : t.email) ?? null, this.providerSub = ((n = e.user) == null ? void 0 : n.providerSub) ?? null, this.loginType = ee.normalizeLoginType((o = e.user) == null ? void 0 : o.signInProvider), this.tokenSignatureVerified = e.tokenSignatureVerified ?? !1, this._isRecoveringSession || this.emit("authChanged", {
|
|
2166
2211
|
isAuthenticated: this.authenticated,
|
|
2167
2212
|
address: this.address,
|
|
2168
2213
|
userId: this.userId
|
|
@@ -2170,7 +2215,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2170
2215
|
}
|
|
2171
2216
|
/** 인증 상태를 초기화합니다. */
|
|
2172
2217
|
clearAuthState() {
|
|
2173
|
-
this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.providerSub = null, this.loginType = null, this.tokenSignatureVerified = !1, this.pinStore.clear(), this.emit("authChanged", {
|
|
2218
|
+
this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.providerSub = null, this.loginType = null, this.tokenSignatureVerified = !1, this.pinStore.clear(), this._isRecoveringSession || this.emit("authChanged", {
|
|
2174
2219
|
isAuthenticated: !1,
|
|
2175
2220
|
address: null,
|
|
2176
2221
|
userId: null
|
|
@@ -2184,6 +2229,80 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2184
2229
|
forceLogout() {
|
|
2185
2230
|
this.authenticated && (d.warn("[CROSSx] 인증 만료(Gateway -10002) — 강제 로그아웃"), this.clearAuthState());
|
|
2186
2231
|
}
|
|
2232
|
+
/**
|
|
2233
|
+
* 세션 만료 시 동일 계정으로 재인증합니다.
|
|
2234
|
+
*
|
|
2235
|
+
* OAuth를 다시 열고, 로그인 직전에 보관해 둔 식별자와 비교합니다.
|
|
2236
|
+
* - `providerSub`(Firebase identities의 Google UID / Apple sub)가 있으면 **그 값이 같을 때만** 성공 처리합니다.
|
|
2237
|
+
* - 없으면(레거시) `userId`로 동일 여부를 판단합니다.
|
|
2238
|
+
*
|
|
2239
|
+
* 다른 계정이면 서버 `signOut` 후 `confirm()`으로 안내합니다.
|
|
2240
|
+
* - **확인(OK)**: 같은 계정으로 다시 `signInAgain()` 재시도
|
|
2241
|
+
* - **취소**: 로컬 인증 상태 정리(로그아웃)
|
|
2242
|
+
*
|
|
2243
|
+
* @returns 재인증 성공 시 AuthResult, 실패 시 { success: false }
|
|
2244
|
+
*/
|
|
2245
|
+
async signInAgain() {
|
|
2246
|
+
var n, o;
|
|
2247
|
+
this.ensureInitialized();
|
|
2248
|
+
const e = this.providerSub, s = this.userId, t = this.loginType;
|
|
2249
|
+
this._isRecoveringSession = !0;
|
|
2250
|
+
try {
|
|
2251
|
+
this.authenticated = !1, this.tokenStore.clear();
|
|
2252
|
+
const i = t ? { provider: t } : void 0;
|
|
2253
|
+
let a;
|
|
2254
|
+
try {
|
|
2255
|
+
a = await this.signInUseCase.execute(i);
|
|
2256
|
+
} catch (h) {
|
|
2257
|
+
throw this.clearAuthState(), h;
|
|
2258
|
+
}
|
|
2259
|
+
if (!a.success)
|
|
2260
|
+
return this.clearAuthState(), a;
|
|
2261
|
+
const c = ((n = a.user) == null ? void 0 : n.providerSub) ?? null, l = ((o = a.user) == null ? void 0 : o.id) ?? null;
|
|
2262
|
+
if (!(e ? !!c && c === e : s ? !!l && s === l : !0)) {
|
|
2263
|
+
d.warn("[CROSSx] signInAgain: providerSub/userId 불일치 — 잘못된 계정으로 로그인됨"), await this.signOutUseCase.execute().catch(() => {
|
|
2264
|
+
});
|
|
2265
|
+
const h = ve(this._config.locale ?? "en");
|
|
2266
|
+
return (typeof globalThis.confirm == "function" ? globalThis.confirm(h.alert_differentAccount) : !1) ? (this._isRecoveringSession = !1, this.signInAgain()) : (this.clearAuthState(), { success: !1, error: "Different account signed in" });
|
|
2267
|
+
}
|
|
2268
|
+
this.applyAuthResult(a);
|
|
2269
|
+
try {
|
|
2270
|
+
await this.loadWalletAfterAuth();
|
|
2271
|
+
} catch {
|
|
2272
|
+
d.warn("[CROSSx] signInAgain: loadWalletAfterAuth 실패 (로그인은 유지)");
|
|
2273
|
+
}
|
|
2274
|
+
return d.log("[CROSSx] signInAgain: 세션 복구 성공"), a;
|
|
2275
|
+
} finally {
|
|
2276
|
+
this._isRecoveringSession = !1;
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
* SESSION_EXPIRED 에러 발생 시 자동 재인증 후 재시도합니다.
|
|
2281
|
+
*
|
|
2282
|
+
* @param fn 실행할 비동기 함수
|
|
2283
|
+
* @returns fn의 결과 또는 재시도 후 결과
|
|
2284
|
+
*/
|
|
2285
|
+
async withSessionRecovery(e) {
|
|
2286
|
+
try {
|
|
2287
|
+
return await e();
|
|
2288
|
+
} catch (s) {
|
|
2289
|
+
const t = ve(this._config.locale ?? "en");
|
|
2290
|
+
if (s instanceof m && s.code === p.WITHDRAW_FAILED)
|
|
2291
|
+
throw d.warn("[CROSSx] WITHDRAW_FAILED — 로컬 인증 초기화"), typeof globalThis.alert == "function" && globalThis.alert(t.alert_accountWithdrawn), this.clearAuthState(), s;
|
|
2292
|
+
if (s instanceof m && s.code === p.WALLET_NOT_FOUND)
|
|
2293
|
+
throw d.warn("[CROSSx] WALLET_NOT_FOUND — 로컬 인증 초기화"), typeof globalThis.alert == "function" && globalThis.alert(t.alert_walletNotFound), this.clearAuthState(), s;
|
|
2294
|
+
if (!(s instanceof m) || s.code !== p.SESSION_EXPIRED)
|
|
2295
|
+
throw s;
|
|
2296
|
+
d.warn("[CROSSx] SESSION_EXPIRED 감지 — 자동 재인증 시도"), typeof globalThis.alert == "function" && globalThis.alert(t.alert_sessionExpired);
|
|
2297
|
+
const n = await this.signInAgain();
|
|
2298
|
+
if (!n.success)
|
|
2299
|
+
throw new m(
|
|
2300
|
+
p.SESSION_EXPIRED,
|
|
2301
|
+
n.error ?? "세션이 만료되었습니다. 다시 로그인해 주세요."
|
|
2302
|
+
);
|
|
2303
|
+
return e();
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2187
2306
|
/**
|
|
2188
2307
|
* Firebase sign_in_provider 값을 정규화합니다.
|
|
2189
2308
|
* 'google.com' → 'google', 'apple.com' → 'apple'
|
|
@@ -2225,11 +2344,13 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2225
2344
|
*
|
|
2226
2345
|
* @param initialErrorMessage 모달을 열 때 처음부터 표시할 에러 메시지.
|
|
2227
2346
|
* @param lockExpiresAt PIN 잠금 만료 시각 (Unix ms). 제공 시 잠금 UI를 표시합니다.
|
|
2347
|
+
* @param attemptCount 현재 시도 횟수 (1~maxAttempts). X/maxAttempts 형태로 표시.
|
|
2348
|
+
* @param maxAttempts 최대 시도 허용 횟수.
|
|
2228
2349
|
*
|
|
2229
2350
|
* 뮤텍스: 동시에 여러 곳에서 호출되어도 모달은 하나만 표시됩니다.
|
|
2230
2351
|
* (initialErrorMessage가 없을 때만 공유, 에러 재시도 시에는 항상 새로 열림)
|
|
2231
2352
|
*/
|
|
2232
|
-
async ensureVerifiedPin(e, s) {
|
|
2353
|
+
async ensureVerifiedPin(e, s, t, n) {
|
|
2233
2354
|
if (e)
|
|
2234
2355
|
this.pinStore.clear();
|
|
2235
2356
|
else if (this.pinStore.has())
|
|
@@ -2238,53 +2359,87 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2238
2359
|
d.log("[CROSSx] ensureVerifiedPin: 진행 중인 검증 대기"), await this._verifyPinMutex;
|
|
2239
2360
|
return;
|
|
2240
2361
|
}
|
|
2241
|
-
let
|
|
2242
|
-
this._verifyPinMutex = new Promise((
|
|
2243
|
-
|
|
2362
|
+
let o, i;
|
|
2363
|
+
this._verifyPinMutex = new Promise((c, l) => {
|
|
2364
|
+
o = c, i = l;
|
|
2244
2365
|
});
|
|
2366
|
+
const a = ve(this._config.locale ?? "en");
|
|
2245
2367
|
try {
|
|
2246
2368
|
if (typeof this.walletProvider.verifyPin != "function") {
|
|
2247
|
-
const
|
|
2369
|
+
const l = await this.confirmation.showPinInputPrompt({
|
|
2248
2370
|
verifyMode: !0,
|
|
2249
2371
|
errorMessage: e,
|
|
2250
|
-
lockExpiresAt: s
|
|
2372
|
+
lockExpiresAt: s,
|
|
2373
|
+
attemptCount: t,
|
|
2374
|
+
maxAttempts: n
|
|
2251
2375
|
});
|
|
2252
|
-
if (!
|
|
2376
|
+
if (!l)
|
|
2253
2377
|
throw new m(p.PIN_CANCELLED, "사용자가 PIN 입력을 취소했습니다");
|
|
2254
|
-
this.pinStore.set(
|
|
2378
|
+
this.pinStore.set(l), d.log("[CROSSx] PIN 캐시 완료 (verifyPin 미지원, 로컬 전용)"), o();
|
|
2255
2379
|
return;
|
|
2256
2380
|
}
|
|
2257
|
-
const
|
|
2381
|
+
const c = await this.confirmation.showPinInputPrompt({
|
|
2258
2382
|
verifyMode: !0,
|
|
2259
2383
|
errorMessage: e,
|
|
2260
2384
|
lockExpiresAt: s,
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2385
|
+
attemptCount: t,
|
|
2386
|
+
maxAttempts: n,
|
|
2387
|
+
onSubmit: async (l) => {
|
|
2388
|
+
this.pinStore.set(l);
|
|
2264
2389
|
try {
|
|
2265
|
-
return await this.walletProvider.verifyPin(
|
|
2266
|
-
} catch (
|
|
2267
|
-
if (this.pinStore.clear(),
|
|
2268
|
-
if (
|
|
2269
|
-
return { ok: !1, error:
|
|
2270
|
-
if (
|
|
2271
|
-
return { ok: !1, error:
|
|
2272
|
-
if (
|
|
2273
|
-
return
|
|
2390
|
+
return await this.walletProvider.verifyPin(l) ? (d.log("[CROSSx] PIN 서버 검증 완료 (verify-password)"), { ok: !0 }) : (this.pinStore.clear(), { ok: !1, error: a.pinInput_error });
|
|
2391
|
+
} catch (u) {
|
|
2392
|
+
if (this.pinStore.clear(), u instanceof m) {
|
|
2393
|
+
if (u.code === p.PIN_WRONG)
|
|
2394
|
+
return { ok: !1, error: a.pinInput_error };
|
|
2395
|
+
if (u.code === p.PIN_INVALID)
|
|
2396
|
+
return { ok: !1, error: u.message };
|
|
2397
|
+
if (u.code === p.PIN_LOCKED)
|
|
2398
|
+
return ee.buildPinLockedResult(u, a);
|
|
2274
2399
|
}
|
|
2275
|
-
throw
|
|
2400
|
+
throw u;
|
|
2276
2401
|
}
|
|
2277
2402
|
}
|
|
2278
2403
|
});
|
|
2279
|
-
if (!
|
|
2404
|
+
if (!c)
|
|
2280
2405
|
throw new m(p.PIN_CANCELLED, "사용자가 PIN 입력을 취소했습니다");
|
|
2281
|
-
this.pinStore.set(
|
|
2282
|
-
} catch (
|
|
2283
|
-
|
|
2406
|
+
this.pinStore.set(c), d.log("[CROSSx] PIN 갱신 완료 (verify 모달 닫힘)"), o();
|
|
2407
|
+
} catch (c) {
|
|
2408
|
+
if (c instanceof m && (c.code === p.AUTH_NOT_AUTHENTICATED || c.code === p.AUTH_TOKEN_EXPIRED || c.code === p.SESSION_EXPIRED) && c.code !== p.SESSION_EXPIRED) {
|
|
2409
|
+
const { alert_sessionExpired: l } = ve(this._config.locale ?? "en");
|
|
2410
|
+
typeof globalThis.alert == "function" && globalThis.alert(l);
|
|
2411
|
+
}
|
|
2412
|
+
throw i(c), c;
|
|
2284
2413
|
} finally {
|
|
2285
2414
|
this._verifyPinMutex = null;
|
|
2286
2415
|
}
|
|
2287
2416
|
}
|
|
2417
|
+
/**
|
|
2418
|
+
* PIN_LOCKED 에러에서 잠금 상태를 분석하여 onSubmit 결과를 구성합니다.
|
|
2419
|
+
* iOS의 passwordLocked(PinLockInfo) 분기와 동일한 로직:
|
|
2420
|
+
* - remainingAttempts > 0: 경고 + 시도 횟수
|
|
2421
|
+
* - remainingAttempts == 0: 잠금 + 카운트다운
|
|
2422
|
+
* - permanent: 영구 잠금
|
|
2423
|
+
*/
|
|
2424
|
+
static buildPinLockedResult(e, s) {
|
|
2425
|
+
const t = e.details;
|
|
2426
|
+
if (t != null && t.permanent)
|
|
2427
|
+
return { ok: !1, error: s.pinLocked_permanent };
|
|
2428
|
+
if ((t == null ? void 0 : t.remainingAttempts) != null && t.remainingAttempts > 0 && t.maxAttempts) {
|
|
2429
|
+
const n = t.maxAttempts - t.remainingAttempts;
|
|
2430
|
+
return {
|
|
2431
|
+
ok: !1,
|
|
2432
|
+
error: s.pinLocked_failureWarning,
|
|
2433
|
+
attemptCount: n,
|
|
2434
|
+
maxAttempts: t.maxAttempts
|
|
2435
|
+
};
|
|
2436
|
+
}
|
|
2437
|
+
return {
|
|
2438
|
+
ok: !1,
|
|
2439
|
+
error: "Too many failed attempts. Your account is temporarily locked.",
|
|
2440
|
+
lockExpiresAt: t == null ? void 0 : t.lockExpiresAt
|
|
2441
|
+
};
|
|
2442
|
+
}
|
|
2288
2443
|
/**
|
|
2289
2444
|
* 세션 복원(refresh) 후 지갑 상태를 확인하고 주소를 로드합니다.
|
|
2290
2445
|
*
|
|
@@ -2320,44 +2475,32 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2320
2475
|
* PIN_WRONG이 계속 발생하는 경우(verifyPin 미지원 환경 등) 취소할 때까지 무한 루프.
|
|
2321
2476
|
*/
|
|
2322
2477
|
async withPinRetry(e) {
|
|
2323
|
-
|
|
2478
|
+
const s = ve(this._config.locale ?? "en");
|
|
2479
|
+
let t, n, o, i;
|
|
2480
|
+
const a = (c) => {
|
|
2481
|
+
if (c.code === p.PIN_WRONG)
|
|
2482
|
+
return t = s.pinInput_error, n = void 0, o = void 0, i = void 0, !0;
|
|
2483
|
+
if (c.code === p.PIN_INVALID)
|
|
2484
|
+
return t = c.message, n = void 0, o = void 0, i = void 0, !0;
|
|
2485
|
+
if (c.code === p.PIN_LOCKED) {
|
|
2486
|
+
const l = c.details;
|
|
2487
|
+
return l != null && l.permanent ? (t = s.pinLocked_permanent, n = void 0, o = void 0, i = void 0) : (l == null ? void 0 : l.remainingAttempts) != null && l.remainingAttempts > 0 && l.maxAttempts ? (t = s.pinLocked_failureWarning, n = void 0, o = l.maxAttempts - l.remainingAttempts, i = l.maxAttempts) : (t = "Too many failed attempts. Your account is temporarily locked.", n = l == null ? void 0 : l.lockExpiresAt, o = void 0, i = void 0), !0;
|
|
2488
|
+
}
|
|
2489
|
+
return !1;
|
|
2490
|
+
};
|
|
2324
2491
|
try {
|
|
2325
2492
|
return await e();
|
|
2326
|
-
} catch (
|
|
2327
|
-
if (
|
|
2328
|
-
if (n.code === p.PIN_WRONG)
|
|
2329
|
-
s = "Incorrect PIN. Please enter your current PIN.";
|
|
2330
|
-
else if (n.code === p.PIN_INVALID)
|
|
2331
|
-
s = n.message;
|
|
2332
|
-
else if (n.code === p.PIN_LOCKED) {
|
|
2333
|
-
const o = n.details;
|
|
2334
|
-
t = o == null ? void 0 : o.lockExpiresAt, s = "Too many failed attempts. Your account is temporarily locked.";
|
|
2335
|
-
} else
|
|
2336
|
-
throw n;
|
|
2337
|
-
else
|
|
2338
|
-
throw n;
|
|
2493
|
+
} catch (c) {
|
|
2494
|
+
if (!(c instanceof m && a(c))) throw c;
|
|
2339
2495
|
}
|
|
2340
2496
|
for (; ; ) {
|
|
2341
|
-
d.warn("[CROSSx] PIN 불일치/잠금 — 재입력 요청:",
|
|
2497
|
+
d.warn("[CROSSx] PIN 불일치/잠금 — 재입력 요청:", t), this.pinStore.clear(), await this.ensureVerifiedPin(t, n, o, i), n = void 0, o = void 0, i = void 0;
|
|
2342
2498
|
try {
|
|
2343
2499
|
return await e();
|
|
2344
|
-
} catch (
|
|
2345
|
-
if (
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
continue;
|
|
2349
|
-
}
|
|
2350
|
-
if (n.code === p.PIN_INVALID) {
|
|
2351
|
-
s = n.message;
|
|
2352
|
-
continue;
|
|
2353
|
-
}
|
|
2354
|
-
if (n.code === p.PIN_LOCKED) {
|
|
2355
|
-
const o = n.details;
|
|
2356
|
-
t = o == null ? void 0 : o.lockExpiresAt, s = "Too many failed attempts. Your account is temporarily locked.";
|
|
2357
|
-
continue;
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
throw n;
|
|
2500
|
+
} catch (c) {
|
|
2501
|
+
if (c instanceof m && a(c))
|
|
2502
|
+
continue;
|
|
2503
|
+
throw c;
|
|
2361
2504
|
}
|
|
2362
2505
|
}
|
|
2363
2506
|
}
|
|
@@ -2397,7 +2540,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2397
2540
|
*/
|
|
2398
2541
|
dispose() {
|
|
2399
2542
|
var e;
|
|
2400
|
-
(e = this._themeMediaCleanup) == null || e.call(this), this._themeMediaCleanup = null, this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(),
|
|
2543
|
+
(e = this._themeMediaCleanup) == null || e.call(this), this._themeMediaCleanup = null, this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), Et(null);
|
|
2401
2544
|
}
|
|
2402
2545
|
/**
|
|
2403
2546
|
* @internal internal 패키지 전용 — 공개 문서에 기재하지 않음
|
|
@@ -2417,9 +2560,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2417
2560
|
};
|
|
2418
2561
|
}
|
|
2419
2562
|
};
|
|
2420
|
-
|
|
2421
|
-
let
|
|
2422
|
-
class
|
|
2563
|
+
ee.OFFCHAIN_CHAIN_ID = "0";
|
|
2564
|
+
let ct = ee;
|
|
2565
|
+
class or {
|
|
2423
2566
|
constructor() {
|
|
2424
2567
|
this.prefix = "crossx_";
|
|
2425
2568
|
}
|
|
@@ -2456,8 +2599,8 @@ class nr {
|
|
|
2456
2599
|
}
|
|
2457
2600
|
}
|
|
2458
2601
|
}
|
|
2459
|
-
const
|
|
2460
|
-
class
|
|
2602
|
+
const Ze = "crossx-sdk", ir = 1, de = "data", Ee = "keys", Be = "aes-primary", ar = 12;
|
|
2603
|
+
class Lt {
|
|
2461
2604
|
constructor(e) {
|
|
2462
2605
|
this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
|
|
2463
2606
|
}
|
|
@@ -2466,10 +2609,10 @@ class Ct {
|
|
|
2466
2609
|
}
|
|
2467
2610
|
openDB(e = this.dbName) {
|
|
2468
2611
|
return new Promise((s, t) => {
|
|
2469
|
-
const n = indexedDB.open(e,
|
|
2612
|
+
const n = indexedDB.open(e, ir);
|
|
2470
2613
|
n.onupgradeneeded = () => {
|
|
2471
2614
|
const o = n.result;
|
|
2472
|
-
o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(
|
|
2615
|
+
o.objectStoreNames.contains(de) || o.createObjectStore(de), o.objectStoreNames.contains(Ee) || o.createObjectStore(Ee);
|
|
2473
2616
|
}, n.onsuccess = () => s(n.result), n.onerror = () => t(n.error);
|
|
2474
2617
|
});
|
|
2475
2618
|
}
|
|
@@ -2499,7 +2642,7 @@ class Ct {
|
|
|
2499
2642
|
}
|
|
2500
2643
|
async init() {
|
|
2501
2644
|
this.db = await this.openDB();
|
|
2502
|
-
const e = await this.idbGet(
|
|
2645
|
+
const e = await this.idbGet(Ee, Be);
|
|
2503
2646
|
if (e) {
|
|
2504
2647
|
this.cryptoKey = e;
|
|
2505
2648
|
return;
|
|
@@ -2513,16 +2656,16 @@ class Ct {
|
|
|
2513
2656
|
{ name: "AES-GCM", length: 256 },
|
|
2514
2657
|
!1,
|
|
2515
2658
|
["encrypt", "decrypt"]
|
|
2516
|
-
), await this.idbPut(
|
|
2659
|
+
), await this.idbPut(Ee, Be, this.cryptoKey);
|
|
2517
2660
|
}
|
|
2518
2661
|
/**
|
|
2519
2662
|
* 레거시 DB('crossx-sdk')에서 projectId 스코프 DB로 암호키·데이터 마이그레이션.
|
|
2520
2663
|
* 마이그레이션 성공 시 레거시 DB 삭제.
|
|
2521
2664
|
*/
|
|
2522
2665
|
async migrateFromLegacyDB() {
|
|
2523
|
-
if (this.dbName ===
|
|
2666
|
+
if (this.dbName === Ze) return null;
|
|
2524
2667
|
try {
|
|
2525
|
-
const e = await this.openDB(
|
|
2668
|
+
const e = await this.openDB(Ze), s = e.transaction([Ee, de], "readonly"), t = s.objectStore(Ee).get(Be), n = await new Promise((l, u) => {
|
|
2526
2669
|
t.onsuccess = () => l(t.result), t.onerror = () => u(t.error);
|
|
2527
2670
|
});
|
|
2528
2671
|
if (!n)
|
|
@@ -2535,16 +2678,16 @@ class Ct {
|
|
|
2535
2678
|
i.onsuccess = () => l(i.result), i.onerror = () => u(i.error);
|
|
2536
2679
|
})
|
|
2537
2680
|
]);
|
|
2538
|
-
e.close(), await this.idbPut(
|
|
2681
|
+
e.close(), await this.idbPut(Ee, Be, n);
|
|
2539
2682
|
for (let l = 0; l < c.length; l++)
|
|
2540
2683
|
await this.idbPut(de, String(c[l]), a[l]);
|
|
2541
|
-
return indexedDB.deleteDatabase(
|
|
2684
|
+
return indexedDB.deleteDatabase(Ze), d.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
|
|
2542
2685
|
} catch (e) {
|
|
2543
2686
|
return d.warn("[CROSSx] IndexedDB 레거시 DB 마이그레이션 실패:", e), null;
|
|
2544
2687
|
}
|
|
2545
2688
|
}
|
|
2546
2689
|
async encrypt(e) {
|
|
2547
|
-
const s = new Uint8Array(
|
|
2690
|
+
const s = new Uint8Array(ar);
|
|
2548
2691
|
crypto.getRandomValues(s);
|
|
2549
2692
|
const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
|
|
2550
2693
|
{ name: "AES-GCM", iv: s },
|
|
@@ -2603,7 +2746,7 @@ class Ct {
|
|
|
2603
2746
|
}
|
|
2604
2747
|
}
|
|
2605
2748
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2606
|
-
function
|
|
2749
|
+
function pt(r) {
|
|
2607
2750
|
return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
|
|
2608
2751
|
}
|
|
2609
2752
|
function me(r, e = "") {
|
|
@@ -2612,64 +2755,64 @@ function me(r, e = "") {
|
|
|
2612
2755
|
throw new Error(`${s}expected integer >= 0, got ${r}`);
|
|
2613
2756
|
}
|
|
2614
2757
|
}
|
|
2615
|
-
function
|
|
2616
|
-
const t =
|
|
2758
|
+
function q(r, e, s = "") {
|
|
2759
|
+
const t = pt(r), n = r == null ? void 0 : r.length, o = e !== void 0;
|
|
2617
2760
|
if (!t || o && n !== e) {
|
|
2618
2761
|
const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
|
|
2619
2762
|
throw new Error(i + "expected Uint8Array" + a + ", got " + c);
|
|
2620
2763
|
}
|
|
2621
2764
|
return r;
|
|
2622
2765
|
}
|
|
2623
|
-
function
|
|
2766
|
+
function rs(r) {
|
|
2624
2767
|
if (typeof r != "function" || typeof r.create != "function")
|
|
2625
2768
|
throw new Error("Hash must wrapped by utils.createHasher");
|
|
2626
2769
|
me(r.outputLen), me(r.blockLen);
|
|
2627
2770
|
}
|
|
2628
|
-
function
|
|
2771
|
+
function Oe(r, e = !0) {
|
|
2629
2772
|
if (r.destroyed)
|
|
2630
2773
|
throw new Error("Hash instance has been destroyed");
|
|
2631
2774
|
if (e && r.finished)
|
|
2632
2775
|
throw new Error("Hash#digest() has already been called");
|
|
2633
2776
|
}
|
|
2634
|
-
function
|
|
2635
|
-
|
|
2777
|
+
function ns(r, e) {
|
|
2778
|
+
q(r, void 0, "digestInto() output");
|
|
2636
2779
|
const s = e.outputLen;
|
|
2637
2780
|
if (r.length < s)
|
|
2638
2781
|
throw new Error('"digestInto() output" expected to be of length >=' + s);
|
|
2639
2782
|
}
|
|
2640
|
-
function
|
|
2783
|
+
function cr(r) {
|
|
2641
2784
|
return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
|
|
2642
2785
|
}
|
|
2643
|
-
function
|
|
2786
|
+
function Ce(...r) {
|
|
2644
2787
|
for (let e = 0; e < r.length; e++)
|
|
2645
2788
|
r[e].fill(0);
|
|
2646
2789
|
}
|
|
2647
|
-
function
|
|
2790
|
+
function Qe(r) {
|
|
2648
2791
|
return new DataView(r.buffer, r.byteOffset, r.byteLength);
|
|
2649
2792
|
}
|
|
2650
2793
|
function ue(r, e) {
|
|
2651
2794
|
return r << 32 - e | r >>> e;
|
|
2652
2795
|
}
|
|
2653
|
-
const
|
|
2654
|
-
function
|
|
2796
|
+
const lr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
2797
|
+
function dr(r) {
|
|
2655
2798
|
return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
|
|
2656
2799
|
}
|
|
2657
|
-
function
|
|
2800
|
+
function ur(r) {
|
|
2658
2801
|
for (let e = 0; e < r.length; e++)
|
|
2659
|
-
r[e] =
|
|
2802
|
+
r[e] = dr(r[e]);
|
|
2660
2803
|
return r;
|
|
2661
2804
|
}
|
|
2662
|
-
const
|
|
2663
|
-
function
|
|
2664
|
-
if (
|
|
2805
|
+
const Dt = lr ? (r) => r : ur, os = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", hr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
|
|
2806
|
+
function $e(r) {
|
|
2807
|
+
if (q(r), os)
|
|
2665
2808
|
return r.toHex();
|
|
2666
2809
|
let e = "";
|
|
2667
2810
|
for (let s = 0; s < r.length; s++)
|
|
2668
|
-
e +=
|
|
2811
|
+
e += hr[r[s]];
|
|
2669
2812
|
return e;
|
|
2670
2813
|
}
|
|
2671
2814
|
const fe = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
2672
|
-
function
|
|
2815
|
+
function Mt(r) {
|
|
2673
2816
|
if (r >= fe._0 && r <= fe._9)
|
|
2674
2817
|
return r - fe._0;
|
|
2675
2818
|
if (r >= fe.A && r <= fe.F)
|
|
@@ -2677,17 +2820,17 @@ function Lt(r) {
|
|
|
2677
2820
|
if (r >= fe.a && r <= fe.f)
|
|
2678
2821
|
return r - (fe.a - 10);
|
|
2679
2822
|
}
|
|
2680
|
-
function
|
|
2823
|
+
function qe(r) {
|
|
2681
2824
|
if (typeof r != "string")
|
|
2682
2825
|
throw new Error("hex string expected, got " + typeof r);
|
|
2683
|
-
if (
|
|
2826
|
+
if (os)
|
|
2684
2827
|
return Uint8Array.fromHex(r);
|
|
2685
2828
|
const e = r.length, s = e / 2;
|
|
2686
2829
|
if (e % 2)
|
|
2687
2830
|
throw new Error("hex string expected, got unpadded hex of length " + e);
|
|
2688
2831
|
const t = new Uint8Array(s);
|
|
2689
2832
|
for (let n = 0, o = 0; n < s; n++, o += 2) {
|
|
2690
|
-
const i =
|
|
2833
|
+
const i = Mt(r.charCodeAt(o)), a = Mt(r.charCodeAt(o + 1));
|
|
2691
2834
|
if (i === void 0 || a === void 0) {
|
|
2692
2835
|
const c = r[o] + r[o + 1];
|
|
2693
2836
|
throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + o);
|
|
@@ -2696,11 +2839,11 @@ function We(r) {
|
|
|
2696
2839
|
}
|
|
2697
2840
|
return t;
|
|
2698
2841
|
}
|
|
2699
|
-
function
|
|
2842
|
+
function Se(...r) {
|
|
2700
2843
|
let e = 0;
|
|
2701
2844
|
for (let t = 0; t < r.length; t++) {
|
|
2702
2845
|
const n = r[t];
|
|
2703
|
-
|
|
2846
|
+
q(n), e += n.length;
|
|
2704
2847
|
}
|
|
2705
2848
|
const s = new Uint8Array(e);
|
|
2706
2849
|
for (let t = 0, n = 0; t < r.length; t++) {
|
|
@@ -2709,47 +2852,47 @@ function ve(...r) {
|
|
|
2709
2852
|
}
|
|
2710
2853
|
return s;
|
|
2711
2854
|
}
|
|
2712
|
-
function
|
|
2855
|
+
function is(r, e = {}) {
|
|
2713
2856
|
const s = (n, o) => r(o).update(n).digest(), t = r(void 0);
|
|
2714
2857
|
return s.outputLen = t.outputLen, s.blockLen = t.blockLen, s.create = (n) => r(n), Object.assign(s, e), Object.freeze(s);
|
|
2715
2858
|
}
|
|
2716
|
-
function
|
|
2859
|
+
function as(r = 32) {
|
|
2717
2860
|
const e = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
2718
2861
|
if (typeof (e == null ? void 0 : e.getRandomValues) != "function")
|
|
2719
2862
|
throw new Error("crypto.getRandomValues must be defined");
|
|
2720
2863
|
return e.getRandomValues(new Uint8Array(r));
|
|
2721
2864
|
}
|
|
2722
|
-
const
|
|
2865
|
+
const pr = (r) => ({
|
|
2723
2866
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
|
|
2724
2867
|
});
|
|
2725
|
-
function
|
|
2868
|
+
function fr(r, e, s) {
|
|
2726
2869
|
return r & e ^ ~r & s;
|
|
2727
2870
|
}
|
|
2728
|
-
function
|
|
2871
|
+
function _r(r, e, s) {
|
|
2729
2872
|
return r & e ^ r & s ^ e & s;
|
|
2730
2873
|
}
|
|
2731
|
-
class
|
|
2874
|
+
class xr {
|
|
2732
2875
|
constructor(e, s, t, n) {
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2876
|
+
T(this, "blockLen");
|
|
2877
|
+
T(this, "outputLen");
|
|
2878
|
+
T(this, "padOffset");
|
|
2879
|
+
T(this, "isLE");
|
|
2737
2880
|
// For partial updates less than block size
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view =
|
|
2881
|
+
T(this, "buffer");
|
|
2882
|
+
T(this, "view");
|
|
2883
|
+
T(this, "finished", !1);
|
|
2884
|
+
T(this, "length", 0);
|
|
2885
|
+
T(this, "pos", 0);
|
|
2886
|
+
T(this, "destroyed", !1);
|
|
2887
|
+
this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Qe(this.buffer);
|
|
2745
2888
|
}
|
|
2746
2889
|
update(e) {
|
|
2747
|
-
|
|
2890
|
+
Oe(this), q(e);
|
|
2748
2891
|
const { view: s, buffer: t, blockLen: n } = this, o = e.length;
|
|
2749
2892
|
for (let i = 0; i < o; ) {
|
|
2750
2893
|
const a = Math.min(n - this.pos, o - i);
|
|
2751
2894
|
if (a === n) {
|
|
2752
|
-
const c =
|
|
2895
|
+
const c = Qe(e);
|
|
2753
2896
|
for (; n <= o - i; i += n)
|
|
2754
2897
|
this.process(c, i);
|
|
2755
2898
|
continue;
|
|
@@ -2759,14 +2902,14 @@ class _r {
|
|
|
2759
2902
|
return this.length += e.length, this.roundClean(), this;
|
|
2760
2903
|
}
|
|
2761
2904
|
digestInto(e) {
|
|
2762
|
-
|
|
2905
|
+
Oe(this), ns(e, this), this.finished = !0;
|
|
2763
2906
|
const { buffer: s, view: t, blockLen: n, isLE: o } = this;
|
|
2764
2907
|
let { pos: i } = this;
|
|
2765
|
-
s[i++] = 128,
|
|
2908
|
+
s[i++] = 128, Ce(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
|
|
2766
2909
|
for (let h = i; h < n; h++)
|
|
2767
2910
|
s[h] = 0;
|
|
2768
2911
|
t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
|
|
2769
|
-
const a =
|
|
2912
|
+
const a = Qe(e), c = this.outputLen;
|
|
2770
2913
|
if (c % 4)
|
|
2771
2914
|
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
2772
2915
|
const l = c / 4, u = this.get();
|
|
@@ -2799,20 +2942,20 @@ const we = /* @__PURE__ */ Uint32Array.from([
|
|
|
2799
2942
|
2600822924,
|
|
2800
2943
|
528734635,
|
|
2801
2944
|
1541459225
|
|
2802
|
-
]),
|
|
2803
|
-
function xr(r, e = !1) {
|
|
2804
|
-
return e ? { h: Number(r & Be), l: Number(r >> Dt & Be) } : { h: Number(r >> Dt & Be) | 0, l: Number(r & Be) | 0 };
|
|
2805
|
-
}
|
|
2945
|
+
]), Ue = /* @__PURE__ */ BigInt(2 ** 32 - 1), $t = /* @__PURE__ */ BigInt(32);
|
|
2806
2946
|
function gr(r, e = !1) {
|
|
2947
|
+
return e ? { h: Number(r & Ue), l: Number(r >> $t & Ue) } : { h: Number(r >> $t & Ue) | 0, l: Number(r & Ue) | 0 };
|
|
2948
|
+
}
|
|
2949
|
+
function mr(r, e = !1) {
|
|
2807
2950
|
const s = r.length;
|
|
2808
2951
|
let t = new Uint32Array(s), n = new Uint32Array(s);
|
|
2809
2952
|
for (let o = 0; o < s; o++) {
|
|
2810
|
-
const { h: i, l: a } =
|
|
2953
|
+
const { h: i, l: a } = gr(r[o], e);
|
|
2811
2954
|
[t[o], n[o]] = [i, a];
|
|
2812
2955
|
}
|
|
2813
2956
|
return [t, n];
|
|
2814
2957
|
}
|
|
2815
|
-
const
|
|
2958
|
+
const wr = (r, e, s) => r << s | e >>> 32 - s, yr = (r, e, s) => e << s | r >>> 32 - s, br = (r, e, s) => e << s - 32 | r >>> 64 - s, Sr = (r, e, s) => r << s - 32 | e >>> 64 - s, vr = /* @__PURE__ */ Uint32Array.from([
|
|
2816
2959
|
1116352408,
|
|
2817
2960
|
1899447441,
|
|
2818
2961
|
3049323471,
|
|
@@ -2878,7 +3021,7 @@ const mr = (r, e, s) => r << s | e >>> 32 - s, wr = (r, e, s) => e << s | r >>>
|
|
|
2878
3021
|
3204031479,
|
|
2879
3022
|
3329325298
|
|
2880
3023
|
]), ye = /* @__PURE__ */ new Uint32Array(64);
|
|
2881
|
-
class
|
|
3024
|
+
class Er extends xr {
|
|
2882
3025
|
constructor(e) {
|
|
2883
3026
|
super(64, e, 8, !1);
|
|
2884
3027
|
}
|
|
@@ -2894,132 +3037,132 @@ class Sr extends _r {
|
|
|
2894
3037
|
for (let h = 0; h < 16; h++, s += 4)
|
|
2895
3038
|
ye[h] = e.getUint32(s, !1);
|
|
2896
3039
|
for (let h = 16; h < 64; h++) {
|
|
2897
|
-
const _ = ye[h - 15], f = ye[h - 2], w = ue(_, 7) ^ ue(_, 18) ^ _ >>> 3,
|
|
2898
|
-
ye[h] =
|
|
3040
|
+
const _ = ye[h - 15], f = ye[h - 2], w = ue(_, 7) ^ ue(_, 18) ^ _ >>> 3, E = ue(f, 17) ^ ue(f, 19) ^ f >>> 10;
|
|
3041
|
+
ye[h] = E + ye[h - 7] + w + ye[h - 16] | 0;
|
|
2899
3042
|
}
|
|
2900
3043
|
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: u } = this;
|
|
2901
3044
|
for (let h = 0; h < 64; h++) {
|
|
2902
|
-
const _ = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), f = u + _ +
|
|
2903
|
-
u = l, l = c, c = a, a = i + f | 0, i = o, o = n, n = t, t = f +
|
|
3045
|
+
const _ = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), f = u + _ + fr(a, c, l) + vr[h] + ye[h] | 0, E = (ue(t, 2) ^ ue(t, 13) ^ ue(t, 22)) + _r(t, n, o) | 0;
|
|
3046
|
+
u = l, l = c, c = a, a = i + f | 0, i = o, o = n, n = t, t = f + E | 0;
|
|
2904
3047
|
}
|
|
2905
3048
|
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);
|
|
2906
3049
|
}
|
|
2907
3050
|
roundClean() {
|
|
2908
|
-
|
|
3051
|
+
Ce(ye);
|
|
2909
3052
|
}
|
|
2910
3053
|
destroy() {
|
|
2911
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0),
|
|
3054
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), Ce(this.buffer);
|
|
2912
3055
|
}
|
|
2913
3056
|
}
|
|
2914
|
-
class
|
|
3057
|
+
class Ir extends Er {
|
|
2915
3058
|
constructor() {
|
|
2916
3059
|
super(32);
|
|
2917
3060
|
// We cannot use array here since array allows indexing by variable
|
|
2918
3061
|
// which means optimizer/compiler cannot use registers.
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
const
|
|
2930
|
-
() => new
|
|
2931
|
-
/* @__PURE__ */
|
|
3062
|
+
T(this, "A", we[0] | 0);
|
|
3063
|
+
T(this, "B", we[1] | 0);
|
|
3064
|
+
T(this, "C", we[2] | 0);
|
|
3065
|
+
T(this, "D", we[3] | 0);
|
|
3066
|
+
T(this, "E", we[4] | 0);
|
|
3067
|
+
T(this, "F", we[5] | 0);
|
|
3068
|
+
T(this, "G", we[6] | 0);
|
|
3069
|
+
T(this, "H", we[7] | 0);
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
const Ar = /* @__PURE__ */ is(
|
|
3073
|
+
() => new Ir(),
|
|
3074
|
+
/* @__PURE__ */ pr(1)
|
|
2932
3075
|
);
|
|
2933
3076
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2934
|
-
const
|
|
2935
|
-
function
|
|
3077
|
+
const ft = /* @__PURE__ */ BigInt(0), lt = /* @__PURE__ */ BigInt(1);
|
|
3078
|
+
function Ke(r, e = "") {
|
|
2936
3079
|
if (typeof r != "boolean") {
|
|
2937
3080
|
const s = e && `"${e}" `;
|
|
2938
3081
|
throw new Error(s + "expected boolean, got type=" + typeof r);
|
|
2939
3082
|
}
|
|
2940
3083
|
return r;
|
|
2941
3084
|
}
|
|
2942
|
-
function
|
|
3085
|
+
function cs(r) {
|
|
2943
3086
|
if (typeof r == "bigint") {
|
|
2944
|
-
if (!
|
|
3087
|
+
if (!Ge(r))
|
|
2945
3088
|
throw new Error("positive bigint expected, got " + r);
|
|
2946
3089
|
} else
|
|
2947
3090
|
me(r);
|
|
2948
3091
|
return r;
|
|
2949
3092
|
}
|
|
2950
|
-
function
|
|
2951
|
-
const e =
|
|
3093
|
+
function He(r) {
|
|
3094
|
+
const e = cs(r).toString(16);
|
|
2952
3095
|
return e.length & 1 ? "0" + e : e;
|
|
2953
3096
|
}
|
|
2954
|
-
function
|
|
3097
|
+
function ls(r) {
|
|
2955
3098
|
if (typeof r != "string")
|
|
2956
3099
|
throw new Error("hex string expected, got " + typeof r);
|
|
2957
|
-
return r === "" ?
|
|
3100
|
+
return r === "" ? ft : BigInt("0x" + r);
|
|
2958
3101
|
}
|
|
2959
|
-
function
|
|
2960
|
-
return
|
|
3102
|
+
function je(r) {
|
|
3103
|
+
return ls($e(r));
|
|
2961
3104
|
}
|
|
2962
|
-
function
|
|
2963
|
-
return
|
|
3105
|
+
function ds(r) {
|
|
3106
|
+
return ls($e(Tr(q(r)).reverse()));
|
|
2964
3107
|
}
|
|
2965
|
-
function
|
|
2966
|
-
me(e), r =
|
|
2967
|
-
const s =
|
|
3108
|
+
function _t(r, e) {
|
|
3109
|
+
me(e), r = cs(r);
|
|
3110
|
+
const s = qe(r.toString(16).padStart(e * 2, "0"));
|
|
2968
3111
|
if (s.length !== e)
|
|
2969
3112
|
throw new Error("number too large");
|
|
2970
3113
|
return s;
|
|
2971
3114
|
}
|
|
2972
|
-
function
|
|
2973
|
-
return
|
|
3115
|
+
function us(r, e) {
|
|
3116
|
+
return _t(r, e).reverse();
|
|
2974
3117
|
}
|
|
2975
3118
|
function Tr(r) {
|
|
2976
3119
|
return Uint8Array.from(r);
|
|
2977
3120
|
}
|
|
2978
|
-
const
|
|
2979
|
-
function
|
|
2980
|
-
return
|
|
3121
|
+
const Ge = (r) => typeof r == "bigint" && ft <= r;
|
|
3122
|
+
function Rr(r, e, s) {
|
|
3123
|
+
return Ge(r) && Ge(e) && Ge(s) && e <= r && r < s;
|
|
2981
3124
|
}
|
|
2982
|
-
function
|
|
2983
|
-
if (!
|
|
3125
|
+
function kr(r, e, s, t) {
|
|
3126
|
+
if (!Rr(e, s, t))
|
|
2984
3127
|
throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
|
|
2985
3128
|
}
|
|
2986
|
-
function
|
|
3129
|
+
function Pr(r) {
|
|
2987
3130
|
let e;
|
|
2988
|
-
for (e = 0; r >
|
|
3131
|
+
for (e = 0; r > ft; r >>= lt, e += 1)
|
|
2989
3132
|
;
|
|
2990
3133
|
return e;
|
|
2991
3134
|
}
|
|
2992
|
-
const
|
|
2993
|
-
function
|
|
3135
|
+
const xt = (r) => (lt << BigInt(r)) - lt;
|
|
3136
|
+
function Or(r, e, s) {
|
|
2994
3137
|
if (me(r, "hashLen"), me(e, "qByteLen"), typeof s != "function")
|
|
2995
3138
|
throw new Error("hmacFn must be a function");
|
|
2996
3139
|
const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
|
|
2997
3140
|
let c = t(r), l = t(r), u = 0;
|
|
2998
3141
|
const h = () => {
|
|
2999
3142
|
c.fill(1), l.fill(0), u = 0;
|
|
3000
|
-
}, _ = (...y) => s(l,
|
|
3143
|
+
}, _ = (...y) => s(l, Se(c, ...y)), f = (y = n) => {
|
|
3001
3144
|
l = _(o, y), c = _(), y.length !== 0 && (l = _(i, y), c = _());
|
|
3002
3145
|
}, w = () => {
|
|
3003
3146
|
if (u++ >= a)
|
|
3004
3147
|
throw new Error("drbg: tried max amount of iterations");
|
|
3005
3148
|
let y = 0;
|
|
3006
|
-
const
|
|
3149
|
+
const R = [];
|
|
3007
3150
|
for (; y < e; ) {
|
|
3008
3151
|
c = _();
|
|
3009
3152
|
const N = c.slice();
|
|
3010
|
-
|
|
3153
|
+
R.push(N), y += c.length;
|
|
3011
3154
|
}
|
|
3012
|
-
return
|
|
3155
|
+
return Se(...R);
|
|
3013
3156
|
};
|
|
3014
|
-
return (y,
|
|
3157
|
+
return (y, R) => {
|
|
3015
3158
|
h(), f(y);
|
|
3016
3159
|
let N;
|
|
3017
|
-
for (; !(N =
|
|
3160
|
+
for (; !(N = R(w())); )
|
|
3018
3161
|
f();
|
|
3019
3162
|
return h(), N;
|
|
3020
3163
|
};
|
|
3021
3164
|
}
|
|
3022
|
-
function
|
|
3165
|
+
function gt(r, e = {}, s = {}) {
|
|
3023
3166
|
if (!r || typeof r != "object")
|
|
3024
3167
|
throw new Error("expected valid options object");
|
|
3025
3168
|
function t(o, i, a) {
|
|
@@ -3033,7 +3176,7 @@ function _t(r, e = {}, s = {}) {
|
|
|
3033
3176
|
const n = (o, i) => Object.entries(o).forEach(([a, c]) => t(a, c, i));
|
|
3034
3177
|
n(e, !1), n(s, !0);
|
|
3035
3178
|
}
|
|
3036
|
-
function
|
|
3179
|
+
function Bt(r) {
|
|
3037
3180
|
const e = /* @__PURE__ */ new WeakMap();
|
|
3038
3181
|
return (s, ...t) => {
|
|
3039
3182
|
const n = e.get(s);
|
|
@@ -3044,7 +3187,7 @@ function Mt(r) {
|
|
|
3044
3187
|
};
|
|
3045
3188
|
}
|
|
3046
3189
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3047
|
-
const ne = /* @__PURE__ */ BigInt(0),
|
|
3190
|
+
const ne = /* @__PURE__ */ BigInt(0), te = /* @__PURE__ */ BigInt(1), Ae = /* @__PURE__ */ BigInt(2), hs = /* @__PURE__ */ BigInt(3), ps = /* @__PURE__ */ BigInt(4), fs = /* @__PURE__ */ BigInt(5), Cr = /* @__PURE__ */ BigInt(7), _s = /* @__PURE__ */ BigInt(8), Nr = /* @__PURE__ */ BigInt(9), xs = /* @__PURE__ */ BigInt(16);
|
|
3048
3191
|
function le(r, e) {
|
|
3049
3192
|
const s = r % e;
|
|
3050
3193
|
return s >= ne ? s : e + s;
|
|
@@ -3055,80 +3198,80 @@ function ae(r, e, s) {
|
|
|
3055
3198
|
t *= t, t %= s;
|
|
3056
3199
|
return t;
|
|
3057
3200
|
}
|
|
3058
|
-
function
|
|
3201
|
+
function Ut(r, e) {
|
|
3059
3202
|
if (r === ne)
|
|
3060
3203
|
throw new Error("invert: expected non-zero number");
|
|
3061
3204
|
if (e <= ne)
|
|
3062
3205
|
throw new Error("invert: expected positive modulus, got " + e);
|
|
3063
|
-
let s = le(r, e), t = e, n = ne, o =
|
|
3206
|
+
let s = le(r, e), t = e, n = ne, o = te;
|
|
3064
3207
|
for (; s !== ne; ) {
|
|
3065
3208
|
const a = t / s, c = t % s, l = n - o * a;
|
|
3066
3209
|
t = s, s = c, n = o, o = l;
|
|
3067
3210
|
}
|
|
3068
|
-
if (t !==
|
|
3211
|
+
if (t !== te)
|
|
3069
3212
|
throw new Error("invert: does not exist");
|
|
3070
3213
|
return le(n, e);
|
|
3071
3214
|
}
|
|
3072
|
-
function
|
|
3215
|
+
function mt(r, e, s) {
|
|
3073
3216
|
if (!r.eql(r.sqr(e), s))
|
|
3074
3217
|
throw new Error("Cannot find square root");
|
|
3075
3218
|
}
|
|
3076
|
-
function
|
|
3077
|
-
const s = (r.ORDER +
|
|
3078
|
-
return
|
|
3219
|
+
function gs(r, e) {
|
|
3220
|
+
const s = (r.ORDER + te) / ps, t = r.pow(e, s);
|
|
3221
|
+
return mt(r, t, e), t;
|
|
3079
3222
|
}
|
|
3080
|
-
function
|
|
3081
|
-
const s = (r.ORDER -
|
|
3082
|
-
return
|
|
3223
|
+
function Lr(r, e) {
|
|
3224
|
+
const s = (r.ORDER - fs) / _s, t = r.mul(e, Ae), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, Ae), n), a = r.mul(o, r.sub(i, r.ONE));
|
|
3225
|
+
return mt(r, a, e), a;
|
|
3083
3226
|
}
|
|
3084
|
-
function
|
|
3085
|
-
const e =
|
|
3227
|
+
function Dr(r) {
|
|
3228
|
+
const e = Ye(r), s = ms(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Cr) / xs;
|
|
3086
3229
|
return (a, c) => {
|
|
3087
3230
|
let l = a.pow(c, i), u = a.mul(l, t);
|
|
3088
3231
|
const h = a.mul(l, n), _ = a.mul(l, o), f = a.eql(a.sqr(u), c), w = a.eql(a.sqr(h), c);
|
|
3089
3232
|
l = a.cmov(l, u, f), u = a.cmov(_, h, w);
|
|
3090
|
-
const
|
|
3091
|
-
return
|
|
3233
|
+
const E = a.eql(a.sqr(u), c), y = a.cmov(l, u, E);
|
|
3234
|
+
return mt(a, y, c), y;
|
|
3092
3235
|
};
|
|
3093
3236
|
}
|
|
3094
|
-
function
|
|
3095
|
-
if (r <
|
|
3237
|
+
function ms(r) {
|
|
3238
|
+
if (r < hs)
|
|
3096
3239
|
throw new Error("sqrt is not defined for small field");
|
|
3097
|
-
let e = r -
|
|
3098
|
-
for (; e %
|
|
3099
|
-
e /=
|
|
3100
|
-
let t =
|
|
3101
|
-
const n =
|
|
3102
|
-
for (;
|
|
3240
|
+
let e = r - te, s = 0;
|
|
3241
|
+
for (; e % Ae === ne; )
|
|
3242
|
+
e /= Ae, s++;
|
|
3243
|
+
let t = Ae;
|
|
3244
|
+
const n = Ye(r);
|
|
3245
|
+
for (; Ht(n, t) === 1; )
|
|
3103
3246
|
if (t++ > 1e3)
|
|
3104
3247
|
throw new Error("Cannot find square root: probably non-prime P");
|
|
3105
3248
|
if (s === 1)
|
|
3106
|
-
return
|
|
3249
|
+
return gs;
|
|
3107
3250
|
let o = n.pow(t, e);
|
|
3108
|
-
const i = (e +
|
|
3251
|
+
const i = (e + te) / Ae;
|
|
3109
3252
|
return function(c, l) {
|
|
3110
3253
|
if (c.is0(l))
|
|
3111
3254
|
return l;
|
|
3112
|
-
if (
|
|
3255
|
+
if (Ht(c, l) !== 1)
|
|
3113
3256
|
throw new Error("Cannot find square root");
|
|
3114
3257
|
let u = s, h = c.mul(c.ONE, o), _ = c.pow(l, e), f = c.pow(l, i);
|
|
3115
3258
|
for (; !c.eql(_, c.ONE); ) {
|
|
3116
3259
|
if (c.is0(_))
|
|
3117
3260
|
return c.ZERO;
|
|
3118
|
-
let w = 1,
|
|
3119
|
-
for (; !c.eql(
|
|
3120
|
-
if (w++,
|
|
3261
|
+
let w = 1, E = c.sqr(_);
|
|
3262
|
+
for (; !c.eql(E, c.ONE); )
|
|
3263
|
+
if (w++, E = c.sqr(E), w === u)
|
|
3121
3264
|
throw new Error("Cannot find square root");
|
|
3122
|
-
const y =
|
|
3123
|
-
u = w, h = c.sqr(
|
|
3265
|
+
const y = te << BigInt(u - w - 1), R = c.pow(h, y);
|
|
3266
|
+
u = w, h = c.sqr(R), _ = c.mul(_, h), f = c.mul(f, R);
|
|
3124
3267
|
}
|
|
3125
3268
|
return f;
|
|
3126
3269
|
};
|
|
3127
3270
|
}
|
|
3128
|
-
function
|
|
3129
|
-
return r %
|
|
3271
|
+
function Mr(r) {
|
|
3272
|
+
return r % ps === hs ? gs : r % _s === fs ? Lr : r % xs === Nr ? Dr(r) : ms(r);
|
|
3130
3273
|
}
|
|
3131
|
-
const
|
|
3274
|
+
const $r = [
|
|
3132
3275
|
"create",
|
|
3133
3276
|
"isValid",
|
|
3134
3277
|
"is0",
|
|
@@ -3147,59 +3290,59 @@ const Mr = [
|
|
|
3147
3290
|
"mulN",
|
|
3148
3291
|
"sqrN"
|
|
3149
3292
|
];
|
|
3150
|
-
function
|
|
3293
|
+
function Br(r) {
|
|
3151
3294
|
const e = {
|
|
3152
3295
|
ORDER: "bigint",
|
|
3153
3296
|
BYTES: "number",
|
|
3154
3297
|
BITS: "number"
|
|
3155
|
-
}, s =
|
|
3156
|
-
return
|
|
3298
|
+
}, s = $r.reduce((t, n) => (t[n] = "function", t), e);
|
|
3299
|
+
return gt(r, s), r;
|
|
3157
3300
|
}
|
|
3158
|
-
function
|
|
3301
|
+
function Ur(r, e, s) {
|
|
3159
3302
|
if (s < ne)
|
|
3160
3303
|
throw new Error("invalid exponent, negatives unsupported");
|
|
3161
3304
|
if (s === ne)
|
|
3162
3305
|
return r.ONE;
|
|
3163
|
-
if (s ===
|
|
3306
|
+
if (s === te)
|
|
3164
3307
|
return e;
|
|
3165
3308
|
let t = r.ONE, n = e;
|
|
3166
3309
|
for (; s > ne; )
|
|
3167
|
-
s &
|
|
3310
|
+
s & te && (t = r.mul(t, n)), n = r.sqr(n), s >>= te;
|
|
3168
3311
|
return t;
|
|
3169
3312
|
}
|
|
3170
|
-
function
|
|
3313
|
+
function ws(r, e, s = !1) {
|
|
3171
3314
|
const t = new Array(e.length).fill(s ? r.ZERO : void 0), n = e.reduce((i, a, c) => r.is0(a) ? i : (t[c] = i, r.mul(i, a)), r.ONE), o = r.inv(n);
|
|
3172
3315
|
return e.reduceRight((i, a, c) => r.is0(a) ? i : (t[c] = r.mul(i, t[c]), r.mul(i, a)), o), t;
|
|
3173
3316
|
}
|
|
3174
|
-
function
|
|
3175
|
-
const s = (r.ORDER -
|
|
3317
|
+
function Ht(r, e) {
|
|
3318
|
+
const s = (r.ORDER - te) / Ae, t = r.pow(e, s), n = r.eql(t, r.ONE), o = r.eql(t, r.ZERO), i = r.eql(t, r.neg(r.ONE));
|
|
3176
3319
|
if (!n && !o && !i)
|
|
3177
3320
|
throw new Error("invalid Legendre symbol result");
|
|
3178
3321
|
return n ? 1 : o ? 0 : -1;
|
|
3179
3322
|
}
|
|
3180
|
-
function
|
|
3323
|
+
function Hr(r, e) {
|
|
3181
3324
|
e !== void 0 && me(e);
|
|
3182
3325
|
const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
|
|
3183
3326
|
return { nBitLength: s, nByteLength: t };
|
|
3184
3327
|
}
|
|
3185
|
-
class
|
|
3328
|
+
class Fr {
|
|
3186
3329
|
constructor(e, s = {}) {
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3330
|
+
T(this, "ORDER");
|
|
3331
|
+
T(this, "BITS");
|
|
3332
|
+
T(this, "BYTES");
|
|
3333
|
+
T(this, "isLE");
|
|
3334
|
+
T(this, "ZERO", ne);
|
|
3335
|
+
T(this, "ONE", te);
|
|
3336
|
+
T(this, "_lengths");
|
|
3337
|
+
T(this, "_sqrt");
|
|
3195
3338
|
// cached sqrt
|
|
3196
|
-
|
|
3339
|
+
T(this, "_mod");
|
|
3197
3340
|
var i;
|
|
3198
3341
|
if (e <= ne)
|
|
3199
3342
|
throw new Error("invalid field: expected ORDER > 0, got " + e);
|
|
3200
3343
|
let t;
|
|
3201
3344
|
this.isLE = !1, s != null && typeof s == "object" && (typeof s.BITS == "number" && (t = s.BITS), typeof s.sqrt == "function" && (this.sqrt = s.sqrt), typeof s.isLE == "boolean" && (this.isLE = s.isLE), s.allowedLengths && (this._lengths = (i = s.allowedLengths) == null ? void 0 : i.slice()), typeof s.modFromBytes == "boolean" && (this._mod = s.modFromBytes));
|
|
3202
|
-
const { nBitLength: n, nByteLength: o } =
|
|
3345
|
+
const { nBitLength: n, nByteLength: o } = Hr(e, t);
|
|
3203
3346
|
if (o > 2048)
|
|
3204
3347
|
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
3205
3348
|
this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
|
|
@@ -3220,7 +3363,7 @@ class Hr {
|
|
|
3220
3363
|
return !this.is0(e) && this.isValid(e);
|
|
3221
3364
|
}
|
|
3222
3365
|
isOdd(e) {
|
|
3223
|
-
return (e &
|
|
3366
|
+
return (e & te) === te;
|
|
3224
3367
|
}
|
|
3225
3368
|
neg(e) {
|
|
3226
3369
|
return le(-e, this.ORDER);
|
|
@@ -3241,10 +3384,10 @@ class Hr {
|
|
|
3241
3384
|
return le(e * s, this.ORDER);
|
|
3242
3385
|
}
|
|
3243
3386
|
pow(e, s) {
|
|
3244
|
-
return
|
|
3387
|
+
return Ur(this, e, s);
|
|
3245
3388
|
}
|
|
3246
3389
|
div(e, s) {
|
|
3247
|
-
return le(e *
|
|
3390
|
+
return le(e * Ut(s, this.ORDER), this.ORDER);
|
|
3248
3391
|
}
|
|
3249
3392
|
// Same as above, but doesn't normalize
|
|
3250
3393
|
sqrN(e) {
|
|
@@ -3260,16 +3403,16 @@ class Hr {
|
|
|
3260
3403
|
return e * s;
|
|
3261
3404
|
}
|
|
3262
3405
|
inv(e) {
|
|
3263
|
-
return
|
|
3406
|
+
return Ut(e, this.ORDER);
|
|
3264
3407
|
}
|
|
3265
3408
|
sqrt(e) {
|
|
3266
|
-
return this._sqrt || (this._sqrt =
|
|
3409
|
+
return this._sqrt || (this._sqrt = Mr(this.ORDER)), this._sqrt(this, e);
|
|
3267
3410
|
}
|
|
3268
3411
|
toBytes(e) {
|
|
3269
|
-
return this.isLE ?
|
|
3412
|
+
return this.isLE ? us(e, this.BYTES) : _t(e, this.BYTES);
|
|
3270
3413
|
}
|
|
3271
3414
|
fromBytes(e, s = !1) {
|
|
3272
|
-
|
|
3415
|
+
q(e);
|
|
3273
3416
|
const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
|
|
3274
3417
|
if (t) {
|
|
3275
3418
|
if (!t.includes(e.length) || e.length > n)
|
|
@@ -3279,14 +3422,14 @@ class Hr {
|
|
|
3279
3422
|
}
|
|
3280
3423
|
if (e.length !== n)
|
|
3281
3424
|
throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
|
|
3282
|
-
let c = o ?
|
|
3425
|
+
let c = o ? ds(e) : je(e);
|
|
3283
3426
|
if (a && (c = le(c, i)), !s && !this.isValid(c))
|
|
3284
3427
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
3285
3428
|
return c;
|
|
3286
3429
|
}
|
|
3287
3430
|
// TODO: we don't need it here, move out to separate fn
|
|
3288
3431
|
invertBatch(e) {
|
|
3289
|
-
return
|
|
3432
|
+
return ws(this, e);
|
|
3290
3433
|
}
|
|
3291
3434
|
// We can't move this out because Fp6, Fp12 implement it
|
|
3292
3435
|
// and it's unclear what to return in there.
|
|
@@ -3294,74 +3437,74 @@ class Hr {
|
|
|
3294
3437
|
return t ? s : e;
|
|
3295
3438
|
}
|
|
3296
3439
|
}
|
|
3297
|
-
function
|
|
3298
|
-
return new
|
|
3440
|
+
function Ye(r, e = {}) {
|
|
3441
|
+
return new Fr(r, e);
|
|
3299
3442
|
}
|
|
3300
|
-
function
|
|
3443
|
+
function ys(r) {
|
|
3301
3444
|
if (typeof r != "bigint")
|
|
3302
3445
|
throw new Error("field order must be bigint");
|
|
3303
3446
|
const e = r.toString(2).length;
|
|
3304
3447
|
return Math.ceil(e / 8);
|
|
3305
3448
|
}
|
|
3306
|
-
function
|
|
3307
|
-
const e =
|
|
3449
|
+
function bs(r) {
|
|
3450
|
+
const e = ys(r);
|
|
3308
3451
|
return e + Math.ceil(e / 2);
|
|
3309
3452
|
}
|
|
3310
|
-
function
|
|
3311
|
-
|
|
3312
|
-
const t = r.length, n =
|
|
3453
|
+
function Gr(r, e, s = !1) {
|
|
3454
|
+
q(r);
|
|
3455
|
+
const t = r.length, n = ys(e), o = bs(e);
|
|
3313
3456
|
if (t < 16 || t < o || t > 1024)
|
|
3314
3457
|
throw new Error("expected " + o + "-1024 bytes of input, got " + t);
|
|
3315
|
-
const i = s ?
|
|
3316
|
-
return s ?
|
|
3458
|
+
const i = s ? ds(r) : je(r), a = le(i, e - te) + te;
|
|
3459
|
+
return s ? us(a, n) : _t(a, n);
|
|
3317
3460
|
}
|
|
3318
3461
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3319
|
-
const
|
|
3320
|
-
function
|
|
3462
|
+
const Ne = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1);
|
|
3463
|
+
function Ve(r, e) {
|
|
3321
3464
|
const s = e.negate();
|
|
3322
3465
|
return r ? s : e;
|
|
3323
3466
|
}
|
|
3324
|
-
function
|
|
3325
|
-
const s =
|
|
3467
|
+
function Ft(r, e) {
|
|
3468
|
+
const s = ws(r.Fp, e.map((t) => t.Z));
|
|
3326
3469
|
return e.map((t, n) => r.fromAffine(t.toAffine(s[n])));
|
|
3327
3470
|
}
|
|
3328
|
-
function
|
|
3471
|
+
function Ss(r, e) {
|
|
3329
3472
|
if (!Number.isSafeInteger(r) || r <= 0 || r > e)
|
|
3330
3473
|
throw new Error("invalid window size, expected [1.." + e + "], got W=" + r);
|
|
3331
3474
|
}
|
|
3332
|
-
function
|
|
3333
|
-
|
|
3334
|
-
const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o =
|
|
3475
|
+
function et(r, e) {
|
|
3476
|
+
Ss(r, e);
|
|
3477
|
+
const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = xt(r), i = BigInt(r);
|
|
3335
3478
|
return { windows: s, windowSize: t, mask: o, maxNumber: n, shiftBy: i };
|
|
3336
3479
|
}
|
|
3337
|
-
function
|
|
3480
|
+
function Gt(r, e, s) {
|
|
3338
3481
|
const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
|
|
3339
3482
|
let a = Number(r & n), c = r >> i;
|
|
3340
3483
|
a > t && (a -= o, c += Te);
|
|
3341
3484
|
const l = e * t, u = l + Math.abs(a) - 1, h = a === 0, _ = a < 0, f = e % 2 !== 0;
|
|
3342
3485
|
return { nextN: c, offset: u, isZero: h, isNeg: _, isNegF: f, offsetF: l };
|
|
3343
3486
|
}
|
|
3344
|
-
const
|
|
3345
|
-
function
|
|
3346
|
-
return
|
|
3487
|
+
const tt = /* @__PURE__ */ new WeakMap(), vs = /* @__PURE__ */ new WeakMap();
|
|
3488
|
+
function st(r) {
|
|
3489
|
+
return vs.get(r) || 1;
|
|
3347
3490
|
}
|
|
3348
|
-
function
|
|
3349
|
-
if (r !==
|
|
3491
|
+
function Wt(r) {
|
|
3492
|
+
if (r !== Ne)
|
|
3350
3493
|
throw new Error("invalid wNAF");
|
|
3351
3494
|
}
|
|
3352
|
-
class
|
|
3495
|
+
class Wr {
|
|
3353
3496
|
// Parametrized with a given Point class (not individual point)
|
|
3354
3497
|
constructor(e, s) {
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3498
|
+
T(this, "BASE");
|
|
3499
|
+
T(this, "ZERO");
|
|
3500
|
+
T(this, "Fn");
|
|
3501
|
+
T(this, "bits");
|
|
3359
3502
|
this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
|
|
3360
3503
|
}
|
|
3361
3504
|
// non-const time multiplication ladder
|
|
3362
3505
|
_unsafeLadder(e, s, t = this.ZERO) {
|
|
3363
3506
|
let n = e;
|
|
3364
|
-
for (; s >
|
|
3507
|
+
for (; s > Ne; )
|
|
3365
3508
|
s & Te && (t = t.add(n)), n = n.double(), s >>= Te;
|
|
3366
3509
|
return t;
|
|
3367
3510
|
}
|
|
@@ -3378,7 +3521,7 @@ class Gr {
|
|
|
3378
3521
|
* @returns precomputed point tables flattened to a single array
|
|
3379
3522
|
*/
|
|
3380
3523
|
precomputeWindow(e, s) {
|
|
3381
|
-
const { windows: t, windowSize: n } =
|
|
3524
|
+
const { windows: t, windowSize: n } = et(s, this.bits), o = [];
|
|
3382
3525
|
let i = e, a = i;
|
|
3383
3526
|
for (let c = 0; c < t; c++) {
|
|
3384
3527
|
a = i, o.push(a);
|
|
@@ -3398,12 +3541,12 @@ class Gr {
|
|
|
3398
3541
|
if (!this.Fn.isValid(t))
|
|
3399
3542
|
throw new Error("invalid scalar");
|
|
3400
3543
|
let n = this.ZERO, o = this.BASE;
|
|
3401
|
-
const i =
|
|
3544
|
+
const i = et(e, this.bits);
|
|
3402
3545
|
for (let a = 0; a < i.windows; a++) {
|
|
3403
|
-
const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF: _, offsetF: f } =
|
|
3404
|
-
t = c, u ? o = o.add(
|
|
3546
|
+
const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF: _, offsetF: f } = Gt(t, a, i);
|
|
3547
|
+
t = c, u ? o = o.add(Ve(_, s[f])) : n = n.add(Ve(h, s[l]));
|
|
3405
3548
|
}
|
|
3406
|
-
return
|
|
3549
|
+
return Wt(t), { p: n, f: o };
|
|
3407
3550
|
}
|
|
3408
3551
|
/**
|
|
3409
3552
|
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
@@ -3411,81 +3554,81 @@ class Gr {
|
|
|
3411
3554
|
* @returns point
|
|
3412
3555
|
*/
|
|
3413
3556
|
wNAFUnsafe(e, s, t, n = this.ZERO) {
|
|
3414
|
-
const o =
|
|
3415
|
-
for (let i = 0; i < o.windows && t !==
|
|
3416
|
-
const { nextN: a, offset: c, isZero: l, isNeg: u } =
|
|
3557
|
+
const o = et(e, this.bits);
|
|
3558
|
+
for (let i = 0; i < o.windows && t !== Ne; i++) {
|
|
3559
|
+
const { nextN: a, offset: c, isZero: l, isNeg: u } = Gt(t, i, o);
|
|
3417
3560
|
if (t = a, !l) {
|
|
3418
3561
|
const h = s[c];
|
|
3419
3562
|
n = n.add(u ? h.negate() : h);
|
|
3420
3563
|
}
|
|
3421
3564
|
}
|
|
3422
|
-
return
|
|
3565
|
+
return Wt(t), n;
|
|
3423
3566
|
}
|
|
3424
3567
|
getPrecomputes(e, s, t) {
|
|
3425
|
-
let n =
|
|
3426
|
-
return n || (n = this.precomputeWindow(s, e), e !== 1 && (typeof t == "function" && (n = t(n)),
|
|
3568
|
+
let n = tt.get(s);
|
|
3569
|
+
return n || (n = this.precomputeWindow(s, e), e !== 1 && (typeof t == "function" && (n = t(n)), tt.set(s, n))), n;
|
|
3427
3570
|
}
|
|
3428
3571
|
cached(e, s, t) {
|
|
3429
|
-
const n =
|
|
3572
|
+
const n = st(e);
|
|
3430
3573
|
return this.wNAF(n, this.getPrecomputes(n, e, t), s);
|
|
3431
3574
|
}
|
|
3432
3575
|
unsafe(e, s, t, n) {
|
|
3433
|
-
const o =
|
|
3576
|
+
const o = st(e);
|
|
3434
3577
|
return o === 1 ? this._unsafeLadder(e, s, n) : this.wNAFUnsafe(o, this.getPrecomputes(o, e, t), s, n);
|
|
3435
3578
|
}
|
|
3436
3579
|
// We calculate precomputes for elliptic curve point multiplication
|
|
3437
3580
|
// using windowed method. This specifies window size and
|
|
3438
3581
|
// stores precomputed values. Usually only base point would be precomputed.
|
|
3439
3582
|
createCache(e, s) {
|
|
3440
|
-
|
|
3583
|
+
Ss(s, this.bits), vs.set(e, s), tt.delete(e);
|
|
3441
3584
|
}
|
|
3442
3585
|
hasCache(e) {
|
|
3443
|
-
return
|
|
3586
|
+
return st(e) !== 1;
|
|
3444
3587
|
}
|
|
3445
3588
|
}
|
|
3446
|
-
function
|
|
3589
|
+
function qr(r, e, s, t) {
|
|
3447
3590
|
let n = e, o = r.ZERO, i = r.ZERO;
|
|
3448
|
-
for (; s >
|
|
3591
|
+
for (; s > Ne || t > Ne; )
|
|
3449
3592
|
s & Te && (o = o.add(n)), t & Te && (i = i.add(n)), n = n.double(), s >>= Te, t >>= Te;
|
|
3450
3593
|
return { p1: o, p2: i };
|
|
3451
3594
|
}
|
|
3452
|
-
function
|
|
3595
|
+
function qt(r, e, s) {
|
|
3453
3596
|
if (e) {
|
|
3454
3597
|
if (e.ORDER !== r)
|
|
3455
3598
|
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
3456
|
-
return
|
|
3599
|
+
return Br(e), e;
|
|
3457
3600
|
} else
|
|
3458
|
-
return
|
|
3601
|
+
return Ye(r, { isLE: s });
|
|
3459
3602
|
}
|
|
3460
|
-
function
|
|
3603
|
+
function Kr(r, e, s = {}, t) {
|
|
3461
3604
|
if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
|
|
3462
3605
|
throw new Error(`expected valid ${r} CURVE object`);
|
|
3463
3606
|
for (const c of ["p", "n", "h"]) {
|
|
3464
3607
|
const l = e[c];
|
|
3465
|
-
if (!(typeof l == "bigint" && l >
|
|
3608
|
+
if (!(typeof l == "bigint" && l > Ne))
|
|
3466
3609
|
throw new Error(`CURVE.${c} must be positive bigint`);
|
|
3467
3610
|
}
|
|
3468
|
-
const n =
|
|
3611
|
+
const n = qt(e.p, s.Fp, t), o = qt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
|
|
3469
3612
|
for (const c of a)
|
|
3470
3613
|
if (!n.isValid(e[c]))
|
|
3471
3614
|
throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
|
|
3472
3615
|
return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
|
|
3473
3616
|
}
|
|
3474
|
-
function
|
|
3617
|
+
function Vr(r, e) {
|
|
3475
3618
|
return function(t) {
|
|
3476
3619
|
const n = r(t);
|
|
3477
3620
|
return { secretKey: n, publicKey: e(n) };
|
|
3478
3621
|
};
|
|
3479
3622
|
}
|
|
3480
|
-
class
|
|
3623
|
+
class Es {
|
|
3481
3624
|
constructor(e, s) {
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
if (
|
|
3625
|
+
T(this, "oHash");
|
|
3626
|
+
T(this, "iHash");
|
|
3627
|
+
T(this, "blockLen");
|
|
3628
|
+
T(this, "outputLen");
|
|
3629
|
+
T(this, "finished", !1);
|
|
3630
|
+
T(this, "destroyed", !1);
|
|
3631
|
+
if (rs(e), q(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
|
|
3489
3632
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
3490
3633
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
3491
3634
|
const t = this.blockLen, n = new Uint8Array(t);
|
|
@@ -3495,13 +3638,13 @@ class vs {
|
|
|
3495
3638
|
this.iHash.update(n), this.oHash = e.create();
|
|
3496
3639
|
for (let o = 0; o < n.length; o++)
|
|
3497
3640
|
n[o] ^= 106;
|
|
3498
|
-
this.oHash.update(n),
|
|
3641
|
+
this.oHash.update(n), Ce(n);
|
|
3499
3642
|
}
|
|
3500
3643
|
update(e) {
|
|
3501
|
-
return
|
|
3644
|
+
return Oe(this), this.iHash.update(e), this;
|
|
3502
3645
|
}
|
|
3503
3646
|
digestInto(e) {
|
|
3504
|
-
|
|
3647
|
+
Oe(this), q(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
|
|
3505
3648
|
}
|
|
3506
3649
|
digest() {
|
|
3507
3650
|
const e = new Uint8Array(this.oHash.outputLen);
|
|
@@ -3519,39 +3662,39 @@ class vs {
|
|
|
3519
3662
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
3520
3663
|
}
|
|
3521
3664
|
}
|
|
3522
|
-
const
|
|
3523
|
-
|
|
3665
|
+
const Is = (r, e, s) => new Es(r, e).update(s).digest();
|
|
3666
|
+
Is.create = (r, e) => new Es(r, e);
|
|
3524
3667
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3525
|
-
const
|
|
3526
|
-
function
|
|
3527
|
-
const [[t, n], [o, i]] = e, a =
|
|
3668
|
+
const Kt = (r, e) => (r + (r >= 0 ? e : -e) / As) / e;
|
|
3669
|
+
function zr(r, e, s) {
|
|
3670
|
+
const [[t, n], [o, i]] = e, a = Kt(i * r, s), c = Kt(-n * r, s);
|
|
3528
3671
|
let l = r - a * t - c * o, u = -a * n - c * i;
|
|
3529
3672
|
const h = l < xe, _ = u < xe;
|
|
3530
3673
|
h && (l = -l), _ && (u = -u);
|
|
3531
|
-
const f =
|
|
3674
|
+
const f = xt(Math.ceil(Pr(s) / 2)) + Pe;
|
|
3532
3675
|
if (l < xe || l >= f || u < xe || u >= f)
|
|
3533
3676
|
throw new Error("splitScalar (endomorphism): failed, k=" + r);
|
|
3534
3677
|
return { k1neg: h, k1: l, k2neg: _, k2: u };
|
|
3535
3678
|
}
|
|
3536
|
-
function
|
|
3679
|
+
function dt(r) {
|
|
3537
3680
|
if (!["compact", "recovered", "der"].includes(r))
|
|
3538
3681
|
throw new Error('Signature format must be "compact", "recovered", or "der"');
|
|
3539
3682
|
return r;
|
|
3540
3683
|
}
|
|
3541
|
-
function
|
|
3684
|
+
function rt(r, e) {
|
|
3542
3685
|
const s = {};
|
|
3543
3686
|
for (let t of Object.keys(e))
|
|
3544
3687
|
s[t] = r[t] === void 0 ? e[t] : r[t];
|
|
3545
|
-
return
|
|
3688
|
+
return Ke(s.lowS, "lowS"), Ke(s.prehash, "prehash"), s.format !== void 0 && dt(s.format), s;
|
|
3546
3689
|
}
|
|
3547
|
-
class
|
|
3690
|
+
class jr extends Error {
|
|
3548
3691
|
constructor(e = "") {
|
|
3549
3692
|
super(e);
|
|
3550
3693
|
}
|
|
3551
3694
|
}
|
|
3552
3695
|
const be = {
|
|
3553
3696
|
// asn.1 DER encoding utils
|
|
3554
|
-
Err:
|
|
3697
|
+
Err: jr,
|
|
3555
3698
|
// Basic building block is TLV (Tag-Length-Value)
|
|
3556
3699
|
_tlv: {
|
|
3557
3700
|
encode: (r, e) => {
|
|
@@ -3560,11 +3703,11 @@ const be = {
|
|
|
3560
3703
|
throw new s("tlv.encode: wrong tag");
|
|
3561
3704
|
if (e.length & 1)
|
|
3562
3705
|
throw new s("tlv.encode: unpadded data");
|
|
3563
|
-
const t = e.length / 2, n =
|
|
3706
|
+
const t = e.length / 2, n = He(t);
|
|
3564
3707
|
if (n.length / 2 & 128)
|
|
3565
3708
|
throw new s("tlv.encode: long form length too big");
|
|
3566
|
-
const o = t > 127 ?
|
|
3567
|
-
return
|
|
3709
|
+
const o = t > 127 ? He(n.length / 2 | 128) : "";
|
|
3710
|
+
return He(r) + o + n + e;
|
|
3568
3711
|
},
|
|
3569
3712
|
// v - value, l - left bytes (unparsed)
|
|
3570
3713
|
decode(r, e) {
|
|
@@ -3609,7 +3752,7 @@ const be = {
|
|
|
3609
3752
|
const { Err: e } = be;
|
|
3610
3753
|
if (r < xe)
|
|
3611
3754
|
throw new e("integer: negative integers are not allowed");
|
|
3612
|
-
let s =
|
|
3755
|
+
let s = He(r);
|
|
3613
3756
|
if (Number.parseInt(s[0], 16) & 8 && (s = "00" + s), s.length & 1)
|
|
3614
3757
|
throw new e("unexpected DER parsing assertion: unpadded hex");
|
|
3615
3758
|
return s;
|
|
@@ -3620,11 +3763,11 @@ const be = {
|
|
|
3620
3763
|
throw new e("invalid signature integer: negative");
|
|
3621
3764
|
if (r[0] === 0 && !(r[1] & 128))
|
|
3622
3765
|
throw new e("invalid signature integer: unnecessary leading zero");
|
|
3623
|
-
return
|
|
3766
|
+
return je(r);
|
|
3624
3767
|
}
|
|
3625
3768
|
},
|
|
3626
3769
|
toSig(r) {
|
|
3627
|
-
const { Err: e, _int: s, _tlv: t } = be, n =
|
|
3770
|
+
const { Err: e, _int: s, _tlv: t } = be, n = q(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
|
|
3628
3771
|
if (i.length)
|
|
3629
3772
|
throw new e("invalid signature: left bytes after parsing");
|
|
3630
3773
|
const { v: a, l: c } = t.decode(2, o), { v: l, l: u } = t.decode(2, c);
|
|
@@ -3636,12 +3779,12 @@ const be = {
|
|
|
3636
3779
|
const { _tlv: e, _int: s } = be, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
|
|
3637
3780
|
return e.encode(48, o);
|
|
3638
3781
|
}
|
|
3639
|
-
}, xe = BigInt(0),
|
|
3640
|
-
function
|
|
3641
|
-
const s =
|
|
3782
|
+
}, xe = BigInt(0), Pe = BigInt(1), As = BigInt(2), Fe = BigInt(3), Yr = BigInt(4);
|
|
3783
|
+
function Xr(r, e = {}) {
|
|
3784
|
+
const s = Kr("weierstrass", r, e), { Fp: t, Fn: n } = s;
|
|
3642
3785
|
let o = s.CURVE;
|
|
3643
3786
|
const { h: i, n: a } = o;
|
|
3644
|
-
|
|
3787
|
+
gt(e, {}, {
|
|
3645
3788
|
allowInfinityPoint: "boolean",
|
|
3646
3789
|
clearCofactor: "function",
|
|
3647
3790
|
isTorsionFree: "function",
|
|
@@ -3652,87 +3795,87 @@ function Yr(r, e = {}) {
|
|
|
3652
3795
|
const { endo: c } = e;
|
|
3653
3796
|
if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
|
|
3654
3797
|
throw new Error('invalid endo: expected "beta": bigint and "basises": array');
|
|
3655
|
-
const l =
|
|
3798
|
+
const l = Rs(t, n);
|
|
3656
3799
|
function u() {
|
|
3657
3800
|
if (!t.isOdd)
|
|
3658
3801
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
3659
3802
|
}
|
|
3660
3803
|
function h(I, x, g) {
|
|
3661
|
-
const { x: v, y:
|
|
3662
|
-
if (
|
|
3804
|
+
const { x: v, y: A } = x.toAffine(), C = t.toBytes(v);
|
|
3805
|
+
if (Ke(g, "isCompressed"), g) {
|
|
3663
3806
|
u();
|
|
3664
|
-
const
|
|
3665
|
-
return
|
|
3807
|
+
const O = !t.isOdd(A);
|
|
3808
|
+
return Se(Ts(O), C);
|
|
3666
3809
|
} else
|
|
3667
|
-
return
|
|
3810
|
+
return Se(Uint8Array.of(4), C, t.toBytes(A));
|
|
3668
3811
|
}
|
|
3669
3812
|
function _(I) {
|
|
3670
|
-
|
|
3671
|
-
const { publicKey: x, publicKeyUncompressed: g } = l, v = I.length,
|
|
3672
|
-
if (v === x && (
|
|
3673
|
-
const
|
|
3674
|
-
if (!t.isValid(
|
|
3813
|
+
q(I, void 0, "Point");
|
|
3814
|
+
const { publicKey: x, publicKeyUncompressed: g } = l, v = I.length, A = I[0], C = I.subarray(1);
|
|
3815
|
+
if (v === x && (A === 2 || A === 3)) {
|
|
3816
|
+
const O = t.fromBytes(C);
|
|
3817
|
+
if (!t.isValid(O))
|
|
3675
3818
|
throw new Error("bad point: is not on curve, wrong x");
|
|
3676
|
-
const
|
|
3677
|
-
let
|
|
3819
|
+
const L = E(O);
|
|
3820
|
+
let P;
|
|
3678
3821
|
try {
|
|
3679
|
-
|
|
3680
|
-
} catch (
|
|
3681
|
-
const
|
|
3682
|
-
throw new Error("bad point: is not on curve, sqrt error" +
|
|
3822
|
+
P = t.sqrt(L);
|
|
3823
|
+
} catch (Y) {
|
|
3824
|
+
const W = Y instanceof Error ? ": " + Y.message : "";
|
|
3825
|
+
throw new Error("bad point: is not on curve, sqrt error" + W);
|
|
3683
3826
|
}
|
|
3684
3827
|
u();
|
|
3685
|
-
const
|
|
3686
|
-
return (
|
|
3687
|
-
} else if (v === g &&
|
|
3688
|
-
const
|
|
3689
|
-
if (!y(
|
|
3828
|
+
const D = t.isOdd(P);
|
|
3829
|
+
return (A & 1) === 1 !== D && (P = t.neg(P)), { x: O, y: P };
|
|
3830
|
+
} else if (v === g && A === 4) {
|
|
3831
|
+
const O = t.BYTES, L = t.fromBytes(C.subarray(0, O)), P = t.fromBytes(C.subarray(O, O * 2));
|
|
3832
|
+
if (!y(L, P))
|
|
3690
3833
|
throw new Error("bad point: is not on curve");
|
|
3691
|
-
return { x:
|
|
3834
|
+
return { x: L, y: P };
|
|
3692
3835
|
} else
|
|
3693
3836
|
throw new Error(`bad point: got length ${v}, expected compressed=${x} or uncompressed=${g}`);
|
|
3694
3837
|
}
|
|
3695
3838
|
const f = e.toBytes || h, w = e.fromBytes || _;
|
|
3696
|
-
function
|
|
3839
|
+
function E(I) {
|
|
3697
3840
|
const x = t.sqr(I), g = t.mul(x, I);
|
|
3698
3841
|
return t.add(t.add(g, t.mul(I, o.a)), o.b);
|
|
3699
3842
|
}
|
|
3700
3843
|
function y(I, x) {
|
|
3701
|
-
const g = t.sqr(x), v =
|
|
3844
|
+
const g = t.sqr(x), v = E(I);
|
|
3702
3845
|
return t.eql(g, v);
|
|
3703
3846
|
}
|
|
3704
3847
|
if (!y(o.Gx, o.Gy))
|
|
3705
3848
|
throw new Error("bad curve params: generator point");
|
|
3706
|
-
const
|
|
3707
|
-
if (t.is0(t.add(
|
|
3849
|
+
const R = t.mul(t.pow(o.a, Fe), Yr), N = t.mul(t.sqr(o.b), BigInt(27));
|
|
3850
|
+
if (t.is0(t.add(R, N)))
|
|
3708
3851
|
throw new Error("bad curve params: a or b");
|
|
3709
|
-
function
|
|
3852
|
+
function F(I, x, g = !1) {
|
|
3710
3853
|
if (!t.isValid(x) || g && t.is0(x))
|
|
3711
3854
|
throw new Error(`bad point coordinate ${I}`);
|
|
3712
3855
|
return x;
|
|
3713
3856
|
}
|
|
3714
|
-
function
|
|
3715
|
-
if (!(I instanceof
|
|
3857
|
+
function M(I) {
|
|
3858
|
+
if (!(I instanceof z))
|
|
3716
3859
|
throw new Error("Weierstrass Point expected");
|
|
3717
3860
|
}
|
|
3718
|
-
function
|
|
3861
|
+
function V(I) {
|
|
3719
3862
|
if (!c || !c.basises)
|
|
3720
3863
|
throw new Error("no endo");
|
|
3721
|
-
return
|
|
3864
|
+
return zr(I, c.basises, n.ORDER);
|
|
3722
3865
|
}
|
|
3723
|
-
const
|
|
3724
|
-
const { X: g, Y: v, Z:
|
|
3725
|
-
if (t.eql(
|
|
3866
|
+
const G = Bt((I, x) => {
|
|
3867
|
+
const { X: g, Y: v, Z: A } = I;
|
|
3868
|
+
if (t.eql(A, t.ONE))
|
|
3726
3869
|
return { x: g, y: v };
|
|
3727
|
-
const
|
|
3728
|
-
x == null && (x =
|
|
3729
|
-
const
|
|
3730
|
-
if (
|
|
3870
|
+
const C = I.is0();
|
|
3871
|
+
x == null && (x = C ? t.ONE : t.inv(A));
|
|
3872
|
+
const O = t.mul(g, x), L = t.mul(v, x), P = t.mul(A, x);
|
|
3873
|
+
if (C)
|
|
3731
3874
|
return { x: t.ZERO, y: t.ZERO };
|
|
3732
|
-
if (!t.eql(
|
|
3875
|
+
if (!t.eql(P, t.ONE))
|
|
3733
3876
|
throw new Error("invZ was invalid");
|
|
3734
|
-
return { x:
|
|
3735
|
-
}),
|
|
3877
|
+
return { x: O, y: L };
|
|
3878
|
+
}), J = Bt((I) => {
|
|
3736
3879
|
if (I.is0()) {
|
|
3737
3880
|
if (e.allowInfinityPoint && !t.is0(I.Y))
|
|
3738
3881
|
return;
|
|
@@ -3747,16 +3890,16 @@ function Yr(r, e = {}) {
|
|
|
3747
3890
|
throw new Error("bad point: not in prime-order subgroup");
|
|
3748
3891
|
return !0;
|
|
3749
3892
|
});
|
|
3750
|
-
function
|
|
3751
|
-
return g = new
|
|
3893
|
+
function H(I, x, g, v, A) {
|
|
3894
|
+
return g = new z(t.mul(g.X, I), g.Y, g.Z), x = Ve(v, x), g = Ve(A, g), x.add(g);
|
|
3752
3895
|
}
|
|
3753
|
-
const
|
|
3896
|
+
const S = class S {
|
|
3754
3897
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3755
3898
|
constructor(x, g, v) {
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
this.X =
|
|
3899
|
+
T(this, "X");
|
|
3900
|
+
T(this, "Y");
|
|
3901
|
+
T(this, "Z");
|
|
3902
|
+
this.X = F("x", x), this.Y = F("y", g, !0), this.Z = F("z", v), Object.freeze(this);
|
|
3760
3903
|
}
|
|
3761
3904
|
static CURVE() {
|
|
3762
3905
|
return o;
|
|
@@ -3766,16 +3909,16 @@ function Yr(r, e = {}) {
|
|
|
3766
3909
|
const { x: g, y: v } = x || {};
|
|
3767
3910
|
if (!x || !t.isValid(g) || !t.isValid(v))
|
|
3768
3911
|
throw new Error("invalid affine point");
|
|
3769
|
-
if (x instanceof
|
|
3912
|
+
if (x instanceof S)
|
|
3770
3913
|
throw new Error("projective point not allowed");
|
|
3771
|
-
return t.is0(g) && t.is0(v) ?
|
|
3914
|
+
return t.is0(g) && t.is0(v) ? S.ZERO : new S(g, v, t.ONE);
|
|
3772
3915
|
}
|
|
3773
3916
|
static fromBytes(x) {
|
|
3774
|
-
const g =
|
|
3917
|
+
const g = S.fromAffine(w(q(x, void 0, "point")));
|
|
3775
3918
|
return g.assertValidity(), g;
|
|
3776
3919
|
}
|
|
3777
3920
|
static fromHex(x) {
|
|
3778
|
-
return
|
|
3921
|
+
return S.fromBytes(qe(x));
|
|
3779
3922
|
}
|
|
3780
3923
|
get x() {
|
|
3781
3924
|
return this.toAffine().x;
|
|
@@ -3790,12 +3933,12 @@ function Yr(r, e = {}) {
|
|
|
3790
3933
|
* @returns
|
|
3791
3934
|
*/
|
|
3792
3935
|
precompute(x = 8, g = !0) {
|
|
3793
|
-
return
|
|
3936
|
+
return b.createCache(this, x), g || this.multiply(Fe), this;
|
|
3794
3937
|
}
|
|
3795
3938
|
// TODO: return `this`
|
|
3796
3939
|
/** A point on curve is valid if it conforms to equation. */
|
|
3797
3940
|
assertValidity() {
|
|
3798
|
-
|
|
3941
|
+
J(this);
|
|
3799
3942
|
}
|
|
3800
3943
|
hasEvenY() {
|
|
3801
3944
|
const { y: x } = this.toAffine();
|
|
@@ -3805,42 +3948,42 @@ function Yr(r, e = {}) {
|
|
|
3805
3948
|
}
|
|
3806
3949
|
/** Compare one point to another. */
|
|
3807
3950
|
equals(x) {
|
|
3808
|
-
|
|
3809
|
-
const { X: g, Y: v, Z:
|
|
3810
|
-
return
|
|
3951
|
+
M(x);
|
|
3952
|
+
const { X: g, Y: v, Z: A } = this, { X: C, Y: O, Z: L } = x, P = t.eql(t.mul(g, L), t.mul(C, A)), D = t.eql(t.mul(v, L), t.mul(O, A));
|
|
3953
|
+
return P && D;
|
|
3811
3954
|
}
|
|
3812
3955
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
3813
3956
|
negate() {
|
|
3814
|
-
return new
|
|
3957
|
+
return new S(this.X, t.neg(this.Y), this.Z);
|
|
3815
3958
|
}
|
|
3816
3959
|
// Renes-Costello-Batina exception-free doubling formula.
|
|
3817
3960
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
3818
3961
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
3819
3962
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
3820
3963
|
double() {
|
|
3821
|
-
const { a: x, b: g } = o, v = t.mul(g,
|
|
3822
|
-
let
|
|
3823
|
-
return
|
|
3964
|
+
const { a: x, b: g } = o, v = t.mul(g, Fe), { X: A, Y: C, Z: O } = this;
|
|
3965
|
+
let L = t.ZERO, P = t.ZERO, D = t.ZERO, U = t.mul(A, A), Y = t.mul(C, C), W = t.mul(O, O), B = t.mul(A, C);
|
|
3966
|
+
return B = t.add(B, B), D = t.mul(A, O), D = t.add(D, D), L = t.mul(x, D), P = t.mul(v, W), P = t.add(L, P), L = t.sub(Y, P), P = t.add(Y, P), P = t.mul(L, P), L = t.mul(B, L), D = t.mul(v, D), W = t.mul(x, W), B = t.sub(U, W), B = t.mul(x, B), B = t.add(B, D), D = t.add(U, U), U = t.add(D, U), U = t.add(U, W), U = t.mul(U, B), P = t.add(P, U), W = t.mul(C, O), W = t.add(W, W), U = t.mul(W, B), L = t.sub(L, U), D = t.mul(W, Y), D = t.add(D, D), D = t.add(D, D), new S(L, P, D);
|
|
3824
3967
|
}
|
|
3825
3968
|
// Renes-Costello-Batina exception-free addition formula.
|
|
3826
3969
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
3827
3970
|
// https://eprint.iacr.org/2015/1060, algorithm 1
|
|
3828
3971
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
3829
3972
|
add(x) {
|
|
3830
|
-
|
|
3831
|
-
const { X: g, Y: v, Z:
|
|
3832
|
-
let
|
|
3833
|
-
const
|
|
3834
|
-
let
|
|
3835
|
-
oe = t.mul(oe,
|
|
3836
|
-
let Q = t.add(
|
|
3837
|
-
return
|
|
3973
|
+
M(x);
|
|
3974
|
+
const { X: g, Y: v, Z: A } = this, { X: C, Y: O, Z: L } = x;
|
|
3975
|
+
let P = t.ZERO, D = t.ZERO, U = t.ZERO;
|
|
3976
|
+
const Y = o.a, W = t.mul(o.b, Fe);
|
|
3977
|
+
let B = t.mul(g, C), X = t.mul(v, O), Z = t.mul(A, L), oe = t.add(g, v), K = t.add(C, O);
|
|
3978
|
+
oe = t.mul(oe, K), K = t.add(B, X), oe = t.sub(oe, K), K = t.add(g, A);
|
|
3979
|
+
let Q = t.add(C, L);
|
|
3980
|
+
return K = t.mul(K, Q), Q = t.add(B, Z), K = t.sub(K, Q), Q = t.add(v, A), P = t.add(O, L), Q = t.mul(Q, P), P = t.add(X, Z), Q = t.sub(Q, P), U = t.mul(Y, K), P = t.mul(W, Z), U = t.add(P, U), P = t.sub(X, U), U = t.add(X, U), D = t.mul(P, U), X = t.add(B, B), X = t.add(X, B), Z = t.mul(Y, Z), K = t.mul(W, K), X = t.add(X, Z), Z = t.sub(B, Z), Z = t.mul(Y, Z), K = t.add(K, Z), B = t.mul(X, K), D = t.add(D, B), B = t.mul(Q, K), P = t.mul(oe, P), P = t.sub(P, B), B = t.mul(oe, X), U = t.mul(Q, U), U = t.add(U, B), new S(P, D, U);
|
|
3838
3981
|
}
|
|
3839
3982
|
subtract(x) {
|
|
3840
3983
|
return this.add(x.negate());
|
|
3841
3984
|
}
|
|
3842
3985
|
is0() {
|
|
3843
|
-
return this.equals(
|
|
3986
|
+
return this.equals(S.ZERO);
|
|
3844
3987
|
}
|
|
3845
3988
|
/**
|
|
3846
3989
|
* Constant time multiplication.
|
|
@@ -3855,16 +3998,16 @@ function Yr(r, e = {}) {
|
|
|
3855
3998
|
const { endo: g } = e;
|
|
3856
3999
|
if (!n.isValidNot0(x))
|
|
3857
4000
|
throw new Error("invalid scalar: out of range");
|
|
3858
|
-
let v,
|
|
3859
|
-
const
|
|
4001
|
+
let v, A;
|
|
4002
|
+
const C = (O) => b.cached(this, O, (L) => Ft(S, L));
|
|
3860
4003
|
if (g) {
|
|
3861
|
-
const { k1neg:
|
|
3862
|
-
|
|
4004
|
+
const { k1neg: O, k1: L, k2neg: P, k2: D } = V(x), { p: U, f: Y } = C(L), { p: W, f: B } = C(D);
|
|
4005
|
+
A = Y.add(B), v = H(g.beta, U, W, O, P);
|
|
3863
4006
|
} else {
|
|
3864
|
-
const { p:
|
|
3865
|
-
v =
|
|
4007
|
+
const { p: O, f: L } = C(x);
|
|
4008
|
+
v = O, A = L;
|
|
3866
4009
|
}
|
|
3867
|
-
return
|
|
4010
|
+
return Ft(S, [v, A])[0];
|
|
3868
4011
|
}
|
|
3869
4012
|
/**
|
|
3870
4013
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -3876,23 +4019,23 @@ function Yr(r, e = {}) {
|
|
|
3876
4019
|
if (!n.isValid(x))
|
|
3877
4020
|
throw new Error("invalid scalar: out of range");
|
|
3878
4021
|
if (x === xe || v.is0())
|
|
3879
|
-
return
|
|
3880
|
-
if (x ===
|
|
4022
|
+
return S.ZERO;
|
|
4023
|
+
if (x === Pe)
|
|
3881
4024
|
return v;
|
|
3882
|
-
if (
|
|
4025
|
+
if (b.hasCache(this))
|
|
3883
4026
|
return this.multiply(x);
|
|
3884
4027
|
if (g) {
|
|
3885
|
-
const { k1neg:
|
|
3886
|
-
return
|
|
4028
|
+
const { k1neg: A, k1: C, k2neg: O, k2: L } = V(x), { p1: P, p2: D } = qr(S, v, C, L);
|
|
4029
|
+
return H(g.beta, P, D, A, O);
|
|
3887
4030
|
} else
|
|
3888
|
-
return
|
|
4031
|
+
return b.unsafe(v, x);
|
|
3889
4032
|
}
|
|
3890
4033
|
/**
|
|
3891
4034
|
* Converts Projective point to affine (x, y) coordinates.
|
|
3892
4035
|
* @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
|
|
3893
4036
|
*/
|
|
3894
4037
|
toAffine(x) {
|
|
3895
|
-
return
|
|
4038
|
+
return G(this, x);
|
|
3896
4039
|
}
|
|
3897
4040
|
/**
|
|
3898
4041
|
* Checks whether Point is free of torsion elements (is in prime subgroup).
|
|
@@ -3900,39 +4043,39 @@ function Yr(r, e = {}) {
|
|
|
3900
4043
|
*/
|
|
3901
4044
|
isTorsionFree() {
|
|
3902
4045
|
const { isTorsionFree: x } = e;
|
|
3903
|
-
return i ===
|
|
4046
|
+
return i === Pe ? !0 : x ? x(S, this) : b.unsafe(this, a).is0();
|
|
3904
4047
|
}
|
|
3905
4048
|
clearCofactor() {
|
|
3906
4049
|
const { clearCofactor: x } = e;
|
|
3907
|
-
return i ===
|
|
4050
|
+
return i === Pe ? this : x ? x(S, this) : this.multiplyUnsafe(i);
|
|
3908
4051
|
}
|
|
3909
4052
|
isSmallOrder() {
|
|
3910
4053
|
return this.multiplyUnsafe(i).is0();
|
|
3911
4054
|
}
|
|
3912
4055
|
toBytes(x = !0) {
|
|
3913
|
-
return
|
|
4056
|
+
return Ke(x, "isCompressed"), this.assertValidity(), f(S, this, x);
|
|
3914
4057
|
}
|
|
3915
4058
|
toHex(x = !0) {
|
|
3916
|
-
return
|
|
4059
|
+
return $e(this.toBytes(x));
|
|
3917
4060
|
}
|
|
3918
4061
|
toString() {
|
|
3919
4062
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
3920
4063
|
}
|
|
3921
4064
|
};
|
|
3922
4065
|
// base / generator point
|
|
3923
|
-
|
|
3924
|
-
|
|
4066
|
+
T(S, "BASE", new S(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
|
|
4067
|
+
T(S, "ZERO", new S(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
|
|
3925
4068
|
// math field
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
let
|
|
3929
|
-
const
|
|
3930
|
-
return
|
|
4069
|
+
T(S, "Fp", t), // scalar field
|
|
4070
|
+
T(S, "Fn", n);
|
|
4071
|
+
let z = S;
|
|
4072
|
+
const k = n.BITS, b = new Wr(z, e.endo ? Math.ceil(k / 2) : k);
|
|
4073
|
+
return z.BASE.precompute(8), z;
|
|
3931
4074
|
}
|
|
3932
|
-
function
|
|
4075
|
+
function Ts(r) {
|
|
3933
4076
|
return Uint8Array.of(r ? 2 : 3);
|
|
3934
4077
|
}
|
|
3935
|
-
function
|
|
4078
|
+
function Rs(r, e) {
|
|
3936
4079
|
return {
|
|
3937
4080
|
secretKey: e.BYTES,
|
|
3938
4081
|
publicKey: 1 + r.BYTES,
|
|
@@ -3942,7 +4085,7 @@ function Ts(r, e) {
|
|
|
3942
4085
|
};
|
|
3943
4086
|
}
|
|
3944
4087
|
function Jr(r, e = {}) {
|
|
3945
|
-
const { Fn: s } = r, t = e.randomBytes ||
|
|
4088
|
+
const { Fn: s } = r, t = e.randomBytes || as, n = Object.assign(Rs(r.Fp, s), { seed: bs(s.ORDER) });
|
|
3946
4089
|
function o(f) {
|
|
3947
4090
|
try {
|
|
3948
4091
|
const w = s.fromBytes(f);
|
|
@@ -3952,99 +4095,99 @@ function Jr(r, e = {}) {
|
|
|
3952
4095
|
}
|
|
3953
4096
|
}
|
|
3954
4097
|
function i(f, w) {
|
|
3955
|
-
const { publicKey:
|
|
4098
|
+
const { publicKey: E, publicKeyUncompressed: y } = n;
|
|
3956
4099
|
try {
|
|
3957
|
-
const
|
|
3958
|
-
return w === !0 &&
|
|
4100
|
+
const R = f.length;
|
|
4101
|
+
return w === !0 && R !== E || w === !1 && R !== y ? !1 : !!r.fromBytes(f);
|
|
3959
4102
|
} catch {
|
|
3960
4103
|
return !1;
|
|
3961
4104
|
}
|
|
3962
4105
|
}
|
|
3963
4106
|
function a(f = t(n.seed)) {
|
|
3964
|
-
return
|
|
4107
|
+
return Gr(q(f, n.seed, "seed"), s.ORDER);
|
|
3965
4108
|
}
|
|
3966
4109
|
function c(f, w = !0) {
|
|
3967
4110
|
return r.BASE.multiply(s.fromBytes(f)).toBytes(w);
|
|
3968
4111
|
}
|
|
3969
4112
|
function l(f) {
|
|
3970
|
-
const { secretKey: w, publicKey:
|
|
3971
|
-
if (!
|
|
4113
|
+
const { secretKey: w, publicKey: E, publicKeyUncompressed: y } = n;
|
|
4114
|
+
if (!pt(f) || "_lengths" in s && s._lengths || w === E)
|
|
3972
4115
|
return;
|
|
3973
|
-
const
|
|
3974
|
-
return
|
|
4116
|
+
const R = q(f, void 0, "key").length;
|
|
4117
|
+
return R === E || R === y;
|
|
3975
4118
|
}
|
|
3976
|
-
function u(f, w,
|
|
4119
|
+
function u(f, w, E = !0) {
|
|
3977
4120
|
if (l(f) === !0)
|
|
3978
4121
|
throw new Error("first arg must be private key");
|
|
3979
4122
|
if (l(w) === !1)
|
|
3980
4123
|
throw new Error("second arg must be public key");
|
|
3981
4124
|
const y = s.fromBytes(f);
|
|
3982
|
-
return r.fromBytes(w).multiply(y).toBytes(
|
|
4125
|
+
return r.fromBytes(w).multiply(y).toBytes(E);
|
|
3983
4126
|
}
|
|
3984
4127
|
const h = {
|
|
3985
4128
|
isValidSecretKey: o,
|
|
3986
4129
|
isValidPublicKey: i,
|
|
3987
4130
|
randomSecretKey: a
|
|
3988
|
-
}, _ =
|
|
4131
|
+
}, _ = Vr(a, c);
|
|
3989
4132
|
return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: _, Point: r, utils: h, lengths: n });
|
|
3990
4133
|
}
|
|
3991
|
-
function
|
|
3992
|
-
|
|
4134
|
+
function Zr(r, e, s = {}) {
|
|
4135
|
+
rs(e), gt(s, {}, {
|
|
3993
4136
|
hmac: "function",
|
|
3994
4137
|
lowS: "boolean",
|
|
3995
4138
|
randomBytes: "function",
|
|
3996
4139
|
bits2int: "function",
|
|
3997
4140
|
bits2int_modN: "function"
|
|
3998
4141
|
}), s = Object.assign({}, s);
|
|
3999
|
-
const t = s.randomBytes ||
|
|
4142
|
+
const t = s.randomBytes || as, n = s.hmac || ((x, g) => Is(e, x, g)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: u, getSharedSecret: h, utils: _, lengths: f } = Jr(r, s), w = {
|
|
4000
4143
|
prehash: !0,
|
|
4001
4144
|
lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
|
|
4002
4145
|
format: "compact",
|
|
4003
4146
|
extraEntropy: !1
|
|
4004
|
-
},
|
|
4147
|
+
}, E = a * As < o.ORDER;
|
|
4005
4148
|
function y(x) {
|
|
4006
|
-
const g = a >>
|
|
4149
|
+
const g = a >> Pe;
|
|
4007
4150
|
return x > g;
|
|
4008
4151
|
}
|
|
4009
|
-
function
|
|
4152
|
+
function R(x, g) {
|
|
4010
4153
|
if (!i.isValidNot0(g))
|
|
4011
4154
|
throw new Error(`invalid signature ${x}: out of range 1..Point.Fn.ORDER`);
|
|
4012
4155
|
return g;
|
|
4013
4156
|
}
|
|
4014
4157
|
function N() {
|
|
4015
|
-
if (
|
|
4158
|
+
if (E)
|
|
4016
4159
|
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
4017
4160
|
}
|
|
4018
|
-
function
|
|
4019
|
-
|
|
4020
|
-
const v = f.signature,
|
|
4021
|
-
return
|
|
4022
|
-
}
|
|
4023
|
-
class
|
|
4024
|
-
constructor(g, v,
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
if (this.r =
|
|
4029
|
-
if (N(), ![0, 1, 2, 3].includes(
|
|
4161
|
+
function F(x, g) {
|
|
4162
|
+
dt(g);
|
|
4163
|
+
const v = f.signature, A = g === "compact" ? v : g === "recovered" ? v + 1 : void 0;
|
|
4164
|
+
return q(x, A);
|
|
4165
|
+
}
|
|
4166
|
+
class M {
|
|
4167
|
+
constructor(g, v, A) {
|
|
4168
|
+
T(this, "r");
|
|
4169
|
+
T(this, "s");
|
|
4170
|
+
T(this, "recovery");
|
|
4171
|
+
if (this.r = R("r", g), this.s = R("s", v), A != null) {
|
|
4172
|
+
if (N(), ![0, 1, 2, 3].includes(A))
|
|
4030
4173
|
throw new Error("invalid recovery id");
|
|
4031
|
-
this.recovery =
|
|
4174
|
+
this.recovery = A;
|
|
4032
4175
|
}
|
|
4033
4176
|
Object.freeze(this);
|
|
4034
4177
|
}
|
|
4035
4178
|
static fromBytes(g, v = w.format) {
|
|
4036
|
-
|
|
4037
|
-
let
|
|
4179
|
+
F(g, v);
|
|
4180
|
+
let A;
|
|
4038
4181
|
if (v === "der") {
|
|
4039
|
-
const { r:
|
|
4040
|
-
return new
|
|
4182
|
+
const { r: P, s: D } = be.toSig(q(g));
|
|
4183
|
+
return new M(P, D);
|
|
4041
4184
|
}
|
|
4042
|
-
v === "recovered" && (
|
|
4043
|
-
const
|
|
4044
|
-
return new
|
|
4185
|
+
v === "recovered" && (A = g[0], v = "compact", g = g.subarray(1));
|
|
4186
|
+
const C = f.signature / 2, O = g.subarray(0, C), L = g.subarray(C, C * 2);
|
|
4187
|
+
return new M(i.fromBytes(O), i.fromBytes(L), A);
|
|
4045
4188
|
}
|
|
4046
4189
|
static fromHex(g, v) {
|
|
4047
|
-
return this.fromBytes(
|
|
4190
|
+
return this.fromBytes(qe(g), v);
|
|
4048
4191
|
}
|
|
4049
4192
|
assertRecovery() {
|
|
4050
4193
|
const { recovery: g } = this;
|
|
@@ -4053,96 +4196,96 @@ function Xr(r, e, s = {}) {
|
|
|
4053
4196
|
return g;
|
|
4054
4197
|
}
|
|
4055
4198
|
addRecoveryBit(g) {
|
|
4056
|
-
return new
|
|
4199
|
+
return new M(this.r, this.s, g);
|
|
4057
4200
|
}
|
|
4058
4201
|
recoverPublicKey(g) {
|
|
4059
|
-
const { r: v, s:
|
|
4060
|
-
if (!o.isValid(
|
|
4202
|
+
const { r: v, s: A } = this, C = this.assertRecovery(), O = C === 2 || C === 3 ? v + a : v;
|
|
4203
|
+
if (!o.isValid(O))
|
|
4061
4204
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
4062
|
-
const
|
|
4063
|
-
if (
|
|
4205
|
+
const L = o.toBytes(O), P = r.fromBytes(Se(Ts((C & 1) === 0), L)), D = i.inv(O), U = G(q(g, void 0, "msgHash")), Y = i.create(-U * D), W = i.create(A * D), B = r.BASE.multiplyUnsafe(Y).add(P.multiplyUnsafe(W));
|
|
4206
|
+
if (B.is0())
|
|
4064
4207
|
throw new Error("invalid recovery: point at infinify");
|
|
4065
|
-
return
|
|
4208
|
+
return B.assertValidity(), B;
|
|
4066
4209
|
}
|
|
4067
4210
|
// Signatures should be low-s, to prevent malleability.
|
|
4068
4211
|
hasHighS() {
|
|
4069
4212
|
return y(this.s);
|
|
4070
4213
|
}
|
|
4071
4214
|
toBytes(g = w.format) {
|
|
4072
|
-
if (
|
|
4073
|
-
return
|
|
4074
|
-
const { r: v, s:
|
|
4075
|
-
return g === "recovered" ? (N(),
|
|
4215
|
+
if (dt(g), g === "der")
|
|
4216
|
+
return qe(be.hexFromSig(this));
|
|
4217
|
+
const { r: v, s: A } = this, C = i.toBytes(v), O = i.toBytes(A);
|
|
4218
|
+
return g === "recovered" ? (N(), Se(Uint8Array.of(this.assertRecovery()), C, O)) : Se(C, O);
|
|
4076
4219
|
}
|
|
4077
4220
|
toHex(g) {
|
|
4078
|
-
return
|
|
4221
|
+
return $e(this.toBytes(g));
|
|
4079
4222
|
}
|
|
4080
4223
|
}
|
|
4081
|
-
const
|
|
4224
|
+
const V = s.bits2int || function(g) {
|
|
4082
4225
|
if (g.length > 8192)
|
|
4083
4226
|
throw new Error("input is too large");
|
|
4084
|
-
const v =
|
|
4085
|
-
return
|
|
4086
|
-
},
|
|
4087
|
-
return i.create(
|
|
4088
|
-
},
|
|
4089
|
-
function
|
|
4090
|
-
return
|
|
4091
|
-
}
|
|
4092
|
-
function
|
|
4093
|
-
return
|
|
4094
|
-
}
|
|
4095
|
-
function
|
|
4096
|
-
const { lowS:
|
|
4097
|
-
x =
|
|
4098
|
-
const
|
|
4099
|
-
if (!i.isValidNot0(
|
|
4227
|
+
const v = je(g), A = g.length * 8 - c;
|
|
4228
|
+
return A > 0 ? v >> BigInt(A) : v;
|
|
4229
|
+
}, G = s.bits2int_modN || function(g) {
|
|
4230
|
+
return i.create(V(g));
|
|
4231
|
+
}, J = xt(c);
|
|
4232
|
+
function H(x) {
|
|
4233
|
+
return kr("num < 2^" + c, x, xe, J), i.toBytes(x);
|
|
4234
|
+
}
|
|
4235
|
+
function z(x, g) {
|
|
4236
|
+
return q(x, void 0, "message"), g ? q(e(x), void 0, "prehashed message") : x;
|
|
4237
|
+
}
|
|
4238
|
+
function k(x, g, v) {
|
|
4239
|
+
const { lowS: A, prehash: C, extraEntropy: O } = rt(v, w);
|
|
4240
|
+
x = z(x, C);
|
|
4241
|
+
const L = G(x), P = i.fromBytes(g);
|
|
4242
|
+
if (!i.isValidNot0(P))
|
|
4100
4243
|
throw new Error("invalid private key");
|
|
4101
|
-
const
|
|
4102
|
-
if (
|
|
4103
|
-
const
|
|
4104
|
-
|
|
4105
|
-
}
|
|
4106
|
-
const
|
|
4107
|
-
function
|
|
4108
|
-
const X =
|
|
4244
|
+
const D = [H(P), H(L)];
|
|
4245
|
+
if (O != null && O !== !1) {
|
|
4246
|
+
const B = O === !0 ? t(f.secretKey) : O;
|
|
4247
|
+
D.push(q(B, void 0, "extraEntropy"));
|
|
4248
|
+
}
|
|
4249
|
+
const U = Se(...D), Y = L;
|
|
4250
|
+
function W(B) {
|
|
4251
|
+
const X = V(B);
|
|
4109
4252
|
if (!i.isValidNot0(X))
|
|
4110
4253
|
return;
|
|
4111
|
-
const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(),
|
|
4112
|
-
if (
|
|
4254
|
+
const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(), K = i.create(oe.x);
|
|
4255
|
+
if (K === xe)
|
|
4113
4256
|
return;
|
|
4114
|
-
const Q = i.create(Z * i.create(
|
|
4257
|
+
const Q = i.create(Z * i.create(Y + K * P));
|
|
4115
4258
|
if (Q === xe)
|
|
4116
4259
|
return;
|
|
4117
|
-
let
|
|
4118
|
-
return
|
|
4260
|
+
let St = (oe.x === K ? 0 : 2) | Number(oe.y & Pe), vt = Q;
|
|
4261
|
+
return A && y(Q) && (vt = i.neg(Q), St ^= 1), new M(K, vt, E ? void 0 : St);
|
|
4119
4262
|
}
|
|
4120
|
-
return { seed:
|
|
4263
|
+
return { seed: U, k2sig: W };
|
|
4121
4264
|
}
|
|
4122
|
-
function
|
|
4123
|
-
const { seed:
|
|
4124
|
-
return
|
|
4265
|
+
function b(x, g, v = {}) {
|
|
4266
|
+
const { seed: A, k2sig: C } = k(x, g, v);
|
|
4267
|
+
return Or(e.outputLen, i.BYTES, n)(A, C).toBytes(v.format);
|
|
4125
4268
|
}
|
|
4126
|
-
function
|
|
4127
|
-
const { lowS:
|
|
4128
|
-
if (v =
|
|
4129
|
-
const
|
|
4130
|
-
throw new Error("verify expects Uint8Array signature" +
|
|
4269
|
+
function S(x, g, v, A = {}) {
|
|
4270
|
+
const { lowS: C, prehash: O, format: L } = rt(A, w);
|
|
4271
|
+
if (v = q(v, void 0, "publicKey"), g = z(g, O), !pt(x)) {
|
|
4272
|
+
const P = x instanceof M ? ", use sig.toBytes()" : "";
|
|
4273
|
+
throw new Error("verify expects Uint8Array signature" + P);
|
|
4131
4274
|
}
|
|
4132
|
-
|
|
4275
|
+
F(x, L);
|
|
4133
4276
|
try {
|
|
4134
|
-
const
|
|
4135
|
-
if (
|
|
4277
|
+
const P = M.fromBytes(x, L), D = r.fromBytes(v);
|
|
4278
|
+
if (C && P.hasHighS())
|
|
4136
4279
|
return !1;
|
|
4137
|
-
const { r:
|
|
4138
|
-
return oe.is0() ? !1 : i.create(oe.x) ===
|
|
4280
|
+
const { r: U, s: Y } = P, W = G(g), B = i.inv(Y), X = i.create(W * B), Z = i.create(U * B), oe = r.BASE.multiplyUnsafe(X).add(D.multiplyUnsafe(Z));
|
|
4281
|
+
return oe.is0() ? !1 : i.create(oe.x) === U;
|
|
4139
4282
|
} catch {
|
|
4140
4283
|
return !1;
|
|
4141
4284
|
}
|
|
4142
4285
|
}
|
|
4143
4286
|
function I(x, g, v = {}) {
|
|
4144
|
-
const { prehash:
|
|
4145
|
-
return g =
|
|
4287
|
+
const { prehash: A } = rt(v, w);
|
|
4288
|
+
return g = z(g, A), M.fromBytes(x, "recovered").recoverPublicKey(g).toBytes();
|
|
4146
4289
|
}
|
|
4147
4290
|
return Object.freeze({
|
|
4148
4291
|
keygen: l,
|
|
@@ -4151,15 +4294,15 @@ function Xr(r, e, s = {}) {
|
|
|
4151
4294
|
utils: _,
|
|
4152
4295
|
lengths: f,
|
|
4153
4296
|
Point: r,
|
|
4154
|
-
sign:
|
|
4155
|
-
verify:
|
|
4297
|
+
sign: b,
|
|
4298
|
+
verify: S,
|
|
4156
4299
|
recoverPublicKey: I,
|
|
4157
|
-
Signature:
|
|
4300
|
+
Signature: M,
|
|
4158
4301
|
hash: e
|
|
4159
4302
|
});
|
|
4160
4303
|
}
|
|
4161
4304
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
4162
|
-
const
|
|
4305
|
+
const wt = {
|
|
4163
4306
|
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
|
|
4164
4307
|
n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
|
|
4165
4308
|
h: BigInt(1),
|
|
@@ -4167,44 +4310,44 @@ const gt = {
|
|
|
4167
4310
|
b: BigInt(7),
|
|
4168
4311
|
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
4169
4312
|
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
|
4170
|
-
},
|
|
4313
|
+
}, Qr = {
|
|
4171
4314
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
4172
4315
|
basises: [
|
|
4173
4316
|
[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
|
|
4174
4317
|
[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
|
|
4175
4318
|
]
|
|
4176
|
-
},
|
|
4177
|
-
function
|
|
4178
|
-
const e =
|
|
4179
|
-
if (!
|
|
4319
|
+
}, Vt = /* @__PURE__ */ BigInt(2);
|
|
4320
|
+
function en(r) {
|
|
4321
|
+
const e = wt.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, u = l * l * r % e, h = ae(u, s, e) * u % e, _ = ae(h, s, e) * u % e, f = ae(_, Vt, e) * l % e, w = ae(f, n, e) * f % e, E = ae(w, o, e) * w % e, y = ae(E, a, e) * E % e, R = ae(y, c, e) * y % e, N = ae(R, a, e) * E % e, F = ae(N, s, e) * u % e, M = ae(F, i, e) * w % e, V = ae(M, t, e) * l % e, G = ae(V, Vt, e);
|
|
4322
|
+
if (!ut.eql(ut.sqr(G), r))
|
|
4180
4323
|
throw new Error("Cannot find square root");
|
|
4181
|
-
return
|
|
4182
|
-
}
|
|
4183
|
-
const
|
|
4184
|
-
Fp:
|
|
4185
|
-
endo:
|
|
4186
|
-
}),
|
|
4187
|
-
for (let r = 0, e =
|
|
4188
|
-
[s, t] = [t, (2 * s + 3 * t) % 5],
|
|
4189
|
-
let n =
|
|
4324
|
+
return G;
|
|
4325
|
+
}
|
|
4326
|
+
const ut = Ye(wt.p, { sqrt: en }), tn = /* @__PURE__ */ Xr(wt, {
|
|
4327
|
+
Fp: ut,
|
|
4328
|
+
endo: Qr
|
|
4329
|
+
}), sn = /* @__PURE__ */ Zr(tn, Ar), rn = BigInt(0), Le = BigInt(1), nn = BigInt(2), on = BigInt(7), an = BigInt(256), cn = BigInt(113), ks = [], Ps = [], Os = [];
|
|
4330
|
+
for (let r = 0, e = Le, s = 1, t = 0; r < 24; r++) {
|
|
4331
|
+
[s, t] = [t, (2 * s + 3 * t) % 5], ks.push(2 * (5 * t + s)), Ps.push((r + 1) * (r + 2) / 2 % 64);
|
|
4332
|
+
let n = rn;
|
|
4190
4333
|
for (let o = 0; o < 7; o++)
|
|
4191
|
-
e = (e <<
|
|
4192
|
-
|
|
4334
|
+
e = (e << Le ^ (e >> on) * cn) % an, e & nn && (n ^= Le << (Le << BigInt(o)) - Le);
|
|
4335
|
+
Os.push(n);
|
|
4193
4336
|
}
|
|
4194
|
-
const
|
|
4195
|
-
function
|
|
4337
|
+
const Cs = mr(Os, !0), ln = Cs[0], dn = Cs[1], zt = (r, e, s) => s > 32 ? br(r, e, s) : wr(r, e, s), jt = (r, e, s) => s > 32 ? Sr(r, e, s) : yr(r, e, s);
|
|
4338
|
+
function un(r, e = 24) {
|
|
4196
4339
|
const s = new Uint32Array(10);
|
|
4197
4340
|
for (let t = 24 - e; t < 24; t++) {
|
|
4198
4341
|
for (let i = 0; i < 10; i++)
|
|
4199
4342
|
s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
|
|
4200
4343
|
for (let i = 0; i < 10; i += 2) {
|
|
4201
|
-
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], u = s[c + 1], h =
|
|
4344
|
+
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], u = s[c + 1], h = zt(l, u, 1) ^ s[a], _ = jt(l, u, 1) ^ s[a + 1];
|
|
4202
4345
|
for (let f = 0; f < 50; f += 10)
|
|
4203
4346
|
r[i + f] ^= h, r[i + f + 1] ^= _;
|
|
4204
4347
|
}
|
|
4205
4348
|
let n = r[2], o = r[3];
|
|
4206
4349
|
for (let i = 0; i < 24; i++) {
|
|
4207
|
-
const a =
|
|
4350
|
+
const a = Ps[i], c = zt(n, o, a), l = jt(n, o, a), u = ks[i];
|
|
4208
4351
|
n = r[u], o = r[u + 1], r[u] = c, r[u + 1] = l;
|
|
4209
4352
|
}
|
|
4210
4353
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -4213,36 +4356,36 @@ function dn(r, e = 24) {
|
|
|
4213
4356
|
for (let a = 0; a < 10; a++)
|
|
4214
4357
|
r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
|
|
4215
4358
|
}
|
|
4216
|
-
r[0] ^=
|
|
4359
|
+
r[0] ^= ln[t], r[1] ^= dn[t];
|
|
4217
4360
|
}
|
|
4218
|
-
|
|
4361
|
+
Ce(s);
|
|
4219
4362
|
}
|
|
4220
|
-
class
|
|
4363
|
+
class yt {
|
|
4221
4364
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
4222
4365
|
constructor(e, s, t, n = !1, o = 24) {
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4366
|
+
T(this, "state");
|
|
4367
|
+
T(this, "pos", 0);
|
|
4368
|
+
T(this, "posOut", 0);
|
|
4369
|
+
T(this, "finished", !1);
|
|
4370
|
+
T(this, "state32");
|
|
4371
|
+
T(this, "destroyed", !1);
|
|
4372
|
+
T(this, "blockLen");
|
|
4373
|
+
T(this, "suffix");
|
|
4374
|
+
T(this, "outputLen");
|
|
4375
|
+
T(this, "enableXOF", !1);
|
|
4376
|
+
T(this, "rounds");
|
|
4234
4377
|
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, me(t, "outputLen"), !(0 < e && e < 200))
|
|
4235
4378
|
throw new Error("only keccak-f1600 function is supported");
|
|
4236
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
4379
|
+
this.state = new Uint8Array(200), this.state32 = cr(this.state);
|
|
4237
4380
|
}
|
|
4238
4381
|
clone() {
|
|
4239
4382
|
return this._cloneInto();
|
|
4240
4383
|
}
|
|
4241
4384
|
keccak() {
|
|
4242
|
-
|
|
4385
|
+
Dt(this.state32), un(this.state32, this.rounds), Dt(this.state32), this.posOut = 0, this.pos = 0;
|
|
4243
4386
|
}
|
|
4244
4387
|
update(e) {
|
|
4245
|
-
|
|
4388
|
+
Oe(this), q(e);
|
|
4246
4389
|
const { blockLen: s, state: t } = this, n = e.length;
|
|
4247
4390
|
for (let o = 0; o < n; ) {
|
|
4248
4391
|
const i = Math.min(s - this.pos, n - o);
|
|
@@ -4260,7 +4403,7 @@ class mt {
|
|
|
4260
4403
|
e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
|
|
4261
4404
|
}
|
|
4262
4405
|
writeInto(e) {
|
|
4263
|
-
|
|
4406
|
+
Oe(this, !1), q(e), this.finish();
|
|
4264
4407
|
const s = this.state, { blockLen: t } = this;
|
|
4265
4408
|
for (let n = 0, o = e.length; n < o; ) {
|
|
4266
4409
|
this.posOut >= t && this.keccak();
|
|
@@ -4278,7 +4421,7 @@ class mt {
|
|
|
4278
4421
|
return me(e), this.xofInto(new Uint8Array(e));
|
|
4279
4422
|
}
|
|
4280
4423
|
digestInto(e) {
|
|
4281
|
-
if (
|
|
4424
|
+
if (ns(e, this), this.finished)
|
|
4282
4425
|
throw new Error("digest() was already called");
|
|
4283
4426
|
return this.writeInto(e), this.destroy(), e;
|
|
4284
4427
|
}
|
|
@@ -4286,21 +4429,21 @@ class mt {
|
|
|
4286
4429
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
4287
4430
|
}
|
|
4288
4431
|
destroy() {
|
|
4289
|
-
this.destroyed = !0,
|
|
4432
|
+
this.destroyed = !0, Ce(this.state);
|
|
4290
4433
|
}
|
|
4291
4434
|
_cloneInto(e) {
|
|
4292
4435
|
const { blockLen: s, suffix: t, outputLen: n, rounds: o, enableXOF: i } = this;
|
|
4293
|
-
return e || (e = new
|
|
4436
|
+
return e || (e = new yt(s, t, n, i, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = t, e.outputLen = n, e.enableXOF = i, e.destroyed = this.destroyed, e;
|
|
4294
4437
|
}
|
|
4295
4438
|
}
|
|
4296
|
-
const
|
|
4297
|
-
class
|
|
4439
|
+
const hn = (r, e, s, t = {}) => is(() => new yt(e, r, s), t), Yt = /* @__PURE__ */ hn(1, 136, 32), pn = 60;
|
|
4440
|
+
class fn {
|
|
4298
4441
|
constructor() {
|
|
4299
4442
|
this.jwks = null;
|
|
4300
4443
|
}
|
|
4301
4444
|
setJWKSEndpoint(e) {
|
|
4302
4445
|
try {
|
|
4303
|
-
this.jwks =
|
|
4446
|
+
this.jwks = Bs(new URL(e)), d.log("[CROSSx] JWKS 엔드포인트 설정:", e);
|
|
4304
4447
|
} catch (s) {
|
|
4305
4448
|
d.warn("[CROSSx] JWKS 엔드포인트 URL 파싱 실패:", s);
|
|
4306
4449
|
}
|
|
@@ -4314,7 +4457,7 @@ class pn {
|
|
|
4314
4457
|
iat: t.iat
|
|
4315
4458
|
});
|
|
4316
4459
|
const n = Math.floor(Date.now() / 1e3);
|
|
4317
|
-
if (t.exp && t.exp +
|
|
4460
|
+
if (t.exp && t.exp + pn < n)
|
|
4318
4461
|
return d.warn("[CROSSx] 토큰 만료:", {
|
|
4319
4462
|
exp: t.exp,
|
|
4320
4463
|
now: n,
|
|
@@ -4324,7 +4467,7 @@ class pn {
|
|
|
4324
4467
|
return d.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 };
|
|
4325
4468
|
if (this.jwks)
|
|
4326
4469
|
try {
|
|
4327
|
-
const { payload: o } = await
|
|
4470
|
+
const { payload: o } = await Us(e, this.jwks, {
|
|
4328
4471
|
algorithms: ["RS256", "ES256"]
|
|
4329
4472
|
});
|
|
4330
4473
|
return d.log("[CROSSx] JWT 서명 검증 성공"), {
|
|
@@ -4343,7 +4486,7 @@ class pn {
|
|
|
4343
4486
|
}
|
|
4344
4487
|
}
|
|
4345
4488
|
decodeJWT(e) {
|
|
4346
|
-
return
|
|
4489
|
+
return Hs(e);
|
|
4347
4490
|
}
|
|
4348
4491
|
/**
|
|
4349
4492
|
* EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
|
|
@@ -4358,29 +4501,29 @@ class pn {
|
|
|
4358
4501
|
${t.length}`
|
|
4359
4502
|
), o = new Uint8Array(n.length + t.length);
|
|
4360
4503
|
o.set(n, 0), o.set(t, n.length);
|
|
4361
|
-
const i =
|
|
4504
|
+
const i = Yt(o), a = s.startsWith("0x") ? s.slice(2) : s;
|
|
4362
4505
|
if (a.length !== 130)
|
|
4363
4506
|
throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
|
|
4364
|
-
const c =
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
).addRecoveryBit(_).recoverPublicKey(i).toBytes(!1).slice(1), y =
|
|
4368
|
-
return "0x" +
|
|
4507
|
+
const c = _n(a), l = c.slice(0, 32), u = c.slice(32, 64), h = c[64], _ = h >= 27 ? h - 27 : h, E = new sn.Signature(
|
|
4508
|
+
Xt(l),
|
|
4509
|
+
Xt(u)
|
|
4510
|
+
).addRecoveryBit(_).recoverPublicKey(i).toBytes(!1).slice(1), y = Yt(E);
|
|
4511
|
+
return "0x" + $e(y.slice(12));
|
|
4369
4512
|
}
|
|
4370
4513
|
}
|
|
4371
|
-
function
|
|
4514
|
+
function _n(r) {
|
|
4372
4515
|
const e = new Uint8Array(r.length / 2);
|
|
4373
4516
|
for (let s = 0; s < e.length; s++)
|
|
4374
4517
|
e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
|
|
4375
4518
|
return e;
|
|
4376
4519
|
}
|
|
4377
|
-
function
|
|
4520
|
+
function Xt(r) {
|
|
4378
4521
|
let e = "0x";
|
|
4379
4522
|
for (const s of r) e += s.toString(16).padStart(2, "0");
|
|
4380
4523
|
return BigInt(e);
|
|
4381
4524
|
}
|
|
4382
|
-
const
|
|
4383
|
-
class
|
|
4525
|
+
const xn = 3e4, gn = 1e3;
|
|
4526
|
+
class mn {
|
|
4384
4527
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4385
4528
|
async request(e) {
|
|
4386
4529
|
const s = e.retries ?? 0;
|
|
@@ -4391,7 +4534,7 @@ class gn {
|
|
|
4391
4534
|
} catch (n) {
|
|
4392
4535
|
if (t === s) throw n;
|
|
4393
4536
|
}
|
|
4394
|
-
await new Promise((n) => setTimeout(n,
|
|
4537
|
+
await new Promise((n) => setTimeout(n, gn * 2 ** t));
|
|
4395
4538
|
}
|
|
4396
4539
|
throw new Error("Unexpected: retry loop exited without result");
|
|
4397
4540
|
}
|
|
@@ -4399,7 +4542,7 @@ class gn {
|
|
|
4399
4542
|
async _doRequest(e) {
|
|
4400
4543
|
const s = new AbortController(), t = setTimeout(
|
|
4401
4544
|
() => s.abort(),
|
|
4402
|
-
e.timeoutMs ??
|
|
4545
|
+
e.timeoutMs ?? xn
|
|
4403
4546
|
);
|
|
4404
4547
|
try {
|
|
4405
4548
|
const n = await fetch(e.url, {
|
|
@@ -4426,12 +4569,12 @@ class gn {
|
|
|
4426
4569
|
}
|
|
4427
4570
|
}
|
|
4428
4571
|
}
|
|
4429
|
-
const
|
|
4572
|
+
const wn = /* @__PURE__ */ new Set([
|
|
4430
4573
|
"https://cross-wallet-oauth.crosstoken.io",
|
|
4431
4574
|
"https://stg-cross-wallet-oauth.crosstoken.io",
|
|
4432
4575
|
"https://dev-cross-wallet-oauth.crosstoken.io"
|
|
4433
4576
|
]);
|
|
4434
|
-
class
|
|
4577
|
+
class Ie {
|
|
4435
4578
|
static generateRandom16Hex() {
|
|
4436
4579
|
const e = new Uint8Array(16);
|
|
4437
4580
|
return crypto.getRandomValues(e), Array.from(e, (s) => s.toString(16).padStart(2, "0")).join("");
|
|
@@ -4455,7 +4598,7 @@ class Ee {
|
|
|
4455
4598
|
* - Google 및 기타: originalNonce === jwt.nonce
|
|
4456
4599
|
*/
|
|
4457
4600
|
static async verifyIdTokenNonce(e, s) {
|
|
4458
|
-
const t =
|
|
4601
|
+
const t = Ie.parseJwtPayload(e), n = t.nonce, o = typeof t.iss == "string" ? t.iss : "(unknown)";
|
|
4459
4602
|
if (d.log("[CROSSx] nonce 검증 시작 —", {
|
|
4460
4603
|
iss: o,
|
|
4461
4604
|
nonceClaimType: typeof n,
|
|
@@ -4477,7 +4620,7 @@ class Ee {
|
|
|
4477
4620
|
return;
|
|
4478
4621
|
}
|
|
4479
4622
|
if (o.includes("appleid.apple.com")) {
|
|
4480
|
-
const i = await
|
|
4623
|
+
const i = await Ie.sha256Hex(s);
|
|
4481
4624
|
if (d.log("[CROSSx] Apple nonce 검증 —", {
|
|
4482
4625
|
expectedHashLength: i.length,
|
|
4483
4626
|
receivedHashLength: n.length,
|
|
@@ -4494,7 +4637,7 @@ class Ee {
|
|
|
4494
4637
|
}
|
|
4495
4638
|
openAuth(e) {
|
|
4496
4639
|
return new Promise((s, t) => {
|
|
4497
|
-
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 =
|
|
4640
|
+
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 = Ie.generateRandom16Hex(), l = Ie.generateRandom16Hex(), u = e.authUrl.includes("?") ? "&" : "?", h = `${e.authUrl}${u}state=${c}&nonce=${l}`;
|
|
4498
4641
|
d.log("[CROSSx] OAuth 팝업 열기 — state, nonce 생성 완료:", {
|
|
4499
4642
|
stateLength: c.length,
|
|
4500
4643
|
nonceLength: l.length,
|
|
@@ -4510,73 +4653,73 @@ class Ee {
|
|
|
4510
4653
|
return;
|
|
4511
4654
|
}
|
|
4512
4655
|
const f = setTimeout(() => {
|
|
4513
|
-
d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"),
|
|
4514
|
-
}, 5 * 60 * 1e3), w = 10,
|
|
4515
|
-
let y = 0,
|
|
4656
|
+
d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), M(), t(new Error("Authentication timeout"));
|
|
4657
|
+
}, 5 * 60 * 1e3), w = 10, E = 30;
|
|
4658
|
+
let y = 0, R = null;
|
|
4516
4659
|
const N = () => {
|
|
4517
|
-
clearInterval(
|
|
4518
|
-
|
|
4660
|
+
clearInterval(F), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + E + "초간 대기합니다"), R = setTimeout(() => {
|
|
4661
|
+
M(), t(new Error(
|
|
4519
4662
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
4520
4663
|
));
|
|
4521
|
-
},
|
|
4522
|
-
},
|
|
4664
|
+
}, E * 1e3);
|
|
4665
|
+
}, F = setInterval(() => {
|
|
4523
4666
|
y++;
|
|
4524
4667
|
try {
|
|
4525
|
-
_.closed && (y <= w ? N() : (
|
|
4668
|
+
_.closed && (y <= w ? N() : (M(), t(new Error("로그인이 취소되었습니다"))));
|
|
4526
4669
|
} catch {
|
|
4527
4670
|
N();
|
|
4528
4671
|
}
|
|
4529
|
-
}, 1e3),
|
|
4530
|
-
clearTimeout(f), clearInterval(
|
|
4531
|
-
},
|
|
4532
|
-
if (
|
|
4533
|
-
if (!
|
|
4534
|
-
d.error("[CROSSx] postMessage origin이 허용 목록에 없음:",
|
|
4672
|
+
}, 1e3), M = () => {
|
|
4673
|
+
clearTimeout(f), clearInterval(F), R && clearTimeout(R), window.removeEventListener("message", V);
|
|
4674
|
+
}, V = (G) => {
|
|
4675
|
+
if (G.origin !== e.expectedOrigin) return;
|
|
4676
|
+
if (!wn.has(G.origin)) {
|
|
4677
|
+
d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", G.origin), M(), t(new Error("Unauthorized OAuth origin"));
|
|
4535
4678
|
return;
|
|
4536
4679
|
}
|
|
4537
|
-
|
|
4538
|
-
const
|
|
4680
|
+
M();
|
|
4681
|
+
const J = typeof G.data.status == "string", H = J ? G.data.data ?? {} : G.data;
|
|
4539
4682
|
d.log("[CROSSx] OAuth postMessage 수신 —", {
|
|
4540
|
-
format:
|
|
4541
|
-
status:
|
|
4683
|
+
format: J ? "wrapped" : "flat",
|
|
4684
|
+
status: J ? G.data.status : "(flat)"
|
|
4542
4685
|
});
|
|
4543
|
-
const
|
|
4544
|
-
if (!
|
|
4686
|
+
const z = (H == null ? void 0 : H.state) ?? G.data.state;
|
|
4687
|
+
if (!z || z !== c) {
|
|
4545
4688
|
t(new Error("OAuth state mismatch — possible CSRF attack"));
|
|
4546
4689
|
return;
|
|
4547
4690
|
}
|
|
4548
|
-
if (
|
|
4549
|
-
d.error("[CROSSx] OAuth 실패:",
|
|
4691
|
+
if (J && G.data.status !== "success") {
|
|
4692
|
+
d.error("[CROSSx] OAuth 실패:", H == null ? void 0 : H.error), t(new Error((H == null ? void 0 : H.error) || "Authentication failed"));
|
|
4550
4693
|
return;
|
|
4551
4694
|
}
|
|
4552
|
-
if (!
|
|
4553
|
-
d.error("[CROSSx] OAuth 실패:",
|
|
4695
|
+
if (!J && (H != null && H.error)) {
|
|
4696
|
+
d.error("[CROSSx] OAuth 실패:", H.error), t(new Error(H.error || "Authentication failed"));
|
|
4554
4697
|
return;
|
|
4555
4698
|
}
|
|
4556
|
-
const
|
|
4699
|
+
const k = H == null ? void 0 : H.idToken, b = H == null ? void 0 : H.accessToken, S = b ?? k;
|
|
4557
4700
|
if (d.log("[CROSSx] OAuth 토큰 수신:", {
|
|
4558
|
-
hasAccessToken: !!
|
|
4559
|
-
hasIdToken: !!
|
|
4560
|
-
}), !
|
|
4561
|
-
d.error("[CROSSx] 토큰을 찾을 수 없음:",
|
|
4701
|
+
hasAccessToken: !!b,
|
|
4702
|
+
hasIdToken: !!k
|
|
4703
|
+
}), !S) {
|
|
4704
|
+
d.error("[CROSSx] 토큰을 찾을 수 없음:", G.data), t(new Error("Token not found in response"));
|
|
4562
4705
|
return;
|
|
4563
4706
|
}
|
|
4564
4707
|
const I = (x) => {
|
|
4565
|
-
|
|
4708
|
+
Ie.verifyIdTokenNonce(x, l).then(() => s(S)).catch((g) => {
|
|
4566
4709
|
d.error("[CROSSx] nonce 검증 실패:", g), t(g instanceof Error ? g : new Error("nonce verification failed"));
|
|
4567
4710
|
});
|
|
4568
4711
|
};
|
|
4569
|
-
|
|
4712
|
+
b ? b.split(".").length === 3 ? I(b) : k ? I(k) : (d.warn(
|
|
4570
4713
|
"[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
|
|
4571
4714
|
"서버 측 nonce 검증이 필요합니다."
|
|
4572
|
-
), s(
|
|
4715
|
+
), s(S)) : k ? I(k) : t(new Error("Token not found in response"));
|
|
4573
4716
|
};
|
|
4574
|
-
window.addEventListener("message",
|
|
4717
|
+
window.addEventListener("message", V);
|
|
4575
4718
|
});
|
|
4576
4719
|
}
|
|
4577
4720
|
}
|
|
4578
|
-
const
|
|
4579
|
-
class
|
|
4721
|
+
const De = "crossx_wallet_data", Re = "crossx_mock_pin_hash";
|
|
4722
|
+
class yn {
|
|
4580
4723
|
constructor(e, s) {
|
|
4581
4724
|
this.storage = e, this.pinStore = s ?? null;
|
|
4582
4725
|
}
|
|
@@ -4589,13 +4732,13 @@ class wn {
|
|
|
4589
4732
|
async checkWallet() {
|
|
4590
4733
|
if (this.migrateScenario !== void 0)
|
|
4591
4734
|
return d.log("[Mock] checkWallet → migration_required"), "migration_required";
|
|
4592
|
-
const s = await this.storage.get(
|
|
4735
|
+
const s = await this.storage.get(De) ? "exists" : "not_found";
|
|
4593
4736
|
return d.log(`[Mock] checkWallet → ${s}`), s;
|
|
4594
4737
|
}
|
|
4595
4738
|
async getOrCreateWallet(e) {
|
|
4596
4739
|
var s;
|
|
4597
4740
|
try {
|
|
4598
|
-
const t = await this.storage.get(
|
|
4741
|
+
const t = await this.storage.get(De);
|
|
4599
4742
|
if (t) return t;
|
|
4600
4743
|
const n = {
|
|
4601
4744
|
id: e,
|
|
@@ -4603,16 +4746,16 @@ class wn {
|
|
|
4603
4746
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
4604
4747
|
createdAt: Date.now()
|
|
4605
4748
|
};
|
|
4606
|
-
await this.storage.set(
|
|
4749
|
+
await this.storage.set(De, n);
|
|
4607
4750
|
const o = (s = this.pinStore) == null ? void 0 : s.get();
|
|
4608
|
-
return o && (await this.storage.set(
|
|
4751
|
+
return o && (await this.storage.set(Re, o), d.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
|
|
4609
4752
|
} catch (t) {
|
|
4610
4753
|
throw new m(p.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", t);
|
|
4611
4754
|
}
|
|
4612
4755
|
}
|
|
4613
4756
|
/** GET /mnemonic/addresses 모킹 — PIN 불필요, 캐시된 주소 반환 */
|
|
4614
4757
|
async getAddresses(e) {
|
|
4615
|
-
const s = await this.storage.get(
|
|
4758
|
+
const s = await this.storage.get(De);
|
|
4616
4759
|
return s ? [{ address: s.address, index: 0 }] : [];
|
|
4617
4760
|
}
|
|
4618
4761
|
async getAddress(e, s) {
|
|
@@ -4647,8 +4790,8 @@ class wn {
|
|
|
4647
4790
|
var t;
|
|
4648
4791
|
if (d.log("[Mock] verifyPin"), this.pinScenario === "wrong")
|
|
4649
4792
|
return !1;
|
|
4650
|
-
const s = await this.storage.get(
|
|
4651
|
-
return s && s !== e ? !1 : (s || await this.storage.set(
|
|
4793
|
+
const s = await this.storage.get(Re);
|
|
4794
|
+
return s && s !== e ? !1 : (s || await this.storage.set(Re, e), (t = this.pinStore) == null || t.set(e), d.log("[Mock] verifyPin → 성공"), !0);
|
|
4652
4795
|
}
|
|
4653
4796
|
/**
|
|
4654
4797
|
* POST /mnemonic/change-password 모킹
|
|
@@ -4658,10 +4801,10 @@ class wn {
|
|
|
4658
4801
|
var o;
|
|
4659
4802
|
if (d.log("[Mock] changePin"), this.pinScenario === "wrong")
|
|
4660
4803
|
throw new m(p.PIN_WRONG, "Incorrect PIN.");
|
|
4661
|
-
const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(
|
|
4804
|
+
const t = (o = this.pinStore) == null ? void 0 : o.get(), n = await this.storage.get(Re);
|
|
4662
4805
|
if (n && t && n !== t)
|
|
4663
4806
|
throw new m(p.PIN_WRONG, "Incorrect PIN.");
|
|
4664
|
-
await this.storage.set(
|
|
4807
|
+
await this.storage.set(Re, s), d.log("[Mock] changePin 완료");
|
|
4665
4808
|
}
|
|
4666
4809
|
async migrateWallet(e, s) {
|
|
4667
4810
|
var o;
|
|
@@ -4692,9 +4835,9 @@ class wn {
|
|
|
4692
4835
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
4693
4836
|
createdAt: Date.now()
|
|
4694
4837
|
};
|
|
4695
|
-
await this.storage.set(
|
|
4838
|
+
await this.storage.set(De, t);
|
|
4696
4839
|
const n = (o = this.pinStore) == null ? void 0 : o.get();
|
|
4697
|
-
return n && (await this.storage.set(
|
|
4840
|
+
return n && (await this.storage.set(Re, n), d.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
|
|
4698
4841
|
}
|
|
4699
4842
|
/**
|
|
4700
4843
|
* POST /mnemonic/share-c 모킹
|
|
@@ -4721,7 +4864,7 @@ class wn {
|
|
|
4721
4864
|
).join("");
|
|
4722
4865
|
}
|
|
4723
4866
|
}
|
|
4724
|
-
class
|
|
4867
|
+
class ke {
|
|
4725
4868
|
constructor(e, s, t, n, o) {
|
|
4726
4869
|
this._refreshPromise = null, this._walletStatusCache = null, this.adapterConfig = e, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n, this.pinStore = o ?? null;
|
|
4727
4870
|
}
|
|
@@ -4743,22 +4886,30 @@ class Le {
|
|
|
4743
4886
|
*
|
|
4744
4887
|
* 1. 토큰이 있고 만료 임박하지 않으면 즉시 반환
|
|
4745
4888
|
* 2. 만료 임박/만료 시 → 자동 갱신 시도 (동시 호출 deduplicate)
|
|
4746
|
-
* 3.
|
|
4747
|
-
* 4.
|
|
4889
|
+
* 3. 만료 임박·만료 상태에서 갱신에 실패하면 SESSION_EXPIRED (stale access로 호출하지 않음)
|
|
4890
|
+
* 4. refresher 미등록 등으로 갱신을 시도하지 않은 경우에만 기존 토큰 사용
|
|
4748
4891
|
*/
|
|
4749
4892
|
async ensureValidToken() {
|
|
4750
4893
|
const e = this.tokenStore.get();
|
|
4751
|
-
if (e && !this.tokenStore.isExpiringSoon(
|
|
4894
|
+
if (e && !this.tokenStore.isExpiringSoon(Nt))
|
|
4752
4895
|
return e;
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
if (
|
|
4896
|
+
const s = !e || this.tokenStore.isExpiringSoon(Nt);
|
|
4897
|
+
if (this._onTokenRefresh) {
|
|
4898
|
+
if (await this.deduplicatedRefresh()) {
|
|
4899
|
+
const n = this.tokenStore.get();
|
|
4900
|
+
if (n) return n;
|
|
4901
|
+
}
|
|
4902
|
+
if (s)
|
|
4903
|
+
throw new m(
|
|
4904
|
+
p.SESSION_EXPIRED,
|
|
4905
|
+
"인증 세션이 만료되었습니다. 다시 로그인해 주세요."
|
|
4906
|
+
);
|
|
4756
4907
|
}
|
|
4757
4908
|
if (e)
|
|
4758
4909
|
return d.warn("[CROSSx] 토큰 갱신 실패 — 기존 토큰으로 요청 시도"), e;
|
|
4759
4910
|
throw new m(
|
|
4760
|
-
p.
|
|
4761
|
-
"인증
|
|
4911
|
+
p.SESSION_EXPIRED,
|
|
4912
|
+
"인증 세션이 만료되었습니다. 다시 로그인해 주세요."
|
|
4762
4913
|
);
|
|
4763
4914
|
}
|
|
4764
4915
|
/** 동시 갱신 요청을 단일 Promise로 합칩니다. */
|
|
@@ -4790,11 +4941,14 @@ class Le {
|
|
|
4790
4941
|
url: i,
|
|
4791
4942
|
method: e
|
|
4792
4943
|
});
|
|
4793
|
-
const w =
|
|
4794
|
-
if (w === p.AUTH_NOT_AUTHENTICATED && !n && this._onTokenRefresh
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4944
|
+
const w = ke.mapGatewayError(_.code, _.data);
|
|
4945
|
+
if (w === p.AUTH_NOT_AUTHENTICATED && !n && this._onTokenRefresh) {
|
|
4946
|
+
if (d.warn("[CROSSx] Gateway -10002 감지 — 토큰 갱신 후 재시도"), await this.deduplicatedRefresh())
|
|
4947
|
+
return this.request(e, s, t, !0);
|
|
4948
|
+
throw new m(p.SESSION_EXPIRED, "인증 세션이 만료되었습니다. 다시 로그인해 주세요.");
|
|
4949
|
+
}
|
|
4950
|
+
const E = w === p.AUTH_NOT_AUTHENTICATED ? p.SESSION_EXPIRED : w, y = E === p.SESSION_EXPIRED ? "인증 세션이 만료되었습니다. 다시 로그인해 주세요." : ke.getGatewayErrorMessage(_.code, f), R = _.data, N = w === p.PIN_LOCKED ? ke.extractLockDetails(R) : R ?? void 0;
|
|
4951
|
+
throw new m(E, y, N);
|
|
4798
4952
|
}
|
|
4799
4953
|
return d.log("[CROSSx] Wallet Gateway API 성공:", { code: _.code, url: i, method: e }), _.data ?? _;
|
|
4800
4954
|
}
|
|
@@ -4802,19 +4956,25 @@ class Le {
|
|
|
4802
4956
|
} catch (h) {
|
|
4803
4957
|
if (h instanceof m) throw h;
|
|
4804
4958
|
const _ = ((c = h.response) == null ? void 0 : c.status) ?? h.status;
|
|
4805
|
-
if ((_ === 401 || _ === 403) && !n && this._onTokenRefresh
|
|
4806
|
-
|
|
4959
|
+
if ((_ === 401 || _ === 403) && !n && this._onTokenRefresh) {
|
|
4960
|
+
if (d.warn(`[CROSSx] HTTP ${_} 감지 — 토큰 갱신 후 재시도`), await this.deduplicatedRefresh())
|
|
4961
|
+
return this.request(e, s, t, !0);
|
|
4962
|
+
throw new m(
|
|
4963
|
+
p.SESSION_EXPIRED,
|
|
4964
|
+
"인증 세션이 만료되었습니다. 다시 로그인해 주세요."
|
|
4965
|
+
);
|
|
4966
|
+
}
|
|
4807
4967
|
if ((l = h.response) != null && l.data) {
|
|
4808
|
-
const f = h.response.data, w = f.message || f.data || "API 요청에 실패했습니다",
|
|
4968
|
+
const f = h.response.data, w = f.message || f.data || "API 요청에 실패했습니다", E = f.code || "UNKNOWN";
|
|
4809
4969
|
throw d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
|
|
4810
|
-
code:
|
|
4970
|
+
code: E,
|
|
4811
4971
|
message: w,
|
|
4812
4972
|
url: i,
|
|
4813
4973
|
method: e,
|
|
4814
4974
|
status: (u = h.response) == null ? void 0 : u.status
|
|
4815
4975
|
}), new m(
|
|
4816
4976
|
p.UNKNOWN_ERROR,
|
|
4817
|
-
`Wallet Gateway 오류 (${
|
|
4977
|
+
`Wallet Gateway 오류 (${E}): ${w}`
|
|
4818
4978
|
);
|
|
4819
4979
|
}
|
|
4820
4980
|
throw h;
|
|
@@ -5013,14 +5173,29 @@ class Le {
|
|
|
5013
5173
|
return e;
|
|
5014
5174
|
}
|
|
5015
5175
|
/**
|
|
5016
|
-
* -10031 응답의 data 필드에서
|
|
5176
|
+
* -10028/-10031 응답의 data 필드에서 잠금 상세 정보를 추출합니다.
|
|
5017
5177
|
* 서버는 lockStatus.lockExpiresAt을 초(Unix seconds) 또는 ms로 반환할 수 있습니다.
|
|
5018
5178
|
* 일반적으로 seconds 단위이므로 > 1e10 이면 ms로 간주합니다.
|
|
5179
|
+
*
|
|
5180
|
+
* iOS의 PinLockInfo와 동일한 필드: permanent, lockExpiresAt, maxAttempts, remainingAttempts
|
|
5019
5181
|
*/
|
|
5020
5182
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5021
5183
|
static extractLockDetails(e) {
|
|
5022
|
-
const s = (e == null ? void 0 : e.lockStatus) ?? e, t = (s == null ? void 0 : s.lockExpiresAt) ?? (s == null ? void 0 : s.lock_expires_at);
|
|
5023
|
-
|
|
5184
|
+
const s = (e == null ? void 0 : e.lockStatus) ?? (e == null ? void 0 : e.lock_status) ?? e, t = {}, n = (s == null ? void 0 : s.lockExpiresAt) ?? (s == null ? void 0 : s.lock_expires_at);
|
|
5185
|
+
n && (t.lockExpiresAt = n > 1e10 ? n : n * 1e3);
|
|
5186
|
+
const o = (s == null ? void 0 : s.remainingAttempts) ?? (s == null ? void 0 : s.remaining_attempts);
|
|
5187
|
+
typeof o == "number" && (t.remainingAttempts = o);
|
|
5188
|
+
const i = (s == null ? void 0 : s.maxAttempts) ?? (s == null ? void 0 : s.max_attempts);
|
|
5189
|
+
return typeof i == "number" && (t.maxAttempts = i), typeof (s == null ? void 0 : s.permanent) == "boolean" && (t.permanent = s.permanent), t;
|
|
5190
|
+
}
|
|
5191
|
+
/**
|
|
5192
|
+
* -10028 응답의 data에 lockStatus 정보가 포함되어 있는지 확인합니다.
|
|
5193
|
+
* iOS SDK와 동일하게, -10028에 lockStatus가 있으면 PIN_LOCKED로 승격 처리합니다.
|
|
5194
|
+
*/
|
|
5195
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5196
|
+
static hasLockInfo(e) {
|
|
5197
|
+
const s = (e == null ? void 0 : e.lockStatus) ?? (e == null ? void 0 : e.lock_status) ?? e;
|
|
5198
|
+
return !s || typeof s != "object" ? !1 : typeof s.remainingAttempts == "number" || typeof s.remaining_attempts == "number" || typeof s.maxAttempts == "number" || typeof s.max_attempts == "number";
|
|
5024
5199
|
}
|
|
5025
5200
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5026
5201
|
static mapGatewayError(e, s) {
|
|
@@ -5060,7 +5235,7 @@ class Le {
|
|
|
5060
5235
|
case -10025:
|
|
5061
5236
|
return p.INVALID_APP_TYPE;
|
|
5062
5237
|
case -10028:
|
|
5063
|
-
return p.PIN_WRONG;
|
|
5238
|
+
return ke.hasLockInfo(s) ? p.PIN_LOCKED : p.PIN_WRONG;
|
|
5064
5239
|
case -10029:
|
|
5065
5240
|
return p.PIN_INVALID;
|
|
5066
5241
|
case -10031:
|
|
@@ -5137,7 +5312,7 @@ class Le {
|
|
|
5137
5312
|
}
|
|
5138
5313
|
}
|
|
5139
5314
|
}
|
|
5140
|
-
class
|
|
5315
|
+
class Me {
|
|
5141
5316
|
constructor(e, s) {
|
|
5142
5317
|
this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this.adapterConfig = e, this.projectId = e.projectId, this.transport = s;
|
|
5143
5318
|
}
|
|
@@ -5155,7 +5330,7 @@ class De {
|
|
|
5155
5330
|
const s = e.data.chains;
|
|
5156
5331
|
return this.populateCache(s, !1), s;
|
|
5157
5332
|
} catch {
|
|
5158
|
-
const e =
|
|
5333
|
+
const e = Me.fallbackChains();
|
|
5159
5334
|
return this.populateCache(e, !0), e;
|
|
5160
5335
|
}
|
|
5161
5336
|
}
|
|
@@ -5169,7 +5344,7 @@ class De {
|
|
|
5169
5344
|
}
|
|
5170
5345
|
isCacheValid() {
|
|
5171
5346
|
if (this.loadedAt === 0) return !1;
|
|
5172
|
-
const e = this.usingFallback ?
|
|
5347
|
+
const e = this.usingFallback ? nr : rr;
|
|
5173
5348
|
return e === 0 ? !0 : Date.now() - this.loadedAt < e;
|
|
5174
5349
|
}
|
|
5175
5350
|
populateCache(e, s) {
|
|
@@ -5191,13 +5366,13 @@ class De {
|
|
|
5191
5366
|
if (e.code < 0) {
|
|
5192
5367
|
const s = typeof e.data == "string" ? e.data : e.message ?? "체인 레지스트리 요청에 실패했습니다";
|
|
5193
5368
|
throw new m(
|
|
5194
|
-
|
|
5369
|
+
Me.mapErrorCode(e.code),
|
|
5195
5370
|
s
|
|
5196
5371
|
);
|
|
5197
5372
|
}
|
|
5198
5373
|
}
|
|
5199
5374
|
fallbackOrThrow(e) {
|
|
5200
|
-
const s =
|
|
5375
|
+
const s = Me.fallbackChains().find(
|
|
5201
5376
|
(t) => t.chainId === e
|
|
5202
5377
|
);
|
|
5203
5378
|
if (s) return s;
|
|
@@ -5207,7 +5382,7 @@ class De {
|
|
|
5207
5382
|
);
|
|
5208
5383
|
}
|
|
5209
5384
|
static fallbackChains() {
|
|
5210
|
-
return Object.values(
|
|
5385
|
+
return Object.values(ze).map((e) => ({
|
|
5211
5386
|
chainId: e.caipId,
|
|
5212
5387
|
rpcUrl: e.rpcUrl
|
|
5213
5388
|
}));
|
|
@@ -5231,7 +5406,7 @@ class De {
|
|
|
5231
5406
|
}
|
|
5232
5407
|
}
|
|
5233
5408
|
}
|
|
5234
|
-
const
|
|
5409
|
+
const Jt = "__crossx-confirm-style", se = "__crossx-confirm-overlay", bn = {
|
|
5235
5410
|
light: {
|
|
5236
5411
|
bg: "#FFFFFF",
|
|
5237
5412
|
border: "rgba(18,18,18,0.05)",
|
|
@@ -5287,8 +5462,8 @@ const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", yn = {
|
|
|
5287
5462
|
onPrimary: "#FFFFFF"
|
|
5288
5463
|
}
|
|
5289
5464
|
};
|
|
5290
|
-
function
|
|
5291
|
-
const s =
|
|
5465
|
+
function Zt(r, e) {
|
|
5466
|
+
const s = bn[r], t = e == null ? void 0 : e[r];
|
|
5292
5467
|
return t ? {
|
|
5293
5468
|
...s,
|
|
5294
5469
|
// ── Brand
|
|
@@ -5320,10 +5495,10 @@ function Jt(r, e) {
|
|
|
5320
5495
|
...t.error !== void 0 && { errorColor: t.error }
|
|
5321
5496
|
} : s;
|
|
5322
5497
|
}
|
|
5323
|
-
const
|
|
5498
|
+
const Sn = `
|
|
5324
5499
|
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
|
|
5325
5500
|
|
|
5326
|
-
#${
|
|
5501
|
+
#${se} {
|
|
5327
5502
|
position: fixed;
|
|
5328
5503
|
inset: 0;
|
|
5329
5504
|
z-index: 2147483647;
|
|
@@ -6487,6 +6662,8 @@ const bn = `
|
|
|
6487
6662
|
max-height: 320px;
|
|
6488
6663
|
overflow-y: auto;
|
|
6489
6664
|
-webkit-overflow-scrolling: touch;
|
|
6665
|
+
overscroll-behavior: contain;
|
|
6666
|
+
touch-action: pan-y;
|
|
6490
6667
|
scrollbar-width: thin;
|
|
6491
6668
|
}
|
|
6492
6669
|
.__crossx-wallet-list::-webkit-scrollbar {
|
|
@@ -6589,7 +6766,7 @@ const bn = `
|
|
|
6589
6766
|
|
|
6590
6767
|
/* ── Mobile bottom sheet ───────────────────────────────────── */
|
|
6591
6768
|
@media (max-width: 480px) {
|
|
6592
|
-
#${
|
|
6769
|
+
#${se} { align-items: flex-end; }
|
|
6593
6770
|
.__crossx-card {
|
|
6594
6771
|
width: 100%;
|
|
6595
6772
|
max-width: 100%;
|
|
@@ -6601,6 +6778,18 @@ const bn = `
|
|
|
6601
6778
|
}
|
|
6602
6779
|
.__crossx-card--wallet-selector {
|
|
6603
6780
|
overflow: hidden !important;
|
|
6781
|
+
display: flex !important;
|
|
6782
|
+
flex-direction: column !important;
|
|
6783
|
+
}
|
|
6784
|
+
.__crossx-card--wallet-selector .__crossx-body {
|
|
6785
|
+
flex: 1;
|
|
6786
|
+
min-height: 0;
|
|
6787
|
+
overflow: hidden;
|
|
6788
|
+
display: flex;
|
|
6789
|
+
flex-direction: column;
|
|
6790
|
+
}
|
|
6791
|
+
.__crossx-card--wallet-selector .__crossx-col-right-ws {
|
|
6792
|
+
min-height: 0;
|
|
6604
6793
|
}
|
|
6605
6794
|
.__crossx-card--wallet-selector .__crossx-wallet-list { max-height: 203px; }
|
|
6606
6795
|
.__crossx-card--send-tx,
|
|
@@ -6728,7 +6917,7 @@ const bn = `
|
|
|
6728
6917
|
|
|
6729
6918
|
/* ── Landscape for signing/transaction modals ──────────── */
|
|
6730
6919
|
@media (orientation: landscape) and (max-height: 500px) {
|
|
6731
|
-
#${
|
|
6920
|
+
#${se} { align-items: center !important; overflow: hidden; }
|
|
6732
6921
|
.__crossx-card--send-tx,
|
|
6733
6922
|
.__crossx-card--sign-tx,
|
|
6734
6923
|
.__crossx-card--sign-msg,
|
|
@@ -7025,6 +7214,24 @@ const bn = `
|
|
|
7025
7214
|
flex-shrink: 0;
|
|
7026
7215
|
color: var(--cx-error);
|
|
7027
7216
|
}
|
|
7217
|
+
/* 시도 횟수 카운트 (X/Y) */
|
|
7218
|
+
.__crossx-pin6-attempt {
|
|
7219
|
+
font-size: 16px;
|
|
7220
|
+
font-weight: 500;
|
|
7221
|
+
line-height: 1.5;
|
|
7222
|
+
color: var(--cx-error);
|
|
7223
|
+
text-align: center;
|
|
7224
|
+
letter-spacing: -0.16px;
|
|
7225
|
+
margin: 0;
|
|
7226
|
+
}
|
|
7227
|
+
.__crossx-pin6-warning {
|
|
7228
|
+
font-size: 14px;
|
|
7229
|
+
font-weight: 500;
|
|
7230
|
+
line-height: 1.5;
|
|
7231
|
+
color: var(--cx-error);
|
|
7232
|
+
text-align: center;
|
|
7233
|
+
margin: 0;
|
|
7234
|
+
}
|
|
7028
7235
|
/* Next 버튼 */
|
|
7029
7236
|
.__crossx-pin6-next {
|
|
7030
7237
|
width: 100%;
|
|
@@ -7047,30 +7254,45 @@ const bn = `
|
|
|
7047
7254
|
}
|
|
7048
7255
|
`;
|
|
7049
7256
|
function he() {
|
|
7050
|
-
let r = document.getElementById(
|
|
7051
|
-
r || (r = document.createElement("style"), r.id =
|
|
7257
|
+
let r = document.getElementById(Jt);
|
|
7258
|
+
r || (r = document.createElement("style"), r.id = Jt, document.head.appendChild(r)), r.textContent = Sn;
|
|
7052
7259
|
}
|
|
7053
7260
|
function pe(r) {
|
|
7054
7261
|
const e = (s) => s.stopPropagation();
|
|
7055
|
-
for (const s of ["pointerdown", "pointerup", "mousedown", "mouseup", "click"
|
|
7262
|
+
for (const s of ["pointerdown", "pointerup", "mousedown", "mouseup", "click"])
|
|
7056
7263
|
r.addEventListener(s, e);
|
|
7264
|
+
for (const s of ["touchstart", "touchend"])
|
|
7265
|
+
r.addEventListener(s, e, { passive: !0 });
|
|
7057
7266
|
document.body.appendChild(r);
|
|
7058
7267
|
}
|
|
7059
|
-
|
|
7268
|
+
const vn = () => /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
7269
|
+
function nt() {
|
|
7270
|
+
if (vn()) {
|
|
7271
|
+
const e = window.scrollY;
|
|
7272
|
+
return document.body.style.position = "fixed", document.body.style.top = `-${e}px`, document.body.style.left = "0", document.body.style.right = "0", () => {
|
|
7273
|
+
document.body.style.position = "", document.body.style.top = "", document.body.style.left = "", document.body.style.right = "", window.scrollTo(0, e);
|
|
7274
|
+
};
|
|
7275
|
+
}
|
|
7276
|
+
const r = document.body.style.overflow;
|
|
7277
|
+
return document.body.style.overflow = "hidden", () => {
|
|
7278
|
+
document.body.style.overflow = r;
|
|
7279
|
+
};
|
|
7280
|
+
}
|
|
7281
|
+
function re(r) {
|
|
7060
7282
|
return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
|
|
7061
7283
|
}
|
|
7062
|
-
function
|
|
7284
|
+
function En(r, e = "CROSS", s = 18) {
|
|
7063
7285
|
if (!r || r === "0x" || r === "0x0") return null;
|
|
7064
7286
|
try {
|
|
7065
7287
|
const t = BigInt(r);
|
|
7066
7288
|
if (t === 0n) return null;
|
|
7067
|
-
const n =
|
|
7289
|
+
const n = ht(t, s);
|
|
7068
7290
|
return n === "0" ? null : `${n} ${e}`;
|
|
7069
7291
|
} catch {
|
|
7070
7292
|
return null;
|
|
7071
7293
|
}
|
|
7072
7294
|
}
|
|
7073
|
-
const
|
|
7295
|
+
const Qt = {
|
|
7074
7296
|
1: "Ethereum Mainnet",
|
|
7075
7297
|
5: "Goerli Testnet",
|
|
7076
7298
|
11155111: "Ethereum Sepolia",
|
|
@@ -7093,16 +7315,16 @@ const Xt = {
|
|
|
7093
7315
|
612044: "CROSS Testnet",
|
|
7094
7316
|
612055: "CROSS Mainnet"
|
|
7095
7317
|
};
|
|
7096
|
-
function
|
|
7318
|
+
function Ns(r) {
|
|
7097
7319
|
const e = parseInt(r.split(":")[1] ?? "", 10);
|
|
7098
|
-
return !isNaN(e) &&
|
|
7320
|
+
return !isNaN(e) && Qt[e] ? Qt[e] : r;
|
|
7099
7321
|
}
|
|
7100
|
-
function
|
|
7322
|
+
function ht(r, e) {
|
|
7101
7323
|
if (r === 0n) return "0";
|
|
7102
7324
|
const s = 10n ** BigInt(e), t = r / s, i = (r % s).toString().padStart(e, "0").slice(0, 6).replace(/0+$/, "");
|
|
7103
7325
|
return i ? `${t}.${i}` : `${t}`;
|
|
7104
7326
|
}
|
|
7105
|
-
function
|
|
7327
|
+
function ot(r) {
|
|
7106
7328
|
try {
|
|
7107
7329
|
const e = BigInt(r), s = e / 1000000000n, n = (e % 1000000000n).toString().padStart(9, "0").slice(0, 2).replace(/0+$/, "");
|
|
7108
7330
|
return n ? `${s}.${n}` : `${s}`;
|
|
@@ -7110,25 +7332,25 @@ function rt(r) {
|
|
|
7110
7332
|
return r;
|
|
7111
7333
|
}
|
|
7112
7334
|
}
|
|
7113
|
-
function
|
|
7335
|
+
function In(r) {
|
|
7114
7336
|
try {
|
|
7115
7337
|
return BigInt(r).toLocaleString();
|
|
7116
7338
|
} catch {
|
|
7117
7339
|
return r;
|
|
7118
7340
|
}
|
|
7119
7341
|
}
|
|
7120
|
-
function
|
|
7342
|
+
function An(r) {
|
|
7121
7343
|
const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
|
|
7122
7344
|
if (!e) return null;
|
|
7123
7345
|
try {
|
|
7124
|
-
const a = BigInt(e), c =
|
|
7346
|
+
const a = BigInt(e), c = In(e);
|
|
7125
7347
|
if (t) {
|
|
7126
7348
|
const l = a * BigInt(t);
|
|
7127
7349
|
return {
|
|
7128
7350
|
isDynamic: !0,
|
|
7129
|
-
estTxFee: `${
|
|
7130
|
-
maxFeeGwei:
|
|
7131
|
-
maxPriorityFeeGwei: n ?
|
|
7351
|
+
estTxFee: `${ht(l, i)} ${o}`,
|
|
7352
|
+
maxFeeGwei: ot(t),
|
|
7353
|
+
maxPriorityFeeGwei: n ? ot(n) : void 0,
|
|
7132
7354
|
gasLimitFormatted: c
|
|
7133
7355
|
};
|
|
7134
7356
|
}
|
|
@@ -7136,8 +7358,8 @@ function En(r) {
|
|
|
7136
7358
|
const l = a * BigInt(s);
|
|
7137
7359
|
return {
|
|
7138
7360
|
isDynamic: !1,
|
|
7139
|
-
estTxFee: `${
|
|
7140
|
-
gasPriceGwei:
|
|
7361
|
+
estTxFee: `${ht(l, i)} ${o}`,
|
|
7362
|
+
gasPriceGwei: ot(s),
|
|
7141
7363
|
gasLimitFormatted: c
|
|
7142
7364
|
};
|
|
7143
7365
|
}
|
|
@@ -7146,11 +7368,11 @@ function En(r) {
|
|
|
7146
7368
|
return null;
|
|
7147
7369
|
}
|
|
7148
7370
|
}
|
|
7149
|
-
function
|
|
7150
|
-
const e =
|
|
7151
|
-
if (!e) return
|
|
7152
|
-
let s =
|
|
7153
|
-
return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s +=
|
|
7371
|
+
function Ls(r) {
|
|
7372
|
+
const e = An(r);
|
|
7373
|
+
if (!e) return j("Estimated fee", "<span>—</span>");
|
|
7374
|
+
let s = j("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
|
|
7375
|
+
return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += j("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += j("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += j("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += j("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
|
|
7154
7376
|
}
|
|
7155
7377
|
const ge = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
7156
7378
|
<rect x="9" y="9" width="13" height="13" rx="2"/>
|
|
@@ -7158,16 +7380,16 @@ const ge = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="
|
|
|
7158
7380
|
</svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
|
|
7159
7381
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
7160
7382
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
7161
|
-
</svg>`,
|
|
7383
|
+
</svg>`, Tn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7162
7384
|
<circle cx="20" cy="20" r="20" fill="#00D5AA"/>
|
|
7163
7385
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.3225 2.85742L23.7249 6.25982V11.8301L28.1175 7.43757L32.9292 12.2493L28.5806 16.5979H20.3225C18.4435 16.5979 16.9201 18.1212 16.9201 20.0003C16.9201 21.8794 18.4434 23.4027 20.3225 23.4027H28.5372L32.9293 27.7948L28.1176 32.6066L23.7249 28.2139V33.7407L20.3225 37.1431L16.9201 33.7407V28.2584L12.5719 32.6066L7.76022 27.7948L12.1524 23.4027H6.58209L3.17969 20.0003L6.58209 16.5979H12.1089L7.76035 12.2493L12.5721 7.43757L16.9201 11.7857V6.25982L20.3225 2.85742Z" fill="#121212"/>
|
|
7164
|
-
</svg>`,
|
|
7386
|
+
</svg>`, bt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
7165
7387
|
<rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
|
|
7166
7388
|
<path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
|
|
7167
7389
|
<rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
|
|
7168
|
-
</svg>`,
|
|
7390
|
+
</svg>`, Rn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
7169
7391
|
<path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="var(--cx-error)"/>
|
|
7170
|
-
</svg>`,
|
|
7392
|
+
</svg>`, kn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
7171
7393
|
<circle cx="12" cy="12" r="12" fill="var(--cx-error)"/>
|
|
7172
7394
|
<circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
|
|
7173
7395
|
<path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
|
|
@@ -7198,17 +7420,17 @@ function ce(r) {
|
|
|
7198
7420
|
`--cx-on-primary:${r.onPrimary}`
|
|
7199
7421
|
].join(";");
|
|
7200
7422
|
}
|
|
7201
|
-
function
|
|
7423
|
+
function j(r, e) {
|
|
7202
7424
|
return `
|
|
7203
7425
|
<div class="__crossx-row">
|
|
7204
7426
|
<span class="__crossx-row-label">${r}</span>
|
|
7205
7427
|
<div class="__crossx-row-value">${e}</div>
|
|
7206
7428
|
</div>`;
|
|
7207
7429
|
}
|
|
7208
|
-
function
|
|
7209
|
-
const s = e, t =
|
|
7210
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7211
|
-
return a.id =
|
|
7430
|
+
function Pn(r, e) {
|
|
7431
|
+
const s = e, t = Xe(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${re(r.to)}</span>
|
|
7432
|
+
<button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${ge}</button>` : "<span>—</span>", o = Ls(r), i = r.data ?? "0x", a = document.createElement("div");
|
|
7433
|
+
return a.id = se, a.innerHTML = `
|
|
7212
7434
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7213
7435
|
<div class="__crossx-header">
|
|
7214
7436
|
<p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
|
|
@@ -7219,22 +7441,22 @@ function Rn(r, e) {
|
|
|
7219
7441
|
<div class="__crossx-body-cols">
|
|
7220
7442
|
<div class="__crossx-col-left">
|
|
7221
7443
|
<p class="__crossx-sig-subtitle">
|
|
7222
|
-
<span class="__crossx-sig-origin">${
|
|
7444
|
+
<span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
|
|
7223
7445
|
</p>
|
|
7224
7446
|
<div class="__crossx-addr-pill">
|
|
7225
|
-
${
|
|
7226
|
-
<span class="__crossx-addr-pill-text">${
|
|
7447
|
+
${bt}
|
|
7448
|
+
<span class="__crossx-addr-pill-text">${re(r.from)}</span>
|
|
7227
7449
|
</div>
|
|
7228
7450
|
<p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
|
|
7229
7451
|
</div>
|
|
7230
7452
|
<hr class="__crossx-divider __crossx-divider--cols">
|
|
7231
7453
|
<div class="__crossx-col-right-sign">
|
|
7232
7454
|
<div class="__crossx-rows">
|
|
7233
|
-
${
|
|
7234
|
-
${
|
|
7455
|
+
${j("To", n)}
|
|
7456
|
+
${j("Network", `<span>${Ns(r.chainId)}</span>`)}
|
|
7235
7457
|
${o}
|
|
7236
7458
|
</div>
|
|
7237
|
-
<pre class="__crossx-raw-tx">${
|
|
7459
|
+
<pre class="__crossx-raw-tx">${$(i)}</pre>
|
|
7238
7460
|
</div>
|
|
7239
7461
|
</div>
|
|
7240
7462
|
<div class="__crossx-btn-row">
|
|
@@ -7245,10 +7467,10 @@ function Rn(r, e) {
|
|
|
7245
7467
|
</div>
|
|
7246
7468
|
`, a;
|
|
7247
7469
|
}
|
|
7248
|
-
function
|
|
7249
|
-
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o =
|
|
7250
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7251
|
-
return u.id =
|
|
7470
|
+
function On(r, e) {
|
|
7471
|
+
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Xe(r.dappName), i = r.to ? `<span class="__crossx-addr-text">${re(r.to)}</span>
|
|
7472
|
+
<button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${ge}</button>` : "<span>—</span>", a = Ls(r), l = En(r.value, t, n) ?? "—", u = document.createElement("div");
|
|
7473
|
+
return u.id = se, u.innerHTML = `
|
|
7252
7474
|
<div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7253
7475
|
<div class="__crossx-header">
|
|
7254
7476
|
<p class="__crossx-title" id="__crossx-ttl">Approve transaction</p>
|
|
@@ -7257,16 +7479,16 @@ function kn(r, e) {
|
|
|
7257
7479
|
<hr class="__crossx-divider">
|
|
7258
7480
|
<div class="__crossx-body">
|
|
7259
7481
|
<p class="__crossx-tx-subtitle">
|
|
7260
|
-
<span class="__crossx-sig-origin">${
|
|
7482
|
+
<span class="__crossx-sig-origin">${$(o)}</span> wants your permission to approve the following transaction.
|
|
7261
7483
|
</p>
|
|
7262
7484
|
<div class="__crossx-body-cols">
|
|
7263
7485
|
<div class="__crossx-rows">
|
|
7264
|
-
${
|
|
7265
|
-
${
|
|
7486
|
+
${j("To", i)}
|
|
7487
|
+
${j("Network", `<span>${Ns(r.chainId)}</span>`)}
|
|
7266
7488
|
${a}
|
|
7267
7489
|
</div>
|
|
7268
7490
|
<div class="__crossx-pill">
|
|
7269
|
-
<span class="__crossx-pill-from">${
|
|
7491
|
+
<span class="__crossx-pill-from">${re(r.from)}</span>
|
|
7270
7492
|
<span class="__crossx-pill-amount">${l}</span>
|
|
7271
7493
|
</div>
|
|
7272
7494
|
</div>
|
|
@@ -7275,7 +7497,7 @@ function kn(r, e) {
|
|
|
7275
7497
|
</div>
|
|
7276
7498
|
`, u;
|
|
7277
7499
|
}
|
|
7278
|
-
function
|
|
7500
|
+
function Xe(r) {
|
|
7279
7501
|
var e;
|
|
7280
7502
|
if (r) return r;
|
|
7281
7503
|
try {
|
|
@@ -7284,33 +7506,33 @@ function Ye(r) {
|
|
|
7284
7506
|
return "This site";
|
|
7285
7507
|
}
|
|
7286
7508
|
}
|
|
7287
|
-
function
|
|
7509
|
+
function $(r) {
|
|
7288
7510
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7289
7511
|
}
|
|
7290
|
-
function
|
|
7512
|
+
function Cn(r) {
|
|
7291
7513
|
return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
|
|
7292
7514
|
}
|
|
7293
|
-
function
|
|
7294
|
-
if (typeof r == "string") return
|
|
7515
|
+
function Nn(r) {
|
|
7516
|
+
if (typeof r == "string") return $(r);
|
|
7295
7517
|
if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
|
|
7296
7518
|
try {
|
|
7297
|
-
return
|
|
7519
|
+
return $(JSON.stringify(r));
|
|
7298
7520
|
} catch {
|
|
7299
7521
|
return String(r);
|
|
7300
7522
|
}
|
|
7301
7523
|
}
|
|
7302
|
-
function
|
|
7303
|
-
const s =
|
|
7524
|
+
function Ln(r, e) {
|
|
7525
|
+
const s = j(
|
|
7304
7526
|
"From",
|
|
7305
|
-
`<span class="__crossx-addr-text">${
|
|
7306
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7307
|
-
), t = r.to ?
|
|
7308
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7309
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7527
|
+
`<span class="__crossx-addr-text">${re(r.from)}</span>
|
|
7528
|
+
<button class="__crossx-copy-btn" data-copy="${$(r.from)}" title="Copy address">${ge}</button>`
|
|
7529
|
+
), t = r.to ? j("To", `<span class="__crossx-addr-text">${re(r.to)}</span>
|
|
7530
|
+
<button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${ge}</button>`) : "", n = r.amount ? j("Transfer", `<span>${$(r.amount)}</span>`) : "", o = r.fees ? j("Tx Fee", `<span>${$(r.fees)}</span>`) : "", i = r.txHash ? j("Tx Hash", `<span class="__crossx-addr-text">${re(r.txHash)}</span>
|
|
7531
|
+
<button class="__crossx-copy-btn" data-copy="${$(r.txHash)}" title="Copy hash">${ge}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
|
|
7310
7532
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7311
|
-
<span class="__crossx-total-amount">${
|
|
7533
|
+
<span class="__crossx-total-amount">${$(r.total)}</span>
|
|
7312
7534
|
</div>` : "", c = document.createElement("div");
|
|
7313
|
-
return c.id =
|
|
7535
|
+
return c.id = se, c.innerHTML = `
|
|
7314
7536
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7315
7537
|
<div class="__crossx-header">
|
|
7316
7538
|
<p class="__crossx-title" id="__crossx-ttl">Transaction complete</p>
|
|
@@ -7331,9 +7553,9 @@ function Cn(r, e) {
|
|
|
7331
7553
|
</div>
|
|
7332
7554
|
`, c;
|
|
7333
7555
|
}
|
|
7334
|
-
function
|
|
7556
|
+
function Dn(r, e) {
|
|
7335
7557
|
const s = document.createElement("div");
|
|
7336
|
-
return s.id =
|
|
7558
|
+
return s.id = se, s.innerHTML = `
|
|
7337
7559
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7338
7560
|
<div class="__crossx-header">
|
|
7339
7561
|
<p class="__crossx-title" id="__crossx-ttl">Waiting for confirmation</p>
|
|
@@ -7348,11 +7570,11 @@ function Nn(r, e) {
|
|
|
7348
7570
|
</div>
|
|
7349
7571
|
`, s;
|
|
7350
7572
|
}
|
|
7351
|
-
function
|
|
7573
|
+
function Mn(r, e, s) {
|
|
7352
7574
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
7353
7575
|
if (o) {
|
|
7354
|
-
const w = n ?
|
|
7355
|
-
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${
|
|
7576
|
+
const w = n ? kn : t ? "" : Rn, E = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
7577
|
+
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${E}</span>`) : o.textContent = E;
|
|
7356
7578
|
}
|
|
7357
7579
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
7358
7580
|
const w = document.createElement("button");
|
|
@@ -7360,12 +7582,12 @@ function Ln(r, e, s) {
|
|
|
7360
7582
|
}
|
|
7361
7583
|
const a = r.querySelector("#__crossx-progress-body");
|
|
7362
7584
|
if (!a) return;
|
|
7363
|
-
const c = e.from ?
|
|
7364
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7365
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7366
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7585
|
+
const c = e.from ? j("From", `<span class="__crossx-addr-text">${re(e.from)}</span>
|
|
7586
|
+
<button class="__crossx-copy-btn" data-copy="${$(e.from)}" title="Copy address">${ge}</button>`) : "", l = e.to ? j("To", `<span class="__crossx-addr-text">${re(e.to)}</span>
|
|
7587
|
+
<button class="__crossx-copy-btn" data-copy="${$(e.to)}" title="Copy address">${ge}</button>`) : "", u = e.amount ? j("Transfer", `<span>${$(e.amount)}</span>`) : "", h = e.fees ? j("Tx Fee", `<span>${$(e.fees)}</span>`) : "", _ = e.txHash ? j("Tx Hash", `<span class="__crossx-addr-text">${re(e.txHash)}</span>
|
|
7588
|
+
<button class="__crossx-copy-btn" data-copy="${$(e.txHash)}" title="Copy hash">${ge}</button>`) : "", f = e.total ? `<div class="__crossx-total-pill">
|
|
7367
7589
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7368
|
-
<span class="__crossx-total-amount">${
|
|
7590
|
+
<span class="__crossx-total-amount">${$(e.total)}</span>
|
|
7369
7591
|
</div>` : "";
|
|
7370
7592
|
a.innerHTML = `
|
|
7371
7593
|
<div class="__crossx-rows">
|
|
@@ -7378,18 +7600,18 @@ function Ln(r, e, s) {
|
|
|
7378
7600
|
${f}
|
|
7379
7601
|
<button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
|
|
7380
7602
|
`, a.querySelectorAll(".__crossx-copy-btn").forEach((w) => {
|
|
7381
|
-
w.addEventListener("click", (
|
|
7382
|
-
var
|
|
7383
|
-
|
|
7603
|
+
w.addEventListener("click", (E) => {
|
|
7604
|
+
var R;
|
|
7605
|
+
E.stopPropagation();
|
|
7384
7606
|
const y = w.dataset.copy;
|
|
7385
|
-
y && ((
|
|
7607
|
+
y && ((R = navigator.clipboard) == null || R.writeText(y).catch(() => {
|
|
7386
7608
|
}));
|
|
7387
7609
|
});
|
|
7388
7610
|
});
|
|
7389
7611
|
}
|
|
7390
|
-
function
|
|
7391
|
-
const s = e, t =
|
|
7392
|
-
return o.id =
|
|
7612
|
+
function $n(r, e) {
|
|
7613
|
+
const s = e, t = Xe(r.dappName), n = $(r.message), o = document.createElement("div");
|
|
7614
|
+
return o.id = se, o.innerHTML = `
|
|
7393
7615
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7394
7616
|
<div class="__crossx-header">
|
|
7395
7617
|
<p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
|
|
@@ -7400,11 +7622,11 @@ function Dn(r, e) {
|
|
|
7400
7622
|
<div class="__crossx-body-cols">
|
|
7401
7623
|
<div class="__crossx-col-left">
|
|
7402
7624
|
<p class="__crossx-sig-subtitle">
|
|
7403
|
-
<span class="__crossx-sig-origin">${
|
|
7625
|
+
<span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
|
|
7404
7626
|
</p>
|
|
7405
7627
|
<div class="__crossx-addr-pill">
|
|
7406
|
-
${
|
|
7407
|
-
<span class="__crossx-addr-pill-text">${
|
|
7628
|
+
${bt}
|
|
7629
|
+
<span class="__crossx-addr-pill-text">${re(r.from)}</span>
|
|
7408
7630
|
</div>
|
|
7409
7631
|
<p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
|
|
7410
7632
|
</div>
|
|
@@ -7419,8 +7641,8 @@ function Dn(r, e) {
|
|
|
7419
7641
|
</div>
|
|
7420
7642
|
`, o;
|
|
7421
7643
|
}
|
|
7422
|
-
function
|
|
7423
|
-
const s = e, t =
|
|
7644
|
+
function Bn(r, e) {
|
|
7645
|
+
const s = e, t = Xe(r.dappName);
|
|
7424
7646
|
let n = {};
|
|
7425
7647
|
if (typeof r.typedData == "string")
|
|
7426
7648
|
try {
|
|
@@ -7432,19 +7654,19 @@ function Mn(r, e) {
|
|
|
7432
7654
|
let a = `
|
|
7433
7655
|
<div class="__crossx-td-row">
|
|
7434
7656
|
<span class="__crossx-td-label">Primary Type</span>
|
|
7435
|
-
<span class="__crossx-td-value">${
|
|
7657
|
+
<span class="__crossx-td-value">${$(o)}</span>
|
|
7436
7658
|
</div>`;
|
|
7437
7659
|
for (const [l, u] of Object.entries(i)) {
|
|
7438
|
-
const h =
|
|
7439
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7660
|
+
const h = Nn(u), f = Cn(u) ? `<span class="__crossx-addr-text">${re(u)}</span>
|
|
7661
|
+
<button class="__crossx-copy-btn" data-copy="${$(String(u))}" title="Copy">${ge}</button>` : `<span>${h}</span>`;
|
|
7440
7662
|
a += `
|
|
7441
7663
|
<div class="__crossx-td-row">
|
|
7442
|
-
<span class="__crossx-td-label">${
|
|
7664
|
+
<span class="__crossx-td-label">${$(l)}</span>
|
|
7443
7665
|
<div class="__crossx-td-value">${f}</div>
|
|
7444
7666
|
</div>`;
|
|
7445
7667
|
}
|
|
7446
7668
|
const c = document.createElement("div");
|
|
7447
|
-
return c.id =
|
|
7669
|
+
return c.id = se, c.innerHTML = `
|
|
7448
7670
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-typed" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7449
7671
|
<div class="__crossx-header">
|
|
7450
7672
|
<p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
|
|
@@ -7455,11 +7677,11 @@ function Mn(r, e) {
|
|
|
7455
7677
|
<div class="__crossx-body-cols">
|
|
7456
7678
|
<div class="__crossx-col-left">
|
|
7457
7679
|
<p class="__crossx-sig-subtitle">
|
|
7458
|
-
<span class="__crossx-sig-origin">${
|
|
7680
|
+
<span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
|
|
7459
7681
|
</p>
|
|
7460
7682
|
<div class="__crossx-addr-pill">
|
|
7461
|
-
${
|
|
7462
|
-
<span class="__crossx-addr-pill-text">${
|
|
7683
|
+
${bt}
|
|
7684
|
+
<span class="__crossx-addr-pill-text">${re(r.from)}</span>
|
|
7463
7685
|
</div>
|
|
7464
7686
|
<p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
|
|
7465
7687
|
</div>
|
|
@@ -7474,18 +7696,18 @@ function Mn(r, e) {
|
|
|
7474
7696
|
</div>
|
|
7475
7697
|
`, c;
|
|
7476
7698
|
}
|
|
7477
|
-
const
|
|
7699
|
+
const Un = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
7478
7700
|
<line x1="12" y1="5" x2="12" y2="19"/>
|
|
7479
7701
|
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
7480
7702
|
</svg>`;
|
|
7481
|
-
function
|
|
7703
|
+
function Hn(r, e, s) {
|
|
7482
7704
|
const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
|
|
7483
7705
|
const a = t && i.address.toLowerCase() === t;
|
|
7484
|
-
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${
|
|
7485
|
-
<span class="__crossx-wallet-addr">${
|
|
7706
|
+
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${$(i.address)}">
|
|
7707
|
+
<span class="__crossx-wallet-addr">${re(i.address)}</span>${a ? '<span class="__crossx-wallet-selected">selected</span>' : ""}
|
|
7486
7708
|
</button>`;
|
|
7487
7709
|
}).join(""), o = document.createElement("div");
|
|
7488
|
-
return o.id =
|
|
7710
|
+
return o.id = se, o.innerHTML = `
|
|
7489
7711
|
<div class="__crossx-card __crossx-card--migration __crossx-card--wallet-selector" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7490
7712
|
<div class="__crossx-header">
|
|
7491
7713
|
<div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
|
|
@@ -7509,7 +7731,7 @@ function Bn(r, e, s) {
|
|
|
7509
7731
|
${n}
|
|
7510
7732
|
</div>
|
|
7511
7733
|
<button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
|
|
7512
|
-
<span class="__crossx-wallet-add-icon">${
|
|
7734
|
+
<span class="__crossx-wallet-add-icon">${Un}</span>
|
|
7513
7735
|
<span class="__crossx-wallet-add-label">add a wallet</span>
|
|
7514
7736
|
</button>
|
|
7515
7737
|
</div>
|
|
@@ -7518,16 +7740,16 @@ function Bn(r, e, s) {
|
|
|
7518
7740
|
</div>
|
|
7519
7741
|
`, o;
|
|
7520
7742
|
}
|
|
7521
|
-
const
|
|
7743
|
+
const Fn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7522
7744
|
<path d="M26.693 21.193c-.028-3.168 2.587-4.712 2.706-4.786-1.477-2.16-3.77-2.454-4.58-2.484-1.944-.197-3.804 1.148-4.793 1.148-.992 0-2.52-1.12-4.147-1.09-2.13.032-4.1 1.239-5.198 3.133-2.222 3.855-.569 9.562 1.593 12.69 1.061 1.535 2.318 3.258 3.975 3.196 1.6-.064 2.2-1.03 4.133-1.03 1.928 0 2.48 1.03 4.172.997 1.72-.03 2.806-1.56 3.862-3.1 1.211-1.779 1.713-3.495 1.74-3.583-.037-.017-3.427-1.316-3.463-5.09z" fill="currentColor"/>
|
|
7523
7745
|
<path d="M23.527 11.876c.877-1.065 1.471-2.545 1.31-4.024-1.266.053-2.807.845-3.718 1.907-.813.946-1.53 2.468-1.34 3.915 1.41.107 2.852-.716 3.748-1.798z" fill="currentColor"/>
|
|
7524
|
-
</svg>`,
|
|
7746
|
+
</svg>`, Gn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7525
7747
|
<path d="M38.06 20.44c0-1.34-.12-2.63-.34-3.87H20.5v7.32h9.84c-.42 2.28-1.71 4.21-3.65 5.51v4.57h5.91c3.46-3.19 5.46-7.88 5.46-13.53z" fill="#4285F4"/>
|
|
7526
7748
|
<path d="M20.5 38.5c4.94 0 9.09-1.64 12.12-4.44l-5.91-4.57c-1.64 1.1-3.73 1.75-6.21 1.75-4.77 0-8.82-3.22-10.26-7.55H4.16v4.72A18.49 18.49 0 0 0 20.5 38.5z" fill="#34A853"/>
|
|
7527
7749
|
<path d="M10.24 23.69A11.16 11.16 0 0 1 9.66 20c0-1.28.22-2.52.58-3.69v-4.72H4.16A18.49 18.49 0 0 0 2 20c0 2.97.71 5.78 1.97 8.28l6.27-4.59z" fill="#FBBC05"/>
|
|
7528
7750
|
<path d="M20.5 8.76c2.69 0 5.1.92 7 2.73l5.24-5.24C29.58 3.36 25.43 1.5 20.5 1.5A18.49 18.49 0 0 0 4.16 11.59l6.08 4.72C11.68 11.98 15.73 8.76 20.5 8.76z" fill="#EA4335"/>
|
|
7529
7751
|
</svg>`;
|
|
7530
|
-
function
|
|
7752
|
+
function Wn(r, e = !1) {
|
|
7531
7753
|
const s = r, t = e ? `
|
|
7532
7754
|
<div class="__crossx-login-or-divider">
|
|
7533
7755
|
<hr><span>or</span><hr>
|
|
@@ -7538,7 +7760,7 @@ function Fn(r, e = !1) {
|
|
|
7538
7760
|
<span class="__crossx-connect-other-desc">Connect your existing Web3 wallet to manage your assets.</span>
|
|
7539
7761
|
</div>
|
|
7540
7762
|
</button>` : "", n = document.createElement("div");
|
|
7541
|
-
return n.id =
|
|
7763
|
+
return n.id = se, n.innerHTML = `
|
|
7542
7764
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7543
7765
|
<div class="__crossx-header">
|
|
7544
7766
|
<div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
|
|
@@ -7551,11 +7773,11 @@ function Fn(r, e = !1) {
|
|
|
7551
7773
|
<div class="__crossx-body">
|
|
7552
7774
|
<div class="__crossx-login-btn-row">
|
|
7553
7775
|
<button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
|
|
7554
|
-
<span class="__crossx-login-icon" style="color:var(--cx-value);">${
|
|
7776
|
+
<span class="__crossx-login-icon" style="color:var(--cx-value);">${Fn}</span>
|
|
7555
7777
|
<span class="__crossx-login-btn-label">Sign in with Apple</span>
|
|
7556
7778
|
</button>
|
|
7557
7779
|
<button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
|
|
7558
|
-
<span class="__crossx-login-icon">${
|
|
7780
|
+
<span class="__crossx-login-icon">${Gn}</span>
|
|
7559
7781
|
<span class="__crossx-login-btn-label">Sign in with Google</span>
|
|
7560
7782
|
</button>
|
|
7561
7783
|
</div>${t}
|
|
@@ -7566,9 +7788,9 @@ function Fn(r, e = !1) {
|
|
|
7566
7788
|
</div>
|
|
7567
7789
|
`, n;
|
|
7568
7790
|
}
|
|
7569
|
-
function
|
|
7791
|
+
function qn(r, e = !0) {
|
|
7570
7792
|
const s = r, t = e ? `<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>` : "", n = e ? '<button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>' : "", o = document.createElement("div");
|
|
7571
|
-
return o.id =
|
|
7793
|
+
return o.id = se, o.innerHTML = `
|
|
7572
7794
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7573
7795
|
<div class="__crossx-header">
|
|
7574
7796
|
<p class="__crossx-title" id="__crossx-ttl">Wallet Found on Social Account 🎉</p>
|
|
@@ -7582,7 +7804,7 @@ function Gn(r, e = !0) {
|
|
|
7582
7804
|
<p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
|
|
7583
7805
|
</div>
|
|
7584
7806
|
<button class="__crossx-recover-btn" id="__crossx-recover-btn">
|
|
7585
|
-
<span class="__crossx-recover-icon">${
|
|
7807
|
+
<span class="__crossx-recover-icon">${Tn}</span>
|
|
7586
7808
|
<span class="__crossx-recover-label">Import from Social Backup</span>
|
|
7587
7809
|
</button>
|
|
7588
7810
|
${n}
|
|
@@ -7590,9 +7812,9 @@ function Gn(r, e = !0) {
|
|
|
7590
7812
|
</div>
|
|
7591
7813
|
`, o;
|
|
7592
7814
|
}
|
|
7593
|
-
function
|
|
7815
|
+
function Kn(r, e) {
|
|
7594
7816
|
const s = r, { errorMessage: t, attemptCount: n, maxAttempts: o = 5 } = e ?? {}, i = !!t, a = i ? " --error" : "", c = n != null && n > 0 ? `<p class="__crossx-pin-attempt">${n}/${o}</p>` : "", l = n != null && n >= 3 ? '<p class="__crossx-pin-warning">Your account will be locked after further failures.</p>' : "", u = i ? `<p class="__crossx-pin-error-text">${t}</p>` : "", h = document.createElement("div");
|
|
7595
|
-
return h.id =
|
|
7817
|
+
return h.id = se, h.innerHTML = `
|
|
7596
7818
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7597
7819
|
<div class="__crossx-header">
|
|
7598
7820
|
<p class="__crossx-title" id="__crossx-ttl">Import from Social Backup</p>
|
|
@@ -7614,13 +7836,13 @@ function Wn(r, e) {
|
|
|
7614
7836
|
</div>
|
|
7615
7837
|
`, h;
|
|
7616
7838
|
}
|
|
7617
|
-
function
|
|
7839
|
+
function Vn(r) {
|
|
7618
7840
|
const e = new Date(r), s = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], t = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], n = s[e.getDay()], o = t[e.getMonth()], i = e.getDate(), a = String(e.getHours()).padStart(2, "0"), c = String(e.getMinutes()).padStart(2, "0");
|
|
7619
7841
|
return `${n}, ${o} ${i} ${a}:${c}`;
|
|
7620
7842
|
}
|
|
7621
|
-
function
|
|
7622
|
-
const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ?
|
|
7623
|
-
return a.id =
|
|
7843
|
+
function zn(r, e, s) {
|
|
7844
|
+
const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? Vn(o) : null, a = document.createElement("div");
|
|
7845
|
+
return a.id = se, a.innerHTML = `
|
|
7624
7846
|
<div class="__crossx-card __crossx-card--migration" style="${ce(t)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7625
7847
|
<div class="__crossx-header">
|
|
7626
7848
|
<p class="__crossx-title" id="__crossx-ttl">Import from Social Backup</p>
|
|
@@ -7649,17 +7871,17 @@ function Kn(r, e, s) {
|
|
|
7649
7871
|
return () => clearInterval(h);
|
|
7650
7872
|
} };
|
|
7651
7873
|
}
|
|
7652
|
-
function
|
|
7874
|
+
function jn(r) {
|
|
7653
7875
|
const s = [r.check1, r.check2].map((t, n) => `
|
|
7654
7876
|
<div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
|
|
7655
|
-
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${
|
|
7656
|
-
<span class="__crossx-pw-notice-item-text">${
|
|
7877
|
+
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${Jn}</div>
|
|
7878
|
+
<span class="__crossx-pw-notice-item-text">${$(t)}</span>
|
|
7657
7879
|
</div>
|
|
7658
7880
|
`).join("");
|
|
7659
7881
|
return `
|
|
7660
7882
|
<div class="__crossx-header">
|
|
7661
|
-
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${
|
|
7662
|
-
<p class="__crossx-pw-subtitle">${
|
|
7883
|
+
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${$(r.title)}</p>
|
|
7884
|
+
<p class="__crossx-pw-subtitle">${$(r.headerSubtitle)}</p>
|
|
7663
7885
|
<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
|
|
7664
7886
|
</div>
|
|
7665
7887
|
<hr class="__crossx-divider">
|
|
@@ -7667,35 +7889,35 @@ function Vn(r) {
|
|
|
7667
7889
|
<div class="__crossx-pw-fields __crossx-pw-fields--notice">
|
|
7668
7890
|
<div class="__crossx-pw-notice-header">
|
|
7669
7891
|
<div class="__crossx-pw-notice-title-row">
|
|
7670
|
-
<span class="__crossx-pw-notice-icon">${
|
|
7671
|
-
<p class="__crossx-pw-notice-title">${
|
|
7892
|
+
<span class="__crossx-pw-notice-icon">${Zn}</span>
|
|
7893
|
+
<p class="__crossx-pw-notice-title">${$(r.noticeTitle)}</p>
|
|
7672
7894
|
</div>
|
|
7673
|
-
<p class="__crossx-pw-notice-desc">${
|
|
7895
|
+
<p class="__crossx-pw-notice-desc">${$(r.noticeDesc)}</p>
|
|
7674
7896
|
</div>
|
|
7675
7897
|
<div class="__crossx-pw-notice-checks" id="__crossx-notice-checks">
|
|
7676
7898
|
${s}
|
|
7677
7899
|
</div>
|
|
7678
7900
|
</div>
|
|
7679
7901
|
<button class="__crossx-pw-btn --disabled" id="__crossx-pin-notice-next"
|
|
7680
|
-
data-next-label="${
|
|
7681
|
-
data-submit-label="${
|
|
7682
|
-
${
|
|
7902
|
+
data-next-label="${$(r.nextButton)}"
|
|
7903
|
+
data-submit-label="${$(r.submitButton)}">
|
|
7904
|
+
${$(r.nextButton)}
|
|
7683
7905
|
</button>
|
|
7684
7906
|
</div>
|
|
7685
7907
|
<div class="__crossx-home-indicator"></div>
|
|
7686
7908
|
`;
|
|
7687
7909
|
}
|
|
7688
|
-
function
|
|
7689
|
-
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">${
|
|
7690
|
-
${
|
|
7910
|
+
function it(r) {
|
|
7911
|
+
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">${$(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${$(r.subtitle)}</p>` : "", o = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${$(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">
|
|
7912
|
+
${Ds}
|
|
7691
7913
|
<span id="__crossx-pin6-lock-countdown"></span>
|
|
7692
|
-
</p>` : "", a = e ? " --locked" : "",
|
|
7914
|
+
</p>` : "", a = r.attemptCount != null && r.attemptCount > 0 ? `<p class="__crossx-pin6-attempt" id="__crossx-pin6-attempt">${r.attemptCount}/${r.maxAttempts ?? "?"}</p>` : '<p class="__crossx-pin6-attempt" id="__crossx-pin6-attempt"></p>', c = e ? " --locked" : "", l = Array.from(
|
|
7693
7915
|
{ length: 6 },
|
|
7694
|
-
(
|
|
7916
|
+
(u, h) => `<input class="__crossx-pin6-box${c}" type="password" maxlength="1" inputmode="numeric" pattern="[0-9]" autocomplete="off" aria-label="PIN digit ${h + 1}"${e ? " disabled" : ""}>`
|
|
7695
7917
|
).join("");
|
|
7696
7918
|
return `
|
|
7697
7919
|
<div class="__crossx-header">
|
|
7698
|
-
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${
|
|
7920
|
+
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${$(r.title)}</p>
|
|
7699
7921
|
${t}
|
|
7700
7922
|
<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
|
|
7701
7923
|
</div>
|
|
@@ -7703,149 +7925,162 @@ function nt(r) {
|
|
|
7703
7925
|
<div class="__crossx-pin6-body"${s}>
|
|
7704
7926
|
${n}
|
|
7705
7927
|
<div class="__crossx-pin6-boxes" id="__crossx-pin6-boxes">
|
|
7706
|
-
${
|
|
7928
|
+
${l}
|
|
7707
7929
|
</div>
|
|
7708
7930
|
${o}
|
|
7931
|
+
${a}
|
|
7709
7932
|
${i}
|
|
7710
7933
|
</div>
|
|
7711
7934
|
<div class="__crossx-home-indicator"></div>
|
|
7712
7935
|
`;
|
|
7713
7936
|
}
|
|
7714
|
-
function
|
|
7937
|
+
function es(r, e) {
|
|
7715
7938
|
const s = document.createElement("div");
|
|
7716
|
-
return s.id =
|
|
7939
|
+
return s.id = se, s.innerHTML = `
|
|
7717
7940
|
<div class="__crossx-card __crossx-card--pin6" style="${ce(r)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7718
7941
|
${e}
|
|
7719
7942
|
</div>
|
|
7720
7943
|
`, s;
|
|
7721
7944
|
}
|
|
7722
|
-
function
|
|
7945
|
+
function Yn(r, e) {
|
|
7723
7946
|
if (r.length !== 6) return e.tooShort;
|
|
7724
7947
|
if (!/^\d+$/.test(r)) return e.numbersOnly;
|
|
7725
7948
|
if (/(.)\1{2}/.test(r)) return e.repeatingDigit;
|
|
7726
7949
|
const s = r.split("").map(Number), t = s.every((o, i) => i === 0 || o === (s[i - 1] + 1) % 10), n = s.every((o, i) => i === 0 || o === (s[i - 1] + 9) % 10);
|
|
7727
7950
|
return t || n ? e.sequential : r[0] !== r[1] && r === r.slice(0, 2).repeat(3) ? e.alternatingPattern : null;
|
|
7728
7951
|
}
|
|
7729
|
-
function
|
|
7952
|
+
function Xn(r) {
|
|
7730
7953
|
const e = Math.max(0, Math.ceil(r / 1e3)), s = Math.floor(e / 3600), t = Math.floor(e % 3600 / 60), n = e % 60;
|
|
7731
7954
|
return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
|
|
7732
7955
|
}
|
|
7733
|
-
function
|
|
7734
|
-
var
|
|
7956
|
+
function at(r, e, s, t, n, o) {
|
|
7957
|
+
var H, z;
|
|
7735
7958
|
let i = !!(o && o > Date.now()), a = !1;
|
|
7736
|
-
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), u = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), _ = () => r.querySelector("#__crossx-pin6-lock-countdown"), f = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((
|
|
7737
|
-
i =
|
|
7738
|
-
|
|
7959
|
+
const c = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), l = () => r.querySelector("#__crossx-pin6-boxes"), u = () => r.querySelector("#__crossx-pin6-error"), h = () => r.querySelector("#__crossx-pin6-lock-msg"), _ = () => r.querySelector("#__crossx-pin6-lock-countdown"), f = () => r.querySelector(".__crossx-pin6-body"), w = () => c().map((k) => k.value).join(""), E = (k) => {
|
|
7960
|
+
i = k, c().forEach((b) => {
|
|
7961
|
+
b.disabled = k, b.classList.toggle("--locked", k);
|
|
7739
7962
|
});
|
|
7740
|
-
}, y = () => {
|
|
7741
|
-
const
|
|
7742
|
-
|
|
7743
|
-
},
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7963
|
+
}, y = () => r.querySelector("#__crossx-pin6-attempt"), R = () => {
|
|
7964
|
+
const k = u();
|
|
7965
|
+
k && (k.textContent = "");
|
|
7966
|
+
}, N = (k, b) => {
|
|
7967
|
+
var I;
|
|
7968
|
+
let S = y();
|
|
7969
|
+
if (!S) {
|
|
7970
|
+
S = document.createElement("p"), S.className = "__crossx-pin6-attempt", S.id = "__crossx-pin6-attempt";
|
|
7971
|
+
const x = u();
|
|
7972
|
+
x ? x.insertAdjacentElement("afterend", S) : (I = f()) == null || I.appendChild(S);
|
|
7973
|
+
}
|
|
7974
|
+
S.textContent = `${k}/${b}`;
|
|
7975
|
+
}, F = () => {
|
|
7976
|
+
const k = y();
|
|
7977
|
+
k && (k.textContent = "");
|
|
7978
|
+
}, M = (k) => {
|
|
7979
|
+
const b = u();
|
|
7980
|
+
b && (b.textContent = k);
|
|
7981
|
+
const S = l();
|
|
7982
|
+
S == null || S.classList.add("--shake"), setTimeout(() => S == null ? void 0 : S.classList.remove("--shake"), 500), c().forEach((I) => {
|
|
7983
|
+
I.value = "";
|
|
7749
7984
|
}), setTimeout(() => {
|
|
7750
|
-
var
|
|
7751
|
-
return (
|
|
7985
|
+
var I;
|
|
7986
|
+
return (I = c()[0]) == null ? void 0 : I.focus();
|
|
7752
7987
|
}, 50);
|
|
7753
|
-
},
|
|
7754
|
-
var
|
|
7755
|
-
|
|
7756
|
-
|
|
7988
|
+
}, V = (k) => {
|
|
7989
|
+
var g;
|
|
7990
|
+
E(!0), c().forEach((v) => {
|
|
7991
|
+
v.value = "";
|
|
7757
7992
|
});
|
|
7758
|
-
const
|
|
7759
|
-
if (
|
|
7760
|
-
const
|
|
7761
|
-
|
|
7762
|
-
const
|
|
7763
|
-
|
|
7764
|
-
}
|
|
7765
|
-
const
|
|
7766
|
-
var
|
|
7767
|
-
const
|
|
7768
|
-
|
|
7769
|
-
var
|
|
7770
|
-
return (
|
|
7771
|
-
}, 50)) :
|
|
7772
|
-
},
|
|
7773
|
-
|
|
7774
|
-
const
|
|
7775
|
-
document.contains(r) || (clearInterval(
|
|
7993
|
+
const b = u();
|
|
7994
|
+
if (b && (b.textContent = "Too many failed attempts. Please wait."), !h()) {
|
|
7995
|
+
const v = document.createElement("p");
|
|
7996
|
+
v.className = "__crossx-pin6-lock-msg", v.id = "__crossx-pin6-lock-msg", v.innerHTML = `${Ds}<span id="__crossx-pin6-lock-countdown"></span>`;
|
|
7997
|
+
const A = u();
|
|
7998
|
+
A ? A.insertAdjacentElement("afterend", v) : (g = f()) == null || g.appendChild(v);
|
|
7999
|
+
}
|
|
8000
|
+
const S = () => {
|
|
8001
|
+
var C;
|
|
8002
|
+
const v = k - Date.now(), A = _();
|
|
8003
|
+
v <= 0 ? (clearInterval(I), E(!1), (C = h()) == null || C.remove(), b && (b.textContent = ""), setTimeout(() => {
|
|
8004
|
+
var O;
|
|
8005
|
+
return (O = c()[0]) == null ? void 0 : O.focus();
|
|
8006
|
+
}, 50)) : A && (A.textContent = ` ${Xn(v)}`);
|
|
8007
|
+
}, I = setInterval(S, 1e3);
|
|
8008
|
+
S();
|
|
8009
|
+
const x = new MutationObserver(() => {
|
|
8010
|
+
document.contains(r) || (clearInterval(I), x.disconnect());
|
|
7776
8011
|
});
|
|
7777
|
-
|
|
7778
|
-
},
|
|
8012
|
+
x.observe(document.body, { childList: !0, subtree: !1 });
|
|
8013
|
+
}, G = async () => {
|
|
7779
8014
|
if (i || a) return;
|
|
7780
|
-
const
|
|
7781
|
-
if (
|
|
7782
|
-
a = !0, c().forEach((
|
|
7783
|
-
|
|
8015
|
+
const k = w();
|
|
8016
|
+
if (k.length === 6) {
|
|
8017
|
+
a = !0, c().forEach((b) => {
|
|
8018
|
+
b.disabled = !0;
|
|
7784
8019
|
});
|
|
7785
8020
|
try {
|
|
7786
8021
|
if (n) {
|
|
7787
|
-
const
|
|
7788
|
-
|
|
8022
|
+
const b = await n(k);
|
|
8023
|
+
b.ok ? e(k) : b.lockExpiresAt ? (F(), V(b.lockExpiresAt)) : (M(b.error ?? "Incorrect PIN. Please try again."), b.attemptCount != null && b.maxAttempts != null ? N(b.attemptCount, b.maxAttempts) : F());
|
|
7789
8024
|
} else
|
|
7790
|
-
e(
|
|
7791
|
-
} catch (
|
|
7792
|
-
t && t(
|
|
8025
|
+
e(k);
|
|
8026
|
+
} catch (b) {
|
|
8027
|
+
t && t(b);
|
|
7793
8028
|
} finally {
|
|
7794
|
-
a = !1, i || c().forEach((
|
|
7795
|
-
|
|
8029
|
+
a = !1, i || c().forEach((b) => {
|
|
8030
|
+
b.disabled = !1;
|
|
7796
8031
|
});
|
|
7797
8032
|
}
|
|
7798
8033
|
}
|
|
7799
8034
|
};
|
|
7800
|
-
o && o > Date.now() ?
|
|
7801
|
-
var
|
|
7802
|
-
return (
|
|
8035
|
+
o && o > Date.now() ? V(o) : setTimeout(() => {
|
|
8036
|
+
var k;
|
|
8037
|
+
return (k = c()[0]) == null ? void 0 : k.focus();
|
|
7803
8038
|
}, 100);
|
|
7804
|
-
const
|
|
8039
|
+
const J = () => {
|
|
7805
8040
|
if (i || a) return;
|
|
7806
|
-
const
|
|
7807
|
-
|
|
8041
|
+
const k = c(), b = k.find((S) => !S.value) ?? k[k.length - 1];
|
|
8042
|
+
b == null || b.focus();
|
|
7808
8043
|
};
|
|
7809
|
-
(
|
|
7810
|
-
|
|
7811
|
-
}), (
|
|
7812
|
-
const
|
|
7813
|
-
|
|
7814
|
-
}), c().forEach((
|
|
7815
|
-
|
|
7816
|
-
var
|
|
7817
|
-
const
|
|
7818
|
-
|
|
7819
|
-
}),
|
|
7820
|
-
var
|
|
7821
|
-
if (
|
|
7822
|
-
if (
|
|
7823
|
-
|
|
7824
|
-
else if (
|
|
7825
|
-
const
|
|
7826
|
-
|
|
8044
|
+
(H = l()) == null || H.addEventListener("click", (k) => {
|
|
8045
|
+
k.target.classList.contains("__crossx-pin6-box") || J();
|
|
8046
|
+
}), (z = f()) == null || z.addEventListener("click", (k) => {
|
|
8047
|
+
const b = k.target;
|
|
8048
|
+
b.classList.contains("__crossx-pin6-box") || b.closest("button") || J();
|
|
8049
|
+
}), c().forEach((k, b) => {
|
|
8050
|
+
k.addEventListener("input", () => {
|
|
8051
|
+
var I;
|
|
8052
|
+
const S = k.value.replace(/\D/g, "").slice(-1);
|
|
8053
|
+
k.value = S, R(), S && b < 5 && ((I = c()[b + 1]) == null || I.focus()), w().length === 6 && setTimeout(G, 80);
|
|
8054
|
+
}), k.addEventListener("keydown", (S) => {
|
|
8055
|
+
var I, x;
|
|
8056
|
+
if (S.key === "Backspace") {
|
|
8057
|
+
if (S.preventDefault(), k.value)
|
|
8058
|
+
k.value = "";
|
|
8059
|
+
else if (b > 0) {
|
|
8060
|
+
const g = c()[b - 1];
|
|
8061
|
+
g.value = "", g.focus();
|
|
7827
8062
|
}
|
|
7828
|
-
} else
|
|
7829
|
-
}),
|
|
7830
|
-
var
|
|
7831
|
-
|
|
7832
|
-
const
|
|
7833
|
-
if (!
|
|
7834
|
-
const
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
}), (
|
|
7838
|
-
}),
|
|
8063
|
+
} else S.key === "ArrowLeft" && b > 0 ? (S.preventDefault(), (I = c()[b - 1]) == null || I.focus()) : S.key === "ArrowRight" && b < 5 ? (S.preventDefault(), (x = c()[b + 1]) == null || x.focus()) : S.key === "Escape" && s();
|
|
8064
|
+
}), k.addEventListener("paste", (S) => {
|
|
8065
|
+
var g, v;
|
|
8066
|
+
S.preventDefault();
|
|
8067
|
+
const I = (((g = S.clipboardData) == null ? void 0 : g.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
|
|
8068
|
+
if (!I) return;
|
|
8069
|
+
const x = c();
|
|
8070
|
+
I.split("").forEach((A, C) => {
|
|
8071
|
+
x[C] && (x[C].value = A);
|
|
8072
|
+
}), (v = x[Math.min(I.length - 1, 5)]) == null || v.focus(), R(), w().length === 6 && setTimeout(G, 80);
|
|
8073
|
+
}), k.addEventListener("focus", () => k.select());
|
|
7839
8074
|
});
|
|
7840
8075
|
}
|
|
7841
|
-
const
|
|
8076
|
+
const Ds = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7842
8077
|
<path d="M14.5 8.5H14V6.5C14 4.015 11.985 2 9.5 2C7.015 2 5 4.015 5 6.5V8.5H4.5C3.672 8.5 3 9.172 3 10V16.5C3 17.328 3.672 18 4.5 18H14.5C15.328 18 16 17.328 16 16.5V10C16 9.172 15.328 8.5 14.5 8.5ZM10.5 13.415V15C10.5 15.276 10.276 15.5 10 15.5H9C8.724 15.5 8.5 15.276 8.5 15V13.415C8.187 13.196 8 12.847 8 12.5C8 11.672 8.672 11 9.5 11C10.328 11 11 11.672 11 12.5C11 12.847 10.813 13.196 10.5 13.415ZM12.5 8.5H6.5V6.5C6.5 4.843 7.843 3.5 9.5 3.5C11.157 3.5 12.5 4.843 12.5 6.5V8.5Z" fill="currentColor"/>
|
|
7843
|
-
</svg>`,
|
|
8078
|
+
</svg>`, Jn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7844
8079
|
<path d="M1 4.5L4 7.5L10 1" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7845
|
-
</svg>`,
|
|
8080
|
+
</svg>`, Zn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7846
8081
|
<path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="currentColor"/>
|
|
7847
8082
|
</svg>`;
|
|
7848
|
-
function
|
|
8083
|
+
function Qn(r, e, s) {
|
|
7849
8084
|
var o;
|
|
7850
8085
|
const t = r.querySelectorAll(".__crossx-pin-input");
|
|
7851
8086
|
t.forEach((i, a) => {
|
|
@@ -7878,12 +8113,12 @@ function Xn(r, e, s) {
|
|
|
7878
8113
|
}
|
|
7879
8114
|
}), (o = t[0]) == null || o.focus();
|
|
7880
8115
|
}
|
|
7881
|
-
class
|
|
8116
|
+
class eo {
|
|
7882
8117
|
constructor(e = "light", s) {
|
|
7883
|
-
this.theme = e, this.overrides = s, this.tokens =
|
|
8118
|
+
this.theme = e, this.overrides = s, this.tokens = Zt(e, s);
|
|
7884
8119
|
}
|
|
7885
8120
|
setTheme(e, s) {
|
|
7886
|
-
this.theme = e, s !== void 0 && (this.overrides = s), this.tokens =
|
|
8121
|
+
this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = Zt(e, this.overrides);
|
|
7887
8122
|
}
|
|
7888
8123
|
setMessages(e) {
|
|
7889
8124
|
this.messages = e;
|
|
@@ -7898,13 +8133,13 @@ class Zn {
|
|
|
7898
8133
|
*/
|
|
7899
8134
|
showWalletSelector(e, s, t) {
|
|
7900
8135
|
return new Promise((n) => {
|
|
7901
|
-
var
|
|
8136
|
+
var E;
|
|
7902
8137
|
he();
|
|
7903
|
-
const o = [...e], i =
|
|
7904
|
-
|
|
8138
|
+
const o = [...e], i = Hn(o, this.tokens, t), a = nt();
|
|
8139
|
+
pe(i);
|
|
7905
8140
|
let c = !1;
|
|
7906
8141
|
const l = () => {
|
|
7907
|
-
c || (c = !0, i.remove(),
|
|
8142
|
+
c || (c = !0, i.remove(), a());
|
|
7908
8143
|
}, u = (y) => {
|
|
7909
8144
|
l(), n(y);
|
|
7910
8145
|
}, h = () => {
|
|
@@ -7913,8 +8148,8 @@ class Zn {
|
|
|
7913
8148
|
(() => {
|
|
7914
8149
|
i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
|
|
7915
8150
|
y.addEventListener("click", () => {
|
|
7916
|
-
const
|
|
7917
|
-
u({ address:
|
|
8151
|
+
const R = y.dataset.walletAddress ?? "", N = parseInt(y.dataset.walletIndex ?? "0", 10);
|
|
8152
|
+
u({ address: R, index: N });
|
|
7918
8153
|
});
|
|
7919
8154
|
});
|
|
7920
8155
|
})();
|
|
@@ -7924,16 +8159,16 @@ class Zn {
|
|
|
7924
8159
|
try {
|
|
7925
8160
|
const y = await s();
|
|
7926
8161
|
o.push(y);
|
|
7927
|
-
const
|
|
7928
|
-
if (
|
|
8162
|
+
const R = i.querySelector("#__crossx-wallet-list");
|
|
8163
|
+
if (R) {
|
|
7929
8164
|
const N = document.createElement("button");
|
|
7930
|
-
N.className = "__crossx-wallet-item", N.dataset.walletIndex = String(y.index), N.dataset.walletAddress = y.address, N.innerHTML = `<span class="__crossx-wallet-addr">${
|
|
8165
|
+
N.className = "__crossx-wallet-item", N.dataset.walletIndex = String(y.index), N.dataset.walletAddress = y.address, N.innerHTML = `<span class="__crossx-wallet-addr">${re(y.address)}</span>`, N.addEventListener("click", () => u(y)), R.appendChild(N), N.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
7931
8166
|
}
|
|
7932
8167
|
} catch {
|
|
7933
8168
|
} finally {
|
|
7934
8169
|
f.disabled = !1;
|
|
7935
8170
|
}
|
|
7936
|
-
}), (
|
|
8171
|
+
}), (E = i.querySelector("#__crossx-close-btn")) == null || E.addEventListener("click", h), i.addEventListener("click", (y) => {
|
|
7937
8172
|
y.target === i && h();
|
|
7938
8173
|
});
|
|
7939
8174
|
const w = (y) => {
|
|
@@ -7952,7 +8187,7 @@ class Zn {
|
|
|
7952
8187
|
return new Promise((s) => {
|
|
7953
8188
|
var c, l, u, h;
|
|
7954
8189
|
he();
|
|
7955
|
-
const t =
|
|
8190
|
+
const t = Wn(this.tokens, e == null ? void 0 : e.showConnectOtherWallets);
|
|
7956
8191
|
pe(t);
|
|
7957
8192
|
const n = () => t.remove(), o = (_) => {
|
|
7958
8193
|
n(), s(_);
|
|
@@ -7980,7 +8215,7 @@ class Zn {
|
|
|
7980
8215
|
return new Promise((t) => {
|
|
7981
8216
|
var a, c, l;
|
|
7982
8217
|
he();
|
|
7983
|
-
const n =
|
|
8218
|
+
const n = qn(this.tokens, s);
|
|
7984
8219
|
pe(n);
|
|
7985
8220
|
const o = () => n.remove(), i = () => {
|
|
7986
8221
|
o(), t("recover");
|
|
@@ -8026,11 +8261,11 @@ class Zn {
|
|
|
8026
8261
|
}, i = {
|
|
8027
8262
|
title: (t == null ? void 0 : t.pinSetup_confirmTitle) ?? "Confirm PIN",
|
|
8028
8263
|
headerSubtitle: (t == null ? void 0 : t.pinSetup_confirmSubtitle) ?? "Enter your PIN again to confirm."
|
|
8029
|
-
}, a =
|
|
8030
|
-
|
|
8264
|
+
}, a = es(this.tokens, jn(n)), c = nt();
|
|
8265
|
+
pe(a);
|
|
8031
8266
|
let l = !1;
|
|
8032
8267
|
const u = () => {
|
|
8033
|
-
l || (l = !0, a.remove(),
|
|
8268
|
+
l || (l = !0, a.remove(), c());
|
|
8034
8269
|
}, h = (N) => {
|
|
8035
8270
|
u(), s(N);
|
|
8036
8271
|
}, _ = () => {
|
|
@@ -8041,64 +8276,64 @@ class Zn {
|
|
|
8041
8276
|
repeatingDigit: (t == null ? void 0 : t.pinValidation_repeatingDigit) ?? "Cannot use the same number 3+ times in a row.",
|
|
8042
8277
|
sequential: (t == null ? void 0 : t.pinValidation_sequential) ?? "Sequential numbers (e.g., 123456) are not allowed.",
|
|
8043
8278
|
alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
|
|
8044
|
-
},
|
|
8045
|
-
var
|
|
8046
|
-
f.innerHTML =
|
|
8279
|
+
}, E = (N) => {
|
|
8280
|
+
var F;
|
|
8281
|
+
f.innerHTML = it({
|
|
8047
8282
|
title: i.title,
|
|
8048
8283
|
headerSubtitle: i.headerSubtitle
|
|
8049
|
-
}), (
|
|
8050
|
-
|
|
8284
|
+
}), (F = f.querySelector("#__crossx-close-btn")) == null || F.addEventListener("click", _), at(f, (M) => {
|
|
8285
|
+
M === N ? h(N) : y(o.mismatchError);
|
|
8051
8286
|
}, _);
|
|
8052
8287
|
}, y = (N) => {
|
|
8053
|
-
var
|
|
8054
|
-
f.innerHTML =
|
|
8288
|
+
var F;
|
|
8289
|
+
f.innerHTML = it({
|
|
8055
8290
|
title: o.title,
|
|
8056
8291
|
headerSubtitle: o.headerSubtitle,
|
|
8057
8292
|
subtitle: o.subtitle,
|
|
8058
8293
|
errorMessage: N
|
|
8059
|
-
}), (
|
|
8060
|
-
const
|
|
8061
|
-
|
|
8294
|
+
}), (F = f.querySelector("#__crossx-close-btn")) == null || F.addEventListener("click", _), at(f, (M) => {
|
|
8295
|
+
const V = Yn(M, w);
|
|
8296
|
+
V ? y(V) : E(M);
|
|
8062
8297
|
}, _);
|
|
8063
8298
|
};
|
|
8064
8299
|
(() => {
|
|
8065
|
-
var
|
|
8066
|
-
const N = Array.from(f.querySelectorAll(".__crossx-pw-notice-item")),
|
|
8067
|
-
|
|
8068
|
-
const
|
|
8069
|
-
const
|
|
8070
|
-
|
|
8071
|
-
},
|
|
8072
|
-
if (
|
|
8073
|
-
const I =
|
|
8074
|
-
|
|
8075
|
-
},
|
|
8076
|
-
if (!
|
|
8077
|
-
const I =
|
|
8078
|
-
|
|
8300
|
+
var k;
|
|
8301
|
+
const N = Array.from(f.querySelectorAll(".__crossx-pw-notice-item")), F = f.querySelector("#__crossx-pin-notice-next"), M = /* @__PURE__ */ new Set();
|
|
8302
|
+
F.removeAttribute("disabled");
|
|
8303
|
+
const V = F.dataset.nextLabel ?? "Next", G = F.dataset.submitLabel ?? "I Understand", J = () => {
|
|
8304
|
+
const b = M.size === N.length;
|
|
8305
|
+
F.classList.toggle("--disabled", !b), F.textContent = b ? G : V;
|
|
8306
|
+
}, H = (b, S) => {
|
|
8307
|
+
if (M.has(S)) return;
|
|
8308
|
+
const I = b.querySelector(`#__crossx-notice-check-${S}`);
|
|
8309
|
+
M.add(S), I.classList.add("--checked"), b.setAttribute("aria-checked", "true"), J();
|
|
8310
|
+
}, z = (b, S) => {
|
|
8311
|
+
if (!M.has(S)) return;
|
|
8312
|
+
const I = b.querySelector(`#__crossx-notice-check-${S}`);
|
|
8313
|
+
M.delete(S), I.classList.remove("--checked"), b.setAttribute("aria-checked", "false"), J();
|
|
8079
8314
|
};
|
|
8080
|
-
N.forEach((
|
|
8081
|
-
const
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
}),
|
|
8085
|
-
(I.key === " " || I.key === "Enter") && (I.preventDefault(),
|
|
8315
|
+
N.forEach((b) => {
|
|
8316
|
+
const S = parseInt(b.dataset.checkIndex ?? "0", 10);
|
|
8317
|
+
b.addEventListener("click", () => {
|
|
8318
|
+
M.has(S) ? z(b, S) : H(b, S);
|
|
8319
|
+
}), b.addEventListener("keydown", (I) => {
|
|
8320
|
+
(I.key === " " || I.key === "Enter") && (I.preventDefault(), M.has(S) ? z(b, S) : H(b, S));
|
|
8086
8321
|
});
|
|
8087
|
-
}),
|
|
8088
|
-
if (
|
|
8322
|
+
}), F.addEventListener("click", () => {
|
|
8323
|
+
if (M.size === N.length) {
|
|
8089
8324
|
y(e == null ? void 0 : e.errorMessage);
|
|
8090
8325
|
return;
|
|
8091
8326
|
}
|
|
8092
|
-
const
|
|
8327
|
+
const b = N.find((I) => {
|
|
8093
8328
|
const x = parseInt(I.dataset.checkIndex ?? "0", 10);
|
|
8094
|
-
return !
|
|
8329
|
+
return !M.has(x);
|
|
8095
8330
|
});
|
|
8096
|
-
if (!
|
|
8097
|
-
const
|
|
8098
|
-
|
|
8099
|
-
|
|
8331
|
+
if (!b) return;
|
|
8332
|
+
const S = parseInt(b.dataset.checkIndex ?? "0", 10);
|
|
8333
|
+
b.scrollIntoView({ behavior: "smooth", block: "nearest" }), b.classList.add("--highlight"), setTimeout(() => {
|
|
8334
|
+
b.classList.remove("--highlight"), H(b, S);
|
|
8100
8335
|
}, 400);
|
|
8101
|
-
}), (
|
|
8336
|
+
}), (k = f.querySelector("#__crossx-close-btn")) == null || k.addEventListener("click", _);
|
|
8102
8337
|
})(), a.addEventListener("click", (N) => {
|
|
8103
8338
|
N.target === a && _();
|
|
8104
8339
|
});
|
|
@@ -8113,28 +8348,30 @@ class Zn {
|
|
|
8113
8348
|
return new Promise((s, t) => {
|
|
8114
8349
|
var y;
|
|
8115
8350
|
he();
|
|
8116
|
-
const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c =
|
|
8351
|
+
const n = this.messages, o = (e == null ? void 0 : e.verifyMode) === !0, i = o ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = o ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c = es(
|
|
8117
8352
|
this.tokens,
|
|
8118
|
-
|
|
8353
|
+
it({
|
|
8119
8354
|
title: i,
|
|
8120
8355
|
headerSubtitle: a,
|
|
8121
8356
|
errorMessage: e == null ? void 0 : e.errorMessage,
|
|
8122
|
-
lockExpiresAt: e == null ? void 0 : e.lockExpiresAt
|
|
8357
|
+
lockExpiresAt: e == null ? void 0 : e.lockExpiresAt,
|
|
8358
|
+
attemptCount: e == null ? void 0 : e.attemptCount,
|
|
8359
|
+
maxAttempts: e == null ? void 0 : e.maxAttempts
|
|
8123
8360
|
})
|
|
8124
|
-
), l =
|
|
8125
|
-
|
|
8361
|
+
), l = nt();
|
|
8362
|
+
pe(c);
|
|
8126
8363
|
let u = !1;
|
|
8127
8364
|
const h = () => {
|
|
8128
|
-
u || (u = !0, c.remove(),
|
|
8129
|
-
}, _ = (
|
|
8130
|
-
h(), s(
|
|
8365
|
+
u || (u = !0, c.remove(), l());
|
|
8366
|
+
}, _ = (R) => {
|
|
8367
|
+
h(), s(R);
|
|
8131
8368
|
}, f = () => {
|
|
8132
8369
|
h(), s(null);
|
|
8133
|
-
}, w = (
|
|
8134
|
-
h(), t(
|
|
8135
|
-
},
|
|
8136
|
-
(y =
|
|
8137
|
-
|
|
8370
|
+
}, w = (R) => {
|
|
8371
|
+
h(), t(R);
|
|
8372
|
+
}, E = c.querySelector(".__crossx-card");
|
|
8373
|
+
(y = E.querySelector("#__crossx-close-btn")) == null || y.addEventListener("click", f), at(E, _, f, w, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt), c.addEventListener("click", (R) => {
|
|
8374
|
+
R.target === c && f();
|
|
8138
8375
|
});
|
|
8139
8376
|
});
|
|
8140
8377
|
}
|
|
@@ -8149,14 +8386,14 @@ class Zn {
|
|
|
8149
8386
|
return new Promise((s) => {
|
|
8150
8387
|
var a;
|
|
8151
8388
|
he();
|
|
8152
|
-
const t =
|
|
8389
|
+
const t = Kn(this.tokens, e);
|
|
8153
8390
|
pe(t);
|
|
8154
8391
|
const n = () => t.remove(), o = (c) => {
|
|
8155
8392
|
n(), s(c);
|
|
8156
8393
|
}, i = () => {
|
|
8157
8394
|
n(), s(null);
|
|
8158
8395
|
};
|
|
8159
|
-
|
|
8396
|
+
Qn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
|
|
8160
8397
|
c.target === t && i();
|
|
8161
8398
|
});
|
|
8162
8399
|
});
|
|
@@ -8171,7 +8408,7 @@ class Zn {
|
|
|
8171
8408
|
return new Promise((t) => {
|
|
8172
8409
|
var l;
|
|
8173
8410
|
he();
|
|
8174
|
-
const { overlay: n, startCountdown: o } =
|
|
8411
|
+
const { overlay: n, startCountdown: o } = zn(this.tokens, e, s);
|
|
8175
8412
|
pe(n);
|
|
8176
8413
|
const i = () => {
|
|
8177
8414
|
c(), n.remove();
|
|
@@ -8191,7 +8428,7 @@ class Zn {
|
|
|
8191
8428
|
return new Promise((s) => {
|
|
8192
8429
|
var a, c;
|
|
8193
8430
|
he();
|
|
8194
|
-
const t =
|
|
8431
|
+
const t = Ln(e, this.tokens);
|
|
8195
8432
|
pe(t);
|
|
8196
8433
|
const n = () => t.remove(), o = () => {
|
|
8197
8434
|
n(), s();
|
|
@@ -8220,7 +8457,7 @@ class Zn {
|
|
|
8220
8457
|
showTransactionProgress(e, s) {
|
|
8221
8458
|
return new Promise((t) => {
|
|
8222
8459
|
he();
|
|
8223
|
-
const n =
|
|
8460
|
+
const n = Dn(e, this.tokens);
|
|
8224
8461
|
pe(n);
|
|
8225
8462
|
const o = () => n.remove();
|
|
8226
8463
|
let i = !1;
|
|
@@ -8237,7 +8474,7 @@ class Zn {
|
|
|
8237
8474
|
document.addEventListener("keydown", l);
|
|
8238
8475
|
};
|
|
8239
8476
|
s.then((l) => {
|
|
8240
|
-
i || (
|
|
8477
|
+
i || (Mn(n, l, this.tokens), c());
|
|
8241
8478
|
});
|
|
8242
8479
|
});
|
|
8243
8480
|
}
|
|
@@ -8246,7 +8483,7 @@ class Zn {
|
|
|
8246
8483
|
var c, l, u;
|
|
8247
8484
|
he();
|
|
8248
8485
|
let t;
|
|
8249
|
-
e.type === "sign-message" ? t =
|
|
8486
|
+
e.type === "sign-message" ? t = $n(e, this.tokens) : e.type === "sign-typed-data" ? t = Bn(e, this.tokens) : e.type === "sign" ? t = Pn(e, this.tokens) : t = On(e, this.tokens), pe(t);
|
|
8250
8487
|
const n = () => t.remove(), o = () => {
|
|
8251
8488
|
n(), s(!0);
|
|
8252
8489
|
}, i = () => {
|
|
@@ -8270,7 +8507,7 @@ class Zn {
|
|
|
8270
8507
|
});
|
|
8271
8508
|
}
|
|
8272
8509
|
}
|
|
8273
|
-
class
|
|
8510
|
+
class to {
|
|
8274
8511
|
constructor() {
|
|
8275
8512
|
this._accessToken = null, this._expiresAt = 0;
|
|
8276
8513
|
}
|
|
@@ -8302,9 +8539,9 @@ class Qn {
|
|
|
8302
8539
|
return !this._accessToken || this._expiresAt <= 0 ? !0 : Date.now() >= this._expiresAt - e;
|
|
8303
8540
|
}
|
|
8304
8541
|
}
|
|
8305
|
-
function
|
|
8542
|
+
function lo(r, e) {
|
|
8306
8543
|
r.debug;
|
|
8307
|
-
const s =
|
|
8544
|
+
const s = We.production, t = {
|
|
8308
8545
|
...r,
|
|
8309
8546
|
oauthServiceUrl: s.oauthServiceUrl,
|
|
8310
8547
|
authApiUrl: s.authApiUrl,
|
|
@@ -8312,22 +8549,22 @@ function ao(r, e) {
|
|
|
8312
8549
|
}, n = {
|
|
8313
8550
|
gatewayUrl: s.walletGatewayUrl,
|
|
8314
8551
|
projectId: r.projectId
|
|
8315
|
-
}, o = t.authMode !== "cookie" &&
|
|
8552
|
+
}, o = t.authMode !== "cookie" && Lt.isAvailable();
|
|
8316
8553
|
!o && t.authMode !== "cookie" && d.warn(
|
|
8317
8554
|
"[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
|
|
8318
8555
|
"refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
|
|
8319
8556
|
"IndexedDB를 지원하는 브라우저 사용을 권장합니다."
|
|
8320
8557
|
), t.secureStorageAvailable = o;
|
|
8321
|
-
const i = o ? new
|
|
8558
|
+
const i = o ? new Lt(r.projectId) : new or(), a = new fn(), c = new mn(), l = new Ie(), u = new to(), h = new ss();
|
|
8322
8559
|
let _;
|
|
8323
|
-
r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), _ = new
|
|
8560
|
+
r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), _ = new yn(i, h)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), _ = new ke(
|
|
8324
8561
|
n,
|
|
8325
8562
|
i,
|
|
8326
8563
|
c,
|
|
8327
8564
|
u,
|
|
8328
8565
|
h
|
|
8329
8566
|
));
|
|
8330
|
-
const f = new
|
|
8567
|
+
const f = new Me(n, c), w = new eo(r.theme ?? "light", r.themeTokens), E = e != null && e.wrapConfirmation ? e.wrapConfirmation(w) : w, y = new ct(
|
|
8331
8568
|
t,
|
|
8332
8569
|
n,
|
|
8333
8570
|
i,
|
|
@@ -8336,15 +8573,15 @@ function ao(r, e) {
|
|
|
8336
8573
|
l,
|
|
8337
8574
|
_,
|
|
8338
8575
|
u,
|
|
8339
|
-
|
|
8576
|
+
E,
|
|
8340
8577
|
f,
|
|
8341
8578
|
h
|
|
8342
8579
|
);
|
|
8343
8580
|
return typeof window < "u" && (window.__crossxSDK = y), y;
|
|
8344
8581
|
}
|
|
8345
|
-
function
|
|
8346
|
-
const e =
|
|
8347
|
-
|
|
8582
|
+
function uo(r) {
|
|
8583
|
+
const e = so(r), s = ro(e), t = JSON.parse(s);
|
|
8584
|
+
oo(t);
|
|
8348
8585
|
const { data: n } = t;
|
|
8349
8586
|
return {
|
|
8350
8587
|
status: t.status,
|
|
@@ -8358,7 +8595,7 @@ function co(r) {
|
|
|
8358
8595
|
raw: t
|
|
8359
8596
|
};
|
|
8360
8597
|
}
|
|
8361
|
-
function
|
|
8598
|
+
function so(r) {
|
|
8362
8599
|
if (r.includes("://") && r.includes("?")) {
|
|
8363
8600
|
const e = new URL(r), s = e.searchParams.get("crossx_oauth_result");
|
|
8364
8601
|
if (s) return s;
|
|
@@ -8368,22 +8605,22 @@ function eo(r) {
|
|
|
8368
8605
|
}
|
|
8369
8606
|
return r;
|
|
8370
8607
|
}
|
|
8371
|
-
function
|
|
8608
|
+
function ro(r) {
|
|
8372
8609
|
if (r.startsWith("{"))
|
|
8373
8610
|
return r;
|
|
8374
8611
|
if (r.startsWith("%7B") || r.startsWith("%7b"))
|
|
8375
8612
|
return decodeURIComponent(r);
|
|
8376
|
-
const e =
|
|
8613
|
+
const e = no(r);
|
|
8377
8614
|
return decodeURIComponent(e);
|
|
8378
8615
|
}
|
|
8379
|
-
function
|
|
8616
|
+
function no(r) {
|
|
8380
8617
|
if (typeof atob == "function")
|
|
8381
8618
|
return atob(r);
|
|
8382
8619
|
if (typeof Buffer < "u")
|
|
8383
8620
|
return Buffer.from(r, "base64").toString("utf-8");
|
|
8384
8621
|
throw new Error("Base64 디코딩을 지원하는 환경이 아닙니다");
|
|
8385
8622
|
}
|
|
8386
|
-
function
|
|
8623
|
+
function oo(r) {
|
|
8387
8624
|
if (typeof r != "object" || r === null)
|
|
8388
8625
|
throw new Error("Deeplink payload가 유효한 객체가 아닙니다");
|
|
8389
8626
|
const e = r;
|
|
@@ -8401,12 +8638,12 @@ function ro(r) {
|
|
|
8401
8638
|
}
|
|
8402
8639
|
export {
|
|
8403
8640
|
m as CROSSxError,
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8641
|
+
Ws as CROSSxEthereumProvider,
|
|
8642
|
+
ct as CROSSxSDK,
|
|
8643
|
+
co as ChainId,
|
|
8407
8644
|
p as ErrorCode,
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8645
|
+
ss as PinMemoryStore,
|
|
8646
|
+
to as TokenMemoryStore,
|
|
8647
|
+
lo as createCROSSxSDK,
|
|
8648
|
+
uo as parseOAuthDeeplink
|
|
8412
8649
|
};
|