@ainra/middleware 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.
Files changed (2) hide show
  1. package/dist/index.js +5 -3
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  //! Two surfaces:
8
8
  //! * `ainraGate(verifier, opts)` → Connect/Express `(req, res, next)` middleware.
9
9
  //! * `checkRequest(verifier, bundle, opts)` → framework-agnostic `{ allow, reason?, verdict }` (edge/fetch).
10
- import { verdictEvent, serializeVerdictEvent, decodeInstance, verifyPresentation, isPresentationRef, splitPresentation, joinPresentation, presentationRef, POP_HEADER, PRIME_PATH, decisionRequestDigest, linkFromIndex, jwkThumbprintEd25519, } from "@ainra/sdk";
10
+ import { verdictEvent, serializeVerdictEvent, decodeInstance, verifyPresentation, isPresentationRef, splitPresentation, joinPresentation, presentationRef, POP_HEADER, PRIME_PATH, decisionRequestDigest, linkFromIndex, presentedKeyThumbprint, } from "@ainra/sdk";
11
11
  import { createHash } from "node:crypto";
12
12
  /** The default store: in memory, bounded, oldest-first eviction, and nothing outlives the credential it holds.
13
13
  * Bounded because whoever can mint valid bundles can otherwise fill it; eviction costs them nothing but costs an
@@ -282,11 +282,13 @@ export function ainraLinkGate(verifier, opts) {
282
282
  }
283
283
  let r;
284
284
  let tp = null;
285
- if (!key || key.length !== 32) {
285
+ // A key of either Link algorithm (D-082): 32 bytes Ed25519, 33 a compressed secp256k1 point. Anything else, or
286
+ // bytes that are no point on the curve, is not a key this gate verified.
287
+ tp = key ? presentedKeyThumbprint(key) : null;
288
+ if (!key || tp === null) {
286
289
  r = { verdict: "invalid", reason: "sig_invalid" };
287
290
  }
288
291
  else {
289
- tp = jwkThumbprintEd25519(key);
290
292
  let link = null;
291
293
  try {
292
294
  const { index, status } = await opts.source();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ainra/middleware",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "AINRA verifier middleware — a fail-closed gate (Connect/Express + framework-agnostic) that verifies an AINRA passport on a request, over @ainra/sdk. The verification wedge: local, offline, ~5-line integration.",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "test": "node --test"
15
15
  },
16
16
  "dependencies": {
17
- "@ainra/sdk": "^0.5.0"
17
+ "@ainra/sdk": "^0.6.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/node": "^26.1.1",