@nexus-cross/crossx-sdk-core 1.3.9 → 1.3.11
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 +13 -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 +151 -91
- package/dist/index.cjs +147 -87
- package/dist/index.js +1331 -1072
- 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: "취소",
|
|
@@ -265,8 +265,18 @@ const d = {
|
|
|
265
265
|
// ── PIN 잠금 안내 ─────────────────────────────────────────────
|
|
266
266
|
pinLocked_message: "잠금이 해제된 후 다시 시도해 주세요.",
|
|
267
267
|
pinLocked_availableFrom: "이용 가능 시간",
|
|
268
|
-
|
|
269
|
-
|
|
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 = {
|
|
270
280
|
// ── Common buttons ───────────────────────────────────────────
|
|
271
281
|
confirm: "Confirm",
|
|
272
282
|
cancel: "Cancel",
|
|
@@ -333,16 +343,26 @@ const d = {
|
|
|
333
343
|
// ── PIN lock message ─────────────────────────────────────────
|
|
334
344
|
pinLocked_message: "Please try again after the lock expires.",
|
|
335
345
|
pinLocked_availableFrom: "Available from",
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
|
340
360
|
};
|
|
341
|
-
function
|
|
342
|
-
return
|
|
361
|
+
function ve(r = "en", e) {
|
|
362
|
+
return Ks[r] ?? ts;
|
|
343
363
|
}
|
|
344
|
-
const
|
|
345
|
-
class
|
|
364
|
+
const It = "crossx_access_token", At = "crossx_refresh_token", Tt = "crossx_user_info";
|
|
365
|
+
class Vs {
|
|
346
366
|
constructor(e, s, t, n, o, i, a) {
|
|
347
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;
|
|
348
368
|
const c = e.projectId;
|
|
@@ -384,10 +404,12 @@ class qs {
|
|
|
384
404
|
expectedOrigin: new URL(o).origin
|
|
385
405
|
}), d.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", s.length, ")");
|
|
386
406
|
} catch (t) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
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);
|
|
391
413
|
}
|
|
392
414
|
return this.processFirebaseToken(s);
|
|
393
415
|
}
|
|
@@ -416,18 +438,18 @@ class qs {
|
|
|
416
438
|
try {
|
|
417
439
|
const w = this.crypto.decodeJWT(e);
|
|
418
440
|
_ = (n = w.firebase) == null ? void 0 : n.sign_in_provider;
|
|
419
|
-
const
|
|
420
|
-
_ === "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);
|
|
421
443
|
} catch {
|
|
422
444
|
d.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
|
|
423
445
|
}
|
|
424
446
|
if (l) {
|
|
425
447
|
const w = this.crypto.decodeJWT(l);
|
|
426
448
|
d.log("[CROSSx] access_token 디코딩 — sub:", w.sub, "exp:", w.exp);
|
|
427
|
-
const
|
|
428
|
-
if (t =
|
|
449
|
+
const E = await this.crypto.verifyJWT(l);
|
|
450
|
+
if (t = E.signatureVerified ?? !1, !E.valid)
|
|
429
451
|
throw d.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
|
|
430
|
-
const y =
|
|
452
|
+
const y = E.payload;
|
|
431
453
|
s = {
|
|
432
454
|
id: y.sub,
|
|
433
455
|
email: y.email,
|
|
@@ -678,10 +700,10 @@ class qs {
|
|
|
678
700
|
const e = await this.storage.get(Tt);
|
|
679
701
|
if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
|
|
680
702
|
await this.storage.set(this.STORAGE_KEY_USER, e);
|
|
681
|
-
const t = await this.storage.get(
|
|
703
|
+
const t = await this.storage.get(It);
|
|
682
704
|
t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
|
|
683
|
-
const n = await this.storage.get(
|
|
684
|
-
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 스코프)");
|
|
685
707
|
} catch (e) {
|
|
686
708
|
d.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
|
|
687
709
|
}
|
|
@@ -716,7 +738,7 @@ class qs {
|
|
|
716
738
|
return d.log("[CROSSx] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
|
|
717
739
|
}
|
|
718
740
|
}
|
|
719
|
-
class
|
|
741
|
+
class zs {
|
|
720
742
|
constructor(e, s, t) {
|
|
721
743
|
this.config = e, this.storage = s, this.tokenStore = t;
|
|
722
744
|
const n = e.projectId;
|
|
@@ -726,7 +748,7 @@ class Ks {
|
|
|
726
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();
|
|
727
749
|
}
|
|
728
750
|
}
|
|
729
|
-
class
|
|
751
|
+
class Ys {
|
|
730
752
|
constructor(e, s) {
|
|
731
753
|
this.storage = e, this.walletProvider = s;
|
|
732
754
|
}
|
|
@@ -743,7 +765,7 @@ class Vs {
|
|
|
743
765
|
};
|
|
744
766
|
}
|
|
745
767
|
}
|
|
746
|
-
class
|
|
768
|
+
class ss {
|
|
747
769
|
constructor() {
|
|
748
770
|
this.encryptedBytes = null, this.xorKey = null;
|
|
749
771
|
}
|
|
@@ -784,7 +806,7 @@ class es {
|
|
|
784
806
|
return this.encryptedBytes !== null;
|
|
785
807
|
}
|
|
786
808
|
}
|
|
787
|
-
class
|
|
809
|
+
class js {
|
|
788
810
|
constructor(e, s) {
|
|
789
811
|
this.chainRegistry = e, this.transport = s, this._nextId = 1;
|
|
790
812
|
}
|
|
@@ -816,7 +838,7 @@ class zs {
|
|
|
816
838
|
return a == null ? void 0 : a.result;
|
|
817
839
|
}
|
|
818
840
|
}
|
|
819
|
-
class
|
|
841
|
+
class Xs {
|
|
820
842
|
constructor() {
|
|
821
843
|
this.listeners = /* @__PURE__ */ new Map();
|
|
822
844
|
}
|
|
@@ -839,7 +861,7 @@ class js {
|
|
|
839
861
|
this.listeners.clear();
|
|
840
862
|
}
|
|
841
863
|
}
|
|
842
|
-
const
|
|
864
|
+
const We = {
|
|
843
865
|
// TODO(v2.0.0-BEFORE-RELEASE): 아래 블록으로 교체
|
|
844
866
|
// production: {
|
|
845
867
|
// oauthServiceUrl: 'https://cross-wallet-oauth.crosstoken.io',
|
|
@@ -862,24 +884,24 @@ const Ge = {
|
|
|
862
884
|
walletGatewayUrl: "https://dev-embedded-wallet-gateway.crosstoken.io/api/v1"
|
|
863
885
|
}
|
|
864
886
|
};
|
|
865
|
-
function
|
|
887
|
+
function Js(r) {
|
|
866
888
|
const e = r.environment;
|
|
867
|
-
return e && e in
|
|
889
|
+
return e && e in We ? We[e] : null;
|
|
868
890
|
}
|
|
869
|
-
function
|
|
891
|
+
function Zs() {
|
|
870
892
|
try {
|
|
871
893
|
if (typeof __CROSSX_CONFIG__ < "u") {
|
|
872
|
-
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);
|
|
873
895
|
if (e) return e;
|
|
874
896
|
}
|
|
875
897
|
} catch {
|
|
876
898
|
}
|
|
877
|
-
return
|
|
899
|
+
return We.production;
|
|
878
900
|
}
|
|
879
|
-
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 {
|
|
880
902
|
constructor(e, s, t, n, o, i, a, c, l, u, h) {
|
|
881
903
|
var _, f;
|
|
882
|
-
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 js(u, o), this.signInUseCase = new Vs(
|
|
883
905
|
this.internalConfig,
|
|
884
906
|
t,
|
|
885
907
|
n,
|
|
@@ -887,7 +909,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
887
909
|
o,
|
|
888
910
|
a,
|
|
889
911
|
c
|
|
890
|
-
), this.signOutUseCase = new
|
|
912
|
+
), this.signOutUseCase = new zs(this.internalConfig, t, c), this.migrateWalletUseCase = new Ys(t, a), (_ = a.setOnUnauthorized) == null || _.call(a, () => this.forceLogout()), (f = a.setTokenRefresher) == null || f.call(
|
|
891
913
|
a,
|
|
892
914
|
() => this.signInUseCase.refreshAccessToken()
|
|
893
915
|
), e.autoDetectTheme && this._setupAutoDetectTheme();
|
|
@@ -916,9 +938,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
916
938
|
}
|
|
917
939
|
async _doInitialize(e) {
|
|
918
940
|
var s, t;
|
|
919
|
-
d.log("[CROSSx SDK] v1.3.
|
|
941
|
+
d.log("[CROSSx SDK] v1.3.11 초기화 중..."), this.confirmation.setMessages(ve(this._config.locale));
|
|
920
942
|
try {
|
|
921
|
-
const n =
|
|
943
|
+
const n = Zs();
|
|
922
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`);
|
|
923
945
|
const o = await this.signInUseCase.restoreSession();
|
|
924
946
|
if (o != null && o.success) {
|
|
@@ -931,7 +953,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
931
953
|
d.log("[CROSSx] initialize: 비밀번호 입력 취소 — 지갑 미로드 상태로 계속");
|
|
932
954
|
}
|
|
933
955
|
}
|
|
934
|
-
return this.initialized = !0, d.info("[CROSSx SDK] v1.3.
|
|
956
|
+
return this.initialized = !0, d.info("[CROSSx SDK] v1.3.11 초기화 완료"), this.emit("initialized", { restored: !!(o != null && o.success) }), o ?? null;
|
|
935
957
|
} catch (n) {
|
|
936
958
|
throw new m(p.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", n);
|
|
937
959
|
}
|
|
@@ -960,7 +982,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
960
982
|
const t = await this.signInUseCase.execute(s);
|
|
961
983
|
return t.success && this.applyAuthResult(t), t;
|
|
962
984
|
} catch (t) {
|
|
963
|
-
throw new m(p.AUTH_FAILED, "로그인에 실패했습니다", t);
|
|
985
|
+
throw t instanceof m ? t : new m(p.AUTH_FAILED, "로그인에 실패했습니다", t);
|
|
964
986
|
}
|
|
965
987
|
}
|
|
966
988
|
/**
|
|
@@ -1207,7 +1229,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1207
1229
|
*/
|
|
1208
1230
|
async getAddresses() {
|
|
1209
1231
|
if (this.ensureAuthenticated(), !this.userId) return [];
|
|
1210
|
-
const e = await this.
|
|
1232
|
+
const e = await this.withSessionRecovery(
|
|
1233
|
+
() => this.walletProvider.getAddresses(this.userId)
|
|
1234
|
+
);
|
|
1211
1235
|
return e.length === 0 && this.address ? [{ address: this.address, index: 0 }] : e;
|
|
1212
1236
|
}
|
|
1213
1237
|
/**
|
|
@@ -1232,14 +1256,18 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1232
1256
|
async selectWallet(e) {
|
|
1233
1257
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1234
1258
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1235
|
-
let s = await this.
|
|
1259
|
+
let s = await this.withSessionRecovery(
|
|
1260
|
+
() => this.walletProvider.getAddresses(this.userId)
|
|
1261
|
+
);
|
|
1236
1262
|
s.length === 0 && this.address && (s = [{ address: this.address, index: 0 }]);
|
|
1237
1263
|
const t = await this.confirmation.showWalletSelector(
|
|
1238
1264
|
s,
|
|
1239
1265
|
async () => {
|
|
1240
1266
|
await this.ensurePinForSigning();
|
|
1241
1267
|
const n = s.length, i = { address: (await this.withPinRetry(
|
|
1242
|
-
() => this.
|
|
1268
|
+
() => this.withSessionRecovery(
|
|
1269
|
+
() => this.walletProvider.getAddress(this.userId, n)
|
|
1270
|
+
)
|
|
1243
1271
|
)).address, index: n };
|
|
1244
1272
|
return s.push(i), i;
|
|
1245
1273
|
},
|
|
@@ -1339,7 +1367,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1339
1367
|
* sdk.applyLocale('ko');
|
|
1340
1368
|
*/
|
|
1341
1369
|
applyLocale(e = this._config.locale ?? "en") {
|
|
1342
|
-
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));
|
|
1343
1371
|
}
|
|
1344
1372
|
/**
|
|
1345
1373
|
* 지갑 생성/로드 (로그인 후 address가 없는 경우)
|
|
@@ -1348,6 +1376,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1348
1376
|
* - migration_required: 마이그레이션 플로우 실행
|
|
1349
1377
|
*/
|
|
1350
1378
|
async createWallet() {
|
|
1379
|
+
return this.withSessionRecovery(() => this._createWallet());
|
|
1380
|
+
}
|
|
1381
|
+
async _createWallet() {
|
|
1351
1382
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1352
1383
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1353
1384
|
d.log("[CROSSx] createWallet 시작");
|
|
@@ -1425,6 +1456,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1425
1456
|
* @todo 백엔드 메시지 서명 전용 엔드포인트 추가 후 구현
|
|
1426
1457
|
*/
|
|
1427
1458
|
async signMessage(e, s, t) {
|
|
1459
|
+
return this.withSessionRecovery(() => this._signMessage(e, s, t));
|
|
1460
|
+
}
|
|
1461
|
+
async _signMessage(e, s, t) {
|
|
1428
1462
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1429
1463
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1430
1464
|
const n = await this.resolveAddress(t == null ? void 0 : t.index);
|
|
@@ -1481,11 +1515,14 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1481
1515
|
* });
|
|
1482
1516
|
*/
|
|
1483
1517
|
async signTypedData(e, s, t) {
|
|
1518
|
+
return this.withSessionRecovery(() => this._signTypedData(e, s, t));
|
|
1519
|
+
}
|
|
1520
|
+
async _signTypedData(e, s, t) {
|
|
1484
1521
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1485
1522
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1486
1523
|
if (!this.walletProvider.signTypedData)
|
|
1487
1524
|
throw new m(p.NOT_IMPLEMENTED, "signTypedData가 구현되어 있지 않습니다");
|
|
1488
|
-
|
|
1525
|
+
ee.validateTypedDataChainId(e, s);
|
|
1489
1526
|
const n = await this.resolveAddress(t == null ? void 0 : t.index);
|
|
1490
1527
|
if (!await this.confirmation.requestConfirmation({
|
|
1491
1528
|
type: "sign-typed-data",
|
|
@@ -1508,7 +1545,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1508
1545
|
n.address
|
|
1509
1546
|
);
|
|
1510
1547
|
});
|
|
1511
|
-
return
|
|
1548
|
+
return ee.validateSignatureFormat(i.signature), {
|
|
1512
1549
|
chainId: e,
|
|
1513
1550
|
signature: i.signature,
|
|
1514
1551
|
address: n.address
|
|
@@ -1537,7 +1574,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1537
1574
|
* });
|
|
1538
1575
|
*/
|
|
1539
1576
|
async signTypedDataOffchain(e, s) {
|
|
1540
|
-
return this.signTypedData(
|
|
1577
|
+
return this.signTypedData(ee.OFFCHAIN_CHAIN_ID, e, s);
|
|
1541
1578
|
}
|
|
1542
1579
|
// ============================================================================
|
|
1543
1580
|
// 트랜잭션
|
|
@@ -1549,6 +1586,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1549
1586
|
* @param opts 서명 옵션 (index, dappName, accountName)
|
|
1550
1587
|
*/
|
|
1551
1588
|
async signTransaction(e, s, t) {
|
|
1589
|
+
return this.withSessionRecovery(() => this._signTransaction(e, s, t));
|
|
1590
|
+
}
|
|
1591
|
+
async _signTransaction(e, s, t) {
|
|
1552
1592
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1553
1593
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1554
1594
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
@@ -1582,7 +1622,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1582
1622
|
c
|
|
1583
1623
|
);
|
|
1584
1624
|
});
|
|
1585
|
-
return
|
|
1625
|
+
return ee.validateSignedTxFormat(a.signature), {
|
|
1586
1626
|
chainId: e,
|
|
1587
1627
|
signedTx: a.signature,
|
|
1588
1628
|
txHash: a.txHash ?? ""
|
|
@@ -1604,6 +1644,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1604
1644
|
* @param opts 서명 옵션 (index, dappName, accountName)
|
|
1605
1645
|
*/
|
|
1606
1646
|
async sendTransaction(e, s, t) {
|
|
1647
|
+
return this.withSessionRecovery(() => this._sendTransaction(e, s, t));
|
|
1648
|
+
}
|
|
1649
|
+
async _sendTransaction(e, s, t) {
|
|
1607
1650
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1608
1651
|
throw new m(p.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1609
1652
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
@@ -1675,7 +1718,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1675
1718
|
* @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
|
|
1676
1719
|
*/
|
|
1677
1720
|
async waitForTxAndGetReceipt(e, s, t = {}) {
|
|
1678
|
-
const n = t.intervalMs ??
|
|
1721
|
+
const n = t.intervalMs ?? er, o = tr, i = t.timeoutMs ?? Rt, a = Date.now() + i;
|
|
1679
1722
|
let c = n;
|
|
1680
1723
|
for (; Date.now() < a; ) {
|
|
1681
1724
|
const l = await this.getTransactionReceipt(e, s);
|
|
@@ -1703,29 +1746,29 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1703
1746
|
* logger.log(receipt.status); // '0x1' | '0x0'
|
|
1704
1747
|
*/
|
|
1705
1748
|
async sendTransactionWithWaitForReceipt(e, s, t = {}) {
|
|
1706
|
-
var
|
|
1707
|
-
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 ?? "";
|
|
1708
1751
|
let _, f;
|
|
1709
|
-
const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((
|
|
1710
|
-
_ =
|
|
1711
|
-
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);
|
|
1712
1755
|
return {
|
|
1713
1756
|
chainId: e,
|
|
1714
1757
|
txHash: a,
|
|
1715
|
-
from:
|
|
1716
|
-
to:
|
|
1717
|
-
amount:
|
|
1718
|
-
fees:
|
|
1719
|
-
total:
|
|
1758
|
+
from: R.from,
|
|
1759
|
+
to: R.to ?? s.to,
|
|
1760
|
+
amount: M,
|
|
1761
|
+
fees: V,
|
|
1762
|
+
total: G,
|
|
1720
1763
|
nativeSymbol: u.symbol,
|
|
1721
|
-
status:
|
|
1764
|
+
status: R.status === "0x1" ? "success" : "reverted"
|
|
1722
1765
|
};
|
|
1723
|
-
}).catch((
|
|
1766
|
+
}).catch((R) => (f = R instanceof Error ? R : new Error(String(R)), {
|
|
1724
1767
|
chainId: e,
|
|
1725
1768
|
txHash: a,
|
|
1726
1769
|
from: h,
|
|
1727
1770
|
to: s.to,
|
|
1728
|
-
amount:
|
|
1771
|
+
amount: ee.formatTxAmount(s.value, u.symbol, u.decimals),
|
|
1729
1772
|
nativeSymbol: u.symbol,
|
|
1730
1773
|
status: "timeout"
|
|
1731
1774
|
}));
|
|
@@ -1903,7 +1946,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1903
1946
|
return { wei: "0x0", formatted: "0", chainId: e };
|
|
1904
1947
|
try {
|
|
1905
1948
|
const n = await this.jsonRpc.call("eth_getBalance", [s, "latest"], e) ?? "0x0";
|
|
1906
|
-
return { wei: n, formatted:
|
|
1949
|
+
return { wei: n, formatted: ee.formatWei(n), chainId: e };
|
|
1907
1950
|
} catch (t) {
|
|
1908
1951
|
if (t instanceof m) throw t;
|
|
1909
1952
|
const n = t instanceof Error ? t.message : String(t);
|
|
@@ -1915,7 +1958,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1915
1958
|
try {
|
|
1916
1959
|
const s = BigInt(e);
|
|
1917
1960
|
if (s === 0n) return "0";
|
|
1918
|
-
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);
|
|
1919
1962
|
return i ? `${n}.${i}` : `${n}`;
|
|
1920
1963
|
} catch {
|
|
1921
1964
|
return "?";
|
|
@@ -1940,7 +1983,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1940
1983
|
* const client = createWalletClient({ transport: custom(provider) });
|
|
1941
1984
|
*/
|
|
1942
1985
|
getProvider(e) {
|
|
1943
|
-
return this.ensureAuthenticated(), new
|
|
1986
|
+
return this.ensureAuthenticated(), new Ws(this, e);
|
|
1944
1987
|
}
|
|
1945
1988
|
/**
|
|
1946
1989
|
* 범용 JSON-RPC 요청 — 노드에 직접 연결.
|
|
@@ -1974,7 +2017,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
1974
2017
|
try {
|
|
1975
2018
|
const n = BigInt(e);
|
|
1976
2019
|
if (n === 0n) return;
|
|
1977
|
-
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+$/, "");
|
|
1978
2021
|
return `${c ? `${i}.${c}` : `${i}`} ${s}`;
|
|
1979
2022
|
} catch {
|
|
1980
2023
|
return;
|
|
@@ -2019,8 +2062,8 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2019
2062
|
}
|
|
2020
2063
|
const f = _.pinStatus;
|
|
2021
2064
|
if (i = f.maxAttempts, o = i - f.remainingAttempts, f.remainingAttempts === 0 && f.lockExpiresAt) {
|
|
2022
|
-
const w = f.lockExpiresAt * 1e3,
|
|
2023
|
-
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.";
|
|
2024
2067
|
} else
|
|
2025
2068
|
d.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 ${o}/${i})`), n = "Incorrect PIN.";
|
|
2026
2069
|
} catch (_) {
|
|
@@ -2029,8 +2072,8 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2029
2072
|
const f = _.details;
|
|
2030
2073
|
if (i = (f == null ? void 0 : f.maxAttempts) ?? 5, (f == null ? void 0 : f.permanent) === !0)
|
|
2031
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;
|
|
2032
|
-
const w = ((f == null ? void 0 : f.lockExpiresAt) ?? 0) * 1e3,
|
|
2033
|
-
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.";
|
|
2034
2077
|
} else
|
|
2035
2078
|
throw d.error("[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):", _), _;
|
|
2036
2079
|
}
|
|
@@ -2071,12 +2114,12 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2071
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) {
|
|
2072
2115
|
const f = _;
|
|
2073
2116
|
if (f) {
|
|
2074
|
-
const w =
|
|
2117
|
+
const w = kt;
|
|
2075
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");
|
|
2076
2119
|
} else
|
|
2077
|
-
c.gasPrice =
|
|
2120
|
+
c.gasPrice = sr, d.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
|
|
2078
2121
|
}
|
|
2079
|
-
return !i && a && (c.maxPriorityFeePerGas =
|
|
2122
|
+
return !i && a && (c.maxPriorityFeePerGas = kt, d.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
|
|
2080
2123
|
}
|
|
2081
2124
|
/**
|
|
2082
2125
|
* EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
|
|
@@ -2085,7 +2128,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2085
2128
|
* - chainId가 '0' → domain.chainId가 없거나 0이어야 함
|
|
2086
2129
|
*/
|
|
2087
2130
|
static validateTypedDataChainId(e, s) {
|
|
2088
|
-
const t =
|
|
2131
|
+
const t = ee.extractDomainChainId(s);
|
|
2089
2132
|
if (e === "0") {
|
|
2090
2133
|
if (t !== void 0 && t !== 0)
|
|
2091
2134
|
throw new m(
|
|
@@ -2123,10 +2166,10 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2123
2166
|
const s = e.startsWith("0x") ? e.slice(2) : e;
|
|
2124
2167
|
if (!/^[0-9a-fA-F]+$/.test(s))
|
|
2125
2168
|
throw new m(p.SIGNATURE_FAILED, "유효하지 않은 서명: 올바른 hex 문자열이 아닙니다");
|
|
2126
|
-
if (s.length !==
|
|
2169
|
+
if (s.length !== Pt)
|
|
2127
2170
|
throw new m(
|
|
2128
2171
|
p.SIGNATURE_FAILED,
|
|
2129
|
-
`서명 길이가 유효하지 않습니다: ${
|
|
2172
|
+
`서명 길이가 유효하지 않습니다: ${Pt} hex 문자(65 바이트) 예상, 현재 ${s.length}`
|
|
2130
2173
|
);
|
|
2131
2174
|
}
|
|
2132
2175
|
/** RLP-encoded signed transaction 형식 검증 */
|
|
@@ -2164,7 +2207,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2164
2207
|
/** AuthResult를 내부 상태에 반영합니다. */
|
|
2165
2208
|
applyAuthResult(e) {
|
|
2166
2209
|
var s, t, n, o;
|
|
2167
|
-
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", {
|
|
2168
2211
|
isAuthenticated: this.authenticated,
|
|
2169
2212
|
address: this.address,
|
|
2170
2213
|
userId: this.userId
|
|
@@ -2172,7 +2215,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2172
2215
|
}
|
|
2173
2216
|
/** 인증 상태를 초기화합니다. */
|
|
2174
2217
|
clearAuthState() {
|
|
2175
|
-
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", {
|
|
2176
2219
|
isAuthenticated: !1,
|
|
2177
2220
|
address: null,
|
|
2178
2221
|
userId: null
|
|
@@ -2186,6 +2229,80 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2186
2229
|
forceLogout() {
|
|
2187
2230
|
this.authenticated && (d.warn("[CROSSx] 인증 만료(Gateway -10002) — 강제 로그아웃"), this.clearAuthState());
|
|
2188
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
|
+
}
|
|
2189
2306
|
/**
|
|
2190
2307
|
* Firebase sign_in_provider 값을 정규화합니다.
|
|
2191
2308
|
* 'google.com' → 'google', 'apple.com' → 'apple'
|
|
@@ -2227,11 +2344,13 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2227
2344
|
*
|
|
2228
2345
|
* @param initialErrorMessage 모달을 열 때 처음부터 표시할 에러 메시지.
|
|
2229
2346
|
* @param lockExpiresAt PIN 잠금 만료 시각 (Unix ms). 제공 시 잠금 UI를 표시합니다.
|
|
2347
|
+
* @param attemptCount 현재 시도 횟수 (1~maxAttempts). X/maxAttempts 형태로 표시.
|
|
2348
|
+
* @param maxAttempts 최대 시도 허용 횟수.
|
|
2230
2349
|
*
|
|
2231
2350
|
* 뮤텍스: 동시에 여러 곳에서 호출되어도 모달은 하나만 표시됩니다.
|
|
2232
2351
|
* (initialErrorMessage가 없을 때만 공유, 에러 재시도 시에는 항상 새로 열림)
|
|
2233
2352
|
*/
|
|
2234
|
-
async ensureVerifiedPin(e, s) {
|
|
2353
|
+
async ensureVerifiedPin(e, s, t, n) {
|
|
2235
2354
|
if (e)
|
|
2236
2355
|
this.pinStore.clear();
|
|
2237
2356
|
else if (this.pinStore.has())
|
|
@@ -2240,57 +2359,87 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2240
2359
|
d.log("[CROSSx] ensureVerifiedPin: 진행 중인 검증 대기"), await this._verifyPinMutex;
|
|
2241
2360
|
return;
|
|
2242
2361
|
}
|
|
2243
|
-
let
|
|
2244
|
-
this._verifyPinMutex = new Promise((
|
|
2245
|
-
|
|
2362
|
+
let o, i;
|
|
2363
|
+
this._verifyPinMutex = new Promise((c, l) => {
|
|
2364
|
+
o = c, i = l;
|
|
2246
2365
|
});
|
|
2366
|
+
const a = ve(this._config.locale ?? "en");
|
|
2247
2367
|
try {
|
|
2248
2368
|
if (typeof this.walletProvider.verifyPin != "function") {
|
|
2249
|
-
const
|
|
2369
|
+
const l = await this.confirmation.showPinInputPrompt({
|
|
2250
2370
|
verifyMode: !0,
|
|
2251
2371
|
errorMessage: e,
|
|
2252
|
-
lockExpiresAt: s
|
|
2372
|
+
lockExpiresAt: s,
|
|
2373
|
+
attemptCount: t,
|
|
2374
|
+
maxAttempts: n
|
|
2253
2375
|
});
|
|
2254
|
-
if (!
|
|
2376
|
+
if (!l)
|
|
2255
2377
|
throw new m(p.PIN_CANCELLED, "사용자가 PIN 입력을 취소했습니다");
|
|
2256
|
-
this.pinStore.set(
|
|
2378
|
+
this.pinStore.set(l), d.log("[CROSSx] PIN 캐시 완료 (verifyPin 미지원, 로컬 전용)"), o();
|
|
2257
2379
|
return;
|
|
2258
2380
|
}
|
|
2259
|
-
const
|
|
2381
|
+
const c = await this.confirmation.showPinInputPrompt({
|
|
2260
2382
|
verifyMode: !0,
|
|
2261
2383
|
errorMessage: e,
|
|
2262
2384
|
lockExpiresAt: s,
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2385
|
+
attemptCount: t,
|
|
2386
|
+
maxAttempts: n,
|
|
2387
|
+
onSubmit: async (l) => {
|
|
2388
|
+
this.pinStore.set(l);
|
|
2266
2389
|
try {
|
|
2267
|
-
return await this.walletProvider.verifyPin(
|
|
2268
|
-
} catch (
|
|
2269
|
-
if (this.pinStore.clear(),
|
|
2270
|
-
if (
|
|
2271
|
-
return { ok: !1, error:
|
|
2272
|
-
if (
|
|
2273
|
-
return { ok: !1, error:
|
|
2274
|
-
if (
|
|
2275
|
-
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);
|
|
2276
2399
|
}
|
|
2277
|
-
throw
|
|
2400
|
+
throw u;
|
|
2278
2401
|
}
|
|
2279
2402
|
}
|
|
2280
2403
|
});
|
|
2281
|
-
if (!
|
|
2404
|
+
if (!c)
|
|
2282
2405
|
throw new m(p.PIN_CANCELLED, "사용자가 PIN 입력을 취소했습니다");
|
|
2283
|
-
this.pinStore.set(
|
|
2284
|
-
} catch (
|
|
2285
|
-
if (
|
|
2286
|
-
const { alert_sessionExpired:
|
|
2287
|
-
typeof globalThis.alert == "function" && globalThis.alert(
|
|
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);
|
|
2288
2411
|
}
|
|
2289
|
-
throw
|
|
2412
|
+
throw i(c), c;
|
|
2290
2413
|
} finally {
|
|
2291
2414
|
this._verifyPinMutex = null;
|
|
2292
2415
|
}
|
|
2293
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
|
+
}
|
|
2294
2443
|
/**
|
|
2295
2444
|
* 세션 복원(refresh) 후 지갑 상태를 확인하고 주소를 로드합니다.
|
|
2296
2445
|
*
|
|
@@ -2326,44 +2475,32 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2326
2475
|
* PIN_WRONG이 계속 발생하는 경우(verifyPin 미지원 환경 등) 취소할 때까지 무한 루프.
|
|
2327
2476
|
*/
|
|
2328
2477
|
async withPinRetry(e) {
|
|
2329
|
-
|
|
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
|
+
};
|
|
2330
2491
|
try {
|
|
2331
2492
|
return await e();
|
|
2332
|
-
} catch (
|
|
2333
|
-
if (
|
|
2334
|
-
if (n.code === p.PIN_WRONG)
|
|
2335
|
-
s = "Incorrect PIN. Please enter your current PIN.";
|
|
2336
|
-
else if (n.code === p.PIN_INVALID)
|
|
2337
|
-
s = n.message;
|
|
2338
|
-
else if (n.code === p.PIN_LOCKED) {
|
|
2339
|
-
const o = n.details;
|
|
2340
|
-
t = o == null ? void 0 : o.lockExpiresAt, s = "Too many failed attempts. Your account is temporarily locked.";
|
|
2341
|
-
} else
|
|
2342
|
-
throw n;
|
|
2343
|
-
else
|
|
2344
|
-
throw n;
|
|
2493
|
+
} catch (c) {
|
|
2494
|
+
if (!(c instanceof m && a(c))) throw c;
|
|
2345
2495
|
}
|
|
2346
2496
|
for (; ; ) {
|
|
2347
|
-
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;
|
|
2348
2498
|
try {
|
|
2349
2499
|
return await e();
|
|
2350
|
-
} catch (
|
|
2351
|
-
if (
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
continue;
|
|
2355
|
-
}
|
|
2356
|
-
if (n.code === p.PIN_INVALID) {
|
|
2357
|
-
s = n.message;
|
|
2358
|
-
continue;
|
|
2359
|
-
}
|
|
2360
|
-
if (n.code === p.PIN_LOCKED) {
|
|
2361
|
-
const o = n.details;
|
|
2362
|
-
t = o == null ? void 0 : o.lockExpiresAt, s = "Too many failed attempts. Your account is temporarily locked.";
|
|
2363
|
-
continue;
|
|
2364
|
-
}
|
|
2365
|
-
}
|
|
2366
|
-
throw n;
|
|
2500
|
+
} catch (c) {
|
|
2501
|
+
if (c instanceof m && a(c))
|
|
2502
|
+
continue;
|
|
2503
|
+
throw c;
|
|
2367
2504
|
}
|
|
2368
2505
|
}
|
|
2369
2506
|
}
|
|
@@ -2403,7 +2540,7 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2403
2540
|
*/
|
|
2404
2541
|
dispose() {
|
|
2405
2542
|
var e;
|
|
2406
|
-
(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);
|
|
2407
2544
|
}
|
|
2408
2545
|
/**
|
|
2409
2546
|
* @internal internal 패키지 전용 — 공개 문서에 기재하지 않음
|
|
@@ -2423,9 +2560,9 @@ const Xs = 2e3, At = 6e4, Zs = 1e3, Qs = 1e4, er = "0x77359400", Rt = "0x3B9ACA0
|
|
|
2423
2560
|
};
|
|
2424
2561
|
}
|
|
2425
2562
|
};
|
|
2426
|
-
|
|
2427
|
-
let
|
|
2428
|
-
class
|
|
2563
|
+
ee.OFFCHAIN_CHAIN_ID = "0";
|
|
2564
|
+
let ct = ee;
|
|
2565
|
+
class or {
|
|
2429
2566
|
constructor() {
|
|
2430
2567
|
this.prefix = "crossx_";
|
|
2431
2568
|
}
|
|
@@ -2462,8 +2599,8 @@ class nr {
|
|
|
2462
2599
|
}
|
|
2463
2600
|
}
|
|
2464
2601
|
}
|
|
2465
|
-
const Ze = "crossx-sdk",
|
|
2466
|
-
class
|
|
2602
|
+
const Ze = "crossx-sdk", ir = 1, de = "data", Ee = "keys", Be = "aes-primary", ar = 12;
|
|
2603
|
+
class Lt {
|
|
2467
2604
|
constructor(e) {
|
|
2468
2605
|
this.db = null, this.cryptoKey = null, this.initPromise = null, this.dbName = `crossx-sdk-${e}`;
|
|
2469
2606
|
}
|
|
@@ -2472,10 +2609,10 @@ class Ct {
|
|
|
2472
2609
|
}
|
|
2473
2610
|
openDB(e = this.dbName) {
|
|
2474
2611
|
return new Promise((s, t) => {
|
|
2475
|
-
const n = indexedDB.open(e,
|
|
2612
|
+
const n = indexedDB.open(e, ir);
|
|
2476
2613
|
n.onupgradeneeded = () => {
|
|
2477
2614
|
const o = n.result;
|
|
2478
|
-
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);
|
|
2479
2616
|
}, n.onsuccess = () => s(n.result), n.onerror = () => t(n.error);
|
|
2480
2617
|
});
|
|
2481
2618
|
}
|
|
@@ -2505,7 +2642,7 @@ class Ct {
|
|
|
2505
2642
|
}
|
|
2506
2643
|
async init() {
|
|
2507
2644
|
this.db = await this.openDB();
|
|
2508
|
-
const e = await this.idbGet(
|
|
2645
|
+
const e = await this.idbGet(Ee, Be);
|
|
2509
2646
|
if (e) {
|
|
2510
2647
|
this.cryptoKey = e;
|
|
2511
2648
|
return;
|
|
@@ -2519,7 +2656,7 @@ class Ct {
|
|
|
2519
2656
|
{ name: "AES-GCM", length: 256 },
|
|
2520
2657
|
!1,
|
|
2521
2658
|
["encrypt", "decrypt"]
|
|
2522
|
-
), await this.idbPut(
|
|
2659
|
+
), await this.idbPut(Ee, Be, this.cryptoKey);
|
|
2523
2660
|
}
|
|
2524
2661
|
/**
|
|
2525
2662
|
* 레거시 DB('crossx-sdk')에서 projectId 스코프 DB로 암호키·데이터 마이그레이션.
|
|
@@ -2528,7 +2665,7 @@ class Ct {
|
|
|
2528
2665
|
async migrateFromLegacyDB() {
|
|
2529
2666
|
if (this.dbName === Ze) return null;
|
|
2530
2667
|
try {
|
|
2531
|
-
const e = await this.openDB(Ze), s = e.transaction([
|
|
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) => {
|
|
2532
2669
|
t.onsuccess = () => l(t.result), t.onerror = () => u(t.error);
|
|
2533
2670
|
});
|
|
2534
2671
|
if (!n)
|
|
@@ -2541,7 +2678,7 @@ class Ct {
|
|
|
2541
2678
|
i.onsuccess = () => l(i.result), i.onerror = () => u(i.error);
|
|
2542
2679
|
})
|
|
2543
2680
|
]);
|
|
2544
|
-
e.close(), await this.idbPut(
|
|
2681
|
+
e.close(), await this.idbPut(Ee, Be, n);
|
|
2545
2682
|
for (let l = 0; l < c.length; l++)
|
|
2546
2683
|
await this.idbPut(de, String(c[l]), a[l]);
|
|
2547
2684
|
return indexedDB.deleteDatabase(Ze), d.log("[CROSSx] IndexedDB 레거시 DB 마이그레이션 완료"), n;
|
|
@@ -2550,7 +2687,7 @@ class Ct {
|
|
|
2550
2687
|
}
|
|
2551
2688
|
}
|
|
2552
2689
|
async encrypt(e) {
|
|
2553
|
-
const s = new Uint8Array(
|
|
2690
|
+
const s = new Uint8Array(ar);
|
|
2554
2691
|
crypto.getRandomValues(s);
|
|
2555
2692
|
const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
|
|
2556
2693
|
{ name: "AES-GCM", iv: s },
|
|
@@ -2609,7 +2746,7 @@ class Ct {
|
|
|
2609
2746
|
}
|
|
2610
2747
|
}
|
|
2611
2748
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2612
|
-
function
|
|
2749
|
+
function pt(r) {
|
|
2613
2750
|
return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
|
|
2614
2751
|
}
|
|
2615
2752
|
function me(r, e = "") {
|
|
@@ -2618,35 +2755,35 @@ function me(r, e = "") {
|
|
|
2618
2755
|
throw new Error(`${s}expected integer >= 0, got ${r}`);
|
|
2619
2756
|
}
|
|
2620
2757
|
}
|
|
2621
|
-
function
|
|
2622
|
-
const t =
|
|
2758
|
+
function q(r, e, s = "") {
|
|
2759
|
+
const t = pt(r), n = r == null ? void 0 : r.length, o = e !== void 0;
|
|
2623
2760
|
if (!t || o && n !== e) {
|
|
2624
2761
|
const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
|
|
2625
2762
|
throw new Error(i + "expected Uint8Array" + a + ", got " + c);
|
|
2626
2763
|
}
|
|
2627
2764
|
return r;
|
|
2628
2765
|
}
|
|
2629
|
-
function
|
|
2766
|
+
function rs(r) {
|
|
2630
2767
|
if (typeof r != "function" || typeof r.create != "function")
|
|
2631
2768
|
throw new Error("Hash must wrapped by utils.createHasher");
|
|
2632
2769
|
me(r.outputLen), me(r.blockLen);
|
|
2633
2770
|
}
|
|
2634
|
-
function
|
|
2771
|
+
function Oe(r, e = !0) {
|
|
2635
2772
|
if (r.destroyed)
|
|
2636
2773
|
throw new Error("Hash instance has been destroyed");
|
|
2637
2774
|
if (e && r.finished)
|
|
2638
2775
|
throw new Error("Hash#digest() has already been called");
|
|
2639
2776
|
}
|
|
2640
|
-
function
|
|
2641
|
-
|
|
2777
|
+
function ns(r, e) {
|
|
2778
|
+
q(r, void 0, "digestInto() output");
|
|
2642
2779
|
const s = e.outputLen;
|
|
2643
2780
|
if (r.length < s)
|
|
2644
2781
|
throw new Error('"digestInto() output" expected to be of length >=' + s);
|
|
2645
2782
|
}
|
|
2646
|
-
function
|
|
2783
|
+
function cr(r) {
|
|
2647
2784
|
return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
|
|
2648
2785
|
}
|
|
2649
|
-
function
|
|
2786
|
+
function Ce(...r) {
|
|
2650
2787
|
for (let e = 0; e < r.length; e++)
|
|
2651
2788
|
r[e].fill(0);
|
|
2652
2789
|
}
|
|
@@ -2656,26 +2793,26 @@ function Qe(r) {
|
|
|
2656
2793
|
function ue(r, e) {
|
|
2657
2794
|
return r << 32 - e | r >>> e;
|
|
2658
2795
|
}
|
|
2659
|
-
const
|
|
2660
|
-
function
|
|
2796
|
+
const lr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
2797
|
+
function dr(r) {
|
|
2661
2798
|
return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
|
|
2662
2799
|
}
|
|
2663
|
-
function
|
|
2800
|
+
function ur(r) {
|
|
2664
2801
|
for (let e = 0; e < r.length; e++)
|
|
2665
|
-
r[e] =
|
|
2802
|
+
r[e] = dr(r[e]);
|
|
2666
2803
|
return r;
|
|
2667
2804
|
}
|
|
2668
|
-
const
|
|
2669
|
-
function
|
|
2670
|
-
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)
|
|
2671
2808
|
return r.toHex();
|
|
2672
2809
|
let e = "";
|
|
2673
2810
|
for (let s = 0; s < r.length; s++)
|
|
2674
|
-
e +=
|
|
2811
|
+
e += hr[r[s]];
|
|
2675
2812
|
return e;
|
|
2676
2813
|
}
|
|
2677
2814
|
const fe = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
2678
|
-
function
|
|
2815
|
+
function Mt(r) {
|
|
2679
2816
|
if (r >= fe._0 && r <= fe._9)
|
|
2680
2817
|
return r - fe._0;
|
|
2681
2818
|
if (r >= fe.A && r <= fe.F)
|
|
@@ -2683,17 +2820,17 @@ function Lt(r) {
|
|
|
2683
2820
|
if (r >= fe.a && r <= fe.f)
|
|
2684
2821
|
return r - (fe.a - 10);
|
|
2685
2822
|
}
|
|
2686
|
-
function
|
|
2823
|
+
function qe(r) {
|
|
2687
2824
|
if (typeof r != "string")
|
|
2688
2825
|
throw new Error("hex string expected, got " + typeof r);
|
|
2689
|
-
if (
|
|
2826
|
+
if (os)
|
|
2690
2827
|
return Uint8Array.fromHex(r);
|
|
2691
2828
|
const e = r.length, s = e / 2;
|
|
2692
2829
|
if (e % 2)
|
|
2693
2830
|
throw new Error("hex string expected, got unpadded hex of length " + e);
|
|
2694
2831
|
const t = new Uint8Array(s);
|
|
2695
2832
|
for (let n = 0, o = 0; n < s; n++, o += 2) {
|
|
2696
|
-
const i =
|
|
2833
|
+
const i = Mt(r.charCodeAt(o)), a = Mt(r.charCodeAt(o + 1));
|
|
2697
2834
|
if (i === void 0 || a === void 0) {
|
|
2698
2835
|
const c = r[o] + r[o + 1];
|
|
2699
2836
|
throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + o);
|
|
@@ -2702,11 +2839,11 @@ function We(r) {
|
|
|
2702
2839
|
}
|
|
2703
2840
|
return t;
|
|
2704
2841
|
}
|
|
2705
|
-
function
|
|
2842
|
+
function Se(...r) {
|
|
2706
2843
|
let e = 0;
|
|
2707
2844
|
for (let t = 0; t < r.length; t++) {
|
|
2708
2845
|
const n = r[t];
|
|
2709
|
-
|
|
2846
|
+
q(n), e += n.length;
|
|
2710
2847
|
}
|
|
2711
2848
|
const s = new Uint8Array(e);
|
|
2712
2849
|
for (let t = 0, n = 0; t < r.length; t++) {
|
|
@@ -2715,42 +2852,42 @@ function ve(...r) {
|
|
|
2715
2852
|
}
|
|
2716
2853
|
return s;
|
|
2717
2854
|
}
|
|
2718
|
-
function
|
|
2855
|
+
function is(r, e = {}) {
|
|
2719
2856
|
const s = (n, o) => r(o).update(n).digest(), t = r(void 0);
|
|
2720
2857
|
return s.outputLen = t.outputLen, s.blockLen = t.blockLen, s.create = (n) => r(n), Object.assign(s, e), Object.freeze(s);
|
|
2721
2858
|
}
|
|
2722
|
-
function
|
|
2859
|
+
function as(r = 32) {
|
|
2723
2860
|
const e = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
2724
2861
|
if (typeof (e == null ? void 0 : e.getRandomValues) != "function")
|
|
2725
2862
|
throw new Error("crypto.getRandomValues must be defined");
|
|
2726
2863
|
return e.getRandomValues(new Uint8Array(r));
|
|
2727
2864
|
}
|
|
2728
|
-
const
|
|
2865
|
+
const pr = (r) => ({
|
|
2729
2866
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
|
|
2730
2867
|
});
|
|
2731
|
-
function
|
|
2868
|
+
function fr(r, e, s) {
|
|
2732
2869
|
return r & e ^ ~r & s;
|
|
2733
2870
|
}
|
|
2734
|
-
function
|
|
2871
|
+
function _r(r, e, s) {
|
|
2735
2872
|
return r & e ^ r & s ^ e & s;
|
|
2736
2873
|
}
|
|
2737
|
-
class
|
|
2874
|
+
class xr {
|
|
2738
2875
|
constructor(e, s, t, n) {
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2876
|
+
T(this, "blockLen");
|
|
2877
|
+
T(this, "outputLen");
|
|
2878
|
+
T(this, "padOffset");
|
|
2879
|
+
T(this, "isLE");
|
|
2743
2880
|
// For partial updates less than block size
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
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);
|
|
2750
2887
|
this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Qe(this.buffer);
|
|
2751
2888
|
}
|
|
2752
2889
|
update(e) {
|
|
2753
|
-
|
|
2890
|
+
Oe(this), q(e);
|
|
2754
2891
|
const { view: s, buffer: t, blockLen: n } = this, o = e.length;
|
|
2755
2892
|
for (let i = 0; i < o; ) {
|
|
2756
2893
|
const a = Math.min(n - this.pos, o - i);
|
|
@@ -2765,10 +2902,10 @@ class _r {
|
|
|
2765
2902
|
return this.length += e.length, this.roundClean(), this;
|
|
2766
2903
|
}
|
|
2767
2904
|
digestInto(e) {
|
|
2768
|
-
|
|
2905
|
+
Oe(this), ns(e, this), this.finished = !0;
|
|
2769
2906
|
const { buffer: s, view: t, blockLen: n, isLE: o } = this;
|
|
2770
2907
|
let { pos: i } = this;
|
|
2771
|
-
s[i++] = 128,
|
|
2908
|
+
s[i++] = 128, Ce(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
|
|
2772
2909
|
for (let h = i; h < n; h++)
|
|
2773
2910
|
s[h] = 0;
|
|
2774
2911
|
t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
|
|
@@ -2805,20 +2942,20 @@ const we = /* @__PURE__ */ Uint32Array.from([
|
|
|
2805
2942
|
2600822924,
|
|
2806
2943
|
528734635,
|
|
2807
2944
|
1541459225
|
|
2808
|
-
]),
|
|
2809
|
-
function xr(r, e = !1) {
|
|
2810
|
-
return e ? { h: Number(r & Be), l: Number(r >> Dt & Be) } : { h: Number(r >> Dt & Be) | 0, l: Number(r & Be) | 0 };
|
|
2811
|
-
}
|
|
2945
|
+
]), Ue = /* @__PURE__ */ BigInt(2 ** 32 - 1), $t = /* @__PURE__ */ BigInt(32);
|
|
2812
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) {
|
|
2813
2950
|
const s = r.length;
|
|
2814
2951
|
let t = new Uint32Array(s), n = new Uint32Array(s);
|
|
2815
2952
|
for (let o = 0; o < s; o++) {
|
|
2816
|
-
const { h: i, l: a } =
|
|
2953
|
+
const { h: i, l: a } = gr(r[o], e);
|
|
2817
2954
|
[t[o], n[o]] = [i, a];
|
|
2818
2955
|
}
|
|
2819
2956
|
return [t, n];
|
|
2820
2957
|
}
|
|
2821
|
-
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([
|
|
2822
2959
|
1116352408,
|
|
2823
2960
|
1899447441,
|
|
2824
2961
|
3049323471,
|
|
@@ -2884,7 +3021,7 @@ const mr = (r, e, s) => r << s | e >>> 32 - s, wr = (r, e, s) => e << s | r >>>
|
|
|
2884
3021
|
3204031479,
|
|
2885
3022
|
3329325298
|
|
2886
3023
|
]), ye = /* @__PURE__ */ new Uint32Array(64);
|
|
2887
|
-
class
|
|
3024
|
+
class Er extends xr {
|
|
2888
3025
|
constructor(e) {
|
|
2889
3026
|
super(64, e, 8, !1);
|
|
2890
3027
|
}
|
|
@@ -2900,132 +3037,132 @@ class Sr extends _r {
|
|
|
2900
3037
|
for (let h = 0; h < 16; h++, s += 4)
|
|
2901
3038
|
ye[h] = e.getUint32(s, !1);
|
|
2902
3039
|
for (let h = 16; h < 64; h++) {
|
|
2903
|
-
const _ = ye[h - 15], f = ye[h - 2], w = ue(_, 7) ^ ue(_, 18) ^ _ >>> 3,
|
|
2904
|
-
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;
|
|
2905
3042
|
}
|
|
2906
3043
|
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: u } = this;
|
|
2907
3044
|
for (let h = 0; h < 64; h++) {
|
|
2908
|
-
const _ = ue(a, 6) ^ ue(a, 11) ^ ue(a, 25), f = u + _ +
|
|
2909
|
-
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;
|
|
2910
3047
|
}
|
|
2911
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);
|
|
2912
3049
|
}
|
|
2913
3050
|
roundClean() {
|
|
2914
|
-
|
|
3051
|
+
Ce(ye);
|
|
2915
3052
|
}
|
|
2916
3053
|
destroy() {
|
|
2917
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0),
|
|
3054
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), Ce(this.buffer);
|
|
2918
3055
|
}
|
|
2919
3056
|
}
|
|
2920
|
-
class
|
|
3057
|
+
class Ir extends Er {
|
|
2921
3058
|
constructor() {
|
|
2922
3059
|
super(32);
|
|
2923
3060
|
// We cannot use array here since array allows indexing by variable
|
|
2924
3061
|
// which means optimizer/compiler cannot use registers.
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
}
|
|
2934
|
-
}
|
|
2935
|
-
const
|
|
2936
|
-
() => new
|
|
2937
|
-
/* @__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)
|
|
2938
3075
|
);
|
|
2939
3076
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2940
|
-
const
|
|
2941
|
-
function
|
|
3077
|
+
const ft = /* @__PURE__ */ BigInt(0), lt = /* @__PURE__ */ BigInt(1);
|
|
3078
|
+
function Ke(r, e = "") {
|
|
2942
3079
|
if (typeof r != "boolean") {
|
|
2943
3080
|
const s = e && `"${e}" `;
|
|
2944
3081
|
throw new Error(s + "expected boolean, got type=" + typeof r);
|
|
2945
3082
|
}
|
|
2946
3083
|
return r;
|
|
2947
3084
|
}
|
|
2948
|
-
function
|
|
3085
|
+
function cs(r) {
|
|
2949
3086
|
if (typeof r == "bigint") {
|
|
2950
|
-
if (!
|
|
3087
|
+
if (!Ge(r))
|
|
2951
3088
|
throw new Error("positive bigint expected, got " + r);
|
|
2952
3089
|
} else
|
|
2953
3090
|
me(r);
|
|
2954
3091
|
return r;
|
|
2955
3092
|
}
|
|
2956
|
-
function
|
|
2957
|
-
const e =
|
|
3093
|
+
function He(r) {
|
|
3094
|
+
const e = cs(r).toString(16);
|
|
2958
3095
|
return e.length & 1 ? "0" + e : e;
|
|
2959
3096
|
}
|
|
2960
|
-
function
|
|
3097
|
+
function ls(r) {
|
|
2961
3098
|
if (typeof r != "string")
|
|
2962
3099
|
throw new Error("hex string expected, got " + typeof r);
|
|
2963
|
-
return r === "" ?
|
|
3100
|
+
return r === "" ? ft : BigInt("0x" + r);
|
|
2964
3101
|
}
|
|
2965
|
-
function
|
|
2966
|
-
return
|
|
3102
|
+
function Ye(r) {
|
|
3103
|
+
return ls($e(r));
|
|
2967
3104
|
}
|
|
2968
|
-
function
|
|
2969
|
-
return
|
|
3105
|
+
function ds(r) {
|
|
3106
|
+
return ls($e(Tr(q(r)).reverse()));
|
|
2970
3107
|
}
|
|
2971
|
-
function
|
|
2972
|
-
me(e), r =
|
|
2973
|
-
const s =
|
|
3108
|
+
function _t(r, e) {
|
|
3109
|
+
me(e), r = cs(r);
|
|
3110
|
+
const s = qe(r.toString(16).padStart(e * 2, "0"));
|
|
2974
3111
|
if (s.length !== e)
|
|
2975
3112
|
throw new Error("number too large");
|
|
2976
3113
|
return s;
|
|
2977
3114
|
}
|
|
2978
|
-
function
|
|
2979
|
-
return
|
|
3115
|
+
function us(r, e) {
|
|
3116
|
+
return _t(r, e).reverse();
|
|
2980
3117
|
}
|
|
2981
3118
|
function Tr(r) {
|
|
2982
3119
|
return Uint8Array.from(r);
|
|
2983
3120
|
}
|
|
2984
|
-
const
|
|
2985
|
-
function
|
|
2986
|
-
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;
|
|
2987
3124
|
}
|
|
2988
|
-
function
|
|
2989
|
-
if (!
|
|
3125
|
+
function kr(r, e, s, t) {
|
|
3126
|
+
if (!Rr(e, s, t))
|
|
2990
3127
|
throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
|
|
2991
3128
|
}
|
|
2992
|
-
function
|
|
3129
|
+
function Pr(r) {
|
|
2993
3130
|
let e;
|
|
2994
|
-
for (e = 0; r >
|
|
3131
|
+
for (e = 0; r > ft; r >>= lt, e += 1)
|
|
2995
3132
|
;
|
|
2996
3133
|
return e;
|
|
2997
3134
|
}
|
|
2998
|
-
const
|
|
2999
|
-
function
|
|
3135
|
+
const xt = (r) => (lt << BigInt(r)) - lt;
|
|
3136
|
+
function Or(r, e, s) {
|
|
3000
3137
|
if (me(r, "hashLen"), me(e, "qByteLen"), typeof s != "function")
|
|
3001
3138
|
throw new Error("hmacFn must be a function");
|
|
3002
3139
|
const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
|
|
3003
3140
|
let c = t(r), l = t(r), u = 0;
|
|
3004
3141
|
const h = () => {
|
|
3005
3142
|
c.fill(1), l.fill(0), u = 0;
|
|
3006
|
-
}, _ = (...y) => s(l,
|
|
3143
|
+
}, _ = (...y) => s(l, Se(c, ...y)), f = (y = n) => {
|
|
3007
3144
|
l = _(o, y), c = _(), y.length !== 0 && (l = _(i, y), c = _());
|
|
3008
3145
|
}, w = () => {
|
|
3009
3146
|
if (u++ >= a)
|
|
3010
3147
|
throw new Error("drbg: tried max amount of iterations");
|
|
3011
3148
|
let y = 0;
|
|
3012
|
-
const
|
|
3149
|
+
const R = [];
|
|
3013
3150
|
for (; y < e; ) {
|
|
3014
3151
|
c = _();
|
|
3015
3152
|
const N = c.slice();
|
|
3016
|
-
|
|
3153
|
+
R.push(N), y += c.length;
|
|
3017
3154
|
}
|
|
3018
|
-
return
|
|
3155
|
+
return Se(...R);
|
|
3019
3156
|
};
|
|
3020
|
-
return (y,
|
|
3157
|
+
return (y, R) => {
|
|
3021
3158
|
h(), f(y);
|
|
3022
3159
|
let N;
|
|
3023
|
-
for (; !(N =
|
|
3160
|
+
for (; !(N = R(w())); )
|
|
3024
3161
|
f();
|
|
3025
3162
|
return h(), N;
|
|
3026
3163
|
};
|
|
3027
3164
|
}
|
|
3028
|
-
function
|
|
3165
|
+
function gt(r, e = {}, s = {}) {
|
|
3029
3166
|
if (!r || typeof r != "object")
|
|
3030
3167
|
throw new Error("expected valid options object");
|
|
3031
3168
|
function t(o, i, a) {
|
|
@@ -3039,7 +3176,7 @@ function xt(r, e = {}, s = {}) {
|
|
|
3039
3176
|
const n = (o, i) => Object.entries(o).forEach(([a, c]) => t(a, c, i));
|
|
3040
3177
|
n(e, !1), n(s, !0);
|
|
3041
3178
|
}
|
|
3042
|
-
function
|
|
3179
|
+
function Bt(r) {
|
|
3043
3180
|
const e = /* @__PURE__ */ new WeakMap();
|
|
3044
3181
|
return (s, ...t) => {
|
|
3045
3182
|
const n = e.get(s);
|
|
@@ -3050,7 +3187,7 @@ function Mt(r) {
|
|
|
3050
3187
|
};
|
|
3051
3188
|
}
|
|
3052
3189
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3053
|
-
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);
|
|
3054
3191
|
function le(r, e) {
|
|
3055
3192
|
const s = r % e;
|
|
3056
3193
|
return s >= ne ? s : e + s;
|
|
@@ -3061,80 +3198,80 @@ function ae(r, e, s) {
|
|
|
3061
3198
|
t *= t, t %= s;
|
|
3062
3199
|
return t;
|
|
3063
3200
|
}
|
|
3064
|
-
function
|
|
3201
|
+
function Ut(r, e) {
|
|
3065
3202
|
if (r === ne)
|
|
3066
3203
|
throw new Error("invert: expected non-zero number");
|
|
3067
3204
|
if (e <= ne)
|
|
3068
3205
|
throw new Error("invert: expected positive modulus, got " + e);
|
|
3069
|
-
let s = le(r, e), t = e, n = ne, o =
|
|
3206
|
+
let s = le(r, e), t = e, n = ne, o = te;
|
|
3070
3207
|
for (; s !== ne; ) {
|
|
3071
3208
|
const a = t / s, c = t % s, l = n - o * a;
|
|
3072
3209
|
t = s, s = c, n = o, o = l;
|
|
3073
3210
|
}
|
|
3074
|
-
if (t !==
|
|
3211
|
+
if (t !== te)
|
|
3075
3212
|
throw new Error("invert: does not exist");
|
|
3076
3213
|
return le(n, e);
|
|
3077
3214
|
}
|
|
3078
|
-
function
|
|
3215
|
+
function mt(r, e, s) {
|
|
3079
3216
|
if (!r.eql(r.sqr(e), s))
|
|
3080
3217
|
throw new Error("Cannot find square root");
|
|
3081
3218
|
}
|
|
3082
|
-
function
|
|
3083
|
-
const s = (r.ORDER +
|
|
3084
|
-
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;
|
|
3085
3222
|
}
|
|
3086
|
-
function
|
|
3087
|
-
const s = (r.ORDER -
|
|
3088
|
-
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;
|
|
3089
3226
|
}
|
|
3090
|
-
function
|
|
3091
|
-
const e = je(r), s =
|
|
3227
|
+
function Dr(r) {
|
|
3228
|
+
const e = je(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;
|
|
3092
3229
|
return (a, c) => {
|
|
3093
3230
|
let l = a.pow(c, i), u = a.mul(l, t);
|
|
3094
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);
|
|
3095
3232
|
l = a.cmov(l, u, f), u = a.cmov(_, h, w);
|
|
3096
|
-
const
|
|
3097
|
-
return
|
|
3233
|
+
const E = a.eql(a.sqr(u), c), y = a.cmov(l, u, E);
|
|
3234
|
+
return mt(a, y, c), y;
|
|
3098
3235
|
};
|
|
3099
3236
|
}
|
|
3100
|
-
function
|
|
3101
|
-
if (r <
|
|
3237
|
+
function ms(r) {
|
|
3238
|
+
if (r < hs)
|
|
3102
3239
|
throw new Error("sqrt is not defined for small field");
|
|
3103
|
-
let e = r -
|
|
3104
|
-
for (; e %
|
|
3105
|
-
e /=
|
|
3106
|
-
let t =
|
|
3240
|
+
let e = r - te, s = 0;
|
|
3241
|
+
for (; e % Ae === ne; )
|
|
3242
|
+
e /= Ae, s++;
|
|
3243
|
+
let t = Ae;
|
|
3107
3244
|
const n = je(r);
|
|
3108
|
-
for (;
|
|
3245
|
+
for (; Ht(n, t) === 1; )
|
|
3109
3246
|
if (t++ > 1e3)
|
|
3110
3247
|
throw new Error("Cannot find square root: probably non-prime P");
|
|
3111
3248
|
if (s === 1)
|
|
3112
|
-
return
|
|
3249
|
+
return gs;
|
|
3113
3250
|
let o = n.pow(t, e);
|
|
3114
|
-
const i = (e +
|
|
3251
|
+
const i = (e + te) / Ae;
|
|
3115
3252
|
return function(c, l) {
|
|
3116
3253
|
if (c.is0(l))
|
|
3117
3254
|
return l;
|
|
3118
|
-
if (
|
|
3255
|
+
if (Ht(c, l) !== 1)
|
|
3119
3256
|
throw new Error("Cannot find square root");
|
|
3120
3257
|
let u = s, h = c.mul(c.ONE, o), _ = c.pow(l, e), f = c.pow(l, i);
|
|
3121
3258
|
for (; !c.eql(_, c.ONE); ) {
|
|
3122
3259
|
if (c.is0(_))
|
|
3123
3260
|
return c.ZERO;
|
|
3124
|
-
let w = 1,
|
|
3125
|
-
for (; !c.eql(
|
|
3126
|
-
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)
|
|
3127
3264
|
throw new Error("Cannot find square root");
|
|
3128
|
-
const y =
|
|
3129
|
-
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);
|
|
3130
3267
|
}
|
|
3131
3268
|
return f;
|
|
3132
3269
|
};
|
|
3133
3270
|
}
|
|
3134
|
-
function
|
|
3135
|
-
return r %
|
|
3271
|
+
function Mr(r) {
|
|
3272
|
+
return r % ps === hs ? gs : r % _s === fs ? Lr : r % xs === Nr ? Dr(r) : ms(r);
|
|
3136
3273
|
}
|
|
3137
|
-
const
|
|
3274
|
+
const $r = [
|
|
3138
3275
|
"create",
|
|
3139
3276
|
"isValid",
|
|
3140
3277
|
"is0",
|
|
@@ -3153,59 +3290,59 @@ const Mr = [
|
|
|
3153
3290
|
"mulN",
|
|
3154
3291
|
"sqrN"
|
|
3155
3292
|
];
|
|
3156
|
-
function
|
|
3293
|
+
function Br(r) {
|
|
3157
3294
|
const e = {
|
|
3158
3295
|
ORDER: "bigint",
|
|
3159
3296
|
BYTES: "number",
|
|
3160
3297
|
BITS: "number"
|
|
3161
|
-
}, s =
|
|
3162
|
-
return
|
|
3298
|
+
}, s = $r.reduce((t, n) => (t[n] = "function", t), e);
|
|
3299
|
+
return gt(r, s), r;
|
|
3163
3300
|
}
|
|
3164
|
-
function
|
|
3301
|
+
function Ur(r, e, s) {
|
|
3165
3302
|
if (s < ne)
|
|
3166
3303
|
throw new Error("invalid exponent, negatives unsupported");
|
|
3167
3304
|
if (s === ne)
|
|
3168
3305
|
return r.ONE;
|
|
3169
|
-
if (s ===
|
|
3306
|
+
if (s === te)
|
|
3170
3307
|
return e;
|
|
3171
3308
|
let t = r.ONE, n = e;
|
|
3172
3309
|
for (; s > ne; )
|
|
3173
|
-
s &
|
|
3310
|
+
s & te && (t = r.mul(t, n)), n = r.sqr(n), s >>= te;
|
|
3174
3311
|
return t;
|
|
3175
3312
|
}
|
|
3176
|
-
function
|
|
3313
|
+
function ws(r, e, s = !1) {
|
|
3177
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);
|
|
3178
3315
|
return e.reduceRight((i, a, c) => r.is0(a) ? i : (t[c] = r.mul(i, t[c]), r.mul(i, a)), o), t;
|
|
3179
3316
|
}
|
|
3180
|
-
function
|
|
3181
|
-
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));
|
|
3182
3319
|
if (!n && !o && !i)
|
|
3183
3320
|
throw new Error("invalid Legendre symbol result");
|
|
3184
3321
|
return n ? 1 : o ? 0 : -1;
|
|
3185
3322
|
}
|
|
3186
|
-
function
|
|
3323
|
+
function Hr(r, e) {
|
|
3187
3324
|
e !== void 0 && me(e);
|
|
3188
3325
|
const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
|
|
3189
3326
|
return { nBitLength: s, nByteLength: t };
|
|
3190
3327
|
}
|
|
3191
|
-
class
|
|
3328
|
+
class Fr {
|
|
3192
3329
|
constructor(e, s = {}) {
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
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");
|
|
3201
3338
|
// cached sqrt
|
|
3202
|
-
|
|
3339
|
+
T(this, "_mod");
|
|
3203
3340
|
var i;
|
|
3204
3341
|
if (e <= ne)
|
|
3205
3342
|
throw new Error("invalid field: expected ORDER > 0, got " + e);
|
|
3206
3343
|
let t;
|
|
3207
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));
|
|
3208
|
-
const { nBitLength: n, nByteLength: o } =
|
|
3345
|
+
const { nBitLength: n, nByteLength: o } = Hr(e, t);
|
|
3209
3346
|
if (o > 2048)
|
|
3210
3347
|
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
3211
3348
|
this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
|
|
@@ -3226,7 +3363,7 @@ class Hr {
|
|
|
3226
3363
|
return !this.is0(e) && this.isValid(e);
|
|
3227
3364
|
}
|
|
3228
3365
|
isOdd(e) {
|
|
3229
|
-
return (e &
|
|
3366
|
+
return (e & te) === te;
|
|
3230
3367
|
}
|
|
3231
3368
|
neg(e) {
|
|
3232
3369
|
return le(-e, this.ORDER);
|
|
@@ -3247,10 +3384,10 @@ class Hr {
|
|
|
3247
3384
|
return le(e * s, this.ORDER);
|
|
3248
3385
|
}
|
|
3249
3386
|
pow(e, s) {
|
|
3250
|
-
return
|
|
3387
|
+
return Ur(this, e, s);
|
|
3251
3388
|
}
|
|
3252
3389
|
div(e, s) {
|
|
3253
|
-
return le(e *
|
|
3390
|
+
return le(e * Ut(s, this.ORDER), this.ORDER);
|
|
3254
3391
|
}
|
|
3255
3392
|
// Same as above, but doesn't normalize
|
|
3256
3393
|
sqrN(e) {
|
|
@@ -3266,16 +3403,16 @@ class Hr {
|
|
|
3266
3403
|
return e * s;
|
|
3267
3404
|
}
|
|
3268
3405
|
inv(e) {
|
|
3269
|
-
return
|
|
3406
|
+
return Ut(e, this.ORDER);
|
|
3270
3407
|
}
|
|
3271
3408
|
sqrt(e) {
|
|
3272
|
-
return this._sqrt || (this._sqrt =
|
|
3409
|
+
return this._sqrt || (this._sqrt = Mr(this.ORDER)), this._sqrt(this, e);
|
|
3273
3410
|
}
|
|
3274
3411
|
toBytes(e) {
|
|
3275
|
-
return this.isLE ?
|
|
3412
|
+
return this.isLE ? us(e, this.BYTES) : _t(e, this.BYTES);
|
|
3276
3413
|
}
|
|
3277
3414
|
fromBytes(e, s = !1) {
|
|
3278
|
-
|
|
3415
|
+
q(e);
|
|
3279
3416
|
const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
|
|
3280
3417
|
if (t) {
|
|
3281
3418
|
if (!t.includes(e.length) || e.length > n)
|
|
@@ -3285,14 +3422,14 @@ class Hr {
|
|
|
3285
3422
|
}
|
|
3286
3423
|
if (e.length !== n)
|
|
3287
3424
|
throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
|
|
3288
|
-
let c = o ?
|
|
3425
|
+
let c = o ? ds(e) : Ye(e);
|
|
3289
3426
|
if (a && (c = le(c, i)), !s && !this.isValid(c))
|
|
3290
3427
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
3291
3428
|
return c;
|
|
3292
3429
|
}
|
|
3293
3430
|
// TODO: we don't need it here, move out to separate fn
|
|
3294
3431
|
invertBatch(e) {
|
|
3295
|
-
return
|
|
3432
|
+
return ws(this, e);
|
|
3296
3433
|
}
|
|
3297
3434
|
// We can't move this out because Fp6, Fp12 implement it
|
|
3298
3435
|
// and it's unclear what to return in there.
|
|
@@ -3301,73 +3438,73 @@ class Hr {
|
|
|
3301
3438
|
}
|
|
3302
3439
|
}
|
|
3303
3440
|
function je(r, e = {}) {
|
|
3304
|
-
return new
|
|
3441
|
+
return new Fr(r, e);
|
|
3305
3442
|
}
|
|
3306
|
-
function
|
|
3443
|
+
function ys(r) {
|
|
3307
3444
|
if (typeof r != "bigint")
|
|
3308
3445
|
throw new Error("field order must be bigint");
|
|
3309
3446
|
const e = r.toString(2).length;
|
|
3310
3447
|
return Math.ceil(e / 8);
|
|
3311
3448
|
}
|
|
3312
|
-
function
|
|
3313
|
-
const e =
|
|
3449
|
+
function bs(r) {
|
|
3450
|
+
const e = ys(r);
|
|
3314
3451
|
return e + Math.ceil(e / 2);
|
|
3315
3452
|
}
|
|
3316
|
-
function
|
|
3317
|
-
|
|
3318
|
-
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);
|
|
3319
3456
|
if (t < 16 || t < o || t > 1024)
|
|
3320
3457
|
throw new Error("expected " + o + "-1024 bytes of input, got " + t);
|
|
3321
|
-
const i = s ?
|
|
3322
|
-
return s ?
|
|
3458
|
+
const i = s ? ds(r) : Ye(r), a = le(i, e - te) + te;
|
|
3459
|
+
return s ? us(a, n) : _t(a, n);
|
|
3323
3460
|
}
|
|
3324
3461
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3325
|
-
const
|
|
3326
|
-
function
|
|
3462
|
+
const Ne = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1);
|
|
3463
|
+
function Ve(r, e) {
|
|
3327
3464
|
const s = e.negate();
|
|
3328
3465
|
return r ? s : e;
|
|
3329
3466
|
}
|
|
3330
|
-
function
|
|
3331
|
-
const s =
|
|
3467
|
+
function Ft(r, e) {
|
|
3468
|
+
const s = ws(r.Fp, e.map((t) => t.Z));
|
|
3332
3469
|
return e.map((t, n) => r.fromAffine(t.toAffine(s[n])));
|
|
3333
3470
|
}
|
|
3334
|
-
function
|
|
3471
|
+
function Ss(r, e) {
|
|
3335
3472
|
if (!Number.isSafeInteger(r) || r <= 0 || r > e)
|
|
3336
3473
|
throw new Error("invalid window size, expected [1.." + e + "], got W=" + r);
|
|
3337
3474
|
}
|
|
3338
3475
|
function et(r, e) {
|
|
3339
|
-
|
|
3340
|
-
const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o =
|
|
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);
|
|
3341
3478
|
return { windows: s, windowSize: t, mask: o, maxNumber: n, shiftBy: i };
|
|
3342
3479
|
}
|
|
3343
|
-
function
|
|
3480
|
+
function Gt(r, e, s) {
|
|
3344
3481
|
const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
|
|
3345
3482
|
let a = Number(r & n), c = r >> i;
|
|
3346
3483
|
a > t && (a -= o, c += Te);
|
|
3347
3484
|
const l = e * t, u = l + Math.abs(a) - 1, h = a === 0, _ = a < 0, f = e % 2 !== 0;
|
|
3348
3485
|
return { nextN: c, offset: u, isZero: h, isNeg: _, isNegF: f, offsetF: l };
|
|
3349
3486
|
}
|
|
3350
|
-
const tt = /* @__PURE__ */ new WeakMap(),
|
|
3487
|
+
const tt = /* @__PURE__ */ new WeakMap(), vs = /* @__PURE__ */ new WeakMap();
|
|
3351
3488
|
function st(r) {
|
|
3352
|
-
return
|
|
3489
|
+
return vs.get(r) || 1;
|
|
3353
3490
|
}
|
|
3354
|
-
function
|
|
3355
|
-
if (r !==
|
|
3491
|
+
function Wt(r) {
|
|
3492
|
+
if (r !== Ne)
|
|
3356
3493
|
throw new Error("invalid wNAF");
|
|
3357
3494
|
}
|
|
3358
|
-
class
|
|
3495
|
+
class Wr {
|
|
3359
3496
|
// Parametrized with a given Point class (not individual point)
|
|
3360
3497
|
constructor(e, s) {
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3498
|
+
T(this, "BASE");
|
|
3499
|
+
T(this, "ZERO");
|
|
3500
|
+
T(this, "Fn");
|
|
3501
|
+
T(this, "bits");
|
|
3365
3502
|
this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
|
|
3366
3503
|
}
|
|
3367
3504
|
// non-const time multiplication ladder
|
|
3368
3505
|
_unsafeLadder(e, s, t = this.ZERO) {
|
|
3369
3506
|
let n = e;
|
|
3370
|
-
for (; s >
|
|
3507
|
+
for (; s > Ne; )
|
|
3371
3508
|
s & Te && (t = t.add(n)), n = n.double(), s >>= Te;
|
|
3372
3509
|
return t;
|
|
3373
3510
|
}
|
|
@@ -3406,10 +3543,10 @@ class Gr {
|
|
|
3406
3543
|
let n = this.ZERO, o = this.BASE;
|
|
3407
3544
|
const i = et(e, this.bits);
|
|
3408
3545
|
for (let a = 0; a < i.windows; a++) {
|
|
3409
|
-
const { nextN: c, offset: l, isZero: u, isNeg: h, isNegF: _, offsetF: f } =
|
|
3410
|
-
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]));
|
|
3411
3548
|
}
|
|
3412
|
-
return
|
|
3549
|
+
return Wt(t), { p: n, f: o };
|
|
3413
3550
|
}
|
|
3414
3551
|
/**
|
|
3415
3552
|
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
@@ -3418,14 +3555,14 @@ class Gr {
|
|
|
3418
3555
|
*/
|
|
3419
3556
|
wNAFUnsafe(e, s, t, n = this.ZERO) {
|
|
3420
3557
|
const o = et(e, this.bits);
|
|
3421
|
-
for (let i = 0; i < o.windows && t !==
|
|
3422
|
-
const { nextN: a, offset: c, isZero: l, isNeg: u } =
|
|
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);
|
|
3423
3560
|
if (t = a, !l) {
|
|
3424
3561
|
const h = s[c];
|
|
3425
3562
|
n = n.add(u ? h.negate() : h);
|
|
3426
3563
|
}
|
|
3427
3564
|
}
|
|
3428
|
-
return
|
|
3565
|
+
return Wt(t), n;
|
|
3429
3566
|
}
|
|
3430
3567
|
getPrecomputes(e, s, t) {
|
|
3431
3568
|
let n = tt.get(s);
|
|
@@ -3443,55 +3580,55 @@ class Gr {
|
|
|
3443
3580
|
// using windowed method. This specifies window size and
|
|
3444
3581
|
// stores precomputed values. Usually only base point would be precomputed.
|
|
3445
3582
|
createCache(e, s) {
|
|
3446
|
-
|
|
3583
|
+
Ss(s, this.bits), vs.set(e, s), tt.delete(e);
|
|
3447
3584
|
}
|
|
3448
3585
|
hasCache(e) {
|
|
3449
3586
|
return st(e) !== 1;
|
|
3450
3587
|
}
|
|
3451
3588
|
}
|
|
3452
|
-
function
|
|
3589
|
+
function qr(r, e, s, t) {
|
|
3453
3590
|
let n = e, o = r.ZERO, i = r.ZERO;
|
|
3454
|
-
for (; s >
|
|
3591
|
+
for (; s > Ne || t > Ne; )
|
|
3455
3592
|
s & Te && (o = o.add(n)), t & Te && (i = i.add(n)), n = n.double(), s >>= Te, t >>= Te;
|
|
3456
3593
|
return { p1: o, p2: i };
|
|
3457
3594
|
}
|
|
3458
|
-
function
|
|
3595
|
+
function qt(r, e, s) {
|
|
3459
3596
|
if (e) {
|
|
3460
3597
|
if (e.ORDER !== r)
|
|
3461
3598
|
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
3462
|
-
return
|
|
3599
|
+
return Br(e), e;
|
|
3463
3600
|
} else
|
|
3464
3601
|
return je(r, { isLE: s });
|
|
3465
3602
|
}
|
|
3466
|
-
function
|
|
3603
|
+
function Kr(r, e, s = {}, t) {
|
|
3467
3604
|
if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
|
|
3468
3605
|
throw new Error(`expected valid ${r} CURVE object`);
|
|
3469
3606
|
for (const c of ["p", "n", "h"]) {
|
|
3470
3607
|
const l = e[c];
|
|
3471
|
-
if (!(typeof l == "bigint" && l >
|
|
3608
|
+
if (!(typeof l == "bigint" && l > Ne))
|
|
3472
3609
|
throw new Error(`CURVE.${c} must be positive bigint`);
|
|
3473
3610
|
}
|
|
3474
|
-
const n =
|
|
3611
|
+
const n = qt(e.p, s.Fp, t), o = qt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
|
|
3475
3612
|
for (const c of a)
|
|
3476
3613
|
if (!n.isValid(e[c]))
|
|
3477
3614
|
throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
|
|
3478
3615
|
return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
|
|
3479
3616
|
}
|
|
3480
|
-
function
|
|
3617
|
+
function Vr(r, e) {
|
|
3481
3618
|
return function(t) {
|
|
3482
3619
|
const n = r(t);
|
|
3483
3620
|
return { secretKey: n, publicKey: e(n) };
|
|
3484
3621
|
};
|
|
3485
3622
|
}
|
|
3486
|
-
class
|
|
3623
|
+
class Es {
|
|
3487
3624
|
constructor(e, s) {
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
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")
|
|
3495
3632
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
3496
3633
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
3497
3634
|
const t = this.blockLen, n = new Uint8Array(t);
|
|
@@ -3501,13 +3638,13 @@ class vs {
|
|
|
3501
3638
|
this.iHash.update(n), this.oHash = e.create();
|
|
3502
3639
|
for (let o = 0; o < n.length; o++)
|
|
3503
3640
|
n[o] ^= 106;
|
|
3504
|
-
this.oHash.update(n),
|
|
3641
|
+
this.oHash.update(n), Ce(n);
|
|
3505
3642
|
}
|
|
3506
3643
|
update(e) {
|
|
3507
|
-
return
|
|
3644
|
+
return Oe(this), this.iHash.update(e), this;
|
|
3508
3645
|
}
|
|
3509
3646
|
digestInto(e) {
|
|
3510
|
-
|
|
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();
|
|
3511
3648
|
}
|
|
3512
3649
|
digest() {
|
|
3513
3650
|
const e = new Uint8Array(this.oHash.outputLen);
|
|
@@ -3525,21 +3662,21 @@ class vs {
|
|
|
3525
3662
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
3526
3663
|
}
|
|
3527
3664
|
}
|
|
3528
|
-
const
|
|
3529
|
-
|
|
3665
|
+
const Is = (r, e, s) => new Es(r, e).update(s).digest();
|
|
3666
|
+
Is.create = (r, e) => new Es(r, e);
|
|
3530
3667
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3531
|
-
const
|
|
3532
|
-
function
|
|
3533
|
-
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);
|
|
3534
3671
|
let l = r - a * t - c * o, u = -a * n - c * i;
|
|
3535
3672
|
const h = l < xe, _ = u < xe;
|
|
3536
3673
|
h && (l = -l), _ && (u = -u);
|
|
3537
|
-
const f =
|
|
3674
|
+
const f = xt(Math.ceil(Pr(s) / 2)) + Pe;
|
|
3538
3675
|
if (l < xe || l >= f || u < xe || u >= f)
|
|
3539
3676
|
throw new Error("splitScalar (endomorphism): failed, k=" + r);
|
|
3540
3677
|
return { k1neg: h, k1: l, k2neg: _, k2: u };
|
|
3541
3678
|
}
|
|
3542
|
-
function
|
|
3679
|
+
function dt(r) {
|
|
3543
3680
|
if (!["compact", "recovered", "der"].includes(r))
|
|
3544
3681
|
throw new Error('Signature format must be "compact", "recovered", or "der"');
|
|
3545
3682
|
return r;
|
|
@@ -3548,16 +3685,16 @@ function rt(r, e) {
|
|
|
3548
3685
|
const s = {};
|
|
3549
3686
|
for (let t of Object.keys(e))
|
|
3550
3687
|
s[t] = r[t] === void 0 ? e[t] : r[t];
|
|
3551
|
-
return
|
|
3688
|
+
return Ke(s.lowS, "lowS"), Ke(s.prehash, "prehash"), s.format !== void 0 && dt(s.format), s;
|
|
3552
3689
|
}
|
|
3553
|
-
class
|
|
3690
|
+
class Yr extends Error {
|
|
3554
3691
|
constructor(e = "") {
|
|
3555
3692
|
super(e);
|
|
3556
3693
|
}
|
|
3557
3694
|
}
|
|
3558
3695
|
const be = {
|
|
3559
3696
|
// asn.1 DER encoding utils
|
|
3560
|
-
Err:
|
|
3697
|
+
Err: Yr,
|
|
3561
3698
|
// Basic building block is TLV (Tag-Length-Value)
|
|
3562
3699
|
_tlv: {
|
|
3563
3700
|
encode: (r, e) => {
|
|
@@ -3566,11 +3703,11 @@ const be = {
|
|
|
3566
3703
|
throw new s("tlv.encode: wrong tag");
|
|
3567
3704
|
if (e.length & 1)
|
|
3568
3705
|
throw new s("tlv.encode: unpadded data");
|
|
3569
|
-
const t = e.length / 2, n =
|
|
3706
|
+
const t = e.length / 2, n = He(t);
|
|
3570
3707
|
if (n.length / 2 & 128)
|
|
3571
3708
|
throw new s("tlv.encode: long form length too big");
|
|
3572
|
-
const o = t > 127 ?
|
|
3573
|
-
return
|
|
3709
|
+
const o = t > 127 ? He(n.length / 2 | 128) : "";
|
|
3710
|
+
return He(r) + o + n + e;
|
|
3574
3711
|
},
|
|
3575
3712
|
// v - value, l - left bytes (unparsed)
|
|
3576
3713
|
decode(r, e) {
|
|
@@ -3615,7 +3752,7 @@ const be = {
|
|
|
3615
3752
|
const { Err: e } = be;
|
|
3616
3753
|
if (r < xe)
|
|
3617
3754
|
throw new e("integer: negative integers are not allowed");
|
|
3618
|
-
let s =
|
|
3755
|
+
let s = He(r);
|
|
3619
3756
|
if (Number.parseInt(s[0], 16) & 8 && (s = "00" + s), s.length & 1)
|
|
3620
3757
|
throw new e("unexpected DER parsing assertion: unpadded hex");
|
|
3621
3758
|
return s;
|
|
@@ -3626,11 +3763,11 @@ const be = {
|
|
|
3626
3763
|
throw new e("invalid signature integer: negative");
|
|
3627
3764
|
if (r[0] === 0 && !(r[1] & 128))
|
|
3628
3765
|
throw new e("invalid signature integer: unnecessary leading zero");
|
|
3629
|
-
return
|
|
3766
|
+
return Ye(r);
|
|
3630
3767
|
}
|
|
3631
3768
|
},
|
|
3632
3769
|
toSig(r) {
|
|
3633
|
-
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);
|
|
3634
3771
|
if (i.length)
|
|
3635
3772
|
throw new e("invalid signature: left bytes after parsing");
|
|
3636
3773
|
const { v: a, l: c } = t.decode(2, o), { v: l, l: u } = t.decode(2, c);
|
|
@@ -3642,12 +3779,12 @@ const be = {
|
|
|
3642
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;
|
|
3643
3780
|
return e.encode(48, o);
|
|
3644
3781
|
}
|
|
3645
|
-
}, xe = BigInt(0),
|
|
3646
|
-
function
|
|
3647
|
-
const s =
|
|
3782
|
+
}, xe = BigInt(0), Pe = BigInt(1), As = BigInt(2), Fe = BigInt(3), jr = BigInt(4);
|
|
3783
|
+
function Xr(r, e = {}) {
|
|
3784
|
+
const s = Kr("weierstrass", r, e), { Fp: t, Fn: n } = s;
|
|
3648
3785
|
let o = s.CURVE;
|
|
3649
3786
|
const { h: i, n: a } = o;
|
|
3650
|
-
|
|
3787
|
+
gt(e, {}, {
|
|
3651
3788
|
allowInfinityPoint: "boolean",
|
|
3652
3789
|
clearCofactor: "function",
|
|
3653
3790
|
isTorsionFree: "function",
|
|
@@ -3658,87 +3795,87 @@ function Yr(r, e = {}) {
|
|
|
3658
3795
|
const { endo: c } = e;
|
|
3659
3796
|
if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
|
|
3660
3797
|
throw new Error('invalid endo: expected "beta": bigint and "basises": array');
|
|
3661
|
-
const l =
|
|
3798
|
+
const l = Rs(t, n);
|
|
3662
3799
|
function u() {
|
|
3663
3800
|
if (!t.isOdd)
|
|
3664
3801
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
3665
3802
|
}
|
|
3666
3803
|
function h(I, x, g) {
|
|
3667
|
-
const { x: v, y:
|
|
3668
|
-
if (
|
|
3804
|
+
const { x: v, y: A } = x.toAffine(), C = t.toBytes(v);
|
|
3805
|
+
if (Ke(g, "isCompressed"), g) {
|
|
3669
3806
|
u();
|
|
3670
|
-
const
|
|
3671
|
-
return
|
|
3807
|
+
const O = !t.isOdd(A);
|
|
3808
|
+
return Se(Ts(O), C);
|
|
3672
3809
|
} else
|
|
3673
|
-
return
|
|
3810
|
+
return Se(Uint8Array.of(4), C, t.toBytes(A));
|
|
3674
3811
|
}
|
|
3675
3812
|
function _(I) {
|
|
3676
|
-
|
|
3677
|
-
const { publicKey: x, publicKeyUncompressed: g } = l, v = I.length,
|
|
3678
|
-
if (v === x && (
|
|
3679
|
-
const
|
|
3680
|
-
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))
|
|
3681
3818
|
throw new Error("bad point: is not on curve, wrong x");
|
|
3682
|
-
const
|
|
3683
|
-
let
|
|
3819
|
+
const L = E(O);
|
|
3820
|
+
let P;
|
|
3684
3821
|
try {
|
|
3685
|
-
|
|
3686
|
-
} catch (
|
|
3687
|
-
const
|
|
3688
|
-
throw new Error("bad point: is not on curve, sqrt error" +
|
|
3822
|
+
P = t.sqrt(L);
|
|
3823
|
+
} catch (j) {
|
|
3824
|
+
const W = j instanceof Error ? ": " + j.message : "";
|
|
3825
|
+
throw new Error("bad point: is not on curve, sqrt error" + W);
|
|
3689
3826
|
}
|
|
3690
3827
|
u();
|
|
3691
|
-
const
|
|
3692
|
-
return (
|
|
3693
|
-
} else if (v === g &&
|
|
3694
|
-
const
|
|
3695
|
-
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))
|
|
3696
3833
|
throw new Error("bad point: is not on curve");
|
|
3697
|
-
return { x:
|
|
3834
|
+
return { x: L, y: P };
|
|
3698
3835
|
} else
|
|
3699
3836
|
throw new Error(`bad point: got length ${v}, expected compressed=${x} or uncompressed=${g}`);
|
|
3700
3837
|
}
|
|
3701
3838
|
const f = e.toBytes || h, w = e.fromBytes || _;
|
|
3702
|
-
function
|
|
3839
|
+
function E(I) {
|
|
3703
3840
|
const x = t.sqr(I), g = t.mul(x, I);
|
|
3704
3841
|
return t.add(t.add(g, t.mul(I, o.a)), o.b);
|
|
3705
3842
|
}
|
|
3706
3843
|
function y(I, x) {
|
|
3707
|
-
const g = t.sqr(x), v =
|
|
3844
|
+
const g = t.sqr(x), v = E(I);
|
|
3708
3845
|
return t.eql(g, v);
|
|
3709
3846
|
}
|
|
3710
3847
|
if (!y(o.Gx, o.Gy))
|
|
3711
3848
|
throw new Error("bad curve params: generator point");
|
|
3712
|
-
const
|
|
3713
|
-
if (t.is0(t.add(
|
|
3849
|
+
const R = t.mul(t.pow(o.a, Fe), jr), N = t.mul(t.sqr(o.b), BigInt(27));
|
|
3850
|
+
if (t.is0(t.add(R, N)))
|
|
3714
3851
|
throw new Error("bad curve params: a or b");
|
|
3715
|
-
function
|
|
3852
|
+
function F(I, x, g = !1) {
|
|
3716
3853
|
if (!t.isValid(x) || g && t.is0(x))
|
|
3717
3854
|
throw new Error(`bad point coordinate ${I}`);
|
|
3718
3855
|
return x;
|
|
3719
3856
|
}
|
|
3720
|
-
function
|
|
3721
|
-
if (!(I instanceof
|
|
3857
|
+
function M(I) {
|
|
3858
|
+
if (!(I instanceof z))
|
|
3722
3859
|
throw new Error("Weierstrass Point expected");
|
|
3723
3860
|
}
|
|
3724
|
-
function
|
|
3861
|
+
function V(I) {
|
|
3725
3862
|
if (!c || !c.basises)
|
|
3726
3863
|
throw new Error("no endo");
|
|
3727
|
-
return
|
|
3864
|
+
return zr(I, c.basises, n.ORDER);
|
|
3728
3865
|
}
|
|
3729
|
-
const
|
|
3730
|
-
const { X: g, Y: v, Z:
|
|
3731
|
-
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))
|
|
3732
3869
|
return { x: g, y: v };
|
|
3733
|
-
const
|
|
3734
|
-
x == null && (x =
|
|
3735
|
-
const
|
|
3736
|
-
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)
|
|
3737
3874
|
return { x: t.ZERO, y: t.ZERO };
|
|
3738
|
-
if (!t.eql(
|
|
3875
|
+
if (!t.eql(P, t.ONE))
|
|
3739
3876
|
throw new Error("invZ was invalid");
|
|
3740
|
-
return { x:
|
|
3741
|
-
}),
|
|
3877
|
+
return { x: O, y: L };
|
|
3878
|
+
}), J = Bt((I) => {
|
|
3742
3879
|
if (I.is0()) {
|
|
3743
3880
|
if (e.allowInfinityPoint && !t.is0(I.Y))
|
|
3744
3881
|
return;
|
|
@@ -3753,16 +3890,16 @@ function Yr(r, e = {}) {
|
|
|
3753
3890
|
throw new Error("bad point: not in prime-order subgroup");
|
|
3754
3891
|
return !0;
|
|
3755
3892
|
});
|
|
3756
|
-
function
|
|
3757
|
-
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);
|
|
3758
3895
|
}
|
|
3759
|
-
const
|
|
3896
|
+
const S = class S {
|
|
3760
3897
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
3761
3898
|
constructor(x, g, v) {
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
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);
|
|
3766
3903
|
}
|
|
3767
3904
|
static CURVE() {
|
|
3768
3905
|
return o;
|
|
@@ -3772,16 +3909,16 @@ function Yr(r, e = {}) {
|
|
|
3772
3909
|
const { x: g, y: v } = x || {};
|
|
3773
3910
|
if (!x || !t.isValid(g) || !t.isValid(v))
|
|
3774
3911
|
throw new Error("invalid affine point");
|
|
3775
|
-
if (x instanceof
|
|
3912
|
+
if (x instanceof S)
|
|
3776
3913
|
throw new Error("projective point not allowed");
|
|
3777
|
-
return t.is0(g) && t.is0(v) ?
|
|
3914
|
+
return t.is0(g) && t.is0(v) ? S.ZERO : new S(g, v, t.ONE);
|
|
3778
3915
|
}
|
|
3779
3916
|
static fromBytes(x) {
|
|
3780
|
-
const g =
|
|
3917
|
+
const g = S.fromAffine(w(q(x, void 0, "point")));
|
|
3781
3918
|
return g.assertValidity(), g;
|
|
3782
3919
|
}
|
|
3783
3920
|
static fromHex(x) {
|
|
3784
|
-
return
|
|
3921
|
+
return S.fromBytes(qe(x));
|
|
3785
3922
|
}
|
|
3786
3923
|
get x() {
|
|
3787
3924
|
return this.toAffine().x;
|
|
@@ -3796,12 +3933,12 @@ function Yr(r, e = {}) {
|
|
|
3796
3933
|
* @returns
|
|
3797
3934
|
*/
|
|
3798
3935
|
precompute(x = 8, g = !0) {
|
|
3799
|
-
return
|
|
3936
|
+
return b.createCache(this, x), g || this.multiply(Fe), this;
|
|
3800
3937
|
}
|
|
3801
3938
|
// TODO: return `this`
|
|
3802
3939
|
/** A point on curve is valid if it conforms to equation. */
|
|
3803
3940
|
assertValidity() {
|
|
3804
|
-
|
|
3941
|
+
J(this);
|
|
3805
3942
|
}
|
|
3806
3943
|
hasEvenY() {
|
|
3807
3944
|
const { y: x } = this.toAffine();
|
|
@@ -3811,42 +3948,42 @@ function Yr(r, e = {}) {
|
|
|
3811
3948
|
}
|
|
3812
3949
|
/** Compare one point to another. */
|
|
3813
3950
|
equals(x) {
|
|
3814
|
-
|
|
3815
|
-
const { X: g, Y: v, Z:
|
|
3816
|
-
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;
|
|
3817
3954
|
}
|
|
3818
3955
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
3819
3956
|
negate() {
|
|
3820
|
-
return new
|
|
3957
|
+
return new S(this.X, t.neg(this.Y), this.Z);
|
|
3821
3958
|
}
|
|
3822
3959
|
// Renes-Costello-Batina exception-free doubling formula.
|
|
3823
3960
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
3824
3961
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
3825
3962
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
3826
3963
|
double() {
|
|
3827
|
-
const { a: x, b: g } = o, v = t.mul(g,
|
|
3828
|
-
let
|
|
3829
|
-
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), j = 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(j, P), P = t.add(j, 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, j), D = t.add(D, D), D = t.add(D, D), new S(L, P, D);
|
|
3830
3967
|
}
|
|
3831
3968
|
// Renes-Costello-Batina exception-free addition formula.
|
|
3832
3969
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
3833
3970
|
// https://eprint.iacr.org/2015/1060, algorithm 1
|
|
3834
3971
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
3835
3972
|
add(x) {
|
|
3836
|
-
|
|
3837
|
-
const { X: g, Y: v, Z:
|
|
3838
|
-
let
|
|
3839
|
-
const
|
|
3840
|
-
let
|
|
3841
|
-
oe = t.mul(oe,
|
|
3842
|
-
let Q = t.add(
|
|
3843
|
-
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 j = 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(j, 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(j, Z), K = t.mul(W, K), X = t.add(X, Z), Z = t.sub(B, Z), Z = t.mul(j, 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);
|
|
3844
3981
|
}
|
|
3845
3982
|
subtract(x) {
|
|
3846
3983
|
return this.add(x.negate());
|
|
3847
3984
|
}
|
|
3848
3985
|
is0() {
|
|
3849
|
-
return this.equals(
|
|
3986
|
+
return this.equals(S.ZERO);
|
|
3850
3987
|
}
|
|
3851
3988
|
/**
|
|
3852
3989
|
* Constant time multiplication.
|
|
@@ -3861,16 +3998,16 @@ function Yr(r, e = {}) {
|
|
|
3861
3998
|
const { endo: g } = e;
|
|
3862
3999
|
if (!n.isValidNot0(x))
|
|
3863
4000
|
throw new Error("invalid scalar: out of range");
|
|
3864
|
-
let v,
|
|
3865
|
-
const
|
|
4001
|
+
let v, A;
|
|
4002
|
+
const C = (O) => b.cached(this, O, (L) => Ft(S, L));
|
|
3866
4003
|
if (g) {
|
|
3867
|
-
const { k1neg:
|
|
3868
|
-
|
|
4004
|
+
const { k1neg: O, k1: L, k2neg: P, k2: D } = V(x), { p: U, f: j } = C(L), { p: W, f: B } = C(D);
|
|
4005
|
+
A = j.add(B), v = H(g.beta, U, W, O, P);
|
|
3869
4006
|
} else {
|
|
3870
|
-
const { p:
|
|
3871
|
-
v =
|
|
4007
|
+
const { p: O, f: L } = C(x);
|
|
4008
|
+
v = O, A = L;
|
|
3872
4009
|
}
|
|
3873
|
-
return
|
|
4010
|
+
return Ft(S, [v, A])[0];
|
|
3874
4011
|
}
|
|
3875
4012
|
/**
|
|
3876
4013
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -3882,23 +4019,23 @@ function Yr(r, e = {}) {
|
|
|
3882
4019
|
if (!n.isValid(x))
|
|
3883
4020
|
throw new Error("invalid scalar: out of range");
|
|
3884
4021
|
if (x === xe || v.is0())
|
|
3885
|
-
return
|
|
3886
|
-
if (x ===
|
|
4022
|
+
return S.ZERO;
|
|
4023
|
+
if (x === Pe)
|
|
3887
4024
|
return v;
|
|
3888
|
-
if (
|
|
4025
|
+
if (b.hasCache(this))
|
|
3889
4026
|
return this.multiply(x);
|
|
3890
4027
|
if (g) {
|
|
3891
|
-
const { k1neg:
|
|
3892
|
-
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);
|
|
3893
4030
|
} else
|
|
3894
|
-
return
|
|
4031
|
+
return b.unsafe(v, x);
|
|
3895
4032
|
}
|
|
3896
4033
|
/**
|
|
3897
4034
|
* Converts Projective point to affine (x, y) coordinates.
|
|
3898
4035
|
* @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
|
|
3899
4036
|
*/
|
|
3900
4037
|
toAffine(x) {
|
|
3901
|
-
return
|
|
4038
|
+
return G(this, x);
|
|
3902
4039
|
}
|
|
3903
4040
|
/**
|
|
3904
4041
|
* Checks whether Point is free of torsion elements (is in prime subgroup).
|
|
@@ -3906,39 +4043,39 @@ function Yr(r, e = {}) {
|
|
|
3906
4043
|
*/
|
|
3907
4044
|
isTorsionFree() {
|
|
3908
4045
|
const { isTorsionFree: x } = e;
|
|
3909
|
-
return i ===
|
|
4046
|
+
return i === Pe ? !0 : x ? x(S, this) : b.unsafe(this, a).is0();
|
|
3910
4047
|
}
|
|
3911
4048
|
clearCofactor() {
|
|
3912
4049
|
const { clearCofactor: x } = e;
|
|
3913
|
-
return i ===
|
|
4050
|
+
return i === Pe ? this : x ? x(S, this) : this.multiplyUnsafe(i);
|
|
3914
4051
|
}
|
|
3915
4052
|
isSmallOrder() {
|
|
3916
4053
|
return this.multiplyUnsafe(i).is0();
|
|
3917
4054
|
}
|
|
3918
4055
|
toBytes(x = !0) {
|
|
3919
|
-
return
|
|
4056
|
+
return Ke(x, "isCompressed"), this.assertValidity(), f(S, this, x);
|
|
3920
4057
|
}
|
|
3921
4058
|
toHex(x = !0) {
|
|
3922
|
-
return
|
|
4059
|
+
return $e(this.toBytes(x));
|
|
3923
4060
|
}
|
|
3924
4061
|
toString() {
|
|
3925
4062
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
3926
4063
|
}
|
|
3927
4064
|
};
|
|
3928
4065
|
// base / generator point
|
|
3929
|
-
|
|
3930
|
-
|
|
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
|
|
3931
4068
|
// math field
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
let
|
|
3935
|
-
const
|
|
3936
|
-
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;
|
|
3937
4074
|
}
|
|
3938
|
-
function
|
|
4075
|
+
function Ts(r) {
|
|
3939
4076
|
return Uint8Array.of(r ? 2 : 3);
|
|
3940
4077
|
}
|
|
3941
|
-
function
|
|
4078
|
+
function Rs(r, e) {
|
|
3942
4079
|
return {
|
|
3943
4080
|
secretKey: e.BYTES,
|
|
3944
4081
|
publicKey: 1 + r.BYTES,
|
|
@@ -3948,7 +4085,7 @@ function Ts(r, e) {
|
|
|
3948
4085
|
};
|
|
3949
4086
|
}
|
|
3950
4087
|
function Jr(r, e = {}) {
|
|
3951
|
-
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) });
|
|
3952
4089
|
function o(f) {
|
|
3953
4090
|
try {
|
|
3954
4091
|
const w = s.fromBytes(f);
|
|
@@ -3958,99 +4095,99 @@ function Jr(r, e = {}) {
|
|
|
3958
4095
|
}
|
|
3959
4096
|
}
|
|
3960
4097
|
function i(f, w) {
|
|
3961
|
-
const { publicKey:
|
|
4098
|
+
const { publicKey: E, publicKeyUncompressed: y } = n;
|
|
3962
4099
|
try {
|
|
3963
|
-
const
|
|
3964
|
-
return w === !0 &&
|
|
4100
|
+
const R = f.length;
|
|
4101
|
+
return w === !0 && R !== E || w === !1 && R !== y ? !1 : !!r.fromBytes(f);
|
|
3965
4102
|
} catch {
|
|
3966
4103
|
return !1;
|
|
3967
4104
|
}
|
|
3968
4105
|
}
|
|
3969
4106
|
function a(f = t(n.seed)) {
|
|
3970
|
-
return
|
|
4107
|
+
return Gr(q(f, n.seed, "seed"), s.ORDER);
|
|
3971
4108
|
}
|
|
3972
4109
|
function c(f, w = !0) {
|
|
3973
4110
|
return r.BASE.multiply(s.fromBytes(f)).toBytes(w);
|
|
3974
4111
|
}
|
|
3975
4112
|
function l(f) {
|
|
3976
|
-
const { secretKey: w, publicKey:
|
|
3977
|
-
if (!
|
|
4113
|
+
const { secretKey: w, publicKey: E, publicKeyUncompressed: y } = n;
|
|
4114
|
+
if (!pt(f) || "_lengths" in s && s._lengths || w === E)
|
|
3978
4115
|
return;
|
|
3979
|
-
const
|
|
3980
|
-
return
|
|
4116
|
+
const R = q(f, void 0, "key").length;
|
|
4117
|
+
return R === E || R === y;
|
|
3981
4118
|
}
|
|
3982
|
-
function u(f, w,
|
|
4119
|
+
function u(f, w, E = !0) {
|
|
3983
4120
|
if (l(f) === !0)
|
|
3984
4121
|
throw new Error("first arg must be private key");
|
|
3985
4122
|
if (l(w) === !1)
|
|
3986
4123
|
throw new Error("second arg must be public key");
|
|
3987
4124
|
const y = s.fromBytes(f);
|
|
3988
|
-
return r.fromBytes(w).multiply(y).toBytes(
|
|
4125
|
+
return r.fromBytes(w).multiply(y).toBytes(E);
|
|
3989
4126
|
}
|
|
3990
4127
|
const h = {
|
|
3991
4128
|
isValidSecretKey: o,
|
|
3992
4129
|
isValidPublicKey: i,
|
|
3993
4130
|
randomSecretKey: a
|
|
3994
|
-
}, _ =
|
|
4131
|
+
}, _ = Vr(a, c);
|
|
3995
4132
|
return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: _, Point: r, utils: h, lengths: n });
|
|
3996
4133
|
}
|
|
3997
|
-
function
|
|
3998
|
-
|
|
4134
|
+
function Zr(r, e, s = {}) {
|
|
4135
|
+
rs(e), gt(s, {}, {
|
|
3999
4136
|
hmac: "function",
|
|
4000
4137
|
lowS: "boolean",
|
|
4001
4138
|
randomBytes: "function",
|
|
4002
4139
|
bits2int: "function",
|
|
4003
4140
|
bits2int_modN: "function"
|
|
4004
4141
|
}), s = Object.assign({}, s);
|
|
4005
|
-
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 = {
|
|
4006
4143
|
prehash: !0,
|
|
4007
4144
|
lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
|
|
4008
4145
|
format: "compact",
|
|
4009
4146
|
extraEntropy: !1
|
|
4010
|
-
},
|
|
4147
|
+
}, E = a * As < o.ORDER;
|
|
4011
4148
|
function y(x) {
|
|
4012
|
-
const g = a >>
|
|
4149
|
+
const g = a >> Pe;
|
|
4013
4150
|
return x > g;
|
|
4014
4151
|
}
|
|
4015
|
-
function
|
|
4152
|
+
function R(x, g) {
|
|
4016
4153
|
if (!i.isValidNot0(g))
|
|
4017
4154
|
throw new Error(`invalid signature ${x}: out of range 1..Point.Fn.ORDER`);
|
|
4018
4155
|
return g;
|
|
4019
4156
|
}
|
|
4020
4157
|
function N() {
|
|
4021
|
-
if (
|
|
4158
|
+
if (E)
|
|
4022
4159
|
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
4023
4160
|
}
|
|
4024
|
-
function
|
|
4025
|
-
|
|
4026
|
-
const v = f.signature,
|
|
4027
|
-
return
|
|
4028
|
-
}
|
|
4029
|
-
class
|
|
4030
|
-
constructor(g, v,
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
if (this.r =
|
|
4035
|
-
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))
|
|
4036
4173
|
throw new Error("invalid recovery id");
|
|
4037
|
-
this.recovery =
|
|
4174
|
+
this.recovery = A;
|
|
4038
4175
|
}
|
|
4039
4176
|
Object.freeze(this);
|
|
4040
4177
|
}
|
|
4041
4178
|
static fromBytes(g, v = w.format) {
|
|
4042
|
-
|
|
4043
|
-
let
|
|
4179
|
+
F(g, v);
|
|
4180
|
+
let A;
|
|
4044
4181
|
if (v === "der") {
|
|
4045
|
-
const { r:
|
|
4046
|
-
return new
|
|
4182
|
+
const { r: P, s: D } = be.toSig(q(g));
|
|
4183
|
+
return new M(P, D);
|
|
4047
4184
|
}
|
|
4048
|
-
v === "recovered" && (
|
|
4049
|
-
const
|
|
4050
|
-
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);
|
|
4051
4188
|
}
|
|
4052
4189
|
static fromHex(g, v) {
|
|
4053
|
-
return this.fromBytes(
|
|
4190
|
+
return this.fromBytes(qe(g), v);
|
|
4054
4191
|
}
|
|
4055
4192
|
assertRecovery() {
|
|
4056
4193
|
const { recovery: g } = this;
|
|
@@ -4059,96 +4196,96 @@ function Xr(r, e, s = {}) {
|
|
|
4059
4196
|
return g;
|
|
4060
4197
|
}
|
|
4061
4198
|
addRecoveryBit(g) {
|
|
4062
|
-
return new
|
|
4199
|
+
return new M(this.r, this.s, g);
|
|
4063
4200
|
}
|
|
4064
4201
|
recoverPublicKey(g) {
|
|
4065
|
-
const { r: v, s:
|
|
4066
|
-
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))
|
|
4067
4204
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
4068
|
-
const
|
|
4069
|
-
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")), j = i.create(-U * D), W = i.create(A * D), B = r.BASE.multiplyUnsafe(j).add(P.multiplyUnsafe(W));
|
|
4206
|
+
if (B.is0())
|
|
4070
4207
|
throw new Error("invalid recovery: point at infinify");
|
|
4071
|
-
return
|
|
4208
|
+
return B.assertValidity(), B;
|
|
4072
4209
|
}
|
|
4073
4210
|
// Signatures should be low-s, to prevent malleability.
|
|
4074
4211
|
hasHighS() {
|
|
4075
4212
|
return y(this.s);
|
|
4076
4213
|
}
|
|
4077
4214
|
toBytes(g = w.format) {
|
|
4078
|
-
if (
|
|
4079
|
-
return
|
|
4080
|
-
const { r: v, s:
|
|
4081
|
-
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);
|
|
4082
4219
|
}
|
|
4083
4220
|
toHex(g) {
|
|
4084
|
-
return
|
|
4221
|
+
return $e(this.toBytes(g));
|
|
4085
4222
|
}
|
|
4086
4223
|
}
|
|
4087
|
-
const
|
|
4224
|
+
const V = s.bits2int || function(g) {
|
|
4088
4225
|
if (g.length > 8192)
|
|
4089
4226
|
throw new Error("input is too large");
|
|
4090
|
-
const v =
|
|
4091
|
-
return
|
|
4092
|
-
},
|
|
4093
|
-
return i.create(
|
|
4094
|
-
},
|
|
4095
|
-
function
|
|
4096
|
-
return
|
|
4097
|
-
}
|
|
4098
|
-
function
|
|
4099
|
-
return
|
|
4100
|
-
}
|
|
4101
|
-
function
|
|
4102
|
-
const { lowS:
|
|
4103
|
-
x =
|
|
4104
|
-
const
|
|
4105
|
-
if (!i.isValidNot0(
|
|
4227
|
+
const v = Ye(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))
|
|
4106
4243
|
throw new Error("invalid private key");
|
|
4107
|
-
const
|
|
4108
|
-
if (
|
|
4109
|
-
const
|
|
4110
|
-
|
|
4111
|
-
}
|
|
4112
|
-
const
|
|
4113
|
-
function
|
|
4114
|
-
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), j = L;
|
|
4250
|
+
function W(B) {
|
|
4251
|
+
const X = V(B);
|
|
4115
4252
|
if (!i.isValidNot0(X))
|
|
4116
4253
|
return;
|
|
4117
|
-
const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(),
|
|
4118
|
-
if (
|
|
4254
|
+
const Z = i.inv(X), oe = r.BASE.multiply(X).toAffine(), K = i.create(oe.x);
|
|
4255
|
+
if (K === xe)
|
|
4119
4256
|
return;
|
|
4120
|
-
const Q = i.create(Z * i.create(
|
|
4257
|
+
const Q = i.create(Z * i.create(j + K * P));
|
|
4121
4258
|
if (Q === xe)
|
|
4122
4259
|
return;
|
|
4123
|
-
let
|
|
4124
|
-
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);
|
|
4125
4262
|
}
|
|
4126
|
-
return { seed:
|
|
4263
|
+
return { seed: U, k2sig: W };
|
|
4127
4264
|
}
|
|
4128
|
-
function
|
|
4129
|
-
const { seed:
|
|
4130
|
-
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);
|
|
4131
4268
|
}
|
|
4132
|
-
function
|
|
4133
|
-
const { lowS:
|
|
4134
|
-
if (v =
|
|
4135
|
-
const
|
|
4136
|
-
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);
|
|
4137
4274
|
}
|
|
4138
|
-
|
|
4275
|
+
F(x, L);
|
|
4139
4276
|
try {
|
|
4140
|
-
const
|
|
4141
|
-
if (
|
|
4277
|
+
const P = M.fromBytes(x, L), D = r.fromBytes(v);
|
|
4278
|
+
if (C && P.hasHighS())
|
|
4142
4279
|
return !1;
|
|
4143
|
-
const { r:
|
|
4144
|
-
return oe.is0() ? !1 : i.create(oe.x) ===
|
|
4280
|
+
const { r: U, s: j } = P, W = G(g), B = i.inv(j), 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;
|
|
4145
4282
|
} catch {
|
|
4146
4283
|
return !1;
|
|
4147
4284
|
}
|
|
4148
4285
|
}
|
|
4149
4286
|
function I(x, g, v = {}) {
|
|
4150
|
-
const { prehash:
|
|
4151
|
-
return g =
|
|
4287
|
+
const { prehash: A } = rt(v, w);
|
|
4288
|
+
return g = z(g, A), M.fromBytes(x, "recovered").recoverPublicKey(g).toBytes();
|
|
4152
4289
|
}
|
|
4153
4290
|
return Object.freeze({
|
|
4154
4291
|
keygen: l,
|
|
@@ -4157,15 +4294,15 @@ function Xr(r, e, s = {}) {
|
|
|
4157
4294
|
utils: _,
|
|
4158
4295
|
lengths: f,
|
|
4159
4296
|
Point: r,
|
|
4160
|
-
sign:
|
|
4161
|
-
verify:
|
|
4297
|
+
sign: b,
|
|
4298
|
+
verify: S,
|
|
4162
4299
|
recoverPublicKey: I,
|
|
4163
|
-
Signature:
|
|
4300
|
+
Signature: M,
|
|
4164
4301
|
hash: e
|
|
4165
4302
|
});
|
|
4166
4303
|
}
|
|
4167
4304
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
4168
|
-
const
|
|
4305
|
+
const wt = {
|
|
4169
4306
|
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
|
|
4170
4307
|
n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
|
|
4171
4308
|
h: BigInt(1),
|
|
@@ -4173,44 +4310,44 @@ const mt = {
|
|
|
4173
4310
|
b: BigInt(7),
|
|
4174
4311
|
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
4175
4312
|
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
|
4176
|
-
},
|
|
4313
|
+
}, Qr = {
|
|
4177
4314
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
4178
4315
|
basises: [
|
|
4179
4316
|
[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
|
|
4180
4317
|
[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
|
|
4181
4318
|
]
|
|
4182
|
-
},
|
|
4183
|
-
function
|
|
4184
|
-
const e =
|
|
4185
|
-
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))
|
|
4186
4323
|
throw new Error("Cannot find square root");
|
|
4187
|
-
return
|
|
4188
|
-
}
|
|
4189
|
-
const
|
|
4190
|
-
Fp:
|
|
4191
|
-
endo:
|
|
4192
|
-
}),
|
|
4193
|
-
for (let r = 0, e =
|
|
4194
|
-
[s, t] = [t, (2 * s + 3 * t) % 5],
|
|
4195
|
-
let n =
|
|
4324
|
+
return G;
|
|
4325
|
+
}
|
|
4326
|
+
const ut = je(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;
|
|
4196
4333
|
for (let o = 0; o < 7; o++)
|
|
4197
|
-
e = (e <<
|
|
4198
|
-
|
|
4334
|
+
e = (e << Le ^ (e >> on) * cn) % an, e & nn && (n ^= Le << (Le << BigInt(o)) - Le);
|
|
4335
|
+
Os.push(n);
|
|
4199
4336
|
}
|
|
4200
|
-
const
|
|
4201
|
-
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), Yt = (r, e, s) => s > 32 ? Sr(r, e, s) : yr(r, e, s);
|
|
4338
|
+
function un(r, e = 24) {
|
|
4202
4339
|
const s = new Uint32Array(10);
|
|
4203
4340
|
for (let t = 24 - e; t < 24; t++) {
|
|
4204
4341
|
for (let i = 0; i < 10; i++)
|
|
4205
4342
|
s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
|
|
4206
4343
|
for (let i = 0; i < 10; i += 2) {
|
|
4207
|
-
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], _ = Yt(l, u, 1) ^ s[a + 1];
|
|
4208
4345
|
for (let f = 0; f < 50; f += 10)
|
|
4209
4346
|
r[i + f] ^= h, r[i + f + 1] ^= _;
|
|
4210
4347
|
}
|
|
4211
4348
|
let n = r[2], o = r[3];
|
|
4212
4349
|
for (let i = 0; i < 24; i++) {
|
|
4213
|
-
const a =
|
|
4350
|
+
const a = Ps[i], c = zt(n, o, a), l = Yt(n, o, a), u = ks[i];
|
|
4214
4351
|
n = r[u], o = r[u + 1], r[u] = c, r[u + 1] = l;
|
|
4215
4352
|
}
|
|
4216
4353
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -4219,36 +4356,36 @@ function dn(r, e = 24) {
|
|
|
4219
4356
|
for (let a = 0; a < 10; a++)
|
|
4220
4357
|
r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
|
|
4221
4358
|
}
|
|
4222
|
-
r[0] ^=
|
|
4359
|
+
r[0] ^= ln[t], r[1] ^= dn[t];
|
|
4223
4360
|
}
|
|
4224
|
-
|
|
4361
|
+
Ce(s);
|
|
4225
4362
|
}
|
|
4226
|
-
class
|
|
4363
|
+
class yt {
|
|
4227
4364
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
4228
4365
|
constructor(e, s, t, n = !1, o = 24) {
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
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");
|
|
4240
4377
|
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, me(t, "outputLen"), !(0 < e && e < 200))
|
|
4241
4378
|
throw new Error("only keccak-f1600 function is supported");
|
|
4242
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
4379
|
+
this.state = new Uint8Array(200), this.state32 = cr(this.state);
|
|
4243
4380
|
}
|
|
4244
4381
|
clone() {
|
|
4245
4382
|
return this._cloneInto();
|
|
4246
4383
|
}
|
|
4247
4384
|
keccak() {
|
|
4248
|
-
|
|
4385
|
+
Dt(this.state32), un(this.state32, this.rounds), Dt(this.state32), this.posOut = 0, this.pos = 0;
|
|
4249
4386
|
}
|
|
4250
4387
|
update(e) {
|
|
4251
|
-
|
|
4388
|
+
Oe(this), q(e);
|
|
4252
4389
|
const { blockLen: s, state: t } = this, n = e.length;
|
|
4253
4390
|
for (let o = 0; o < n; ) {
|
|
4254
4391
|
const i = Math.min(s - this.pos, n - o);
|
|
@@ -4266,7 +4403,7 @@ class wt {
|
|
|
4266
4403
|
e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
|
|
4267
4404
|
}
|
|
4268
4405
|
writeInto(e) {
|
|
4269
|
-
|
|
4406
|
+
Oe(this, !1), q(e), this.finish();
|
|
4270
4407
|
const s = this.state, { blockLen: t } = this;
|
|
4271
4408
|
for (let n = 0, o = e.length; n < o; ) {
|
|
4272
4409
|
this.posOut >= t && this.keccak();
|
|
@@ -4284,7 +4421,7 @@ class wt {
|
|
|
4284
4421
|
return me(e), this.xofInto(new Uint8Array(e));
|
|
4285
4422
|
}
|
|
4286
4423
|
digestInto(e) {
|
|
4287
|
-
if (
|
|
4424
|
+
if (ns(e, this), this.finished)
|
|
4288
4425
|
throw new Error("digest() was already called");
|
|
4289
4426
|
return this.writeInto(e), this.destroy(), e;
|
|
4290
4427
|
}
|
|
@@ -4292,21 +4429,21 @@ class wt {
|
|
|
4292
4429
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
4293
4430
|
}
|
|
4294
4431
|
destroy() {
|
|
4295
|
-
this.destroyed = !0,
|
|
4432
|
+
this.destroyed = !0, Ce(this.state);
|
|
4296
4433
|
}
|
|
4297
4434
|
_cloneInto(e) {
|
|
4298
4435
|
const { blockLen: s, suffix: t, outputLen: n, rounds: o, enableXOF: i } = this;
|
|
4299
|
-
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;
|
|
4300
4437
|
}
|
|
4301
4438
|
}
|
|
4302
|
-
const
|
|
4303
|
-
class
|
|
4439
|
+
const hn = (r, e, s, t = {}) => is(() => new yt(e, r, s), t), jt = /* @__PURE__ */ hn(1, 136, 32), pn = 60;
|
|
4440
|
+
class fn {
|
|
4304
4441
|
constructor() {
|
|
4305
4442
|
this.jwks = null;
|
|
4306
4443
|
}
|
|
4307
4444
|
setJWKSEndpoint(e) {
|
|
4308
4445
|
try {
|
|
4309
|
-
this.jwks =
|
|
4446
|
+
this.jwks = Bs(new URL(e)), d.log("[CROSSx] JWKS 엔드포인트 설정:", e);
|
|
4310
4447
|
} catch (s) {
|
|
4311
4448
|
d.warn("[CROSSx] JWKS 엔드포인트 URL 파싱 실패:", s);
|
|
4312
4449
|
}
|
|
@@ -4320,7 +4457,7 @@ class pn {
|
|
|
4320
4457
|
iat: t.iat
|
|
4321
4458
|
});
|
|
4322
4459
|
const n = Math.floor(Date.now() / 1e3);
|
|
4323
|
-
if (t.exp && t.exp +
|
|
4460
|
+
if (t.exp && t.exp + pn < n)
|
|
4324
4461
|
return d.warn("[CROSSx] 토큰 만료:", {
|
|
4325
4462
|
exp: t.exp,
|
|
4326
4463
|
now: n,
|
|
@@ -4330,7 +4467,7 @@ class pn {
|
|
|
4330
4467
|
return d.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 };
|
|
4331
4468
|
if (this.jwks)
|
|
4332
4469
|
try {
|
|
4333
|
-
const { payload: o } = await
|
|
4470
|
+
const { payload: o } = await Us(e, this.jwks, {
|
|
4334
4471
|
algorithms: ["RS256", "ES256"]
|
|
4335
4472
|
});
|
|
4336
4473
|
return d.log("[CROSSx] JWT 서명 검증 성공"), {
|
|
@@ -4349,7 +4486,7 @@ class pn {
|
|
|
4349
4486
|
}
|
|
4350
4487
|
}
|
|
4351
4488
|
decodeJWT(e) {
|
|
4352
|
-
return
|
|
4489
|
+
return Hs(e);
|
|
4353
4490
|
}
|
|
4354
4491
|
/**
|
|
4355
4492
|
* EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
|
|
@@ -4364,29 +4501,29 @@ class pn {
|
|
|
4364
4501
|
${t.length}`
|
|
4365
4502
|
), o = new Uint8Array(n.length + t.length);
|
|
4366
4503
|
o.set(n, 0), o.set(t, n.length);
|
|
4367
|
-
const i =
|
|
4504
|
+
const i = jt(o), a = s.startsWith("0x") ? s.slice(2) : s;
|
|
4368
4505
|
if (a.length !== 130)
|
|
4369
4506
|
throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
|
|
4370
|
-
const c =
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
).addRecoveryBit(_).recoverPublicKey(i).toBytes(!1).slice(1), y =
|
|
4374
|
-
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 = jt(E);
|
|
4511
|
+
return "0x" + $e(y.slice(12));
|
|
4375
4512
|
}
|
|
4376
4513
|
}
|
|
4377
|
-
function
|
|
4514
|
+
function _n(r) {
|
|
4378
4515
|
const e = new Uint8Array(r.length / 2);
|
|
4379
4516
|
for (let s = 0; s < e.length; s++)
|
|
4380
4517
|
e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
|
|
4381
4518
|
return e;
|
|
4382
4519
|
}
|
|
4383
|
-
function
|
|
4520
|
+
function Xt(r) {
|
|
4384
4521
|
let e = "0x";
|
|
4385
4522
|
for (const s of r) e += s.toString(16).padStart(2, "0");
|
|
4386
4523
|
return BigInt(e);
|
|
4387
4524
|
}
|
|
4388
|
-
const
|
|
4389
|
-
class
|
|
4525
|
+
const xn = 3e4, gn = 1e3;
|
|
4526
|
+
class mn {
|
|
4390
4527
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4391
4528
|
async request(e) {
|
|
4392
4529
|
const s = e.retries ?? 0;
|
|
@@ -4397,7 +4534,7 @@ class gn {
|
|
|
4397
4534
|
} catch (n) {
|
|
4398
4535
|
if (t === s) throw n;
|
|
4399
4536
|
}
|
|
4400
|
-
await new Promise((n) => setTimeout(n,
|
|
4537
|
+
await new Promise((n) => setTimeout(n, gn * 2 ** t));
|
|
4401
4538
|
}
|
|
4402
4539
|
throw new Error("Unexpected: retry loop exited without result");
|
|
4403
4540
|
}
|
|
@@ -4405,7 +4542,7 @@ class gn {
|
|
|
4405
4542
|
async _doRequest(e) {
|
|
4406
4543
|
const s = new AbortController(), t = setTimeout(
|
|
4407
4544
|
() => s.abort(),
|
|
4408
|
-
e.timeoutMs ??
|
|
4545
|
+
e.timeoutMs ?? xn
|
|
4409
4546
|
);
|
|
4410
4547
|
try {
|
|
4411
4548
|
const n = await fetch(e.url, {
|
|
@@ -4432,12 +4569,12 @@ class gn {
|
|
|
4432
4569
|
}
|
|
4433
4570
|
}
|
|
4434
4571
|
}
|
|
4435
|
-
const
|
|
4572
|
+
const wn = /* @__PURE__ */ new Set([
|
|
4436
4573
|
"https://cross-wallet-oauth.crosstoken.io",
|
|
4437
4574
|
"https://stg-cross-wallet-oauth.crosstoken.io",
|
|
4438
4575
|
"https://dev-cross-wallet-oauth.crosstoken.io"
|
|
4439
4576
|
]);
|
|
4440
|
-
class
|
|
4577
|
+
class Ie {
|
|
4441
4578
|
static generateRandom16Hex() {
|
|
4442
4579
|
const e = new Uint8Array(16);
|
|
4443
4580
|
return crypto.getRandomValues(e), Array.from(e, (s) => s.toString(16).padStart(2, "0")).join("");
|
|
@@ -4461,7 +4598,7 @@ class Ee {
|
|
|
4461
4598
|
* - Google 및 기타: originalNonce === jwt.nonce
|
|
4462
4599
|
*/
|
|
4463
4600
|
static async verifyIdTokenNonce(e, s) {
|
|
4464
|
-
const t =
|
|
4601
|
+
const t = Ie.parseJwtPayload(e), n = t.nonce, o = typeof t.iss == "string" ? t.iss : "(unknown)";
|
|
4465
4602
|
if (d.log("[CROSSx] nonce 검증 시작 —", {
|
|
4466
4603
|
iss: o,
|
|
4467
4604
|
nonceClaimType: typeof n,
|
|
@@ -4483,7 +4620,7 @@ class Ee {
|
|
|
4483
4620
|
return;
|
|
4484
4621
|
}
|
|
4485
4622
|
if (o.includes("appleid.apple.com")) {
|
|
4486
|
-
const i = await
|
|
4623
|
+
const i = await Ie.sha256Hex(s);
|
|
4487
4624
|
if (d.log("[CROSSx] Apple nonce 검증 —", {
|
|
4488
4625
|
expectedHashLength: i.length,
|
|
4489
4626
|
receivedHashLength: n.length,
|
|
@@ -4500,7 +4637,7 @@ class Ee {
|
|
|
4500
4637
|
}
|
|
4501
4638
|
openAuth(e) {
|
|
4502
4639
|
return new Promise((s, t) => {
|
|
4503
|
-
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}`;
|
|
4504
4641
|
d.log("[CROSSx] OAuth 팝업 열기 — state, nonce 생성 완료:", {
|
|
4505
4642
|
stateLength: c.length,
|
|
4506
4643
|
nonceLength: l.length,
|
|
@@ -4516,73 +4653,73 @@ class Ee {
|
|
|
4516
4653
|
return;
|
|
4517
4654
|
}
|
|
4518
4655
|
const f = setTimeout(() => {
|
|
4519
|
-
d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"),
|
|
4520
|
-
}, 5 * 60 * 1e3), w = 10,
|
|
4521
|
-
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;
|
|
4522
4659
|
const N = () => {
|
|
4523
|
-
clearInterval(
|
|
4524
|
-
|
|
4660
|
+
clearInterval(F), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + E + "초간 대기합니다"), R = setTimeout(() => {
|
|
4661
|
+
M(), t(new Error(
|
|
4525
4662
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
4526
4663
|
));
|
|
4527
|
-
},
|
|
4528
|
-
},
|
|
4664
|
+
}, E * 1e3);
|
|
4665
|
+
}, F = setInterval(() => {
|
|
4529
4666
|
y++;
|
|
4530
4667
|
try {
|
|
4531
|
-
_.closed && (y <= w ? N() : (
|
|
4668
|
+
_.closed && (y <= w ? N() : (M(), t(new Error("로그인이 취소되었습니다"))));
|
|
4532
4669
|
} catch {
|
|
4533
4670
|
N();
|
|
4534
4671
|
}
|
|
4535
|
-
}, 1e3),
|
|
4536
|
-
clearTimeout(f), clearInterval(
|
|
4537
|
-
},
|
|
4538
|
-
if (
|
|
4539
|
-
if (!
|
|
4540
|
-
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"));
|
|
4541
4678
|
return;
|
|
4542
4679
|
}
|
|
4543
|
-
|
|
4544
|
-
const
|
|
4680
|
+
M();
|
|
4681
|
+
const J = typeof G.data.status == "string", H = J ? G.data.data ?? {} : G.data;
|
|
4545
4682
|
d.log("[CROSSx] OAuth postMessage 수신 —", {
|
|
4546
|
-
format:
|
|
4547
|
-
status:
|
|
4683
|
+
format: J ? "wrapped" : "flat",
|
|
4684
|
+
status: J ? G.data.status : "(flat)"
|
|
4548
4685
|
});
|
|
4549
|
-
const
|
|
4550
|
-
if (!
|
|
4686
|
+
const z = (H == null ? void 0 : H.state) ?? G.data.state;
|
|
4687
|
+
if (!z || z !== c) {
|
|
4551
4688
|
t(new Error("OAuth state mismatch — possible CSRF attack"));
|
|
4552
4689
|
return;
|
|
4553
4690
|
}
|
|
4554
|
-
if (
|
|
4555
|
-
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"));
|
|
4556
4693
|
return;
|
|
4557
4694
|
}
|
|
4558
|
-
if (!
|
|
4559
|
-
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"));
|
|
4560
4697
|
return;
|
|
4561
4698
|
}
|
|
4562
|
-
const
|
|
4699
|
+
const k = H == null ? void 0 : H.idToken, b = H == null ? void 0 : H.accessToken, S = b ?? k;
|
|
4563
4700
|
if (d.log("[CROSSx] OAuth 토큰 수신:", {
|
|
4564
|
-
hasAccessToken: !!
|
|
4565
|
-
hasIdToken: !!
|
|
4566
|
-
}), !
|
|
4567
|
-
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"));
|
|
4568
4705
|
return;
|
|
4569
4706
|
}
|
|
4570
4707
|
const I = (x) => {
|
|
4571
|
-
|
|
4708
|
+
Ie.verifyIdTokenNonce(x, l).then(() => s(S)).catch((g) => {
|
|
4572
4709
|
d.error("[CROSSx] nonce 검증 실패:", g), t(g instanceof Error ? g : new Error("nonce verification failed"));
|
|
4573
4710
|
});
|
|
4574
4711
|
};
|
|
4575
|
-
|
|
4712
|
+
b ? b.split(".").length === 3 ? I(b) : k ? I(k) : (d.warn(
|
|
4576
4713
|
"[CROSSx] opaque accessToken만 수신 (idToken 없음) — nonce 검증 불가.",
|
|
4577
4714
|
"서버 측 nonce 검증이 필요합니다."
|
|
4578
|
-
), s(
|
|
4715
|
+
), s(S)) : k ? I(k) : t(new Error("Token not found in response"));
|
|
4579
4716
|
};
|
|
4580
|
-
window.addEventListener("message",
|
|
4717
|
+
window.addEventListener("message", V);
|
|
4581
4718
|
});
|
|
4582
4719
|
}
|
|
4583
4720
|
}
|
|
4584
|
-
const
|
|
4585
|
-
class
|
|
4721
|
+
const De = "crossx_wallet_data", Re = "crossx_mock_pin_hash";
|
|
4722
|
+
class yn {
|
|
4586
4723
|
constructor(e, s) {
|
|
4587
4724
|
this.storage = e, this.pinStore = s ?? null;
|
|
4588
4725
|
}
|
|
@@ -4595,13 +4732,13 @@ class wn {
|
|
|
4595
4732
|
async checkWallet() {
|
|
4596
4733
|
if (this.migrateScenario !== void 0)
|
|
4597
4734
|
return d.log("[Mock] checkWallet → migration_required"), "migration_required";
|
|
4598
|
-
const s = await this.storage.get(
|
|
4735
|
+
const s = await this.storage.get(De) ? "exists" : "not_found";
|
|
4599
4736
|
return d.log(`[Mock] checkWallet → ${s}`), s;
|
|
4600
4737
|
}
|
|
4601
4738
|
async getOrCreateWallet(e) {
|
|
4602
4739
|
var s;
|
|
4603
4740
|
try {
|
|
4604
|
-
const t = await this.storage.get(
|
|
4741
|
+
const t = await this.storage.get(De);
|
|
4605
4742
|
if (t) return t;
|
|
4606
4743
|
const n = {
|
|
4607
4744
|
id: e,
|
|
@@ -4609,16 +4746,16 @@ class wn {
|
|
|
4609
4746
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
4610
4747
|
createdAt: Date.now()
|
|
4611
4748
|
};
|
|
4612
|
-
await this.storage.set(
|
|
4749
|
+
await this.storage.set(De, n);
|
|
4613
4750
|
const o = (s = this.pinStore) == null ? void 0 : s.get();
|
|
4614
|
-
return o && (await this.storage.set(
|
|
4751
|
+
return o && (await this.storage.set(Re, o), d.log("[Mock] 지갑 생성 — PIN 저장됨")), n;
|
|
4615
4752
|
} catch (t) {
|
|
4616
4753
|
throw new m(p.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", t);
|
|
4617
4754
|
}
|
|
4618
4755
|
}
|
|
4619
4756
|
/** GET /mnemonic/addresses 모킹 — PIN 불필요, 캐시된 주소 반환 */
|
|
4620
4757
|
async getAddresses(e) {
|
|
4621
|
-
const s = await this.storage.get(
|
|
4758
|
+
const s = await this.storage.get(De);
|
|
4622
4759
|
return s ? [{ address: s.address, index: 0 }] : [];
|
|
4623
4760
|
}
|
|
4624
4761
|
async getAddress(e, s) {
|
|
@@ -4653,8 +4790,8 @@ class wn {
|
|
|
4653
4790
|
var t;
|
|
4654
4791
|
if (d.log("[Mock] verifyPin"), this.pinScenario === "wrong")
|
|
4655
4792
|
return !1;
|
|
4656
|
-
const s = await this.storage.get(
|
|
4657
|
-
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);
|
|
4658
4795
|
}
|
|
4659
4796
|
/**
|
|
4660
4797
|
* POST /mnemonic/change-password 모킹
|
|
@@ -4664,10 +4801,10 @@ class wn {
|
|
|
4664
4801
|
var o;
|
|
4665
4802
|
if (d.log("[Mock] changePin"), this.pinScenario === "wrong")
|
|
4666
4803
|
throw new m(p.PIN_WRONG, "Incorrect PIN.");
|
|
4667
|
-
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);
|
|
4668
4805
|
if (n && t && n !== t)
|
|
4669
4806
|
throw new m(p.PIN_WRONG, "Incorrect PIN.");
|
|
4670
|
-
await this.storage.set(
|
|
4807
|
+
await this.storage.set(Re, s), d.log("[Mock] changePin 완료");
|
|
4671
4808
|
}
|
|
4672
4809
|
async migrateWallet(e, s) {
|
|
4673
4810
|
var o;
|
|
@@ -4698,9 +4835,9 @@ class wn {
|
|
|
4698
4835
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
4699
4836
|
createdAt: Date.now()
|
|
4700
4837
|
};
|
|
4701
|
-
await this.storage.set(
|
|
4838
|
+
await this.storage.set(De, t);
|
|
4702
4839
|
const n = (o = this.pinStore) == null ? void 0 : o.get();
|
|
4703
|
-
return n && (await this.storage.set(
|
|
4840
|
+
return n && (await this.storage.set(Re, n), d.log("[Mock] 마이그레이션 — PIN 저장됨")), t;
|
|
4704
4841
|
}
|
|
4705
4842
|
/**
|
|
4706
4843
|
* POST /mnemonic/share-c 모킹
|
|
@@ -4727,7 +4864,7 @@ class wn {
|
|
|
4727
4864
|
).join("");
|
|
4728
4865
|
}
|
|
4729
4866
|
}
|
|
4730
|
-
class
|
|
4867
|
+
class ke {
|
|
4731
4868
|
constructor(e, s, t, n, o) {
|
|
4732
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;
|
|
4733
4870
|
}
|
|
@@ -4749,22 +4886,30 @@ class Le {
|
|
|
4749
4886
|
*
|
|
4750
4887
|
* 1. 토큰이 있고 만료 임박하지 않으면 즉시 반환
|
|
4751
4888
|
* 2. 만료 임박/만료 시 → 자동 갱신 시도 (동시 호출 deduplicate)
|
|
4752
|
-
* 3.
|
|
4753
|
-
* 4.
|
|
4889
|
+
* 3. 만료 임박·만료 상태에서 갱신에 실패하면 SESSION_EXPIRED (stale access로 호출하지 않음)
|
|
4890
|
+
* 4. refresher 미등록 등으로 갱신을 시도하지 않은 경우에만 기존 토큰 사용
|
|
4754
4891
|
*/
|
|
4755
4892
|
async ensureValidToken() {
|
|
4756
4893
|
const e = this.tokenStore.get();
|
|
4757
|
-
if (e && !this.tokenStore.isExpiringSoon(
|
|
4894
|
+
if (e && !this.tokenStore.isExpiringSoon(Nt))
|
|
4758
4895
|
return e;
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
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
|
+
);
|
|
4762
4907
|
}
|
|
4763
4908
|
if (e)
|
|
4764
4909
|
return d.warn("[CROSSx] 토큰 갱신 실패 — 기존 토큰으로 요청 시도"), e;
|
|
4765
4910
|
throw new m(
|
|
4766
|
-
p.
|
|
4767
|
-
"인증
|
|
4911
|
+
p.SESSION_EXPIRED,
|
|
4912
|
+
"인증 세션이 만료되었습니다. 다시 로그인해 주세요."
|
|
4768
4913
|
);
|
|
4769
4914
|
}
|
|
4770
4915
|
/** 동시 갱신 요청을 단일 Promise로 합칩니다. */
|
|
@@ -4796,11 +4941,14 @@ class Le {
|
|
|
4796
4941
|
url: i,
|
|
4797
4942
|
method: e
|
|
4798
4943
|
});
|
|
4799
|
-
const w =
|
|
4800
|
-
if (w === p.AUTH_NOT_AUTHENTICATED && !n && this._onTokenRefresh
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
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);
|
|
4804
4952
|
}
|
|
4805
4953
|
return d.log("[CROSSx] Wallet Gateway API 성공:", { code: _.code, url: i, method: e }), _.data ?? _;
|
|
4806
4954
|
}
|
|
@@ -4808,19 +4956,25 @@ class Le {
|
|
|
4808
4956
|
} catch (h) {
|
|
4809
4957
|
if (h instanceof m) throw h;
|
|
4810
4958
|
const _ = ((c = h.response) == null ? void 0 : c.status) ?? h.status;
|
|
4811
|
-
if ((_ === 401 || _ === 403) && !n && this._onTokenRefresh
|
|
4812
|
-
|
|
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
|
+
}
|
|
4813
4967
|
if ((l = h.response) != null && l.data) {
|
|
4814
|
-
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";
|
|
4815
4969
|
throw d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
|
|
4816
|
-
code:
|
|
4970
|
+
code: E,
|
|
4817
4971
|
message: w,
|
|
4818
4972
|
url: i,
|
|
4819
4973
|
method: e,
|
|
4820
4974
|
status: (u = h.response) == null ? void 0 : u.status
|
|
4821
4975
|
}), new m(
|
|
4822
4976
|
p.UNKNOWN_ERROR,
|
|
4823
|
-
`Wallet Gateway 오류 (${
|
|
4977
|
+
`Wallet Gateway 오류 (${E}): ${w}`
|
|
4824
4978
|
);
|
|
4825
4979
|
}
|
|
4826
4980
|
throw h;
|
|
@@ -5019,14 +5173,29 @@ class Le {
|
|
|
5019
5173
|
return e;
|
|
5020
5174
|
}
|
|
5021
5175
|
/**
|
|
5022
|
-
* -10031 응답의 data 필드에서
|
|
5176
|
+
* -10028/-10031 응답의 data 필드에서 잠금 상세 정보를 추출합니다.
|
|
5023
5177
|
* 서버는 lockStatus.lockExpiresAt을 초(Unix seconds) 또는 ms로 반환할 수 있습니다.
|
|
5024
5178
|
* 일반적으로 seconds 단위이므로 > 1e10 이면 ms로 간주합니다.
|
|
5179
|
+
*
|
|
5180
|
+
* iOS의 PinLockInfo와 동일한 필드: permanent, lockExpiresAt, maxAttempts, remainingAttempts
|
|
5025
5181
|
*/
|
|
5026
5182
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5027
5183
|
static extractLockDetails(e) {
|
|
5028
|
-
const s = (e == null ? void 0 : e.lockStatus) ?? e, t = (s == null ? void 0 : s.lockExpiresAt) ?? (s == null ? void 0 : s.lock_expires_at);
|
|
5029
|
-
|
|
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";
|
|
5030
5199
|
}
|
|
5031
5200
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5032
5201
|
static mapGatewayError(e, s) {
|
|
@@ -5066,7 +5235,7 @@ class Le {
|
|
|
5066
5235
|
case -10025:
|
|
5067
5236
|
return p.INVALID_APP_TYPE;
|
|
5068
5237
|
case -10028:
|
|
5069
|
-
return p.PIN_WRONG;
|
|
5238
|
+
return ke.hasLockInfo(s) ? p.PIN_LOCKED : p.PIN_WRONG;
|
|
5070
5239
|
case -10029:
|
|
5071
5240
|
return p.PIN_INVALID;
|
|
5072
5241
|
case -10031:
|
|
@@ -5143,7 +5312,7 @@ class Le {
|
|
|
5143
5312
|
}
|
|
5144
5313
|
}
|
|
5145
5314
|
}
|
|
5146
|
-
class
|
|
5315
|
+
class Me {
|
|
5147
5316
|
constructor(e, s) {
|
|
5148
5317
|
this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this.adapterConfig = e, this.projectId = e.projectId, this.transport = s;
|
|
5149
5318
|
}
|
|
@@ -5161,7 +5330,7 @@ class De {
|
|
|
5161
5330
|
const s = e.data.chains;
|
|
5162
5331
|
return this.populateCache(s, !1), s;
|
|
5163
5332
|
} catch {
|
|
5164
|
-
const e =
|
|
5333
|
+
const e = Me.fallbackChains();
|
|
5165
5334
|
return this.populateCache(e, !0), e;
|
|
5166
5335
|
}
|
|
5167
5336
|
}
|
|
@@ -5175,7 +5344,7 @@ class De {
|
|
|
5175
5344
|
}
|
|
5176
5345
|
isCacheValid() {
|
|
5177
5346
|
if (this.loadedAt === 0) return !1;
|
|
5178
|
-
const e = this.usingFallback ?
|
|
5347
|
+
const e = this.usingFallback ? nr : rr;
|
|
5179
5348
|
return e === 0 ? !0 : Date.now() - this.loadedAt < e;
|
|
5180
5349
|
}
|
|
5181
5350
|
populateCache(e, s) {
|
|
@@ -5197,13 +5366,13 @@ class De {
|
|
|
5197
5366
|
if (e.code < 0) {
|
|
5198
5367
|
const s = typeof e.data == "string" ? e.data : e.message ?? "체인 레지스트리 요청에 실패했습니다";
|
|
5199
5368
|
throw new m(
|
|
5200
|
-
|
|
5369
|
+
Me.mapErrorCode(e.code),
|
|
5201
5370
|
s
|
|
5202
5371
|
);
|
|
5203
5372
|
}
|
|
5204
5373
|
}
|
|
5205
5374
|
fallbackOrThrow(e) {
|
|
5206
|
-
const s =
|
|
5375
|
+
const s = Me.fallbackChains().find(
|
|
5207
5376
|
(t) => t.chainId === e
|
|
5208
5377
|
);
|
|
5209
5378
|
if (s) return s;
|
|
@@ -5213,7 +5382,7 @@ class De {
|
|
|
5213
5382
|
);
|
|
5214
5383
|
}
|
|
5215
5384
|
static fallbackChains() {
|
|
5216
|
-
return Object.values(
|
|
5385
|
+
return Object.values(ze).map((e) => ({
|
|
5217
5386
|
chainId: e.caipId,
|
|
5218
5387
|
rpcUrl: e.rpcUrl
|
|
5219
5388
|
}));
|
|
@@ -5237,7 +5406,7 @@ class De {
|
|
|
5237
5406
|
}
|
|
5238
5407
|
}
|
|
5239
5408
|
}
|
|
5240
|
-
const
|
|
5409
|
+
const Jt = "__crossx-confirm-style", se = "__crossx-confirm-overlay", bn = {
|
|
5241
5410
|
light: {
|
|
5242
5411
|
bg: "#FFFFFF",
|
|
5243
5412
|
border: "rgba(18,18,18,0.05)",
|
|
@@ -5293,8 +5462,8 @@ const Yt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", yn = {
|
|
|
5293
5462
|
onPrimary: "#FFFFFF"
|
|
5294
5463
|
}
|
|
5295
5464
|
};
|
|
5296
|
-
function
|
|
5297
|
-
const s =
|
|
5465
|
+
function Zt(r, e) {
|
|
5466
|
+
const s = bn[r], t = e == null ? void 0 : e[r];
|
|
5298
5467
|
return t ? {
|
|
5299
5468
|
...s,
|
|
5300
5469
|
// ── Brand
|
|
@@ -5326,10 +5495,10 @@ function Jt(r, e) {
|
|
|
5326
5495
|
...t.error !== void 0 && { errorColor: t.error }
|
|
5327
5496
|
} : s;
|
|
5328
5497
|
}
|
|
5329
|
-
const
|
|
5498
|
+
const Sn = `
|
|
5330
5499
|
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
|
|
5331
5500
|
|
|
5332
|
-
#${
|
|
5501
|
+
#${se} {
|
|
5333
5502
|
position: fixed;
|
|
5334
5503
|
inset: 0;
|
|
5335
5504
|
z-index: 2147483647;
|
|
@@ -6493,6 +6662,8 @@ const bn = `
|
|
|
6493
6662
|
max-height: 320px;
|
|
6494
6663
|
overflow-y: auto;
|
|
6495
6664
|
-webkit-overflow-scrolling: touch;
|
|
6665
|
+
overscroll-behavior: contain;
|
|
6666
|
+
touch-action: pan-y;
|
|
6496
6667
|
scrollbar-width: thin;
|
|
6497
6668
|
}
|
|
6498
6669
|
.__crossx-wallet-list::-webkit-scrollbar {
|
|
@@ -6595,7 +6766,7 @@ const bn = `
|
|
|
6595
6766
|
|
|
6596
6767
|
/* ── Mobile bottom sheet ───────────────────────────────────── */
|
|
6597
6768
|
@media (max-width: 480px) {
|
|
6598
|
-
#${
|
|
6769
|
+
#${se} { align-items: flex-end; }
|
|
6599
6770
|
.__crossx-card {
|
|
6600
6771
|
width: 100%;
|
|
6601
6772
|
max-width: 100%;
|
|
@@ -6607,8 +6778,37 @@ const bn = `
|
|
|
6607
6778
|
}
|
|
6608
6779
|
.__crossx-card--wallet-selector {
|
|
6609
6780
|
overflow: hidden !important;
|
|
6781
|
+
display: flex !important;
|
|
6782
|
+
flex-direction: column !important;
|
|
6610
6783
|
}
|
|
6611
|
-
.__crossx-card--wallet-selector .__crossx-
|
|
6784
|
+
.__crossx-card--wallet-selector .__crossx-header { flex-shrink: 0; }
|
|
6785
|
+
.__crossx-card--wallet-selector > .__crossx-divider { flex-shrink: 0; }
|
|
6786
|
+
.__crossx-card--wallet-selector .__crossx-body {
|
|
6787
|
+
flex: 1;
|
|
6788
|
+
min-height: 0;
|
|
6789
|
+
overflow: hidden;
|
|
6790
|
+
display: flex;
|
|
6791
|
+
flex-direction: column;
|
|
6792
|
+
}
|
|
6793
|
+
.__crossx-card--wallet-selector .__crossx-body-cols {
|
|
6794
|
+
flex: 1;
|
|
6795
|
+
min-height: 0;
|
|
6796
|
+
display: flex;
|
|
6797
|
+
flex-direction: column;
|
|
6798
|
+
}
|
|
6799
|
+
.__crossx-card--wallet-selector .__crossx-col-left { flex-shrink: 0; }
|
|
6800
|
+
.__crossx-card--wallet-selector .__crossx-col-right-ws {
|
|
6801
|
+
flex: 1;
|
|
6802
|
+
min-height: 0;
|
|
6803
|
+
display: flex;
|
|
6804
|
+
flex-direction: column;
|
|
6805
|
+
}
|
|
6806
|
+
.__crossx-card--wallet-selector .__crossx-wallet-list {
|
|
6807
|
+
flex: 1;
|
|
6808
|
+
min-height: 0;
|
|
6809
|
+
max-height: 203px;
|
|
6810
|
+
}
|
|
6811
|
+
.__crossx-card--wallet-selector .__crossx-wallet-add { flex-shrink: 0; }
|
|
6612
6812
|
.__crossx-card--send-tx,
|
|
6613
6813
|
.__crossx-card--sign-tx,
|
|
6614
6814
|
.__crossx-card--sign-msg,
|
|
@@ -6734,7 +6934,7 @@ const bn = `
|
|
|
6734
6934
|
|
|
6735
6935
|
/* ── Landscape for signing/transaction modals ──────────── */
|
|
6736
6936
|
@media (orientation: landscape) and (max-height: 500px) {
|
|
6737
|
-
#${
|
|
6937
|
+
#${se} { align-items: center !important; overflow: hidden; }
|
|
6738
6938
|
.__crossx-card--send-tx,
|
|
6739
6939
|
.__crossx-card--sign-tx,
|
|
6740
6940
|
.__crossx-card--sign-msg,
|
|
@@ -7031,6 +7231,24 @@ const bn = `
|
|
|
7031
7231
|
flex-shrink: 0;
|
|
7032
7232
|
color: var(--cx-error);
|
|
7033
7233
|
}
|
|
7234
|
+
/* 시도 횟수 카운트 (X/Y) */
|
|
7235
|
+
.__crossx-pin6-attempt {
|
|
7236
|
+
font-size: 16px;
|
|
7237
|
+
font-weight: 500;
|
|
7238
|
+
line-height: 1.5;
|
|
7239
|
+
color: var(--cx-error);
|
|
7240
|
+
text-align: center;
|
|
7241
|
+
letter-spacing: -0.16px;
|
|
7242
|
+
margin: 0;
|
|
7243
|
+
}
|
|
7244
|
+
.__crossx-pin6-warning {
|
|
7245
|
+
font-size: 14px;
|
|
7246
|
+
font-weight: 500;
|
|
7247
|
+
line-height: 1.5;
|
|
7248
|
+
color: var(--cx-error);
|
|
7249
|
+
text-align: center;
|
|
7250
|
+
margin: 0;
|
|
7251
|
+
}
|
|
7034
7252
|
/* Next 버튼 */
|
|
7035
7253
|
.__crossx-pin6-next {
|
|
7036
7254
|
width: 100%;
|
|
@@ -7053,30 +7271,56 @@ const bn = `
|
|
|
7053
7271
|
}
|
|
7054
7272
|
`;
|
|
7055
7273
|
function he() {
|
|
7056
|
-
let r = document.getElementById(
|
|
7057
|
-
r || (r = document.createElement("style"), r.id =
|
|
7274
|
+
let r = document.getElementById(Jt);
|
|
7275
|
+
r || (r = document.createElement("style"), r.id = Jt, document.head.appendChild(r)), r.textContent = Sn;
|
|
7058
7276
|
}
|
|
7059
7277
|
function pe(r) {
|
|
7060
7278
|
const e = (s) => s.stopPropagation();
|
|
7061
|
-
for (const s of ["pointerdown", "pointerup", "mousedown", "mouseup", "click"
|
|
7279
|
+
for (const s of ["pointerdown", "pointerup", "mousedown", "mouseup", "click"])
|
|
7280
|
+
r.addEventListener(s, e);
|
|
7281
|
+
r.setAttribute("data-vaul-no-drag", "");
|
|
7282
|
+
for (const s of ["touchstart", "touchend"])
|
|
7062
7283
|
r.addEventListener(s, e);
|
|
7063
|
-
|
|
7284
|
+
r.addEventListener("touchmove", (s) => {
|
|
7285
|
+
s.stopPropagation();
|
|
7286
|
+
let t = s.target;
|
|
7287
|
+
for (; t && t !== r; ) {
|
|
7288
|
+
const n = window.getComputedStyle(t);
|
|
7289
|
+
if ((n.overflowY === "auto" || n.overflowY === "scroll") && t.scrollHeight > t.clientHeight)
|
|
7290
|
+
return;
|
|
7291
|
+
t = t.parentElement;
|
|
7292
|
+
}
|
|
7293
|
+
s.preventDefault();
|
|
7294
|
+
}, { passive: !1 }), document.body.appendChild(r);
|
|
7295
|
+
}
|
|
7296
|
+
const vn = () => /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
7297
|
+
function nt() {
|
|
7298
|
+
if (vn()) {
|
|
7299
|
+
const e = window.scrollY;
|
|
7300
|
+
return document.body.style.position = "fixed", document.body.style.top = `-${e}px`, document.body.style.left = "0", document.body.style.right = "0", () => {
|
|
7301
|
+
document.body.style.position = "", document.body.style.top = "", document.body.style.left = "", document.body.style.right = "", window.scrollTo(0, e);
|
|
7302
|
+
};
|
|
7303
|
+
}
|
|
7304
|
+
const r = document.body.style.overflow;
|
|
7305
|
+
return document.body.style.overflow = "hidden", () => {
|
|
7306
|
+
document.body.style.overflow = r;
|
|
7307
|
+
};
|
|
7064
7308
|
}
|
|
7065
|
-
function
|
|
7309
|
+
function re(r) {
|
|
7066
7310
|
return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
|
|
7067
7311
|
}
|
|
7068
|
-
function
|
|
7312
|
+
function En(r, e = "CROSS", s = 18) {
|
|
7069
7313
|
if (!r || r === "0x" || r === "0x0") return null;
|
|
7070
7314
|
try {
|
|
7071
7315
|
const t = BigInt(r);
|
|
7072
7316
|
if (t === 0n) return null;
|
|
7073
|
-
const n =
|
|
7317
|
+
const n = ht(t, s);
|
|
7074
7318
|
return n === "0" ? null : `${n} ${e}`;
|
|
7075
7319
|
} catch {
|
|
7076
7320
|
return null;
|
|
7077
7321
|
}
|
|
7078
7322
|
}
|
|
7079
|
-
const
|
|
7323
|
+
const Qt = {
|
|
7080
7324
|
1: "Ethereum Mainnet",
|
|
7081
7325
|
5: "Goerli Testnet",
|
|
7082
7326
|
11155111: "Ethereum Sepolia",
|
|
@@ -7099,16 +7343,16 @@ const Xt = {
|
|
|
7099
7343
|
612044: "CROSS Testnet",
|
|
7100
7344
|
612055: "CROSS Mainnet"
|
|
7101
7345
|
};
|
|
7102
|
-
function
|
|
7346
|
+
function Ns(r) {
|
|
7103
7347
|
const e = parseInt(r.split(":")[1] ?? "", 10);
|
|
7104
|
-
return !isNaN(e) &&
|
|
7348
|
+
return !isNaN(e) && Qt[e] ? Qt[e] : r;
|
|
7105
7349
|
}
|
|
7106
|
-
function
|
|
7350
|
+
function ht(r, e) {
|
|
7107
7351
|
if (r === 0n) return "0";
|
|
7108
7352
|
const s = 10n ** BigInt(e), t = r / s, i = (r % s).toString().padStart(e, "0").slice(0, 6).replace(/0+$/, "");
|
|
7109
7353
|
return i ? `${t}.${i}` : `${t}`;
|
|
7110
7354
|
}
|
|
7111
|
-
function
|
|
7355
|
+
function ot(r) {
|
|
7112
7356
|
try {
|
|
7113
7357
|
const e = BigInt(r), s = e / 1000000000n, n = (e % 1000000000n).toString().padStart(9, "0").slice(0, 2).replace(/0+$/, "");
|
|
7114
7358
|
return n ? `${s}.${n}` : `${s}`;
|
|
@@ -7116,25 +7360,25 @@ function nt(r) {
|
|
|
7116
7360
|
return r;
|
|
7117
7361
|
}
|
|
7118
7362
|
}
|
|
7119
|
-
function
|
|
7363
|
+
function In(r) {
|
|
7120
7364
|
try {
|
|
7121
7365
|
return BigInt(r).toLocaleString();
|
|
7122
7366
|
} catch {
|
|
7123
7367
|
return r;
|
|
7124
7368
|
}
|
|
7125
7369
|
}
|
|
7126
|
-
function
|
|
7370
|
+
function An(r) {
|
|
7127
7371
|
const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
|
|
7128
7372
|
if (!e) return null;
|
|
7129
7373
|
try {
|
|
7130
|
-
const a = BigInt(e), c =
|
|
7374
|
+
const a = BigInt(e), c = In(e);
|
|
7131
7375
|
if (t) {
|
|
7132
7376
|
const l = a * BigInt(t);
|
|
7133
7377
|
return {
|
|
7134
7378
|
isDynamic: !0,
|
|
7135
|
-
estTxFee: `${
|
|
7136
|
-
maxFeeGwei:
|
|
7137
|
-
maxPriorityFeeGwei: n ?
|
|
7379
|
+
estTxFee: `${ht(l, i)} ${o}`,
|
|
7380
|
+
maxFeeGwei: ot(t),
|
|
7381
|
+
maxPriorityFeeGwei: n ? ot(n) : void 0,
|
|
7138
7382
|
gasLimitFormatted: c
|
|
7139
7383
|
};
|
|
7140
7384
|
}
|
|
@@ -7142,8 +7386,8 @@ function En(r) {
|
|
|
7142
7386
|
const l = a * BigInt(s);
|
|
7143
7387
|
return {
|
|
7144
7388
|
isDynamic: !1,
|
|
7145
|
-
estTxFee: `${
|
|
7146
|
-
gasPriceGwei:
|
|
7389
|
+
estTxFee: `${ht(l, i)} ${o}`,
|
|
7390
|
+
gasPriceGwei: ot(s),
|
|
7147
7391
|
gasLimitFormatted: c
|
|
7148
7392
|
};
|
|
7149
7393
|
}
|
|
@@ -7152,8 +7396,8 @@ function En(r) {
|
|
|
7152
7396
|
return null;
|
|
7153
7397
|
}
|
|
7154
7398
|
}
|
|
7155
|
-
function
|
|
7156
|
-
const e =
|
|
7399
|
+
function Ls(r) {
|
|
7400
|
+
const e = An(r);
|
|
7157
7401
|
if (!e) return Y("Estimated fee", "<span>—</span>");
|
|
7158
7402
|
let s = Y("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
|
|
7159
7403
|
return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += Y("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += Y("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += Y("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += Y("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
|
|
@@ -7164,16 +7408,16 @@ const ge = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="
|
|
|
7164
7408
|
</svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
|
|
7165
7409
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
7166
7410
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
7167
|
-
</svg>`,
|
|
7411
|
+
</svg>`, Tn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7168
7412
|
<circle cx="20" cy="20" r="20" fill="#00D5AA"/>
|
|
7169
7413
|
<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"/>
|
|
7170
|
-
</svg>`,
|
|
7414
|
+
</svg>`, bt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
7171
7415
|
<rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
|
|
7172
7416
|
<path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
|
|
7173
7417
|
<rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
|
|
7174
|
-
</svg>`,
|
|
7418
|
+
</svg>`, Rn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
7175
7419
|
<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)"/>
|
|
7176
|
-
</svg>`,
|
|
7420
|
+
</svg>`, kn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
7177
7421
|
<circle cx="12" cy="12" r="12" fill="var(--cx-error)"/>
|
|
7178
7422
|
<circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
|
|
7179
7423
|
<path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
|
|
@@ -7211,10 +7455,10 @@ function Y(r, e) {
|
|
|
7211
7455
|
<div class="__crossx-row-value">${e}</div>
|
|
7212
7456
|
</div>`;
|
|
7213
7457
|
}
|
|
7214
|
-
function
|
|
7215
|
-
const s = e, t =
|
|
7216
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7217
|
-
return a.id =
|
|
7458
|
+
function Pn(r, e) {
|
|
7459
|
+
const s = e, t = Xe(r.dappName), n = r.to ? `<span class="__crossx-addr-text">${re(r.to)}</span>
|
|
7460
|
+
<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");
|
|
7461
|
+
return a.id = se, a.innerHTML = `
|
|
7218
7462
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7219
7463
|
<div class="__crossx-header">
|
|
7220
7464
|
<p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
|
|
@@ -7225,11 +7469,11 @@ function Rn(r, e) {
|
|
|
7225
7469
|
<div class="__crossx-body-cols">
|
|
7226
7470
|
<div class="__crossx-col-left">
|
|
7227
7471
|
<p class="__crossx-sig-subtitle">
|
|
7228
|
-
<span class="__crossx-sig-origin">${
|
|
7472
|
+
<span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
|
|
7229
7473
|
</p>
|
|
7230
7474
|
<div class="__crossx-addr-pill">
|
|
7231
|
-
${
|
|
7232
|
-
<span class="__crossx-addr-pill-text">${
|
|
7475
|
+
${bt}
|
|
7476
|
+
<span class="__crossx-addr-pill-text">${re(r.from)}</span>
|
|
7233
7477
|
</div>
|
|
7234
7478
|
<p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
|
|
7235
7479
|
</div>
|
|
@@ -7237,10 +7481,10 @@ function Rn(r, e) {
|
|
|
7237
7481
|
<div class="__crossx-col-right-sign">
|
|
7238
7482
|
<div class="__crossx-rows">
|
|
7239
7483
|
${Y("To", n)}
|
|
7240
|
-
${Y("Network", `<span>${
|
|
7484
|
+
${Y("Network", `<span>${Ns(r.chainId)}</span>`)}
|
|
7241
7485
|
${o}
|
|
7242
7486
|
</div>
|
|
7243
|
-
<pre class="__crossx-raw-tx">${
|
|
7487
|
+
<pre class="__crossx-raw-tx">${$(i)}</pre>
|
|
7244
7488
|
</div>
|
|
7245
7489
|
</div>
|
|
7246
7490
|
<div class="__crossx-btn-row">
|
|
@@ -7251,10 +7495,10 @@ function Rn(r, e) {
|
|
|
7251
7495
|
</div>
|
|
7252
7496
|
`, a;
|
|
7253
7497
|
}
|
|
7254
|
-
function
|
|
7255
|
-
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o =
|
|
7256
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7257
|
-
return u.id =
|
|
7498
|
+
function On(r, e) {
|
|
7499
|
+
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>
|
|
7500
|
+
<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");
|
|
7501
|
+
return u.id = se, u.innerHTML = `
|
|
7258
7502
|
<div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7259
7503
|
<div class="__crossx-header">
|
|
7260
7504
|
<p class="__crossx-title" id="__crossx-ttl">Approve transaction</p>
|
|
@@ -7263,16 +7507,16 @@ function kn(r, e) {
|
|
|
7263
7507
|
<hr class="__crossx-divider">
|
|
7264
7508
|
<div class="__crossx-body">
|
|
7265
7509
|
<p class="__crossx-tx-subtitle">
|
|
7266
|
-
<span class="__crossx-sig-origin">${
|
|
7510
|
+
<span class="__crossx-sig-origin">${$(o)}</span> wants your permission to approve the following transaction.
|
|
7267
7511
|
</p>
|
|
7268
7512
|
<div class="__crossx-body-cols">
|
|
7269
7513
|
<div class="__crossx-rows">
|
|
7270
7514
|
${Y("To", i)}
|
|
7271
|
-
${Y("Network", `<span>${
|
|
7515
|
+
${Y("Network", `<span>${Ns(r.chainId)}</span>`)}
|
|
7272
7516
|
${a}
|
|
7273
7517
|
</div>
|
|
7274
7518
|
<div class="__crossx-pill">
|
|
7275
|
-
<span class="__crossx-pill-from">${
|
|
7519
|
+
<span class="__crossx-pill-from">${re(r.from)}</span>
|
|
7276
7520
|
<span class="__crossx-pill-amount">${l}</span>
|
|
7277
7521
|
</div>
|
|
7278
7522
|
</div>
|
|
@@ -7281,7 +7525,7 @@ function kn(r, e) {
|
|
|
7281
7525
|
</div>
|
|
7282
7526
|
`, u;
|
|
7283
7527
|
}
|
|
7284
|
-
function
|
|
7528
|
+
function Xe(r) {
|
|
7285
7529
|
var e;
|
|
7286
7530
|
if (r) return r;
|
|
7287
7531
|
try {
|
|
@@ -7290,33 +7534,33 @@ function Ye(r) {
|
|
|
7290
7534
|
return "This site";
|
|
7291
7535
|
}
|
|
7292
7536
|
}
|
|
7293
|
-
function
|
|
7537
|
+
function $(r) {
|
|
7294
7538
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7295
7539
|
}
|
|
7296
|
-
function
|
|
7540
|
+
function Cn(r) {
|
|
7297
7541
|
return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
|
|
7298
7542
|
}
|
|
7299
|
-
function
|
|
7300
|
-
if (typeof r == "string") return
|
|
7543
|
+
function Nn(r) {
|
|
7544
|
+
if (typeof r == "string") return $(r);
|
|
7301
7545
|
if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
|
|
7302
7546
|
try {
|
|
7303
|
-
return
|
|
7547
|
+
return $(JSON.stringify(r));
|
|
7304
7548
|
} catch {
|
|
7305
7549
|
return String(r);
|
|
7306
7550
|
}
|
|
7307
7551
|
}
|
|
7308
|
-
function
|
|
7552
|
+
function Ln(r, e) {
|
|
7309
7553
|
const s = Y(
|
|
7310
7554
|
"From",
|
|
7311
|
-
`<span class="__crossx-addr-text">${
|
|
7312
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7313
|
-
), t = r.to ? Y("To", `<span class="__crossx-addr-text">${
|
|
7314
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7315
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7555
|
+
`<span class="__crossx-addr-text">${re(r.from)}</span>
|
|
7556
|
+
<button class="__crossx-copy-btn" data-copy="${$(r.from)}" title="Copy address">${ge}</button>`
|
|
7557
|
+
), t = r.to ? Y("To", `<span class="__crossx-addr-text">${re(r.to)}</span>
|
|
7558
|
+
<button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${ge}</button>`) : "", n = r.amount ? Y("Transfer", `<span>${$(r.amount)}</span>`) : "", o = r.fees ? Y("Tx Fee", `<span>${$(r.fees)}</span>`) : "", i = r.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${re(r.txHash)}</span>
|
|
7559
|
+
<button class="__crossx-copy-btn" data-copy="${$(r.txHash)}" title="Copy hash">${ge}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
|
|
7316
7560
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7317
|
-
<span class="__crossx-total-amount">${
|
|
7561
|
+
<span class="__crossx-total-amount">${$(r.total)}</span>
|
|
7318
7562
|
</div>` : "", c = document.createElement("div");
|
|
7319
|
-
return c.id =
|
|
7563
|
+
return c.id = se, c.innerHTML = `
|
|
7320
7564
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7321
7565
|
<div class="__crossx-header">
|
|
7322
7566
|
<p class="__crossx-title" id="__crossx-ttl">Transaction complete</p>
|
|
@@ -7337,9 +7581,9 @@ function Cn(r, e) {
|
|
|
7337
7581
|
</div>
|
|
7338
7582
|
`, c;
|
|
7339
7583
|
}
|
|
7340
|
-
function
|
|
7584
|
+
function Dn(r, e) {
|
|
7341
7585
|
const s = document.createElement("div");
|
|
7342
|
-
return s.id =
|
|
7586
|
+
return s.id = se, s.innerHTML = `
|
|
7343
7587
|
<div class="__crossx-card __crossx-card--migration" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7344
7588
|
<div class="__crossx-header">
|
|
7345
7589
|
<p class="__crossx-title" id="__crossx-ttl">Waiting for confirmation</p>
|
|
@@ -7354,11 +7598,11 @@ function Nn(r, e) {
|
|
|
7354
7598
|
</div>
|
|
7355
7599
|
`, s;
|
|
7356
7600
|
}
|
|
7357
|
-
function
|
|
7601
|
+
function Mn(r, e, s) {
|
|
7358
7602
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
7359
7603
|
if (o) {
|
|
7360
|
-
const w = n ?
|
|
7361
|
-
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${
|
|
7604
|
+
const w = n ? kn : t ? "" : Rn, E = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
7605
|
+
w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${E}</span>`) : o.textContent = E;
|
|
7362
7606
|
}
|
|
7363
7607
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
7364
7608
|
const w = document.createElement("button");
|
|
@@ -7366,12 +7610,12 @@ function Ln(r, e, s) {
|
|
|
7366
7610
|
}
|
|
7367
7611
|
const a = r.querySelector("#__crossx-progress-body");
|
|
7368
7612
|
if (!a) return;
|
|
7369
|
-
const c = e.from ? Y("From", `<span class="__crossx-addr-text">${
|
|
7370
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7371
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7372
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7613
|
+
const c = e.from ? Y("From", `<span class="__crossx-addr-text">${re(e.from)}</span>
|
|
7614
|
+
<button class="__crossx-copy-btn" data-copy="${$(e.from)}" title="Copy address">${ge}</button>`) : "", l = e.to ? Y("To", `<span class="__crossx-addr-text">${re(e.to)}</span>
|
|
7615
|
+
<button class="__crossx-copy-btn" data-copy="${$(e.to)}" title="Copy address">${ge}</button>`) : "", u = e.amount ? Y("Transfer", `<span>${$(e.amount)}</span>`) : "", h = e.fees ? Y("Tx Fee", `<span>${$(e.fees)}</span>`) : "", _ = e.txHash ? Y("Tx Hash", `<span class="__crossx-addr-text">${re(e.txHash)}</span>
|
|
7616
|
+
<button class="__crossx-copy-btn" data-copy="${$(e.txHash)}" title="Copy hash">${ge}</button>`) : "", f = e.total ? `<div class="__crossx-total-pill">
|
|
7373
7617
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
7374
|
-
<span class="__crossx-total-amount">${
|
|
7618
|
+
<span class="__crossx-total-amount">${$(e.total)}</span>
|
|
7375
7619
|
</div>` : "";
|
|
7376
7620
|
a.innerHTML = `
|
|
7377
7621
|
<div class="__crossx-rows">
|
|
@@ -7384,18 +7628,18 @@ function Ln(r, e, s) {
|
|
|
7384
7628
|
${f}
|
|
7385
7629
|
<button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
|
|
7386
7630
|
`, a.querySelectorAll(".__crossx-copy-btn").forEach((w) => {
|
|
7387
|
-
w.addEventListener("click", (
|
|
7388
|
-
var
|
|
7389
|
-
|
|
7631
|
+
w.addEventListener("click", (E) => {
|
|
7632
|
+
var R;
|
|
7633
|
+
E.stopPropagation();
|
|
7390
7634
|
const y = w.dataset.copy;
|
|
7391
|
-
y && ((
|
|
7635
|
+
y && ((R = navigator.clipboard) == null || R.writeText(y).catch(() => {
|
|
7392
7636
|
}));
|
|
7393
7637
|
});
|
|
7394
7638
|
});
|
|
7395
7639
|
}
|
|
7396
|
-
function
|
|
7397
|
-
const s = e, t =
|
|
7398
|
-
return o.id =
|
|
7640
|
+
function $n(r, e) {
|
|
7641
|
+
const s = e, t = Xe(r.dappName), n = $(r.message), o = document.createElement("div");
|
|
7642
|
+
return o.id = se, o.innerHTML = `
|
|
7399
7643
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7400
7644
|
<div class="__crossx-header">
|
|
7401
7645
|
<p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
|
|
@@ -7406,11 +7650,11 @@ function Dn(r, e) {
|
|
|
7406
7650
|
<div class="__crossx-body-cols">
|
|
7407
7651
|
<div class="__crossx-col-left">
|
|
7408
7652
|
<p class="__crossx-sig-subtitle">
|
|
7409
|
-
<span class="__crossx-sig-origin">${
|
|
7653
|
+
<span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
|
|
7410
7654
|
</p>
|
|
7411
7655
|
<div class="__crossx-addr-pill">
|
|
7412
|
-
${
|
|
7413
|
-
<span class="__crossx-addr-pill-text">${
|
|
7656
|
+
${bt}
|
|
7657
|
+
<span class="__crossx-addr-pill-text">${re(r.from)}</span>
|
|
7414
7658
|
</div>
|
|
7415
7659
|
<p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
|
|
7416
7660
|
</div>
|
|
@@ -7425,8 +7669,8 @@ function Dn(r, e) {
|
|
|
7425
7669
|
</div>
|
|
7426
7670
|
`, o;
|
|
7427
7671
|
}
|
|
7428
|
-
function
|
|
7429
|
-
const s = e, t =
|
|
7672
|
+
function Bn(r, e) {
|
|
7673
|
+
const s = e, t = Xe(r.dappName);
|
|
7430
7674
|
let n = {};
|
|
7431
7675
|
if (typeof r.typedData == "string")
|
|
7432
7676
|
try {
|
|
@@ -7438,19 +7682,19 @@ function Mn(r, e) {
|
|
|
7438
7682
|
let a = `
|
|
7439
7683
|
<div class="__crossx-td-row">
|
|
7440
7684
|
<span class="__crossx-td-label">Primary Type</span>
|
|
7441
|
-
<span class="__crossx-td-value">${
|
|
7685
|
+
<span class="__crossx-td-value">${$(o)}</span>
|
|
7442
7686
|
</div>`;
|
|
7443
7687
|
for (const [l, u] of Object.entries(i)) {
|
|
7444
|
-
const h =
|
|
7445
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
7688
|
+
const h = Nn(u), f = Cn(u) ? `<span class="__crossx-addr-text">${re(u)}</span>
|
|
7689
|
+
<button class="__crossx-copy-btn" data-copy="${$(String(u))}" title="Copy">${ge}</button>` : `<span>${h}</span>`;
|
|
7446
7690
|
a += `
|
|
7447
7691
|
<div class="__crossx-td-row">
|
|
7448
|
-
<span class="__crossx-td-label">${
|
|
7692
|
+
<span class="__crossx-td-label">${$(l)}</span>
|
|
7449
7693
|
<div class="__crossx-td-value">${f}</div>
|
|
7450
7694
|
</div>`;
|
|
7451
7695
|
}
|
|
7452
7696
|
const c = document.createElement("div");
|
|
7453
|
-
return c.id =
|
|
7697
|
+
return c.id = se, c.innerHTML = `
|
|
7454
7698
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-typed" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7455
7699
|
<div class="__crossx-header">
|
|
7456
7700
|
<p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
|
|
@@ -7461,11 +7705,11 @@ function Mn(r, e) {
|
|
|
7461
7705
|
<div class="__crossx-body-cols">
|
|
7462
7706
|
<div class="__crossx-col-left">
|
|
7463
7707
|
<p class="__crossx-sig-subtitle">
|
|
7464
|
-
<span class="__crossx-sig-origin">${
|
|
7708
|
+
<span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
|
|
7465
7709
|
</p>
|
|
7466
7710
|
<div class="__crossx-addr-pill">
|
|
7467
|
-
${
|
|
7468
|
-
<span class="__crossx-addr-pill-text">${
|
|
7711
|
+
${bt}
|
|
7712
|
+
<span class="__crossx-addr-pill-text">${re(r.from)}</span>
|
|
7469
7713
|
</div>
|
|
7470
7714
|
<p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
|
|
7471
7715
|
</div>
|
|
@@ -7480,18 +7724,18 @@ function Mn(r, e) {
|
|
|
7480
7724
|
</div>
|
|
7481
7725
|
`, c;
|
|
7482
7726
|
}
|
|
7483
|
-
const
|
|
7727
|
+
const Un = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
7484
7728
|
<line x1="12" y1="5" x2="12" y2="19"/>
|
|
7485
7729
|
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
7486
7730
|
</svg>`;
|
|
7487
|
-
function
|
|
7731
|
+
function Hn(r, e, s) {
|
|
7488
7732
|
const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
|
|
7489
7733
|
const a = t && i.address.toLowerCase() === t;
|
|
7490
|
-
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${
|
|
7491
|
-
<span class="__crossx-wallet-addr">${
|
|
7734
|
+
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${$(i.address)}">
|
|
7735
|
+
<span class="__crossx-wallet-addr">${re(i.address)}</span>${a ? '<span class="__crossx-wallet-selected">selected</span>' : ""}
|
|
7492
7736
|
</button>`;
|
|
7493
7737
|
}).join(""), o = document.createElement("div");
|
|
7494
|
-
return o.id =
|
|
7738
|
+
return o.id = se, o.innerHTML = `
|
|
7495
7739
|
<div class="__crossx-card __crossx-card--migration __crossx-card--wallet-selector" style="${ce(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7496
7740
|
<div class="__crossx-header">
|
|
7497
7741
|
<div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
|
|
@@ -7515,7 +7759,7 @@ function Bn(r, e, s) {
|
|
|
7515
7759
|
${n}
|
|
7516
7760
|
</div>
|
|
7517
7761
|
<button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
|
|
7518
|
-
<span class="__crossx-wallet-add-icon">${
|
|
7762
|
+
<span class="__crossx-wallet-add-icon">${Un}</span>
|
|
7519
7763
|
<span class="__crossx-wallet-add-label">add a wallet</span>
|
|
7520
7764
|
</button>
|
|
7521
7765
|
</div>
|
|
@@ -7524,16 +7768,16 @@ function Bn(r, e, s) {
|
|
|
7524
7768
|
</div>
|
|
7525
7769
|
`, o;
|
|
7526
7770
|
}
|
|
7527
|
-
const
|
|
7771
|
+
const Fn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7528
7772
|
<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"/>
|
|
7529
7773
|
<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"/>
|
|
7530
|
-
</svg>`,
|
|
7774
|
+
</svg>`, Gn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7531
7775
|
<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"/>
|
|
7532
7776
|
<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"/>
|
|
7533
7777
|
<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"/>
|
|
7534
7778
|
<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"/>
|
|
7535
7779
|
</svg>`;
|
|
7536
|
-
function
|
|
7780
|
+
function Wn(r, e = !1) {
|
|
7537
7781
|
const s = r, t = e ? `
|
|
7538
7782
|
<div class="__crossx-login-or-divider">
|
|
7539
7783
|
<hr><span>or</span><hr>
|
|
@@ -7544,7 +7788,7 @@ function Fn(r, e = !1) {
|
|
|
7544
7788
|
<span class="__crossx-connect-other-desc">Connect your existing Web3 wallet to manage your assets.</span>
|
|
7545
7789
|
</div>
|
|
7546
7790
|
</button>` : "", n = document.createElement("div");
|
|
7547
|
-
return n.id =
|
|
7791
|
+
return n.id = se, n.innerHTML = `
|
|
7548
7792
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7549
7793
|
<div class="__crossx-header">
|
|
7550
7794
|
<div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
|
|
@@ -7557,11 +7801,11 @@ function Fn(r, e = !1) {
|
|
|
7557
7801
|
<div class="__crossx-body">
|
|
7558
7802
|
<div class="__crossx-login-btn-row">
|
|
7559
7803
|
<button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
|
|
7560
|
-
<span class="__crossx-login-icon" style="color:var(--cx-value);">${
|
|
7804
|
+
<span class="__crossx-login-icon" style="color:var(--cx-value);">${Fn}</span>
|
|
7561
7805
|
<span class="__crossx-login-btn-label">Sign in with Apple</span>
|
|
7562
7806
|
</button>
|
|
7563
7807
|
<button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
|
|
7564
|
-
<span class="__crossx-login-icon">${
|
|
7808
|
+
<span class="__crossx-login-icon">${Gn}</span>
|
|
7565
7809
|
<span class="__crossx-login-btn-label">Sign in with Google</span>
|
|
7566
7810
|
</button>
|
|
7567
7811
|
</div>${t}
|
|
@@ -7572,9 +7816,9 @@ function Fn(r, e = !1) {
|
|
|
7572
7816
|
</div>
|
|
7573
7817
|
`, n;
|
|
7574
7818
|
}
|
|
7575
|
-
function
|
|
7819
|
+
function qn(r, e = !0) {
|
|
7576
7820
|
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");
|
|
7577
|
-
return o.id =
|
|
7821
|
+
return o.id = se, o.innerHTML = `
|
|
7578
7822
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7579
7823
|
<div class="__crossx-header">
|
|
7580
7824
|
<p class="__crossx-title" id="__crossx-ttl">Wallet Found on Social Account 🎉</p>
|
|
@@ -7588,7 +7832,7 @@ function Gn(r, e = !0) {
|
|
|
7588
7832
|
<p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
|
|
7589
7833
|
</div>
|
|
7590
7834
|
<button class="__crossx-recover-btn" id="__crossx-recover-btn">
|
|
7591
|
-
<span class="__crossx-recover-icon">${
|
|
7835
|
+
<span class="__crossx-recover-icon">${Tn}</span>
|
|
7592
7836
|
<span class="__crossx-recover-label">Import from Social Backup</span>
|
|
7593
7837
|
</button>
|
|
7594
7838
|
${n}
|
|
@@ -7596,9 +7840,9 @@ function Gn(r, e = !0) {
|
|
|
7596
7840
|
</div>
|
|
7597
7841
|
`, o;
|
|
7598
7842
|
}
|
|
7599
|
-
function
|
|
7843
|
+
function Kn(r, e) {
|
|
7600
7844
|
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");
|
|
7601
|
-
return h.id =
|
|
7845
|
+
return h.id = se, h.innerHTML = `
|
|
7602
7846
|
<div class="__crossx-card __crossx-card--migration" style="${ce(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7603
7847
|
<div class="__crossx-header">
|
|
7604
7848
|
<p class="__crossx-title" id="__crossx-ttl">Import from Social Backup</p>
|
|
@@ -7620,13 +7864,13 @@ function Wn(r, e) {
|
|
|
7620
7864
|
</div>
|
|
7621
7865
|
`, h;
|
|
7622
7866
|
}
|
|
7623
|
-
function
|
|
7867
|
+
function Vn(r) {
|
|
7624
7868
|
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");
|
|
7625
7869
|
return `${n}, ${o} ${i} ${a}:${c}`;
|
|
7626
7870
|
}
|
|
7627
|
-
function
|
|
7628
|
-
const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ?
|
|
7629
|
-
return a.id =
|
|
7871
|
+
function zn(r, e, s) {
|
|
7872
|
+
const t = r, n = e <= 0, o = n ? null : Date.now() + e * 1e3, i = o ? Vn(o) : null, a = document.createElement("div");
|
|
7873
|
+
return a.id = se, a.innerHTML = `
|
|
7630
7874
|
<div class="__crossx-card __crossx-card--migration" style="${ce(t)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7631
7875
|
<div class="__crossx-header">
|
|
7632
7876
|
<p class="__crossx-title" id="__crossx-ttl">Import from Social Backup</p>
|
|
@@ -7655,17 +7899,17 @@ function Kn(r, e, s) {
|
|
|
7655
7899
|
return () => clearInterval(h);
|
|
7656
7900
|
} };
|
|
7657
7901
|
}
|
|
7658
|
-
function
|
|
7902
|
+
function Yn(r) {
|
|
7659
7903
|
const s = [r.check1, r.check2].map((t, n) => `
|
|
7660
7904
|
<div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
|
|
7661
|
-
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${
|
|
7662
|
-
<span class="__crossx-pw-notice-item-text">${
|
|
7905
|
+
<div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${Jn}</div>
|
|
7906
|
+
<span class="__crossx-pw-notice-item-text">${$(t)}</span>
|
|
7663
7907
|
</div>
|
|
7664
7908
|
`).join("");
|
|
7665
7909
|
return `
|
|
7666
7910
|
<div class="__crossx-header">
|
|
7667
|
-
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${
|
|
7668
|
-
<p class="__crossx-pw-subtitle">${
|
|
7911
|
+
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${$(r.title)}</p>
|
|
7912
|
+
<p class="__crossx-pw-subtitle">${$(r.headerSubtitle)}</p>
|
|
7669
7913
|
<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
|
|
7670
7914
|
</div>
|
|
7671
7915
|
<hr class="__crossx-divider">
|
|
@@ -7673,35 +7917,35 @@ function Vn(r) {
|
|
|
7673
7917
|
<div class="__crossx-pw-fields __crossx-pw-fields--notice">
|
|
7674
7918
|
<div class="__crossx-pw-notice-header">
|
|
7675
7919
|
<div class="__crossx-pw-notice-title-row">
|
|
7676
|
-
<span class="__crossx-pw-notice-icon">${
|
|
7677
|
-
<p class="__crossx-pw-notice-title">${
|
|
7920
|
+
<span class="__crossx-pw-notice-icon">${Zn}</span>
|
|
7921
|
+
<p class="__crossx-pw-notice-title">${$(r.noticeTitle)}</p>
|
|
7678
7922
|
</div>
|
|
7679
|
-
<p class="__crossx-pw-notice-desc">${
|
|
7923
|
+
<p class="__crossx-pw-notice-desc">${$(r.noticeDesc)}</p>
|
|
7680
7924
|
</div>
|
|
7681
7925
|
<div class="__crossx-pw-notice-checks" id="__crossx-notice-checks">
|
|
7682
7926
|
${s}
|
|
7683
7927
|
</div>
|
|
7684
7928
|
</div>
|
|
7685
7929
|
<button class="__crossx-pw-btn --disabled" id="__crossx-pin-notice-next"
|
|
7686
|
-
data-next-label="${
|
|
7687
|
-
data-submit-label="${
|
|
7688
|
-
${
|
|
7930
|
+
data-next-label="${$(r.nextButton)}"
|
|
7931
|
+
data-submit-label="${$(r.submitButton)}">
|
|
7932
|
+
${$(r.nextButton)}
|
|
7689
7933
|
</button>
|
|
7690
7934
|
</div>
|
|
7691
7935
|
<div class="__crossx-home-indicator"></div>
|
|
7692
7936
|
`;
|
|
7693
7937
|
}
|
|
7694
|
-
function
|
|
7695
|
-
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">${
|
|
7696
|
-
${
|
|
7938
|
+
function it(r) {
|
|
7939
|
+
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">
|
|
7940
|
+
${Ds}
|
|
7697
7941
|
<span id="__crossx-pin6-lock-countdown"></span>
|
|
7698
|
-
</p>` : "", a = e ? " --locked" : "",
|
|
7942
|
+
</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(
|
|
7699
7943
|
{ length: 6 },
|
|
7700
|
-
(
|
|
7944
|
+
(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" : ""}>`
|
|
7701
7945
|
).join("");
|
|
7702
7946
|
return `
|
|
7703
7947
|
<div class="__crossx-header">
|
|
7704
|
-
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${
|
|
7948
|
+
<p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${$(r.title)}</p>
|
|
7705
7949
|
${t}
|
|
7706
7950
|
<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
|
|
7707
7951
|
</div>
|
|
@@ -7709,149 +7953,162 @@ function ot(r) {
|
|
|
7709
7953
|
<div class="__crossx-pin6-body"${s}>
|
|
7710
7954
|
${n}
|
|
7711
7955
|
<div class="__crossx-pin6-boxes" id="__crossx-pin6-boxes">
|
|
7712
|
-
${
|
|
7956
|
+
${l}
|
|
7713
7957
|
</div>
|
|
7714
7958
|
${o}
|
|
7959
|
+
${a}
|
|
7715
7960
|
${i}
|
|
7716
7961
|
</div>
|
|
7717
7962
|
<div class="__crossx-home-indicator"></div>
|
|
7718
7963
|
`;
|
|
7719
7964
|
}
|
|
7720
|
-
function
|
|
7965
|
+
function es(r, e) {
|
|
7721
7966
|
const s = document.createElement("div");
|
|
7722
|
-
return s.id =
|
|
7967
|
+
return s.id = se, s.innerHTML = `
|
|
7723
7968
|
<div class="__crossx-card __crossx-card--pin6" style="${ce(r)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
7724
7969
|
${e}
|
|
7725
7970
|
</div>
|
|
7726
7971
|
`, s;
|
|
7727
7972
|
}
|
|
7728
|
-
function
|
|
7973
|
+
function jn(r, e) {
|
|
7729
7974
|
if (r.length !== 6) return e.tooShort;
|
|
7730
7975
|
if (!/^\d+$/.test(r)) return e.numbersOnly;
|
|
7731
7976
|
if (/(.)\1{2}/.test(r)) return e.repeatingDigit;
|
|
7732
7977
|
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);
|
|
7733
7978
|
return t || n ? e.sequential : r[0] !== r[1] && r === r.slice(0, 2).repeat(3) ? e.alternatingPattern : null;
|
|
7734
7979
|
}
|
|
7735
|
-
function
|
|
7980
|
+
function Xn(r) {
|
|
7736
7981
|
const e = Math.max(0, Math.ceil(r / 1e3)), s = Math.floor(e / 3600), t = Math.floor(e % 3600 / 60), n = e % 60;
|
|
7737
7982
|
return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
|
|
7738
7983
|
}
|
|
7739
|
-
function
|
|
7740
|
-
var
|
|
7984
|
+
function at(r, e, s, t, n, o) {
|
|
7985
|
+
var H, z;
|
|
7741
7986
|
let i = !!(o && o > Date.now()), a = !1;
|
|
7742
|
-
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((
|
|
7743
|
-
i =
|
|
7744
|
-
|
|
7987
|
+
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) => {
|
|
7988
|
+
i = k, c().forEach((b) => {
|
|
7989
|
+
b.disabled = k, b.classList.toggle("--locked", k);
|
|
7745
7990
|
});
|
|
7746
|
-
}, y = () => {
|
|
7747
|
-
const
|
|
7748
|
-
|
|
7749
|
-
},
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7991
|
+
}, y = () => r.querySelector("#__crossx-pin6-attempt"), R = () => {
|
|
7992
|
+
const k = u();
|
|
7993
|
+
k && (k.textContent = "");
|
|
7994
|
+
}, N = (k, b) => {
|
|
7995
|
+
var I;
|
|
7996
|
+
let S = y();
|
|
7997
|
+
if (!S) {
|
|
7998
|
+
S = document.createElement("p"), S.className = "__crossx-pin6-attempt", S.id = "__crossx-pin6-attempt";
|
|
7999
|
+
const x = u();
|
|
8000
|
+
x ? x.insertAdjacentElement("afterend", S) : (I = f()) == null || I.appendChild(S);
|
|
8001
|
+
}
|
|
8002
|
+
S.textContent = `${k}/${b}`;
|
|
8003
|
+
}, F = () => {
|
|
8004
|
+
const k = y();
|
|
8005
|
+
k && (k.textContent = "");
|
|
8006
|
+
}, M = (k) => {
|
|
8007
|
+
const b = u();
|
|
8008
|
+
b && (b.textContent = k);
|
|
8009
|
+
const S = l();
|
|
8010
|
+
S == null || S.classList.add("--shake"), setTimeout(() => S == null ? void 0 : S.classList.remove("--shake"), 500), c().forEach((I) => {
|
|
8011
|
+
I.value = "";
|
|
7755
8012
|
}), setTimeout(() => {
|
|
7756
|
-
var
|
|
7757
|
-
return (
|
|
8013
|
+
var I;
|
|
8014
|
+
return (I = c()[0]) == null ? void 0 : I.focus();
|
|
7758
8015
|
}, 50);
|
|
7759
|
-
},
|
|
7760
|
-
var
|
|
7761
|
-
|
|
7762
|
-
|
|
8016
|
+
}, V = (k) => {
|
|
8017
|
+
var g;
|
|
8018
|
+
E(!0), c().forEach((v) => {
|
|
8019
|
+
v.value = "";
|
|
7763
8020
|
});
|
|
7764
|
-
const
|
|
7765
|
-
if (
|
|
7766
|
-
const
|
|
7767
|
-
|
|
7768
|
-
const
|
|
7769
|
-
|
|
7770
|
-
}
|
|
7771
|
-
const
|
|
7772
|
-
var
|
|
7773
|
-
const
|
|
7774
|
-
|
|
7775
|
-
var
|
|
7776
|
-
return (
|
|
7777
|
-
}, 50)) :
|
|
7778
|
-
},
|
|
7779
|
-
|
|
7780
|
-
const
|
|
7781
|
-
document.contains(r) || (clearInterval(
|
|
8021
|
+
const b = u();
|
|
8022
|
+
if (b && (b.textContent = "Too many failed attempts. Please wait."), !h()) {
|
|
8023
|
+
const v = document.createElement("p");
|
|
8024
|
+
v.className = "__crossx-pin6-lock-msg", v.id = "__crossx-pin6-lock-msg", v.innerHTML = `${Ds}<span id="__crossx-pin6-lock-countdown"></span>`;
|
|
8025
|
+
const A = u();
|
|
8026
|
+
A ? A.insertAdjacentElement("afterend", v) : (g = f()) == null || g.appendChild(v);
|
|
8027
|
+
}
|
|
8028
|
+
const S = () => {
|
|
8029
|
+
var C;
|
|
8030
|
+
const v = k - Date.now(), A = _();
|
|
8031
|
+
v <= 0 ? (clearInterval(I), E(!1), (C = h()) == null || C.remove(), b && (b.textContent = ""), setTimeout(() => {
|
|
8032
|
+
var O;
|
|
8033
|
+
return (O = c()[0]) == null ? void 0 : O.focus();
|
|
8034
|
+
}, 50)) : A && (A.textContent = ` ${Xn(v)}`);
|
|
8035
|
+
}, I = setInterval(S, 1e3);
|
|
8036
|
+
S();
|
|
8037
|
+
const x = new MutationObserver(() => {
|
|
8038
|
+
document.contains(r) || (clearInterval(I), x.disconnect());
|
|
7782
8039
|
});
|
|
7783
|
-
|
|
7784
|
-
},
|
|
8040
|
+
x.observe(document.body, { childList: !0, subtree: !1 });
|
|
8041
|
+
}, G = async () => {
|
|
7785
8042
|
if (i || a) return;
|
|
7786
|
-
const
|
|
7787
|
-
if (
|
|
7788
|
-
a = !0, c().forEach((
|
|
7789
|
-
|
|
8043
|
+
const k = w();
|
|
8044
|
+
if (k.length === 6) {
|
|
8045
|
+
a = !0, c().forEach((b) => {
|
|
8046
|
+
b.disabled = !0;
|
|
7790
8047
|
});
|
|
7791
8048
|
try {
|
|
7792
8049
|
if (n) {
|
|
7793
|
-
const
|
|
7794
|
-
|
|
8050
|
+
const b = await n(k);
|
|
8051
|
+
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());
|
|
7795
8052
|
} else
|
|
7796
|
-
e(
|
|
7797
|
-
} catch (
|
|
7798
|
-
t && t(
|
|
8053
|
+
e(k);
|
|
8054
|
+
} catch (b) {
|
|
8055
|
+
t && t(b);
|
|
7799
8056
|
} finally {
|
|
7800
|
-
a = !1, i || c().forEach((
|
|
7801
|
-
|
|
8057
|
+
a = !1, i || c().forEach((b) => {
|
|
8058
|
+
b.disabled = !1;
|
|
7802
8059
|
});
|
|
7803
8060
|
}
|
|
7804
8061
|
}
|
|
7805
8062
|
};
|
|
7806
|
-
o && o > Date.now() ?
|
|
7807
|
-
var
|
|
7808
|
-
return (
|
|
8063
|
+
o && o > Date.now() ? V(o) : setTimeout(() => {
|
|
8064
|
+
var k;
|
|
8065
|
+
return (k = c()[0]) == null ? void 0 : k.focus();
|
|
7809
8066
|
}, 100);
|
|
7810
|
-
const
|
|
8067
|
+
const J = () => {
|
|
7811
8068
|
if (i || a) return;
|
|
7812
|
-
const
|
|
7813
|
-
|
|
8069
|
+
const k = c(), b = k.find((S) => !S.value) ?? k[k.length - 1];
|
|
8070
|
+
b == null || b.focus();
|
|
7814
8071
|
};
|
|
7815
|
-
(
|
|
7816
|
-
|
|
7817
|
-
}), (
|
|
7818
|
-
const
|
|
7819
|
-
|
|
7820
|
-
}), c().forEach((
|
|
7821
|
-
|
|
7822
|
-
var
|
|
7823
|
-
const
|
|
7824
|
-
|
|
7825
|
-
}),
|
|
7826
|
-
var
|
|
7827
|
-
if (
|
|
7828
|
-
if (
|
|
7829
|
-
|
|
7830
|
-
else if (
|
|
7831
|
-
const
|
|
7832
|
-
|
|
8072
|
+
(H = l()) == null || H.addEventListener("click", (k) => {
|
|
8073
|
+
k.target.classList.contains("__crossx-pin6-box") || J();
|
|
8074
|
+
}), (z = f()) == null || z.addEventListener("click", (k) => {
|
|
8075
|
+
const b = k.target;
|
|
8076
|
+
b.classList.contains("__crossx-pin6-box") || b.closest("button") || J();
|
|
8077
|
+
}), c().forEach((k, b) => {
|
|
8078
|
+
k.addEventListener("input", () => {
|
|
8079
|
+
var I;
|
|
8080
|
+
const S = k.value.replace(/\D/g, "").slice(-1);
|
|
8081
|
+
k.value = S, R(), S && b < 5 && ((I = c()[b + 1]) == null || I.focus()), w().length === 6 && setTimeout(G, 80);
|
|
8082
|
+
}), k.addEventListener("keydown", (S) => {
|
|
8083
|
+
var I, x;
|
|
8084
|
+
if (S.key === "Backspace") {
|
|
8085
|
+
if (S.preventDefault(), k.value)
|
|
8086
|
+
k.value = "";
|
|
8087
|
+
else if (b > 0) {
|
|
8088
|
+
const g = c()[b - 1];
|
|
8089
|
+
g.value = "", g.focus();
|
|
7833
8090
|
}
|
|
7834
|
-
} else
|
|
7835
|
-
}),
|
|
7836
|
-
var
|
|
7837
|
-
|
|
7838
|
-
const
|
|
7839
|
-
if (!
|
|
7840
|
-
const
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
}), (
|
|
7844
|
-
}),
|
|
8091
|
+
} 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();
|
|
8092
|
+
}), k.addEventListener("paste", (S) => {
|
|
8093
|
+
var g, v;
|
|
8094
|
+
S.preventDefault();
|
|
8095
|
+
const I = (((g = S.clipboardData) == null ? void 0 : g.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
|
|
8096
|
+
if (!I) return;
|
|
8097
|
+
const x = c();
|
|
8098
|
+
I.split("").forEach((A, C) => {
|
|
8099
|
+
x[C] && (x[C].value = A);
|
|
8100
|
+
}), (v = x[Math.min(I.length - 1, 5)]) == null || v.focus(), R(), w().length === 6 && setTimeout(G, 80);
|
|
8101
|
+
}), k.addEventListener("focus", () => k.select());
|
|
7845
8102
|
});
|
|
7846
8103
|
}
|
|
7847
|
-
const
|
|
8104
|
+
const Ds = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7848
8105
|
<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"/>
|
|
7849
|
-
</svg>`,
|
|
8106
|
+
</svg>`, Jn = `<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7850
8107
|
<path d="M1 4.5L4 7.5L10 1" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7851
|
-
</svg>`,
|
|
8108
|
+
</svg>`, Zn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7852
8109
|
<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"/>
|
|
7853
8110
|
</svg>`;
|
|
7854
|
-
function
|
|
8111
|
+
function Qn(r, e, s) {
|
|
7855
8112
|
var o;
|
|
7856
8113
|
const t = r.querySelectorAll(".__crossx-pin-input");
|
|
7857
8114
|
t.forEach((i, a) => {
|
|
@@ -7884,12 +8141,12 @@ function Xn(r, e, s) {
|
|
|
7884
8141
|
}
|
|
7885
8142
|
}), (o = t[0]) == null || o.focus();
|
|
7886
8143
|
}
|
|
7887
|
-
class
|
|
8144
|
+
class eo {
|
|
7888
8145
|
constructor(e = "light", s) {
|
|
7889
|
-
this.theme = e, this.overrides = s, this.tokens =
|
|
8146
|
+
this.theme = e, this.overrides = s, this.tokens = Zt(e, s);
|
|
7890
8147
|
}
|
|
7891
8148
|
setTheme(e, s) {
|
|
7892
|
-
this.theme = e, s !== void 0 && (this.overrides = s), this.tokens =
|
|
8149
|
+
this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = Zt(e, this.overrides);
|
|
7893
8150
|
}
|
|
7894
8151
|
setMessages(e) {
|
|
7895
8152
|
this.messages = e;
|
|
@@ -7904,13 +8161,13 @@ class Zn {
|
|
|
7904
8161
|
*/
|
|
7905
8162
|
showWalletSelector(e, s, t) {
|
|
7906
8163
|
return new Promise((n) => {
|
|
7907
|
-
var
|
|
8164
|
+
var E;
|
|
7908
8165
|
he();
|
|
7909
|
-
const o = [...e], i =
|
|
7910
|
-
|
|
8166
|
+
const o = [...e], i = Hn(o, this.tokens, t), a = nt();
|
|
8167
|
+
pe(i);
|
|
7911
8168
|
let c = !1;
|
|
7912
8169
|
const l = () => {
|
|
7913
|
-
c || (c = !0, i.remove(),
|
|
8170
|
+
c || (c = !0, i.remove(), a());
|
|
7914
8171
|
}, u = (y) => {
|
|
7915
8172
|
l(), n(y);
|
|
7916
8173
|
}, h = () => {
|
|
@@ -7919,8 +8176,8 @@ class Zn {
|
|
|
7919
8176
|
(() => {
|
|
7920
8177
|
i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
|
|
7921
8178
|
y.addEventListener("click", () => {
|
|
7922
|
-
const
|
|
7923
|
-
u({ address:
|
|
8179
|
+
const R = y.dataset.walletAddress ?? "", N = parseInt(y.dataset.walletIndex ?? "0", 10);
|
|
8180
|
+
u({ address: R, index: N });
|
|
7924
8181
|
});
|
|
7925
8182
|
});
|
|
7926
8183
|
})();
|
|
@@ -7930,16 +8187,16 @@ class Zn {
|
|
|
7930
8187
|
try {
|
|
7931
8188
|
const y = await s();
|
|
7932
8189
|
o.push(y);
|
|
7933
|
-
const
|
|
7934
|
-
if (
|
|
8190
|
+
const R = i.querySelector("#__crossx-wallet-list");
|
|
8191
|
+
if (R) {
|
|
7935
8192
|
const N = document.createElement("button");
|
|
7936
|
-
N.className = "__crossx-wallet-item", N.dataset.walletIndex = String(y.index), N.dataset.walletAddress = y.address, N.innerHTML = `<span class="__crossx-wallet-addr">${
|
|
8193
|
+
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" });
|
|
7937
8194
|
}
|
|
7938
8195
|
} catch {
|
|
7939
8196
|
} finally {
|
|
7940
8197
|
f.disabled = !1;
|
|
7941
8198
|
}
|
|
7942
|
-
}), (
|
|
8199
|
+
}), (E = i.querySelector("#__crossx-close-btn")) == null || E.addEventListener("click", h), i.addEventListener("click", (y) => {
|
|
7943
8200
|
y.target === i && h();
|
|
7944
8201
|
});
|
|
7945
8202
|
const w = (y) => {
|
|
@@ -7958,7 +8215,7 @@ class Zn {
|
|
|
7958
8215
|
return new Promise((s) => {
|
|
7959
8216
|
var c, l, u, h;
|
|
7960
8217
|
he();
|
|
7961
|
-
const t =
|
|
8218
|
+
const t = Wn(this.tokens, e == null ? void 0 : e.showConnectOtherWallets);
|
|
7962
8219
|
pe(t);
|
|
7963
8220
|
const n = () => t.remove(), o = (_) => {
|
|
7964
8221
|
n(), s(_);
|
|
@@ -7986,7 +8243,7 @@ class Zn {
|
|
|
7986
8243
|
return new Promise((t) => {
|
|
7987
8244
|
var a, c, l;
|
|
7988
8245
|
he();
|
|
7989
|
-
const n =
|
|
8246
|
+
const n = qn(this.tokens, s);
|
|
7990
8247
|
pe(n);
|
|
7991
8248
|
const o = () => n.remove(), i = () => {
|
|
7992
8249
|
o(), t("recover");
|
|
@@ -8032,11 +8289,11 @@ class Zn {
|
|
|
8032
8289
|
}, i = {
|
|
8033
8290
|
title: (t == null ? void 0 : t.pinSetup_confirmTitle) ?? "Confirm PIN",
|
|
8034
8291
|
headerSubtitle: (t == null ? void 0 : t.pinSetup_confirmSubtitle) ?? "Enter your PIN again to confirm."
|
|
8035
|
-
}, a =
|
|
8036
|
-
|
|
8292
|
+
}, a = es(this.tokens, Yn(n)), c = nt();
|
|
8293
|
+
pe(a);
|
|
8037
8294
|
let l = !1;
|
|
8038
8295
|
const u = () => {
|
|
8039
|
-
l || (l = !0, a.remove(),
|
|
8296
|
+
l || (l = !0, a.remove(), c());
|
|
8040
8297
|
}, h = (N) => {
|
|
8041
8298
|
u(), s(N);
|
|
8042
8299
|
}, _ = () => {
|
|
@@ -8047,64 +8304,64 @@ class Zn {
|
|
|
8047
8304
|
repeatingDigit: (t == null ? void 0 : t.pinValidation_repeatingDigit) ?? "Cannot use the same number 3+ times in a row.",
|
|
8048
8305
|
sequential: (t == null ? void 0 : t.pinValidation_sequential) ?? "Sequential numbers (e.g., 123456) are not allowed.",
|
|
8049
8306
|
alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
|
|
8050
|
-
},
|
|
8051
|
-
var
|
|
8052
|
-
f.innerHTML =
|
|
8307
|
+
}, E = (N) => {
|
|
8308
|
+
var F;
|
|
8309
|
+
f.innerHTML = it({
|
|
8053
8310
|
title: i.title,
|
|
8054
8311
|
headerSubtitle: i.headerSubtitle
|
|
8055
|
-
}), (
|
|
8056
|
-
|
|
8312
|
+
}), (F = f.querySelector("#__crossx-close-btn")) == null || F.addEventListener("click", _), at(f, (M) => {
|
|
8313
|
+
M === N ? h(N) : y(o.mismatchError);
|
|
8057
8314
|
}, _);
|
|
8058
8315
|
}, y = (N) => {
|
|
8059
|
-
var
|
|
8060
|
-
f.innerHTML =
|
|
8316
|
+
var F;
|
|
8317
|
+
f.innerHTML = it({
|
|
8061
8318
|
title: o.title,
|
|
8062
8319
|
headerSubtitle: o.headerSubtitle,
|
|
8063
8320
|
subtitle: o.subtitle,
|
|
8064
8321
|
errorMessage: N
|
|
8065
|
-
}), (
|
|
8066
|
-
const
|
|
8067
|
-
|
|
8322
|
+
}), (F = f.querySelector("#__crossx-close-btn")) == null || F.addEventListener("click", _), at(f, (M) => {
|
|
8323
|
+
const V = jn(M, w);
|
|
8324
|
+
V ? y(V) : E(M);
|
|
8068
8325
|
}, _);
|
|
8069
8326
|
};
|
|
8070
8327
|
(() => {
|
|
8071
|
-
var
|
|
8072
|
-
const N = Array.from(f.querySelectorAll(".__crossx-pw-notice-item")),
|
|
8073
|
-
|
|
8074
|
-
const
|
|
8075
|
-
const
|
|
8076
|
-
|
|
8077
|
-
},
|
|
8078
|
-
if (
|
|
8079
|
-
const I =
|
|
8080
|
-
|
|
8081
|
-
},
|
|
8082
|
-
if (!
|
|
8083
|
-
const I =
|
|
8084
|
-
|
|
8328
|
+
var k;
|
|
8329
|
+
const N = Array.from(f.querySelectorAll(".__crossx-pw-notice-item")), F = f.querySelector("#__crossx-pin-notice-next"), M = /* @__PURE__ */ new Set();
|
|
8330
|
+
F.removeAttribute("disabled");
|
|
8331
|
+
const V = F.dataset.nextLabel ?? "Next", G = F.dataset.submitLabel ?? "I Understand", J = () => {
|
|
8332
|
+
const b = M.size === N.length;
|
|
8333
|
+
F.classList.toggle("--disabled", !b), F.textContent = b ? G : V;
|
|
8334
|
+
}, H = (b, S) => {
|
|
8335
|
+
if (M.has(S)) return;
|
|
8336
|
+
const I = b.querySelector(`#__crossx-notice-check-${S}`);
|
|
8337
|
+
M.add(S), I.classList.add("--checked"), b.setAttribute("aria-checked", "true"), J();
|
|
8338
|
+
}, z = (b, S) => {
|
|
8339
|
+
if (!M.has(S)) return;
|
|
8340
|
+
const I = b.querySelector(`#__crossx-notice-check-${S}`);
|
|
8341
|
+
M.delete(S), I.classList.remove("--checked"), b.setAttribute("aria-checked", "false"), J();
|
|
8085
8342
|
};
|
|
8086
|
-
N.forEach((
|
|
8087
|
-
const
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
}),
|
|
8091
|
-
(I.key === " " || I.key === "Enter") && (I.preventDefault(),
|
|
8343
|
+
N.forEach((b) => {
|
|
8344
|
+
const S = parseInt(b.dataset.checkIndex ?? "0", 10);
|
|
8345
|
+
b.addEventListener("click", () => {
|
|
8346
|
+
M.has(S) ? z(b, S) : H(b, S);
|
|
8347
|
+
}), b.addEventListener("keydown", (I) => {
|
|
8348
|
+
(I.key === " " || I.key === "Enter") && (I.preventDefault(), M.has(S) ? z(b, S) : H(b, S));
|
|
8092
8349
|
});
|
|
8093
|
-
}),
|
|
8094
|
-
if (
|
|
8350
|
+
}), F.addEventListener("click", () => {
|
|
8351
|
+
if (M.size === N.length) {
|
|
8095
8352
|
y(e == null ? void 0 : e.errorMessage);
|
|
8096
8353
|
return;
|
|
8097
8354
|
}
|
|
8098
|
-
const
|
|
8355
|
+
const b = N.find((I) => {
|
|
8099
8356
|
const x = parseInt(I.dataset.checkIndex ?? "0", 10);
|
|
8100
|
-
return !
|
|
8357
|
+
return !M.has(x);
|
|
8101
8358
|
});
|
|
8102
|
-
if (!
|
|
8103
|
-
const
|
|
8104
|
-
|
|
8105
|
-
|
|
8359
|
+
if (!b) return;
|
|
8360
|
+
const S = parseInt(b.dataset.checkIndex ?? "0", 10);
|
|
8361
|
+
b.scrollIntoView({ behavior: "smooth", block: "nearest" }), b.classList.add("--highlight"), setTimeout(() => {
|
|
8362
|
+
b.classList.remove("--highlight"), H(b, S);
|
|
8106
8363
|
}, 400);
|
|
8107
|
-
}), (
|
|
8364
|
+
}), (k = f.querySelector("#__crossx-close-btn")) == null || k.addEventListener("click", _);
|
|
8108
8365
|
})(), a.addEventListener("click", (N) => {
|
|
8109
8366
|
N.target === a && _();
|
|
8110
8367
|
});
|
|
@@ -8119,28 +8376,30 @@ class Zn {
|
|
|
8119
8376
|
return new Promise((s, t) => {
|
|
8120
8377
|
var y;
|
|
8121
8378
|
he();
|
|
8122
|
-
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 =
|
|
8379
|
+
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(
|
|
8123
8380
|
this.tokens,
|
|
8124
|
-
|
|
8381
|
+
it({
|
|
8125
8382
|
title: i,
|
|
8126
8383
|
headerSubtitle: a,
|
|
8127
8384
|
errorMessage: e == null ? void 0 : e.errorMessage,
|
|
8128
|
-
lockExpiresAt: e == null ? void 0 : e.lockExpiresAt
|
|
8385
|
+
lockExpiresAt: e == null ? void 0 : e.lockExpiresAt,
|
|
8386
|
+
attemptCount: e == null ? void 0 : e.attemptCount,
|
|
8387
|
+
maxAttempts: e == null ? void 0 : e.maxAttempts
|
|
8129
8388
|
})
|
|
8130
|
-
), l =
|
|
8131
|
-
|
|
8389
|
+
), l = nt();
|
|
8390
|
+
pe(c);
|
|
8132
8391
|
let u = !1;
|
|
8133
8392
|
const h = () => {
|
|
8134
|
-
u || (u = !0, c.remove(),
|
|
8135
|
-
}, _ = (
|
|
8136
|
-
h(), s(
|
|
8393
|
+
u || (u = !0, c.remove(), l());
|
|
8394
|
+
}, _ = (R) => {
|
|
8395
|
+
h(), s(R);
|
|
8137
8396
|
}, f = () => {
|
|
8138
8397
|
h(), s(null);
|
|
8139
|
-
}, w = (
|
|
8140
|
-
h(), t(
|
|
8141
|
-
},
|
|
8142
|
-
(y =
|
|
8143
|
-
|
|
8398
|
+
}, w = (R) => {
|
|
8399
|
+
h(), t(R);
|
|
8400
|
+
}, E = c.querySelector(".__crossx-card");
|
|
8401
|
+
(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) => {
|
|
8402
|
+
R.target === c && f();
|
|
8144
8403
|
});
|
|
8145
8404
|
});
|
|
8146
8405
|
}
|
|
@@ -8155,14 +8414,14 @@ class Zn {
|
|
|
8155
8414
|
return new Promise((s) => {
|
|
8156
8415
|
var a;
|
|
8157
8416
|
he();
|
|
8158
|
-
const t =
|
|
8417
|
+
const t = Kn(this.tokens, e);
|
|
8159
8418
|
pe(t);
|
|
8160
8419
|
const n = () => t.remove(), o = (c) => {
|
|
8161
8420
|
n(), s(c);
|
|
8162
8421
|
}, i = () => {
|
|
8163
8422
|
n(), s(null);
|
|
8164
8423
|
};
|
|
8165
|
-
|
|
8424
|
+
Qn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
|
|
8166
8425
|
c.target === t && i();
|
|
8167
8426
|
});
|
|
8168
8427
|
});
|
|
@@ -8177,7 +8436,7 @@ class Zn {
|
|
|
8177
8436
|
return new Promise((t) => {
|
|
8178
8437
|
var l;
|
|
8179
8438
|
he();
|
|
8180
|
-
const { overlay: n, startCountdown: o } =
|
|
8439
|
+
const { overlay: n, startCountdown: o } = zn(this.tokens, e, s);
|
|
8181
8440
|
pe(n);
|
|
8182
8441
|
const i = () => {
|
|
8183
8442
|
c(), n.remove();
|
|
@@ -8197,7 +8456,7 @@ class Zn {
|
|
|
8197
8456
|
return new Promise((s) => {
|
|
8198
8457
|
var a, c;
|
|
8199
8458
|
he();
|
|
8200
|
-
const t =
|
|
8459
|
+
const t = Ln(e, this.tokens);
|
|
8201
8460
|
pe(t);
|
|
8202
8461
|
const n = () => t.remove(), o = () => {
|
|
8203
8462
|
n(), s();
|
|
@@ -8226,7 +8485,7 @@ class Zn {
|
|
|
8226
8485
|
showTransactionProgress(e, s) {
|
|
8227
8486
|
return new Promise((t) => {
|
|
8228
8487
|
he();
|
|
8229
|
-
const n =
|
|
8488
|
+
const n = Dn(e, this.tokens);
|
|
8230
8489
|
pe(n);
|
|
8231
8490
|
const o = () => n.remove();
|
|
8232
8491
|
let i = !1;
|
|
@@ -8243,7 +8502,7 @@ class Zn {
|
|
|
8243
8502
|
document.addEventListener("keydown", l);
|
|
8244
8503
|
};
|
|
8245
8504
|
s.then((l) => {
|
|
8246
|
-
i || (
|
|
8505
|
+
i || (Mn(n, l, this.tokens), c());
|
|
8247
8506
|
});
|
|
8248
8507
|
});
|
|
8249
8508
|
}
|
|
@@ -8252,7 +8511,7 @@ class Zn {
|
|
|
8252
8511
|
var c, l, u;
|
|
8253
8512
|
he();
|
|
8254
8513
|
let t;
|
|
8255
|
-
e.type === "sign-message" ? t =
|
|
8514
|
+
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);
|
|
8256
8515
|
const n = () => t.remove(), o = () => {
|
|
8257
8516
|
n(), s(!0);
|
|
8258
8517
|
}, i = () => {
|
|
@@ -8276,7 +8535,7 @@ class Zn {
|
|
|
8276
8535
|
});
|
|
8277
8536
|
}
|
|
8278
8537
|
}
|
|
8279
|
-
class
|
|
8538
|
+
class to {
|
|
8280
8539
|
constructor() {
|
|
8281
8540
|
this._accessToken = null, this._expiresAt = 0;
|
|
8282
8541
|
}
|
|
@@ -8308,9 +8567,9 @@ class Qn {
|
|
|
8308
8567
|
return !this._accessToken || this._expiresAt <= 0 ? !0 : Date.now() >= this._expiresAt - e;
|
|
8309
8568
|
}
|
|
8310
8569
|
}
|
|
8311
|
-
function
|
|
8570
|
+
function lo(r, e) {
|
|
8312
8571
|
r.debug;
|
|
8313
|
-
const s =
|
|
8572
|
+
const s = We.production, t = {
|
|
8314
8573
|
...r,
|
|
8315
8574
|
oauthServiceUrl: s.oauthServiceUrl,
|
|
8316
8575
|
authApiUrl: s.authApiUrl,
|
|
@@ -8318,22 +8577,22 @@ function ao(r, e) {
|
|
|
8318
8577
|
}, n = {
|
|
8319
8578
|
gatewayUrl: s.walletGatewayUrl,
|
|
8320
8579
|
projectId: r.projectId
|
|
8321
|
-
}, o = t.authMode !== "cookie" &&
|
|
8580
|
+
}, o = t.authMode !== "cookie" && Lt.isAvailable();
|
|
8322
8581
|
!o && t.authMode !== "cookie" && d.warn(
|
|
8323
8582
|
"[CROSSx] IndexedDB 사용 불가 — LocalStorage fallback 사용 중.",
|
|
8324
8583
|
"refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
|
|
8325
8584
|
"IndexedDB를 지원하는 브라우저 사용을 권장합니다."
|
|
8326
8585
|
), t.secureStorageAvailable = o;
|
|
8327
|
-
const i = o ? new
|
|
8586
|
+
const i = o ? new Lt(r.projectId) : new or(), a = new fn(), c = new mn(), l = new Ie(), u = new to(), h = new ss();
|
|
8328
8587
|
let _;
|
|
8329
|
-
r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), _ = new
|
|
8588
|
+
r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), _ = new yn(i, h)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), _ = new ke(
|
|
8330
8589
|
n,
|
|
8331
8590
|
i,
|
|
8332
8591
|
c,
|
|
8333
8592
|
u,
|
|
8334
8593
|
h
|
|
8335
8594
|
));
|
|
8336
|
-
const f = new
|
|
8595
|
+
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(
|
|
8337
8596
|
t,
|
|
8338
8597
|
n,
|
|
8339
8598
|
i,
|
|
@@ -8342,15 +8601,15 @@ function ao(r, e) {
|
|
|
8342
8601
|
l,
|
|
8343
8602
|
_,
|
|
8344
8603
|
u,
|
|
8345
|
-
|
|
8604
|
+
E,
|
|
8346
8605
|
f,
|
|
8347
8606
|
h
|
|
8348
8607
|
);
|
|
8349
8608
|
return typeof window < "u" && (window.__crossxSDK = y), y;
|
|
8350
8609
|
}
|
|
8351
|
-
function
|
|
8352
|
-
const e =
|
|
8353
|
-
|
|
8610
|
+
function uo(r) {
|
|
8611
|
+
const e = so(r), s = ro(e), t = JSON.parse(s);
|
|
8612
|
+
oo(t);
|
|
8354
8613
|
const { data: n } = t;
|
|
8355
8614
|
return {
|
|
8356
8615
|
status: t.status,
|
|
@@ -8364,7 +8623,7 @@ function co(r) {
|
|
|
8364
8623
|
raw: t
|
|
8365
8624
|
};
|
|
8366
8625
|
}
|
|
8367
|
-
function
|
|
8626
|
+
function so(r) {
|
|
8368
8627
|
if (r.includes("://") && r.includes("?")) {
|
|
8369
8628
|
const e = new URL(r), s = e.searchParams.get("crossx_oauth_result");
|
|
8370
8629
|
if (s) return s;
|
|
@@ -8374,22 +8633,22 @@ function eo(r) {
|
|
|
8374
8633
|
}
|
|
8375
8634
|
return r;
|
|
8376
8635
|
}
|
|
8377
|
-
function
|
|
8636
|
+
function ro(r) {
|
|
8378
8637
|
if (r.startsWith("{"))
|
|
8379
8638
|
return r;
|
|
8380
8639
|
if (r.startsWith("%7B") || r.startsWith("%7b"))
|
|
8381
8640
|
return decodeURIComponent(r);
|
|
8382
|
-
const e =
|
|
8641
|
+
const e = no(r);
|
|
8383
8642
|
return decodeURIComponent(e);
|
|
8384
8643
|
}
|
|
8385
|
-
function
|
|
8644
|
+
function no(r) {
|
|
8386
8645
|
if (typeof atob == "function")
|
|
8387
8646
|
return atob(r);
|
|
8388
8647
|
if (typeof Buffer < "u")
|
|
8389
8648
|
return Buffer.from(r, "base64").toString("utf-8");
|
|
8390
8649
|
throw new Error("Base64 디코딩을 지원하는 환경이 아닙니다");
|
|
8391
8650
|
}
|
|
8392
|
-
function
|
|
8651
|
+
function oo(r) {
|
|
8393
8652
|
if (typeof r != "object" || r === null)
|
|
8394
8653
|
throw new Error("Deeplink payload가 유효한 객체가 아닙니다");
|
|
8395
8654
|
const e = r;
|
|
@@ -8407,12 +8666,12 @@ function ro(r) {
|
|
|
8407
8666
|
}
|
|
8408
8667
|
export {
|
|
8409
8668
|
m as CROSSxError,
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8669
|
+
Ws as CROSSxEthereumProvider,
|
|
8670
|
+
ct as CROSSxSDK,
|
|
8671
|
+
co as ChainId,
|
|
8413
8672
|
p as ErrorCode,
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8673
|
+
ss as PinMemoryStore,
|
|
8674
|
+
to as TokenMemoryStore,
|
|
8675
|
+
lo as createCROSSxSDK,
|
|
8676
|
+
uo as parseOAuthDeeplink
|
|
8418
8677
|
};
|