plenipo 0.5.0 → 0.5.1

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/README.md CHANGED
@@ -13,9 +13,9 @@ Plenipo gives AI agents the same thing, with one difference: the powers are neve
13
13
  Every mandate has a scope, limits and an expiry, every sub-delegation can only narrow it,
14
14
  and the person can revoke it at any time.
15
15
 
16
- > Status: 0.5, experimental. The cryptography is real; wallets, PID providers and banks in
16
+ > Status: 0.5.1, experimental. The cryptography is real; wallets, PID providers and banks in
17
17
  > the examples and the sandbox are test doubles. The code went through security reviews by independent
18
- > AI review agents (two rounds for 0.3, one for 0.5), and their findings are fixed (see
18
+ > AI review agents (two rounds for 0.3, two for 0.5), and their findings are fixed (see
19
19
  > [CHANGELOG.md](CHANGELOG.md)); it has not yet been audited by an external security firm. Do not use it
20
20
  > to protect real money or real data yet.
21
21
 
@@ -209,13 +209,25 @@ export function jsonMediaType(contentType) {
209
209
  const t = type.toLowerCase();
210
210
  if (!/^application\/([a-z0-9!#$&^_.-]+\+)?json$/.test(t))
211
211
  return null;
212
- for (const p of params) {
213
- const m = /^charset\s*=\s*"?([^"]*)"?$/i.exec(p);
214
- if (!m || m[1].toLowerCase() !== 'utf-8')
212
+ for (const p of params)
213
+ if (charsetOf(p)?.toLowerCase() !== 'utf-8')
215
214
  return null;
216
- }
217
215
  return t;
218
216
  }
217
+ /** The value of a `charset=` parameter, optionally quoted; undefined for any other parameter. No regex: the header comes from the network. */
218
+ function charsetOf(param) {
219
+ if (param.slice(0, 7).toLowerCase() !== 'charset')
220
+ return undefined;
221
+ const rest = param.slice(7).trimStart();
222
+ if (!rest.startsWith('='))
223
+ return undefined;
224
+ let v = rest.slice(1).trimStart();
225
+ if (v.startsWith('"'))
226
+ v = v.slice(1);
227
+ if (v.endsWith('"'))
228
+ v = v.slice(0, -1);
229
+ return v.includes('"') ? undefined : v;
230
+ }
219
231
  function makeContext(request, url, params, body) {
220
232
  let text;
221
233
  let json;
package/dist/testing.js CHANGED
@@ -376,14 +376,18 @@ function ts12EmandateValid(p) {
376
376
  }
377
377
  return true;
378
378
  }
379
+ /** Claim names a verifier sends: none of them may reach a prototype. */
380
+ const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
379
381
  function claimsFrame(claims) {
380
- const frame = {};
382
+ const frame = Object.create(null);
381
383
  for (const c of claims ?? []) {
382
384
  const [a, b] = c.path;
385
+ if (typeof a !== 'string' || UNSAFE_KEYS.has(a) || (b !== undefined && (typeof b !== 'string' || UNSAFE_KEYS.has(b))))
386
+ continue;
383
387
  if (b === undefined)
384
388
  frame[a] = true;
385
389
  else if (frame[a] !== true)
386
- (frame[a] ??= {})[b] = true;
390
+ (frame[a] ??= Object.create(null))[b] = true;
387
391
  }
388
392
  return frame;
389
393
  }
@@ -348,11 +348,16 @@ export async function checkCertificateRevocation(chain, opts, now) {
348
348
  }
349
349
  return report;
350
350
  }
351
+ const CRL_BEGIN = '-----BEGIN X509 CRL-----';
352
+ const CRL_END = '-----END X509 CRL-----';
353
+ /** PEM or base64 to DER. With indexOf, not a lazy regex, whose time grows with the square of a malformed input. */
351
354
  function toDer(c) {
352
355
  if (typeof c !== 'string')
353
356
  return c;
354
- const m = /-----BEGIN X509 CRL-----([\s\S]+?)-----END X509 CRL-----/.exec(c);
355
- return new Uint8Array(Buffer.from(m ? m[1] : c, 'base64'));
357
+ const start = c.indexOf(CRL_BEGIN);
358
+ const end = start < 0 ? -1 : c.indexOf(CRL_END, start + CRL_BEGIN.length);
359
+ const body = start >= 0 && end > start + CRL_BEGIN.length ? c.slice(start + CRL_BEGIN.length, end) : c;
360
+ return new Uint8Array(Buffer.from(body, 'base64'));
356
361
  }
357
362
  // --- OCSP -------------------------------------------------------------------------------------------------
358
363
  const SHA1 = '1.3.14.3.2.26';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plenipo",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Wallet-anchored mandates for AI agents: EUDI Wallet PID as root, enforced attenuation, expiry and revocation, MCP guard.",
5
5
  "keywords": [
6
6
  "eudi-wallet",
@@ -69,13 +69,13 @@
69
69
  "example:gateway": "tsx examples/bank-gateway.ts"
70
70
  },
71
71
  "dependencies": {
72
- "@owf/token-status-list": "^0.5.0",
73
- "@peculiar/asn1-ocsp": "^2.11.0",
74
- "@peculiar/asn1-schema": "^2.11.0",
75
- "@peculiar/asn1-x509": "^2.11.0",
76
- "@peculiar/x509": "^2.2.0",
72
+ "@owf/token-status-list": "^0.7.0",
73
+ "@peculiar/asn1-ocsp": "^3.0.0",
74
+ "@peculiar/asn1-schema": "^3.0.0",
75
+ "@peculiar/asn1-x509": "^3.0.0",
76
+ "@peculiar/x509": "^3.1.0",
77
77
  "@sd-jwt/crypto-nodejs": "^0.19.0",
78
- "@sd-jwt/sd-jwt-vc": "^0.23.0",
78
+ "@sd-jwt/sd-jwt-vc": "^0.24.3",
79
79
  "canonicalize": "^5.1.0",
80
80
  "jose": "^6.2.12",
81
81
  "reflect-metadata": "^0.2.2",
@@ -84,7 +84,7 @@
84
84
  "devDependencies": {
85
85
  "@electric-sql/pglite": "^0.5.10",
86
86
  "@modelcontextprotocol/sdk": "^1.32.1",
87
- "@owf/eudi-lote": "^0.5.0",
87
+ "@owf/eudi-lote": "^0.6.0",
88
88
  "@types/express": "^5.0.3",
89
89
  "@types/node": "^26.6.5",
90
90
  "@types/pg": "^8.23.1",