@pear-protocol/symmio-client 0.2.39 → 0.2.41
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/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +31 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -17
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +14 -13
- package/dist/react/index.d.ts +14 -13
- package/dist/react/index.js +61 -126
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +61 -126
- package/dist/react/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isAddress, encodeFunctionData } from 'viem';
|
|
2
|
+
import { SiweMessage } from 'siwe';
|
|
2
3
|
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __export = (target, all) => {
|
|
@@ -24396,6 +24397,7 @@ var instant_exports = {};
|
|
|
24396
24397
|
__export(instant_exports, {
|
|
24397
24398
|
cancelInstantClose: () => cancelInstantClose,
|
|
24398
24399
|
createSiweMessage: () => createSiweMessage,
|
|
24400
|
+
getHedgerBaseUrl: () => getHedgerBaseUrl,
|
|
24399
24401
|
getNonce: () => getNonce,
|
|
24400
24402
|
getOpenInstantCloses: () => getOpenInstantCloses,
|
|
24401
24403
|
instantClose: () => instantClose,
|
|
@@ -24415,19 +24417,17 @@ function createSiweMessage(params) {
|
|
|
24415
24417
|
const expirationTime = new Date(
|
|
24416
24418
|
Date.now() + 30 * 24 * 60 * 60 * 1e3
|
|
24417
24419
|
).toISOString();
|
|
24418
|
-
const message =
|
|
24419
|
-
|
|
24420
|
-
params.address,
|
|
24421
|
-
|
|
24422
|
-
params.
|
|
24423
|
-
|
|
24424
|
-
|
|
24425
|
-
|
|
24426
|
-
|
|
24427
|
-
|
|
24428
|
-
|
|
24429
|
-
`Expiration Time: ${expirationTime}`
|
|
24430
|
-
].join("\n");
|
|
24420
|
+
const message = new SiweMessage({
|
|
24421
|
+
domain: params.domain,
|
|
24422
|
+
address: params.address,
|
|
24423
|
+
statement: params.statement,
|
|
24424
|
+
chainId: params.chainId,
|
|
24425
|
+
nonce: params.nonce,
|
|
24426
|
+
version,
|
|
24427
|
+
uri: params.uri,
|
|
24428
|
+
issuedAt,
|
|
24429
|
+
expirationTime
|
|
24430
|
+
}).prepareMessage();
|
|
24431
24431
|
return { message, issuedAt, expirationTime };
|
|
24432
24432
|
}
|
|
24433
24433
|
async function getNonce(chainId, subAccount) {
|
|
@@ -24456,10 +24456,24 @@ async function login(chainId, params) {
|
|
|
24456
24456
|
body: JSON.stringify(body)
|
|
24457
24457
|
});
|
|
24458
24458
|
if (!response.ok) {
|
|
24459
|
-
|
|
24460
|
-
|
|
24461
|
-
|
|
24462
|
-
|
|
24459
|
+
let errorMessage = "";
|
|
24460
|
+
if (typeof response.text === "function") {
|
|
24461
|
+
const rawBody = await response.text().catch(() => "");
|
|
24462
|
+
if (rawBody) {
|
|
24463
|
+
try {
|
|
24464
|
+
const parsed = JSON.parse(rawBody);
|
|
24465
|
+
errorMessage = parsed.error_message ?? parsed.message ?? parsed.detail ?? rawBody;
|
|
24466
|
+
} catch {
|
|
24467
|
+
errorMessage = rawBody;
|
|
24468
|
+
}
|
|
24469
|
+
}
|
|
24470
|
+
}
|
|
24471
|
+
if (!errorMessage && typeof response.json === "function") {
|
|
24472
|
+
const errorData = await response.json().catch(() => null);
|
|
24473
|
+
errorMessage = errorData?.error_message ?? errorData?.message ?? errorData?.detail ?? "";
|
|
24474
|
+
}
|
|
24475
|
+
const reason = errorMessage || response.statusText;
|
|
24476
|
+
throw new Error(reason ? `Login failed: ${reason}` : "Login failed");
|
|
24463
24477
|
}
|
|
24464
24478
|
const data = await response.json();
|
|
24465
24479
|
if (!data.access_token) {
|