@atlasauth/pca-express 0.1.0 → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Atlas Authorization
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @atlasauth/pca-express
2
2
 
3
- Express middleware for Proof-Carrying Authority: requirePCA() verifies the inbound PCActn and attaches the verdict, or answers 401/403 with a WWW-Authenticate challenge.
3
+ Express middleware for Proof-Carrying Authority. `pcaExpress()` verifies the inbound PCActn with the `requirePCA` guard from `@atlasauth/pca`, attaches `{ verdict, pcactn }` to the request on success, and otherwise answers `401` or `403` with a `WWW-Authenticate` challenge. It is default-deny: a required check that is not enforced denies.
4
4
 
5
5
  ## Install
6
6
 
@@ -10,27 +10,48 @@ npm i @atlasauth/pca-express
10
10
  npm i express
11
11
  ```
12
12
 
13
- `express` (v4 or v5) is an optional peer dependency.
13
+ `express` (v4 or v5) is an optional peer dependency; it is never imported, so the middleware works with any compatible request/response shape. Depends on `@atlasauth/pca`.
14
14
 
15
15
  ## Usage
16
16
 
17
17
  ```ts
18
18
  import { pcaExpress } from '@atlasauth/pca-express';
19
+ import { memoryPcaStore } from '@atlasauth/pca';
20
+
21
+ app.use(express.json());
19
22
 
20
23
  app.post(
21
24
  '/refunds',
22
25
  pcaExpress({
23
- audience: 'ins_acme', // this resource server's / instance id the PCActn must name
24
- resolveGrant, // (ref) => Capability — look up the root grant
25
- budgetStore, // per-holder replay/budget store
26
+ audience: 'ins_acme', // the audience a PCActn must name
27
+ resolveGrant: async (ref) => grants.get(ref) ?? null, // your root-grant store
28
+ budgetStore: memoryPcaStore(), // replay counter + budget; use a shared store in production
29
+ hooks: { revocation: myRevocationChecker }, // e.g. built with createRevocationChecker from @atlasauth/pca
30
+ context: async (req, pcactn) => ({
31
+ plan: knownPlan(pcactn), // the plan your server knows for this action
32
+ planAuthorized: true, // only if the principal authorized that plan root
33
+ params: req.body?.params,
34
+ risk: { reversibility: 1, blastRadius: 0, confidence: 1, semanticDistance: 0, taint: 0 },
35
+ budget: { B: 500, tau: 0, asOf: Date.now() },
36
+ }),
26
37
  }),
27
38
  (req, res) => {
28
- const { verdict, pcactn } = req.pca!; // attached on success
39
+ const { verdict, pcactn } = req.pca!; // attached on success (rename with `attachAs`)
29
40
  res.json({ ok: true });
30
41
  },
31
42
  );
