@nexus-cross/crossx-sdk-core 1.0.6 → 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 +4 -1
- 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 +8 -1
- 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 +68 -56
- package/dist/index.js +1015 -903
- package/dist/sdk/CROSSxSDK.d.ts +14 -2
- package/dist/sdk/CROSSxSDK.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
|
-
class
|
|
6
|
+
class x extends Error {
|
|
7
7
|
constructor(e, s, t) {
|
|
8
|
-
super(s), this.code = e, this.details = t, this.name = "CROSSxError", Object.setPrototypeOf(this,
|
|
8
|
+
super(s), this.code = e, this.details = t, this.name = "CROSSxError", Object.setPrototypeOf(this, x.prototype);
|
|
9
9
|
}
|
|
10
10
|
toJSON() {
|
|
11
11
|
return {
|
|
@@ -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
|
}
|
|
@@ -106,17 +106,17 @@ class Cs {
|
|
|
106
106
|
}
|
|
107
107
|
case "personal_sign":
|
|
108
108
|
case "eth_sign":
|
|
109
|
-
throw new
|
|
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":
|
|
115
115
|
case "eth_signTypedData_v3":
|
|
116
116
|
case "eth_signTypedData_v4":
|
|
117
|
-
throw new
|
|
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);
|
|
@@ -168,7 +168,7 @@ let we = null;
|
|
|
168
168
|
function wt(r) {
|
|
169
169
|
we = r;
|
|
170
170
|
}
|
|
171
|
-
const
|
|
171
|
+
const p = {
|
|
172
172
|
log(...r) {
|
|
173
173
|
if (we) {
|
|
174
174
|
we.log(...r);
|
|
@@ -187,8 +187,83 @@ const f = {
|
|
|
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
|
}
|
|
@@ -202,17 +277,17 @@ class ks {
|
|
|
202
277
|
*/
|
|
203
278
|
checkResponseError(e, s) {
|
|
204
279
|
if (e != null && e.code && e.code !== 200 && e.code > 0)
|
|
205
|
-
throw new
|
|
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) {
|
|
211
286
|
const n = t;
|
|
212
287
|
if (n.code && n.code !== 200 && n.code > 0)
|
|
213
|
-
throw new
|
|
288
|
+
throw new x(
|
|
214
289
|
g.AUTH_FAILED,
|
|
215
|
-
`${s}
|
|
290
|
+
`${s} 실패 (코드 ${n.code}): ${n.message}`
|
|
216
291
|
);
|
|
217
292
|
}
|
|
218
293
|
}
|
|
@@ -223,55 +298,55 @@ class ks {
|
|
|
223
298
|
const c = e == null ? void 0 : e.provider;
|
|
224
299
|
let l = "/login";
|
|
225
300
|
c === "google" ? l = "/google" : c === "apple" && (l = "/apple");
|
|
226
|
-
const { oauthServiceUrl: d, authApiUrl:
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
authUrl:
|
|
301
|
+
const { oauthServiceUrl: d, authApiUrl: f } = this.config, w = `${d}${l}`;
|
|
302
|
+
p.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인):`, w);
|
|
303
|
+
const _ = await this.oauth.openAuth({
|
|
304
|
+
authUrl: w,
|
|
230
305
|
expectedOrigin: new URL(d).origin
|
|
231
306
|
});
|
|
232
|
-
|
|
233
|
-
const { accessToken:
|
|
234
|
-
let
|
|
307
|
+
p.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", _.length, ")");
|
|
308
|
+
const { accessToken: m, refreshToken: A } = await this.exchangeFirebaseToken(_, f);
|
|
309
|
+
let y, I;
|
|
235
310
|
try {
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
|
|
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) ?? {};
|
|
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
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
if (t =
|
|
248
|
-
throw
|
|
249
|
-
const
|
|
250
|
-
s = {
|
|
251
|
-
id: M.sub,
|
|
252
|
-
email: M.email,
|
|
253
|
-
signInProvider: E,
|
|
254
|
-
providerSub: S
|
|
255
|
-
}, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set(Ye, w), b && await this.storage.set(Ne, b));
|
|
256
|
-
} else {
|
|
257
|
-
const B = this.crypto.decodeJWT(x);
|
|
318
|
+
if (m) {
|
|
319
|
+
const F = this.crypto.decodeJWT(m);
|
|
320
|
+
p.log("[CROSSx] access_token 디코딩 — sub:", F.sub, "exp:", F.exp);
|
|
321
|
+
const $ = await this.crypto.verifyJWT(m);
|
|
322
|
+
if (t = $.signatureVerified ?? !1, !$.valid)
|
|
323
|
+
throw p.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
|
|
324
|
+
const B = $.payload;
|
|
258
325
|
s = {
|
|
259
326
|
id: B.sub,
|
|
260
327
|
email: B.email,
|
|
261
|
-
signInProvider:
|
|
262
|
-
providerSub:
|
|
263
|
-
},
|
|
328
|
+
signInProvider: I,
|
|
329
|
+
providerSub: y
|
|
330
|
+
}, this.tokenStore.set(m), this.useCookieAuth || (await this.storage.set(Ye, m), A && await this.storage.set(Ne, A));
|
|
331
|
+
} else {
|
|
332
|
+
const F = this.crypto.decodeJWT(_);
|
|
333
|
+
s = {
|
|
334
|
+
id: F.sub,
|
|
335
|
+
email: F.email,
|
|
336
|
+
signInProvider: I,
|
|
337
|
+
providerSub: y
|
|
338
|
+
}, p.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
|
|
264
339
|
}
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
await this.storage.set(Pe,
|
|
340
|
+
p.log("[CROSSx] 사용자 정보 — id:", s.id);
|
|
341
|
+
const L = this.useCookieAuth ? { id: s.id, signInProvider: s.signInProvider, providerSub: s.providerSub } : s;
|
|
342
|
+
await this.storage.set(Pe, L), p.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
|
|
268
343
|
} catch (c) {
|
|
269
|
-
return
|
|
344
|
+
return p.error("[CROSSx] SignIn 에러 (OAuth/토큰 교환 단계):", c), {
|
|
270
345
|
success: !1,
|
|
271
346
|
error: c instanceof Error ? c.message : "Sign in failed"
|
|
272
347
|
};
|
|
273
348
|
}
|
|
274
|
-
return
|
|
349
|
+
return p.log("[CROSSx][Migration Phase 1] OAuth 로그인 완료, 지갑 로드 시작 — userId:", s.id), this.loadWallet(s, t);
|
|
275
350
|
}
|
|
276
351
|
/**
|
|
277
352
|
* Firebase 토큰 → CROSSx 인증 교환
|
|
@@ -280,7 +355,7 @@ class ks {
|
|
|
280
355
|
*/
|
|
281
356
|
async exchangeFirebaseToken(e, s) {
|
|
282
357
|
const t = this.useCookieAuth, n = t ? `${s}/cross-auth/social/login/cookie` : `${s}/cross-auth/social/login`;
|
|
283
|
-
|
|
358
|
+
p.log("[CROSSx] Firebase 토큰 교환 요청:", n);
|
|
284
359
|
const o = await this.transport.request({
|
|
285
360
|
url: n,
|
|
286
361
|
method: "POST",
|
|
@@ -288,18 +363,18 @@ class ks {
|
|
|
288
363
|
body: { auth_code: e, login_type: "firebase" },
|
|
289
364
|
...t ? { credentials: "include" } : {}
|
|
290
365
|
});
|
|
291
|
-
|
|
366
|
+
p.log("[CROSSx] 토큰 교환 응답 — status:", o.status);
|
|
292
367
|
const i = o.data;
|
|
293
368
|
this.checkResponseError(i, "Token exchange");
|
|
294
369
|
const a = this.extractAccessToken(i);
|
|
295
370
|
if (t && !a)
|
|
296
|
-
return
|
|
371
|
+
return p.log("[CROSSx] Cookie 모드 — 로그인 성공 (JWT는 HttpOnly 쿠키)"), {};
|
|
297
372
|
if (!a)
|
|
298
|
-
throw new
|
|
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;
|
|
304
379
|
return t || (c = this.extractRefreshToken(i)), { accessToken: a, refreshToken: c };
|
|
305
380
|
}
|
|
@@ -361,38 +436,38 @@ class ks {
|
|
|
361
436
|
if (t.valid) {
|
|
362
437
|
const n = await this.storage.get(Pe);
|
|
363
438
|
if (n)
|
|
364
|
-
return
|
|
439
|
+
return p.log("[CROSSx] restoreSession — 메모리 토큰 유효, 세션 복원"), this.loadWallet(n, t.signatureVerified);
|
|
365
440
|
}
|
|
366
441
|
this.tokenStore.clear();
|
|
367
442
|
}
|
|
368
443
|
if (this.useCookieAuth) {
|
|
369
|
-
|
|
444
|
+
p.log("[CROSSx] restoreSession — 쿠키 기반 silentRefresh 시도");
|
|
370
445
|
const t = await this.silentRefresh();
|
|
371
446
|
t && this.tokenStore.set(t);
|
|
372
447
|
} else {
|
|
373
448
|
const t = await this.storage.get(Ye), n = await this.storage.get(Ne);
|
|
374
|
-
if (
|
|
449
|
+
if (p.log(
|
|
375
450
|
"[CROSSx] restoreSession — access_token:",
|
|
376
451
|
t ? "있음" : "없음",
|
|
377
452
|
"refresh_token:",
|
|
378
453
|
n ? "있음" : "없음"
|
|
379
454
|
), !n)
|
|
380
|
-
return
|
|
455
|
+
return p.log("[CROSSx] restoreSession — refresh_token 없음, 세션 복원 생략"), null;
|
|
381
456
|
t && this.tokenStore.set(t);
|
|
382
457
|
const o = await this.silentRefresh(n);
|
|
383
|
-
|
|
458
|
+
p.log("[CROSSx] restoreSession — silentRefresh 결과:", o ? "토큰 발급 성공" : "토큰 없음"), o && this.tokenStore.set(o);
|
|
384
459
|
}
|
|
385
460
|
const s = await this.storage.get(Pe);
|
|
386
|
-
if (
|
|
461
|
+
if (p.log("[CROSSx] restoreSession — userInfo 조회:", s ? `있음 (id: ${s.id})` : "없음"), !s)
|
|
387
462
|
return null;
|
|
388
|
-
|
|
463
|
+
p.log("[CROSSx] restoreSession — silentRefresh 성공, 세션 복원 — userId:", s.id);
|
|
389
464
|
try {
|
|
390
465
|
return await this.loadWallet(s, !1);
|
|
391
466
|
} catch (t) {
|
|
392
|
-
return
|
|
467
|
+
return p.warn("[CROSSx] restoreSession — 지갑 로드 실패 (세션은 유지):", t), { success: !0, user: s, tokenSignatureVerified: !1 };
|
|
393
468
|
}
|
|
394
469
|
} catch (e) {
|
|
395
|
-
return
|
|
470
|
+
return p.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(Ne), await this.storage.remove(Pe), null;
|
|
396
471
|
}
|
|
397
472
|
}
|
|
398
473
|
/**
|
|
@@ -418,66 +493,66 @@ class ks {
|
|
|
418
493
|
body: o,
|
|
419
494
|
...t ? { credentials: "include" } : {}
|
|
420
495
|
});
|
|
421
|
-
|
|
496
|
+
p.log("[CROSSx] silentRefresh 응답 — status:", i.status);
|
|
422
497
|
const a = i.data;
|
|
423
498
|
this.checkResponseError(a, "Silent refresh");
|
|
424
499
|
const c = this.extractAccessToken(a);
|
|
425
500
|
if (t && !c) {
|
|
426
|
-
|
|
501
|
+
p.log("[CROSSx] silentRefresh 성공 (cookie 갱신)");
|
|
427
502
|
return;
|
|
428
503
|
}
|
|
429
504
|
if (!c)
|
|
430
|
-
throw new
|
|
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);
|
|
434
509
|
l && await this.storage.set(Ne, l);
|
|
435
510
|
}
|
|
436
|
-
return
|
|
511
|
+
return p.log("[CROSSx] silentRefresh 성공"), c;
|
|
437
512
|
}
|
|
438
513
|
async loadWallet(e, s) {
|
|
439
514
|
let t, n = !1;
|
|
440
515
|
try {
|
|
441
|
-
|
|
516
|
+
p.log("[CROSSx][Migration Phase 2] POST /mnemonic/create 호출 — userId:", e.id), t = (await this.walletProvider.getOrCreateWallet(e.id)).address, p.log("[CROSSx][Migration Phase 2] 지갑 로드 완료 (기존 백업 없음) — address:", t);
|
|
442
517
|
} catch (o) {
|
|
443
|
-
if (o instanceof
|
|
444
|
-
|
|
518
|
+
if (o instanceof x && o.code === g.MIGRATION_BACKUP_EXISTS)
|
|
519
|
+
p.log("[CROSSx][Migration Phase 2] Gateway -10012 감지 → needsMigration = true"), n = !0;
|
|
445
520
|
else {
|
|
446
|
-
if (o instanceof
|
|
447
|
-
throw
|
|
448
|
-
|
|
521
|
+
if (o instanceof x && (o.code === g.PROJECT_NOT_REGISTERED || o.code === g.PROJECT_ID_MISSING || o.code === g.ORIGIN_NOT_ALLOWED))
|
|
522
|
+
throw p.error("[CROSSx][Migration Phase 2] 프로젝트 설정 에러:", o.message), o;
|
|
523
|
+
p.warn("[CROSSx][Migration Phase 2] 지갑 로드 실패 (로그인은 유지):", o);
|
|
449
524
|
}
|
|
450
525
|
}
|
|
451
|
-
return
|
|
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
|
}
|
|
467
542
|
async execute(e, s) {
|
|
468
543
|
if (!this.walletProvider.migrateWallet)
|
|
469
|
-
throw new
|
|
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);
|
|
475
|
-
return
|
|
550
|
+
return p.log("[CROSSx][Migration Phase 5] MigrateWalletUseCase 완료 — address:", t.address), {
|
|
476
551
|
address: t.address
|
|
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
|
}
|
|
@@ -502,14 +577,14 @@ class Ms {
|
|
|
502
577
|
body: o
|
|
503
578
|
})).data;
|
|
504
579
|
if (a != null && a.error)
|
|
505
|
-
throw new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
820
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
740
821
|
try {
|
|
741
822
|
const s = await this.migrateWalletUseCase.execute(e, this.userId);
|
|
742
|
-
return this.address = s.address, this.emit("addressChanged", { address: s.address, index: 0 }),
|
|
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
|
-
throw s instanceof
|
|
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
|
|
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 };
|
|
@@ -787,25 +868,27 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
787
868
|
* SDK 내부에 "활성 지갑" 상태를 저장하지 않습니다.
|
|
788
869
|
* 반환된 index를 서명/전송 시 opts.index로 전달하세요.
|
|
789
870
|
*
|
|
871
|
+
* @param currentAddress 현재 활성 지갑 주소 (선택 UI에 "selected" 표시, 미전달 시 표시 없음)
|
|
790
872
|
* @returns 선택된 지갑 `{ address, index }` 또는 닫기 시 `null`
|
|
791
873
|
*
|
|
792
874
|
* @example
|
|
793
|
-
* const wallet = await sdk.selectWallet();
|
|
875
|
+
* const wallet = await sdk.selectWallet(currentAddress);
|
|
794
876
|
* if (wallet) {
|
|
795
877
|
* await sdk.signMessage(chainId, message, { index: wallet.index });
|
|
796
878
|
* }
|
|
797
879
|
*/
|
|
798
|
-
async selectWallet() {
|
|
880
|
+
async selectWallet(e) {
|
|
799
881
|
if (this.ensureAuthenticated(), !this.userId)
|
|
800
|
-
throw new
|
|
801
|
-
const
|
|
802
|
-
|
|
882
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
883
|
+
const s = await this.walletProvider.getAddresses(this.userId), t = await this.confirmation.showWalletSelector(
|
|
884
|
+
s,
|
|
803
885
|
async () => {
|
|
804
|
-
const
|
|
805
|
-
return
|
|
806
|
-
}
|
|
886
|
+
const n = s.length, i = { address: (await this.walletProvider.getAddress(this.userId, n)).address, index: n };
|
|
887
|
+
return s.push(i), i;
|
|
888
|
+
},
|
|
889
|
+
e
|
|
807
890
|
);
|
|
808
|
-
return
|
|
891
|
+
return t && (this.address = t.address, this.emit("addressChanged", { address: t.address, index: t.index })), t;
|
|
809
892
|
}
|
|
810
893
|
/**
|
|
811
894
|
* 지갑이 2개 이상이면 selectWallet()을 호출합니다.
|
|
@@ -835,7 +918,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
835
918
|
try {
|
|
836
919
|
return await this.chainRegistry.getChains();
|
|
837
920
|
} catch (e) {
|
|
838
|
-
throw e instanceof
|
|
921
|
+
throw e instanceof x ? e : new x(g.UNKNOWN_ERROR, "체인 목록 조회에 실패했습니다", e);
|
|
839
922
|
}
|
|
840
923
|
}
|
|
841
924
|
/**
|
|
@@ -854,7 +937,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
854
937
|
try {
|
|
855
938
|
return await this.chainRegistry.getChain(e);
|
|
856
939
|
} catch (s) {
|
|
857
|
-
throw s instanceof
|
|
940
|
+
throw s instanceof x ? s : new x(g.CHAIN_NOT_SUPPORTED, `체인 조회에 실패했습니다: ${e}`, s);
|
|
858
941
|
}
|
|
859
942
|
}
|
|
860
943
|
// ============================================================================
|
|
@@ -874,27 +957,40 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
874
957
|
applyTheme(e = this._config.theme ?? "light", s = this._config.themeTokens ?? {}) {
|
|
875
958
|
this._config = Object.freeze({ ...this._config, theme: e, themeTokens: s }), this.confirmation.setTheme(e, s);
|
|
876
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
|
+
}
|
|
877
973
|
/**
|
|
878
974
|
* 지갑 생성 (로그인 후 지갑이 없는 경우)
|
|
879
975
|
* 기존 CROSSx 백업이 발견되면 자동으로 마이그레이션 플로우 실행
|
|
880
976
|
*/
|
|
881
977
|
async createWallet() {
|
|
882
978
|
if (this.ensureAuthenticated(), !this.userId)
|
|
883
|
-
throw new
|
|
884
|
-
|
|
979
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
980
|
+
p.log("[CROSSx] 지갑 생성 시작");
|
|
885
981
|
try {
|
|
886
982
|
const e = await this.walletProvider.getOrCreateWallet(this.userId);
|
|
887
|
-
return this.address = e.address, this.emit("addressChanged", { address: e.address, index: 0 }),
|
|
983
|
+
return this.address = e.address, this.emit("addressChanged", { address: e.address, index: 0 }), p.log("[CROSSx] 지갑 생성 완료:", e.address), { address: e.address };
|
|
888
984
|
} catch (e) {
|
|
889
|
-
if (e instanceof
|
|
985
|
+
if (e instanceof x && e.code === g.MIGRATION_BACKUP_EXISTS) {
|
|
890
986
|
const s = this.providerSub ?? this.userId;
|
|
891
|
-
|
|
987
|
+
p.log("[CROSSx][Migration Phase 3] createWallet() — Gateway -10012 감지, 마이그레이션 UI 시작 — migrationSub:", s);
|
|
892
988
|
const t = await this.handleMigrationFlow(s);
|
|
893
989
|
if (t)
|
|
894
990
|
return this.address = t.address, this.emit("addressChanged", { address: t.address, index: 0 }), { address: t.address };
|
|
895
|
-
throw new
|
|
991
|
+
throw new x(
|
|
896
992
|
g.MIGRATION_FAILED,
|
|
897
|
-
"
|
|
993
|
+
"사용자가 마이그레이션을 건너뛰었습니다"
|
|
898
994
|
);
|
|
899
995
|
}
|
|
900
996
|
throw e;
|
|
@@ -912,7 +1008,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
912
1008
|
*/
|
|
913
1009
|
async signMessage(e, s, t) {
|
|
914
1010
|
if (this.ensureAuthenticated(), !this.userId)
|
|
915
|
-
throw new
|
|
1011
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
916
1012
|
const n = t == null ? void 0 : t.index, o = await this.walletProvider.getAddress(this.userId, n ?? 0);
|
|
917
1013
|
let i;
|
|
918
1014
|
if (this.walletProvider.prepare && (i = (await this.walletProvider.prepare("sign-message", { message: s, from: o.address })).uuid), !await this.confirmation.requestConfirmation({
|
|
@@ -923,7 +1019,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
923
1019
|
dappName: t == null ? void 0 : t.dappName,
|
|
924
1020
|
accountName: t == null ? void 0 : t.accountName
|
|
925
1021
|
}))
|
|
926
|
-
throw new
|
|
1022
|
+
throw new x(g.USER_REJECTED, "사용자가 메시지 서명을 거부했습니다");
|
|
927
1023
|
try {
|
|
928
1024
|
const c = await this.walletProvider.signMessage(
|
|
929
1025
|
this.userId,
|
|
@@ -940,7 +1036,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
940
1036
|
address: o.address
|
|
941
1037
|
};
|
|
942
1038
|
} catch (c) {
|
|
943
|
-
throw c instanceof
|
|
1039
|
+
throw c instanceof x ? c : new x(g.SIGNATURE_FAILED, `메시지 서명에 실패했습니다 (${e})`, c);
|
|
944
1040
|
}
|
|
945
1041
|
}
|
|
946
1042
|
/**
|
|
@@ -966,9 +1062,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
966
1062
|
*/
|
|
967
1063
|
async signTypedData(e, s, t) {
|
|
968
1064
|
if (this.ensureAuthenticated(), !this.userId)
|
|
969
|
-
throw new
|
|
1065
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
970
1066
|
if (!this.walletProvider.signTypedData)
|
|
971
|
-
throw new
|
|
1067
|
+
throw new x(g.NOT_IMPLEMENTED, "signTypedData가 구현되어 있지 않습니다");
|
|
972
1068
|
X.validateTypedDataChainId(e, s);
|
|
973
1069
|
const n = await this.walletProvider.getAddress(this.userId, (t == null ? void 0 : t.index) ?? 0);
|
|
974
1070
|
let o;
|
|
@@ -980,7 +1076,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
980
1076
|
dappName: t == null ? void 0 : t.dappName,
|
|
981
1077
|
accountName: t == null ? void 0 : t.accountName
|
|
982
1078
|
}))
|
|
983
|
-
throw new
|
|
1079
|
+
throw new x(g.USER_REJECTED, "사용자가 타입 데이터 서명을 거부했습니다");
|
|
984
1080
|
try {
|
|
985
1081
|
const a = await this.walletProvider.signTypedData(
|
|
986
1082
|
this.userId,
|
|
@@ -996,7 +1092,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
996
1092
|
address: n.address
|
|
997
1093
|
};
|
|
998
1094
|
} catch (a) {
|
|
999
|
-
throw a instanceof
|
|
1095
|
+
throw a instanceof x ? a : new x(g.SIGNATURE_FAILED, `타입 데이터 서명에 실패했습니다 (${e})`, a);
|
|
1000
1096
|
}
|
|
1001
1097
|
}
|
|
1002
1098
|
/**
|
|
@@ -1032,7 +1128,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1032
1128
|
*/
|
|
1033
1129
|
async signTransaction(e, s, t) {
|
|
1034
1130
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1035
|
-
throw new
|
|
1131
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1036
1132
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
1037
1133
|
let o;
|
|
1038
1134
|
this.walletProvider.prepare && (o = (await this.walletProvider.prepare("sign", { tx: n })).uuid);
|
|
@@ -1053,7 +1149,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1053
1149
|
dappName: t == null ? void 0 : t.dappName,
|
|
1054
1150
|
accountName: t == null ? void 0 : t.accountName
|
|
1055
1151
|
}))
|
|
1056
|
-
throw new
|
|
1152
|
+
throw new x(g.USER_REJECTED, "사용자가 트랜잭션 서명을 거부했습니다");
|
|
1057
1153
|
try {
|
|
1058
1154
|
const c = await this.walletProvider.signTransaction(
|
|
1059
1155
|
this.userId,
|
|
@@ -1068,11 +1164,11 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1068
1164
|
txHash: c.txHash ?? ""
|
|
1069
1165
|
};
|
|
1070
1166
|
} catch (c) {
|
|
1071
|
-
if (c instanceof
|
|
1167
|
+
if (c instanceof x) throw c;
|
|
1072
1168
|
const l = c instanceof Error ? c.message : String(c);
|
|
1073
|
-
throw new
|
|
1169
|
+
throw new x(
|
|
1074
1170
|
g.SIGNATURE_FAILED,
|
|
1075
|
-
|
|
1171
|
+
`트랜잭션 서명에 실패했습니다 (${e}): ${l}`,
|
|
1076
1172
|
c
|
|
1077
1173
|
);
|
|
1078
1174
|
}
|
|
@@ -1085,7 +1181,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1085
1181
|
*/
|
|
1086
1182
|
async sendTransaction(e, s, t) {
|
|
1087
1183
|
if (this.ensureAuthenticated(), !this.userId)
|
|
1088
|
-
throw new
|
|
1184
|
+
throw new x(g.AUTH_NOT_AUTHENTICATED, "사용자 ID를 찾을 수 없습니다");
|
|
1089
1185
|
const n = await this.withResolvedGasAndFee(s, e);
|
|
1090
1186
|
let o;
|
|
1091
1187
|
this.walletProvider.prepare && (o = (await this.walletProvider.prepare("send", { tx: n })).uuid);
|
|
@@ -1106,7 +1202,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1106
1202
|
dappName: t == null ? void 0 : t.dappName,
|
|
1107
1203
|
accountName: t == null ? void 0 : t.accountName
|
|
1108
1204
|
}))
|
|
1109
|
-
throw new
|
|
1205
|
+
throw new x(g.USER_REJECTED, "사용자가 트랜잭션을 거부했습니다");
|
|
1110
1206
|
try {
|
|
1111
1207
|
let c;
|
|
1112
1208
|
if (this.walletProvider.sendTransaction)
|
|
@@ -1129,9 +1225,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1129
1225
|
return { chainId: e, txHash: c, status: "pending" };
|
|
1130
1226
|
} catch (c) {
|
|
1131
1227
|
const l = c instanceof Error ? c.message : String(c);
|
|
1132
|
-
throw new
|
|
1228
|
+
throw new x(
|
|
1133
1229
|
g.TRANSACTION_FAILED,
|
|
1134
|
-
|
|
1230
|
+
`트랜잭션 전송에 실패했습니다 (${e}): ${l}`,
|
|
1135
1231
|
c
|
|
1136
1232
|
);
|
|
1137
1233
|
}
|
|
@@ -1155,16 +1251,16 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1155
1251
|
* @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
|
|
1156
1252
|
*/
|
|
1157
1253
|
async waitForTxAndGetReceipt(e, s, t = {}) {
|
|
1158
|
-
const n = t.intervalMs ??
|
|
1254
|
+
const n = t.intervalMs ?? Vs, o = Ks, i = t.timeoutMs ?? vt, a = Date.now() + i;
|
|
1159
1255
|
let c = n;
|
|
1160
1256
|
for (; Date.now() < a; ) {
|
|
1161
1257
|
const l = await this.getTransactionReceipt(e, s);
|
|
1162
1258
|
if (l) return l;
|
|
1163
1259
|
await new Promise((d) => setTimeout(d, c)), c = Math.min(c * 2, o);
|
|
1164
1260
|
}
|
|
1165
|
-
throw new
|
|
1261
|
+
throw new x(
|
|
1166
1262
|
g.UNKNOWN_ERROR,
|
|
1167
|
-
|
|
1263
|
+
`트랜잭션 영수증 조회 시간이 초과되었습니다 (${e})`
|
|
1168
1264
|
);
|
|
1169
1265
|
}
|
|
1170
1266
|
/**
|
|
@@ -1183,37 +1279,37 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1183
1279
|
* logger.log(receipt.status); // '0x1' | '0x0'
|
|
1184
1280
|
*/
|
|
1185
1281
|
async sendTransactionWithWaitForReceipt(e, s, t = {}) {
|
|
1186
|
-
var
|
|
1187
|
-
const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((
|
|
1188
|
-
let
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
const
|
|
1282
|
+
var A, y;
|
|
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 ?? "";
|
|
1284
|
+
let w, _;
|
|
1285
|
+
const m = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((I) => {
|
|
1286
|
+
w = I;
|
|
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);
|
|
1192
1288
|
return {
|
|
1193
1289
|
chainId: e,
|
|
1194
1290
|
txHash: a,
|
|
1195
|
-
from:
|
|
1196
|
-
to:
|
|
1197
|
-
amount:
|
|
1198
|
-
fees:
|
|
1291
|
+
from: I.from,
|
|
1292
|
+
to: I.to ?? s.to,
|
|
1293
|
+
amount: $,
|
|
1294
|
+
fees: B,
|
|
1199
1295
|
total: Q,
|
|
1200
1296
|
nativeSymbol: d.symbol,
|
|
1201
|
-
status:
|
|
1297
|
+
status: I.status === "0x1" ? "success" : "reverted"
|
|
1202
1298
|
};
|
|
1203
|
-
}).catch((
|
|
1299
|
+
}).catch((I) => (_ = I instanceof Error ? I : new Error(String(I)), {
|
|
1204
1300
|
chainId: e,
|
|
1205
1301
|
txHash: a,
|
|
1206
|
-
from:
|
|
1302
|
+
from: f,
|
|
1207
1303
|
to: s.to,
|
|
1208
1304
|
amount: X.formatTxAmount(s.value, d.symbol, d.decimals),
|
|
1209
1305
|
nativeSymbol: d.symbol,
|
|
1210
1306
|
status: "timeout"
|
|
1211
1307
|
}));
|
|
1212
1308
|
if (await this.confirmation.showTransactionProgress(
|
|
1213
|
-
{ chainId: e, txHash: a, from:
|
|
1214
|
-
|
|
1215
|
-
),
|
|
1216
|
-
return { chainId: e, txHash: a, receipt:
|
|
1309
|
+
{ chainId: e, txHash: a, from: f, to: s.to },
|
|
1310
|
+
m
|
|
1311
|
+
), _) throw _;
|
|
1312
|
+
return { chainId: e, txHash: a, receipt: w };
|
|
1217
1313
|
}
|
|
1218
1314
|
// ============================================================================
|
|
1219
1315
|
// Gas 조회
|
|
@@ -1233,7 +1329,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1233
1329
|
return await this.walletRpc("eth_gasPrice", [], e);
|
|
1234
1330
|
} catch (s) {
|
|
1235
1331
|
const t = s instanceof Error ? s.message : String(s);
|
|
1236
|
-
throw new
|
|
1332
|
+
throw new x(g.GAS_ESTIMATION_FAILED, `가스 가격 조회에 실패했습니다 (${e}): ${t}`, s);
|
|
1237
1333
|
}
|
|
1238
1334
|
}
|
|
1239
1335
|
/**
|
|
@@ -1254,7 +1350,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1254
1350
|
return await this.walletRpc("eth_estimateGas", [t], s);
|
|
1255
1351
|
} catch (n) {
|
|
1256
1352
|
const o = n instanceof Error ? n.message : String(n);
|
|
1257
|
-
throw new
|
|
1353
|
+
throw new x(g.GAS_ESTIMATION_FAILED, `가스 추정에 실패했습니다 (${s}): ${o}`, n);
|
|
1258
1354
|
}
|
|
1259
1355
|
}
|
|
1260
1356
|
/**
|
|
@@ -1275,7 +1371,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1275
1371
|
return (s == null ? void 0 : s.baseFeePerGas) ?? null;
|
|
1276
1372
|
} catch (s) {
|
|
1277
1373
|
const t = s instanceof Error ? s.message : String(s);
|
|
1278
|
-
throw new
|
|
1374
|
+
throw new x(g.GAS_ESTIMATION_FAILED, `baseFeePerGas 조회에 실패했습니다 (${e}): ${t}`, s);
|
|
1279
1375
|
}
|
|
1280
1376
|
}
|
|
1281
1377
|
/**
|
|
@@ -1294,7 +1390,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1294
1390
|
return await this.walletRpc("eth_maxPriorityFeePerGas", [], e);
|
|
1295
1391
|
} catch (s) {
|
|
1296
1392
|
const t = s instanceof Error ? s.message : String(s);
|
|
1297
|
-
throw new
|
|
1393
|
+
throw new x(g.GAS_ESTIMATION_FAILED, `maxPriorityFeePerGas 조회에 실패했습니다 (${e}): ${t}`, s);
|
|
1298
1394
|
}
|
|
1299
1395
|
}
|
|
1300
1396
|
// ============================================================================
|
|
@@ -1312,9 +1408,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1312
1408
|
const t = await this.jsonRpc.call("eth_getTransactionCount", [s, "pending"], e);
|
|
1313
1409
|
return parseInt(t ?? "0x0", 16);
|
|
1314
1410
|
} catch (t) {
|
|
1315
|
-
if (t instanceof
|
|
1411
|
+
if (t instanceof x) throw t;
|
|
1316
1412
|
const n = t instanceof Error ? t.message : String(t);
|
|
1317
|
-
throw new
|
|
1413
|
+
throw new x(g.UNKNOWN_ERROR, `Nonce 조회에 실패했습니다: ${n}`, t);
|
|
1318
1414
|
}
|
|
1319
1415
|
}
|
|
1320
1416
|
/**
|
|
@@ -1331,9 +1427,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1331
1427
|
const n = await this.jsonRpc.call("eth_getBalance", [s, "latest"], e) ?? "0x0";
|
|
1332
1428
|
return { wei: n, formatted: X.formatWei(n), chainId: e };
|
|
1333
1429
|
} catch (t) {
|
|
1334
|
-
if (t instanceof
|
|
1430
|
+
if (t instanceof x) throw t;
|
|
1335
1431
|
const n = t instanceof Error ? t.message : String(t);
|
|
1336
|
-
throw new
|
|
1432
|
+
throw new x(g.UNKNOWN_ERROR, `잔액 조회에 실패했습니다 (${e}): ${n}`, t);
|
|
1337
1433
|
}
|
|
1338
1434
|
}
|
|
1339
1435
|
static formatWei(e) {
|
|
@@ -1341,7 +1437,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1341
1437
|
try {
|
|
1342
1438
|
const s = BigInt(e);
|
|
1343
1439
|
if (s === 0n) return "0";
|
|
1344
|
-
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);
|
|
1345
1441
|
return i ? `${n}.${i}` : `${n}`;
|
|
1346
1442
|
} catch {
|
|
1347
1443
|
return "?";
|
|
@@ -1366,7 +1462,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1366
1462
|
* const client = createWalletClient({ transport: custom(provider) });
|
|
1367
1463
|
*/
|
|
1368
1464
|
getProvider(e) {
|
|
1369
|
-
return this.ensureAuthenticated(), new
|
|
1465
|
+
return this.ensureAuthenticated(), new Ns(this, e);
|
|
1370
1466
|
}
|
|
1371
1467
|
/**
|
|
1372
1468
|
* 범용 JSON-RPC 요청 — 노드에 직접 연결.
|
|
@@ -1382,9 +1478,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1382
1478
|
try {
|
|
1383
1479
|
return await this.jsonRpc.call(e, s, t);
|
|
1384
1480
|
} catch (n) {
|
|
1385
|
-
if (n instanceof
|
|
1481
|
+
if (n instanceof x) throw n;
|
|
1386
1482
|
const o = n instanceof Error ? n.message : String(n);
|
|
1387
|
-
throw new
|
|
1483
|
+
throw new x(g.UNKNOWN_ERROR, `walletRpc 호출에 실패했습니다 [${e}] (${t}): ${o}`, n);
|
|
1388
1484
|
}
|
|
1389
1485
|
}
|
|
1390
1486
|
// ============================================================================
|
|
@@ -1399,7 +1495,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1399
1495
|
try {
|
|
1400
1496
|
const n = BigInt(e);
|
|
1401
1497
|
if (n === 0n) return;
|
|
1402
|
-
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+$/, "");
|
|
1403
1499
|
return `${c ? `${i}.${c}` : `${i}`} ${s}`;
|
|
1404
1500
|
} catch {
|
|
1405
1501
|
return;
|
|
@@ -1412,26 +1508,26 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1412
1508
|
* 3) migrateWallet API 호출
|
|
1413
1509
|
*/
|
|
1414
1510
|
async handleMigrationFlow(e) {
|
|
1415
|
-
|
|
1511
|
+
p.log('[CROSSx][Migration Phase 3] "Wallet Found" 팝업 표시');
|
|
1416
1512
|
const s = await this.confirmation.showMigrationFoundPrompt();
|
|
1417
|
-
if (
|
|
1418
|
-
return
|
|
1513
|
+
if (p.log("[CROSSx][Migration Phase 3] 사용자 선택:", s), s === "skip")
|
|
1514
|
+
return p.log("[CROSSx][Migration Phase 3] 사용자가 마이그레이션을 건너뜀 → 종료"), null;
|
|
1419
1515
|
let t, n = 0;
|
|
1420
1516
|
for (; ; ) {
|
|
1421
|
-
n++,
|
|
1517
|
+
n++, p.log(`[CROSSx][Migration Phase 4] PIN 입력 팝업 표시 (시도 #${n})`, t ? `— 이전 에러: ${t}` : "");
|
|
1422
1518
|
const o = await this.confirmation.showPinInputPrompt(t);
|
|
1423
1519
|
if (o === null)
|
|
1424
|
-
return
|
|
1425
|
-
|
|
1520
|
+
return p.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
|
|
1521
|
+
p.log(`[CROSSx][Migration Phase 4] PIN 입력 완료 (${o.length}자리), Gateway 마이그레이션 API 호출`);
|
|
1426
1522
|
try {
|
|
1427
1523
|
const i = await this.migrateWalletUseCase.execute(o, e);
|
|
1428
|
-
return
|
|
1524
|
+
return p.log("[CROSSx][Migration Phase 5] 마이그레이션 성공 — address:", i.address), i;
|
|
1429
1525
|
} catch (i) {
|
|
1430
|
-
if (i instanceof
|
|
1431
|
-
|
|
1526
|
+
if (i instanceof x && i.code === g.MIGRATION_FAILED) {
|
|
1527
|
+
p.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 #${n}) — 재시도 요청`), t = "PIN이 올바르지 않습니다. 다시 시도해 주세요.";
|
|
1432
1528
|
continue;
|
|
1433
1529
|
}
|
|
1434
|
-
throw
|
|
1530
|
+
throw p.error("[CROSSx][Migration Phase 4] 마이그레이션 실패 (복구 불가):", i), i;
|
|
1435
1531
|
}
|
|
1436
1532
|
}
|
|
1437
1533
|
}
|
|
@@ -1454,21 +1550,21 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1454
1550
|
if (n) {
|
|
1455
1551
|
const l = c.from ?? this.address;
|
|
1456
1552
|
if (l) {
|
|
1457
|
-
|
|
1553
|
+
p.log("[CROSSx] nonce 비어있음 → eth_getTransactionCount 호출 (from:", l, ")");
|
|
1458
1554
|
const d = await this.jsonRpc.call("eth_getTransactionCount", [l, "pending"], s);
|
|
1459
|
-
c.nonce = parseInt(d ?? "0x0", 16),
|
|
1555
|
+
c.nonce = parseInt(d ?? "0x0", 16), p.log("[CROSSx] nonce 결과:", c.nonce);
|
|
1460
1556
|
}
|
|
1461
1557
|
}
|
|
1462
|
-
if (o && (
|
|
1463
|
-
|
|
1558
|
+
if (o && (p.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), c.gasLimit = await this.estimateGas(e, s), p.log("[CROSSx] estimateGas 결과:", c.gasLimit)), i) {
|
|
1559
|
+
p.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
|
|
1464
1560
|
const l = await this.getBaseFeePerGas(s);
|
|
1465
1561
|
if (l) {
|
|
1466
|
-
const d =
|
|
1467
|
-
c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(d)).toString(16), c.maxPriorityFeePerGas = d,
|
|
1562
|
+
const d = St;
|
|
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");
|
|
1468
1564
|
} else
|
|
1469
|
-
c.gasPrice =
|
|
1565
|
+
c.gasPrice = zs, p.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
|
|
1470
1566
|
}
|
|
1471
|
-
return !i && a && (c.maxPriorityFeePerGas =
|
|
1567
|
+
return !i && a && (c.maxPriorityFeePerGas = St, p.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
|
|
1472
1568
|
}
|
|
1473
1569
|
/**
|
|
1474
1570
|
* EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
|
|
@@ -1480,9 +1576,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1480
1576
|
const t = X.extractDomainChainId(s);
|
|
1481
1577
|
if (e === "0") {
|
|
1482
1578
|
if (t !== void 0 && t !== 0)
|
|
1483
|
-
throw new
|
|
1579
|
+
throw new x(
|
|
1484
1580
|
g.TYPED_DATA_CHAIN_ID_MISMATCH,
|
|
1485
|
-
|
|
1581
|
+
`오프체인 서명(chainId=0)에서는 typedData.domain.chainId가 없거나 0이어야 합니다. 현재 값: ${t}`
|
|
1486
1582
|
);
|
|
1487
1583
|
return;
|
|
1488
1584
|
}
|
|
@@ -1490,14 +1586,14 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1490
1586
|
if (n) {
|
|
1491
1587
|
const o = Number(n[1]);
|
|
1492
1588
|
if (t === void 0)
|
|
1493
|
-
throw new
|
|
1589
|
+
throw new x(
|
|
1494
1590
|
g.TYPED_DATA_CHAIN_ID_MISMATCH,
|
|
1495
|
-
|
|
1591
|
+
`온체인 서명(${e})에서는 typedData.domain.chainId가 반드시 있어야 합니다`
|
|
1496
1592
|
);
|
|
1497
1593
|
if (t !== o)
|
|
1498
|
-
throw new
|
|
1594
|
+
throw new x(
|
|
1499
1595
|
g.TYPED_DATA_CHAIN_ID_MISMATCH,
|
|
1500
|
-
`typedData.domain.chainId (${t})
|
|
1596
|
+
`typedData.domain.chainId (${t})가 chainId (${e}, 예상값: ${o})와 일치하지 않습니다`
|
|
1501
1597
|
);
|
|
1502
1598
|
}
|
|
1503
1599
|
}
|
|
@@ -1514,20 +1610,20 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1514
1610
|
static validateSignatureFormat(e) {
|
|
1515
1611
|
const s = e.startsWith("0x") ? e.slice(2) : e;
|
|
1516
1612
|
if (!/^[0-9a-fA-F]+$/.test(s))
|
|
1517
|
-
throw new
|
|
1518
|
-
if (s.length !==
|
|
1519
|
-
throw new
|
|
1613
|
+
throw new x(g.SIGNATURE_FAILED, "유효하지 않은 서명: 올바른 hex 문자열이 아닙니다");
|
|
1614
|
+
if (s.length !== Et)
|
|
1615
|
+
throw new x(
|
|
1520
1616
|
g.SIGNATURE_FAILED,
|
|
1521
|
-
|
|
1617
|
+
`서명 길이가 유효하지 않습니다: ${Et} hex 문자(65 바이트) 예상, 현재 ${s.length}`
|
|
1522
1618
|
);
|
|
1523
1619
|
}
|
|
1524
1620
|
/** RLP-encoded signed transaction 형식 검증 */
|
|
1525
1621
|
static validateSignedTxFormat(e) {
|
|
1526
1622
|
const s = e.startsWith("0x") ? e.slice(2) : e;
|
|
1527
1623
|
if (!/^[0-9a-fA-F]+$/.test(s))
|
|
1528
|
-
throw new
|
|
1624
|
+
throw new x(g.SIGNATURE_FAILED, "유효하지 않은 서명된 트랜잭션: 올바른 hex 문자열이 아닙니다");
|
|
1529
1625
|
if (s.length < 2)
|
|
1530
|
-
throw new
|
|
1626
|
+
throw new x(g.SIGNATURE_FAILED, "유효하지 않은 서명된 트랜잭션: 너무 짧습니다");
|
|
1531
1627
|
}
|
|
1532
1628
|
/**
|
|
1533
1629
|
* Gateway 서명 응답의 ecrecover 검증 (XF-036)
|
|
@@ -1540,17 +1636,17 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1540
1636
|
try {
|
|
1541
1637
|
const n = this.crypto.recoverPersonalSignSigner(e, s);
|
|
1542
1638
|
if (n.toLowerCase() !== t.toLowerCase())
|
|
1543
|
-
throw
|
|
1639
|
+
throw p.error("[CROSSx] 서명 검증 실패: 서명자 주소 불일치", {
|
|
1544
1640
|
expected: t,
|
|
1545
1641
|
recovered: n
|
|
1546
|
-
}), new
|
|
1642
|
+
}), new x(
|
|
1547
1643
|
g.SIGNATURE_SIGNER_MISMATCH,
|
|
1548
|
-
|
|
1644
|
+
`서명자 주소가 일치하지 않습니다: 예상 ${t}, 복원된 주소 ${n}`
|
|
1549
1645
|
);
|
|
1550
|
-
|
|
1646
|
+
p.log("[CROSSx] 서명 ecrecover 검증 성공");
|
|
1551
1647
|
} catch (n) {
|
|
1552
|
-
if (n instanceof
|
|
1553
|
-
|
|
1648
|
+
if (n instanceof x) throw n;
|
|
1649
|
+
p.warn("[CROSSx] ecrecover 검증 중 예외 (무시):", n);
|
|
1554
1650
|
}
|
|
1555
1651
|
}
|
|
1556
1652
|
/** AuthResult를 내부 상태에 반영합니다. */
|
|
@@ -1579,16 +1675,16 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1579
1675
|
}
|
|
1580
1676
|
ensureInitialized() {
|
|
1581
1677
|
if (!this.initialized)
|
|
1582
|
-
throw new
|
|
1678
|
+
throw new x(
|
|
1583
1679
|
g.AUTH_NOT_INITIALIZED,
|
|
1584
|
-
"SDK
|
|
1680
|
+
"SDK가 초기화되지 않았습니다. initialize()를 먼저 호출하세요."
|
|
1585
1681
|
);
|
|
1586
1682
|
}
|
|
1587
1683
|
ensureAuthenticated() {
|
|
1588
1684
|
if (this.ensureInitialized(), !this.authenticated)
|
|
1589
|
-
throw new
|
|
1685
|
+
throw new x(
|
|
1590
1686
|
g.AUTH_NOT_AUTHENTICATED,
|
|
1591
|
-
"
|
|
1687
|
+
"인증되지 않은 상태입니다. signIn()을 먼저 호출하세요."
|
|
1592
1688
|
);
|
|
1593
1689
|
}
|
|
1594
1690
|
/**
|
|
@@ -1603,7 +1699,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
|
|
|
1603
1699
|
};
|
|
1604
1700
|
X.OFFCHAIN_CHAIN_ID = "0";
|
|
1605
1701
|
let st = X;
|
|
1606
|
-
class
|
|
1702
|
+
class Xs {
|
|
1607
1703
|
constructor() {
|
|
1608
1704
|
this.prefix = "crossx_";
|
|
1609
1705
|
}
|
|
@@ -1612,7 +1708,7 @@ class Ks {
|
|
|
1612
1708
|
const t = JSON.stringify(s);
|
|
1613
1709
|
localStorage.setItem(this.prefix + e, t);
|
|
1614
1710
|
} catch (t) {
|
|
1615
|
-
throw
|
|
1711
|
+
throw p.error("Storage set error:", t), t;
|
|
1616
1712
|
}
|
|
1617
1713
|
}
|
|
1618
1714
|
async get(e) {
|
|
@@ -1620,14 +1716,14 @@ class Ks {
|
|
|
1620
1716
|
const s = localStorage.getItem(this.prefix + e);
|
|
1621
1717
|
return s ? JSON.parse(s) : null;
|
|
1622
1718
|
} catch (s) {
|
|
1623
|
-
return
|
|
1719
|
+
return p.error("Storage get error:", s), null;
|
|
1624
1720
|
}
|
|
1625
1721
|
}
|
|
1626
1722
|
async remove(e) {
|
|
1627
1723
|
try {
|
|
1628
1724
|
localStorage.removeItem(this.prefix + e);
|
|
1629
1725
|
} catch (s) {
|
|
1630
|
-
throw
|
|
1726
|
+
throw p.error("Storage remove error:", s), s;
|
|
1631
1727
|
}
|
|
1632
1728
|
}
|
|
1633
1729
|
async clear() {
|
|
@@ -1636,12 +1732,12 @@ class Ks {
|
|
|
1636
1732
|
s.startsWith(this.prefix) && localStorage.removeItem(s);
|
|
1637
1733
|
});
|
|
1638
1734
|
} catch (e) {
|
|
1639
|
-
throw
|
|
1735
|
+
throw p.error("Storage clear error:", e), e;
|
|
1640
1736
|
}
|
|
1641
1737
|
}
|
|
1642
1738
|
}
|
|
1643
|
-
const
|
|
1644
|
-
class
|
|
1739
|
+
const Js = "crossx-sdk", Qs = 1, Se = "data", Le = "keys", At = "aes-primary", er = 12;
|
|
1740
|
+
class Rt {
|
|
1645
1741
|
constructor() {
|
|
1646
1742
|
this.db = null, this.cryptoKey = null, this.initPromise = null;
|
|
1647
1743
|
}
|
|
@@ -1650,7 +1746,7 @@ class At {
|
|
|
1650
1746
|
}
|
|
1651
1747
|
openDB() {
|
|
1652
1748
|
return new Promise((e, s) => {
|
|
1653
|
-
const t = indexedDB.open(
|
|
1749
|
+
const t = indexedDB.open(Js, Qs);
|
|
1654
1750
|
t.onupgradeneeded = () => {
|
|
1655
1751
|
const n = t.result;
|
|
1656
1752
|
n.objectStoreNames.contains(Se) || n.createObjectStore(Se), n.objectStoreNames.contains(Le) || n.createObjectStore(Le);
|
|
@@ -1683,7 +1779,7 @@ class At {
|
|
|
1683
1779
|
}
|
|
1684
1780
|
async init() {
|
|
1685
1781
|
this.db = await this.openDB();
|
|
1686
|
-
const e = await this.idbGet(Le,
|
|
1782
|
+
const e = await this.idbGet(Le, At);
|
|
1687
1783
|
if (e) {
|
|
1688
1784
|
this.cryptoKey = e;
|
|
1689
1785
|
return;
|
|
@@ -1692,10 +1788,10 @@ class At {
|
|
|
1692
1788
|
{ name: "AES-GCM", length: 256 },
|
|
1693
1789
|
!1,
|
|
1694
1790
|
["encrypt", "decrypt"]
|
|
1695
|
-
), await this.idbPut(Le,
|
|
1791
|
+
), await this.idbPut(Le, At, this.cryptoKey);
|
|
1696
1792
|
}
|
|
1697
1793
|
async encrypt(e) {
|
|
1698
|
-
const s = new Uint8Array(
|
|
1794
|
+
const s = new Uint8Array(er);
|
|
1699
1795
|
crypto.getRandomValues(s);
|
|
1700
1796
|
const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
|
|
1701
1797
|
{ name: "AES-GCM", iv: s },
|
|
@@ -1718,7 +1814,7 @@ class At {
|
|
|
1718
1814
|
const t = JSON.stringify(s), n = await this.encrypt(t);
|
|
1719
1815
|
await this.idbPut(Se, e, n);
|
|
1720
1816
|
} catch (t) {
|
|
1721
|
-
throw
|
|
1817
|
+
throw p.error("[CROSSx] IndexedDB set error:", t), t;
|
|
1722
1818
|
}
|
|
1723
1819
|
}
|
|
1724
1820
|
async get(e) {
|
|
@@ -1729,21 +1825,21 @@ class At {
|
|
|
1729
1825
|
const t = await this.decrypt(s);
|
|
1730
1826
|
return JSON.parse(t);
|
|
1731
1827
|
} catch (s) {
|
|
1732
|
-
return
|
|
1828
|
+
return p.error("[CROSSx] IndexedDB get error:", s), null;
|
|
1733
1829
|
}
|
|
1734
1830
|
}
|
|
1735
1831
|
async remove(e) {
|
|
1736
1832
|
try {
|
|
1737
1833
|
await this.ensureReady(), await this.idbDelete(Se, e);
|
|
1738
1834
|
} catch (s) {
|
|
1739
|
-
throw
|
|
1835
|
+
throw p.error("[CROSSx] IndexedDB remove error:", s), s;
|
|
1740
1836
|
}
|
|
1741
1837
|
}
|
|
1742
1838
|
async clear() {
|
|
1743
1839
|
try {
|
|
1744
1840
|
await this.ensureReady(), await this.idbClear(Se);
|
|
1745
1841
|
} catch (e) {
|
|
1746
|
-
throw
|
|
1842
|
+
throw p.error("[CROSSx] IndexedDB clear error:", e), e;
|
|
1747
1843
|
}
|
|
1748
1844
|
}
|
|
1749
1845
|
/**
|
|
@@ -1763,7 +1859,7 @@ function ue(r, e = "") {
|
|
|
1763
1859
|
throw new Error(`${s}expected integer >= 0, got ${r}`);
|
|
1764
1860
|
}
|
|
1765
1861
|
}
|
|
1766
|
-
function
|
|
1862
|
+
function H(r, e, s = "") {
|
|
1767
1863
|
const t = at(r), n = r == null ? void 0 : r.length, o = e !== void 0;
|
|
1768
1864
|
if (!t || o && n !== e) {
|
|
1769
1865
|
const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
|
|
@@ -1771,7 +1867,7 @@ function F(r, e, s = "") {
|
|
|
1771
1867
|
}
|
|
1772
1868
|
return r;
|
|
1773
1869
|
}
|
|
1774
|
-
function
|
|
1870
|
+
function Yt(r) {
|
|
1775
1871
|
if (typeof r != "function" || typeof r.create != "function")
|
|
1776
1872
|
throw new Error("Hash must wrapped by utils.createHasher");
|
|
1777
1873
|
ue(r.outputLen), ue(r.blockLen);
|
|
@@ -1782,13 +1878,13 @@ function Ie(r, e = !0) {
|
|
|
1782
1878
|
if (e && r.finished)
|
|
1783
1879
|
throw new Error("Hash#digest() has already been called");
|
|
1784
1880
|
}
|
|
1785
|
-
function
|
|
1786
|
-
|
|
1881
|
+
function Zt(r, e) {
|
|
1882
|
+
H(r, void 0, "digestInto() output");
|
|
1787
1883
|
const s = e.outputLen;
|
|
1788
1884
|
if (r.length < s)
|
|
1789
1885
|
throw new Error('"digestInto() output" expected to be of length >=' + s);
|
|
1790
1886
|
}
|
|
1791
|
-
function
|
|
1887
|
+
function tr(r) {
|
|
1792
1888
|
return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
|
|
1793
1889
|
}
|
|
1794
1890
|
function Te(...r) {
|
|
@@ -1801,26 +1897,26 @@ function Ze(r) {
|
|
|
1801
1897
|
function oe(r, e) {
|
|
1802
1898
|
return r << 32 - e | r >>> e;
|
|
1803
1899
|
}
|
|
1804
|
-
const
|
|
1805
|
-
function
|
|
1900
|
+
const sr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
1901
|
+
function rr(r) {
|
|
1806
1902
|
return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
|
|
1807
1903
|
}
|
|
1808
|
-
function
|
|
1904
|
+
function nr(r) {
|
|
1809
1905
|
for (let e = 0; e < r.length; e++)
|
|
1810
|
-
r[e] =
|
|
1906
|
+
r[e] = rr(r[e]);
|
|
1811
1907
|
return r;
|
|
1812
1908
|
}
|
|
1813
|
-
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"));
|
|
1814
1910
|
function ke(r) {
|
|
1815
|
-
if (
|
|
1911
|
+
if (H(r), Xt)
|
|
1816
1912
|
return r.toHex();
|
|
1817
1913
|
let e = "";
|
|
1818
1914
|
for (let s = 0; s < r.length; s++)
|
|
1819
|
-
e +=
|
|
1915
|
+
e += or[r[s]];
|
|
1820
1916
|
return e;
|
|
1821
1917
|
}
|
|
1822
1918
|
const ce = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
1823
|
-
function
|
|
1919
|
+
function Ct(r) {
|
|
1824
1920
|
if (r >= ce._0 && r <= ce._9)
|
|
1825
1921
|
return r - ce._0;
|
|
1826
1922
|
if (r >= ce.A && r <= ce.F)
|
|
@@ -1828,17 +1924,17 @@ function Ot(r) {
|
|
|
1828
1924
|
if (r >= ce.a && r <= ce.f)
|
|
1829
1925
|
return r - (ce.a - 10);
|
|
1830
1926
|
}
|
|
1831
|
-
function
|
|
1927
|
+
function Ue(r) {
|
|
1832
1928
|
if (typeof r != "string")
|
|
1833
1929
|
throw new Error("hex string expected, got " + typeof r);
|
|
1834
|
-
if (
|
|
1930
|
+
if (Xt)
|
|
1835
1931
|
return Uint8Array.fromHex(r);
|
|
1836
1932
|
const e = r.length, s = e / 2;
|
|
1837
1933
|
if (e % 2)
|
|
1838
1934
|
throw new Error("hex string expected, got unpadded hex of length " + e);
|
|
1839
1935
|
const t = new Uint8Array(s);
|
|
1840
1936
|
for (let n = 0, o = 0; n < s; n++, o += 2) {
|
|
1841
|
-
const i =
|
|
1937
|
+
const i = Ct(r.charCodeAt(o)), a = Ct(r.charCodeAt(o + 1));
|
|
1842
1938
|
if (i === void 0 || a === void 0) {
|
|
1843
1939
|
const c = r[o] + r[o + 1];
|
|
1844
1940
|
throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + o);
|
|
@@ -1851,7 +1947,7 @@ function _e(...r) {
|
|
|
1851
1947
|
let e = 0;
|
|
1852
1948
|
for (let t = 0; t < r.length; t++) {
|
|
1853
1949
|
const n = r[t];
|
|
1854
|
-
|
|
1950
|
+
H(n), e += n.length;
|
|
1855
1951
|
}
|
|
1856
1952
|
const s = new Uint8Array(e);
|
|
1857
1953
|
for (let t = 0, n = 0; t < r.length; t++) {
|
|
@@ -1860,26 +1956,26 @@ function _e(...r) {
|
|
|
1860
1956
|
}
|
|
1861
1957
|
return s;
|
|
1862
1958
|
}
|
|
1863
|
-
function
|
|
1959
|
+
function Jt(r, e = {}) {
|
|
1864
1960
|
const s = (n, o) => r(o).update(n).digest(), t = r(void 0);
|
|
1865
1961
|
return s.outputLen = t.outputLen, s.blockLen = t.blockLen, s.create = (n) => r(n), Object.assign(s, e), Object.freeze(s);
|
|
1866
1962
|
}
|
|
1867
|
-
function
|
|
1963
|
+
function Qt(r = 32) {
|
|
1868
1964
|
const e = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
1869
1965
|
if (typeof (e == null ? void 0 : e.getRandomValues) != "function")
|
|
1870
1966
|
throw new Error("crypto.getRandomValues must be defined");
|
|
1871
1967
|
return e.getRandomValues(new Uint8Array(r));
|
|
1872
1968
|
}
|
|
1873
|
-
const
|
|
1969
|
+
const ir = (r) => ({
|
|
1874
1970
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
|
|
1875
1971
|
});
|
|
1876
|
-
function
|
|
1972
|
+
function ar(r, e, s) {
|
|
1877
1973
|
return r & e ^ ~r & s;
|
|
1878
1974
|
}
|
|
1879
|
-
function
|
|
1975
|
+
function cr(r, e, s) {
|
|
1880
1976
|
return r & e ^ r & s ^ e & s;
|
|
1881
1977
|
}
|
|
1882
|
-
class
|
|
1978
|
+
class lr {
|
|
1883
1979
|
constructor(e, s, t, n) {
|
|
1884
1980
|
v(this, "blockLen");
|
|
1885
1981
|
v(this, "outputLen");
|
|
@@ -1895,7 +1991,7 @@ class or {
|
|
|
1895
1991
|
this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ze(this.buffer);
|
|
1896
1992
|
}
|
|
1897
1993
|
update(e) {
|
|
1898
|
-
Ie(this),
|
|
1994
|
+
Ie(this), H(e);
|
|
1899
1995
|
const { view: s, buffer: t, blockLen: n } = this, o = e.length;
|
|
1900
1996
|
for (let i = 0; i < o; ) {
|
|
1901
1997
|
const a = Math.min(n - this.pos, o - i);
|
|
@@ -1910,12 +2006,12 @@ class or {
|
|
|
1910
2006
|
return this.length += e.length, this.roundClean(), this;
|
|
1911
2007
|
}
|
|
1912
2008
|
digestInto(e) {
|
|
1913
|
-
Ie(this),
|
|
2009
|
+
Ie(this), Zt(e, this), this.finished = !0;
|
|
1914
2010
|
const { buffer: s, view: t, blockLen: n, isLE: o } = this;
|
|
1915
2011
|
let { pos: i } = this;
|
|
1916
2012
|
s[i++] = 128, Te(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
|
|
1917
|
-
for (let
|
|
1918
|
-
s[
|
|
2013
|
+
for (let f = i; f < n; f++)
|
|
2014
|
+
s[f] = 0;
|
|
1919
2015
|
t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
|
|
1920
2016
|
const a = Ze(e), c = this.outputLen;
|
|
1921
2017
|
if (c % 4)
|
|
@@ -1923,8 +2019,8 @@ class or {
|
|
|
1923
2019
|
const l = c / 4, d = this.get();
|
|
1924
2020
|
if (l > d.length)
|
|
1925
2021
|
throw new Error("_sha2: outputLen bigger than state");
|
|
1926
|
-
for (let
|
|
1927
|
-
a.setUint32(4 *
|
|
2022
|
+
for (let f = 0; f < l; f++)
|
|
2023
|
+
a.setUint32(4 * f, d[f], o);
|
|
1928
2024
|
}
|
|
1929
2025
|
digest() {
|
|
1930
2026
|
const { buffer: e, outputLen: s } = this;
|
|
@@ -1950,20 +2046,20 @@ const fe = /* @__PURE__ */ Uint32Array.from([
|
|
|
1950
2046
|
2600822924,
|
|
1951
2047
|
528734635,
|
|
1952
2048
|
1541459225
|
|
1953
|
-
]), De = /* @__PURE__ */ BigInt(2 ** 32 - 1),
|
|
1954
|
-
function
|
|
1955
|
-
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 };
|
|
1956
2052
|
}
|
|
1957
|
-
function
|
|
2053
|
+
function ur(r, e = !1) {
|
|
1958
2054
|
const s = r.length;
|
|
1959
2055
|
let t = new Uint32Array(s), n = new Uint32Array(s);
|
|
1960
2056
|
for (let o = 0; o < s; o++) {
|
|
1961
|
-
const { h: i, l: a } =
|
|
2057
|
+
const { h: i, l: a } = dr(r[o], e);
|
|
1962
2058
|
[t[o], n[o]] = [i, a];
|
|
1963
2059
|
}
|
|
1964
2060
|
return [t, n];
|
|
1965
2061
|
}
|
|
1966
|
-
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([
|
|
1967
2063
|
1116352408,
|
|
1968
2064
|
1899447441,
|
|
1969
2065
|
3049323471,
|
|
@@ -2029,7 +2125,7 @@ const cr = (r, e, s) => r << s | e >>> 32 - s, lr = (r, e, s) => e << s | r >>>
|
|
|
2029
2125
|
3204031479,
|
|
2030
2126
|
3329325298
|
|
2031
2127
|
]), pe = /* @__PURE__ */ new Uint32Array(64);
|
|
2032
|
-
class
|
|
2128
|
+
class xr extends lr {
|
|
2033
2129
|
constructor(e) {
|
|
2034
2130
|
super(64, e, 8, !1);
|
|
2035
2131
|
}
|
|
@@ -2042,16 +2138,16 @@ class fr extends or {
|
|
|
2042
2138
|
this.A = e | 0, this.B = s | 0, this.C = t | 0, this.D = n | 0, this.E = o | 0, this.F = i | 0, this.G = a | 0, this.H = c | 0;
|
|
2043
2139
|
}
|
|
2044
2140
|
process(e, s) {
|
|
2045
|
-
for (let
|
|
2046
|
-
pe[
|
|
2047
|
-
for (let
|
|
2048
|
-
const
|
|
2049
|
-
pe[
|
|
2141
|
+
for (let f = 0; f < 16; f++, s += 4)
|
|
2142
|
+
pe[f] = e.getUint32(s, !1);
|
|
2143
|
+
for (let f = 16; f < 64; f++) {
|
|
2144
|
+
const w = pe[f - 15], _ = pe[f - 2], m = oe(w, 7) ^ oe(w, 18) ^ w >>> 3, A = oe(_, 17) ^ oe(_, 19) ^ _ >>> 10;
|
|
2145
|
+
pe[f] = A + pe[f - 7] + m + pe[f - 16] | 0;
|
|
2050
2146
|
}
|
|
2051
2147
|
let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: d } = this;
|
|
2052
|
-
for (let
|
|
2053
|
-
const
|
|
2054
|
-
d = l, l = c, c = a, a = i +
|
|
2148
|
+
for (let f = 0; f < 64; f++) {
|
|
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;
|
|
2150
|
+
d = l, l = c, c = a, a = i + _ | 0, i = o, o = n, n = t, t = _ + A | 0;
|
|
2055
2151
|
}
|
|
2056
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);
|
|
2057
2153
|
}
|
|
@@ -2062,7 +2158,7 @@ class fr extends or {
|
|
|
2062
2158
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), Te(this.buffer);
|
|
2063
2159
|
}
|
|
2064
2160
|
}
|
|
2065
|
-
class
|
|
2161
|
+
class mr extends xr {
|
|
2066
2162
|
constructor() {
|
|
2067
2163
|
super(32);
|
|
2068
2164
|
// We cannot use array here since array allows indexing by variable
|
|
@@ -2077,9 +2173,9 @@ class pr extends fr {
|
|
|
2077
2173
|
v(this, "H", fe[7] | 0);
|
|
2078
2174
|
}
|
|
2079
2175
|
}
|
|
2080
|
-
const
|
|
2081
|
-
() => new
|
|
2082
|
-
/* @__PURE__ */
|
|
2176
|
+
const wr = /* @__PURE__ */ Jt(
|
|
2177
|
+
() => new mr(),
|
|
2178
|
+
/* @__PURE__ */ ir(1)
|
|
2083
2179
|
);
|
|
2084
2180
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2085
2181
|
const ct = /* @__PURE__ */ BigInt(0), rt = /* @__PURE__ */ BigInt(1);
|
|
@@ -2090,7 +2186,7 @@ function He(r, e = "") {
|
|
|
2090
2186
|
}
|
|
2091
2187
|
return r;
|
|
2092
2188
|
}
|
|
2093
|
-
function
|
|
2189
|
+
function es(r) {
|
|
2094
2190
|
if (typeof r == "bigint") {
|
|
2095
2191
|
if (!Be(r))
|
|
2096
2192
|
throw new Error("positive bigint expected, got " + r);
|
|
@@ -2099,75 +2195,75 @@ function Jt(r) {
|
|
|
2099
2195
|
return r;
|
|
2100
2196
|
}
|
|
2101
2197
|
function $e(r) {
|
|
2102
|
-
const e =
|
|
2198
|
+
const e = es(r).toString(16);
|
|
2103
2199
|
return e.length & 1 ? "0" + e : e;
|
|
2104
2200
|
}
|
|
2105
|
-
function
|
|
2201
|
+
function ts(r) {
|
|
2106
2202
|
if (typeof r != "string")
|
|
2107
2203
|
throw new Error("hex string expected, got " + typeof r);
|
|
2108
2204
|
return r === "" ? ct : BigInt("0x" + r);
|
|
2109
2205
|
}
|
|
2110
2206
|
function je(r) {
|
|
2111
|
-
return
|
|
2207
|
+
return ts(ke(r));
|
|
2112
2208
|
}
|
|
2113
|
-
function
|
|
2114
|
-
return
|
|
2209
|
+
function ss(r) {
|
|
2210
|
+
return ts(ke(yr(H(r)).reverse()));
|
|
2115
2211
|
}
|
|
2116
2212
|
function lt(r, e) {
|
|
2117
|
-
ue(e), r =
|
|
2118
|
-
const s =
|
|
2213
|
+
ue(e), r = es(r);
|
|
2214
|
+
const s = Ue(r.toString(16).padStart(e * 2, "0"));
|
|
2119
2215
|
if (s.length !== e)
|
|
2120
2216
|
throw new Error("number too large");
|
|
2121
2217
|
return s;
|
|
2122
2218
|
}
|
|
2123
|
-
function
|
|
2219
|
+
function rs(r, e) {
|
|
2124
2220
|
return lt(r, e).reverse();
|
|
2125
2221
|
}
|
|
2126
|
-
function
|
|
2222
|
+
function yr(r) {
|
|
2127
2223
|
return Uint8Array.from(r);
|
|
2128
2224
|
}
|
|
2129
2225
|
const Be = (r) => typeof r == "bigint" && ct <= r;
|
|
2130
|
-
function
|
|
2226
|
+
function br(r, e, s) {
|
|
2131
2227
|
return Be(r) && Be(e) && Be(s) && e <= r && r < s;
|
|
2132
2228
|
}
|
|
2133
|
-
function
|
|
2134
|
-
if (!
|
|
2229
|
+
function vr(r, e, s, t) {
|
|
2230
|
+
if (!br(e, s, t))
|
|
2135
2231
|
throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
|
|
2136
2232
|
}
|
|
2137
|
-
function
|
|
2233
|
+
function Sr(r) {
|
|
2138
2234
|
let e;
|
|
2139
2235
|
for (e = 0; r > ct; r >>= rt, e += 1)
|
|
2140
2236
|
;
|
|
2141
2237
|
return e;
|
|
2142
2238
|
}
|
|
2143
2239
|
const dt = (r) => (rt << BigInt(r)) - rt;
|
|
2144
|
-
function
|
|
2240
|
+
function Er(r, e, s) {
|
|
2145
2241
|
if (ue(r, "hashLen"), ue(e, "qByteLen"), typeof s != "function")
|
|
2146
2242
|
throw new Error("hmacFn must be a function");
|
|
2147
|
-
const t = (
|
|
2243
|
+
const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
|
|
2148
2244
|
let c = t(r), l = t(r), d = 0;
|
|
2149
|
-
const
|
|
2245
|
+
const f = () => {
|
|
2150
2246
|
c.fill(1), l.fill(0), d = 0;
|
|
2151
|
-
},
|
|
2152
|
-
l =
|
|
2153
|
-
},
|
|
2247
|
+
}, w = (...y) => s(l, _e(c, ...y)), _ = (y = n) => {
|
|
2248
|
+
l = w(o, y), c = w(), y.length !== 0 && (l = w(i, y), c = w());
|
|
2249
|
+
}, m = () => {
|
|
2154
2250
|
if (d++ >= a)
|
|
2155
2251
|
throw new Error("drbg: tried max amount of iterations");
|
|
2156
|
-
let
|
|
2157
|
-
const
|
|
2158
|
-
for (;
|
|
2159
|
-
c =
|
|
2160
|
-
const
|
|
2161
|
-
|
|
2162
|
-
}
|
|
2163
|
-
return _e(...
|
|
2252
|
+
let y = 0;
|
|
2253
|
+
const I = [];
|
|
2254
|
+
for (; y < e; ) {
|
|
2255
|
+
c = w();
|
|
2256
|
+
const L = c.slice();
|
|
2257
|
+
I.push(L), y += c.length;
|
|
2258
|
+
}
|
|
2259
|
+
return _e(...I);
|
|
2164
2260
|
};
|
|
2165
|
-
return (
|
|
2166
|
-
|
|
2167
|
-
let
|
|
2168
|
-
for (; !(
|
|
2169
|
-
|
|
2170
|
-
return
|
|
2261
|
+
return (y, I) => {
|
|
2262
|
+
f(), _(y);
|
|
2263
|
+
let L;
|
|
2264
|
+
for (; !(L = I(m())); )
|
|
2265
|
+
_();
|
|
2266
|
+
return f(), L;
|
|
2171
2267
|
};
|
|
2172
2268
|
}
|
|
2173
2269
|
function ut(r, e = {}, s = {}) {
|
|
@@ -2184,7 +2280,7 @@ function ut(r, e = {}, s = {}) {
|
|
|
2184
2280
|
const n = (o, i) => Object.entries(o).forEach(([a, c]) => t(a, c, i));
|
|
2185
2281
|
n(e, !1), n(s, !0);
|
|
2186
2282
|
}
|
|
2187
|
-
function
|
|
2283
|
+
function Nt(r) {
|
|
2188
2284
|
const e = /* @__PURE__ */ new WeakMap();
|
|
2189
2285
|
return (s, ...t) => {
|
|
2190
2286
|
const n = e.get(s);
|
|
@@ -2195,7 +2291,7 @@ function kt(r) {
|
|
|
2195
2291
|
};
|
|
2196
2292
|
}
|
|
2197
2293
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2198
|
-
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);
|
|
2199
2295
|
function re(r, e) {
|
|
2200
2296
|
const s = r % e;
|
|
2201
2297
|
return s >= J ? s : e + s;
|
|
@@ -2206,7 +2302,7 @@ function se(r, e, s) {
|
|
|
2206
2302
|
t *= t, t %= s;
|
|
2207
2303
|
return t;
|
|
2208
2304
|
}
|
|
2209
|
-
function
|
|
2305
|
+
function Pt(r, e) {
|
|
2210
2306
|
if (r === J)
|
|
2211
2307
|
throw new Error("invert: expected non-zero number");
|
|
2212
2308
|
if (e <= J)
|
|
@@ -2224,62 +2320,62 @@ function ht(r, e, s) {
|
|
|
2224
2320
|
if (!r.eql(r.sqr(e), s))
|
|
2225
2321
|
throw new Error("Cannot find square root");
|
|
2226
2322
|
}
|
|
2227
|
-
function
|
|
2228
|
-
const s = (r.ORDER + z) /
|
|
2323
|
+
function ls(r, e) {
|
|
2324
|
+
const s = (r.ORDER + z) / os, t = r.pow(e, s);
|
|
2229
2325
|
return ht(r, t, e), t;
|
|
2230
2326
|
}
|
|
2231
|
-
function
|
|
2232
|
-
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));
|
|
2233
2329
|
return ht(r, a, e), a;
|
|
2234
2330
|
}
|
|
2235
|
-
function
|
|
2236
|
-
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;
|
|
2237
2333
|
return (a, c) => {
|
|
2238
2334
|
let l = a.pow(c, i), d = a.mul(l, t);
|
|
2239
|
-
const
|
|
2240
|
-
l = a.cmov(l, d,
|
|
2241
|
-
const
|
|
2242
|
-
return ht(a,
|
|
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);
|
|
2336
|
+
l = a.cmov(l, d, _), d = a.cmov(w, f, m);
|
|
2337
|
+
const A = a.eql(a.sqr(d), c), y = a.cmov(l, d, A);
|
|
2338
|
+
return ht(a, y, c), y;
|
|
2243
2339
|
};
|
|
2244
2340
|
}
|
|
2245
|
-
function
|
|
2246
|
-
if (r <
|
|
2341
|
+
function ds(r) {
|
|
2342
|
+
if (r < ns)
|
|
2247
2343
|
throw new Error("sqrt is not defined for small field");
|
|
2248
2344
|
let e = r - z, s = 0;
|
|
2249
2345
|
for (; e % ye === J; )
|
|
2250
2346
|
e /= ye, s++;
|
|
2251
2347
|
let t = ye;
|
|
2252
2348
|
const n = Ve(r);
|
|
2253
|
-
for (;
|
|
2349
|
+
for (; Lt(n, t) === 1; )
|
|
2254
2350
|
if (t++ > 1e3)
|
|
2255
2351
|
throw new Error("Cannot find square root: probably non-prime P");
|
|
2256
2352
|
if (s === 1)
|
|
2257
|
-
return
|
|
2353
|
+
return ls;
|
|
2258
2354
|
let o = n.pow(t, e);
|
|
2259
2355
|
const i = (e + z) / ye;
|
|
2260
2356
|
return function(c, l) {
|
|
2261
2357
|
if (c.is0(l))
|
|
2262
2358
|
return l;
|
|
2263
|
-
if (
|
|
2359
|
+
if (Lt(c, l) !== 1)
|
|
2264
2360
|
throw new Error("Cannot find square root");
|
|
2265
|
-
let d = s,
|
|
2266
|
-
for (; !c.eql(
|
|
2267
|
-
if (c.is0(
|
|
2361
|
+
let d = s, f = c.mul(c.ONE, o), w = c.pow(l, e), _ = c.pow(l, i);
|
|
2362
|
+
for (; !c.eql(w, c.ONE); ) {
|
|
2363
|
+
if (c.is0(w))
|
|
2268
2364
|
return c.ZERO;
|
|
2269
|
-
let
|
|
2270
|
-
for (; !c.eql(
|
|
2271
|
-
if (
|
|
2365
|
+
let m = 1, A = c.sqr(w);
|
|
2366
|
+
for (; !c.eql(A, c.ONE); )
|
|
2367
|
+
if (m++, A = c.sqr(A), m === d)
|
|
2272
2368
|
throw new Error("Cannot find square root");
|
|
2273
|
-
const
|
|
2274
|
-
d =
|
|
2369
|
+
const y = z << BigInt(d - m - 1), I = c.pow(f, y);
|
|
2370
|
+
d = m, f = c.sqr(I), w = c.mul(w, f), _ = c.mul(_, I);
|
|
2275
2371
|
}
|
|
2276
|
-
return
|
|
2372
|
+
return _;
|
|
2277
2373
|
};
|
|
2278
2374
|
}
|
|
2279
|
-
function
|
|
2280
|
-
return r %
|
|
2375
|
+
function Or(r) {
|
|
2376
|
+
return r % os === ns ? ls : r % as === is ? Ar : r % cs === Tr ? Rr(r) : ds(r);
|
|
2281
2377
|
}
|
|
2282
|
-
const
|
|
2378
|
+
const Cr = [
|
|
2283
2379
|
"create",
|
|
2284
2380
|
"isValid",
|
|
2285
2381
|
"is0",
|
|
@@ -2298,15 +2394,15 @@ const Tr = [
|
|
|
2298
2394
|
"mulN",
|
|
2299
2395
|
"sqrN"
|
|
2300
2396
|
];
|
|
2301
|
-
function
|
|
2397
|
+
function kr(r) {
|
|
2302
2398
|
const e = {
|
|
2303
2399
|
ORDER: "bigint",
|
|
2304
2400
|
BYTES: "number",
|
|
2305
2401
|
BITS: "number"
|
|
2306
|
-
}, s =
|
|
2402
|
+
}, s = Cr.reduce((t, n) => (t[n] = "function", t), e);
|
|
2307
2403
|
return ut(r, s), r;
|
|
2308
2404
|
}
|
|
2309
|
-
function
|
|
2405
|
+
function Nr(r, e, s) {
|
|
2310
2406
|
if (s < J)
|
|
2311
2407
|
throw new Error("invalid exponent, negatives unsupported");
|
|
2312
2408
|
if (s === J)
|
|
@@ -2318,22 +2414,22 @@ function Rr(r, e, s) {
|
|
|
2318
2414
|
s & z && (t = r.mul(t, n)), n = r.sqr(n), s >>= z;
|
|
2319
2415
|
return t;
|
|
2320
2416
|
}
|
|
2321
|
-
function
|
|
2417
|
+
function us(r, e, s = !1) {
|
|
2322
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);
|
|
2323
2419
|
return e.reduceRight((i, a, c) => r.is0(a) ? i : (t[c] = r.mul(i, t[c]), r.mul(i, a)), o), t;
|
|
2324
2420
|
}
|
|
2325
|
-
function
|
|
2421
|
+
function Lt(r, e) {
|
|
2326
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));
|
|
2327
2423
|
if (!n && !o && !i)
|
|
2328
2424
|
throw new Error("invalid Legendre symbol result");
|
|
2329
2425
|
return n ? 1 : o ? 0 : -1;
|
|
2330
2426
|
}
|
|
2331
|
-
function
|
|
2427
|
+
function Pr(r, e) {
|
|
2332
2428
|
e !== void 0 && ue(e);
|
|
2333
2429
|
const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
|
|
2334
2430
|
return { nBitLength: s, nByteLength: t };
|
|
2335
2431
|
}
|
|
2336
|
-
class
|
|
2432
|
+
class Lr {
|
|
2337
2433
|
constructor(e, s = {}) {
|
|
2338
2434
|
v(this, "ORDER");
|
|
2339
2435
|
v(this, "BITS");
|
|
@@ -2350,7 +2446,7 @@ class Cr {
|
|
|
2350
2446
|
throw new Error("invalid field: expected ORDER > 0, got " + e);
|
|
2351
2447
|
let t;
|
|
2352
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));
|
|
2353
|
-
const { nBitLength: n, nByteLength: o } =
|
|
2449
|
+
const { nBitLength: n, nByteLength: o } = Pr(e, t);
|
|
2354
2450
|
if (o > 2048)
|
|
2355
2451
|
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
2356
2452
|
this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
|
|
@@ -2392,10 +2488,10 @@ class Cr {
|
|
|
2392
2488
|
return re(e * s, this.ORDER);
|
|
2393
2489
|
}
|
|
2394
2490
|
pow(e, s) {
|
|
2395
|
-
return
|
|
2491
|
+
return Nr(this, e, s);
|
|
2396
2492
|
}
|
|
2397
2493
|
div(e, s) {
|
|
2398
|
-
return re(e *
|
|
2494
|
+
return re(e * Pt(s, this.ORDER), this.ORDER);
|
|
2399
2495
|
}
|
|
2400
2496
|
// Same as above, but doesn't normalize
|
|
2401
2497
|
sqrN(e) {
|
|
@@ -2411,16 +2507,16 @@ class Cr {
|
|
|
2411
2507
|
return e * s;
|
|
2412
2508
|
}
|
|
2413
2509
|
inv(e) {
|
|
2414
|
-
return
|
|
2510
|
+
return Pt(e, this.ORDER);
|
|
2415
2511
|
}
|
|
2416
2512
|
sqrt(e) {
|
|
2417
|
-
return this._sqrt || (this._sqrt =
|
|
2513
|
+
return this._sqrt || (this._sqrt = Or(this.ORDER)), this._sqrt(this, e);
|
|
2418
2514
|
}
|
|
2419
2515
|
toBytes(e) {
|
|
2420
|
-
return this.isLE ?
|
|
2516
|
+
return this.isLE ? rs(e, this.BYTES) : lt(e, this.BYTES);
|
|
2421
2517
|
}
|
|
2422
2518
|
fromBytes(e, s = !1) {
|
|
2423
|
-
|
|
2519
|
+
H(e);
|
|
2424
2520
|
const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
|
|
2425
2521
|
if (t) {
|
|
2426
2522
|
if (!t.includes(e.length) || e.length > n)
|
|
@@ -2430,14 +2526,14 @@ class Cr {
|
|
|
2430
2526
|
}
|
|
2431
2527
|
if (e.length !== n)
|
|
2432
2528
|
throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
|
|
2433
|
-
let c = o ?
|
|
2529
|
+
let c = o ? ss(e) : je(e);
|
|
2434
2530
|
if (a && (c = re(c, i)), !s && !this.isValid(c))
|
|
2435
2531
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
2436
2532
|
return c;
|
|
2437
2533
|
}
|
|
2438
2534
|
// TODO: we don't need it here, move out to separate fn
|
|
2439
2535
|
invertBatch(e) {
|
|
2440
|
-
return
|
|
2536
|
+
return us(this, e);
|
|
2441
2537
|
}
|
|
2442
2538
|
// We can't move this out because Fp6, Fp12 implement it
|
|
2443
2539
|
// and it's unclear what to return in there.
|
|
@@ -2446,25 +2542,25 @@ class Cr {
|
|
|
2446
2542
|
}
|
|
2447
2543
|
}
|
|
2448
2544
|
function Ve(r, e = {}) {
|
|
2449
|
-
return new
|
|
2545
|
+
return new Lr(r, e);
|
|
2450
2546
|
}
|
|
2451
|
-
function
|
|
2547
|
+
function hs(r) {
|
|
2452
2548
|
if (typeof r != "bigint")
|
|
2453
2549
|
throw new Error("field order must be bigint");
|
|
2454
2550
|
const e = r.toString(2).length;
|
|
2455
2551
|
return Math.ceil(e / 8);
|
|
2456
2552
|
}
|
|
2457
|
-
function
|
|
2458
|
-
const e =
|
|
2553
|
+
function fs(r) {
|
|
2554
|
+
const e = hs(r);
|
|
2459
2555
|
return e + Math.ceil(e / 2);
|
|
2460
2556
|
}
|
|
2461
|
-
function
|
|
2462
|
-
|
|
2463
|
-
const t = r.length, n =
|
|
2557
|
+
function Dr(r, e, s = !1) {
|
|
2558
|
+
H(r);
|
|
2559
|
+
const t = r.length, n = hs(e), o = fs(e);
|
|
2464
2560
|
if (t < 16 || t < o || t > 1024)
|
|
2465
2561
|
throw new Error("expected " + o + "-1024 bytes of input, got " + t);
|
|
2466
|
-
const i = s ?
|
|
2467
|
-
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);
|
|
2468
2564
|
}
|
|
2469
2565
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2470
2566
|
const Ae = /* @__PURE__ */ BigInt(0), be = /* @__PURE__ */ BigInt(1);
|
|
@@ -2472,35 +2568,35 @@ function Ge(r, e) {
|
|
|
2472
2568
|
const s = e.negate();
|
|
2473
2569
|
return r ? s : e;
|
|
2474
2570
|
}
|
|
2475
|
-
function
|
|
2476
|
-
const s =
|
|
2571
|
+
function Dt(r, e) {
|
|
2572
|
+
const s = us(r.Fp, e.map((t) => t.Z));
|
|
2477
2573
|
return e.map((t, n) => r.fromAffine(t.toAffine(s[n])));
|
|
2478
2574
|
}
|
|
2479
|
-
function
|
|
2575
|
+
function ps(r, e) {
|
|
2480
2576
|
if (!Number.isSafeInteger(r) || r <= 0 || r > e)
|
|
2481
2577
|
throw new Error("invalid window size, expected [1.." + e + "], got W=" + r);
|
|
2482
2578
|
}
|
|
2483
2579
|
function Xe(r, e) {
|
|
2484
|
-
|
|
2580
|
+
ps(r, e);
|
|
2485
2581
|
const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = dt(r), i = BigInt(r);
|
|
2486
2582
|
return { windows: s, windowSize: t, mask: o, maxNumber: n, shiftBy: i };
|
|
2487
2583
|
}
|
|
2488
|
-
function
|
|
2584
|
+
function $t(r, e, s) {
|
|
2489
2585
|
const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
|
|
2490
2586
|
let a = Number(r & n), c = r >> i;
|
|
2491
2587
|
a > t && (a -= o, c += be);
|
|
2492
|
-
const l = e * t, d = l + Math.abs(a) - 1,
|
|
2493
|
-
return { nextN: c, offset: d, isZero:
|
|
2588
|
+
const l = e * t, d = l + Math.abs(a) - 1, f = a === 0, w = a < 0, _ = e % 2 !== 0;
|
|
2589
|
+
return { nextN: c, offset: d, isZero: f, isNeg: w, isNegF: _, offsetF: l };
|
|
2494
2590
|
}
|
|
2495
|
-
const Je = /* @__PURE__ */ new WeakMap(),
|
|
2591
|
+
const Je = /* @__PURE__ */ new WeakMap(), gs = /* @__PURE__ */ new WeakMap();
|
|
2496
2592
|
function Qe(r) {
|
|
2497
|
-
return
|
|
2593
|
+
return gs.get(r) || 1;
|
|
2498
2594
|
}
|
|
2499
|
-
function
|
|
2595
|
+
function Mt(r) {
|
|
2500
2596
|
if (r !== Ae)
|
|
2501
2597
|
throw new Error("invalid wNAF");
|
|
2502
2598
|
}
|
|
2503
|
-
class
|
|
2599
|
+
class $r {
|
|
2504
2600
|
// Parametrized with a given Point class (not individual point)
|
|
2505
2601
|
constructor(e, s) {
|
|
2506
2602
|
v(this, "BASE");
|
|
@@ -2551,10 +2647,10 @@ class Nr {
|
|
|
2551
2647
|
let n = this.ZERO, o = this.BASE;
|
|
2552
2648
|
const i = Xe(e, this.bits);
|
|
2553
2649
|
for (let a = 0; a < i.windows; a++) {
|
|
2554
|
-
const { nextN: c, offset: l, isZero: d, isNeg:
|
|
2555
|
-
t = c, d ? o = o.add(Ge(
|
|
2650
|
+
const { nextN: c, offset: l, isZero: d, isNeg: f, isNegF: w, offsetF: _ } = $t(t, a, i);
|
|
2651
|
+
t = c, d ? o = o.add(Ge(w, s[_])) : n = n.add(Ge(f, s[l]));
|
|
2556
2652
|
}
|
|
2557
|
-
return
|
|
2653
|
+
return Mt(t), { p: n, f: o };
|
|
2558
2654
|
}
|
|
2559
2655
|
/**
|
|
2560
2656
|
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
@@ -2564,13 +2660,13 @@ class Nr {
|
|
|
2564
2660
|
wNAFUnsafe(e, s, t, n = this.ZERO) {
|
|
2565
2661
|
const o = Xe(e, this.bits);
|
|
2566
2662
|
for (let i = 0; i < o.windows && t !== Ae; i++) {
|
|
2567
|
-
const { nextN: a, offset: c, isZero: l, isNeg: d } =
|
|
2663
|
+
const { nextN: a, offset: c, isZero: l, isNeg: d } = $t(t, i, o);
|
|
2568
2664
|
if (t = a, !l) {
|
|
2569
|
-
const
|
|
2570
|
-
n = n.add(d ?
|
|
2665
|
+
const f = s[c];
|
|
2666
|
+
n = n.add(d ? f.negate() : f);
|
|
2571
2667
|
}
|
|
2572
2668
|
}
|
|
2573
|
-
return
|
|
2669
|
+
return Mt(t), n;
|
|
2574
2670
|
}
|
|
2575
2671
|
getPrecomputes(e, s, t) {
|
|
2576
2672
|
let n = Je.get(s);
|
|
@@ -2588,27 +2684,27 @@ class Nr {
|
|
|
2588
2684
|
// using windowed method. This specifies window size and
|
|
2589
2685
|
// stores precomputed values. Usually only base point would be precomputed.
|
|
2590
2686
|
createCache(e, s) {
|
|
2591
|
-
|
|
2687
|
+
ps(s, this.bits), gs.set(e, s), Je.delete(e);
|
|
2592
2688
|
}
|
|
2593
2689
|
hasCache(e) {
|
|
2594
2690
|
return Qe(e) !== 1;
|
|
2595
2691
|
}
|
|
2596
2692
|
}
|
|
2597
|
-
function
|
|
2693
|
+
function Mr(r, e, s, t) {
|
|
2598
2694
|
let n = e, o = r.ZERO, i = r.ZERO;
|
|
2599
2695
|
for (; s > Ae || t > Ae; )
|
|
2600
2696
|
s & be && (o = o.add(n)), t & be && (i = i.add(n)), n = n.double(), s >>= be, t >>= be;
|
|
2601
2697
|
return { p1: o, p2: i };
|
|
2602
2698
|
}
|
|
2603
|
-
function
|
|
2699
|
+
function Bt(r, e, s) {
|
|
2604
2700
|
if (e) {
|
|
2605
2701
|
if (e.ORDER !== r)
|
|
2606
2702
|
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
2607
|
-
return
|
|
2703
|
+
return kr(e), e;
|
|
2608
2704
|
} else
|
|
2609
2705
|
return Ve(r, { isLE: s });
|
|
2610
2706
|
}
|
|
2611
|
-
function
|
|
2707
|
+
function Br(r, e, s = {}, t) {
|
|
2612
2708
|
if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
|
|
2613
2709
|
throw new Error(`expected valid ${r} CURVE object`);
|
|
2614
2710
|
for (const c of ["p", "n", "h"]) {
|
|
@@ -2616,19 +2712,19 @@ function Lr(r, e, s = {}, t) {
|
|
|
2616
2712
|
if (!(typeof l == "bigint" && l > Ae))
|
|
2617
2713
|
throw new Error(`CURVE.${c} must be positive bigint`);
|
|
2618
2714
|
}
|
|
2619
|
-
const n =
|
|
2715
|
+
const n = Bt(e.p, s.Fp, t), o = Bt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
|
|
2620
2716
|
for (const c of a)
|
|
2621
2717
|
if (!n.isValid(e[c]))
|
|
2622
2718
|
throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
|
|
2623
2719
|
return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
|
|
2624
2720
|
}
|
|
2625
|
-
function
|
|
2721
|
+
function Fr(r, e) {
|
|
2626
2722
|
return function(t) {
|
|
2627
2723
|
const n = r(t);
|
|
2628
2724
|
return { secretKey: n, publicKey: e(n) };
|
|
2629
2725
|
};
|
|
2630
2726
|
}
|
|
2631
|
-
class
|
|
2727
|
+
class _s {
|
|
2632
2728
|
constructor(e, s) {
|
|
2633
2729
|
v(this, "oHash");
|
|
2634
2730
|
v(this, "iHash");
|
|
@@ -2636,7 +2732,7 @@ class ps {
|
|
|
2636
2732
|
v(this, "outputLen");
|
|
2637
2733
|
v(this, "finished", !1);
|
|
2638
2734
|
v(this, "destroyed", !1);
|
|
2639
|
-
if (
|
|
2735
|
+
if (Yt(e), H(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
|
|
2640
2736
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
2641
2737
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
2642
2738
|
const t = this.blockLen, n = new Uint8Array(t);
|
|
@@ -2652,7 +2748,7 @@ class ps {
|
|
|
2652
2748
|
return Ie(this), this.iHash.update(e), this;
|
|
2653
2749
|
}
|
|
2654
2750
|
digestInto(e) {
|
|
2655
|
-
Ie(this),
|
|
2751
|
+
Ie(this), H(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
|
|
2656
2752
|
}
|
|
2657
2753
|
digest() {
|
|
2658
2754
|
const e = new Uint8Array(this.oHash.outputLen);
|
|
@@ -2670,19 +2766,19 @@ class ps {
|
|
|
2670
2766
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
2671
2767
|
}
|
|
2672
2768
|
}
|
|
2673
|
-
const
|
|
2674
|
-
|
|
2769
|
+
const xs = (r, e, s) => new _s(r, e).update(s).digest();
|
|
2770
|
+
xs.create = (r, e) => new _s(r, e);
|
|
2675
2771
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2676
|
-
const
|
|
2677
|
-
function
|
|
2678
|
-
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);
|
|
2679
2775
|
let l = r - a * t - c * o, d = -a * n - c * i;
|
|
2680
|
-
const
|
|
2681
|
-
|
|
2682
|
-
const
|
|
2683
|
-
if (l < le || l >=
|
|
2776
|
+
const f = l < le, w = d < le;
|
|
2777
|
+
f && (l = -l), w && (d = -d);
|
|
2778
|
+
const _ = dt(Math.ceil(Sr(s) / 2)) + Ee;
|
|
2779
|
+
if (l < le || l >= _ || d < le || d >= _)
|
|
2684
2780
|
throw new Error("splitScalar (endomorphism): failed, k=" + r);
|
|
2685
|
-
return { k1neg:
|
|
2781
|
+
return { k1neg: f, k1: l, k2neg: w, k2: d };
|
|
2686
2782
|
}
|
|
2687
2783
|
function nt(r) {
|
|
2688
2784
|
if (!["compact", "recovered", "der"].includes(r))
|
|
@@ -2695,14 +2791,14 @@ function et(r, e) {
|
|
|
2695
2791
|
s[t] = r[t] === void 0 ? e[t] : r[t];
|
|
2696
2792
|
return He(s.lowS, "lowS"), He(s.prehash, "prehash"), s.format !== void 0 && nt(s.format), s;
|
|
2697
2793
|
}
|
|
2698
|
-
class
|
|
2794
|
+
class Hr extends Error {
|
|
2699
2795
|
constructor(e = "") {
|
|
2700
2796
|
super(e);
|
|
2701
2797
|
}
|
|
2702
2798
|
}
|
|
2703
2799
|
const ge = {
|
|
2704
2800
|
// asn.1 DER encoding utils
|
|
2705
|
-
Err:
|
|
2801
|
+
Err: Hr,
|
|
2706
2802
|
// Basic building block is TLV (Tag-Length-Value)
|
|
2707
2803
|
_tlv: {
|
|
2708
2804
|
encode: (r, e) => {
|
|
@@ -2775,7 +2871,7 @@ const ge = {
|
|
|
2775
2871
|
}
|
|
2776
2872
|
},
|
|
2777
2873
|
toSig(r) {
|
|
2778
|
-
const { Err: e, _int: s, _tlv: t } = ge, n =
|
|
2874
|
+
const { Err: e, _int: s, _tlv: t } = ge, n = H(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
|
|
2779
2875
|
if (i.length)
|
|
2780
2876
|
throw new e("invalid signature: left bytes after parsing");
|
|
2781
2877
|
const { v: a, l: c } = t.decode(2, o), { v: l, l: d } = t.decode(2, c);
|
|
@@ -2787,9 +2883,9 @@ const ge = {
|
|
|
2787
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;
|
|
2788
2884
|
return e.encode(48, o);
|
|
2789
2885
|
}
|
|
2790
|
-
}, le = BigInt(0), Ee = BigInt(1),
|
|
2791
|
-
function
|
|
2792
|
-
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;
|
|
2793
2889
|
let o = s.CURVE;
|
|
2794
2890
|
const { h: i, n: a } = o;
|
|
2795
2891
|
ut(e, {}, {
|
|
@@ -2803,87 +2899,87 @@ function Ur(r, e = {}) {
|
|
|
2803
2899
|
const { endo: c } = e;
|
|
2804
2900
|
if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
|
|
2805
2901
|
throw new Error('invalid endo: expected "beta": bigint and "basises": array');
|
|
2806
|
-
const l =
|
|
2902
|
+
const l = ys(t, n);
|
|
2807
2903
|
function d() {
|
|
2808
2904
|
if (!t.isOdd)
|
|
2809
2905
|
throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
2810
2906
|
}
|
|
2811
|
-
function
|
|
2812
|
-
const { x:
|
|
2907
|
+
function f(P, u, h) {
|
|
2908
|
+
const { x: b, y: E } = u.toAffine(), R = t.toBytes(b);
|
|
2813
2909
|
if (He(h, "isCompressed"), h) {
|
|
2814
2910
|
d();
|
|
2815
|
-
const
|
|
2816
|
-
return _e(
|
|
2911
|
+
const T = !t.isOdd(E);
|
|
2912
|
+
return _e(ws(T), R);
|
|
2817
2913
|
} else
|
|
2818
|
-
return _e(Uint8Array.of(4), R, t.toBytes(
|
|
2819
|
-
}
|
|
2820
|
-
function
|
|
2821
|
-
|
|
2822
|
-
const { publicKey: u, publicKeyUncompressed: h } = l,
|
|
2823
|
-
if (
|
|
2824
|
-
const
|
|
2825
|
-
if (!t.isValid(
|
|
2914
|
+
return _e(Uint8Array.of(4), R, t.toBytes(E));
|
|
2915
|
+
}
|
|
2916
|
+
function w(P) {
|
|
2917
|
+
H(P, void 0, "Point");
|
|
2918
|
+
const { publicKey: u, publicKeyUncompressed: h } = l, b = P.length, E = P[0], R = P.subarray(1);
|
|
2919
|
+
if (b === u && (E === 2 || E === 3)) {
|
|
2920
|
+
const T = t.fromBytes(R);
|
|
2921
|
+
if (!t.isValid(T))
|
|
2826
2922
|
throw new Error("bad point: is not on curve, wrong x");
|
|
2827
|
-
const O =
|
|
2828
|
-
let
|
|
2923
|
+
const O = A(T);
|
|
2924
|
+
let S;
|
|
2829
2925
|
try {
|
|
2830
|
-
|
|
2926
|
+
S = t.sqrt(O);
|
|
2831
2927
|
} catch (W) {
|
|
2832
2928
|
const U = W instanceof Error ? ": " + W.message : "";
|
|
2833
2929
|
throw new Error("bad point: is not on curve, sqrt error" + U);
|
|
2834
2930
|
}
|
|
2835
2931
|
d();
|
|
2836
|
-
const C = t.isOdd(
|
|
2837
|
-
return (
|
|
2838
|
-
} else if (
|
|
2839
|
-
const
|
|
2840
|
-
if (!
|
|
2932
|
+
const C = t.isOdd(S);
|
|
2933
|
+
return (E & 1) === 1 !== C && (S = t.neg(S)), { x: T, y: S };
|
|
2934
|
+
} else if (b === h && E === 4) {
|
|
2935
|
+
const T = t.BYTES, O = t.fromBytes(R.subarray(0, T)), S = t.fromBytes(R.subarray(T, T * 2));
|
|
2936
|
+
if (!y(O, S))
|
|
2841
2937
|
throw new Error("bad point: is not on curve");
|
|
2842
|
-
return { x: O, y:
|
|
2938
|
+
return { x: O, y: S };
|
|
2843
2939
|
} else
|
|
2844
|
-
throw new Error(`bad point: got length ${
|
|
2940
|
+
throw new Error(`bad point: got length ${b}, expected compressed=${u} or uncompressed=${h}`);
|
|
2845
2941
|
}
|
|
2846
|
-
const
|
|
2847
|
-
function
|
|
2942
|
+
const _ = e.toBytes || f, m = e.fromBytes || w;
|
|
2943
|
+
function A(P) {
|
|
2848
2944
|
const u = t.sqr(P), h = t.mul(u, P);
|
|
2849
2945
|
return t.add(t.add(h, t.mul(P, o.a)), o.b);
|
|
2850
2946
|
}
|
|
2851
|
-
function
|
|
2852
|
-
const h = t.sqr(u),
|
|
2853
|
-
return t.eql(h,
|
|
2947
|
+
function y(P, u) {
|
|
2948
|
+
const h = t.sqr(u), b = A(P);
|
|
2949
|
+
return t.eql(h, b);
|
|
2854
2950
|
}
|
|
2855
|
-
if (!
|
|
2951
|
+
if (!y(o.Gx, o.Gy))
|
|
2856
2952
|
throw new Error("bad curve params: generator point");
|
|
2857
|
-
const
|
|
2858
|
-
if (t.is0(t.add(
|
|
2953
|
+
const I = t.mul(t.pow(o.a, Me), Gr), L = t.mul(t.sqr(o.b), BigInt(27));
|
|
2954
|
+
if (t.is0(t.add(I, L)))
|
|
2859
2955
|
throw new Error("bad curve params: a or b");
|
|
2860
|
-
function
|
|
2956
|
+
function F(P, u, h = !1) {
|
|
2861
2957
|
if (!t.isValid(u) || h && t.is0(u))
|
|
2862
2958
|
throw new Error(`bad point coordinate ${P}`);
|
|
2863
2959
|
return u;
|
|
2864
2960
|
}
|
|
2865
|
-
function
|
|
2961
|
+
function $(P) {
|
|
2866
2962
|
if (!(P instanceof Z))
|
|
2867
2963
|
throw new Error("Weierstrass Point expected");
|
|
2868
2964
|
}
|
|
2869
|
-
function
|
|
2965
|
+
function B(P) {
|
|
2870
2966
|
if (!c || !c.basises)
|
|
2871
2967
|
throw new Error("no endo");
|
|
2872
|
-
return
|
|
2968
|
+
return Ur(P, c.basises, n.ORDER);
|
|
2873
2969
|
}
|
|
2874
|
-
const Q =
|
|
2875
|
-
const { X: h, Y:
|
|
2876
|
-
if (t.eql(
|
|
2877
|
-
return { x: h, y };
|
|
2970
|
+
const Q = Nt((P, u) => {
|
|
2971
|
+
const { X: h, Y: b, Z: E } = P;
|
|
2972
|
+
if (t.eql(E, t.ONE))
|
|
2973
|
+
return { x: h, y: b };
|
|
2878
2974
|
const R = P.is0();
|
|
2879
|
-
u == null && (u = R ? t.ONE : t.inv(
|
|
2880
|
-
const
|
|
2975
|
+
u == null && (u = R ? t.ONE : t.inv(E));
|
|
2976
|
+
const T = t.mul(h, u), O = t.mul(b, u), S = t.mul(E, u);
|
|
2881
2977
|
if (R)
|
|
2882
2978
|
return { x: t.ZERO, y: t.ZERO };
|
|
2883
|
-
if (!t.eql(
|
|
2979
|
+
if (!t.eql(S, t.ONE))
|
|
2884
2980
|
throw new Error("invZ was invalid");
|
|
2885
|
-
return { x:
|
|
2886
|
-
}), ve =
|
|
2981
|
+
return { x: T, y: O };
|
|
2982
|
+
}), ve = Nt((P) => {
|
|
2887
2983
|
if (P.is0()) {
|
|
2888
2984
|
if (e.allowInfinityPoint && !t.is0(P.Y))
|
|
2889
2985
|
return;
|
|
@@ -2892,41 +2988,41 @@ function Ur(r, e = {}) {
|
|
|
2892
2988
|
const { x: u, y: h } = P.toAffine();
|
|
2893
2989
|
if (!t.isValid(u) || !t.isValid(h))
|
|
2894
2990
|
throw new Error("bad point: x or y not field elements");
|
|
2895
|
-
if (!
|
|
2991
|
+
if (!y(u, h))
|
|
2896
2992
|
throw new Error("bad point: equation left != right");
|
|
2897
2993
|
if (!P.isTorsionFree())
|
|
2898
2994
|
throw new Error("bad point: not in prime-order subgroup");
|
|
2899
2995
|
return !0;
|
|
2900
2996
|
});
|
|
2901
|
-
function he(P, u, h,
|
|
2902
|
-
return h = new Z(t.mul(h.X, P), h.Y, h.Z), u = Ge(
|
|
2997
|
+
function he(P, u, h, b, E) {
|
|
2998
|
+
return h = new Z(t.mul(h.X, P), h.Y, h.Z), u = Ge(b, u), h = Ge(E, h), u.add(h);
|
|
2903
2999
|
}
|
|
2904
|
-
const
|
|
3000
|
+
const D = class D {
|
|
2905
3001
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
2906
|
-
constructor(u, h,
|
|
3002
|
+
constructor(u, h, b) {
|
|
2907
3003
|
v(this, "X");
|
|
2908
3004
|
v(this, "Y");
|
|
2909
3005
|
v(this, "Z");
|
|
2910
|
-
this.X =
|
|
3006
|
+
this.X = F("x", u), this.Y = F("y", h, !0), this.Z = F("z", b), Object.freeze(this);
|
|
2911
3007
|
}
|
|
2912
3008
|
static CURVE() {
|
|
2913
3009
|
return o;
|
|
2914
3010
|
}
|
|
2915
3011
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
2916
3012
|
static fromAffine(u) {
|
|
2917
|
-
const { x: h, y } = u || {};
|
|
2918
|
-
if (!u || !t.isValid(h) || !t.isValid(
|
|
3013
|
+
const { x: h, y: b } = u || {};
|
|
3014
|
+
if (!u || !t.isValid(h) || !t.isValid(b))
|
|
2919
3015
|
throw new Error("invalid affine point");
|
|
2920
|
-
if (u instanceof
|
|
3016
|
+
if (u instanceof D)
|
|
2921
3017
|
throw new Error("projective point not allowed");
|
|
2922
|
-
return t.is0(h) && t.is0(
|
|
3018
|
+
return t.is0(h) && t.is0(b) ? D.ZERO : new D(h, b, t.ONE);
|
|
2923
3019
|
}
|
|
2924
3020
|
static fromBytes(u) {
|
|
2925
|
-
const h =
|
|
3021
|
+
const h = D.fromAffine(m(H(u, void 0, "point")));
|
|
2926
3022
|
return h.assertValidity(), h;
|
|
2927
3023
|
}
|
|
2928
3024
|
static fromHex(u) {
|
|
2929
|
-
return
|
|
3025
|
+
return D.fromBytes(Ue(u));
|
|
2930
3026
|
}
|
|
2931
3027
|
get x() {
|
|
2932
3028
|
return this.toAffine().x;
|
|
@@ -2956,42 +3052,42 @@ function Ur(r, e = {}) {
|
|
|
2956
3052
|
}
|
|
2957
3053
|
/** Compare one point to another. */
|
|
2958
3054
|
equals(u) {
|
|
2959
|
-
|
|
2960
|
-
const { X: h, Y:
|
|
2961
|
-
return
|
|
3055
|
+
$(u);
|
|
3056
|
+
const { X: h, Y: b, Z: E } = this, { X: R, Y: T, Z: O } = u, S = t.eql(t.mul(h, O), t.mul(R, E)), C = t.eql(t.mul(b, O), t.mul(T, E));
|
|
3057
|
+
return S && C;
|
|
2962
3058
|
}
|
|
2963
3059
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
2964
3060
|
negate() {
|
|
2965
|
-
return new
|
|
3061
|
+
return new D(this.X, t.neg(this.Y), this.Z);
|
|
2966
3062
|
}
|
|
2967
3063
|
// Renes-Costello-Batina exception-free doubling formula.
|
|
2968
3064
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
2969
3065
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
2970
3066
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
2971
3067
|
double() {
|
|
2972
|
-
const { a: u, b: h } = o,
|
|
2973
|
-
let O = t.ZERO,
|
|
2974
|
-
return k = t.add(k, k), C = t.mul(
|
|
3068
|
+
const { a: u, b: h } = o, b = t.mul(h, Me), { X: E, Y: R, Z: T } = this;
|
|
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);
|
|
2975
3071
|
}
|
|
2976
3072
|
// Renes-Costello-Batina exception-free addition formula.
|
|
2977
3073
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
2978
3074
|
// https://eprint.iacr.org/2015/1060, algorithm 1
|
|
2979
3075
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
2980
3076
|
add(u) {
|
|
2981
|
-
|
|
2982
|
-
const { X: h, Y:
|
|
2983
|
-
let
|
|
3077
|
+
$(u);
|
|
3078
|
+
const { X: h, Y: b, Z: E } = this, { X: R, Y: T, Z: O } = u;
|
|
3079
|
+
let S = t.ZERO, C = t.ZERO, N = t.ZERO;
|
|
2984
3080
|
const W = o.a, U = t.mul(o.b, Me);
|
|
2985
|
-
let k = t.mul(h, R), j = t.mul(
|
|
2986
|
-
ee = t.mul(ee,
|
|
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);
|
|
3082
|
+
ee = t.mul(ee, G), G = t.add(k, j), ee = t.sub(ee, G), G = t.add(h, E);
|
|
2987
3083
|
let K = t.add(R, O);
|
|
2988
|
-
return
|
|
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);
|
|
2989
3085
|
}
|
|
2990
3086
|
subtract(u) {
|
|
2991
3087
|
return this.add(u.negate());
|
|
2992
3088
|
}
|
|
2993
3089
|
is0() {
|
|
2994
|
-
return this.equals(
|
|
3090
|
+
return this.equals(D.ZERO);
|
|
2995
3091
|
}
|
|
2996
3092
|
/**
|
|
2997
3093
|
* Constant time multiplication.
|
|
@@ -3006,16 +3102,16 @@ function Ur(r, e = {}) {
|
|
|
3006
3102
|
const { endo: h } = e;
|
|
3007
3103
|
if (!n.isValidNot0(u))
|
|
3008
3104
|
throw new Error("invalid scalar: out of range");
|
|
3009
|
-
let
|
|
3010
|
-
const R = (
|
|
3105
|
+
let b, E;
|
|
3106
|
+
const R = (T) => ne.cached(this, T, (O) => Dt(D, O));
|
|
3011
3107
|
if (h) {
|
|
3012
|
-
const { k1neg:
|
|
3013
|
-
|
|
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);
|
|
3014
3110
|
} else {
|
|
3015
|
-
const { p:
|
|
3016
|
-
|
|
3111
|
+
const { p: T, f: O } = R(u);
|
|
3112
|
+
b = T, E = O;
|
|
3017
3113
|
}
|
|
3018
|
-
return
|
|
3114
|
+
return Dt(D, [b, E])[0];
|
|
3019
3115
|
}
|
|
3020
3116
|
/**
|
|
3021
3117
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -3023,20 +3119,20 @@ function Ur(r, e = {}) {
|
|
|
3023
3119
|
* an exposed secret key e.g. sig verification, which works over *public* keys.
|
|
3024
3120
|
*/
|
|
3025
3121
|
multiplyUnsafe(u) {
|
|
3026
|
-
const { endo: h } = e,
|
|
3122
|
+
const { endo: h } = e, b = this;
|
|
3027
3123
|
if (!n.isValid(u))
|
|
3028
3124
|
throw new Error("invalid scalar: out of range");
|
|
3029
|
-
if (u === le ||
|
|
3030
|
-
return
|
|
3125
|
+
if (u === le || b.is0())
|
|
3126
|
+
return D.ZERO;
|
|
3031
3127
|
if (u === Ee)
|
|
3032
|
-
return
|
|
3128
|
+
return b;
|
|
3033
3129
|
if (ne.hasCache(this))
|
|
3034
3130
|
return this.multiply(u);
|
|
3035
3131
|
if (h) {
|
|
3036
|
-
const { k1neg:
|
|
3037
|
-
return he(h.beta,
|
|
3132
|
+
const { k1neg: E, k1: R, k2neg: T, k2: O } = B(u), { p1: S, p2: C } = Mr(D, b, R, O);
|
|
3133
|
+
return he(h.beta, S, C, E, T);
|
|
3038
3134
|
} else
|
|
3039
|
-
return ne.unsafe(
|
|
3135
|
+
return ne.unsafe(b, u);
|
|
3040
3136
|
}
|
|
3041
3137
|
/**
|
|
3042
3138
|
* Converts Projective point to affine (x, y) coordinates.
|
|
@@ -3051,17 +3147,17 @@ function Ur(r, e = {}) {
|
|
|
3051
3147
|
*/
|
|
3052
3148
|
isTorsionFree() {
|
|
3053
3149
|
const { isTorsionFree: u } = e;
|
|
3054
|
-
return i === Ee ? !0 : u ? u(
|
|
3150
|
+
return i === Ee ? !0 : u ? u(D, this) : ne.unsafe(this, a).is0();
|
|
3055
3151
|
}
|
|
3056
3152
|
clearCofactor() {
|
|
3057
3153
|
const { clearCofactor: u } = e;
|
|
3058
|
-
return i === Ee ? this : u ? u(
|
|
3154
|
+
return i === Ee ? this : u ? u(D, this) : this.multiplyUnsafe(i);
|
|
3059
3155
|
}
|
|
3060
3156
|
isSmallOrder() {
|
|
3061
3157
|
return this.multiplyUnsafe(i).is0();
|
|
3062
3158
|
}
|
|
3063
3159
|
toBytes(u = !0) {
|
|
3064
|
-
return He(u, "isCompressed"), this.assertValidity(),
|
|
3160
|
+
return He(u, "isCompressed"), this.assertValidity(), _(D, this, u);
|
|
3065
3161
|
}
|
|
3066
3162
|
toHex(u = !0) {
|
|
3067
3163
|
return ke(this.toBytes(u));
|
|
@@ -3071,19 +3167,19 @@ function Ur(r, e = {}) {
|
|
|
3071
3167
|
}
|
|
3072
3168
|
};
|
|
3073
3169
|
// base / generator point
|
|
3074
|
-
v(
|
|
3075
|
-
v(
|
|
3170
|
+
v(D, "BASE", new D(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
|
|
3171
|
+
v(D, "ZERO", new D(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
|
|
3076
3172
|
// math field
|
|
3077
|
-
v(
|
|
3078
|
-
v(
|
|
3079
|
-
let Z =
|
|
3080
|
-
const xe = n.BITS, ne = new
|
|
3173
|
+
v(D, "Fp", t), // scalar field
|
|
3174
|
+
v(D, "Fn", n);
|
|
3175
|
+
let Z = D;
|
|
3176
|
+
const xe = n.BITS, ne = new $r(Z, e.endo ? Math.ceil(xe / 2) : xe);
|
|
3081
3177
|
return Z.BASE.precompute(8), Z;
|
|
3082
3178
|
}
|
|
3083
|
-
function
|
|
3179
|
+
function ws(r) {
|
|
3084
3180
|
return Uint8Array.of(r ? 2 : 3);
|
|
3085
3181
|
}
|
|
3086
|
-
function
|
|
3182
|
+
function ys(r, e) {
|
|
3087
3183
|
return {
|
|
3088
3184
|
secretKey: e.BYTES,
|
|
3089
3185
|
publicKey: 1 + r.BYTES,
|
|
@@ -3092,110 +3188,110 @@ function ms(r, e) {
|
|
|
3092
3188
|
signature: 2 * e.BYTES
|
|
3093
3189
|
};
|
|
3094
3190
|
}
|
|
3095
|
-
function
|
|
3096
|
-
const { Fn: s } = r, t = e.randomBytes ||
|
|
3097
|
-
function o(
|
|
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) });
|
|
3193
|
+
function o(_) {
|
|
3098
3194
|
try {
|
|
3099
|
-
const
|
|
3100
|
-
return s.isValidNot0(
|
|
3195
|
+
const m = s.fromBytes(_);
|
|
3196
|
+
return s.isValidNot0(m);
|
|
3101
3197
|
} catch {
|
|
3102
3198
|
return !1;
|
|
3103
3199
|
}
|
|
3104
3200
|
}
|
|
3105
|
-
function i(
|
|
3106
|
-
const { publicKey:
|
|
3201
|
+
function i(_, m) {
|
|
3202
|
+
const { publicKey: A, publicKeyUncompressed: y } = n;
|
|
3107
3203
|
try {
|
|
3108
|
-
const
|
|
3109
|
-
return
|
|
3204
|
+
const I = _.length;
|
|
3205
|
+
return m === !0 && I !== A || m === !1 && I !== y ? !1 : !!r.fromBytes(_);
|
|
3110
3206
|
} catch {
|
|
3111
3207
|
return !1;
|
|
3112
3208
|
}
|
|
3113
3209
|
}
|
|
3114
|
-
function a(
|
|
3115
|
-
return
|
|
3210
|
+
function a(_ = t(n.seed)) {
|
|
3211
|
+
return Dr(H(_, n.seed, "seed"), s.ORDER);
|
|
3116
3212
|
}
|
|
3117
|
-
function c(
|
|
3118
|
-
return r.BASE.multiply(s.fromBytes(
|
|
3213
|
+
function c(_, m = !0) {
|
|
3214
|
+
return r.BASE.multiply(s.fromBytes(_)).toBytes(m);
|
|
3119
3215
|
}
|
|
3120
|
-
function l(
|
|
3121
|
-
const { secretKey:
|
|
3122
|
-
if (!at(
|
|
3216
|
+
function l(_) {
|
|
3217
|
+
const { secretKey: m, publicKey: A, publicKeyUncompressed: y } = n;
|
|
3218
|
+
if (!at(_) || "_lengths" in s && s._lengths || m === A)
|
|
3123
3219
|
return;
|
|
3124
|
-
const
|
|
3125
|
-
return
|
|
3220
|
+
const I = H(_, void 0, "key").length;
|
|
3221
|
+
return I === A || I === y;
|
|
3126
3222
|
}
|
|
3127
|
-
function d(
|
|
3128
|
-
if (l(
|
|
3223
|
+
function d(_, m, A = !0) {
|
|
3224
|
+
if (l(_) === !0)
|
|
3129
3225
|
throw new Error("first arg must be private key");
|
|
3130
|
-
if (l(
|
|
3226
|
+
if (l(m) === !1)
|
|
3131
3227
|
throw new Error("second arg must be public key");
|
|
3132
|
-
const
|
|
3133
|
-
return r.fromBytes(
|
|
3228
|
+
const y = s.fromBytes(_);
|
|
3229
|
+
return r.fromBytes(m).multiply(y).toBytes(A);
|
|
3134
3230
|
}
|
|
3135
|
-
const
|
|
3231
|
+
const f = {
|
|
3136
3232
|
isValidSecretKey: o,
|
|
3137
3233
|
isValidPublicKey: i,
|
|
3138
3234
|
randomSecretKey: a
|
|
3139
|
-
},
|
|
3140
|
-
return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen:
|
|
3235
|
+
}, w = Fr(a, c);
|
|
3236
|
+
return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: w, Point: r, utils: f, lengths: n });
|
|
3141
3237
|
}
|
|
3142
|
-
function
|
|
3143
|
-
|
|
3238
|
+
function jr(r, e, s = {}) {
|
|
3239
|
+
Yt(e), ut(s, {}, {
|
|
3144
3240
|
hmac: "function",
|
|
3145
3241
|
lowS: "boolean",
|
|
3146
3242
|
randomBytes: "function",
|
|
3147
3243
|
bits2int: "function",
|
|
3148
3244
|
bits2int_modN: "function"
|
|
3149
3245
|
}), s = Object.assign({}, s);
|
|
3150
|
-
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 = {
|
|
3151
3247
|
prehash: !0,
|
|
3152
3248
|
lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
|
|
3153
3249
|
format: "compact",
|
|
3154
3250
|
extraEntropy: !1
|
|
3155
|
-
},
|
|
3156
|
-
function
|
|
3251
|
+
}, A = a * ms < o.ORDER;
|
|
3252
|
+
function y(u) {
|
|
3157
3253
|
const h = a >> Ee;
|
|
3158
3254
|
return u > h;
|
|
3159
3255
|
}
|
|
3160
|
-
function
|
|
3256
|
+
function I(u, h) {
|
|
3161
3257
|
if (!i.isValidNot0(h))
|
|
3162
3258
|
throw new Error(`invalid signature ${u}: out of range 1..Point.Fn.ORDER`);
|
|
3163
3259
|
return h;
|
|
3164
3260
|
}
|
|
3165
|
-
function
|
|
3166
|
-
if (
|
|
3261
|
+
function L() {
|
|
3262
|
+
if (A)
|
|
3167
3263
|
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
3168
3264
|
}
|
|
3169
|
-
function
|
|
3265
|
+
function F(u, h) {
|
|
3170
3266
|
nt(h);
|
|
3171
|
-
const
|
|
3172
|
-
return
|
|
3267
|
+
const b = _.signature, E = h === "compact" ? b : h === "recovered" ? b + 1 : void 0;
|
|
3268
|
+
return H(u, E);
|
|
3173
3269
|
}
|
|
3174
|
-
class
|
|
3175
|
-
constructor(h,
|
|
3270
|
+
class $ {
|
|
3271
|
+
constructor(h, b, E) {
|
|
3176
3272
|
v(this, "r");
|
|
3177
3273
|
v(this, "s");
|
|
3178
3274
|
v(this, "recovery");
|
|
3179
|
-
if (this.r =
|
|
3180
|
-
if (
|
|
3275
|
+
if (this.r = I("r", h), this.s = I("s", b), E != null) {
|
|
3276
|
+
if (L(), ![0, 1, 2, 3].includes(E))
|
|
3181
3277
|
throw new Error("invalid recovery id");
|
|
3182
|
-
this.recovery =
|
|
3278
|
+
this.recovery = E;
|
|
3183
3279
|
}
|
|
3184
3280
|
Object.freeze(this);
|
|
3185
3281
|
}
|
|
3186
|
-
static fromBytes(h,
|
|
3187
|
-
|
|
3188
|
-
let
|
|
3189
|
-
if (
|
|
3190
|
-
const { r:
|
|
3191
|
-
return new
|
|
3282
|
+
static fromBytes(h, b = m.format) {
|
|
3283
|
+
F(h, b);
|
|
3284
|
+
let E;
|
|
3285
|
+
if (b === "der") {
|
|
3286
|
+
const { r: S, s: C } = ge.toSig(H(h));
|
|
3287
|
+
return new $(S, C);
|
|
3192
3288
|
}
|
|
3193
|
-
|
|
3194
|
-
const R =
|
|
3195
|
-
return new
|
|
3289
|
+
b === "recovered" && (E = h[0], b = "compact", h = h.subarray(1));
|
|
3290
|
+
const R = _.signature / 2, T = h.subarray(0, R), O = h.subarray(R, R * 2);
|
|
3291
|
+
return new $(i.fromBytes(T), i.fromBytes(O), E);
|
|
3196
3292
|
}
|
|
3197
|
-
static fromHex(h,
|
|
3198
|
-
return this.fromBytes(
|
|
3293
|
+
static fromHex(h, b) {
|
|
3294
|
+
return this.fromBytes(Ue(h), b);
|
|
3199
3295
|
}
|
|
3200
3296
|
assertRecovery() {
|
|
3201
3297
|
const { recovery: h } = this;
|
|
@@ -3204,108 +3300,108 @@ function Hr(r, e, s = {}) {
|
|
|
3204
3300
|
return h;
|
|
3205
3301
|
}
|
|
3206
3302
|
addRecoveryBit(h) {
|
|
3207
|
-
return new
|
|
3303
|
+
return new $(this.r, this.s, h);
|
|
3208
3304
|
}
|
|
3209
3305
|
recoverPublicKey(h) {
|
|
3210
|
-
const { r:
|
|
3211
|
-
if (!o.isValid(
|
|
3306
|
+
const { r: b, s: E } = this, R = this.assertRecovery(), T = R === 2 || R === 3 ? b + a : b;
|
|
3307
|
+
if (!o.isValid(T))
|
|
3212
3308
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
3213
|
-
const O = o.toBytes(
|
|
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));
|
|
3214
3310
|
if (k.is0())
|
|
3215
3311
|
throw new Error("invalid recovery: point at infinify");
|
|
3216
3312
|
return k.assertValidity(), k;
|
|
3217
3313
|
}
|
|
3218
3314
|
// Signatures should be low-s, to prevent malleability.
|
|
3219
3315
|
hasHighS() {
|
|
3220
|
-
return
|
|
3316
|
+
return y(this.s);
|
|
3221
3317
|
}
|
|
3222
|
-
toBytes(h =
|
|
3318
|
+
toBytes(h = m.format) {
|
|
3223
3319
|
if (nt(h), h === "der")
|
|
3224
|
-
return
|
|
3225
|
-
const { r:
|
|
3226
|
-
return h === "recovered" ? (
|
|
3320
|
+
return Ue(ge.hexFromSig(this));
|
|
3321
|
+
const { r: b, s: E } = this, R = i.toBytes(b), T = i.toBytes(E);
|
|
3322
|
+
return h === "recovered" ? (L(), _e(Uint8Array.of(this.assertRecovery()), R, T)) : _e(R, T);
|
|
3227
3323
|
}
|
|
3228
3324
|
toHex(h) {
|
|
3229
3325
|
return ke(this.toBytes(h));
|
|
3230
3326
|
}
|
|
3231
3327
|
}
|
|
3232
|
-
const
|
|
3328
|
+
const B = s.bits2int || function(h) {
|
|
3233
3329
|
if (h.length > 8192)
|
|
3234
3330
|
throw new Error("input is too large");
|
|
3235
|
-
const
|
|
3236
|
-
return
|
|
3331
|
+
const b = je(h), E = h.length * 8 - c;
|
|
3332
|
+
return E > 0 ? b >> BigInt(E) : b;
|
|
3237
3333
|
}, Q = s.bits2int_modN || function(h) {
|
|
3238
|
-
return i.create(
|
|
3334
|
+
return i.create(B(h));
|
|
3239
3335
|
}, ve = dt(c);
|
|
3240
3336
|
function he(u) {
|
|
3241
|
-
return
|
|
3337
|
+
return vr("num < 2^" + c, u, le, ve), i.toBytes(u);
|
|
3242
3338
|
}
|
|
3243
3339
|
function Z(u, h) {
|
|
3244
|
-
return
|
|
3340
|
+
return H(u, void 0, "message"), h ? H(e(u), void 0, "prehashed message") : u;
|
|
3245
3341
|
}
|
|
3246
|
-
function xe(u, h,
|
|
3247
|
-
const { lowS:
|
|
3342
|
+
function xe(u, h, b) {
|
|
3343
|
+
const { lowS: E, prehash: R, extraEntropy: T } = et(b, m);
|
|
3248
3344
|
u = Z(u, R);
|
|
3249
|
-
const O = Q(u),
|
|
3250
|
-
if (!i.isValidNot0(
|
|
3345
|
+
const O = Q(u), S = i.fromBytes(h);
|
|
3346
|
+
if (!i.isValidNot0(S))
|
|
3251
3347
|
throw new Error("invalid private key");
|
|
3252
|
-
const C = [he(
|
|
3253
|
-
if (
|
|
3254
|
-
const k =
|
|
3255
|
-
C.push(
|
|
3348
|
+
const C = [he(S), he(O)];
|
|
3349
|
+
if (T != null && T !== !1) {
|
|
3350
|
+
const k = T === !0 ? t(_.secretKey) : T;
|
|
3351
|
+
C.push(H(k, void 0, "extraEntropy"));
|
|
3256
3352
|
}
|
|
3257
3353
|
const N = _e(...C), W = O;
|
|
3258
3354
|
function U(k) {
|
|
3259
|
-
const j =
|
|
3355
|
+
const j = B(k);
|
|
3260
3356
|
if (!i.isValidNot0(j))
|
|
3261
3357
|
return;
|
|
3262
|
-
const V = i.inv(j), ee = r.BASE.multiply(j).toAffine(),
|
|
3263
|
-
if (
|
|
3358
|
+
const V = i.inv(j), ee = r.BASE.multiply(j).toAffine(), G = i.create(ee.x);
|
|
3359
|
+
if (G === le)
|
|
3264
3360
|
return;
|
|
3265
|
-
const K = i.create(V * i.create(W +
|
|
3361
|
+
const K = i.create(V * i.create(W + G * S));
|
|
3266
3362
|
if (K === le)
|
|
3267
3363
|
return;
|
|
3268
|
-
let xt = (ee.x ===
|
|
3269
|
-
return
|
|
3364
|
+
let xt = (ee.x === G ? 0 : 2) | Number(ee.y & Ee), mt = K;
|
|
3365
|
+
return E && y(K) && (mt = i.neg(K), xt ^= 1), new $(G, mt, A ? void 0 : xt);
|
|
3270
3366
|
}
|
|
3271
3367
|
return { seed: N, k2sig: U };
|
|
3272
3368
|
}
|
|
3273
|
-
function ne(u, h,
|
|
3274
|
-
const { seed:
|
|
3275
|
-
return
|
|
3369
|
+
function ne(u, h, b = {}) {
|
|
3370
|
+
const { seed: E, k2sig: R } = xe(u, h, b);
|
|
3371
|
+
return Er(e.outputLen, i.BYTES, n)(E, R).toBytes(b.format);
|
|
3276
3372
|
}
|
|
3277
|
-
function
|
|
3278
|
-
const { lowS: R, prehash:
|
|
3279
|
-
if (
|
|
3280
|
-
const
|
|
3281
|
-
throw new Error("verify expects Uint8Array signature" +
|
|
3373
|
+
function D(u, h, b, E = {}) {
|
|
3374
|
+
const { lowS: R, prehash: T, format: O } = et(E, m);
|
|
3375
|
+
if (b = H(b, void 0, "publicKey"), h = Z(h, T), !at(u)) {
|
|
3376
|
+
const S = u instanceof $ ? ", use sig.toBytes()" : "";
|
|
3377
|
+
throw new Error("verify expects Uint8Array signature" + S);
|
|
3282
3378
|
}
|
|
3283
|
-
|
|
3379
|
+
F(u, O);
|
|
3284
3380
|
try {
|
|
3285
|
-
const
|
|
3286
|
-
if (R &&
|
|
3381
|
+
const S = $.fromBytes(u, O), C = r.fromBytes(b);
|
|
3382
|
+
if (R && S.hasHighS())
|
|
3287
3383
|
return !1;
|
|
3288
|
-
const { r: N, s: W } =
|
|
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));
|
|
3289
3385
|
return ee.is0() ? !1 : i.create(ee.x) === N;
|
|
3290
3386
|
} catch {
|
|
3291
3387
|
return !1;
|
|
3292
3388
|
}
|
|
3293
3389
|
}
|
|
3294
|
-
function P(u, h,
|
|
3295
|
-
const { prehash:
|
|
3296
|
-
return h = Z(h,
|
|
3390
|
+
function P(u, h, b = {}) {
|
|
3391
|
+
const { prehash: E } = et(b, m);
|
|
3392
|
+
return h = Z(h, E), $.fromBytes(u, "recovered").recoverPublicKey(h).toBytes();
|
|
3297
3393
|
}
|
|
3298
3394
|
return Object.freeze({
|
|
3299
3395
|
keygen: l,
|
|
3300
3396
|
getPublicKey: d,
|
|
3301
|
-
getSharedSecret:
|
|
3302
|
-
utils:
|
|
3303
|
-
lengths:
|
|
3397
|
+
getSharedSecret: f,
|
|
3398
|
+
utils: w,
|
|
3399
|
+
lengths: _,
|
|
3304
3400
|
Point: r,
|
|
3305
3401
|
sign: ne,
|
|
3306
|
-
verify:
|
|
3402
|
+
verify: D,
|
|
3307
3403
|
recoverPublicKey: P,
|
|
3308
|
-
Signature:
|
|
3404
|
+
Signature: $,
|
|
3309
3405
|
hash: e
|
|
3310
3406
|
});
|
|
3311
3407
|
}
|
|
@@ -3318,44 +3414,44 @@ const ft = {
|
|
|
3318
3414
|
b: BigInt(7),
|
|
3319
3415
|
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
3320
3416
|
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
|
3321
|
-
},
|
|
3417
|
+
}, Vr = {
|
|
3322
3418
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
3323
3419
|
basises: [
|
|
3324
3420
|
[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
|
|
3325
3421
|
[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
|
|
3326
3422
|
]
|
|
3327
3423
|
}, Ut = /* @__PURE__ */ BigInt(2);
|
|
3328
|
-
function
|
|
3329
|
-
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,
|
|
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);
|
|
3330
3426
|
if (!ot.eql(ot.sqr(Q), r))
|
|
3331
3427
|
throw new Error("Cannot find square root");
|
|
3332
3428
|
return Q;
|
|
3333
3429
|
}
|
|
3334
|
-
const ot = Ve(ft.p, { sqrt:
|
|
3430
|
+
const ot = Ve(ft.p, { sqrt: Kr }), zr = /* @__PURE__ */ qr(ft, {
|
|
3335
3431
|
Fp: ot,
|
|
3336
|
-
endo:
|
|
3337
|
-
}),
|
|
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 = [];
|
|
3338
3434
|
for (let r = 0, e = Re, s = 1, t = 0; r < 24; r++) {
|
|
3339
|
-
[s, t] = [t, (2 * s + 3 * t) % 5],
|
|
3340
|
-
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;
|
|
3341
3437
|
for (let o = 0; o < 7; o++)
|
|
3342
|
-
e = (e << Re ^ (e >>
|
|
3343
|
-
|
|
3438
|
+
e = (e << Re ^ (e >> Jr) * en) % Qr, e & Xr && (n ^= Re << (Re << BigInt(o)) - Re);
|
|
3439
|
+
Ss.push(n);
|
|
3344
3440
|
}
|
|
3345
|
-
const
|
|
3346
|
-
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) {
|
|
3347
3443
|
const s = new Uint32Array(10);
|
|
3348
3444
|
for (let t = 24 - e; t < 24; t++) {
|
|
3349
3445
|
for (let i = 0; i < 10; i++)
|
|
3350
3446
|
s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
|
|
3351
3447
|
for (let i = 0; i < 10; i += 2) {
|
|
3352
|
-
const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1],
|
|
3353
|
-
for (let
|
|
3354
|
-
r[i +
|
|
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];
|
|
3449
|
+
for (let _ = 0; _ < 50; _ += 10)
|
|
3450
|
+
r[i + _] ^= f, r[i + _ + 1] ^= w;
|
|
3355
3451
|
}
|
|
3356
3452
|
let n = r[2], o = r[3];
|
|
3357
3453
|
for (let i = 0; i < 24; i++) {
|
|
3358
|
-
const a =
|
|
3454
|
+
const a = vs[i], c = Ht(n, o, a), l = Gt(n, o, a), d = bs[i];
|
|
3359
3455
|
n = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
|
|
3360
3456
|
}
|
|
3361
3457
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -3364,7 +3460,7 @@ function Qr(r, e = 24) {
|
|
|
3364
3460
|
for (let a = 0; a < 10; a++)
|
|
3365
3461
|
r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
|
|
3366
3462
|
}
|
|
3367
|
-
r[0] ^=
|
|
3463
|
+
r[0] ^= tn[t], r[1] ^= sn[t];
|
|
3368
3464
|
}
|
|
3369
3465
|
Te(s);
|
|
3370
3466
|
}
|
|
@@ -3384,16 +3480,16 @@ class pt {
|
|
|
3384
3480
|
v(this, "rounds");
|
|
3385
3481
|
if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ue(t, "outputLen"), !(0 < e && e < 200))
|
|
3386
3482
|
throw new Error("only keccak-f1600 function is supported");
|
|
3387
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
3483
|
+
this.state = new Uint8Array(200), this.state32 = tr(this.state);
|
|
3388
3484
|
}
|
|
3389
3485
|
clone() {
|
|
3390
3486
|
return this._cloneInto();
|
|
3391
3487
|
}
|
|
3392
3488
|
keccak() {
|
|
3393
|
-
|
|
3489
|
+
Ot(this.state32), rn(this.state32, this.rounds), Ot(this.state32), this.posOut = 0, this.pos = 0;
|
|
3394
3490
|
}
|
|
3395
3491
|
update(e) {
|
|
3396
|
-
Ie(this),
|
|
3492
|
+
Ie(this), H(e);
|
|
3397
3493
|
const { blockLen: s, state: t } = this, n = e.length;
|
|
3398
3494
|
for (let o = 0; o < n; ) {
|
|
3399
3495
|
const i = Math.min(s - this.pos, n - o);
|
|
@@ -3411,7 +3507,7 @@ class pt {
|
|
|
3411
3507
|
e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
|
|
3412
3508
|
}
|
|
3413
3509
|
writeInto(e) {
|
|
3414
|
-
Ie(this, !1),
|
|
3510
|
+
Ie(this, !1), H(e), this.finish();
|
|
3415
3511
|
const s = this.state, { blockLen: t } = this;
|
|
3416
3512
|
for (let n = 0, o = e.length; n < o; ) {
|
|
3417
3513
|
this.posOut >= t && this.keccak();
|
|
@@ -3429,7 +3525,7 @@ class pt {
|
|
|
3429
3525
|
return ue(e), this.xofInto(new Uint8Array(e));
|
|
3430
3526
|
}
|
|
3431
3527
|
digestInto(e) {
|
|
3432
|
-
if (
|
|
3528
|
+
if (Zt(e, this), this.finished)
|
|
3433
3529
|
throw new Error("digest() was already called");
|
|
3434
3530
|
return this.writeInto(e), this.destroy(), e;
|
|
3435
3531
|
}
|
|
@@ -3444,29 +3540,29 @@ class pt {
|
|
|
3444
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;
|
|
3445
3541
|
}
|
|
3446
3542
|
}
|
|
3447
|
-
const
|
|
3448
|
-
class
|
|
3543
|
+
const nn = (r, e, s, t = {}) => Jt(() => new pt(e, r, s), t), qt = /* @__PURE__ */ nn(1, 136, 32);
|
|
3544
|
+
class on {
|
|
3449
3545
|
async verifyJWT(e, s) {
|
|
3450
3546
|
try {
|
|
3451
3547
|
const t = this.decodeJWT(e);
|
|
3452
|
-
|
|
3548
|
+
p.log("[CROSSx] JWT 디코딩 성공:", {
|
|
3453
3549
|
sub: t.sub,
|
|
3454
3550
|
exp: t.exp,
|
|
3455
3551
|
iat: t.iat,
|
|
3456
3552
|
"현재 시간": Math.floor(Date.now() / 1e3)
|
|
3457
3553
|
});
|
|
3458
3554
|
const n = Math.floor(Date.now() / 1e3);
|
|
3459
|
-
return t.exp && t.exp < n ? (
|
|
3555
|
+
return t.exp && t.exp < n ? (p.warn("[CROSSx] 토큰 만료:", {
|
|
3460
3556
|
exp: t.exp,
|
|
3461
3557
|
now: n,
|
|
3462
3558
|
만료시간: new Date(t.exp * 1e3).toISOString()
|
|
3463
|
-
}), { payload: t, valid: !1, signatureVerified: !1 }) : t.sub ? (
|
|
3559
|
+
}), { payload: t, valid: !1, signatureVerified: !1 }) : t.sub ? (p.log("[CROSSx] JWT 검증 성공 (서명 미검증 — JWKS 미구현)"), { payload: t, valid: !0, signatureVerified: !1 }) : (p.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 });
|
|
3464
3560
|
} catch (t) {
|
|
3465
|
-
throw
|
|
3561
|
+
throw p.error("[CROSSx] JWT 검증 중 에러:", t), t;
|
|
3466
3562
|
}
|
|
3467
3563
|
}
|
|
3468
3564
|
decodeJWT(e) {
|
|
3469
|
-
return
|
|
3565
|
+
return Os(e);
|
|
3470
3566
|
}
|
|
3471
3567
|
/**
|
|
3472
3568
|
* EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
|
|
@@ -3481,33 +3577,33 @@ class tn {
|
|
|
3481
3577
|
${t.length}`
|
|
3482
3578
|
), o = new Uint8Array(n.length + t.length);
|
|
3483
3579
|
o.set(n, 0), o.set(t, n.length);
|
|
3484
|
-
const i =
|
|
3580
|
+
const i = qt(o), a = s.startsWith("0x") ? s.slice(2) : s;
|
|
3485
3581
|
if (a.length !== 130)
|
|
3486
|
-
throw new Error(
|
|
3487
|
-
const c =
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
).addRecoveryBit(
|
|
3491
|
-
return "0x" + ke(
|
|
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);
|
|
3587
|
+
return "0x" + ke(y.slice(12));
|
|
3492
3588
|
}
|
|
3493
3589
|
}
|
|
3494
|
-
function
|
|
3590
|
+
function an(r) {
|
|
3495
3591
|
const e = new Uint8Array(r.length / 2);
|
|
3496
3592
|
for (let s = 0; s < e.length; s++)
|
|
3497
3593
|
e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
|
|
3498
3594
|
return e;
|
|
3499
3595
|
}
|
|
3500
|
-
function
|
|
3596
|
+
function Wt(r) {
|
|
3501
3597
|
let e = "0x";
|
|
3502
3598
|
for (const s of r) e += s.toString(16).padStart(2, "0");
|
|
3503
3599
|
return BigInt(e);
|
|
3504
3600
|
}
|
|
3505
|
-
const
|
|
3506
|
-
class
|
|
3601
|
+
const cn = 3e4;
|
|
3602
|
+
class ln {
|
|
3507
3603
|
async request(e) {
|
|
3508
3604
|
const s = new AbortController(), t = setTimeout(
|
|
3509
3605
|
() => s.abort(),
|
|
3510
|
-
e.timeoutMs ??
|
|
3606
|
+
e.timeoutMs ?? cn
|
|
3511
3607
|
);
|
|
3512
3608
|
try {
|
|
3513
3609
|
const n = await fetch(e.url, {
|
|
@@ -3541,58 +3637,58 @@ class gt {
|
|
|
3541
3637
|
}
|
|
3542
3638
|
openAuth(e) {
|
|
3543
3639
|
return new Promise((s, t) => {
|
|
3544
|
-
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(
|
|
3545
3641
|
d,
|
|
3546
3642
|
"CROSSx OAuth",
|
|
3547
3643
|
`width=${n},height=${o},left=${i},top=${a}`
|
|
3548
3644
|
);
|
|
3549
|
-
if (!
|
|
3645
|
+
if (!f) {
|
|
3550
3646
|
t(new Error("팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."));
|
|
3551
3647
|
return;
|
|
3552
3648
|
}
|
|
3553
|
-
const
|
|
3554
|
-
|
|
3555
|
-
}, 5 * 60 * 1e3),
|
|
3556
|
-
let
|
|
3557
|
-
const
|
|
3558
|
-
clearInterval(
|
|
3559
|
-
|
|
3649
|
+
const w = setTimeout(() => {
|
|
3650
|
+
p.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), F(), t(new Error("Authentication timeout"));
|
|
3651
|
+
}, 5 * 60 * 1e3), _ = 10, m = 30;
|
|
3652
|
+
let A = 0, y = null;
|
|
3653
|
+
const I = () => {
|
|
3654
|
+
clearInterval(L), p.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + m + "초간 대기합니다"), y = setTimeout(() => {
|
|
3655
|
+
F(), t(new Error(
|
|
3560
3656
|
"OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
|
|
3561
3657
|
));
|
|
3562
|
-
},
|
|
3563
|
-
},
|
|
3564
|
-
|
|
3658
|
+
}, m * 1e3);
|
|
3659
|
+
}, L = setInterval(() => {
|
|
3660
|
+
A++;
|
|
3565
3661
|
try {
|
|
3566
|
-
|
|
3662
|
+
f.closed && (A <= _ ? I() : (F(), t(new Error("로그인이 취소되었습니다"))));
|
|
3567
3663
|
} catch {
|
|
3568
|
-
|
|
3664
|
+
I();
|
|
3569
3665
|
}
|
|
3570
|
-
}, 1e3),
|
|
3571
|
-
clearTimeout(
|
|
3572
|
-
},
|
|
3573
|
-
var ve, he, Z, xe, ne,
|
|
3574
|
-
if (
|
|
3575
|
-
|
|
3576
|
-
const Q =
|
|
3666
|
+
}, 1e3), F = () => {
|
|
3667
|
+
clearTimeout(w), clearInterval(L), y && clearTimeout(y), window.removeEventListener("message", $);
|
|
3668
|
+
}, $ = (B) => {
|
|
3669
|
+
var ve, he, Z, xe, ne, D, P;
|
|
3670
|
+
if (B.origin !== e.expectedOrigin) return;
|
|
3671
|
+
F(), p.log("[CROSSx] OAuth postMessage 수신 — status:", B.data.status);
|
|
3672
|
+
const Q = B.data.state ?? ((ve = B.data.data) == null ? void 0 : ve.state);
|
|
3577
3673
|
if (!Q || Q !== c) {
|
|
3578
3674
|
t(new Error("OAuth state mismatch — possible CSRF attack"));
|
|
3579
3675
|
return;
|
|
3580
3676
|
}
|
|
3581
|
-
if (
|
|
3582
|
-
const u = ((he =
|
|
3583
|
-
|
|
3584
|
-
hasAccessToken: !!((xe =
|
|
3585
|
-
hasIdToken: !!((ne =
|
|
3586
|
-
}), u ? s(u) : (
|
|
3677
|
+
if (B.data.status === "success") {
|
|
3678
|
+
const u = ((he = B.data.data) == null ? void 0 : he.accessToken) || ((Z = B.data.data) == null ? void 0 : Z.idToken);
|
|
3679
|
+
p.log("[CROSSx] OAuth 토큰 수신:", {
|
|
3680
|
+
hasAccessToken: !!((xe = B.data.data) != null && xe.accessToken),
|
|
3681
|
+
hasIdToken: !!((ne = B.data.data) != null && ne.idToken)
|
|
3682
|
+
}), u ? s(u) : (p.error("[CROSSx] 토큰을 찾을 수 없음:", B.data), t(new Error("Token not found in response")));
|
|
3587
3683
|
} else
|
|
3588
|
-
|
|
3684
|
+
p.error("[CROSSx] OAuth 실패:", (D = B.data.data) == null ? void 0 : D.error), t(new Error(((P = B.data.data) == null ? void 0 : P.error) || "Authentication failed"));
|
|
3589
3685
|
};
|
|
3590
|
-
window.addEventListener("message",
|
|
3686
|
+
window.addEventListener("message", $);
|
|
3591
3687
|
});
|
|
3592
3688
|
}
|
|
3593
3689
|
}
|
|
3594
3690
|
const Oe = "crossx_wallet_data";
|
|
3595
|
-
class
|
|
3691
|
+
class dn {
|
|
3596
3692
|
constructor(e) {
|
|
3597
3693
|
this.storage = e;
|
|
3598
3694
|
}
|
|
@@ -3608,7 +3704,7 @@ class on {
|
|
|
3608
3704
|
};
|
|
3609
3705
|
return await this.storage.set(Oe, t), t;
|
|
3610
3706
|
} catch (s) {
|
|
3611
|
-
throw new
|
|
3707
|
+
throw new x(g.WALLET_CREATION_FAILED, "지갑 생성에 실패했습니다", s);
|
|
3612
3708
|
}
|
|
3613
3709
|
}
|
|
3614
3710
|
async getAddresses(e) {
|
|
@@ -3623,24 +3719,24 @@ class on {
|
|
|
3623
3719
|
}
|
|
3624
3720
|
async prepare(e, s) {
|
|
3625
3721
|
const t = "mock-" + crypto.randomUUID();
|
|
3626
|
-
return
|
|
3722
|
+
return p.log(`[Mock] prepare action=${e} → uuid=${t}`), { uuid: t, expiresAt: new Date(Date.now() + 5 * 6e4).toISOString() };
|
|
3627
3723
|
}
|
|
3628
3724
|
async signMessage(e, s, t, n = 0, o, i) {
|
|
3629
|
-
return
|
|
3725
|
+
return p.log(`[Mock] signMessage chainId=${s} index=${n} uuid=${o} from=${i}: "${t}"`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
|
|
3630
3726
|
}
|
|
3631
3727
|
async signTypedData(e, s, t, n = 0, o, i) {
|
|
3632
|
-
return
|
|
3728
|
+
return p.log(`[Mock] signTypedData chainId=${s} index=${n} uuid=${o} from=${i}`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
|
|
3633
3729
|
}
|
|
3634
3730
|
async signTransaction(e, s, t, n = 0, o) {
|
|
3635
|
-
|
|
3731
|
+
p.log(`[Mock] signTransaction chainId=${s} index=${n} uuid=${o}:`, t);
|
|
3636
3732
|
const i = "0x" + Array(64).fill(0).map(() => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
3637
3733
|
return { chainId: s, signature: this.generateMockSignature(), txHash: i, format: "hex" };
|
|
3638
3734
|
}
|
|
3639
3735
|
async sendTransaction(e, s, t, n) {
|
|
3640
|
-
return
|
|
3736
|
+
return p.log(`[Mock] sendTransaction chainId=${s} uuid=${n}:`, t), { txHash: "0x" + Array(64).fill(0).map(() => Math.floor(Math.random() * 16).toString(16)).join("") };
|
|
3641
3737
|
}
|
|
3642
3738
|
async recoverWallet(e, s) {
|
|
3643
|
-
|
|
3739
|
+
p.log("[Mock] recoverWallet");
|
|
3644
3740
|
const t = {
|
|
3645
3741
|
id: e,
|
|
3646
3742
|
address: this.generateMockEvmAddress(),
|
|
@@ -3650,7 +3746,7 @@ class on {
|
|
|
3650
3746
|
return await this.storage.set(Oe, t), t;
|
|
3651
3747
|
}
|
|
3652
3748
|
async migrateWallet(e, s) {
|
|
3653
|
-
|
|
3749
|
+
p.log(`[Mock] migrateWallet pin=${e} sub=${s}`);
|
|
3654
3750
|
const t = {
|
|
3655
3751
|
id: s,
|
|
3656
3752
|
address: this.generateMockEvmAddress(),
|
|
@@ -3680,9 +3776,9 @@ class qe {
|
|
|
3680
3776
|
getAuthToken() {
|
|
3681
3777
|
const e = this.tokenStore.get();
|
|
3682
3778
|
if (!e)
|
|
3683
|
-
throw new
|
|
3779
|
+
throw new x(
|
|
3684
3780
|
g.AUTH_NOT_AUTHENTICATED,
|
|
3685
|
-
"
|
|
3781
|
+
"인증 토큰을 찾을 수 없습니다. 먼저 로그인해 주세요."
|
|
3686
3782
|
);
|
|
3687
3783
|
return e;
|
|
3688
3784
|
}
|
|
@@ -3702,33 +3798,33 @@ class qe {
|
|
|
3702
3798
|
})).data;
|
|
3703
3799
|
if (d && typeof d.code == "number") {
|
|
3704
3800
|
if (d.code < 0 || d.code >= 400) {
|
|
3705
|
-
const
|
|
3706
|
-
|
|
3801
|
+
const f = d.message || d.data || "API 요청에 실패했습니다";
|
|
3802
|
+
p.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
|
|
3707
3803
|
code: d.code,
|
|
3708
|
-
message:
|
|
3804
|
+
message: f,
|
|
3709
3805
|
url: o,
|
|
3710
3806
|
method: e,
|
|
3711
3807
|
fullResponse: d
|
|
3712
3808
|
});
|
|
3713
|
-
const
|
|
3714
|
-
throw
|
|
3809
|
+
const w = qe.mapGatewayError(d.code), _ = qe.getGatewayErrorMessage(d.code, f), m = new x(w, _);
|
|
3810
|
+
throw m.gatewayCode = d.code, m.gatewayMessage = f, m;
|
|
3715
3811
|
}
|
|
3716
|
-
return
|
|
3812
|
+
return p.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
|
|
3717
3813
|
}
|
|
3718
3814
|
return d;
|
|
3719
3815
|
} catch (l) {
|
|
3720
|
-
if (l instanceof
|
|
3816
|
+
if (l instanceof x) throw l;
|
|
3721
3817
|
if ((a = l.response) != null && a.data) {
|
|
3722
|
-
const d = l.response.data,
|
|
3723
|
-
throw
|
|
3724
|
-
code:
|
|
3725
|
-
message:
|
|
3818
|
+
const d = l.response.data, f = d.message || d.data || "API 요청에 실패했습니다", w = d.code || "UNKNOWN";
|
|
3819
|
+
throw p.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
|
|
3820
|
+
code: w,
|
|
3821
|
+
message: f,
|
|
3726
3822
|
url: o,
|
|
3727
3823
|
method: e,
|
|
3728
3824
|
status: (c = l.response) == null ? void 0 : c.status
|
|
3729
|
-
}), new
|
|
3825
|
+
}), new x(
|
|
3730
3826
|
g.UNKNOWN_ERROR,
|
|
3731
|
-
`Wallet Gateway
|
|
3827
|
+
`Wallet Gateway 오류 (${w}): ${f}`
|
|
3732
3828
|
);
|
|
3733
3829
|
}
|
|
3734
3830
|
throw l;
|
|
@@ -3736,12 +3832,12 @@ class qe {
|
|
|
3736
3832
|
}
|
|
3737
3833
|
async getOrCreateWallet(e) {
|
|
3738
3834
|
var s;
|
|
3739
|
-
|
|
3835
|
+
p.log("[CROSSx][Migration Phase 2] GET /mnemonic/addresses — 기존 지갑 조회");
|
|
3740
3836
|
try {
|
|
3741
3837
|
const t = await this.request("GET", "/mnemonic/addresses");
|
|
3742
3838
|
if (t.addresses && t.addresses.length > 0) {
|
|
3743
3839
|
const { address: n } = t.addresses[0];
|
|
3744
|
-
return
|
|
3840
|
+
return p.log("[CROSSx][Migration Phase 2] 기존 지갑 발견 — address:", n), {
|
|
3745
3841
|
id: e,
|
|
3746
3842
|
address: n,
|
|
3747
3843
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
@@ -3749,12 +3845,12 @@ class qe {
|
|
|
3749
3845
|
};
|
|
3750
3846
|
}
|
|
3751
3847
|
} catch {
|
|
3752
|
-
|
|
3848
|
+
p.log("[CROSSx][Migration Phase 2] 기존 지갑 없음, POST /mnemonic/create 진행");
|
|
3753
3849
|
}
|
|
3754
|
-
|
|
3850
|
+
p.log("[CROSSx][Migration Phase 2] POST /mnemonic/create — ignoreBackup: false");
|
|
3755
3851
|
try {
|
|
3756
3852
|
const t = { ignoreBackup: !1 }, n = await this.request("POST", "/mnemonic/create", t);
|
|
3757
|
-
return
|
|
3853
|
+
return p.log("[CROSSx][Migration Phase 2] /mnemonic/create 성공 — address:", n.address), {
|
|
3758
3854
|
id: e,
|
|
3759
3855
|
address: n.address,
|
|
3760
3856
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
@@ -3762,7 +3858,7 @@ class qe {
|
|
|
3762
3858
|
};
|
|
3763
3859
|
} catch (t) {
|
|
3764
3860
|
if ((t == null ? void 0 : t.gatewayCode) === -10004 || (s = t == null ? void 0 : t.message) != null && s.includes("-10004")) {
|
|
3765
|
-
|
|
3861
|
+
p.log("[CROSSx][Migration Phase 2] 지갑 이미 존재 (-10004), 주소 재조회");
|
|
3766
3862
|
const n = await this.request("GET", "/mnemonic/addresses");
|
|
3767
3863
|
if (n.addresses && n.addresses.length > 0)
|
|
3768
3864
|
return {
|
|
@@ -3772,7 +3868,7 @@ class qe {
|
|
|
3772
3868
|
createdAt: Date.now()
|
|
3773
3869
|
};
|
|
3774
3870
|
}
|
|
3775
|
-
throw (t == null ? void 0 : t.gatewayCode) === -10012 &&
|
|
3871
|
+
throw (t == null ? void 0 : t.gatewayCode) === -10012 && p.log("[CROSSx][Migration Phase 2] Gateway -10012 수신 → MIGRATION_BACKUP_EXISTS throw"), t;
|
|
3776
3872
|
}
|
|
3777
3873
|
}
|
|
3778
3874
|
async getAddresses(e) {
|
|
@@ -3785,8 +3881,8 @@ class qe {
|
|
|
3785
3881
|
`/mnemonic/address?index=${s}`
|
|
3786
3882
|
)).address, derivationPath: `m/44'/60'/0'/0/${s}` };
|
|
3787
3883
|
} catch (t) {
|
|
3788
|
-
if (t instanceof
|
|
3789
|
-
return
|
|
3884
|
+
if (t instanceof x && this.isAddressNotFoundError(t))
|
|
3885
|
+
return p.log(`[CROSSx] index ${s} 주소 없음, 파생 중...`), { address: (await this.request(
|
|
3790
3886
|
"GET",
|
|
3791
3887
|
`/mnemonic/address?index=${s}&derive=true`
|
|
3792
3888
|
)).address, derivationPath: `m/44'/60'/0'/0/${s}` };
|
|
@@ -3802,15 +3898,15 @@ class qe {
|
|
|
3802
3898
|
switch (e) {
|
|
3803
3899
|
case "sign":
|
|
3804
3900
|
case "send":
|
|
3805
|
-
if (!s.tx) throw new
|
|
3901
|
+
if (!s.tx) throw new x(g.TX_INVALID_PARAMS, "prepare: tx가 필요합니다");
|
|
3806
3902
|
t = { unsignedTx: this.buildUnsignedTx(s.tx) };
|
|
3807
3903
|
break;
|
|
3808
3904
|
case "sign-message":
|
|
3809
|
-
if (!s.message) throw new
|
|
3905
|
+
if (!s.message) throw new x(g.TX_INVALID_PARAMS, "prepare: message가 필요합니다");
|
|
3810
3906
|
t = { message: s.message }, s.from && (t.from = s.from);
|
|
3811
3907
|
break;
|
|
3812
3908
|
case "sign-typed-data":
|
|
3813
|
-
if (!s.typedData) throw new
|
|
3909
|
+
if (!s.typedData) throw new x(g.TX_INVALID_PARAMS, "prepare: typedData가 필요합니다");
|
|
3814
3910
|
t = { typedData: s.typedData }, s.from && (t.from = s.from);
|
|
3815
3911
|
break;
|
|
3816
3912
|
}
|
|
@@ -3882,13 +3978,13 @@ class qe {
|
|
|
3882
3978
|
};
|
|
3883
3979
|
}
|
|
3884
3980
|
async migrateWallet(e, s) {
|
|
3885
|
-
|
|
3981
|
+
p.log("[CROSSx][Migration Phase 4] POST /mnemonic/migrate 호출 — sub:", s);
|
|
3886
3982
|
const t = { pin: e, sub: s }, n = await this.request(
|
|
3887
3983
|
"POST",
|
|
3888
3984
|
"/mnemonic/migrate",
|
|
3889
3985
|
t
|
|
3890
3986
|
);
|
|
3891
|
-
return
|
|
3987
|
+
return p.log("[CROSSx][Migration Phase 4] /mnemonic/migrate 완료 — address:", n.address), {
|
|
3892
3988
|
id: s,
|
|
3893
3989
|
address: n.address,
|
|
3894
3990
|
derivationPath: "m/44'/60'/0'/0/0",
|
|
@@ -3984,7 +4080,7 @@ class Ce {
|
|
|
3984
4080
|
}
|
|
3985
4081
|
isCacheValid() {
|
|
3986
4082
|
if (this.loadedAt === 0) return !1;
|
|
3987
|
-
const e = this.usingFallback ?
|
|
4083
|
+
const e = this.usingFallback ? Zs : Ys;
|
|
3988
4084
|
return e === 0 ? !0 : Date.now() - this.loadedAt < e;
|
|
3989
4085
|
}
|
|
3990
4086
|
populateCache(e, s) {
|
|
@@ -4004,8 +4100,8 @@ class Ce {
|
|
|
4004
4100
|
}
|
|
4005
4101
|
handleEnvelopeError(e) {
|
|
4006
4102
|
if (e.code < 0) {
|
|
4007
|
-
const s = typeof e.data == "string" ? e.data : e.message ?? "
|
|
4008
|
-
throw new
|
|
4103
|
+
const s = typeof e.data == "string" ? e.data : e.message ?? "체인 레지스트리 요청에 실패했습니다";
|
|
4104
|
+
throw new x(
|
|
4009
4105
|
Ce.mapErrorCode(e.code),
|
|
4010
4106
|
s
|
|
4011
4107
|
);
|
|
@@ -4016,9 +4112,9 @@ class Ce {
|
|
|
4016
4112
|
(t) => t.chainId === e
|
|
4017
4113
|
);
|
|
4018
4114
|
if (s) return s;
|
|
4019
|
-
throw new
|
|
4115
|
+
throw new x(
|
|
4020
4116
|
g.CHAIN_NOT_SUPPORTED,
|
|
4021
|
-
|
|
4117
|
+
`지원하지 않는 체인: ${e}`
|
|
4022
4118
|
);
|
|
4023
4119
|
}
|
|
4024
4120
|
static fallbackChains() {
|
|
@@ -4046,7 +4142,7 @@ class Ce {
|
|
|
4046
4142
|
}
|
|
4047
4143
|
}
|
|
4048
4144
|
}
|
|
4049
|
-
const
|
|
4145
|
+
const jt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", un = {
|
|
4050
4146
|
light: {
|
|
4051
4147
|
bg: "#FFFFFF",
|
|
4052
4148
|
border: "rgba(18,18,18,0.05)",
|
|
@@ -4092,8 +4188,8 @@ const Wt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", an = {
|
|
|
4092
4188
|
onPrimary: "#FFFFFF"
|
|
4093
4189
|
}
|
|
4094
4190
|
};
|
|
4095
|
-
function
|
|
4096
|
-
const s =
|
|
4191
|
+
function Vt(r, e) {
|
|
4192
|
+
const s = un[r], t = e == null ? void 0 : e[r];
|
|
4097
4193
|
return t ? {
|
|
4098
4194
|
...s,
|
|
4099
4195
|
// ── Brand
|
|
@@ -4122,7 +4218,7 @@ function jt(r, e) {
|
|
|
4122
4218
|
...t.bg !== void 0 && { bg: t.bg, inputBg: t.bg }
|
|
4123
4219
|
} : s;
|
|
4124
4220
|
}
|
|
4125
|
-
const
|
|
4221
|
+
const hn = `
|
|
4126
4222
|
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
|
|
4127
4223
|
|
|
4128
4224
|
#${te} {
|
|
@@ -4851,6 +4947,18 @@ const cn = `
|
|
|
4851
4947
|
color: var(--cx-value);
|
|
4852
4948
|
white-space: nowrap;
|
|
4853
4949
|
}
|
|
4950
|
+
.__crossx-wallet-selected {
|
|
4951
|
+
font-size: 11px;
|
|
4952
|
+
font-weight: 600;
|
|
4953
|
+
line-height: 1;
|
|
4954
|
+
color: var(--cx-primary);
|
|
4955
|
+
border: 1.5px solid var(--cx-primary);
|
|
4956
|
+
border-radius: 6px;
|
|
4957
|
+
padding: 4px 8px;
|
|
4958
|
+
margin-left: auto;
|
|
4959
|
+
flex-shrink: 0;
|
|
4960
|
+
white-space: nowrap;
|
|
4961
|
+
}
|
|
4854
4962
|
.__crossx-wallet-add {
|
|
4855
4963
|
display: flex;
|
|
4856
4964
|
align-items: center;
|
|
@@ -5027,13 +5135,13 @@ const cn = `
|
|
|
5027
5135
|
}
|
|
5028
5136
|
`;
|
|
5029
5137
|
function me() {
|
|
5030
|
-
let r = document.getElementById(
|
|
5031
|
-
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;
|
|
5032
5140
|
}
|
|
5033
5141
|
function Y(r) {
|
|
5034
5142
|
return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
|
|
5035
5143
|
}
|
|
5036
|
-
function
|
|
5144
|
+
function fn(r, e = "CROSS", s = 18) {
|
|
5037
5145
|
if (!r || r === "0x" || r === "0x0") return null;
|
|
5038
5146
|
try {
|
|
5039
5147
|
const t = BigInt(r);
|
|
@@ -5044,7 +5152,7 @@ function ln(r, e = "CROSS", s = 18) {
|
|
|
5044
5152
|
return null;
|
|
5045
5153
|
}
|
|
5046
5154
|
}
|
|
5047
|
-
const
|
|
5155
|
+
const Kt = {
|
|
5048
5156
|
1: "Ethereum Mainnet",
|
|
5049
5157
|
5: "Goerli Testnet",
|
|
5050
5158
|
11155111: "Ethereum Sepolia",
|
|
@@ -5067,9 +5175,9 @@ const Vt = {
|
|
|
5067
5175
|
612044: "CROSS Testnet",
|
|
5068
5176
|
612055: "CROSS Mainnet"
|
|
5069
5177
|
};
|
|
5070
|
-
function
|
|
5178
|
+
function Is(r) {
|
|
5071
5179
|
const e = parseInt(r.split(":")[1] ?? "", 10);
|
|
5072
|
-
return !isNaN(e) &&
|
|
5180
|
+
return !isNaN(e) && Kt[e] ? Kt[e] : r;
|
|
5073
5181
|
}
|
|
5074
5182
|
function it(r, e) {
|
|
5075
5183
|
if (r === 0n) return "0";
|
|
@@ -5084,18 +5192,18 @@ function tt(r) {
|
|
|
5084
5192
|
return r;
|
|
5085
5193
|
}
|
|
5086
5194
|
}
|
|
5087
|
-
function
|
|
5195
|
+
function pn(r) {
|
|
5088
5196
|
try {
|
|
5089
5197
|
return BigInt(r).toLocaleString();
|
|
5090
5198
|
} catch {
|
|
5091
5199
|
return r;
|
|
5092
5200
|
}
|
|
5093
5201
|
}
|
|
5094
|
-
function
|
|
5202
|
+
function gn(r) {
|
|
5095
5203
|
const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
|
|
5096
5204
|
if (!e) return null;
|
|
5097
5205
|
try {
|
|
5098
|
-
const a = BigInt(e), c =
|
|
5206
|
+
const a = BigInt(e), c = pn(e);
|
|
5099
5207
|
if (t) {
|
|
5100
5208
|
const l = a * BigInt(t);
|
|
5101
5209
|
return {
|
|
@@ -5120,11 +5228,11 @@ function un(r) {
|
|
|
5120
5228
|
return null;
|
|
5121
5229
|
}
|
|
5122
5230
|
}
|
|
5123
|
-
function
|
|
5124
|
-
const e =
|
|
5125
|
-
if (!e) return
|
|
5126
|
-
let s =
|
|
5127
|
-
return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s +=
|
|
5231
|
+
function Ts(r) {
|
|
5232
|
+
const e = gn(r);
|
|
5233
|
+
if (!e) return q("Estimated fee", "<span>—</span>");
|
|
5234
|
+
let s = q("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
|
|
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;
|
|
5128
5236
|
}
|
|
5129
5237
|
const de = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
5130
5238
|
<rect x="9" y="9" width="13" height="13" rx="2"/>
|
|
@@ -5133,7 +5241,7 @@ const de = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="
|
|
|
5133
5241
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
5134
5242
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
5135
5243
|
</svg>`;
|
|
5136
|
-
function
|
|
5244
|
+
function _n(r) {
|
|
5137
5245
|
return `<svg width="28" height="28" viewBox="0 0 28 28" fill="none">
|
|
5138
5246
|
<circle cx="14" cy="14" r="14" fill="${r}"/>
|
|
5139
5247
|
<path d="M14 7.5L19.2 10.5V16.5L14 19.5L8.8 16.5V10.5L14 7.5Z" fill="white" opacity="0.9"/>
|
|
@@ -5143,9 +5251,9 @@ const _t = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
|
5143
5251
|
<rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
|
|
5144
5252
|
<path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
|
|
5145
5253
|
<rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
|
|
5146
|
-
</svg>`,
|
|
5254
|
+
</svg>`, xn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
5147
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)"/>
|
|
5148
|
-
</svg>`,
|
|
5256
|
+
</svg>`, mn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
5149
5257
|
<circle cx="12" cy="12" r="12" fill="var(--cx-secondary)"/>
|
|
5150
5258
|
<circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
|
|
5151
5259
|
<path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
|
|
@@ -5174,16 +5282,16 @@ function ae(r) {
|
|
|
5174
5282
|
`--cx-on-primary:${r.onPrimary}`
|
|
5175
5283
|
].join(";");
|
|
5176
5284
|
}
|
|
5177
|
-
function
|
|
5285
|
+
function q(r, e) {
|
|
5178
5286
|
return `
|
|
5179
5287
|
<div class="__crossx-row">
|
|
5180
5288
|
<span class="__crossx-row-label">${r}</span>
|
|
5181
5289
|
<div class="__crossx-row-value">${e}</div>
|
|
5182
5290
|
</div>`;
|
|
5183
5291
|
}
|
|
5184
|
-
function
|
|
5292
|
+
function wn(r, e) {
|
|
5185
5293
|
const s = e, t = Ke(), n = r.to ? `<span class="__crossx-addr-text">${Y(r.to)}</span>
|
|
5186
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
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");
|
|
5187
5295
|
return a.id = te, a.innerHTML = `
|
|
5188
5296
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
5189
5297
|
<div class="__crossx-header">
|
|
@@ -5195,7 +5303,7 @@ function gn(r, e) {
|
|
|
5195
5303
|
<div class="__crossx-body-cols">
|
|
5196
5304
|
<div class="__crossx-col-left">
|
|
5197
5305
|
<p class="__crossx-sig-subtitle">
|
|
5198
|
-
<span class="__crossx-sig-origin">${
|
|
5306
|
+
<span class="__crossx-sig-origin">${M(t)} </span>is requesting a Signature
|
|
5199
5307
|
</p>
|
|
5200
5308
|
<div class="__crossx-addr-pill">
|
|
5201
5309
|
${_t}
|
|
@@ -5204,12 +5312,12 @@ function gn(r, e) {
|
|
|
5204
5312
|
<p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
|
|
5205
5313
|
<hr class="__crossx-divider">
|
|
5206
5314
|
<div class="__crossx-rows">
|
|
5207
|
-
${
|
|
5208
|
-
${
|
|
5315
|
+
${q("To", n)}
|
|
5316
|
+
${q("Network", `<span>${Is(r.chainId)}</span>`)}
|
|
5209
5317
|
${o}
|
|
5210
5318
|
</div>
|
|
5211
5319
|
</div>
|
|
5212
|
-
<pre class="__crossx-raw-tx">${
|
|
5320
|
+
<pre class="__crossx-raw-tx">${M(i)}</pre>
|
|
5213
5321
|
</div>
|
|
5214
5322
|
<div class="__crossx-btn-row">
|
|
5215
5323
|
<button class="__crossx-cancel-btn" id="__crossx-cancel-btn">Cancel</button>
|
|
@@ -5219,9 +5327,9 @@ function gn(r, e) {
|
|
|
5219
5327
|
</div>
|
|
5220
5328
|
`, a;
|
|
5221
5329
|
}
|
|
5222
|
-
function
|
|
5330
|
+
function yn(r, e) {
|
|
5223
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>
|
|
5224
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
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");
|
|
5225
5333
|
return d.id = te, d.innerHTML = `
|
|
5226
5334
|
<div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
5227
5335
|
<div class="__crossx-header">
|
|
@@ -5231,12 +5339,12 @@ function _n(r, e) {
|
|
|
5231
5339
|
<hr class="__crossx-divider">
|
|
5232
5340
|
<div class="__crossx-body">
|
|
5233
5341
|
<p class="__crossx-tx-subtitle">
|
|
5234
|
-
<span class="__crossx-sig-origin">${
|
|
5342
|
+
<span class="__crossx-sig-origin">${M(o)}</span> wants your permission to approve the following transaction.
|
|
5235
5343
|
</p>
|
|
5236
5344
|
<div class="__crossx-body-cols">
|
|
5237
5345
|
<div class="__crossx-rows">
|
|
5238
|
-
${
|
|
5239
|
-
${
|
|
5346
|
+
${q("To", i)}
|
|
5347
|
+
${q("Network", `<span>${Is(r.chainId)}</span>`)}
|
|
5240
5348
|
${a}
|
|
5241
5349
|
</div>
|
|
5242
5350
|
<div class="__crossx-pill">
|
|
@@ -5257,31 +5365,31 @@ function Ke() {
|
|
|
5257
5365
|
return "This site";
|
|
5258
5366
|
}
|
|
5259
5367
|
}
|
|
5260
|
-
function
|
|
5368
|
+
function M(r) {
|
|
5261
5369
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5262
5370
|
}
|
|
5263
|
-
function
|
|
5371
|
+
function bn(r) {
|
|
5264
5372
|
return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
|
|
5265
5373
|
}
|
|
5266
|
-
function
|
|
5267
|
-
if (typeof r == "string") return
|
|
5374
|
+
function vn(r) {
|
|
5375
|
+
if (typeof r == "string") return M(r);
|
|
5268
5376
|
if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
|
|
5269
5377
|
try {
|
|
5270
|
-
return
|
|
5378
|
+
return M(JSON.stringify(r));
|
|
5271
5379
|
} catch {
|
|
5272
5380
|
return String(r);
|
|
5273
5381
|
}
|
|
5274
5382
|
}
|
|
5275
|
-
function
|
|
5276
|
-
const s =
|
|
5383
|
+
function Sn(r, e) {
|
|
5384
|
+
const s = q(
|
|
5277
5385
|
"From",
|
|
5278
5386
|
`<span class="__crossx-addr-text">${Y(r.from)}</span>
|
|
5279
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
5280
|
-
), t = r.to ?
|
|
5281
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
5282
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
5387
|
+
<button class="__crossx-copy-btn" data-copy="${M(r.from)}" title="Copy address">${de}</button>`
|
|
5388
|
+
), t = r.to ? q("To", `<span class="__crossx-addr-text">${Y(r.to)}</span>
|
|
5389
|
+
<button class="__crossx-copy-btn" data-copy="${M(r.to)}" title="Copy address">${de}</button>`) : "", n = r.amount ? q("Transfer", `<span>${M(r.amount)}</span>`) : "", o = r.fees ? q("Tx Fee", `<span>${M(r.fees)}</span>`) : "", i = r.txHash ? q("Tx Hash", `<span class="__crossx-addr-text">${Y(r.txHash)}</span>
|
|
5390
|
+
<button class="__crossx-copy-btn" data-copy="${M(r.txHash)}" title="Copy hash">${de}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
|
|
5283
5391
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
5284
|
-
<span class="__crossx-total-amount">${
|
|
5392
|
+
<span class="__crossx-total-amount">${M(r.total)}</span>
|
|
5285
5393
|
</div>` : "", c = document.createElement("div");
|
|
5286
5394
|
return c.id = te, c.innerHTML = `
|
|
5287
5395
|
<div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -5304,7 +5412,7 @@ function wn(r, e) {
|
|
|
5304
5412
|
</div>
|
|
5305
5413
|
`, c;
|
|
5306
5414
|
}
|
|
5307
|
-
function
|
|
5415
|
+
function En(r, e) {
|
|
5308
5416
|
const s = document.createElement("div");
|
|
5309
5417
|
return s.id = te, s.innerHTML = `
|
|
5310
5418
|
<div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -5321,47 +5429,47 @@ function yn(r, e) {
|
|
|
5321
5429
|
</div>
|
|
5322
5430
|
`, s;
|
|
5323
5431
|
}
|
|
5324
|
-
function
|
|
5432
|
+
function In(r, e, s) {
|
|
5325
5433
|
const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
|
|
5326
5434
|
if (o) {
|
|
5327
|
-
const
|
|
5328
|
-
|
|
5435
|
+
const m = n ? mn : t ? "" : xn, A = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
|
|
5436
|
+
m ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${m}<span>${A}</span>`) : o.textContent = A;
|
|
5329
5437
|
}
|
|
5330
5438
|
if (i && !r.querySelector("#__crossx-close-btn")) {
|
|
5331
|
-
const
|
|
5332
|
-
|
|
5439
|
+
const m = document.createElement("button");
|
|
5440
|
+
m.className = "__crossx-close", m.id = "__crossx-close-btn", m.setAttribute("aria-label", "Close"), m.innerHTML = ie, i.appendChild(m);
|
|
5333
5441
|
}
|
|
5334
5442
|
const a = r.querySelector("#__crossx-progress-body");
|
|
5335
5443
|
if (!a) return;
|
|
5336
|
-
const c = e.from ?
|
|
5337
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
5338
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
5339
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
5444
|
+
const c = e.from ? q("From", `<span class="__crossx-addr-text">${Y(e.from)}</span>
|
|
5445
|
+
<button class="__crossx-copy-btn" data-copy="${M(e.from)}" title="Copy address">${de}</button>`) : "", l = e.to ? q("To", `<span class="__crossx-addr-text">${Y(e.to)}</span>
|
|
5446
|
+
<button class="__crossx-copy-btn" data-copy="${M(e.to)}" title="Copy address">${de}</button>`) : "", d = e.amount ? q("Transfer", `<span>${M(e.amount)}</span>`) : "", f = e.fees ? q("Tx Fee", `<span>${M(e.fees)}</span>`) : "", w = e.txHash ? q("Tx Hash", `<span class="__crossx-addr-text">${Y(e.txHash)}</span>
|
|
5447
|
+
<button class="__crossx-copy-btn" data-copy="${M(e.txHash)}" title="Copy hash">${de}</button>`) : "", _ = e.total ? `<div class="__crossx-total-pill">
|
|
5340
5448
|
<span class="__crossx-total-label">Total<br>(including fees)</span>
|
|
5341
|
-
<span class="__crossx-total-amount">${
|
|
5449
|
+
<span class="__crossx-total-amount">${M(e.total)}</span>
|
|
5342
5450
|
</div>` : "";
|
|
5343
5451
|
a.innerHTML = `
|
|
5344
5452
|
<div class="__crossx-rows">
|
|
5345
5453
|
${c}
|
|
5346
5454
|
${l}
|
|
5347
5455
|
${d}
|
|
5348
|
-
${
|
|
5349
|
-
${
|
|
5456
|
+
${f}
|
|
5457
|
+
${w}
|
|
5350
5458
|
</div>
|
|
5351
|
-
${
|
|
5459
|
+
${_}
|
|
5352
5460
|
<button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
|
|
5353
|
-
`, a.querySelectorAll(".__crossx-copy-btn").forEach((
|
|
5354
|
-
|
|
5355
|
-
var
|
|
5356
|
-
|
|
5357
|
-
const
|
|
5358
|
-
|
|
5461
|
+
`, a.querySelectorAll(".__crossx-copy-btn").forEach((m) => {
|
|
5462
|
+
m.addEventListener("click", (A) => {
|
|
5463
|
+
var I;
|
|
5464
|
+
A.stopPropagation();
|
|
5465
|
+
const y = m.dataset.copy;
|
|
5466
|
+
y && ((I = navigator.clipboard) == null || I.writeText(y).catch(() => {
|
|
5359
5467
|
}));
|
|
5360
5468
|
});
|
|
5361
5469
|
});
|
|
5362
5470
|
}
|
|
5363
|
-
function
|
|
5364
|
-
const s = e, t = Ke(), n =
|
|
5471
|
+
function Tn(r, e) {
|
|
5472
|
+
const s = e, t = Ke(), n = M(r.message), o = document.createElement("div");
|
|
5365
5473
|
return o.id = te, o.innerHTML = `
|
|
5366
5474
|
<div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
5367
5475
|
<div class="__crossx-header">
|
|
@@ -5373,7 +5481,7 @@ function vn(r, e) {
|
|
|
5373
5481
|
<div class="__crossx-body-cols">
|
|
5374
5482
|
<div class="__crossx-col-left">
|
|
5375
5483
|
<p class="__crossx-sig-subtitle">
|
|
5376
|
-
<span class="__crossx-sig-origin">${
|
|
5484
|
+
<span class="__crossx-sig-origin">${M(t)} </span>is requesting a Signature
|
|
5377
5485
|
</p>
|
|
5378
5486
|
<div class="__crossx-addr-pill">
|
|
5379
5487
|
${_t}
|
|
@@ -5392,7 +5500,7 @@ function vn(r, e) {
|
|
|
5392
5500
|
</div>
|
|
5393
5501
|
`, o;
|
|
5394
5502
|
}
|
|
5395
|
-
function
|
|
5503
|
+
function An(r, e) {
|
|
5396
5504
|
const s = e, t = Ke();
|
|
5397
5505
|
let n = {};
|
|
5398
5506
|
if (typeof r.typedData == "string")
|
|
@@ -5405,15 +5513,15 @@ function Sn(r, e) {
|
|
|
5405
5513
|
let a = `
|
|
5406
5514
|
<div class="__crossx-td-row">
|
|
5407
5515
|
<span class="__crossx-td-label">Primary Type</span>
|
|
5408
|
-
<span class="__crossx-td-value">${
|
|
5516
|
+
<span class="__crossx-td-value">${M(o)}</span>
|
|
5409
5517
|
</div>`;
|
|
5410
5518
|
for (const [l, d] of Object.entries(i)) {
|
|
5411
|
-
const
|
|
5412
|
-
<button class="__crossx-copy-btn" data-copy="${
|
|
5519
|
+
const f = vn(d), _ = bn(d) ? `<span class="__crossx-addr-text">${Y(d)}</span>
|
|
5520
|
+
<button class="__crossx-copy-btn" data-copy="${M(String(d))}" title="Copy">${de}</button>` : `<span>${f}</span>`;
|
|
5413
5521
|
a += `
|
|
5414
5522
|
<div class="__crossx-td-row">
|
|
5415
|
-
<span class="__crossx-td-label">${
|
|
5416
|
-
<div class="__crossx-td-value">${
|
|
5523
|
+
<span class="__crossx-td-label">${M(l)}</span>
|
|
5524
|
+
<div class="__crossx-td-value">${_}</div>
|
|
5417
5525
|
</div>`;
|
|
5418
5526
|
}
|
|
5419
5527
|
const c = document.createElement("div");
|
|
@@ -5428,7 +5536,7 @@ function Sn(r, e) {
|
|
|
5428
5536
|
<div class="__crossx-body-cols">
|
|
5429
5537
|
<div class="__crossx-col-left">
|
|
5430
5538
|
<p class="__crossx-sig-subtitle">
|
|
5431
|
-
<span class="__crossx-sig-origin">${
|
|
5539
|
+
<span class="__crossx-sig-origin">${M(t)} </span>is requesting a Signature
|
|
5432
5540
|
</p>
|
|
5433
5541
|
<div class="__crossx-addr-pill">
|
|
5434
5542
|
${_t}
|
|
@@ -5447,17 +5555,18 @@ function Sn(r, e) {
|
|
|
5447
5555
|
</div>
|
|
5448
5556
|
`, c;
|
|
5449
5557
|
}
|
|
5450
|
-
const
|
|
5558
|
+
const Rn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
5451
5559
|
<line x1="12" y1="5" x2="12" y2="19"/>
|
|
5452
5560
|
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
5453
5561
|
</svg>`;
|
|
5454
|
-
function
|
|
5455
|
-
const s = r.map(
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5562
|
+
function On(r, e, s) {
|
|
5563
|
+
const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
|
|
5564
|
+
const a = t && i.address.toLowerCase() === t;
|
|
5565
|
+
return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${M(i.address)}">
|
|
5566
|
+
<span class="__crossx-wallet-addr">${Y(i.address)}</span>${a ? '<span class="__crossx-wallet-selected">selected</span>' : ""}
|
|
5567
|
+
</button>`;
|
|
5568
|
+
}).join(""), o = document.createElement("div");
|
|
5569
|
+
return o.id = te, o.innerHTML = `
|
|
5461
5570
|
<div class="__crossx-card __crossx-card--migration __crossx-card--wallet-selector" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
5462
5571
|
<div class="__crossx-header">
|
|
5463
5572
|
<div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
|
|
@@ -5478,28 +5587,28 @@ function In(r, e) {
|
|
|
5478
5587
|
<hr class="__crossx-divider __crossx-divider--cols">
|
|
5479
5588
|
<div class="__crossx-col-right-ws">
|
|
5480
5589
|
<div class="__crossx-wallet-list" id="__crossx-wallet-list">
|
|
5481
|
-
${
|
|
5590
|
+
${n}
|
|
5482
5591
|
</div>
|
|
5483
5592
|
<button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
|
|
5484
|
-
<span class="__crossx-wallet-add-icon">${
|
|
5593
|
+
<span class="__crossx-wallet-add-icon">${Rn}</span>
|
|
5485
5594
|
<span class="__crossx-wallet-add-label">add a wallet</span>
|
|
5486
5595
|
</button>
|
|
5487
5596
|
</div>
|
|
5488
5597
|
</div>
|
|
5489
5598
|
</div>
|
|
5490
5599
|
</div>
|
|
5491
|
-
`,
|
|
5600
|
+
`, o;
|
|
5492
5601
|
}
|
|
5493
|
-
const
|
|
5602
|
+
const Cn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
5494
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"/>
|
|
5495
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"/>
|
|
5496
|
-
</svg>`,
|
|
5605
|
+
</svg>`, kn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
5497
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"/>
|
|
5498
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"/>
|
|
5499
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"/>
|
|
5500
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"/>
|
|
5501
5610
|
</svg>`;
|
|
5502
|
-
function
|
|
5611
|
+
function Nn(r) {
|
|
5503
5612
|
const e = r, s = document.createElement("div");
|
|
5504
5613
|
return s.id = te, s.innerHTML = `
|
|
5505
5614
|
<div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -5514,11 +5623,11 @@ function Rn(r) {
|
|
|
5514
5623
|
<div class="__crossx-body">
|
|
5515
5624
|
<div class="__crossx-login-btn-row">
|
|
5516
5625
|
<button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
|
|
5517
|
-
<span class="__crossx-login-icon" style="color:var(--cx-value);">${
|
|
5626
|
+
<span class="__crossx-login-icon" style="color:var(--cx-value);">${Cn}</span>
|
|
5518
5627
|
<span class="__crossx-login-btn-label">Sign in with Apple</span>
|
|
5519
5628
|
</button>
|
|
5520
5629
|
<button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
|
|
5521
|
-
<span class="__crossx-login-icon">${
|
|
5630
|
+
<span class="__crossx-login-icon">${kn}</span>
|
|
5522
5631
|
<span class="__crossx-login-btn-label">Sign in with Google</span>
|
|
5523
5632
|
</button>
|
|
5524
5633
|
</div>
|
|
@@ -5530,7 +5639,7 @@ function Rn(r) {
|
|
|
5530
5639
|
</div>
|
|
5531
5640
|
`, s;
|
|
5532
5641
|
}
|
|
5533
|
-
function
|
|
5642
|
+
function Pn(r) {
|
|
5534
5643
|
const e = r, s = document.createElement("div");
|
|
5535
5644
|
return s.id = te, s.innerHTML = `
|
|
5536
5645
|
<div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -5546,7 +5655,7 @@ function On(r) {
|
|
|
5546
5655
|
<p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
|
|
5547
5656
|
</div>
|
|
5548
5657
|
<button class="__crossx-recover-btn" id="__crossx-recover-btn">
|
|
5549
|
-
<span>${
|
|
5658
|
+
<span>${_n(e.primary)}</span>
|
|
5550
5659
|
<span class="__crossx-recover-label">Recover My Wallet</span>
|
|
5551
5660
|
</button>
|
|
5552
5661
|
<button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>
|
|
@@ -5554,7 +5663,7 @@ function On(r) {
|
|
|
5554
5663
|
</div>
|
|
5555
5664
|
`, s;
|
|
5556
5665
|
}
|
|
5557
|
-
function
|
|
5666
|
+
function Ln(r, e) {
|
|
5558
5667
|
const s = r, t = e ? `<p class="__crossx-pin-error-text">${e}</p>` : "", n = document.createElement("div");
|
|
5559
5668
|
return n.id = te, n.innerHTML = `
|
|
5560
5669
|
<div class="__crossx-card __crossx-card--migration" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
|
|
@@ -5576,7 +5685,7 @@ function Cn(r, e) {
|
|
|
5576
5685
|
</div>
|
|
5577
5686
|
`, n;
|
|
5578
5687
|
}
|
|
5579
|
-
function
|
|
5688
|
+
function Dn(r, e, s) {
|
|
5580
5689
|
var n;
|
|
5581
5690
|
const t = r.querySelectorAll(".__crossx-pin-input");
|
|
5582
5691
|
t.forEach((o, i) => {
|
|
@@ -5594,20 +5703,23 @@ function kn(r, e, s) {
|
|
|
5594
5703
|
a.preventDefault();
|
|
5595
5704
|
const c = (((d = a.clipboardData) == null ? void 0 : d.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
|
|
5596
5705
|
if (!c) return;
|
|
5597
|
-
c.split("").forEach((
|
|
5598
|
-
t[
|
|
5706
|
+
c.split("").forEach((f, w) => {
|
|
5707
|
+
t[w] && (t[w].value = f);
|
|
5599
5708
|
});
|
|
5600
5709
|
const l = Math.min(c.length, 3);
|
|
5601
5710
|
t[l].focus(), c.length === 4 && setTimeout(() => e(c), 200);
|
|
5602
5711
|
});
|
|
5603
5712
|
}), (n = t[0]) == null || n.focus();
|
|
5604
5713
|
}
|
|
5605
|
-
class
|
|
5714
|
+
class $n {
|
|
5606
5715
|
constructor(e = "light", s) {
|
|
5607
|
-
this.theme = e, this.overrides = s, this.tokens =
|
|
5716
|
+
this.theme = e, this.overrides = s, this.tokens = Vt(e, s);
|
|
5608
5717
|
}
|
|
5609
5718
|
setTheme(e, s) {
|
|
5610
|
-
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;
|
|
5611
5723
|
}
|
|
5612
5724
|
getTheme() {
|
|
5613
5725
|
return this.theme;
|
|
@@ -5617,50 +5729,50 @@ class Nn {
|
|
|
5617
5729
|
* 지갑 목록을 표시하고, 사용자가 선택하거나 새 지갑을 추가할 수 있습니다.
|
|
5618
5730
|
* 모달은 지갑을 선택하거나 X를 누를 때까지 유지됩니다.
|
|
5619
5731
|
*/
|
|
5620
|
-
showWalletSelector(e, s) {
|
|
5621
|
-
return new Promise((
|
|
5622
|
-
var
|
|
5732
|
+
showWalletSelector(e, s, t) {
|
|
5733
|
+
return new Promise((n) => {
|
|
5734
|
+
var A;
|
|
5623
5735
|
me();
|
|
5624
|
-
const
|
|
5625
|
-
document.body.style.overflow = "hidden", document.body.appendChild(
|
|
5626
|
-
let
|
|
5627
|
-
const
|
|
5628
|
-
|
|
5629
|
-
},
|
|
5630
|
-
|
|
5631
|
-
},
|
|
5632
|
-
|
|
5736
|
+
const o = [...e], i = On(o, this.tokens, t), a = document.body.style.overflow;
|
|
5737
|
+
document.body.style.overflow = "hidden", document.body.appendChild(i);
|
|
5738
|
+
let c = !1;
|
|
5739
|
+
const l = () => {
|
|
5740
|
+
c || (c = !0, i.remove(), document.body.style.overflow = a);
|
|
5741
|
+
}, d = (y) => {
|
|
5742
|
+
l(), n(y);
|
|
5743
|
+
}, f = () => {
|
|
5744
|
+
l(), n(null);
|
|
5633
5745
|
};
|
|
5634
5746
|
(() => {
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
const
|
|
5638
|
-
|
|
5747
|
+
i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
|
|
5748
|
+
y.addEventListener("click", () => {
|
|
5749
|
+
const I = y.dataset.walletAddress ?? "", L = parseInt(y.dataset.walletIndex ?? "0", 10);
|
|
5750
|
+
d({ address: I, index: L });
|
|
5639
5751
|
});
|
|
5640
5752
|
});
|
|
5641
5753
|
})();
|
|
5642
|
-
const
|
|
5643
|
-
|
|
5644
|
-
|
|
5754
|
+
const _ = i.querySelector("#__crossx-add-wallet-btn");
|
|
5755
|
+
_ && _.addEventListener("click", async () => {
|
|
5756
|
+
_.disabled = !0;
|
|
5645
5757
|
try {
|
|
5646
|
-
const
|
|
5647
|
-
|
|
5648
|
-
const
|
|
5649
|
-
if (
|
|
5650
|
-
const
|
|
5651
|
-
|
|
5758
|
+
const y = await s();
|
|
5759
|
+
o.push(y);
|
|
5760
|
+
const I = i.querySelector("#__crossx-wallet-list");
|
|
5761
|
+
if (I) {
|
|
5762
|
+
const L = document.createElement("button");
|
|
5763
|
+
L.className = "__crossx-wallet-item", L.dataset.walletIndex = String(y.index), L.dataset.walletAddress = y.address, L.innerHTML = `<span class="__crossx-wallet-addr">${Y(y.address)}</span>`, L.addEventListener("click", () => d(y)), I.appendChild(L), L.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
5652
5764
|
}
|
|
5653
5765
|
} catch {
|
|
5654
5766
|
} finally {
|
|
5655
|
-
|
|
5767
|
+
_.disabled = !1;
|
|
5656
5768
|
}
|
|
5657
|
-
}), (
|
|
5658
|
-
|
|
5769
|
+
}), (A = i.querySelector("#__crossx-close-btn")) == null || A.addEventListener("click", f), i.addEventListener("click", (y) => {
|
|
5770
|
+
y.target === i && f();
|
|
5659
5771
|
});
|
|
5660
|
-
const
|
|
5661
|
-
|
|
5772
|
+
const m = (y) => {
|
|
5773
|
+
y.key === "Escape" && (document.removeEventListener("keydown", m), f());
|
|
5662
5774
|
};
|
|
5663
|
-
document.addEventListener("keydown",
|
|
5775
|
+
document.addEventListener("keydown", m);
|
|
5664
5776
|
});
|
|
5665
5777
|
}
|
|
5666
5778
|
/**
|
|
@@ -5672,7 +5784,7 @@ class Nn {
|
|
|
5672
5784
|
return new Promise((e) => {
|
|
5673
5785
|
var a, c, l;
|
|
5674
5786
|
me();
|
|
5675
|
-
const s =
|
|
5787
|
+
const s = Nn(this.tokens);
|
|
5676
5788
|
document.body.appendChild(s);
|
|
5677
5789
|
const t = () => s.remove(), n = (d) => {
|
|
5678
5790
|
t(), e(d);
|
|
@@ -5682,7 +5794,7 @@ class Nn {
|
|
|
5682
5794
|
(a = s.querySelector("#__crossx-apple-btn")) == null || a.addEventListener("click", () => n("apple")), (c = s.querySelector("#__crossx-google-btn")) == null || c.addEventListener("click", () => n("google")), (l = s.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", o), s.addEventListener("click", (d) => {
|
|
5683
5795
|
d.target === s && o();
|
|
5684
5796
|
}), s.querySelectorAll(".__crossx-login-terms-link").forEach((d) => {
|
|
5685
|
-
d.addEventListener("click", (
|
|
5797
|
+
d.addEventListener("click", (f) => f.stopPropagation());
|
|
5686
5798
|
});
|
|
5687
5799
|
const i = (d) => {
|
|
5688
5800
|
d.key === "Escape" && (document.removeEventListener("keydown", i), o());
|
|
@@ -5698,7 +5810,7 @@ class Nn {
|
|
|
5698
5810
|
return new Promise((e) => {
|
|
5699
5811
|
var a, c, l;
|
|
5700
5812
|
me();
|
|
5701
|
-
const s =
|
|
5813
|
+
const s = Pn(this.tokens);
|
|
5702
5814
|
document.body.appendChild(s);
|
|
5703
5815
|
const t = () => s.remove(), n = () => {
|
|
5704
5816
|
t(), e("recover");
|
|
@@ -5723,14 +5835,14 @@ class Nn {
|
|
|
5723
5835
|
return new Promise((s) => {
|
|
5724
5836
|
var a;
|
|
5725
5837
|
me();
|
|
5726
|
-
const t =
|
|
5838
|
+
const t = Ln(this.tokens, e);
|
|
5727
5839
|
document.body.appendChild(t);
|
|
5728
5840
|
const n = () => t.remove(), o = (c) => {
|
|
5729
5841
|
n(), s(c);
|
|
5730
5842
|
}, i = () => {
|
|
5731
5843
|
n(), s(null);
|
|
5732
5844
|
};
|
|
5733
|
-
|
|
5845
|
+
Dn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
|
|
5734
5846
|
c.target === t && i();
|
|
5735
5847
|
});
|
|
5736
5848
|
});
|
|
@@ -5743,17 +5855,17 @@ class Nn {
|
|
|
5743
5855
|
return new Promise((s) => {
|
|
5744
5856
|
var a, c;
|
|
5745
5857
|
me();
|
|
5746
|
-
const t =
|
|
5858
|
+
const t = Sn(e, this.tokens);
|
|
5747
5859
|
document.body.appendChild(t);
|
|
5748
5860
|
const n = () => t.remove(), o = () => {
|
|
5749
5861
|
n(), s();
|
|
5750
5862
|
};
|
|
5751
5863
|
(a = t.querySelector("#__crossx-done-btn")) == null || a.addEventListener("click", o), (c = t.querySelector("#__crossx-close-btn")) == null || c.addEventListener("click", o), t.querySelectorAll(".__crossx-copy-btn").forEach((l) => {
|
|
5752
5864
|
l.addEventListener("click", (d) => {
|
|
5753
|
-
var
|
|
5865
|
+
var w;
|
|
5754
5866
|
d.stopPropagation();
|
|
5755
|
-
const
|
|
5756
|
-
|
|
5867
|
+
const f = l.dataset.copy;
|
|
5868
|
+
f && ((w = navigator.clipboard) == null || w.writeText(f).catch(() => {
|
|
5757
5869
|
}));
|
|
5758
5870
|
});
|
|
5759
5871
|
}), t.addEventListener("click", (l) => {
|
|
@@ -5772,24 +5884,24 @@ class Nn {
|
|
|
5772
5884
|
showTransactionProgress(e, s) {
|
|
5773
5885
|
return new Promise((t) => {
|
|
5774
5886
|
me();
|
|
5775
|
-
const n =
|
|
5887
|
+
const n = En(e, this.tokens);
|
|
5776
5888
|
document.body.appendChild(n);
|
|
5777
5889
|
const o = () => n.remove();
|
|
5778
5890
|
let i = !1;
|
|
5779
5891
|
const a = () => {
|
|
5780
5892
|
i || (i = !0, o(), t());
|
|
5781
5893
|
}, c = () => {
|
|
5782
|
-
var d,
|
|
5783
|
-
(d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (
|
|
5784
|
-
|
|
5894
|
+
var d, f;
|
|
5895
|
+
(d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (f = n.querySelector("#__crossx-close-btn")) == null || f.addEventListener("click", a), n.addEventListener("click", (w) => {
|
|
5896
|
+
w.target === n && a();
|
|
5785
5897
|
});
|
|
5786
|
-
const l = (
|
|
5787
|
-
|
|
5898
|
+
const l = (w) => {
|
|
5899
|
+
w.key === "Escape" && (document.removeEventListener("keydown", l), a());
|
|
5788
5900
|
};
|
|
5789
5901
|
document.addEventListener("keydown", l);
|
|
5790
5902
|
};
|
|
5791
5903
|
s.then((l) => {
|
|
5792
|
-
i || (
|
|
5904
|
+
i || (In(n, l, this.tokens), c());
|
|
5793
5905
|
});
|
|
5794
5906
|
});
|
|
5795
5907
|
}
|
|
@@ -5798,31 +5910,31 @@ class Nn {
|
|
|
5798
5910
|
var c, l, d;
|
|
5799
5911
|
me();
|
|
5800
5912
|
let t;
|
|
5801
|
-
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);
|
|
5802
5914
|
const n = () => t.remove(), o = () => {
|
|
5803
5915
|
n(), s(!0);
|
|
5804
5916
|
}, i = () => {
|
|
5805
5917
|
n(), s(!1);
|
|
5806
5918
|
};
|
|
5807
|
-
(c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (d = t.querySelector("#__crossx-close-btn")) == null || d.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((
|
|
5808
|
-
|
|
5809
|
-
var
|
|
5810
|
-
|
|
5811
|
-
const
|
|
5812
|
-
|
|
5919
|
+
(c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (d = t.querySelector("#__crossx-close-btn")) == null || d.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((f) => {
|
|
5920
|
+
f.addEventListener("click", (w) => {
|
|
5921
|
+
var m;
|
|
5922
|
+
w.stopPropagation();
|
|
5923
|
+
const _ = f.dataset.copy;
|
|
5924
|
+
_ && ((m = navigator.clipboard) == null || m.writeText(_).catch(() => {
|
|
5813
5925
|
}));
|
|
5814
5926
|
});
|
|
5815
|
-
}), t.addEventListener("click", (
|
|
5816
|
-
|
|
5927
|
+
}), t.addEventListener("click", (f) => {
|
|
5928
|
+
f.target === t && i();
|
|
5817
5929
|
});
|
|
5818
|
-
const a = (
|
|
5819
|
-
|
|
5930
|
+
const a = (f) => {
|
|
5931
|
+
f.key === "Escape" && (document.removeEventListener("keydown", a), i());
|
|
5820
5932
|
};
|
|
5821
5933
|
document.addEventListener("keydown", a);
|
|
5822
5934
|
});
|
|
5823
5935
|
}
|
|
5824
5936
|
}
|
|
5825
|
-
class
|
|
5937
|
+
class Mn {
|
|
5826
5938
|
constructor() {
|
|
5827
5939
|
this._accessToken = null;
|
|
5828
5940
|
}
|
|
@@ -5839,9 +5951,9 @@ class Pn {
|
|
|
5839
5951
|
return this._accessToken !== null;
|
|
5840
5952
|
}
|
|
5841
5953
|
}
|
|
5842
|
-
function
|
|
5954
|
+
function Hn(r) {
|
|
5843
5955
|
r.debug;
|
|
5844
|
-
const e =
|
|
5956
|
+
const e = Fe.production, s = {
|
|
5845
5957
|
...r,
|
|
5846
5958
|
oauthServiceUrl: e.oauthServiceUrl,
|
|
5847
5959
|
authApiUrl: e.authApiUrl,
|
|
@@ -5849,15 +5961,15 @@ function Mn(r) {
|
|
|
5849
5961
|
}, t = {
|
|
5850
5962
|
gatewayUrl: e.walletGatewayUrl,
|
|
5851
5963
|
projectId: r.projectId
|
|
5852
|
-
}, 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();
|
|
5853
5965
|
let d;
|
|
5854
|
-
r.useMockWallet ? (
|
|
5966
|
+
r.useMockWallet ? (p.log("[CROSSx] Mock Wallet Provider 사용"), d = new dn(o)) : (p.log("[CROSSx] Remote Wallet Provider 사용"), d = new qe(
|
|
5855
5967
|
t,
|
|
5856
5968
|
o,
|
|
5857
5969
|
a,
|
|
5858
5970
|
l
|
|
5859
5971
|
));
|
|
5860
|
-
const
|
|
5972
|
+
const f = new Ce(t, a), w = new $n(r.theme ?? "light", r.themeTokens);
|
|
5861
5973
|
return new st(
|
|
5862
5974
|
s,
|
|
5863
5975
|
t,
|
|
@@ -5867,15 +5979,15 @@ function Mn(r) {
|
|
|
5867
5979
|
c,
|
|
5868
5980
|
d,
|
|
5869
5981
|
l,
|
|
5870
|
-
|
|
5871
|
-
|
|
5982
|
+
w,
|
|
5983
|
+
f
|
|
5872
5984
|
);
|
|
5873
5985
|
}
|
|
5874
5986
|
export {
|
|
5875
|
-
|
|
5876
|
-
|
|
5987
|
+
x as CROSSxError,
|
|
5988
|
+
Ns as CROSSxEthereumProvider,
|
|
5877
5989
|
st as CROSSxSDK,
|
|
5878
|
-
|
|
5990
|
+
Un as ChainId,
|
|
5879
5991
|
g as ErrorCode,
|
|
5880
|
-
|
|
5992
|
+
Hn as createCROSSxSDK
|
|
5881
5993
|
};
|