@naculus/connect-appkit-core 0.5.0 → 0.6.0

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.cts CHANGED
@@ -946,7 +946,12 @@ interface RetryOptions {
946
946
  label?: string;
947
947
  }
948
948
  declare function withRetry<T>(fn: () => Promise<T>, options: RetryOptions): Promise<T>;
949
- /** Convert EIP-1193 chainChanged values into the CAIP-2 form used by sessions. */
949
+ /**
950
+ * Convert EIP-1193 chainChanged values into the CAIP-2 form used by sessions.
951
+ * Refuses chain 0 and anything above `Number.MAX_SAFE_INTEGER`, as
952
+ * connect-core's `normalizeEip155ChainId` does; switch to that export once
953
+ * the connect-lib release that adds it is the minimum supported version.
954
+ */
950
955
  declare function normalizeEip155ChainId(value: unknown): string | undefined;
951
956
  declare function toEip155Accounts(accounts: unknown[], chainId: string): string[];
952
957
  /**
package/dist/index.d.ts CHANGED
@@ -946,7 +946,12 @@ interface RetryOptions {
946
946
  label?: string;
947
947
  }
948
948
  declare function withRetry<T>(fn: () => Promise<T>, options: RetryOptions): Promise<T>;
949
- /** Convert EIP-1193 chainChanged values into the CAIP-2 form used by sessions. */
949
+ /**
950
+ * Convert EIP-1193 chainChanged values into the CAIP-2 form used by sessions.
951
+ * Refuses chain 0 and anything above `Number.MAX_SAFE_INTEGER`, as
952
+ * connect-core's `normalizeEip155ChainId` does; switch to that export once
953
+ * the connect-lib release that adds it is the minimum supported version.
954
+ */
950
955
  declare function normalizeEip155ChainId(value: unknown): string | undefined;
951
956
  declare function toEip155Accounts(accounts: unknown[], chainId: string): string[];
952
957
  /**
package/dist/index.js CHANGED
@@ -1465,18 +1465,25 @@ async function withRetry(fn, options) {
1465
1465
  }
1466
1466
  function normalizeEip155ChainId(value) {
1467
1467
  if (typeof value !== "string") return void 0;
1468
+ let raw;
1469
+ if (value.startsWith("eip155:")) {
1470
+ raw = value.slice("eip155:".length);
1471
+ if (!/^\d+$/.test(raw)) return void 0;
1472
+ } else if (/^0x[0-9a-f]+$/i.test(value) || /^\d+$/.test(value)) {
1473
+ raw = value;
1474
+ } else {
1475
+ return void 0;
1476
+ }
1477
+ let numeric;
1468
1478
  try {
1469
- if (value.startsWith("eip155:")) {
1470
- const reference = value.slice("eip155:".length);
1471
- if (!/^\d+$/.test(reference)) return void 0;
1472
- return `eip155:${BigInt(reference).toString(10)}`;
1473
- }
1474
- if (/^0x[0-9a-f]+$/i.test(value) || /^\d+$/.test(value)) {
1475
- return `eip155:${BigInt(value).toString(10)}`;
1476
- }
1479
+ numeric = BigInt(raw);
1477
1480
  } catch {
1481
+ return void 0;
1478
1482
  }
1479
- return void 0;
1483
+ if (numeric <= 0n || numeric > BigInt(Number.MAX_SAFE_INTEGER)) {
1484
+ return void 0;
1485
+ }
1486
+ return `eip155:${numeric.toString(10)}`;
1480
1487
  }
1481
1488
  function toEip155Accounts(accounts, chainId) {
1482
1489
  const reference = chainId.split(":")[1];