@naculus/connect-appkit-core 0.5.0 → 0.7.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.cjs CHANGED
@@ -67,8 +67,13 @@ __export(src_exports, {
67
67
  normalizeCapabilities: () => normalizeCapabilities,
68
68
  normalizeEip155ChainId: () => normalizeEip155ChainId,
69
69
  parseUserOperationReceipt: () => parseUserOperationReceipt,
70
+ readCurrentMppSessionChannel: () => readCurrentMppSessionChannel,
70
71
  readDecimals: () => readDecimals,
72
+ readMppRecoveryChannelId: () => readMppRecoveryChannelId,
73
+ readMppSessionChannel: () => readMppSessionChannel,
74
+ readMppSessionReceipt: () => readMppSessionReceipt,
71
75
  readSolanaRoles: () => readSolanaRoles,
76
+ replayNotificationSettings: () => replayNotificationSettings,
72
77
  resetSharedSessionKeyManager: () => resetSharedSessionKeyManager,
73
78
  resolveChain: () => resolveChain,
74
79
  resolveContextSimulationEndpoint: () => resolveContextSimulationEndpoint,
@@ -573,6 +578,13 @@ function saveNotificationSettings(storage, settings) {
573
578
  function updateNotificationSettings(current, update) {
574
579
  return { ...current, ...update };
575
580
  }
581
+ function replayNotificationSettings(persisted, updates) {
582
+ let settings = persisted ?? DEFAULT_NOTIFICATION_SETTINGS;
583
+ for (const update of updates) {
584
+ settings = updateNotificationSettings(settings, update(settings));
585
+ }
586
+ return settings;
587
+ }
576
588
  function channelsUpdate(channels) {
577
589
  const update = {};
578
590
  if (channels.includes("telegram")) update.telegram = true;
@@ -1420,6 +1432,36 @@ function describePayment(input, result) {
1420
1432
  };
1421
1433
  }
1422
1434
 
1435
+ // src/mpp-session.ts
1436
+ function record2(value) {
1437
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
1438
+ }
1439
+ function readMppSessionChannel(value) {
1440
+ const channel = record2(value);
1441
+ if (!channel || typeof channel.channelId !== "string" || typeof channel.payer !== "string" || typeof channel.payee !== "string" || typeof channel.mint !== "string" || typeof channel.channelProgram !== "string" || typeof channel.deposit !== "bigint" || typeof channel.gracePeriodSeconds !== "number" || typeof channel.openSlot !== "bigint" || typeof channel.salt !== "bigint") {
1442
+ return null;
1443
+ }
1444
+ return channel;
1445
+ }
1446
+ function readCurrentMppSessionChannel(session) {
1447
+ for (let index = session.channels.length - 1; index >= 0; index--) {
1448
+ const channel = readMppSessionChannel(session.channels[index]);
1449
+ if (channel) return channel;
1450
+ }
1451
+ return null;
1452
+ }
1453
+ function readMppSessionReceipt(value) {
1454
+ const receipt = record2(value);
1455
+ if (receipt?.status !== "success" || typeof receipt.method !== "string" || typeof receipt.timestamp !== "string" || typeof receipt.reference !== "string") {
1456
+ return null;
1457
+ }
1458
+ return receipt;
1459
+ }
1460
+ function readMppRecoveryChannelId(error) {
1461
+ const channelId = record2(error)?.channelId;
1462
+ return typeof channelId === "string" && channelId !== "" ? channelId : null;
1463
+ }
1464
+
1423
1465
  // src/solana-session-key.ts
1424
1466
  var import_connect_core17 = require("@naculus/connect-core");
1425
1467
  function send(rpc) {
@@ -1535,18 +1577,25 @@ async function withRetry(fn, options) {
1535
1577
  }
1536
1578
  function normalizeEip155ChainId(value) {
1537
1579
  if (typeof value !== "string") return void 0;
1580
+ let raw;
1581
+ if (value.startsWith("eip155:")) {
1582
+ raw = value.slice("eip155:".length);
1583
+ if (!/^\d+$/.test(raw)) return void 0;
1584
+ } else if (/^0x[0-9a-f]+$/i.test(value) || /^\d+$/.test(value)) {
1585
+ raw = value;
1586
+ } else {
1587
+ return void 0;
1588
+ }
1589
+ let numeric;
1538
1590
  try {
1539
- if (value.startsWith("eip155:")) {
1540
- const reference = value.slice("eip155:".length);
1541
- if (!/^\d+$/.test(reference)) return void 0;
1542
- return `eip155:${BigInt(reference).toString(10)}`;
1543
- }
1544
- if (/^0x[0-9a-f]+$/i.test(value) || /^\d+$/.test(value)) {
1545
- return `eip155:${BigInt(value).toString(10)}`;
1546
- }
1591
+ numeric = BigInt(raw);
1547
1592
  } catch {
1593
+ return void 0;
1548
1594
  }
1549
- return void 0;
1595
+ if (numeric <= 0n || numeric > BigInt(Number.MAX_SAFE_INTEGER)) {
1596
+ return void 0;
1597
+ }
1598
+ return `eip155:${numeric.toString(10)}`;
1550
1599
  }
1551
1600
  function toEip155Accounts(accounts, chainId) {
1552
1601
  const reference = chainId.split(":")[1];
@@ -1677,8 +1726,13 @@ function siwxResultToSession(result, now = /* @__PURE__ */ new Date()) {
1677
1726
  normalizeCapabilities,
1678
1727
  normalizeEip155ChainId,
1679
1728
  parseUserOperationReceipt,
1729
+ readCurrentMppSessionChannel,
1680
1730
  readDecimals,
1731
+ readMppRecoveryChannelId,
1732
+ readMppSessionChannel,
1733
+ readMppSessionReceipt,
1681
1734
  readSolanaRoles,
1735
+ replayNotificationSettings,
1682
1736
  resetSharedSessionKeyManager,
1683
1737
  resolveChain,
1684
1738
  resolveContextSimulationEndpoint,