@nexus-cross/crossx-sdk-core 1.0.7 → 1.0.8
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 +3 -0
- package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts.map +1 -1
- package/dist/core/config/environments.d.ts.map +1 -1
- package/dist/core/i18n/index.d.ts +14 -0
- package/dist/core/i18n/index.d.ts.map +1 -0
- package/dist/core/i18n/messages.en.d.ts +4 -0
- package/dist/core/i18n/messages.en.d.ts.map +1 -0
- package/dist/core/i18n/messages.ko.d.ts +4 -0
- package/dist/core/i18n/messages.ko.d.ts.map +1 -0
- package/dist/core/i18n/types.d.ts +31 -0
- package/dist/core/i18n/types.d.ts.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/ports/ConfirmationPort.d.ts +6 -0
- package/dist/core/ports/ConfirmationPort.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +8 -0
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/index.cjs +30 -30
- package/dist/index.js +487 -390
- package/dist/sdk/CROSSxSDK.d.ts +11 -0
- package/dist/sdk/CROSSxSDK.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var v = (r, e, s) =>
|
|
4
|
-
import { decodeJwt as
|
|
1
|
+
var As = Object.defineProperty;
|
|
2
|
+
var Rs = (r, e, s) => e in r ? As(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
|
|
3
|
+
var v = (r, e, s) => Rs(r, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import { decodeJwt as Os } from "jose";
|
|
5
5
|
var g = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(g || {});
|
|
6
6
|
class x extends Error {
|
|
7
7
|
constructor(e, s, t) {
|
|
@@ -65,20 +65,20 @@ const We = {
|
|
|
65
65
|
rpcUrl: "https://saigon-testnet.roninchain.com/rpc",
|
|
66
66
|
testnet: !0
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, Un = Object.fromEntries(
|
|
69
69
|
Object.entries(We).map(([r, e]) => [r, e.caipId])
|
|
70
|
-
),
|
|
70
|
+
), Cs = new Map(
|
|
71
71
|
Object.values(We).map((r) => [r.caipId, r])
|
|
72
72
|
);
|
|
73
73
|
new Map(
|
|
74
74
|
Object.values(We).map((r) => [r.chainId, r])
|
|
75
75
|
);
|
|
76
|
-
const
|
|
76
|
+
const ks = { symbol: "", decimals: 18 };
|
|
77
77
|
function ze(r) {
|
|
78
78
|
var e;
|
|
79
|
-
return ((e =
|
|
79
|
+
return ((e = Cs.get(r)) == null ? void 0 : e.nativeCurrency) ?? ks;
|
|
80
80
|
}
|
|
81
|
-
class
|
|
81
|
+
class Ns {
|
|
82
82
|
constructor(e, s) {
|
|
83
83
|
this.sdk = e, this.chainId = s, this._listeners = /* @__PURE__ */ new Map();
|
|
84
84
|
}
|
|
@@ -108,7 +108,7 @@ class Cs {
|
|
|
108
108
|
case "eth_sign":
|
|
109
109
|
throw new x(
|
|
110
110
|
g.NOT_IMPLEMENTED,
|
|
111
|
-
`${e}
|
|
111
|
+
`${e}은(는) 아직 지원되지 않습니다. sdk.signMessage()를 직접 사용하세요.`
|
|
112
112
|
);
|
|
113
113
|
case "eth_signTypedData":
|
|
114
114
|
case "eth_signTypedData_v1":
|
|
@@ -116,7 +116,7 @@ class Cs {
|
|
|
116
116
|
case "eth_signTypedData_v4":
|
|
117
117
|
throw new x(
|
|
118
118
|
g.NOT_IMPLEMENTED,
|
|
119
|
-
`${e}
|
|
119
|
+
`${e}은(는) 아직 지원되지 않습니다. sdk.signTypedData() 또는 sdk.signTypedDataOffchain()을 직접 사용하세요.`
|
|
120
120
|
);
|
|
121
121
|
default:
|
|
122
122
|
return this.sdk.walletRpc(e, s, this.chainId);
|
|
@@ -187,8 +187,83 @@ const p = {
|
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
},
|
|
191
|
-
|
|
190
|
+
}, Ps = {
|
|
191
|
+
// ── 공통 버튼 ────────────────────────────────────────────────
|
|
192
|
+
confirm: "확인",
|
|
193
|
+
cancel: "취소",
|
|
194
|
+
close: "닫기",
|
|
195
|
+
// ── 메시지 서명 모달 ─────────────────────────────────────────
|
|
196
|
+
signMessage_title: "메시지 서명",
|
|
197
|
+
// ── Typed Data 서명 모달 ─────────────────────────────────────
|
|
198
|
+
signTypedData_title: "데이터 서명",
|
|
199
|
+
// ── 트랜잭션 서명 / 전송 모달 ────────────────────────────────
|
|
200
|
+
signTransaction_title: "트랜잭션 서명",
|
|
201
|
+
sendTransaction_title: "트랜잭션 전송",
|
|
202
|
+
// ── 트랜잭션 진행 모달 ───────────────────────────────────────
|
|
203
|
+
tx_pending: "트랜잭션 처리 중...",
|
|
204
|
+
tx_success: "트랜잭션이 완료되었습니다",
|
|
205
|
+
tx_failed: "트랜잭션이 실패했습니다",
|
|
206
|
+
tx_timeout: "트랜잭션 확인 시간이 초과되었습니다",
|
|
207
|
+
// ── 로그인 선택 모달 ─────────────────────────────────────────
|
|
208
|
+
loginSelector_title: "로그인 방법 선택",
|
|
209
|
+
loginSelector_google: "Google로 계속하기",
|
|
210
|
+
loginSelector_apple: "Apple로 계속하기",
|
|
211
|
+
// ── 마이그레이션 모달 ────────────────────────────────────────
|
|
212
|
+
migration_foundTitle: "기존 지갑 발견",
|
|
213
|
+
migration_foundDescription: "기존 CROSSx 지갑이 발견되었습니다. 복구하시겠습니까?",
|
|
214
|
+
migration_recoverButton: "복구하기",
|
|
215
|
+
migration_skipButton: "건너뛰기",
|
|
216
|
+
// ── PIN 입력 모달 ────────────────────────────────────────────
|
|
217
|
+
pinInput_title: "PIN 입력",
|
|
218
|
+
pinInput_placeholder: "4자리 PIN을 입력하세요",
|
|
219
|
+
pinInput_error: "PIN이 올바르지 않습니다. 다시 시도해 주세요.",
|
|
220
|
+
// ── 지갑 선택 모달 ───────────────────────────────────────────
|
|
221
|
+
walletSelector_title: "지갑 선택",
|
|
222
|
+
walletSelector_addButton: "지갑 추가",
|
|
223
|
+
walletSelector_selected: "선택됨"
|
|
224
|
+
}, zt = {
|
|
225
|
+
// ── Common buttons ───────────────────────────────────────────
|
|
226
|
+
confirm: "Confirm",
|
|
227
|
+
cancel: "Cancel",
|
|
228
|
+
close: "Close",
|
|
229
|
+
// ── Sign message modal ───────────────────────────────────────
|
|
230
|
+
signMessage_title: "Sign Message",
|
|
231
|
+
// ── Typed Data sign modal ────────────────────────────────────
|
|
232
|
+
signTypedData_title: "Sign Data",
|
|
233
|
+
// ── Sign / Send transaction modal ────────────────────────────
|
|
234
|
+
signTransaction_title: "Sign Transaction",
|
|
235
|
+
sendTransaction_title: "Send Transaction",
|
|
236
|
+
// ── Transaction progress modal ───────────────────────────────
|
|
237
|
+
tx_pending: "Processing transaction...",
|
|
238
|
+
tx_success: "Transaction completed",
|
|
239
|
+
tx_failed: "Transaction failed",
|
|
240
|
+
tx_timeout: "Transaction confirmation timed out",
|
|
241
|
+
// ── Login selector modal ─────────────────────────────────────
|
|
242
|
+
loginSelector_title: "Choose a sign-in method",
|
|
243
|
+
loginSelector_google: "Continue with Google",
|
|
244
|
+
loginSelector_apple: "Continue with Apple",
|
|
245
|
+
// ── Migration modal ──────────────────────────────────────────
|
|
246
|
+
migration_foundTitle: "Existing Wallet Found",
|
|
247
|
+
migration_foundDescription: "An existing CROSSx wallet was found. Would you like to recover it?",
|
|
248
|
+
migration_recoverButton: "Recover",
|
|
249
|
+
migration_skipButton: "Skip",
|
|
250
|
+
// ── PIN input modal ──────────────────────────────────────────
|
|
251
|
+
pinInput_title: "Enter PIN",
|
|
252
|
+
pinInput_placeholder: "Enter your 4-digit PIN",
|
|
253
|
+
pinInput_error: "Incorrect PIN. Please try again.",
|
|
254
|
+
// ── Wallet selector modal ────────────────────────────────────
|
|
255
|
+
walletSelector_title: "Select Wallet",
|
|
256
|
+
walletSelector_addButton: "Add Wallet",
|
|
257
|
+
walletSelector_selected: "Selected"
|
|
258
|
+
}, Ls = {
|
|
259
|
+
ko: Ps,
|
|
260
|
+
en: zt
|
|
261
|
+
};
|
|
262
|
+
function yt(r = "en", e) {
|
|
263
|
+
return Ls[r] ?? zt;
|
|
264
|
+
}
|
|
265
|
+
const Ye = "crossx_access_token", Ne = "crossx_refresh_token", Pe = "crossx_user_info";
|
|
266
|
+
class Ds {
|
|
192
267
|
constructor(e, s, t, n, o, i, a) {
|
|
193
268
|
this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null;
|
|
194
269
|
}
|
|
@@ -204,7 +279,7 @@ class ks {
|
|
|
204
279
|
if (e != null && e.code && e.code !== 200 && e.code > 0)
|
|
205
280
|
throw new x(
|
|
206
281
|
g.AUTH_FAILED,
|
|
207
|
-
`${s}
|
|
282
|
+
`${s} 실패 (코드 ${e.code}): ${e.message}`
|
|
208
283
|
);
|
|
209
284
|
const t = e == null ? void 0 : e.data;
|
|
210
285
|
if (typeof t == "object" && t !== null && "code" in t) {
|
|
@@ -212,7 +287,7 @@ class ks {
|
|
|
212
287
|
if (n.code && n.code !== 200 && n.code > 0)
|
|
213
288
|
throw new x(
|
|
214
289
|
g.AUTH_FAILED,
|
|
215
|
-
`${s}
|
|
290
|
+
`${s} 실패 (코드 ${n.code}): ${n.message}`
|
|
216
291
|
);
|
|
217
292
|
}
|
|
218
293
|
}
|
|
@@ -233,19 +308,19 @@ class ks {
|
|
|
233
308
|
const { accessToken: m, refreshToken: A } = await this.exchangeFirebaseToken(_, f);
|
|
234
309
|
let y, I;
|
|
235
310
|
try {
|
|
236
|
-
const
|
|
237
|
-
I = (n =
|
|
238
|
-
const $ = ((o =
|
|
311
|
+
const F = this.crypto.decodeJWT(_);
|
|
312
|
+
I = (n = F.firebase) == null ? void 0 : n.sign_in_provider;
|
|
313
|
+
const $ = ((o = F.firebase) == null ? void 0 : o.identities) ?? {};
|
|
239
314
|
I === "google.com" ? y = (i = $["google.com"]) == null ? void 0 : i[0] : I === "apple.com" && (y = (a = $["apple.com"]) == null ? void 0 : a[0]), p.log("[CROSSx] OAuth provider sub 추출 — provider:", I, "hasProviderSub:", !!y);
|
|
240
315
|
} catch {
|
|
241
316
|
p.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
|
|
242
317
|
}
|
|
243
318
|
if (m) {
|
|
244
|
-
const
|
|
245
|
-
p.log("[CROSSx] access_token 디코딩 — sub:",
|
|
319
|
+
const F = this.crypto.decodeJWT(m);
|
|
320
|
+
p.log("[CROSSx] access_token 디코딩 — sub:", F.sub, "exp:", F.exp);
|
|
246
321
|
const $ = await this.crypto.verifyJWT(m);
|
|
247
322
|
if (t = $.signatureVerified ?? !1, !$.valid)
|
|
248
|
-
throw p.error("[CROSSx] access_token 검증 실패"), new Error("
|
|
323
|
+
throw p.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
|
|
249
324
|
const B = $.payload;
|
|
250
325
|
s = {
|
|
251
326
|
id: B.sub,
|
|
@@ -254,10 +329,10 @@ class ks {
|
|
|
254
329
|
providerSub: y
|
|
255
330
|
}, this.tokenStore.set(m), this.useCookieAuth || (await this.storage.set(Ye, m), A && await this.storage.set(Ne, A));
|
|
256
331
|
} else {
|
|
257
|
-
const
|
|
332
|
+
const F = this.crypto.decodeJWT(_);
|
|
258
333
|
s = {
|
|
259
|
-
id:
|
|
260
|
-
email:
|
|
334
|
+
id: F.sub,
|
|
335
|
+
email: F.email,
|
|
261
336
|
signInProvider: I,
|
|
262
337
|
providerSub: y
|
|
263
338
|
}, p.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
|
|
@@ -297,7 +372,7 @@ class ks {
|
|
|
297
372
|
if (!a)
|
|
298
373
|
throw new x(
|
|
299
374
|
g.AUTH_FAILED,
|
|
300
|
-
"
|
|
375
|
+
"토큰 교환 응답에서 access_token을 찾을 수 없습니다"
|
|
301
376
|
);
|
|
302
377
|
p.log("[CROSSx] access_token 교환 성공");
|
|
303
378
|
let c;
|
|
@@ -427,7 +502,7 @@ class ks {
|
|
|
427
502
|
return;
|
|
428
503
|
}
|
|
429
504
|
if (!c)
|
|
430
|
-
throw new x(g.AUTH_FAILED, "
|
|
505
|
+
throw new x(g.AUTH_FAILED, "토큰 자동 갱신 실패: 응답에 토큰이 없습니다");
|
|
431
506
|
if (this.tokenStore.set(c), !t) {
|
|
432
507
|
await this.storage.set(Ye, c);
|
|
433
508
|
const l = this.extractRefreshToken(a);
|
|
@@ -451,16 +526,16 @@ class ks {
|
|
|
451
526
|
return p.log("[CROSSx][Migration Phase 2] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
|
|
452
527
|
}
|
|
453
528
|
}
|
|
454
|
-
const
|
|
455
|
-
class
|
|
529
|
+
const $s = "crossx_access_token", Ms = "crossx_refresh_token", Bs = "crossx_user_info";
|
|
530
|
+
class Fs {
|
|
456
531
|
constructor(e, s, t) {
|
|
457
532
|
this.config = e, this.storage = s, this.tokenStore = t;
|
|
458
533
|
}
|
|
459
534
|
async execute() {
|
|
460
|
-
this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove(
|
|
535
|
+
this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove($s), await this.storage.remove(Ms)), await this.storage.remove(Bs);
|
|
461
536
|
}
|
|
462
537
|
}
|
|
463
|
-
class
|
|
538
|
+
class Us {
|
|
464
539
|
constructor(e, s) {
|
|
465
540
|
this.storage = e, this.walletProvider = s;
|
|
466
541
|
}
|
|
@@ -468,7 +543,7 @@ class $s {
|
|
|
468
543
|
if (!this.walletProvider.migrateWallet)
|
|
469
544
|
throw new x(
|
|
470
545
|
g.NOT_IMPLEMENTED,
|
|
471
|
-
"
|
|
546
|
+
"현재 환경에서는 마이그레이션이 지원되지 않습니다"
|
|
472
547
|
);
|
|
473
548
|
p.log("[CROSSx][Migration Phase 4] MigrateWalletUseCase.execute() — pin 길이:", e.length, "sub:", s);
|
|
474
549
|
const t = await this.walletProvider.migrateWallet(e, s);
|
|
@@ -477,7 +552,7 @@ class $s {
|
|
|
477
552
|
};
|
|
478
553
|
}
|
|
479
554
|
}
|
|
480
|
-
class
|
|
555
|
+
class Hs {
|
|
481
556
|
constructor(e, s) {
|
|
482
557
|
this.chainRegistry = e, this.transport = s;
|
|
483
558
|
}
|
|
@@ -504,12 +579,12 @@ class Ms {
|
|
|
504
579
|
if (a != null && a.error)
|
|
505
580
|
throw new x(
|
|
506
581
|
g.UNKNOWN_ERROR,
|
|
507
|
-
`RPC
|
|
582
|
+
`RPC 오류 [${e}] (${t}): ${a.error.message} (코드: ${a.error.code})`
|
|
508
583
|
);
|
|
509
584
|
return a == null ? void 0 : a.result;
|
|
510
585
|
}
|
|
511
586
|
}
|
|
512
|
-
class
|
|
587
|
+
class Gs {
|
|
513
588
|
constructor() {
|
|
514
589
|
this.listeners = /* @__PURE__ */ new Map();
|
|
515
590
|
}
|
|
@@ -532,11 +607,17 @@ class Bs {
|
|
|
532
607
|
this.listeners.clear();
|
|
533
608
|
}
|
|
534
609
|
}
|
|
535
|
-
const
|
|
610
|
+
const Fe = {
|
|
611
|
+
// TODO(v2.0.0-BEFORE-RELEASE): 아래 블록으로 교체
|
|
612
|
+
// production: {
|
|
613
|
+
// oauthServiceUrl: 'https://cross-wallet-oauth.crosstoken.io',
|
|
614
|
+
// authApiUrl: 'https://cross-auth.crosstoken.io',
|
|
615
|
+
// walletGatewayUrl: 'https://embedded-wallet-gateway.crosstoken.io/api/v1',
|
|
616
|
+
// },
|
|
536
617
|
production: {
|
|
537
|
-
oauthServiceUrl: "https://cross-wallet-oauth.crosstoken.io",
|
|
538
|
-
authApiUrl: "https://cross-auth.crosstoken.io",
|
|
539
|
-
walletGatewayUrl: "https://embedded-wallet-gateway.crosstoken.io/api/v1"
|
|
618
|
+
oauthServiceUrl: "https://stg-cross-wallet-oauth.crosstoken.io",
|
|
619
|
+
authApiUrl: "https://stg-cross-auth.crosstoken.io",
|
|
620
|
+
walletGatewayUrl: "https://stg-embedded-wallet-gateway.crosstoken.io/api/v1"
|
|
540
621
|
},
|
|
541
622
|
staging: {
|
|
542
623
|
oauthServiceUrl: "https://stg-cross-wallet-oauth.crosstoken.io",
|
|
@@ -548,32 +629,32 @@ const Ue = {
|
|
|
548
629
|
authApiUrl: "https://dev-cross-auth.crosstoken.io",
|
|
549
630
|
walletGatewayUrl: "https://dev-embedded-wallet-gateway.crosstoken.io/api/v1"
|
|
550
631
|
}
|
|
551
|
-
},
|
|
552
|
-
function
|
|
632
|
+
}, qs = "/crossx.config.json";
|
|
633
|
+
function bt(r) {
|
|
553
634
|
const e = r.environment;
|
|
554
|
-
return e && e in
|
|
635
|
+
return e && e in Fe ? Fe[e] : null;
|
|
555
636
|
}
|
|
556
|
-
async function
|
|
637
|
+
async function Ws() {
|
|
557
638
|
try {
|
|
558
639
|
if (typeof __CROSSX_CONFIG__ < "u") {
|
|
559
|
-
const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e =
|
|
640
|
+
const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = bt(r);
|
|
560
641
|
if (e) return e;
|
|
561
642
|
}
|
|
562
643
|
} catch {
|
|
563
644
|
}
|
|
564
645
|
try {
|
|
565
|
-
const r = await fetch(
|
|
646
|
+
const r = await fetch(qs);
|
|
566
647
|
if (r.ok) {
|
|
567
|
-
const e = await r.json(), s =
|
|
648
|
+
const e = await r.json(), s = bt(e);
|
|
568
649
|
if (s) return s;
|
|
569
650
|
}
|
|
570
651
|
} catch {
|
|
571
652
|
}
|
|
572
|
-
return
|
|
653
|
+
return Fe.production;
|
|
573
654
|
}
|
|
574
|
-
const
|
|
655
|
+
const js = 2e3, vt = 6e4, Vs = 1e3, Ks = 1e4, zs = "0x77359400", St = "0x3B9ACA00", Et = 130, It = 6, Tt = 18, Ys = 0, Zs = 30 * 1e3, X = class X extends Gs {
|
|
575
656
|
constructor(e, s, t, n, o, i, a, c, l, d) {
|
|
576
|
-
super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this.authenticated = !1, this.userId = null, this.address = null, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && wt(e.logger), this.confirmation = l, this.chainRegistry = d, this.jsonRpc = new
|
|
657
|
+
super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this.authenticated = !1, this.userId = null, this.address = null, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && wt(e.logger), this.confirmation = l, this.chainRegistry = d, this.jsonRpc = new Hs(d, o), this.signInUseCase = new Ds(
|
|
577
658
|
this.internalConfig,
|
|
578
659
|
t,
|
|
579
660
|
n,
|
|
@@ -581,7 +662,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
581
662
|
o,
|
|
582
663
|
a,
|
|
583
664
|
c
|
|
584
|
-
), this.signOutUseCase = new
|
|
665
|
+
), this.signOutUseCase = new Fs(this.internalConfig, t, c), this.migrateWalletUseCase = new Us(t, a);
|
|
585
666
|
}
|
|
586
667
|
get config() {
|
|
587
668
|
return this._config;
|
|
@@ -602,14 +683,14 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
602
683
|
*/
|
|
603
684
|
async initialize() {
|
|
604
685
|
if (this.initialized) return this.authenticated ? { success: !0, address: this.address ?? void 0 } : null;
|
|
605
|
-
console.log("[CROSSx SDK] v1.0.
|
|
686
|
+
console.log("[CROSSx SDK] v1.0.8 초기화 중..."), this.confirmation.setMessages(yt(this._config.locale));
|
|
606
687
|
try {
|
|
607
|
-
const e = await
|
|
688
|
+
const e = await Ws();
|
|
608
689
|
this.internalConfig.oauthServiceUrl = e.oauthServiceUrl, this.internalConfig.authApiUrl = e.authApiUrl, this.internalConfig.walletGatewayUrl = e.walletGatewayUrl, this.adapterConfig.gatewayUrl = e.walletGatewayUrl;
|
|
609
690
|
const s = await this.signInUseCase.restoreSession();
|
|
610
691
|
return s != null && s.success && this.applyAuthResult(s), this.initialized = !0, this.emit("initialized", { restored: !!(s != null && s.success) }), s ?? null;
|
|
611
692
|
} catch (e) {
|
|
612
|
-
throw new x(g.AUTH_NOT_INITIALIZED, "SDK
|
|
693
|
+
throw new x(g.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", e);
|
|
613
694
|
}
|
|
614
695
|
}
|
|
615
696
|
async signIn(e) {
|
|
@@ -625,7 +706,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
625
706
|
const t = await this.signInUseCase.execute(s);
|
|
626
707
|
return t.success && this.applyAuthResult(t), t;
|
|
627
708
|
} catch (t) {
|
|
628
|
-
throw new x(g.AUTH_FAILED, "
|
|
709
|
+
throw new x(g.AUTH_FAILED, "로그인에 실패했습니다", t);
|
|
629
710
|
}
|
|
630
711
|
}
|
|
631
712
|
/**
|
|
@@ -660,7 +741,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
660
741
|
try {
|
|
661
742
|
await this.signOutUseCase.execute(), this.clearAuthState();
|
|
662
743
|
} catch (e) {
|
|
663
|
-
throw new x(g.UNKNOWN_ERROR, "
|
|
744
|
+
throw new x(g.UNKNOWN_ERROR, "로그아웃에 실패했습니다", e);
|
|
664
745
|
}
|
|
665
746
|
}
|
|
666
747
|
isAuthenticated() {
|
|
@@ -736,14 +817,14 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
736
817
|
*/
|
|
737
818
|
async migrateWallet(e) {
|
|
738
819
|
if (this.ensureAuthenticated(), !this.userId)
|
|
739
|
-
throw new x(g.AUTH_NOT_AUTHENTICATED, "
|
|
820
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
740
821
|
try {
|
|
741
822
|
const s = await this.migrateWalletUseCase.execute(e, this.userId);
|
|
742
823
|
return this.address = s.address, this.emit("addressChanged", { address: s.address, index: 0 }), p.log("[CROSSx] migrateWallet 완료 — address:", s.address), s;
|
|
743
824
|
} catch (s) {
|
|
744
825
|
throw s instanceof x ? s : new x(
|
|
745
826
|
g.MIGRATION_FAILED,
|
|
746
|
-
"
|
|
827
|
+
"지갑 마이그레이션에 실패했습니다",
|
|
747
828
|
s
|
|
748
829
|
);
|
|
749
830
|
}
|
|
@@ -763,7 +844,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
763
844
|
async getAddress(e) {
|
|
764
845
|
if (e !== void 0) {
|
|
765
846
|
if (this.ensureAuthenticated(), !this.userId)
|
|
766
|
-
throw new x(g.AUTH_NOT_AUTHENTICATED, "
|
|
847
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
767
848
|
return { address: (await this.walletProvider.getAddress(this.userId, e)).address, index: e };
|
|
768
849
|
}
|
|
769
850
|
return !this.authenticated || !this.address ? null : { address: this.address, index: 0 };
|
|
@@ -798,7 +879,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
798
879
|
*/
|
|
799
880
|
async selectWallet(e) {
|
|
800
881
|
if (this.ensureAuthenticated(), !this.userId)
|
|
801
|
-
throw new x(g.AUTH_NOT_AUTHENTICATED, "
|
|
882
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
802
883
|
const s = await this.walletProvider.getAddresses(this.userId), t = await this.confirmation.showWalletSelector(
|
|
803
884
|
s,
|
|
804
885
|
async () => {
|
|
@@ -837,7 +918,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
837
918
|
try {
|
|
838
919
|
return await this.chainRegistry.getChains();
|
|
839
920
|
} catch (e) {
|
|
840
|
-
throw e instanceof x ? e : new x(g.UNKNOWN_ERROR, "
|
|
921
|
+
throw e instanceof x ? e : new x(g.UNKNOWN_ERROR, "체인 목록 조회에 실패했습니다", e);
|
|
841
922
|
}
|
|
842
923
|
}
|
|
843
924
|
/**
|
|
@@ -856,7 +937,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
856
937
|
try {
|
|
857
938
|
return await this.chainRegistry.getChain(e);
|
|
858
939
|
} catch (s) {
|
|
859
|
-
throw s instanceof x ? s : new x(g.CHAIN_NOT_SUPPORTED,
|
|
940
|
+
throw s instanceof x ? s : new x(g.CHAIN_NOT_SUPPORTED, `체인 조회에 실패했습니다: ${e}`, s);
|
|
860
941
|
}
|
|
861
942
|
}
|
|
862
943
|
// ============================================================================
|
|
@@ -876,13 +957,26 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
876
957
|
applyTheme(e = this._config.theme ?? "light", s = this._config.themeTokens ?? {}) {
|
|
877
958
|
this._config = Object.freeze({ ...this._config, theme: e, themeTokens: s }), this.confirmation.setTheme(e, s);
|
|
878
959
|
}
|
|
960
|
+
/**
|
|
961
|
+
* 모달 UI 언어를 런타임에 변경합니다.
|
|
962
|
+
* 다음 모달이 열릴 때부터 적용됩니다.
|
|
963
|
+
*
|
|
964
|
+
* @param locale 빌트인 언어팩 선택 ('ko' | 'en')
|
|
965
|
+
*
|
|
966
|
+
* @example
|
|
967
|
+
* sdk.applyLocale('en');
|
|
968
|
+
* sdk.applyLocale('ko');
|
|
969
|
+
*/
|
|
970
|
+
applyLocale(e = this._config.locale ?? "en") {
|
|
971
|
+
this._config = Object.freeze({ ...this._config, locale: e }), this.confirmation.setMessages(yt(e));
|
|
972
|
+
}
|
|
879
973
|
/**
|
|
880
974
|
* 지갑 생성 (로그인 후 지갑이 없는 경우)
|
|
881
975
|
* 기존 CROSSx 백업이 발견되면 자동으로 마이그레이션 플로우 실행
|
|
882
976
|
*/
|
|
883
977
|
async createWallet() {
|
|
884
978
|
if (this.ensureAuthenticated(), !this.userId)
|
|
885
|
-
throw new x(g.AUTH_NOT_AUTHENTICATED, "
|
|
979
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
886
980
|
p.log("[CROSSx] 지갑 생성 시작");
|
|
887
981
|
try {
|
|
888
982
|
const e = await this.walletProvider.getOrCreateWallet(this.userId);
|
|
@@ -896,7 +990,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
896
990
|
return this.address = t.address, this.emit("addressChanged", { address: t.address, index: 0 }), { address: t.address };
|
|
897
991
|
throw new x(
|
|
898
992
|
g.MIGRATION_FAILED,
|
|
899
|
-
"
|
|
993
|
+
"사용자가 마이그레이션을 건너뛰었습니다"
|
|
900
994
|
);
|
|
901
995
|
}
|
|
902
996
|
throw e;
|
|
@@ -914,7 +1008,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
914
1008
|
*/
|
|
915
1009
|
async signMessage(e, s, t) {
|
|
916
1010
|
if (this.ensureAuthenticated(), !this.userId)
|
|
917
|
-
throw new x(g.AUTH_NOT_AUTHENTICATED, "
|
|
1011
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
918
1012
|
const n = t == null ? void 0 : t.index, o = await this.walletProvider.getAddress(this.userId, n ?? 0);
|
|
919
1013
|
let i;
|
|
920
1014
|
if (this.walletProvider.prepare && (i = (await this.walletProvider.prepare("sign-message", { message: s, from: o.address })).uuid), !await this.confirmation.requestConfirmation({
|
|
@@ -925,7 +1019,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
925
1019
|
dappName: t == null ? void 0 : t.dappName,
|
|
926
1020
|
accountName: t == null ? void 0 : t.accountName
|
|
927
1021
|
}))
|
|
928
|
-
throw new x(g.USER_REJECTED, "
|
|
1022
|
+
throw new x(g.USER_REJECTED, "사용자가 메시지 서명을 거부했습니다");
|
|
929
1023
|
try {
|
|
930
1024
|
const c = await this.walletProvider.signMessage(
|
|
931
1025
|
this.userId,
|
|
@@ -942,7 +1036,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
942
1036
|
address: o.address
|
|
943
1037
|
};
|
|
944
1038
|
} catch (c) {
|
|
945
|
-
throw c instanceof x ? c : new x(g.SIGNATURE_FAILED,
|
|
1039
|
+
throw c instanceof x ? c : new x(g.SIGNATURE_FAILED, `메시지 서명에 실패했습니다 (${e})`, c);
|
|
946
1040
|
}
|
|
947
1041
|
}
|
|
948
1042
|
/**
|
|
@@ -968,9 +1062,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
968
1062
|
*/
|
|
969
1063
|
async signTypedData(e, s, t) {
|
|
970
1064
|
if (this.ensureAuthenticated(), !this.userId)
|
|
971
|
-
throw new x(g.AUTH_NOT_AUTHENTICATED, "
|
|
1065
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
972
1066
|
if (!this.walletProvider.signTypedData)
|
|
973
|
-
throw new x(g.NOT_IMPLEMENTED, "signTypedData
|
|
1067
|
+
throw new x(g.NOT_IMPLEMENTED, "signTypedData가 구현되어 있지 않습니다");
|
|
974
1068
|
X.validateTypedDataChainId(e, s);
|
|
975
1069
|
const n = await this.walletProvider.getAddress(this.userId, (t == null ? void 0 : t.index) ?? 0);
|
|
976
1070
|
let o;
|
|
@@ -982,7 +1076,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
982
1076
|
dappName: t == null ? void 0 : t.dappName,
|
|
983
1077
|
accountName: t == null ? void 0 : t.accountName
|
|
984
1078
|
}))
|
|
985
|
-
throw new x(g.USER_REJECTED, "
|
|
1079
|
+
throw new x(g.USER_REJECTED, "사용자가 타입 데이터 서명을 거부했습니다");
|
|
986
1080
|
try {
|
|
987
1081
|
const a = await this.walletProvider.signTypedData(
|
|
988
1082
|
this.userId,
|
|
@@ -998,7 +1092,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
998
1092
|
address: n.address
|
|
999
1093
|
};
|
|
1000
1094
|
} catch (a) {
|
|
1001
|
-
throw a instanceof x ? a : new x(g.SIGNATURE_FAILED,
|
|
1095
|
+
throw a instanceof x ? a : new x(g.SIGNATURE_FAILED, `타입 데이터 서명에 실패했습니다 (${e})`, a);
|
|
1002
1096
|
}
|
|
1003
1097
|
}
|
|
1004
1098
|
/**
|
|
@@ -1034,7 +1128,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1034
1128
|
*/
|
|
1035
1129
|
async signTransaction(e, s, t) {
|
|
1036
1130
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1037
|
-
throw new x(g.AUTH_NOT_AUTHENTICATED, "
|
|
1131
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1038
1132
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
1039
1133
|
let o;
|
|
1040
1134
|
this.walletProvider.prepare && (o = (await this.walletProvider.prepare("sign", { tx: n })).uuid);
|
|
@@ -1055,7 +1149,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1055
1149
|
dappName: t == null ? void 0 : t.dappName,
|
|
1056
1150
|
accountName: t == null ? void 0 : t.accountName
|
|
1057
1151
|
}))
|
|
1058
|
-
throw new x(g.USER_REJECTED, "
|
|
1152
|
+
throw new x(g.USER_REJECTED, "사용자가 트랜잭션 서명을 거부했습니다");
|
|
1059
1153
|
try {
|
|
1060
1154
|
const c = await this.walletProvider.signTransaction(
|
|
1061
1155
|
this.userId,
|
|
@@ -1074,7 +1168,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1074
1168
|
const l = c instanceof Error ? c.message : String(c);
|
|
1075
1169
|
throw new x(
|
|
1076
1170
|
g.SIGNATURE_FAILED,
|
|
1077
|
-
|
|
1171
|
+
`트랜잭션 서명에 실패했습니다 (${e}): ${l}`,
|
|
1078
1172
|
c
|
|
1079
1173
|
);
|
|
1080
1174
|
}
|
|
@@ -1087,7 +1181,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1087
1181
|
*/
|
|
1088
1182
|
async sendTransaction(e, s, t) {
|
|
1089
1183
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1090
|
-
throw new x(g.AUTH_NOT_AUTHENTICATED, "
|
|
1184
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1091
1185
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
1092
1186
|
let o;
|
|
1093
1187
|
this.walletProvider.prepare && (o = (await this.walletProvider.prepare("send", { tx: n })).uuid);
|
|
@@ -1108,7 +1202,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1108
1202
|
dappName: t == null ? void 0 : t.dappName,
|
|
1109
1203
|
accountName: t == null ? void 0 : t.accountName
|
|
1110
1204
|
}))
|
|
1111
|
-
throw new x(g.USER_REJECTED, "
|
|
1205
|
+
throw new x(g.USER_REJECTED, "사용자가 트랜잭션을 거부했습니다");
|
|
1112
1206
|
try {
|
|
1113
1207
|
let c;
|
|
1114
1208
|
if (this.walletProvider.sendTransaction)
|
|
@@ -1133,7 +1227,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1133
1227
|
const l = c instanceof Error ? c.message : String(c);
|
|
1134
1228
|
throw new x(
|
|
1135
1229
|
g.TRANSACTION_FAILED,
|
|
1136
|
-
|
|
1230
|
+
`트랜잭션 전송에 실패했습니다 (${e}): ${l}`,
|
|
1137
1231
|
c
|
|
1138
1232
|
);
|
|
1139
1233
|
}
|
|
@@ -1157,7 +1251,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1157
1251
|
* @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
|
|
1158
1252
|
*/
|
|
1159
1253
|
async waitForTxAndGetReceipt(e, s, t = {}) {
|
|
1160
|
-
const n = t.intervalMs ??
|
|
1254
|
+
const n = t.intervalMs ?? Vs, o = Ks, i = t.timeoutMs ?? vt, a = Date.now() + i;
|
|
1161
1255
|
let c = n;
|
|
1162
1256
|
for (; Date.now() < a; ) {
|
|
1163
1257
|
const l = await this.getTransactionReceipt(e, s);
|
|
@@ -1166,7 +1260,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1166
1260
|
}
|
|
1167
1261
|
throw new x(
|
|
1168
1262
|
g.UNKNOWN_ERROR,
|
|
1169
|
-
|
|
1263
|
+
`트랜잭션 영수증 조회 시간이 초과되었습니다 (${e})`
|
|
1170
1264
|
);
|
|
1171
1265
|
}
|
|
1172
1266
|
/**
|
|
@@ -1186,11 +1280,11 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1186
1280
|
*/
|
|
1187
1281
|
async sendTransactionWithWaitForReceipt(e, s, t = {}) {
|
|
1188
1282
|
var A, y;
|
|
1189
|
-
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((A = this._config.receiptPolling) == null ? void 0 : A.intervalMs) ??
|
|
1283
|
+
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((A = this._config.receiptPolling) == null ? void 0 : A.intervalMs) ?? js, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? vt, d = ze(e), f = s.from ?? "";
|
|
1190
1284
|
let w, _;
|
|
1191
1285
|
const m = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((I) => {
|
|
1192
1286
|
w = I;
|
|
1193
|
-
const L = BigInt(I.gasUsed) * BigInt(I.effectiveGasPrice),
|
|
1287
|
+
const L = BigInt(I.gasUsed) * BigInt(I.effectiveGasPrice), F = s.value ? BigInt(s.value) : 0n, $ = X.formatTxAmount(s.value, d.symbol, d.decimals), B = X.formatTxAmount("0x" + L.toString(16), d.symbol, d.decimals), Q = X.formatTxAmount("0x" + (F + L).toString(16), d.symbol, d.decimals);
|
|
1194
1288
|
return {
|
|
1195
1289
|
chainId: e,
|
|
1196
1290
|
txHash: a,
|
|
@@ -1235,7 +1329,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1235
1329
|
return await this.walletRpc("eth_gasPrice", [], e);
|
|
1236
1330
|
} catch (s) {
|
|
1237
1331
|
const t = s instanceof Error ? s.message : String(s);
|
|
1238
|
-
throw new x(g.GAS_ESTIMATION_FAILED,
|
|
1332
|
+
throw new x(g.GAS_ESTIMATION_FAILED, `가스 가격 조회에 실패했습니다 (${e}): ${t}`, s);
|
|
1239
1333
|
}
|
|
1240
1334
|
}
|
|
1241
1335
|
/**
|
|
@@ -1256,7 +1350,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1256
1350
|
return await this.walletRpc("eth_estimateGas", [t], s);
|
|
1257
1351
|
} catch (n) {
|
|
1258
1352
|
const o = n instanceof Error ? n.message : String(n);
|
|
1259
|
-
throw new x(g.GAS_ESTIMATION_FAILED,
|
|
1353
|
+
throw new x(g.GAS_ESTIMATION_FAILED, `가스 추정에 실패했습니다 (${s}): ${o}`, n);
|
|
1260
1354
|
}
|
|
1261
1355
|
}
|
|
1262
1356
|
/**
|
|
@@ -1277,7 +1371,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1277
1371
|
return (s == null ? void 0 : s.baseFeePerGas) ?? null;
|
|
1278
1372
|
} catch (s) {
|
|
1279
1373
|
const t = s instanceof Error ? s.message : String(s);
|
|
1280
|
-
throw new x(g.GAS_ESTIMATION_FAILED, `
|
|
1374
|
+
throw new x(g.GAS_ESTIMATION_FAILED, `baseFeePerGas 조회에 실패했습니다 (${e}): ${t}`, s);
|
|
1281
1375
|
}
|
|
1282
1376
|
}
|
|
1283
1377
|
/**
|
|
@@ -1296,7 +1390,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1296
1390
|
return await this.walletRpc("eth_maxPriorityFeePerGas", [], e);
|
|
1297
1391
|
} catch (s) {
|
|
1298
1392
|
const t = s instanceof Error ? s.message : String(s);
|
|
1299
|
-
throw new x(g.GAS_ESTIMATION_FAILED, `
|
|
1393
|
+
throw new x(g.GAS_ESTIMATION_FAILED, `maxPriorityFeePerGas 조회에 실패했습니다 (${e}): ${t}`, s);
|
|
1300
1394
|
}
|
|
1301
1395
|
}
|
|
1302
1396
|
// ============================================================================
|
|
@@ -1316,7 +1410,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1316
1410
|
} catch (t) {
|
|
1317
1411
|
if (t instanceof x) throw t;
|
|
1318
1412
|
const n = t instanceof Error ? t.message : String(t);
|
|
1319
|
-
throw new x(g.UNKNOWN_ERROR, `
|
|
1413
|
+
throw new x(g.UNKNOWN_ERROR, `Nonce 조회에 실패했습니다: ${n}`, t);
|
|
1320
1414
|
}
|
|
1321
1415
|
}
|
|
1322
1416
|
/**
|
|
@@ -1335,7 +1429,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1335
1429
|
} catch (t) {
|
|
1336
1430
|
if (t instanceof x) throw t;
|
|
1337
1431
|
const n = t instanceof Error ? t.message : String(t);
|
|
1338
|
-
throw new x(g.UNKNOWN_ERROR,
|
|
1432
|
+
throw new x(g.UNKNOWN_ERROR, `잔액 조회에 실패했습니다 (${e}): ${n}`, t);
|
|
1339
1433
|
}
|
|
1340
1434
|
}
|
|
1341
1435
|
static formatWei(e) {
|
|
@@ -1343,7 +1437,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1343
1437
|
try {
|
|
1344
1438
|
const s = BigInt(e);
|
|
1345
1439
|
if (s === 0n) return "0";
|
|
1346
|
-
const t = 10n ** BigInt(
|
|
1440
|
+
const t = 10n ** BigInt(Tt), n = s / t, i = (s % t).toString().padStart(Tt, "0").replace(/0+$/, "").slice(0, It);
|
|
1347
1441
|
return i ? `${n}.${i}` : `${n}`;
|
|
1348
1442
|
} catch {
|
|
1349
1443
|
return "?";
|
|
@@ -1368,7 +1462,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1368
1462
|
* const client = createWalletClient({ transport: custom(provider) });
|
|
1369
1463
|
*/
|
|
1370
1464
|
getProvider(e) {
|
|
1371
|
-
return this.ensureAuthenticated(), new
|
|
1465
|
+
return this.ensureAuthenticated(), new Ns(this, e);
|
|
1372
1466
|
}
|
|
1373
1467
|
/**
|
|
1374
1468
|
* 범용 JSON-RPC 요청 — 노드에 직접 연결.
|
|
@@ -1386,7 +1480,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1386
1480
|
} catch (n) {
|
|
1387
1481
|
if (n instanceof x) throw n;
|
|
1388
1482
|
const o = n instanceof Error ? n.message : String(n);
|
|
1389
|
-
throw new x(g.UNKNOWN_ERROR, `walletRpc
|
|
1483
|
+
throw new x(g.UNKNOWN_ERROR, `walletRpc 호출에 실패했습니다 [${e}] (${t}): ${o}`, n);
|
|
1390
1484
|
}
|
|
1391
1485
|
}
|
|
1392
1486
|
// ============================================================================
|
|
@@ -1401,7 +1495,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1401
1495
|
try {
|
|
1402
1496
|
const n = BigInt(e);
|
|
1403
1497
|
if (n === 0n) return;
|
|
1404
|
-
const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0,
|
|
1498
|
+
const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, It).replace(/0+$/, "");
|
|
1405
1499
|
return `${c ? `${i}.${c}` : `${i}`} ${s}`;
|
|
1406
1500
|
} catch {
|
|
1407
1501
|
return;
|
|
@@ -1430,7 +1524,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1430
1524
|
return p.log("[CROSSx][Migration Phase 5] 마이그레이션 성공 — address:", i.address), i;
|
|
1431
1525
|
} catch (i) {
|
|
1432
1526
|
if (i instanceof x && i.code === g.MIGRATION_FAILED) {
|
|
1433
|
-
p.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 #${n}) — 재시도 요청`), t = "
|
|
1527
|
+
p.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 #${n}) — 재시도 요청`), t = "PIN이 올바르지 않습니다. 다시 시도해 주세요.";
|
|
1434
1528
|
continue;
|
|
1435
1529
|
}
|
|
1436
1530
|
throw p.error("[CROSSx][Migration Phase 4] 마이그레이션 실패 (복구 불가):", i), i;
|
|
@@ -1465,12 +1559,12 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1465
1559
|
p.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
|
|
1466
1560
|
const l = await this.getBaseFeePerGas(s);
|
|
1467
1561
|
if (l) {
|
|
1468
|
-
const d =
|
|
1562
|
+
const d = St;
|
|
1469
1563
|
c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(d)).toString(16), c.maxPriorityFeePerGas = d, p.log("[CROSSx] Dynamic 체인 감지 — baseFee:", l, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
|
|
1470
1564
|
} else
|
|
1471
|
-
c.gasPrice =
|
|
1565
|
+
c.gasPrice = zs, p.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
|
|
1472
1566
|
}
|
|
1473
|
-
return !i && a && (c.maxPriorityFeePerGas =
|
|
1567
|
+
return !i && a && (c.maxPriorityFeePerGas = St, p.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
|
|
1474
1568
|
}
|
|
1475
1569
|
/**
|
|
1476
1570
|
* EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
|
|
@@ -1484,7 +1578,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1484
1578
|
if (t !== void 0 && t !== 0)
|
|
1485
1579
|
throw new x(
|
|
1486
1580
|
g.TYPED_DATA_CHAIN_ID_MISMATCH,
|
|
1487
|
-
|
|
1581
|
+
`오프체인 서명(chainId=0)에서는 typedData.domain.chainId가 없거나 0이어야 합니다. 현재 값: ${t}`
|
|
1488
1582
|
);
|
|
1489
1583
|
return;
|
|
1490
1584
|
}
|
|
@@ -1494,12 +1588,12 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1494
1588
|
if (t === void 0)
|
|
1495
1589
|
throw new x(
|
|
1496
1590
|
g.TYPED_DATA_CHAIN_ID_MISMATCH,
|
|
1497
|
-
|
|
1591
|
+
`온체인 서명(${e})에서는 typedData.domain.chainId가 반드시 있어야 합니다`
|
|
1498
1592
|
);
|
|
1499
1593
|
if (t !== o)
|
|
1500
1594
|
throw new x(
|
|
1501
1595
|
g.TYPED_DATA_CHAIN_ID_MISMATCH,
|
|
1502
|
-
`typedData.domain.chainId (${t})
|
|
1596
|
+
`typedData.domain.chainId (${t})가 chainId (${e}, 예상값: ${o})와 일치하지 않습니다`
|
|
1503
1597
|
);
|
|
1504
1598
|
}
|
|
1505
1599
|
}
|
|
@@ -1516,20 +1610,20 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1516
1610
|
static validateSignatureFormat(e) {
|
|
1517
1611
|
const s = e.startsWith("0x") ? e.slice(2) : e;
|
|
1518
1612
|
if (!/^[0-9a-fA-F]+$/.test(s))
|
|
1519
|
-
throw new x(g.SIGNATURE_FAILED, "
|
|
1520
|
-
if (s.length !==
|
|
1613
|
+
throw new x(g.SIGNATURE_FAILED, "유효하지 않은 서명: 올바른 hex 문자열이 아닙니다");
|
|
1614
|
+
if (s.length !== Et)
|
|
1521
1615
|
throw new x(
|
|
1522
1616
|
g.SIGNATURE_FAILED,
|
|
1523
|
-
|
|
1617
|
+
`서명 길이가 유효하지 않습니다: ${Et} hex 문자(65 바이트) 예상, 현재 ${s.length}`
|
|
1524
1618
|
);
|
|
1525
1619
|
}
|
|
1526
1620
|
/** RLP-encoded signed transaction 형식 검증 */
|
|
1527
1621
|
static validateSignedTxFormat(e) {
|
|
1528
1622
|
const s = e.startsWith("0x") ? e.slice(2) : e;
|
|
1529
1623
|
if (!/^[0-9a-fA-F]+$/.test(s))
|
|
1530
|
-
throw new x(g.SIGNATURE_FAILED, "
|
|
1624
|
+
throw new x(g.SIGNATURE_FAILED, "유효하지 않은 서명된 트랜잭션: 올바른 hex 문자열이 아닙니다");
|
|
1531
1625
|
if (s.length < 2)
|
|
1532
|
-
throw new x(g.SIGNATURE_FAILED, "
|
|
1626
|
+
throw new x(g.SIGNATURE_FAILED, "유효하지 않은 서명된 트랜잭션: 너무 짧습니다");
|
|
1533
1627
|
}
|
|
1534
1628
|
/**
|
|
1535
1629
|
* Gateway 서명 응답의 ecrecover 검증 (XF-036)
|
|
@@ -1547,7 +1641,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1547
1641
|
recovered: n
|
|
1548
1642
|
}), new x(
|
|
1549
1643
|
g.SIGNATURE_SIGNER_MISMATCH,
|
|
1550
|
-
|
|
1644
|
+
`서명자 주소가 일치하지 않습니다: 예상 ${t}, 복원된 주소 ${n}`
|
|
1551
1645
|
);
|
|
1552
1646
|
p.log("[CROSSx] 서명 ecrecover 검증 성공");
|
|
1553
1647
|
} catch (n) {
|
|
@@ -1583,14 +1677,14 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1583
1677
|
if (!this.initialized)
|
|
1584
1678
|
throw new x(
|
|
1585
1679
|
g.AUTH_NOT_INITIALIZED,
|
|
1586
|
-
"SDK
|
|
1680
|
+
"SDK가 초기화되지 않았습니다. initialize()를 먼저 호출하세요."
|
|
1587
1681
|
);
|
|
1588
1682
|
}
|
|
1589
1683
|
ensureAuthenticated() {
|
|
1590
1684
|
if (this.ensureInitialized(), !this.authenticated)
|
|
1591
1685
|
throw new x(
|
|
1592
1686
|
g.AUTH_NOT_AUTHENTICATED,
|
|
1593
|
-
"
|
|
1687
|
+
"인증되지 않은 상태입니다. signIn()을 먼저 호출하세요."
|
|
1594
1688
|
);
|
|
1595
1689
|
}
|
|
1596
1690
|
/**
|
|
@@ -1605,7 +1699,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1605
1699
|
};
|
|
1606
1700
|
X.OFFCHAIN_CHAIN_ID = "0";
|
|
1607
1701
|
let st = X;
|
|
1608
|
-
class
|
|
1702
|
+
class Xs {
|
|
1609
1703
|
constructor() {
|
|
1610
1704
|
this.prefix = "crossx_";
|
|
1611
1705
|
}
|
|
@@ -1642,8 +1736,8 @@ class Ks {
|
|
|
1642
1736
|
}
|
|
1643
1737
|
}
|
|
1644
1738
|
}
|
|
1645
|
-
const
|
|
1646
|
-
class
|
|
1739
|
+
const Js = "crossx-sdk", Qs = 1, Se = "data", Le = "keys", At = "aes-primary", er = 12;
|
|
1740
|
+
class Rt {
|
|
1647
1741
|
constructor() {
|
|
1648
1742
|
this.db = null, this.cryptoKey = null, this.initPromise = null;
|
|
1649
1743
|
}
|
|
@@ -1652,7 +1746,7 @@ class At {
|
|
|
1652
1746
|
}
|
|
1653
1747
|
openDB() {
|
|
1654
1748
|
return new Promise((e, s) => {
|
|
1655
|
-
const t = indexedDB.open(
|
|
1749
|
+
const t = indexedDB.open(Js, Qs);
|
|
1656
1750
|
t.onupgradeneeded = () => {
|
|
1657
1751
|
const n = t.result;
|
|
1658
1752
|
n.objectStoreNames.contains(Se) || n.createObjectStore(Se), n.objectStoreNames.contains(Le) || n.createObjectStore(Le);
|
|
@@ -1685,7 +1779,7 @@ class At {
|
|
|
1685
1779
|
}
|
|
1686
1780
|
async init() {
|
|
1687
1781
|
this.db = await this.openDB();
|
|
1688
|
-
const e = await this.idbGet(Le,
|
|
1782
|
+
const e = await this.idbGet(Le, At);
|
|
1689
1783
|
if (e) {
|
|
1690
1784
|
this.cryptoKey = e;
|
|
1691
1785
|
return;
|
|
@@ -1694,10 +1788,10 @@ class At {
|
|
|
1694
1788
|
{ name: "AES-GCM", length: 256 },
|
|
1695
1789
|
!1,
|
|
1696
1790
|
["encrypt", "decrypt"]
|
|
1697
|
-
), await this.idbPut(Le,
|
|
1791
|
+
), await this.idbPut(Le, At, this.cryptoKey);
|
|
1698
1792
|
}
|
|
1699
1793
|
async encrypt(e) {
|
|
1700
|
-
const s = new Uint8Array(
|
|
1794
|
+
const s = new Uint8Array(er);
|
|
1701
1795
|
crypto.getRandomValues(s);
|
|
1702
1796
|
const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
|
|
1703
1797
|
{ name: "AES-GCM", iv: s },
|
|
@@ -1773,7 +1867,7 @@ function H(r, e, s = "") {
|
|
|
1773
1867
|
}
|
|
1774
1868
|
return r;
|
|
1775
1869
|
}
|
|
1776
|
-
function
|
|
1870
|
+
function Yt(r) {
|
|
1777
1871
|
if (typeof r != "function" || typeof r.create != "function")
|
|
1778
1872
|
throw new Error("Hash must wrapped by utils.createHasher");
|
|
1779
1873
|
ue(r.outputLen), ue(r.blockLen);
|
|
@@ -1784,13 +1878,13 @@ function Ie(r, e = !0) {
|
|
|
1784
1878
|
if (e && r.finished)
|
|
1785
1879
|
throw new Error("Hash#digest() has already been called");
|
|
1786
1880
|
}
|
|
1787
|
-
function
|
|
1881
|
+
function Zt(r, e) {
|
|
1788
1882
|
H(r, void 0, "digestInto() output");
|
|
1789
1883
|
const s = e.outputLen;
|
|
1790
1884
|
if (r.length < s)
|
|
1791
1885
|
throw new Error('"digestInto() output" expected to be of length >=' + s);
|
|
1792
1886
|
}
|
|
1793
|
-
function
|
|
1887
|
+
function tr(r) {
|
|
1794
1888
|
return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
|
|
1795
1889
|
}
|
|
1796
1890
|
function Te(...r) {
|
|
@@ -1803,26 +1897,26 @@ function Ze(r) {
|
|
|
1803
1897
|
function oe(r, e) {
|
|
1804
1898
|
return r << 32 - e | r >>> e;
|
|
1805
1899
|
}
|
|
1806
|
-
const
|
|
1807
|
-
function
|
|
1900
|
+
const sr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
1901
|
+
function rr(r) {
|
|
1808
1902
|
return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
|
|
1809
1903
|
}
|
|
1810
|
-
function
|
|
1904
|
+
function nr(r) {
|
|
1811
1905
|
for (let e = 0; e < r.length; e++)
|
|
1812
|
-
r[e] =
|
|
1906
|
+
r[e] = rr(r[e]);
|
|
1813
1907
|
return r;
|
|
1814
1908
|
}
|
|
1815
|
-
const
|
|
1909
|
+
const Ot = sr ? (r) => r : nr, Xt = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", or = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
|
|
1816
1910
|
function ke(r) {
|
|
1817
|
-
if (H(r),
|
|
1911
|
+
if (H(r), Xt)
|
|
1818
1912
|
return r.toHex();
|
|
1819
1913
|
let e = "";
|
|
1820
1914
|
for (let s = 0; s < r.length; s++)
|
|
1821
|
-
e +=
|
|
1915
|
+
e += or[r[s]];
|
|
1822
1916
|
return e;
|
|
1823
1917
|
}
|
|
1824
1918
|
const ce = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
1825
|
-
function
|
|
1919
|
+
function Ct(r) {
|
|
1826
1920
|
if (r >= ce._0 && r <= ce._9)
|
|
1827
1921
|
return r - ce._0;
|
|
1828
1922
|
if (r >= ce.A && r <= ce.F)
|
|
@@ -1830,17 +1924,17 @@ function Ot(r) {
|
|
|
1830
1924
|
if (r >= ce.a && r <= ce.f)
|
|
1831
1925
|
return r - (ce.a - 10);
|
|
1832
1926
|
}
|
|
1833
|
-
function
|
|
1927
|
+
function Ue(r) {
|
|
1834
1928
|
if (typeof r != "string")
|
|
1835
1929
|
throw new Error("hex string expected, got " + typeof r);
|
|
1836
|
-
if (
|
|
1930
|
+
if (Xt)
|
|
1837
1931
|
return Uint8Array.fromHex(r);
|
|
1838
1932
|
const e = r.length, s = e / 2;
|
|
1839
1933
|
if (e % 2)
|
|
1840
1934
|
throw new Error("hex string expected, got unpadded hex of length " + e);
|
|
1841
1935
|
const t = new Uint8Array(s);
|
|
1842
1936
|
for (let n = 0, o = 0; n < s; n++, o += 2) {
|
|
1843
|
-
const i =
|
|
1937
|
+
const i = Ct(r.charCodeAt(o)), a = Ct(r.charCodeAt(o + 1));
|
|
1844
1938
|
if (i === void 0 || a === void 0) {
|
|
1845
1939
|
const c = r[o] + r[o + 1];
|
|
1846
1940
|
throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + o);
|
|
@@ -1862,26 +1956,26 @@ function _e(...r) {
|
|
|
1862
1956
|
}
|
|
1863
1957
|
return s;
|
|
1864
1958
|
}
|
|
1865
|
-
function
|
|
1959
|
+
function Jt(r, e = {}) {
|
|
1866
1960
|
const s = (n, o) => r(o).update(n).digest(), t = r(void 0);
|
|
1867
1961
|
return s.outputLen = t.outputLen, s.blockLen = t.blockLen, s.create = (n) => r(n), Object.assign(s, e), Object.freeze(s);
|
|
1868
1962
|
}
|
|
1869
|
-
function
|
|
1963
|
+
function Qt(r = 32) {
|
|
1870
1964
|
const e = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
1871
1965
|
if (typeof (e == null ? void 0 : e.getRandomValues) != "function")
|
|
1872
1966
|
throw new Error("crypto.getRandomValues must be defined");
|
|
1873
1967
|
return e.getRandomValues(new Uint8Array(r));
|
|
1874
1968
|
}
|
|
1875
|
-
const
|
|
1969
|
+
const ir = (r) => ({
|
|
1876
1970
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
|
|
1877
1971
|
});
|
|
1878
|
-
function
|
|
1972
|
+
function ar(r, e, s) {
|
|
1879
1973
|
return r & e ^ ~r & s;
|
|
1880
1974
|
}
|
|
1881
|
-
function
|
|
1975
|
+
function cr(r, e, s) {
|
|
1882
1976
|
return r & e ^ r & s ^ e & s;
|
|
1883
1977
|
}
|
|
1884
|
-
class
|
|
1978
|
+
class lr {
|
|
1885
1979
|
constructor(e, s, t, n) {
|
|
1886
1980
|
v(this, "blockLen");
|
|
1887
1981
|
v(this, "outputLen");
|
|
@@ -1912,7 +2006,7 @@ class or {
|
|
|
1912
2006
|
return this.length += e.length, this.roundClean(), this;
|
|
1913
2007
|
}
|
|
1914
2008
|
digestInto(e) {
|
|
1915
|
-
Ie(this),
|
|
2009
|
+
Ie(this), Zt(e, this), this.finished = !0;
|
|
1916
2010
|
const { buffer: s, view: t, blockLen: n, isLE: o } = this;
|
|
1917
2011
|
let { pos: i } = this;
|
|
1918
2012
|
s[i++] = 128, Te(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
|
|
@@ -1952,20 +2046,20 @@ const fe = /* @__PURE__ */ Uint32Array.from([
|
|
|
1952
2046
|
2600822924,
|
|
1953
2047
|
528734635,
|
|
1954
2048
|
1541459225
|
|
1955
|
-
]), De = /* @__PURE__ */ BigInt(2 ** 32 - 1),
|
|
1956
|
-
function
|
|
1957
|
-
return e ? { h: Number(r & De), l: Number(r >>
|
|
2049
|
+
]), De = /* @__PURE__ */ BigInt(2 ** 32 - 1), kt = /* @__PURE__ */ BigInt(32);
|
|
2050
|
+
function dr(r, e = !1) {
|
|
2051
|
+
return e ? { h: Number(r & De), l: Number(r >> kt & De) } : { h: Number(r >> kt & De) | 0, l: Number(r & De) | 0 };
|
|
1958
2052
|
}
|
|
1959
|
-
function
|
|
2053
|
+
function ur(r, e = !1) {
|
|
1960
2054
|
const s = r.length;
|
|
1961
2055
|
let t = new Uint32Array(s), n = new Uint32Array(s);
|
|
1962
2056
|
for (let o = 0; o < s; o++) {
|
|
1963
|
-
const { h: i, l: a } =
|
|
2057
|
+
const { h: i, l: a } = dr(r[o], e);
|
|
1964
2058
|
[t[o], n[o]] = [i, a];
|
|
1965
2059
|
}
|
|
1966
2060
|
return [t, n];
|
|
1967
2061
|
}
|
|
1968
|
-
const
|
|
2062
|
+
const hr = (r, e, s) => r << s | e >>> 32 - s, fr = (r, e, s) => e << s | r >>> 32 - s, pr = (r, e, s) => e << s - 32 | r >>> 64 - s, gr = (r, e, s) => r << s - 32 | e >>> 64 - s, _r = /* @__PURE__ */ Uint32Array.from([
|
|
1969
2063
|
1116352408,
|
|
1970
2064
|
1899447441,
|
|
1971
2065
|
3049323471,
|
|
@@ -2031,7 +2125,7 @@ const cr = (r, e, s) => r << s | e >>> 32 - s, lr = (r, e, s) => e << s | r >>>
|
|
|
2031
2125
|
3204031479,
|
|
2032
2126
|
3329325298
|
|
2033
2127
|
]), pe = /* @__PURE__ */ new Uint32Array(64);
|
|
2034
|
-
class
|
|
2128
|
+
class xr extends lr {
|
|
2035
2129
|
constructor(e) {
|
|
2036
2130
|
super(64, e, 8, !1);
|
|
2037
2131
|
}
|
|
@@ -2052,7 +2146,7 @@ class fr extends or {
|
|
|
2052
2146
|
}
|
|
2053
2147
|
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: d } = this;
|
|
2054
2148
|
for (let f = 0; f < 64; f++) {
|
|
2055
|
-
const w = oe(a, 6) ^ oe(a, 11) ^ oe(a, 25), _ = d + w +
|
|
2149
|
+
const w = oe(a, 6) ^ oe(a, 11) ^ oe(a, 25), _ = d + w + ar(a, c, l) + _r[f] + pe[f] | 0, A = (oe(t, 2) ^ oe(t, 13) ^ oe(t, 22)) + cr(t, n, o) | 0;
|
|
2056
2150
|
d = l, l = c, c = a, a = i + _ | 0, i = o, o = n, n = t, t = _ + A | 0;
|
|
2057
2151
|
}
|
|
2058
2152
|
t = t + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, d = d + this.H | 0, this.set(t, n, o, i, a, c, l, d);
|
|
@@ -2064,7 +2158,7 @@ class fr extends or {
|
|
|
2064
2158
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), Te(this.buffer);
|
|
2065
2159
|
}
|
|
2066
2160
|
}
|
|
2067
|
-
class
|
|
2161
|
+
class mr extends xr {
|
|
2068
2162
|
constructor() {
|
|
2069
2163
|
super(32);
|
|
2070
2164
|
// We cannot use array here since array allows indexing by variable
|
|
@@ -2079,9 +2173,9 @@ class pr extends fr {
|
|
|
2079
2173
|
v(this, "H", fe[7] | 0);
|
|
2080
2174
|
}
|
|
2081
2175
|
}
|
|
2082
|
-
const
|
|
2083
|
-
() => new
|
|
2084
|
-
/* @__PURE__ */
|
|
2176
|
+
const wr = /* @__PURE__ */ Jt(
|
|
2177
|
+
() => new mr(),
|
|
2178
|
+
/* @__PURE__ */ ir(1)
|
|
2085
2179
|
);
|
|
2086
2180
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2087
2181
|
const ct = /* @__PURE__ */ BigInt(0), rt = /* @__PURE__ */ BigInt(1);
|
|
@@ -2092,7 +2186,7 @@ function He(r, e = "") {
|
|
|
2092
2186
|
}
|
|
2093
2187
|
return r;
|
|
2094
2188
|
}
|
|
2095
|
-
function
|
|
2189
|
+
function es(r) {
|
|
2096
2190
|
if (typeof r == "bigint") {
|
|
2097
2191
|
if (!Be(r))
|
|
2098
2192
|
throw new Error("positive bigint expected, got " + r);
|
|
@@ -2101,49 +2195,49 @@ function Jt(r) {
|
|
|
2101
2195
|
return r;
|
|
2102
2196
|
}
|
|
2103
2197
|
function $e(r) {
|
|
2104
|
-
const e =
|
|
2198
|
+
const e = es(r).toString(16);
|
|
2105
2199
|
return e.length & 1 ? "0" + e : e;
|
|
2106
2200
|
}
|
|
2107
|
-
function
|
|
2201
|
+
function ts(r) {
|
|
2108
2202
|
if (typeof r != "string")
|
|
2109
2203
|
throw new Error("hex string expected, got " + typeof r);
|
|
2110
2204
|
return r === "" ? ct : BigInt("0x" + r);
|
|
2111
2205
|
}
|
|
2112
2206
|
function je(r) {
|
|
2113
|
-
return
|
|
2207
|
+
return ts(ke(r));
|
|
2114
2208
|
}
|
|
2115
|
-
function
|
|
2116
|
-
return
|
|
2209
|
+
function ss(r) {
|
|
2210
|
+
return ts(ke(yr(H(r)).reverse()));
|
|
2117
2211
|
}
|
|
2118
2212
|
function lt(r, e) {
|
|
2119
|
-
ue(e), r =
|
|
2120
|
-
const s =
|
|
2213
|
+
ue(e), r = es(r);
|
|
2214
|
+
const s = Ue(r.toString(16).padStart(e * 2, "0"));
|
|
2121
2215
|
if (s.length !== e)
|
|
2122
2216
|
throw new Error("number too large");
|
|
2123
2217
|
return s;
|
|
2124
2218
|
}
|
|
2125
|
-
function
|
|
2219
|
+
function rs(r, e) {
|
|
2126
2220
|
return lt(r, e).reverse();
|
|
2127
2221
|
}
|
|
2128
|
-
function
|
|
2222
|
+
function yr(r) {
|
|
2129
2223
|
return Uint8Array.from(r);
|
|
2130
2224
|
}
|
|
2131
2225
|
const Be = (r) => typeof r == "bigint" && ct <= r;
|
|
2132
|
-
function
|
|
2226
|
+
function br(r, e, s) {
|
|
2133
2227
|
return Be(r) && Be(e) && Be(s) && e <= r && r < s;
|
|
2134
2228
|
}
|
|
2135
|
-
function
|
|
2136
|
-
if (!
|
|
2229
|
+
function vr(r, e, s, t) {
|
|
2230
|
+
if (!br(e, s, t))
|
|
2137
2231
|
throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
|
|
2138
2232
|
}
|
|
2139
|
-
function
|
|
2233
|
+
function Sr(r) {
|
|
2140
2234
|
let e;
|
|
2141
2235
|
for (e = 0; r > ct; r >>= rt, e += 1)
|
|
2142
2236
|
;
|
|
2143
2237
|
return e;
|
|
2144
2238
|
}
|
|
2145
2239
|
const dt = (r) => (rt << BigInt(r)) - rt;
|
|
2146
|
-
function
|
|
2240
|
+
function Er(r, e, s) {
|
|
2147
2241
|
if (ue(r, "hashLen"), ue(e, "qByteLen"), typeof s != "function")
|
|
2148
2242
|
throw new Error("hmacFn must be a function");
|
|
2149
2243
|
const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
|
|
@@ -2186,7 +2280,7 @@ function ut(r, e = {}, s = {}) {
|
|
|
2186
2280
|
const n = (o, i) => Object.entries(o).forEach(([a, c]) => t(a, c, i));
|
|
2187
2281
|
n(e, !1), n(s, !0);
|
|
2188
2282
|
}
|
|
2189
|
-
function
|
|
2283
|
+
function Nt(r) {
|
|
2190
2284
|
const e = /* @__PURE__ */ new WeakMap();
|
|
2191
2285
|
return (s, ...t) => {
|
|
2192
2286
|
const n = e.get(s);
|
|
@@ -2197,7 +2291,7 @@ function kt(r) {
|
|
|
2197
2291
|
};
|
|
2198
2292
|
}
|
|
2199
2293
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2200
|
-
const J = /* @__PURE__ */ BigInt(0), z = /* @__PURE__ */ BigInt(1), ye = /* @__PURE__ */ BigInt(2),
|
|
2294
|
+
const J = /* @__PURE__ */ BigInt(0), z = /* @__PURE__ */ BigInt(1), ye = /* @__PURE__ */ BigInt(2), ns = /* @__PURE__ */ BigInt(3), os = /* @__PURE__ */ BigInt(4), is = /* @__PURE__ */ BigInt(5), Ir = /* @__PURE__ */ BigInt(7), as = /* @__PURE__ */ BigInt(8), Tr = /* @__PURE__ */ BigInt(9), cs = /* @__PURE__ */ BigInt(16);
|
|
2201
2295
|
function re(r, e) {
|
|
2202
2296
|
const s = r % e;
|
|
2203
2297
|
return s >= J ? s : e + s;
|
|
@@ -2208,7 +2302,7 @@ function se(r, e, s) {
|
|
|
2208
2302
|
t *= t, t %= s;
|
|
2209
2303
|
return t;
|
|
2210
2304
|
}
|
|
2211
|
-
function
|
|
2305
|
+
function Pt(r, e) {
|
|
2212
2306
|
if (r === J)
|
|
2213
2307
|
throw new Error("invert: expected non-zero number");
|
|
2214
2308
|
if (e <= J)
|
|
@@ -2226,16 +2320,16 @@ function ht(r, e, s) {
|
|
|
2226
2320
|
if (!r.eql(r.sqr(e), s))
|
|
2227
2321
|
throw new Error("Cannot find square root");
|
|
2228
2322
|
}
|
|
2229
|
-
function
|
|
2230
|
-
const s = (r.ORDER + z) /
|
|
2323
|
+
function ls(r, e) {
|
|
2324
|
+
const s = (r.ORDER + z) / os, t = r.pow(e, s);
|
|
2231
2325
|
return ht(r, t, e), t;
|
|
2232
2326
|
}
|
|
2233
|
-
function
|
|
2234
|
-
const s = (r.ORDER -
|
|
2327
|
+
function Ar(r, e) {
|
|
2328
|
+
const s = (r.ORDER - is) / as, t = r.mul(e, ye), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, ye), n), a = r.mul(o, r.sub(i, r.ONE));
|
|
2235
2329
|
return ht(r, a, e), a;
|
|
2236
2330
|
}
|
|
2237
|
-
function
|
|
2238
|
-
const e = Ve(r), s =
|
|
2331
|
+
function Rr(r) {
|
|
2332
|
+
const e = Ve(r), s = ds(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + Ir) / cs;
|
|
2239
2333
|
return (a, c) => {
|
|
2240
2334
|
let l = a.pow(c, i), d = a.mul(l, t);
|
|
2241
2335
|
const f = a.mul(l, n), w = a.mul(l, o), _ = a.eql(a.sqr(d), c), m = a.eql(a.sqr(f), c);
|
|
@@ -2244,25 +2338,25 @@ function Er(r) {
|
|
|
2244
2338
|
return ht(a, y, c), y;
|
|
2245
2339
|
};
|
|
2246
2340
|
}
|
|
2247
|
-
function
|
|
2248
|
-
if (r <
|
|
2341
|
+
function ds(r) {
|
|
2342
|
+
if (r < ns)
|
|
2249
2343
|
throw new Error("sqrt is not defined for small field");
|
|
2250
2344
|
let e = r - z, s = 0;
|
|
2251
2345
|
for (; e % ye === J; )
|
|
2252
2346
|
e /= ye, s++;
|
|
2253
2347
|
let t = ye;
|
|
2254
2348
|
const n = Ve(r);
|
|
2255
|
-
for (;
|
|
2349
|
+
for (; Lt(n, t) === 1; )
|
|
2256
2350
|
if (t++ > 1e3)
|
|
2257
2351
|
throw new Error("Cannot find square root: probably non-prime P");
|
|
2258
2352
|
if (s === 1)
|
|
2259
|
-
return
|
|
2353
|
+
return ls;
|
|
2260
2354
|
let o = n.pow(t, e);
|
|
2261
2355
|
const i = (e + z) / ye;
|
|
2262
2356
|
return function(c, l) {
|
|
2263
2357
|
if (c.is0(l))
|
|
2264
2358
|
return l;
|
|
2265
|
-
if (
|
|
2359
|
+
if (Lt(c, l) !== 1)
|
|
2266
2360
|
throw new Error("Cannot find square root");
|
|
2267
2361
|
let d = s, f = c.mul(c.ONE, o), w = c.pow(l, e), _ = c.pow(l, i);
|
|
2268
2362
|
for (; !c.eql(w, c.ONE); ) {
|
|
@@ -2278,10 +2372,10 @@ function cs(r) {
|
|
|
2278
2372
|
return _;
|
|
2279
2373
|
};
|
|
2280
2374
|
}
|
|
2281
|
-
function
|
|
2282
|
-
return r %
|
|
2375
|
+
function Or(r) {
|
|
2376
|
+
return r % os === ns ? ls : r % as === is ? Ar : r % cs === Tr ? Rr(r) : ds(r);
|
|
2283
2377
|
}
|
|
2284
|
-
const
|
|
2378
|
+
const Cr = [
|
|
2285
2379
|
"create",
|
|
2286
2380
|
"isValid",
|
|
2287
2381
|
"is0",
|
|
@@ -2300,15 +2394,15 @@ const Tr = [
|
|
|
2300
2394
|
"mulN",
|
|
2301
2395
|
"sqrN"
|
|
2302
2396
|
];
|
|
2303
|
-
function
|
|
2397
|
+
function kr(r) {
|
|
2304
2398
|
const e = {
|
|
2305
2399
|
ORDER: "bigint",
|
|
2306
2400
|
BYTES: "number",
|
|
2307
2401
|
BITS: "number"
|
|
2308
|
-
}, s =
|
|
2402
|
+
}, s = Cr.reduce((t, n) => (t[n] = "function", t), e);
|
|
2309
2403
|
return ut(r, s), r;
|
|
2310
2404
|
}
|
|
2311
|
-
function
|
|
2405
|
+
function Nr(r, e, s) {
|
|
2312
2406
|
if (s < J)
|
|
2313
2407
|
throw new Error("invalid exponent, negatives unsupported");
|
|
2314
2408
|
if (s === J)
|
|
@@ -2320,22 +2414,22 @@ function Rr(r, e, s) {
|
|
|
2320
2414
|
s & z && (t = r.mul(t, n)), n = r.sqr(n), s >>= z;
|
|
2321
2415
|
return t;
|
|
2322
2416
|
}
|
|
2323
|
-
function
|
|
2417
|
+
function us(r, e, s = !1) {
|
|
2324
2418
|
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);
|
|
2325
2419
|
return e.reduceRight((i, a, c) => r.is0(a) ? i : (t[c] = r.mul(i, t[c]), r.mul(i, a)), o), t;
|
|
2326
2420
|
}
|
|
2327
|
-
function
|
|
2421
|
+
function Lt(r, e) {
|
|
2328
2422
|
const s = (r.ORDER - z) / ye, 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));
|
|
2329
2423
|
if (!n && !o && !i)
|
|
2330
2424
|
throw new Error("invalid Legendre symbol result");
|
|
2331
2425
|
return n ? 1 : o ? 0 : -1;
|
|
2332
2426
|
}
|
|
2333
|
-
function
|
|
2427
|
+
function Pr(r, e) {
|
|
2334
2428
|
e !== void 0 && ue(e);
|
|
2335
2429
|
const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
|
|
2336
2430
|
return { nBitLength: s, nByteLength: t };
|
|
2337
2431
|
}
|
|
2338
|
-
class
|
|
2432
|
+
class Lr {
|
|
2339
2433
|
constructor(e, s = {}) {
|
|
2340
2434
|
v(this, "ORDER");
|
|
2341
2435
|
v(this, "BITS");
|
|
@@ -2352,7 +2446,7 @@ class Cr {
|
|
|
2352
2446
|
throw new Error("invalid field: expected ORDER > 0, got " + e);
|
|
2353
2447
|
let t;
|
|
2354
2448
|
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));
|
|
2355
|
-
const { nBitLength: n, nByteLength: o } =
|
|
2449
|
+
const { nBitLength: n, nByteLength: o } = Pr(e, t);
|
|
2356
2450
|
if (o > 2048)
|
|
2357
2451
|
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
2358
2452
|
this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
|
|
@@ -2394,10 +2488,10 @@ class Cr {
|
|
|
2394
2488
|
return re(e * s, this.ORDER);
|
|
2395
2489
|
}
|
|
2396
2490
|
pow(e, s) {
|
|
2397
|
-
return
|
|
2491
|
+
return Nr(this, e, s);
|
|
2398
2492
|
}
|
|
2399
2493
|
div(e, s) {
|
|
2400
|
-
return re(e *
|
|
2494
|
+
return re(e * Pt(s, this.ORDER), this.ORDER);
|
|
2401
2495
|
}
|
|
2402
2496
|
// Same as above, but doesn't normalize
|
|
2403
2497
|
sqrN(e) {
|
|
@@ -2413,13 +2507,13 @@ class Cr {
|
|
|
2413
2507
|
return e * s;
|
|
2414
2508
|
}
|
|
2415
2509
|
inv(e) {
|
|
2416
|
-
return
|
|
2510
|
+
return Pt(e, this.ORDER);
|
|
2417
2511
|
}
|
|
2418
2512
|
sqrt(e) {
|
|
2419
|
-
return this._sqrt || (this._sqrt =
|
|
2513
|
+
return this._sqrt || (this._sqrt = Or(this.ORDER)), this._sqrt(this, e);
|
|
2420
2514
|
}
|
|
2421
2515
|
toBytes(e) {
|
|
2422
|
-
return this.isLE ?
|
|
2516
|
+
return this.isLE ? rs(e, this.BYTES) : lt(e, this.BYTES);
|
|
2423
2517
|
}
|
|
2424
2518
|
fromBytes(e, s = !1) {
|
|
2425
2519
|
H(e);
|
|
@@ -2432,14 +2526,14 @@ class Cr {
|
|
|
2432
2526
|
}
|
|
2433
2527
|
if (e.length !== n)
|
|
2434
2528
|
throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
|
|
2435
|
-
let c = o ?
|
|
2529
|
+
let c = o ? ss(e) : je(e);
|
|
2436
2530
|
if (a && (c = re(c, i)), !s && !this.isValid(c))
|
|
2437
2531
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
2438
2532
|
return c;
|
|
2439
2533
|
}
|
|
2440
2534
|
// TODO: we don't need it here, move out to separate fn
|
|
2441
2535
|
invertBatch(e) {
|
|
2442
|
-
return
|
|
2536
|
+
return us(this, e);
|
|
2443
2537
|
}
|
|
2444
2538
|
// We can't move this out because Fp6, Fp12 implement it
|
|
2445
2539
|
// and it's unclear what to return in there.
|
|
@@ -2448,25 +2542,25 @@ class Cr {
|
|
|
2448
2542
|
}
|
|
2449
2543
|
}
|
|
2450
2544
|
function Ve(r, e = {}) {
|
|
2451
|
-
return new
|
|
2545
|
+
return new Lr(r, e);
|
|
2452
2546
|
}
|
|
2453
|
-
function
|
|
2547
|
+
function hs(r) {
|
|
2454
2548
|
if (typeof r != "bigint")
|
|
2455
2549
|
throw new Error("field order must be bigint");
|
|
2456
2550
|
const e = r.toString(2).length;
|
|
2457
2551
|
return Math.ceil(e / 8);
|
|
2458
2552
|
}
|
|
2459
|
-
function
|
|
2460
|
-
const e =
|
|
2553
|
+
function fs(r) {
|
|
2554
|
+
const e = hs(r);
|
|
2461
2555
|
return e + Math.ceil(e / 2);
|
|
2462
2556
|
}
|
|
2463
|
-
function
|
|
2557
|
+
function Dr(r, e, s = !1) {
|
|
2464
2558
|
H(r);
|
|
2465
|
-
const t = r.length, n =
|
|
2559
|
+
const t = r.length, n = hs(e), o = fs(e);
|
|
2466
2560
|
if (t < 16 || t < o || t > 1024)
|
|
2467
2561
|
throw new Error("expected " + o + "-1024 bytes of input, got " + t);
|
|
2468
|
-
const i = s ?
|
|
2469
|
-
return s ?
|
|
2562
|
+
const i = s ? ss(r) : je(r), a = re(i, e - z) + z;
|
|
2563
|
+
return s ? rs(a, n) : lt(a, n);
|
|
2470
2564
|
}
|
|
2471
2565
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2472
2566
|
const Ae = /* @__PURE__ */ BigInt(0), be = /* @__PURE__ */ BigInt(1);
|
|
@@ -2474,35 +2568,35 @@ function Ge(r, e) {
|
|
|
2474
2568
|
const s = e.negate();
|
|
2475
2569
|
return r ? s : e;
|
|
2476
2570
|
}
|
|
2477
|
-
function
|
|
2478
|
-
const s =
|
|
2571
|
+
function Dt(r, e) {
|
|
2572
|
+
const s = us(r.Fp, e.map((t) => t.Z));
|
|
2479
2573
|
return e.map((t, n) => r.fromAffine(t.toAffine(s[n])));
|
|
2480
2574
|
}
|
|
2481
|
-
function
|
|
2575
|
+
function ps(r, e) {
|
|
2482
2576
|
if (!Number.isSafeInteger(r) || r <= 0 || r > e)
|
|
2483
2577
|
throw new Error("invalid window size, expected [1.." + e + "], got W=" + r);
|
|
2484
2578
|
}
|
|
2485
2579
|
function Xe(r, e) {
|
|
2486
|
-
|
|
2580
|
+
ps(r, e);
|
|
2487
2581
|
const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = dt(r), i = BigInt(r);
|
|
2488
2582
|
return { windows: s, windowSize: t, mask: o, maxNumber: n, shiftBy: i };
|
|
2489
2583
|
}
|
|
2490
|
-
function
|
|
2584
|
+
function $t(r, e, s) {
|
|
2491
2585
|
const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
|
|
2492
2586
|
let a = Number(r & n), c = r >> i;
|
|
2493
2587
|
a > t && (a -= o, c += be);
|
|
2494
2588
|
const l = e * t, d = l + Math.abs(a) - 1, f = a === 0, w = a < 0, _ = e % 2 !== 0;
|
|
2495
2589
|
return { nextN: c, offset: d, isZero: f, isNeg: w, isNegF: _, offsetF: l };
|
|
2496
2590
|
}
|
|
2497
|
-
const Je = /* @__PURE__ */ new WeakMap(),
|
|
2591
|
+
const Je = /* @__PURE__ */ new WeakMap(), gs = /* @__PURE__ */ new WeakMap();
|
|
2498
2592
|
function Qe(r) {
|
|
2499
|
-
return
|
|
2593
|
+
return gs.get(r) || 1;
|
|
2500
2594
|
}
|
|
2501
|
-
function
|
|
2595
|
+
function Mt(r) {
|
|
2502
2596
|
if (r !== Ae)
|
|
2503
2597
|
throw new Error("invalid wNAF");
|
|
2504
2598
|
}
|
|
2505
|
-
class
|
|
2599
|
+
class $r {
|
|
2506
2600
|
// Parametrized with a given Point class (not individual point)
|
|
2507
2601
|
constructor(e, s) {
|
|
2508
2602
|
v(this, "BASE");
|
|
@@ -2553,10 +2647,10 @@ class Nr {
|
|
|
2553
2647
|
let n = this.ZERO, o = this.BASE;
|
|
2554
2648
|
const i = Xe(e, this.bits);
|
|
2555
2649
|
for (let a = 0; a < i.windows; a++) {
|
|
2556
|
-
const { nextN: c, offset: l, isZero: d, isNeg: f, isNegF: w, offsetF: _ } =
|
|
2650
|
+
const { nextN: c, offset: l, isZero: d, isNeg: f, isNegF: w, offsetF: _ } = $t(t, a, i);
|
|
2557
2651
|
t = c, d ? o = o.add(Ge(w, s[_])) : n = n.add(Ge(f, s[l]));
|
|
2558
2652
|
}
|
|
2559
|
-
return
|
|
2653
|
+
return Mt(t), { p: n, f: o };
|
|
2560
2654
|
}
|
|
2561
2655
|
/**
|
|
2562
2656
|
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
@@ -2566,13 +2660,13 @@ class Nr {
|
|
|
2566
2660
|
wNAFUnsafe(e, s, t, n = this.ZERO) {
|
|
2567
2661
|
const o = Xe(e, this.bits);
|
|
2568
2662
|
for (let i = 0; i < o.windows && t !== Ae; i++) {
|
|
2569
|
-
const { nextN: a, offset: c, isZero: l, isNeg: d } =
|
|
2663
|
+
const { nextN: a, offset: c, isZero: l, isNeg: d } = $t(t, i, o);
|
|
2570
2664
|
if (t = a, !l) {
|
|
2571
2665
|
const f = s[c];
|
|
2572
2666
|
n = n.add(d ? f.negate() : f);
|
|
2573
2667
|
}
|
|
2574
2668
|
}
|
|
2575
|
-
return
|
|
2669
|
+
return Mt(t), n;
|
|
2576
2670
|
}
|
|
2577
2671
|
getPrecomputes(e, s, t) {
|
|
2578
2672
|
let n = Je.get(s);
|
|
@@ -2590,27 +2684,27 @@ class Nr {
|
|
|
2590
2684
|
// using windowed method. This specifies window size and
|
|
2591
2685
|
// stores precomputed values. Usually only base point would be precomputed.
|
|
2592
2686
|
createCache(e, s) {
|
|
2593
|
-
|
|
2687
|
+
ps(s, this.bits), gs.set(e, s), Je.delete(e);
|
|
2594
2688
|
}
|
|
2595
2689
|
hasCache(e) {
|
|
2596
2690
|
return Qe(e) !== 1;
|
|
2597
2691
|
}
|
|
2598
2692
|
}
|
|
2599
|
-
function
|
|
2693
|
+
function Mr(r, e, s, t) {
|
|
2600
2694
|
let n = e, o = r.ZERO, i = r.ZERO;
|
|
2601
2695
|
for (; s > Ae || t > Ae; )
|
|
2602
2696
|
s & be && (o = o.add(n)), t & be && (i = i.add(n)), n = n.double(), s >>= be, t >>= be;
|
|
2603
2697
|
return { p1: o, p2: i };
|
|
2604
2698
|
}
|
|
2605
|
-
function
|
|
2699
|
+
function Bt(r, e, s) {
|
|
2606
2700
|
if (e) {
|
|
2607
2701
|
if (e.ORDER !== r)
|
|
2608
2702
|
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
2609
|
-
return
|
|
2703
|
+
return kr(e), e;
|
|
2610
2704
|
} else
|
|
2611
2705
|
return Ve(r, { isLE: s });
|
|
2612
2706
|
}
|
|
2613
|
-
function
|
|
2707
|
+
function Br(r, e, s = {}, t) {
|
|
2614
2708
|
if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
|
|
2615
2709
|
throw new Error(`expected valid ${r} CURVE object`);
|
|
2616
2710
|
for (const c of ["p", "n", "h"]) {
|
|
@@ -2618,19 +2712,19 @@ function Lr(r, e, s = {}, t) {
|
|
|
2618
2712
|
if (!(typeof l == "bigint" && l > Ae))
|
|
2619
2713
|
throw new Error(`CURVE.${c} must be positive bigint`);
|
|
2620
2714
|
}
|
|
2621
|
-
const n =
|
|
2715
|
+
const n = Bt(e.p, s.Fp, t), o = Bt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
|
|
2622
2716
|
for (const c of a)
|
|
2623
2717
|
if (!n.isValid(e[c]))
|
|
2624
2718
|
throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
|
|
2625
2719
|
return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
|
|
2626
2720
|
}
|
|
2627
|
-
function
|
|
2721
|
+
function Fr(r, e) {
|
|
2628
2722
|
return function(t) {
|
|
2629
2723
|
const n = r(t);
|
|
2630
2724
|
return { secretKey: n, publicKey: e(n) };
|
|
2631
2725
|
};
|
|
2632
2726
|
}
|
|
2633
|
-
class
|
|
2727
|
+
class _s {
|
|
2634
2728
|
constructor(e, s) {
|
|
2635
2729
|
v(this, "oHash");
|
|
2636
2730
|
v(this, "iHash");
|
|
@@ -2638,7 +2732,7 @@ class ps {
|
|
|
2638
2732
|
v(this, "outputLen");
|
|
2639
2733
|
v(this, "finished", !1);
|
|
2640
2734
|
v(this, "destroyed", !1);
|
|
2641
|
-
if (
|
|
2735
|
+
if (Yt(e), H(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
|
|
2642
2736
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
2643
2737
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
2644
2738
|
const t = this.blockLen, n = new Uint8Array(t);
|
|
@@ -2672,16 +2766,16 @@ class ps {
|
|
|
2672
2766
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
2673
2767
|
}
|
|
2674
2768
|
}
|
|
2675
|
-
const
|
|
2676
|
-
|
|
2769
|
+
const xs = (r, e, s) => new _s(r, e).update(s).digest();
|
|
2770
|
+
xs.create = (r, e) => new _s(r, e);
|
|
2677
2771
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2678
|
-
const
|
|
2679
|
-
function
|
|
2680
|
-
const [[t, n], [o, i]] = e, a =
|
|
2772
|
+
const Ft = (r, e) => (r + (r >= 0 ? e : -e) / ms) / e;
|
|
2773
|
+
function Ur(r, e, s) {
|
|
2774
|
+
const [[t, n], [o, i]] = e, a = Ft(i * r, s), c = Ft(-n * r, s);
|
|
2681
2775
|
let l = r - a * t - c * o, d = -a * n - c * i;
|
|
2682
2776
|
const f = l < le, w = d < le;
|
|
2683
2777
|
f && (l = -l), w && (d = -d);
|
|
2684
|
-
const _ = dt(Math.ceil(
|
|
2778
|
+
const _ = dt(Math.ceil(Sr(s) / 2)) + Ee;
|
|
2685
2779
|
if (l < le || l >= _ || d < le || d >= _)
|
|
2686
2780
|
throw new Error("splitScalar (endomorphism): failed, k=" + r);
|
|
2687
2781
|
return { k1neg: f, k1: l, k2neg: w, k2: d };
|
|
@@ -2697,14 +2791,14 @@ function et(r, e) {
|
|
|
2697
2791
|
s[t] = r[t] === void 0 ? e[t] : r[t];
|
|
2698
2792
|
return He(s.lowS, "lowS"), He(s.prehash, "prehash"), s.format !== void 0 && nt(s.format), s;
|
|
2699
2793
|
}
|
|
2700
|
-
class
|
|
2794
|
+
class Hr extends Error {
|
|
2701
2795
|
constructor(e = "") {
|
|
2702
2796
|
super(e);
|
|
2703
2797
|
}
|
|
2704
2798
|
}
|
|
2705
2799
|
const ge = {
|
|
2706
2800
|
// asn.1 DER encoding utils
|
|
2707
|
-
Err:
|
|
2801
|
+
Err: Hr,
|
|
2708
2802
|
// Basic building block is TLV (Tag-Length-Value)
|
|
2709
2803
|
_tlv: {
|
|
2710
2804
|
encode: (r, e) => {
|
|
@@ -2789,9 +2883,9 @@ const ge = {
|
|
|
2789
2883
|
const { _tlv: e, _int: s } = ge, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
|
|
2790
2884
|
return e.encode(48, o);
|
|
2791
2885
|
}
|
|
2792
|
-
}, le = BigInt(0), Ee = BigInt(1),
|
|
2793
|
-
function
|
|
2794
|
-
const s =
|
|
2886
|
+
}, le = BigInt(0), Ee = BigInt(1), ms = BigInt(2), Me = BigInt(3), Gr = BigInt(4);
|
|
2887
|
+
function qr(r, e = {}) {
|
|
2888
|
+
const s = Br("weierstrass", r, e), { Fp: t, Fn: n } = s;
|
|
2795
2889
|
let o = s.CURVE;
|
|
2796
2890
|
const { h: i, n: a } = o;
|
|
2797
2891
|
ut(e, {}, {
|
|
@@ -2805,7 +2899,7 @@ function Ur(r, e = {}) {
|
|
|
2805
2899
|
const { endo: c } = e;
|
|
2806
2900
|
if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
|
|
2807
2901
|
throw new Error('invalid endo: expected "beta": bigint and "basises": array');
|
|
2808
|
-
const l =
|
|
2902
|
+
const l = ys(t, n);
|
|
2809
2903
|
function d() {
|
|
2810
2904
|
if (!t.isOdd)
|
|
2811
2905
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
@@ -2815,7 +2909,7 @@ function Ur(r, e = {}) {
|
|
|
2815
2909
|
if (He(h, "isCompressed"), h) {
|
|
2816
2910
|
d();
|
|
2817
2911
|
const T = !t.isOdd(E);
|
|
2818
|
-
return _e(
|
|
2912
|
+
return _e(ws(T), R);
|
|
2819
2913
|
} else
|
|
2820
2914
|
return _e(Uint8Array.of(4), R, t.toBytes(E));
|
|
2821
2915
|
}
|
|
@@ -2831,8 +2925,8 @@ function Ur(r, e = {}) {
|
|
|
2831
2925
|
try {
|
|
2832
2926
|
S = t.sqrt(O);
|
|
2833
2927
|
} catch (W) {
|
|
2834
|
-
const
|
|
2835
|
-
throw new Error("bad point: is not on curve, sqrt error" +
|
|
2928
|
+
const U = W instanceof Error ? ": " + W.message : "";
|
|
2929
|
+
throw new Error("bad point: is not on curve, sqrt error" + U);
|
|
2836
2930
|
}
|
|
2837
2931
|
d();
|
|
2838
2932
|
const C = t.isOdd(S);
|
|
@@ -2856,10 +2950,10 @@ function Ur(r, e = {}) {
|
|
|
2856
2950
|
}
|
|
2857
2951
|
if (!y(o.Gx, o.Gy))
|
|
2858
2952
|
throw new Error("bad curve params: generator point");
|
|
2859
|
-
const I = t.mul(t.pow(o.a, Me),
|
|
2953
|
+
const I = t.mul(t.pow(o.a, Me), Gr), L = t.mul(t.sqr(o.b), BigInt(27));
|
|
2860
2954
|
if (t.is0(t.add(I, L)))
|
|
2861
2955
|
throw new Error("bad curve params: a or b");
|
|
2862
|
-
function
|
|
2956
|
+
function F(P, u, h = !1) {
|
|
2863
2957
|
if (!t.isValid(u) || h && t.is0(u))
|
|
2864
2958
|
throw new Error(`bad point coordinate ${P}`);
|
|
2865
2959
|
return u;
|
|
@@ -2871,9 +2965,9 @@ function Ur(r, e = {}) {
|
|
|
2871
2965
|
function B(P) {
|
|
2872
2966
|
if (!c || !c.basises)
|
|
2873
2967
|
throw new Error("no endo");
|
|
2874
|
-
return
|
|
2968
|
+
return Ur(P, c.basises, n.ORDER);
|
|
2875
2969
|
}
|
|
2876
|
-
const Q =
|
|
2970
|
+
const Q = Nt((P, u) => {
|
|
2877
2971
|
const { X: h, Y: b, Z: E } = P;
|
|
2878
2972
|
if (t.eql(E, t.ONE))
|
|
2879
2973
|
return { x: h, y: b };
|
|
@@ -2885,7 +2979,7 @@ function Ur(r, e = {}) {
|
|
|
2885
2979
|
if (!t.eql(S, t.ONE))
|
|
2886
2980
|
throw new Error("invZ was invalid");
|
|
2887
2981
|
return { x: T, y: O };
|
|
2888
|
-
}), ve =
|
|
2982
|
+
}), ve = Nt((P) => {
|
|
2889
2983
|
if (P.is0()) {
|
|
2890
2984
|
if (e.allowInfinityPoint && !t.is0(P.Y))
|
|
2891
2985
|
return;
|
|
@@ -2909,7 +3003,7 @@ function Ur(r, e = {}) {
|
|
|
2909
3003
|
v(this, "X");
|
|
2910
3004
|
v(this, "Y");
|
|
2911
3005
|
v(this, "Z");
|
|
2912
|
-
this.X =
|
|
3006
|
+
this.X = F("x", u), this.Y = F("y", h, !0), this.Z = F("z", b), Object.freeze(this);
|
|
2913
3007
|
}
|
|
2914
3008
|
static CURVE() {
|
|
2915
3009
|
return o;
|
|
@@ -2928,7 +3022,7 @@ function Ur(r, e = {}) {
|
|
|
2928
3022
|
return h.assertValidity(), h;
|
|
2929
3023
|
}
|
|
2930
3024
|
static fromHex(u) {
|
|
2931
|
-
return D.fromBytes(
|
|
3025
|
+
return D.fromBytes(Ue(u));
|
|
2932
3026
|
}
|
|
2933
3027
|
get x() {
|
|
2934
3028
|
return this.toAffine().x;
|
|
@@ -2972,8 +3066,8 @@ function Ur(r, e = {}) {
|
|
|
2972
3066
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
2973
3067
|
double() {
|
|
2974
3068
|
const { a: u, b: h } = o, b = t.mul(h, Me), { X: E, Y: R, Z: T } = this;
|
|
2975
|
-
let O = t.ZERO, S = t.ZERO, C = t.ZERO, N = t.mul(E, E), W = t.mul(R, R),
|
|
2976
|
-
return k = t.add(k, k), C = t.mul(E, T), C = t.add(C, C), O = t.mul(u, C), S = t.mul(b,
|
|
3069
|
+
let O = t.ZERO, S = t.ZERO, C = t.ZERO, N = t.mul(E, E), W = t.mul(R, R), U = t.mul(T, T), k = t.mul(E, R);
|
|
3070
|
+
return k = t.add(k, k), C = t.mul(E, T), C = t.add(C, C), O = t.mul(u, C), S = t.mul(b, U), S = t.add(O, S), O = t.sub(W, S), S = t.add(W, S), S = t.mul(O, S), O = t.mul(k, O), C = t.mul(b, C), U = t.mul(u, U), k = t.sub(N, U), k = t.mul(u, k), k = t.add(k, C), C = t.add(N, N), N = t.add(C, N), N = t.add(N, U), N = t.mul(N, k), S = t.add(S, N), U = t.mul(R, T), U = t.add(U, U), N = t.mul(U, k), O = t.sub(O, N), C = t.mul(U, W), C = t.add(C, C), C = t.add(C, C), new D(O, S, C);
|
|
2977
3071
|
}
|
|
2978
3072
|
// Renes-Costello-Batina exception-free addition formula.
|
|
2979
3073
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
@@ -2983,11 +3077,11 @@ function Ur(r, e = {}) {
|
|
|
2983
3077
|
$(u);
|
|
2984
3078
|
const { X: h, Y: b, Z: E } = this, { X: R, Y: T, Z: O } = u;
|
|
2985
3079
|
let S = t.ZERO, C = t.ZERO, N = t.ZERO;
|
|
2986
|
-
const W = o.a,
|
|
3080
|
+
const W = o.a, U = t.mul(o.b, Me);
|
|
2987
3081
|
let k = t.mul(h, R), j = t.mul(b, T), V = t.mul(E, O), ee = t.add(h, b), G = t.add(R, T);
|
|
2988
3082
|
ee = t.mul(ee, G), G = t.add(k, j), ee = t.sub(ee, G), G = t.add(h, E);
|
|
2989
3083
|
let K = t.add(R, O);
|
|
2990
|
-
return G = t.mul(G, K), K = t.add(k, V), G = t.sub(G, K), K = t.add(b, E), S = t.add(T, O), K = t.mul(K, S), S = t.add(j, V), K = t.sub(K, S), N = t.mul(W, G), S = t.mul(
|
|
3084
|
+
return G = t.mul(G, K), K = t.add(k, V), G = t.sub(G, K), K = t.add(b, E), S = t.add(T, O), K = t.mul(K, S), S = t.add(j, V), K = t.sub(K, S), N = t.mul(W, G), S = t.mul(U, V), N = t.add(S, N), S = t.sub(j, N), N = t.add(j, N), C = t.mul(S, N), j = t.add(k, k), j = t.add(j, k), V = t.mul(W, V), G = t.mul(U, G), j = t.add(j, V), V = t.sub(k, V), V = t.mul(W, V), G = t.add(G, V), k = t.mul(j, G), C = t.add(C, k), k = t.mul(K, G), S = t.mul(ee, S), S = t.sub(S, k), k = t.mul(ee, j), N = t.mul(K, N), N = t.add(N, k), new D(S, C, N);
|
|
2991
3085
|
}
|
|
2992
3086
|
subtract(u) {
|
|
2993
3087
|
return this.add(u.negate());
|
|
@@ -3009,15 +3103,15 @@ function Ur(r, e = {}) {
|
|
|
3009
3103
|
if (!n.isValidNot0(u))
|
|
3010
3104
|
throw new Error("invalid scalar: out of range");
|
|
3011
3105
|
let b, E;
|
|
3012
|
-
const R = (T) => ne.cached(this, T, (O) =>
|
|
3106
|
+
const R = (T) => ne.cached(this, T, (O) => Dt(D, O));
|
|
3013
3107
|
if (h) {
|
|
3014
|
-
const { k1neg: T, k1: O, k2neg: S, k2: C } = B(u), { p: N, f: W } = R(O), { p:
|
|
3015
|
-
E = W.add(k), b = he(h.beta, N,
|
|
3108
|
+
const { k1neg: T, k1: O, k2neg: S, k2: C } = B(u), { p: N, f: W } = R(O), { p: U, f: k } = R(C);
|
|
3109
|
+
E = W.add(k), b = he(h.beta, N, U, T, S);
|
|
3016
3110
|
} else {
|
|
3017
3111
|
const { p: T, f: O } = R(u);
|
|
3018
3112
|
b = T, E = O;
|
|
3019
3113
|
}
|
|
3020
|
-
return
|
|
3114
|
+
return Dt(D, [b, E])[0];
|
|
3021
3115
|
}
|
|
3022
3116
|
/**
|
|
3023
3117
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -3035,7 +3129,7 @@ function Ur(r, e = {}) {
|
|
|
3035
3129
|
if (ne.hasCache(this))
|
|
3036
3130
|
return this.multiply(u);
|
|
3037
3131
|
if (h) {
|
|
3038
|
-
const { k1neg: E, k1: R, k2neg: T, k2: O } = B(u), { p1: S, p2: C } =
|
|
3132
|
+
const { k1neg: E, k1: R, k2neg: T, k2: O } = B(u), { p1: S, p2: C } = Mr(D, b, R, O);
|
|
3039
3133
|
return he(h.beta, S, C, E, T);
|
|
3040
3134
|
} else
|
|
3041
3135
|
return ne.unsafe(b, u);
|
|
@@ -3079,13 +3173,13 @@ function Ur(r, e = {}) {
|
|
|
3079
3173
|
v(D, "Fp", t), // scalar field
|
|
3080
3174
|
v(D, "Fn", n);
|
|
3081
3175
|
let Z = D;
|
|
3082
|
-
const xe = n.BITS, ne = new
|
|
3176
|
+
const xe = n.BITS, ne = new $r(Z, e.endo ? Math.ceil(xe / 2) : xe);
|
|
3083
3177
|
return Z.BASE.precompute(8), Z;
|
|
3084
3178
|
}
|
|
3085
|
-
function
|
|
3179
|
+
function ws(r) {
|
|
3086
3180
|
return Uint8Array.of(r ? 2 : 3);
|
|
3087
3181
|
}
|
|
3088
|
-
function
|
|
3182
|
+
function ys(r, e) {
|
|
3089
3183
|
return {
|
|
3090
3184
|
secretKey: e.BYTES,
|
|
3091
3185
|
publicKey: 1 + r.BYTES,
|
|
@@ -3094,8 +3188,8 @@ function ms(r, e) {
|
|
|
3094
3188
|
signature: 2 * e.BYTES
|
|
3095
3189
|
};
|
|
3096
3190
|
}
|
|
3097
|
-
function
|
|
3098
|
-
const { Fn: s } = r, t = e.randomBytes ||
|
|
3191
|
+
function Wr(r, e = {}) {
|
|
3192
|
+
const { Fn: s } = r, t = e.randomBytes || Qt, n = Object.assign(ys(r.Fp, s), { seed: fs(s.ORDER) });
|
|
3099
3193
|
function o(_) {
|
|
3100
3194
|
try {
|
|
3101
3195
|
const m = s.fromBytes(_);
|
|
@@ -3114,7 +3208,7 @@ function Fr(r, e = {}) {
|
|
|
3114
3208
|
}
|
|
3115
3209
|
}
|
|
3116
3210
|
function a(_ = t(n.seed)) {
|
|
3117
|
-
return
|
|
3211
|
+
return Dr(H(_, n.seed, "seed"), s.ORDER);
|
|
3118
3212
|
}
|
|
3119
3213
|
function c(_, m = !0) {
|
|
3120
3214
|
return r.BASE.multiply(s.fromBytes(_)).toBytes(m);
|
|
@@ -3138,23 +3232,23 @@ function Fr(r, e = {}) {
|
|
|
3138
3232
|
isValidSecretKey: o,
|
|
3139
3233
|
isValidPublicKey: i,
|
|
3140
3234
|
randomSecretKey: a
|
|
3141
|
-
}, w =
|
|
3235
|
+
}, w = Fr(a, c);
|
|
3142
3236
|
return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: w, Point: r, utils: f, lengths: n });
|
|
3143
3237
|
}
|
|
3144
|
-
function
|
|
3145
|
-
|
|
3238
|
+
function jr(r, e, s = {}) {
|
|
3239
|
+
Yt(e), ut(s, {}, {
|
|
3146
3240
|
hmac: "function",
|
|
3147
3241
|
lowS: "boolean",
|
|
3148
3242
|
randomBytes: "function",
|
|
3149
3243
|
bits2int: "function",
|
|
3150
3244
|
bits2int_modN: "function"
|
|
3151
3245
|
}), s = Object.assign({}, s);
|
|
3152
|
-
const t = s.randomBytes ||
|
|
3246
|
+
const t = s.randomBytes || Qt, n = s.hmac || ((u, h) => xs(e, u, h)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: f, utils: w, lengths: _ } = Wr(r, s), m = {
|
|
3153
3247
|
prehash: !0,
|
|
3154
3248
|
lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
|
|
3155
3249
|
format: "compact",
|
|
3156
3250
|
extraEntropy: !1
|
|
3157
|
-
}, A = a *
|
|
3251
|
+
}, A = a * ms < o.ORDER;
|
|
3158
3252
|
function y(u) {
|
|
3159
3253
|
const h = a >> Ee;
|
|
3160
3254
|
return u > h;
|
|
@@ -3168,7 +3262,7 @@ function Hr(r, e, s = {}) {
|
|
|
3168
3262
|
if (A)
|
|
3169
3263
|
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
3170
3264
|
}
|
|
3171
|
-
function
|
|
3265
|
+
function F(u, h) {
|
|
3172
3266
|
nt(h);
|
|
3173
3267
|
const b = _.signature, E = h === "compact" ? b : h === "recovered" ? b + 1 : void 0;
|
|
3174
3268
|
return H(u, E);
|
|
@@ -3186,7 +3280,7 @@ function Hr(r, e, s = {}) {
|
|
|
3186
3280
|
Object.freeze(this);
|
|
3187
3281
|
}
|
|
3188
3282
|
static fromBytes(h, b = m.format) {
|
|
3189
|
-
|
|
3283
|
+
F(h, b);
|
|
3190
3284
|
let E;
|
|
3191
3285
|
if (b === "der") {
|
|
3192
3286
|
const { r: S, s: C } = ge.toSig(H(h));
|
|
@@ -3197,7 +3291,7 @@ function Hr(r, e, s = {}) {
|
|
|
3197
3291
|
return new $(i.fromBytes(T), i.fromBytes(O), E);
|
|
3198
3292
|
}
|
|
3199
3293
|
static fromHex(h, b) {
|
|
3200
|
-
return this.fromBytes(
|
|
3294
|
+
return this.fromBytes(Ue(h), b);
|
|
3201
3295
|
}
|
|
3202
3296
|
assertRecovery() {
|
|
3203
3297
|
const { recovery: h } = this;
|
|
@@ -3212,7 +3306,7 @@ function Hr(r, e, s = {}) {
|
|
|
3212
3306
|
const { r: b, s: E } = this, R = this.assertRecovery(), T = R === 2 || R === 3 ? b + a : b;
|
|
3213
3307
|
if (!o.isValid(T))
|
|
3214
3308
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
3215
|
-
const O = o.toBytes(T), S = r.fromBytes(_e(
|
|
3309
|
+
const O = o.toBytes(T), S = r.fromBytes(_e(ws((R & 1) === 0), O)), C = i.inv(T), N = Q(H(h, void 0, "msgHash")), W = i.create(-N * C), U = i.create(E * C), k = r.BASE.multiplyUnsafe(W).add(S.multiplyUnsafe(U));
|
|
3216
3310
|
if (k.is0())
|
|
3217
3311
|
throw new Error("invalid recovery: point at infinify");
|
|
3218
3312
|
return k.assertValidity(), k;
|
|
@@ -3223,7 +3317,7 @@ function Hr(r, e, s = {}) {
|
|
|
3223
3317
|
}
|
|
3224
3318
|
toBytes(h = m.format) {
|
|
3225
3319
|
if (nt(h), h === "der")
|
|
3226
|
-
return
|
|
3320
|
+
return Ue(ge.hexFromSig(this));
|
|
3227
3321
|
const { r: b, s: E } = this, R = i.toBytes(b), T = i.toBytes(E);
|
|
3228
3322
|
return h === "recovered" ? (L(), _e(Uint8Array.of(this.assertRecovery()), R, T)) : _e(R, T);
|
|
3229
3323
|
}
|
|
@@ -3240,7 +3334,7 @@ function Hr(r, e, s = {}) {
|
|
|
3240
3334
|
return i.create(B(h));
|
|
3241
3335
|
}, ve = dt(c);
|
|
3242
3336
|
function he(u) {
|
|
3243
|
-
return
|
|
3337
|
+
return vr("num < 2^" + c, u, le, ve), i.toBytes(u);
|
|
3244
3338
|
}
|
|
3245
3339
|
function Z(u, h) {
|
|
3246
3340
|
return H(u, void 0, "message"), h ? H(e(u), void 0, "prehashed message") : u;
|
|
@@ -3257,7 +3351,7 @@ function Hr(r, e, s = {}) {
|
|
|
3257
3351
|
C.push(H(k, void 0, "extraEntropy"));
|
|
3258
3352
|
}
|
|
3259
3353
|
const N = _e(...C), W = O;
|
|
3260
|
-
function
|
|
3354
|
+
function U(k) {
|
|
3261
3355
|
const j = B(k);
|
|
3262
3356
|
if (!i.isValidNot0(j))
|
|
3263
3357
|
return;
|
|
@@ -3270,11 +3364,11 @@ function Hr(r, e, s = {}) {
|
|
|
3270
3364
|
let xt = (ee.x === G ? 0 : 2) | Number(ee.y & Ee), mt = K;
|
|
3271
3365
|
return E && y(K) && (mt = i.neg(K), xt ^= 1), new $(G, mt, A ? void 0 : xt);
|
|
3272
3366
|
}
|
|
3273
|
-
return { seed: N, k2sig:
|
|
3367
|
+
return { seed: N, k2sig: U };
|
|
3274
3368
|
}
|
|
3275
3369
|
function ne(u, h, b = {}) {
|
|
3276
3370
|
const { seed: E, k2sig: R } = xe(u, h, b);
|
|
3277
|
-
return
|
|
3371
|
+
return Er(e.outputLen, i.BYTES, n)(E, R).toBytes(b.format);
|
|
3278
3372
|
}
|
|
3279
3373
|
function D(u, h, b, E = {}) {
|
|
3280
3374
|
const { lowS: R, prehash: T, format: O } = et(E, m);
|
|
@@ -3282,12 +3376,12 @@ function Hr(r, e, s = {}) {
|
|
|
3282
3376
|
const S = u instanceof $ ? ", use sig.toBytes()" : "";
|
|
3283
3377
|
throw new Error("verify expects Uint8Array signature" + S);
|
|
3284
3378
|
}
|
|
3285
|
-
|
|
3379
|
+
F(u, O);
|
|
3286
3380
|
try {
|
|
3287
3381
|
const S = $.fromBytes(u, O), C = r.fromBytes(b);
|
|
3288
3382
|
if (R && S.hasHighS())
|
|
3289
3383
|
return !1;
|
|
3290
|
-
const { r: N, s: W } = S,
|
|
3384
|
+
const { r: N, s: W } = S, U = Q(h), k = i.inv(W), j = i.create(U * k), V = i.create(N * k), ee = r.BASE.multiplyUnsafe(j).add(C.multiplyUnsafe(V));
|
|
3291
3385
|
return ee.is0() ? !1 : i.create(ee.x) === N;
|
|
3292
3386
|
} catch {
|
|
3293
3387
|
return !1;
|
|
@@ -3320,44 +3414,44 @@ const ft = {
|
|
|
3320
3414
|
b: BigInt(7),
|
|
3321
3415
|
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
3322
3416
|
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
|
3323
|
-
},
|
|
3417
|
+
}, Vr = {
|
|
3324
3418
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
3325
3419
|
basises: [
|
|
3326
3420
|
[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
|
|
3327
3421
|
[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
|
|
3328
3422
|
]
|
|
3329
3423
|
}, Ut = /* @__PURE__ */ BigInt(2);
|
|
3330
|
-
function
|
|
3331
|
-
const e = ft.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, f = se(d, s, e) * d % e, w = se(f, s, e) * d % e, _ = se(w, Ut, e) * l % e, m = se(_, n, e) * _ % e, A = se(m, o, e) * m % e, y = se(A, a, e) * A % e, I = se(y, c, e) * y % e, L = se(I, a, e) * A % e,
|
|
3424
|
+
function Kr(r) {
|
|
3425
|
+
const e = ft.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, f = se(d, s, e) * d % e, w = se(f, s, e) * d % e, _ = se(w, Ut, e) * l % e, m = se(_, n, e) * _ % e, A = se(m, o, e) * m % e, y = se(A, a, e) * A % e, I = se(y, c, e) * y % e, L = se(I, a, e) * A % e, F = se(L, s, e) * d % e, $ = se(F, i, e) * m % e, B = se($, t, e) * l % e, Q = se(B, Ut, e);
|
|
3332
3426
|
if (!ot.eql(ot.sqr(Q), r))
|
|
3333
3427
|
throw new Error("Cannot find square root");
|
|
3334
3428
|
return Q;
|
|
3335
3429
|
}
|
|
3336
|
-
const ot = Ve(ft.p, { sqrt:
|
|
3430
|
+
const ot = Ve(ft.p, { sqrt: Kr }), zr = /* @__PURE__ */ qr(ft, {
|
|
3337
3431
|
Fp: ot,
|
|
3338
|
-
endo:
|
|
3339
|
-
}),
|
|
3432
|
+
endo: Vr
|
|
3433
|
+
}), Yr = /* @__PURE__ */ jr(zr, wr), Zr = BigInt(0), Re = BigInt(1), Xr = BigInt(2), Jr = BigInt(7), Qr = BigInt(256), en = BigInt(113), bs = [], vs = [], Ss = [];
|
|
3340
3434
|
for (let r = 0, e = Re, s = 1, t = 0; r < 24; r++) {
|
|
3341
|
-
[s, t] = [t, (2 * s + 3 * t) % 5],
|
|
3342
|
-
let n =
|
|
3435
|
+
[s, t] = [t, (2 * s + 3 * t) % 5], bs.push(2 * (5 * t + s)), vs.push((r + 1) * (r + 2) / 2 % 64);
|
|
3436
|
+
let n = Zr;
|
|
3343
3437
|
for (let o = 0; o < 7; o++)
|
|
3344
|
-
e = (e << Re ^ (e >>
|
|
3345
|
-
|
|
3438
|
+
e = (e << Re ^ (e >> Jr) * en) % Qr, e & Xr && (n ^= Re << (Re << BigInt(o)) - Re);
|
|
3439
|
+
Ss.push(n);
|
|
3346
3440
|
}
|
|
3347
|
-
const
|
|
3348
|
-
function
|
|
3441
|
+
const Es = ur(Ss, !0), tn = Es[0], sn = Es[1], Ht = (r, e, s) => s > 32 ? pr(r, e, s) : hr(r, e, s), Gt = (r, e, s) => s > 32 ? gr(r, e, s) : fr(r, e, s);
|
|
3442
|
+
function rn(r, e = 24) {
|
|
3349
3443
|
const s = new Uint32Array(10);
|
|
3350
3444
|
for (let t = 24 - e; t < 24; t++) {
|
|
3351
3445
|
for (let i = 0; i < 10; i++)
|
|
3352
3446
|
s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
|
|
3353
3447
|
for (let i = 0; i < 10; i += 2) {
|
|
3354
|
-
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], f =
|
|
3448
|
+
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], f = Ht(l, d, 1) ^ s[a], w = Gt(l, d, 1) ^ s[a + 1];
|
|
3355
3449
|
for (let _ = 0; _ < 50; _ += 10)
|
|
3356
3450
|
r[i + _] ^= f, r[i + _ + 1] ^= w;
|
|
3357
3451
|
}
|
|
3358
3452
|
let n = r[2], o = r[3];
|
|
3359
3453
|
for (let i = 0; i < 24; i++) {
|
|
3360
|
-
const a =
|
|
3454
|
+
const a = vs[i], c = Ht(n, o, a), l = Gt(n, o, a), d = bs[i];
|
|
3361
3455
|
n = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
|
|
3362
3456
|
}
|
|
3363
3457
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -3366,7 +3460,7 @@ function Qr(r, e = 24) {
|
|
|
3366
3460
|
for (let a = 0; a < 10; a++)
|
|
3367
3461
|
r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
|
|
3368
3462
|
}
|
|
3369
|
-
r[0] ^=
|
|
3463
|
+
r[0] ^= tn[t], r[1] ^= sn[t];
|
|
3370
3464
|
}
|
|
3371
3465
|
Te(s);
|
|
3372
3466
|
}
|
|
@@ -3386,13 +3480,13 @@ class pt {
|
|
|
3386
3480
|
v(this, "rounds");
|
|
3387
3481
|
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ue(t, "outputLen"), !(0 < e && e < 200))
|
|
3388
3482
|
throw new Error("only keccak-f1600 function is supported");
|
|
3389
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
3483
|
+
this.state = new Uint8Array(200), this.state32 = tr(this.state);
|
|
3390
3484
|
}
|
|
3391
3485
|
clone() {
|
|
3392
3486
|
return this._cloneInto();
|
|
3393
3487
|
}
|
|
3394
3488
|
keccak() {
|
|
3395
|
-
|
|
3489
|
+
Ot(this.state32), rn(this.state32, this.rounds), Ot(this.state32), this.posOut = 0, this.pos = 0;
|
|
3396
3490
|
}
|
|
3397
3491
|
update(e) {
|
|
3398
3492
|
Ie(this), H(e);
|
|
@@ -3431,7 +3525,7 @@ class pt {
|
|
|
3431
3525
|
return ue(e), this.xofInto(new Uint8Array(e));
|
|
3432
3526
|
}
|
|
3433
3527
|
digestInto(e) {
|
|
3434
|
-
if (
|
|
3528
|
+
if (Zt(e, this), this.finished)
|
|
3435
3529
|
throw new Error("digest() was already called");
|
|
3436
3530
|
return this.writeInto(e), this.destroy(), e;
|
|
3437
3531
|
}
|
|
@@ -3446,8 +3540,8 @@ class pt {
|
|
|
3446
3540
|
return e || (e = new pt(s, t, n, i, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = t, e.outputLen = n, e.enableXOF = i, e.destroyed = this.destroyed, e;
|
|
3447
3541
|
}
|
|
3448
3542
|
}
|
|
3449
|
-
const
|
|
3450
|
-
class
|
|
3543
|
+
const nn = (r, e, s, t = {}) => Jt(() => new pt(e, r, s), t), qt = /* @__PURE__ */ nn(1, 136, 32);
|
|
3544
|
+
class on {
|
|
3451
3545
|
async verifyJWT(e, s) {
|
|
3452
3546
|
try {
|
|
3453
3547
|
const t = this.decodeJWT(e);
|
|
@@ -3468,7 +3562,7 @@ class tn {
|
|
|
3468
3562
|
}
|
|
3469
3563
|
}
|
|
3470
3564
|
decodeJWT(e) {
|
|
3471
|
-
return
|
|
3565
|
+
return Os(e);
|
|
3472
3566
|
}
|
|
3473
3567
|
/**
|
|
3474
3568
|
* EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
|
|
@@ -3483,33 +3577,33 @@ class tn {
|
|
|
3483
3577
|
${t.length}`
|
|
3484
3578
|
), o = new Uint8Array(n.length + t.length);
|
|
3485
3579
|
o.set(n, 0), o.set(t, n.length);
|
|
3486
|
-
const i =
|
|
3580
|
+
const i = qt(o), a = s.startsWith("0x") ? s.slice(2) : s;
|
|
3487
3581
|
if (a.length !== 130)
|
|
3488
|
-
throw new Error(
|
|
3489
|
-
const c =
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
).addRecoveryBit(w).recoverPublicKey(i).toBytes(!1).slice(1), y =
|
|
3582
|
+
throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
|
|
3583
|
+
const c = an(a), l = c.slice(0, 32), d = c.slice(32, 64), f = c[64], w = f >= 27 ? f - 27 : f, A = new Yr.Signature(
|
|
3584
|
+
Wt(l),
|
|
3585
|
+
Wt(d)
|
|
3586
|
+
).addRecoveryBit(w).recoverPublicKey(i).toBytes(!1).slice(1), y = qt(A);
|
|
3493
3587
|
return "0x" + ke(y.slice(12));
|
|
3494
3588
|
}
|
|
3495
3589
|
}
|
|
3496
|
-
function
|
|
3590
|
+
function an(r) {
|
|
3497
3591
|
const e = new Uint8Array(r.length / 2);
|
|
3498
3592
|
for (let s = 0; s < e.length; s++)
|
|
3499
3593
|
e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
|
|
3500
3594
|
return e;
|
|
3501
3595
|
}
|
|
3502
|
-
function
|
|
3596
|
+
function Wt(r) {
|
|
3503
3597
|
let e = "0x";
|
|
3504
3598
|
for (const s of r) e += s.toString(16).padStart(2, "0");
|
|
3505
3599
|
return BigInt(e);
|
|
3506
3600
|
}
|
|
3507
|
-
const
|
|
3508
|
-
class
|
|
3601
|
+
const cn = 3e4;
|
|
3602
|
+
class ln {
|
|
3509
3603
|
async request(e) {
|
|
3510
3604
|
const s = new AbortController(), t = setTimeout(
|
|
3511
3605
|
() => s.abort(),
|
|
3512
|
-
e.timeoutMs ??
|
|
3606
|
+
e.timeoutMs ?? cn
|
|
3513
3607
|
);
|
|
3514
3608
|
try {
|
|
3515
3609
|
const n = await fetch(e.url, {
|
|
@@ -3543,7 +3637,7 @@ class gt {
|
|
|
3543
3637
|
}
|
|
3544
3638
|
openAuth(e) {
|
|
3545
3639
|
return new Promise((s, t) => {
|
|
3546
|
-
const n = e.width ?? 500, o = e.height ??
|
|
3640
|
+
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 = gt.generateState(), l = e.authUrl.includes("?") ? "&" : "?", d = `${e.authUrl}${l}state=${c}`, f = window.open(
|
|
3547
3641
|
d,
|
|
3548
3642
|
"CROSSx OAuth",
|
|
3549
3643
|
`width=${n},height=${o},left=${i},top=${a}`
|
|
@@ -3553,28 +3647,28 @@ class gt {
|
|
|
3553
3647
|
return;
|
|
3554
3648
|
}
|
|
3555
3649
|
const w = setTimeout(() => {
|
|
3556
|
-
p.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"),
|
|
3650
|
+
p.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), F(), t(new Error("Authentication timeout"));
|
|
3557
3651
|
}, 5 * 60 * 1e3), _ = 10, m = 30;
|
|
3558
3652
|
let A = 0, y = null;
|
|
3559
3653
|
const I = () => {
|
|
3560
3654
|
clearInterval(L), p.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + m + "초간 대기합니다"), y = setTimeout(() => {
|
|
3561
|
-
|
|
3655
|
+
F(), t(new Error(
|
|
3562
3656
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
3563
3657
|
));
|
|
3564
3658
|
}, m * 1e3);
|
|
3565
3659
|
}, L = setInterval(() => {
|
|
3566
3660
|
A++;
|
|
3567
3661
|
try {
|
|
3568
|
-
f.closed && (A <= _ ? I() : (
|
|
3662
|
+
f.closed && (A <= _ ? I() : (F(), t(new Error("로그인이 취소되었습니다"))));
|
|
3569
3663
|
} catch {
|
|
3570
3664
|
I();
|
|
3571
3665
|
}
|
|
3572
|
-
}, 1e3),
|
|
3666
|
+
}, 1e3), F = () => {
|
|
3573
3667
|
clearTimeout(w), clearInterval(L), y && clearTimeout(y), window.removeEventListener("message", $);
|
|
3574
3668
|
}, $ = (B) => {
|
|
3575
3669
|
var ve, he, Z, xe, ne, D, P;
|
|
3576
3670
|
if (B.origin !== e.expectedOrigin) return;
|
|
3577
|
-
|
|
3671
|
+
F(), p.log("[CROSSx] OAuth postMessage 수신 — status:", B.data.status);
|
|
3578
3672
|
const Q = B.data.state ?? ((ve = B.data.data) == null ? void 0 : ve.state);
|
|
3579
3673
|
if (!Q || Q !== c) {
|
|
3580
3674
|
t(new Error("OAuth state mismatch — possible CSRF attack"));
|
|
@@ -3594,7 +3688,7 @@ class gt {
|
|
|
3594
3688
|
}
|
|
3595
3689
|
}
|
|
3596
3690
|
const Oe = "crossx_wallet_data";
|
|
3597
|
-
class
|
|
3691
|
+
class dn {
|
|
3598
3692
|
constructor(e) {
|
|
3599
3693
|
this.storage = e;
|
|
3600
3694
|
}
|
|
@@ -3610,7 +3704,7 @@ class on {
|
|
|
3610
3704
|
};
|
|
3611
3705
|
return await this.storage.set(Oe, t), t;
|
|
3612
3706
|
} catch (s) {
|
|
3613
|
-
throw new x(g.WALLET_CREATION_FAILED, "
|
|
3707
|
+
throw new x(g.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", s);
|
|
3614
3708
|
}
|
|
3615
3709
|
}
|
|
3616
3710
|
async getAddresses(e) {
|
|
@@ -3684,7 +3778,7 @@ class qe {
|
|
|
3684
3778
|
if (!e)
|
|
3685
3779
|
throw new x(
|
|
3686
3780
|
g.AUTH_NOT_AUTHENTICATED,
|
|
3687
|
-
"
|
|
3781
|
+
"인증 토큰을 찾을 수 없습니다. 먼저 로그인해 주세요."
|
|
3688
3782
|
);
|
|
3689
3783
|
return e;
|
|
3690
3784
|
}
|
|
@@ -3704,7 +3798,7 @@ class qe {
|
|
|
3704
3798
|
})).data;
|
|
3705
3799
|
if (d && typeof d.code == "number") {
|
|
3706
3800
|
if (d.code < 0 || d.code >= 400) {
|
|
3707
|
-
const f = d.message || d.data || "API
|
|
3801
|
+
const f = d.message || d.data || "API 요청에 실패했습니다";
|
|
3708
3802
|
p.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
|
|
3709
3803
|
code: d.code,
|
|
3710
3804
|
message: f,
|
|
@@ -3721,7 +3815,7 @@ class qe {
|
|
|
3721
3815
|
} catch (l) {
|
|
3722
3816
|
if (l instanceof x) throw l;
|
|
3723
3817
|
if ((a = l.response) != null && a.data) {
|
|
3724
|
-
const d = l.response.data, f = d.message || d.data || "API
|
|
3818
|
+
const d = l.response.data, f = d.message || d.data || "API 요청에 실패했습니다", w = d.code || "UNKNOWN";
|
|
3725
3819
|
throw p.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
|
|
3726
3820
|
code: w,
|
|
3727
3821
|
message: f,
|
|
@@ -3730,7 +3824,7 @@ class qe {
|
|
|
3730
3824
|
status: (c = l.response) == null ? void 0 : c.status
|
|
3731
3825
|
}), new x(
|
|
3732
3826
|
g.UNKNOWN_ERROR,
|
|
3733
|
-
`Wallet Gateway
|
|
3827
|
+
`Wallet Gateway 오류 (${w}): ${f}`
|
|
3734
3828
|
);
|
|
3735
3829
|
}
|
|
3736
3830
|
throw l;
|
|
@@ -3804,15 +3898,15 @@ class qe {
|
|
|
3804
3898
|
switch (e) {
|
|
3805
3899
|
case "sign":
|
|
3806
3900
|
case "send":
|
|
3807
|
-
if (!s.tx) throw new x(g.TX_INVALID_PARAMS, "prepare: tx
|
|
3901
|
+
if (!s.tx) throw new x(g.TX_INVALID_PARAMS, "prepare: tx가 필요합니다");
|
|
3808
3902
|
t = { unsignedTx: this.buildUnsignedTx(s.tx) };
|
|
3809
3903
|
break;
|
|
3810
3904
|
case "sign-message":
|
|
3811
|
-
if (!s.message) throw new x(g.TX_INVALID_PARAMS, "prepare: message
|
|
3905
|
+
if (!s.message) throw new x(g.TX_INVALID_PARAMS, "prepare: message가 필요합니다");
|
|
3812
3906
|
t = { message: s.message }, s.from && (t.from = s.from);
|
|
3813
3907
|
break;
|
|
3814
3908
|
case "sign-typed-data":
|
|
3815
|
-
if (!s.typedData) throw new x(g.TX_INVALID_PARAMS, "prepare: typedData
|
|
3909
|
+
if (!s.typedData) throw new x(g.TX_INVALID_PARAMS, "prepare: typedData가 필요합니다");
|
|
3816
3910
|
t = { typedData: s.typedData }, s.from && (t.from = s.from);
|
|
3817
3911
|
break;
|
|
3818
3912
|
}
|
|
@@ -3986,7 +4080,7 @@ class Ce {
|
|
|
3986
4080
|
}
|
|
3987
4081
|
isCacheValid() {
|
|
3988
4082
|
if (this.loadedAt === 0) return !1;
|
|
3989
|
-
const e = this.usingFallback ?
|
|
4083
|
+
const e = this.usingFallback ? Zs : Ys;
|
|
3990
4084
|
return e === 0 ? !0 : Date.now() - this.loadedAt < e;
|
|
3991
4085
|
}
|
|
3992
4086
|
populateCache(e, s) {
|
|
@@ -4006,7 +4100,7 @@ class Ce {
|
|
|
4006
4100
|
}
|
|
4007
4101
|
handleEnvelopeError(e) {
|
|
4008
4102
|
if (e.code < 0) {
|
|
4009
|
-
const s = typeof e.data == "string" ? e.data : e.message ?? "
|
|
4103
|
+
const s = typeof e.data == "string" ? e.data : e.message ?? "체인 레지스트리 요청에 실패했습니다";
|
|
4010
4104
|
throw new x(
|
|
4011
4105
|
Ce.mapErrorCode(e.code),
|
|
4012
4106
|
s
|
|
@@ -4020,7 +4114,7 @@ class Ce {
|
|
|
4020
4114
|
if (s) return s;
|
|
4021
4115
|
throw new x(
|
|
4022
4116
|
g.CHAIN_NOT_SUPPORTED,
|
|
4023
|
-
|
|
4117
|
+
`지원하지 않는 체인: ${e}`
|
|
4024
4118
|
);
|
|
4025
4119
|
}
|
|
4026
4120
|
static fallbackChains() {
|
|
@@ -4048,7 +4142,7 @@ class Ce {
|
|
|
4048
4142
|
}
|
|
4049
4143
|
}
|
|
4050
4144
|
}
|
|
4051
|
-
const
|
|
4145
|
+
const jt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", un = {
|
|
4052
4146
|
light: {
|
|
4053
4147
|
bg: "#FFFFFF",
|
|
4054
4148
|
border: "rgba(18,18,18,0.05)",
|
|
@@ -4094,8 +4188,8 @@ const Wt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", an = {
|
|
|
4094
4188
|
onPrimary: "#FFFFFF"
|
|
4095
4189
|
}
|
|
4096
4190
|
};
|
|
4097
|
-
function
|
|
4098
|
-
const s =
|
|
4191
|
+
function Vt(r, e) {
|
|
4192
|
+
const s = un[r], t = e == null ? void 0 : e[r];
|
|
4099
4193
|
return t ? {
|
|
4100
4194
|
...s,
|
|
4101
4195
|
// ── Brand
|
|
@@ -4124,7 +4218,7 @@ function jt(r, e) {
|
|
|
4124
4218
|
...t.bg !== void 0 && { bg: t.bg, inputBg: t.bg }
|
|
4125
4219
|
} : s;
|
|
4126
4220
|
}
|
|
4127
|
-
const
|
|
4221
|
+
const hn = `
|
|
4128
4222
|
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
|
|
4129
4223
|
|
|
4130
4224
|
#${te} {
|
|
@@ -5041,13 +5135,13 @@ const cn = `
|
|
|
5041
5135
|
}
|
|
5042
5136
|
`;
|
|
5043
5137
|
function me() {
|
|
5044
|
-
let r = document.getElementById(
|
|
5045
|
-
r || (r = document.createElement("style"), r.id =
|
|
5138
|
+
let r = document.getElementById(jt);
|
|
5139
|
+
r || (r = document.createElement("style"), r.id = jt, document.head.appendChild(r)), r.textContent = hn;
|
|
5046
5140
|
}
|
|
5047
5141
|
function Y(r) {
|
|
5048
5142
|
return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
|
|
5049
5143
|
}
|
|
5050
|
-
function
|
|
5144
|
+
function fn(r, e = "CROSS", s = 18) {
|
|
5051
5145
|
if (!r || r === "0x" || r === "0x0") return null;
|
|
5052
5146
|
try {
|
|
5053
5147
|
const t = BigInt(r);
|
|
@@ -5058,7 +5152,7 @@ function ln(r, e = "CROSS", s = 18) {
|
|
|
5058
5152
|
return null;
|
|
5059
5153
|
}
|
|
5060
5154
|
}
|
|
5061
|
-
const
|
|
5155
|
+
const Kt = {
|
|
5062
5156
|
1: "Ethereum Mainnet",
|
|
5063
5157
|
5: "Goerli Testnet",
|
|
5064
5158
|
11155111: "Ethereum Sepolia",
|
|
@@ -5081,9 +5175,9 @@ const Vt = {
|
|
|
5081
5175
|
612044: "CROSS Testnet",
|
|
5082
5176
|
612055: "CROSS Mainnet"
|
|
5083
5177
|
};
|
|
5084
|
-
function
|
|
5178
|
+
function Is(r) {
|
|
5085
5179
|
const e = parseInt(r.split(":")[1] ?? "", 10);
|
|
5086
|
-
return !isNaN(e) &&
|
|
5180
|
+
return !isNaN(e) && Kt[e] ? Kt[e] : r;
|
|
5087
5181
|
}
|
|
5088
5182
|
function it(r, e) {
|
|
5089
5183
|
if (r === 0n) return "0";
|
|
@@ -5098,18 +5192,18 @@ function tt(r) {
|
|
|
5098
5192
|
return r;
|
|
5099
5193
|
}
|
|
5100
5194
|
}
|
|
5101
|
-
function
|
|
5195
|
+
function pn(r) {
|
|
5102
5196
|
try {
|
|
5103
5197
|
return BigInt(r).toLocaleString();
|
|
5104
5198
|
} catch {
|
|
5105
5199
|
return r;
|
|
5106
5200
|
}
|
|
5107
5201
|
}
|
|
5108
|
-
function
|
|
5202
|
+
function gn(r) {
|
|
5109
5203
|
const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
|
|
5110
5204
|
if (!e) return null;
|
|
5111
5205
|
try {
|
|
5112
|
-
const a = BigInt(e), c =
|
|
5206
|
+
const a = BigInt(e), c = pn(e);
|
|
5113
5207
|
if (t) {
|
|
5114
5208
|
const l = a * BigInt(t);
|
|
5115
5209
|
return {
|
|
@@ -5134,8 +5228,8 @@ function un(r) {
|
|
|
5134
5228
|
return null;
|
|
5135
5229
|
}
|
|
5136
5230
|
}
|
|
5137
|
-
function
|
|
5138
|
-
const e =
|
|
5231
|
+
function Ts(r) {
|
|
5232
|
+
const e = gn(r);
|
|
5139
5233
|
if (!e) return q("Estimated fee", "<span>—</span>");
|
|
5140
5234
|
let s = q("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
|
|
5141
5235
|
return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += q("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += q("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += q("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += q("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
|
|
@@ -5147,7 +5241,7 @@ const de = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="
|
|
|
5147
5241
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
5148
5242
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
5149
5243
|
</svg>`;
|
|
5150
|
-
function
|
|
5244
|
+
function _n(r) {
|
|
5151
5245
|
return `<svg width="28" height="28" viewBox="0 0 28 28" fill="none">
|
|
5152
5246
|
<circle cx="14" cy="14" r="14" fill="${r}"/>
|
|
5153
5247
|
<path d="M14 7.5L19.2 10.5V16.5L14 19.5L8.8 16.5V10.5L14 7.5Z" fill="white" opacity="0.9"/>
|
|
@@ -5157,9 +5251,9 @@ const _t = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
|
5157
5251
|
<rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
|
|
5158
5252
|
<path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
|
|
5159
5253
|
<rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
|
|
5160
|
-
</svg>`,
|
|
5254
|
+
</svg>`, xn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
5161
5255
|
<path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="var(--cx-secondary)"/>
|
|
5162
|
-
</svg>`,
|
|
5256
|
+
</svg>`, mn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
5163
5257
|
<circle cx="12" cy="12" r="12" fill="var(--cx-secondary)"/>
|
|
5164
5258
|
<circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
|
|
5165
5259
|
<path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
|
|
@@ -5195,9 +5289,9 @@ function q(r, e) {
|
|
|
5195
5289
|
<div class="__crossx-row-value">${e}</div>
|
|
5196
5290
|
</div>`;
|
|
5197
5291
|
}
|
|
5198
|
-
function
|
|
5292
|
+
function wn(r, e) {
|
|
5199
5293
|
const s = e, t = Ke(), n = r.to ? `<span class="__crossx-addr-text">${Y(r.to)}</span>
|
|
5200
|
-
<button class="__crossx-copy-btn" data-copy="${M(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", o =
|
|
5294
|
+
<button class="__crossx-copy-btn" data-copy="${M(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", o = Ts(r), i = r.data && r.data !== "0x" ? r.data : "0x", a = document.createElement("div");
|
|
5201
5295
|
return a.id = te, a.innerHTML = `
|
|
5202
5296
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
5203
5297
|
<div class="__crossx-header">
|
|
@@ -5219,7 +5313,7 @@ function gn(r, e) {
|
|
|
5219
5313
|
<hr class="__crossx-divider">
|
|
5220
5314
|
<div class="__crossx-rows">
|
|
5221
5315
|
${q("To", n)}
|
|
5222
|
-
${q("Network", `<span>${
|
|
5316
|
+
${q("Network", `<span>${Is(r.chainId)}</span>`)}
|
|
5223
5317
|
${o}
|
|
5224
5318
|
</div>
|
|
5225
5319
|
</div>
|
|
@@ -5233,9 +5327,9 @@ function gn(r, e) {
|
|
|
5233
5327
|
</div>
|
|
5234
5328
|
`, a;
|
|
5235
5329
|
}
|
|
5236
|
-
function
|
|
5330
|
+
function yn(r, e) {
|
|
5237
5331
|
const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Ke(), i = r.to ? `<span class="__crossx-addr-text">${Y(r.to)}</span>
|
|
5238
|
-
<button class="__crossx-copy-btn" data-copy="${M(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", a =
|
|
5332
|
+
<button class="__crossx-copy-btn" data-copy="${M(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", a = Ts(r), l = fn(r.value, t, n) ?? "—", d = document.createElement("div");
|
|
5239
5333
|
return d.id = te, d.innerHTML = `
|
|
5240
5334
|
<div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
5241
5335
|
<div class="__crossx-header">
|
|
@@ -5250,7 +5344,7 @@ function _n(r, e) {
|
|
|
5250
5344
|
<div class="__crossx-body-cols">
|
|
5251
5345
|
<div class="__crossx-rows">
|
|
5252
5346
|
${q("To", i)}
|
|
5253
|
-
${q("Network", `<span>${
|
|
5347
|
+
${q("Network", `<span>${Is(r.chainId)}</span>`)}
|
|
5254
5348
|
${a}
|
|
5255
5349
|
</div>
|
|
5256
5350
|
<div class="__crossx-pill">
|
|
@@ -5274,10 +5368,10 @@ function Ke() {
|
|
|
5274
5368
|
function M(r) {
|
|
5275
5369
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5276
5370
|
}
|
|
5277
|
-
function
|
|
5371
|
+
function bn(r) {
|
|
5278
5372
|
return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
|
|
5279
5373
|
}
|
|
5280
|
-
function
|
|
5374
|
+
function vn(r) {
|
|
5281
5375
|
if (typeof r == "string") return M(r);
|
|
5282
5376
|
if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
|
|
5283
5377
|
try {
|
|
@@ -5286,7 +5380,7 @@ function mn(r) {
|
|
|
5286
5380
|
return String(r);
|
|
5287
5381
|
}
|
|
5288
5382
|
}
|
|
5289
|
-
function
|
|
5383
|
+
function Sn(r, e) {
|
|
5290
5384
|
const s = q(
|
|
5291
5385
|
"From",
|
|
5292
5386
|
`<span class="__crossx-addr-text">${Y(r.from)}</span>
|
|
@@ -5318,7 +5412,7 @@ function wn(r, e) {
|
|
|
5318
5412
|
</div>
|
|
5319
5413
|
`, c;
|
|
5320
5414
|
}
|
|
5321
|
-
function
|
|
5415
|
+
function En(r, e) {
|
|
5322
5416
|
const s = document.createElement("div");
|
|
5323
5417
|
return s.id = te, s.innerHTML = `
|
|
5324
5418
|
<div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -5335,10 +5429,10 @@ function yn(r, e) {
|
|
|
5335
5429
|
</div>
|
|
5336
5430
|
`, s;
|
|
5337
5431
|
}
|
|
5338
|
-
function
|
|
5432
|
+
function In(r, e, s) {
|
|
5339
5433
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
5340
5434
|
if (o) {
|
|
5341
|
-
const m = n ?
|
|
5435
|
+
const m = n ? mn : t ? "" : xn, A = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
5342
5436
|
m ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${m}<span>${A}</span>`) : o.textContent = A;
|
|
5343
5437
|
}
|
|
5344
5438
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
@@ -5374,7 +5468,7 @@ function bn(r, e, s) {
|
|
|
5374
5468
|
});
|
|
5375
5469
|
});
|
|
5376
5470
|
}
|
|
5377
|
-
function
|
|
5471
|
+
function Tn(r, e) {
|
|
5378
5472
|
const s = e, t = Ke(), n = M(r.message), o = document.createElement("div");
|
|
5379
5473
|
return o.id = te, o.innerHTML = `
|
|
5380
5474
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -5406,7 +5500,7 @@ function vn(r, e) {
|
|
|
5406
5500
|
</div>
|
|
5407
5501
|
`, o;
|
|
5408
5502
|
}
|
|
5409
|
-
function
|
|
5503
|
+
function An(r, e) {
|
|
5410
5504
|
const s = e, t = Ke();
|
|
5411
5505
|
let n = {};
|
|
5412
5506
|
if (typeof r.typedData == "string")
|
|
@@ -5422,7 +5516,7 @@ function Sn(r, e) {
|
|
|
5422
5516
|
<span class="__crossx-td-value">${M(o)}</span>
|
|
5423
5517
|
</div>`;
|
|
5424
5518
|
for (const [l, d] of Object.entries(i)) {
|
|
5425
|
-
const f =
|
|
5519
|
+
const f = vn(d), _ = bn(d) ? `<span class="__crossx-addr-text">${Y(d)}</span>
|
|
5426
5520
|
<button class="__crossx-copy-btn" data-copy="${M(String(d))}" title="Copy">${de}</button>` : `<span>${f}</span>`;
|
|
5427
5521
|
a += `
|
|
5428
5522
|
<div class="__crossx-td-row">
|
|
@@ -5461,11 +5555,11 @@ function Sn(r, e) {
|
|
|
5461
5555
|
</div>
|
|
5462
5556
|
`, c;
|
|
5463
5557
|
}
|
|
5464
|
-
const
|
|
5558
|
+
const Rn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
5465
5559
|
<line x1="12" y1="5" x2="12" y2="19"/>
|
|
5466
5560
|
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
5467
5561
|
</svg>`;
|
|
5468
|
-
function
|
|
5562
|
+
function On(r, e, s) {
|
|
5469
5563
|
const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
|
|
5470
5564
|
const a = t && i.address.toLowerCase() === t;
|
|
5471
5565
|
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${M(i.address)}">
|
|
@@ -5496,7 +5590,7 @@ function In(r, e, s) {
|
|
|
5496
5590
|
${n}
|
|
5497
5591
|
</div>
|
|
5498
5592
|
<button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
|
|
5499
|
-
<span class="__crossx-wallet-add-icon">${
|
|
5593
|
+
<span class="__crossx-wallet-add-icon">${Rn}</span>
|
|
5500
5594
|
<span class="__crossx-wallet-add-label">add a wallet</span>
|
|
5501
5595
|
</button>
|
|
5502
5596
|
</div>
|
|
@@ -5505,16 +5599,16 @@ function In(r, e, s) {
|
|
|
5505
5599
|
</div>
|
|
5506
5600
|
`, o;
|
|
5507
5601
|
}
|
|
5508
|
-
const
|
|
5602
|
+
const Cn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
5509
5603
|
<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"/>
|
|
5510
5604
|
<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"/>
|
|
5511
|
-
</svg>`,
|
|
5605
|
+
</svg>`, kn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
5512
5606
|
<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"/>
|
|
5513
5607
|
<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"/>
|
|
5514
5608
|
<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"/>
|
|
5515
5609
|
<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"/>
|
|
5516
5610
|
</svg>`;
|
|
5517
|
-
function
|
|
5611
|
+
function Nn(r) {
|
|
5518
5612
|
const e = r, s = document.createElement("div");
|
|
5519
5613
|
return s.id = te, s.innerHTML = `
|
|
5520
5614
|
<div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -5529,11 +5623,11 @@ function Rn(r) {
|
|
|
5529
5623
|
<div class="__crossx-body">
|
|
5530
5624
|
<div class="__crossx-login-btn-row">
|
|
5531
5625
|
<button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
|
|
5532
|
-
<span class="__crossx-login-icon" style="color:var(--cx-value);">${
|
|
5626
|
+
<span class="__crossx-login-icon" style="color:var(--cx-value);">${Cn}</span>
|
|
5533
5627
|
<span class="__crossx-login-btn-label">Sign in with Apple</span>
|
|
5534
5628
|
</button>
|
|
5535
5629
|
<button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
|
|
5536
|
-
<span class="__crossx-login-icon">${
|
|
5630
|
+
<span class="__crossx-login-icon">${kn}</span>
|
|
5537
5631
|
<span class="__crossx-login-btn-label">Sign in with Google</span>
|
|
5538
5632
|
</button>
|
|
5539
5633
|
</div>
|
|
@@ -5545,7 +5639,7 @@ function Rn(r) {
|
|
|
5545
5639
|
</div>
|
|
5546
5640
|
`, s;
|
|
5547
5641
|
}
|
|
5548
|
-
function
|
|
5642
|
+
function Pn(r) {
|
|
5549
5643
|
const e = r, s = document.createElement("div");
|
|
5550
5644
|
return s.id = te, s.innerHTML = `
|
|
5551
5645
|
<div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -5561,7 +5655,7 @@ function On(r) {
|
|
|
5561
5655
|
<p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
|
|
5562
5656
|
</div>
|
|
5563
5657
|
<button class="__crossx-recover-btn" id="__crossx-recover-btn">
|
|
5564
|
-
<span>${
|
|
5658
|
+
<span>${_n(e.primary)}</span>
|
|
5565
5659
|
<span class="__crossx-recover-label">Recover My Wallet</span>
|
|
5566
5660
|
</button>
|
|
5567
5661
|
<button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>
|
|
@@ -5569,7 +5663,7 @@ function On(r) {
|
|
|
5569
5663
|
</div>
|
|
5570
5664
|
`, s;
|
|
5571
5665
|
}
|
|
5572
|
-
function
|
|
5666
|
+
function Ln(r, e) {
|
|
5573
5667
|
const s = r, t = e ? `<p class="__crossx-pin-error-text">${e}</p>` : "", n = document.createElement("div");
|
|
5574
5668
|
return n.id = te, n.innerHTML = `
|
|
5575
5669
|
<div class="__crossx-card __crossx-card--migration" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -5591,7 +5685,7 @@ function Cn(r, e) {
|
|
|
5591
5685
|
</div>
|
|
5592
5686
|
`, n;
|
|
5593
5687
|
}
|
|
5594
|
-
function
|
|
5688
|
+
function Dn(r, e, s) {
|
|
5595
5689
|
var n;
|
|
5596
5690
|
const t = r.querySelectorAll(".__crossx-pin-input");
|
|
5597
5691
|
t.forEach((o, i) => {
|
|
@@ -5617,12 +5711,15 @@ function kn(r, e, s) {
|
|
|
5617
5711
|
});
|
|
5618
5712
|
}), (n = t[0]) == null || n.focus();
|
|
5619
5713
|
}
|
|
5620
|
-
class
|
|
5714
|
+
class $n {
|
|
5621
5715
|
constructor(e = "light", s) {
|
|
5622
|
-
this.theme = e, this.overrides = s, this.tokens =
|
|
5716
|
+
this.theme = e, this.overrides = s, this.tokens = Vt(e, s);
|
|
5623
5717
|
}
|
|
5624
5718
|
setTheme(e, s) {
|
|
5625
|
-
this.theme = e, s !== void 0 && (this.overrides = s), this.tokens =
|
|
5719
|
+
this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = Vt(e, this.overrides);
|
|
5720
|
+
}
|
|
5721
|
+
setMessages(e) {
|
|
5722
|
+
this.messages = e;
|
|
5626
5723
|
}
|
|
5627
5724
|
getTheme() {
|
|
5628
5725
|
return this.theme;
|
|
@@ -5636,7 +5733,7 @@ class Nn {
|
|
|
5636
5733
|
return new Promise((n) => {
|
|
5637
5734
|
var A;
|
|
5638
5735
|
me();
|
|
5639
|
-
const o = [...e], i =
|
|
5736
|
+
const o = [...e], i = On(o, this.tokens, t), a = document.body.style.overflow;
|
|
5640
5737
|
document.body.style.overflow = "hidden", document.body.appendChild(i);
|
|
5641
5738
|
let c = !1;
|
|
5642
5739
|
const l = () => {
|
|
@@ -5687,7 +5784,7 @@ class Nn {
|
|
|
5687
5784
|
return new Promise((e) => {
|
|
5688
5785
|
var a, c, l;
|
|
5689
5786
|
me();
|
|
5690
|
-
const s =
|
|
5787
|
+
const s = Nn(this.tokens);
|
|
5691
5788
|
document.body.appendChild(s);
|
|
5692
5789
|
const t = () => s.remove(), n = (d) => {
|
|
5693
5790
|
t(), e(d);
|
|
@@ -5713,7 +5810,7 @@ class Nn {
|
|
|
5713
5810
|
return new Promise((e) => {
|
|
5714
5811
|
var a, c, l;
|
|
5715
5812
|
me();
|
|
5716
|
-
const s =
|
|
5813
|
+
const s = Pn(this.tokens);
|
|
5717
5814
|
document.body.appendChild(s);
|
|
5718
5815
|
const t = () => s.remove(), n = () => {
|
|
5719
5816
|
t(), e("recover");
|
|
@@ -5738,14 +5835,14 @@ class Nn {
|
|
|
5738
5835
|
return new Promise((s) => {
|
|
5739
5836
|
var a;
|
|
5740
5837
|
me();
|
|
5741
|
-
const t =
|
|
5838
|
+
const t = Ln(this.tokens, e);
|
|
5742
5839
|
document.body.appendChild(t);
|
|
5743
5840
|
const n = () => t.remove(), o = (c) => {
|
|
5744
5841
|
n(), s(c);
|
|
5745
5842
|
}, i = () => {
|
|
5746
5843
|
n(), s(null);
|
|
5747
5844
|
};
|
|
5748
|
-
|
|
5845
|
+
Dn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
|
|
5749
5846
|
c.target === t && i();
|
|
5750
5847
|
});
|
|
5751
5848
|
});
|
|
@@ -5758,7 +5855,7 @@ class Nn {
|
|
|
5758
5855
|
return new Promise((s) => {
|
|
5759
5856
|
var a, c;
|
|
5760
5857
|
me();
|
|
5761
|
-
const t =
|
|
5858
|
+
const t = Sn(e, this.tokens);
|
|
5762
5859
|
document.body.appendChild(t);
|
|
5763
5860
|
const n = () => t.remove(), o = () => {
|
|
5764
5861
|
n(), s();
|
|
@@ -5787,7 +5884,7 @@ class Nn {
|
|
|
5787
5884
|
showTransactionProgress(e, s) {
|
|
5788
5885
|
return new Promise((t) => {
|
|
5789
5886
|
me();
|
|
5790
|
-
const n =
|
|
5887
|
+
const n = En(e, this.tokens);
|
|
5791
5888
|
document.body.appendChild(n);
|
|
5792
5889
|
const o = () => n.remove();
|
|
5793
5890
|
let i = !1;
|
|
@@ -5804,7 +5901,7 @@ class Nn {
|
|
|
5804
5901
|
document.addEventListener("keydown", l);
|
|
5805
5902
|
};
|
|
5806
5903
|
s.then((l) => {
|
|
5807
|
-
i || (
|
|
5904
|
+
i || (In(n, l, this.tokens), c());
|
|
5808
5905
|
});
|
|
5809
5906
|
});
|
|
5810
5907
|
}
|
|
@@ -5813,7 +5910,7 @@ class Nn {
|
|
|
5813
5910
|
var c, l, d;
|
|
5814
5911
|
me();
|
|
5815
5912
|
let t;
|
|
5816
|
-
e.type === "sign-message" ? t =
|
|
5913
|
+
e.type === "sign-message" ? t = Tn(e, this.tokens) : e.type === "sign-typed-data" ? t = An(e, this.tokens) : e.type === "sign" ? t = wn(e, this.tokens) : t = yn(e, this.tokens), document.body.appendChild(t);
|
|
5817
5914
|
const n = () => t.remove(), o = () => {
|
|
5818
5915
|
n(), s(!0);
|
|
5819
5916
|
}, i = () => {
|
|
@@ -5837,7 +5934,7 @@ class Nn {
|
|
|
5837
5934
|
});
|
|
5838
5935
|
}
|
|
5839
5936
|
}
|
|
5840
|
-
class
|
|
5937
|
+
class Mn {
|
|
5841
5938
|
constructor() {
|
|
5842
5939
|
this._accessToken = null;
|
|
5843
5940
|
}
|
|
@@ -5854,9 +5951,9 @@ class Pn {
|
|
|
5854
5951
|
return this._accessToken !== null;
|
|
5855
5952
|
}
|
|
5856
5953
|
}
|
|
5857
|
-
function
|
|
5954
|
+
function Hn(r) {
|
|
5858
5955
|
r.debug;
|
|
5859
|
-
const e =
|
|
5956
|
+
const e = Fe.production, s = {
|
|
5860
5957
|
...r,
|
|
5861
5958
|
oauthServiceUrl: e.oauthServiceUrl,
|
|
5862
5959
|
authApiUrl: e.authApiUrl,
|
|
@@ -5864,15 +5961,15 @@ function Mn(r) {
|
|
|
5864
5961
|
}, t = {
|
|
5865
5962
|
gatewayUrl: e.walletGatewayUrl,
|
|
5866
5963
|
projectId: r.projectId
|
|
5867
|
-
}, o = s.authMode !== "cookie" &&
|
|
5964
|
+
}, o = s.authMode !== "cookie" && Rt.isAvailable() ? new Rt() : new Xs(), i = new on(), a = new ln(), c = new gt(), l = new Mn();
|
|
5868
5965
|
let d;
|
|
5869
|
-
r.useMockWallet ? (p.log("[CROSSx] Mock Wallet Provider 사용"), d = new
|
|
5966
|
+
r.useMockWallet ? (p.log("[CROSSx] Mock Wallet Provider 사용"), d = new dn(o)) : (p.log("[CROSSx] Remote Wallet Provider 사용"), d = new qe(
|
|
5870
5967
|
t,
|
|
5871
5968
|
o,
|
|
5872
5969
|
a,
|
|
5873
5970
|
l
|
|
5874
5971
|
));
|
|
5875
|
-
const f = new Ce(t, a), w = new
|
|
5972
|
+
const f = new Ce(t, a), w = new $n(r.theme ?? "light", r.themeTokens);
|
|
5876
5973
|
return new st(
|
|
5877
5974
|
s,
|
|
5878
5975
|
t,
|
|
@@ -5888,9 +5985,9 @@ function Mn(r) {
|
|
|
5888
5985
|
}
|
|
5889
5986
|
export {
|
|
5890
5987
|
x as CROSSxError,
|
|
5891
|
-
|
|
5988
|
+
Ns as CROSSxEthereumProvider,
|
|
5892
5989
|
st as CROSSxSDK,
|
|
5893
|
-
|
|
5990
|
+
Un as ChainId,
|
|
5894
5991
|
g as ErrorCode,
|
|
5895
|
-
|
|
5992
|
+
Hn as createCROSSxSDK
|
|
5896
5993
|
};
|