32
43
  ```
33
44
 
34
- The client sends the PCActn as `PCA-Action: <base64url>` (see `@atlasauth/pca` `pcaHeaders`) or a JSON body `{ pcactn }` — the default extractor reads both. The middleware verifies and is default-deny (an unenforced required check denies); it is the verifier that decides, not the client's proof.
45
+ The client sends the PCActn as a `PCA-Action: <base64url>` header (see `pcaHeaders` in `@atlasauth/pca`) or a JSON body `{ pcactn }`; the default extractor reads both. Override the deny response with `onDeny(result, req, res)`. All other options are those of `requirePCA`; see `@atlasauth/pca`.
46
+
47
+ By default the `counter`, `revocation` and `plan_root_authorized` checks (plus audience, validity and grant binding) must pass, which is why `budgetStore`, `hooks.revocation` and `context()` are supplied above. `insecureAllowUnenforced: true` turns that off and is for local development only.
48
+
49
+ The verifier decides, not the client's proof.
50
+
51
+ ## Status
52
+
53
+ Experimental. Part of Proof-Carrying Authority; the cryptography is unaudited.
54
+
55
+ ## License
35
56
 
36
- Part of Proof-Carrying Authority — see `@atlasauth/pca`.
57
+ MIT - see LICENSE
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * pcaExpress({ audience: 'ins_acme', resolveGrant, budgetStore, hooks, context }),
6
6
  * (req, res) => { const { verdict, pcactn } = req.pca!; ... });
7
7
  *
8
- * It verifies the inbound PCActn with the framework-agnostic `requirePCA` guard from `@atlasauth/backend`
8
+ * It verifies the inbound PCActn with the framework-agnostic `requirePCA` guard from `@atlasauth/pca`
9
9
  * (default-deny: a required check that is unenforced DENIES) and, on success, attaches the verdict +
10
10
  * PCActn to `req[attachAs]` (default `req.pca`). On failure it answers 401/403 with a WWW-Authenticate
11
11
  * challenge. The client sends the PCActn as `PCA-Action: <base64url>` (see `@atlasauth/pca` `pcaHeaders`)
@@ -14,8 +14,8 @@
14
14
  * `express` is an OPTIONAL peer dependency and is never imported — the request/response/next shapes are
15
15
  * structural, so this stays compatible across Express 4 and 5.
16
16
  */
17
- import { requirePCA, defaultExtract, memoryPcaStore } from '@atlasauth/backend';
18
- import type { PcaGuardResult, RequirePcaOptions, PcaStateStore } from '@atlasauth/backend';
17
+ import { requirePCA, defaultExtract, memoryPcaStore } from '@atlasauth/pca';
18
+ import type { PcaGuardResult, RequirePcaOptions, PcaStateStore } from '@atlasauth/pca';
19
19
  import type { PCActn } from '@atlasauth/pca';
20
20
  /** Structural shim of an Express request (only `headers`/`body` are read; the rest passes through). */
21
21
  export interface ExpressRequestLike {
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * pcaExpress({ audience: 'ins_acme', resolveGrant, budgetStore, hooks, context }),
7
7
  * (req, res) => { const { verdict, pcactn } = req.pca!; ... });
8
8
  *
9
- * It verifies the inbound PCActn with the framework-agnostic `requirePCA` guard from `@atlasauth/backend`
9
+ * It verifies the inbound PCActn with the framework-agnostic `requirePCA` guard from `@atlasauth/pca`
10
10
  * (default-deny: a required check that is unenforced DENIES) and, on success, attaches the verdict +
11
11
  * PCActn to `req[attachAs]` (default `req.pca`). On failure it answers 401/403 with a WWW-Authenticate
12
12
  * challenge. The client sends the PCActn as `PCA-Action: <base64url>` (see `@atlasauth/pca` `pcaHeaders`)
@@ -18,15 +18,15 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.memoryPcaStore = exports.defaultExtract = exports.requirePCA = void 0;
20
20
  exports.pcaExpress = pcaExpress;
21
- const backend_1 = require("@atlasauth/backend");
22
- Object.defineProperty(exports, "requirePCA", { enumerable: true, get: function () { return backend_1.requirePCA; } });
23
- Object.defineProperty(exports, "defaultExtract", { enumerable: true, get: function () { return backend_1.defaultExtract; } });
24
- Object.defineProperty(exports, "memoryPcaStore", { enumerable: true, get: function () { return backend_1.memoryPcaStore; } });
21
+ const pca_1 = require("@atlasauth/pca");
22
+ Object.defineProperty(exports, "requirePCA", { enumerable: true, get: function () { return pca_1.requirePCA; } });
23
+ Object.defineProperty(exports, "defaultExtract", { enumerable: true, get: function () { return pca_1.defaultExtract; } });
24
+ Object.defineProperty(exports, "memoryPcaStore", { enumerable: true, get: function () { return pca_1.memoryPcaStore; } });
25
25
  /** Build an Express middleware that requires a valid PCActn on the request. */
26
26
  function pcaExpress(options) {
27
27
  const attachAs = options.attachAs ?? 'pca';
28
28
  const onDeny = options.onDeny;
29
- const guard = (0, backend_1.requirePCA)(options);
29
+ const guard = (0, pca_1.requirePCA)(options);
30
30
  return async (req, res, next) => {
31
31
  let result;
32
32
  try {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file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;YACX,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YACzB,OAAO;QACT,CAAC;QACD,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,MAAM,CAAC,eAAe;YAAE,GAAG,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;QAChF,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3F,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,27 @@
1
1
  {
2
2
  "name": "@atlasauth/pca-express",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Express middleware for Proof-Carrying Authority: requirePCA() verifies the inbound PCActn and attaches the verdict, or answers 401/403 with a WWW-Authenticate challenge.",
5
+ "keywords": [
6
+ "express",
7
+ "middleware",
8
+ "401",
9
+ "403",
10
+ "agent authorization",
11
+ "proof-carrying authority",
12
+ "pca",
13
+ "ai agents"
14
+ ],
15
+ "license": "MIT",
16
+ "homepage": "https://github.com/Atlas-Authorization/pca#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/Atlas-Authorization/pca/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Atlas-Authorization/pca.git",
23
+ "directory": "packages/pca-express"
24
+ },
5
25
  "main": "./dist/index.js",
6
26
  "types": "./dist/index.d.ts",
7
27
  "exports": {
@@ -12,8 +32,7 @@
12
32
  "./package.json": "./package.json"
13
33
  },
14
34
  "dependencies": {
15
- "@atlasauth/pca": "0.1.0",
16
- "@atlasauth/backend": "0.3.0"
35
+ "@atlasauth/pca": "0.2.0"
17
36
  },
18
37
  "peerDependencies": {
19
38
  "express": "^4 || ^5"
@@ -29,8 +48,12 @@
29
48
  },
30
49
  "files": [
31
50
  "dist",
32
- "README.md"
51
+ "README.md",
52
+ "LICENSE"
33
53
  ],
54
+ "engines": {
55
+ "node": ">=20"
56
+ },
34
57
  "publishConfig": {
35
58
  "access": "public"
36
59
  },