402-mcp 3.15.3 → 3.15.4

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.
@@ -1,20 +1,19 @@
1
- import { createRequire } from 'node:module';
2
- const require = createRequire(import.meta.url);
3
- const bolt11Lib = require('bolt11');
1
+ import { decode } from 'light-bolt11-decoder';
4
2
  /** Decodes a BOLT-11 Lightning invoice to extract amount, payment hash, and expiry. */
5
3
  export function decodeBolt11(invoice) {
6
4
  try {
7
- const decoded = bolt11Lib.decode(invoice);
8
- let costSats = null;
9
- if (decoded.satoshis !== null && decoded.satoshis !== undefined) {
10
- costSats = decoded.satoshis;
11
- }
12
- else if (decoded.millisatoshis !== null && decoded.millisatoshis !== undefined) {
13
- costSats = Math.floor(Number(decoded.millisatoshis) / 1000);
14
- }
15
- const paymentHash = decoded.tagsObject.payment_hash ?? null;
16
- const expiry = typeof decoded.timeExpireDate === 'number' && typeof decoded.timestamp === 'number'
17
- ? decoded.timeExpireDate - decoded.timestamp
5
+ const { sections } = decode(invoice);
6
+ const amountSection = sections.find(s => s.name === 'amount');
7
+ const costSats = amountSection && 'value' in amountSection
8
+ ? Math.floor(Number(amountSection.value) / 1000)
9
+ : null;
10
+ const hashSection = sections.find(s => s.name === 'payment_hash');
11
+ const paymentHash = hashSection && 'value' in hashSection
12
+ ? hashSection.value
13
+ : null;
14
+ const expirySection = sections.find(s => s.name === 'expiry');
15
+ const expiry = expirySection && 'value' in expirySection
16
+ ? expirySection.value
18
17
  : 3600;
19
18
  return { costSats, paymentHash, expiry };
20
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bolt11.js","sourceRoot":"","sources":["../../src/l402/bolt11.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,SAAS,GAAG,OAAO,CAAC,QA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H,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;QAEpC,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAA;QAC7D,MAAM,QAAQ,GAAG,aAAa,IAAI,OAAO,IAAI,aAAa;YACxD,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YAChD,CAAC,CAAC,IAAI,CAAA;QAER,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,CAAA;QACjE,MAAM,WAAW,GAAG,WAAW,IAAI,OAAO,IAAI,WAAW;YACvD,CAAC,CAAE,WAAW,CAAC,KAAgB;YAC/B,CAAC,CAAC,IAAI,CAAA;QAER,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAA;QAC7D,MAAM,MAAM,GAAG,aAAa,IAAI,OAAO,IAAI,aAAa;YACtD,CAAC,CAAE,aAAa,CAAC,KAAgB;YACjC,CAAC,CAAC,IAAI,CAAA;QAER,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,CAAA;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IAC5D,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "402-mcp",
3
- "version": "3.15.3",
3
+ "version": "3.15.4",
4
4
  "mcpName": "dev.forgesworn/402-mcp",
5
5
  "description": "L402 + x402 client MCP - AI agents discover, pay for, and consume any payment-gated API",
6
6
  "type": "module",
@@ -34,9 +34,9 @@
34
34
  "@cashu/cashu-ts": "^3.6.1",
35
35
  "@modelcontextprotocol/ext-apps": "^1.3.1",
36
36
  "@modelcontextprotocol/sdk": "^1.26.0",
37
- "bolt11": "^1.4.1",
38
37
  "cors": "^2.8.5",
39
38
  "express": "^5.2.1",
39
+ "light-bolt11-decoder": "3.2.0",
40
40
  "nostr-tools": "^2.12.0",
41
41
  "qrcode": "^1.5.4",
42
42
  "zod": "^4.3.6"