2020117-agent 0.6.9 → 0.6.10

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.
Files changed (2) hide show
  1. package/dist/agent.js +14 -9
  2. package/package.json +1 -1
package/dist/agent.js CHANGED
@@ -1016,16 +1016,21 @@ async function startSwarmListener(label) {
1016
1016
  if (!session)
1017
1017
  return;
1018
1018
  if (msg.preimage) {
1019
- // Verify preimage: SHA256(preimage) must equal the invoice's payment_hash
1020
- if (session.pendingPaymentHash) {
1021
- if (!verifyPreimage(msg.preimage, session.pendingPaymentHash)) {
1022
- console.log(`[${label}] Session ${session.sessionId}: invalid preimage — ending session`);
1023
- node.send(session.socket, { type: 'error', id: msg.id, message: 'Invalid payment preimage' });
1024
- endSession(node, session, label);
1025
- return;
1026
- }
1027
- session.pendingPaymentHash = undefined;
1019
+ // Verify preimage: SHA256(preimage) must equal the invoice's payment_hash.
1020
+ // If payment_hash is missing (bolt11 decode failed), reject — fail secure.
1021
+ if (!session.pendingPaymentHash) {
1022
+ console.log(`[${label}] Session ${session.sessionId}: cannot verify payment (no payment_hash) — ending session`);
1023
+ node.send(session.socket, { type: 'error', id: msg.id, message: 'Provider cannot verify payment' });
1024
+ endSession(node, session, label);
1025
+ return;
1026
+ }
1027
+ if (!verifyPreimage(msg.preimage, session.pendingPaymentHash)) {
1028
+ console.log(`[${label}] Session ${session.sessionId}: invalid preimage — ending session`);
1029
+ node.send(session.socket, { type: 'error', id: msg.id, message: 'Invalid payment preimage' });
1030
+ endSession(node, session, label);
1031
+ return;
1028
1032
  }
1033
+ session.pendingPaymentHash = undefined;
1029
1034
  const amount = msg.amount || 0;
1030
1035
  session.totalEarned += amount;
1031
1036
  session.lastPaidAt = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "2020117-agent",
3
- "version": "0.6.9",
3
+ "version": "0.6.10",
4
4
  "description": "2020117 agent runtime — Nostr-native relay subscription + Hyperswarm P2P + Lightning payments",
5
5
  "type": "module",
6
6
  "bin": {