@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.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
- `${params.domain} wants you to sign in with your Ethereum account:`,
24420
- params.address,
24421
- "",
24422
- params.statement,
24423
- "",
24424
- `URI: ${params.uri}`,
24425
- `Version: ${version}`,
24426
- `Chain ID: ${params.chainId}`,
24427
- `Nonce: ${params.nonce}`,
24428
- `Issued At: ${issuedAt}`,
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
- const errorData = await response.json().catch(() => null);
24460
- throw new Error(
24461
- errorData?.error_message ?? `Login failed: ${response.statusText}`
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) {