@atlasauth/pca-fetch 0.1.0 → 0.3.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,8 +1,6 @@
1
1
  # @atlasauth/pca-fetch
2
2
 
3
- Runtime-neutral Web **Fetch** guard for Proof-Carrying Authority — verify an inbound PCActn in any
4
- `Request → Response` runtime: Cloudflare Workers, Deno, Bun, Vercel Edge, Netlify, a Lambda Function
5
- URL. Web platform only, no Node APIs.
3
+ Runtime-neutral Web Fetch guard for Proof-Carrying Authority. It verifies an inbound PCActn in any `Request -> Response` runtime (Cloudflare Workers, Deno, Bun, Vercel Edge, Netlify, a Lambda Function URL) using only the web platform, with no Node APIs. It wraps the `requirePCA` guard from `@atlasauth/pca`, which is default-deny: a required check that is not enforced denies.
6
4
 
7
5
  ## Install
8
6
 
@@ -10,28 +8,44 @@ URL. Web platform only, no Node APIs.
10
8
  npm i @atlasauth/pca-fetch
11
9
  ```
12
10
 
11
+ Depends on `@atlasauth/pca`.
12
+
13
13
  ## Usage
14
14
 
15
15
  ```ts
16
16
  import { withPCA } from '@atlasauth/pca-fetch';
17
+ import { memoryPcaStore } from '@atlasauth/pca';
17
18
 
18
19
  export default {
19
20
  fetch: withPCA(
20
21
  {
21
- audience: 'ins_acme',
22
- resolveGrant: async (grantRef) => grants.get(grantRef), // your grant store
23
- context: async () => ({ params: { amount: 20, currency: 'usd' }, budget: { B: 500, tau: 0 }, planAuthorized: true }),
22
+ audience: 'ins_acme', // the audience a PCActn must name
23
+ resolveGrant: async (grantRef) => grants.get(grantRef) ?? null, // your root-grant store
24
+ budgetStore: memoryPcaStore(), // replay counter + budget; use a shared store in production
25
+ hooks: { revocation: myRevocationChecker }, // e.g. built with createRevocationChecker from @atlasauth/pca
26
+ context: async (req, pcactn) => ({
27
+ plan: knownPlan(pcactn), // the plan your server knows for this action
28
+ planAuthorized: true, // only if the principal authorized that plan root
29
+ params: { amount: 20, currency: 'usd' },
30
+ risk: { reversibility: 1, blastRadius: 0, confidence: 1, semanticDistance: 0, taint: 0 },
31
+ budget: { B: 500, tau: 0, asOf: Date.now() },
32
+ }),
24
33
  },
25
- async (req, { pca }) => Response.json({ ok: true, verdict: pca.verdict }),
34
+ async (req, { pca }) => Response.json({ ok: true, verb: pca.pcactn.action.verb }),
26
35
  ),
27
36
  };
28
37
  ```
29
38
 
30
- On success your handler runs with `{ pca: { verdict, pcactn } }`; otherwise a `401/403` `Response`
31
- with a `WWW-Authenticate` challenge is returned. `createPcaFetchGuard(opts)` returns the raw guard
32
- result if you want to compose it into your own router. The client sends the PCActn as
33
- `PCA-Action: <base64url>` or a JSON body `{ pcactn }`.
39
+ On success your handler runs with `{ pca: { verdict, pcactn } }`. Otherwise a `401` or `403` `Response` is returned with a `WWW-Authenticate: PCA realm=...` challenge and a JSON body (shape it with `denyBody`). `createPcaFetchGuard(opts)` returns the raw guard result if you want to compose it into your own router.
40
+
41
+ The client sends the PCActn as a `PCA-Action: <base64url>` header (see `pcaHeaders` in `@atlasauth/pca`) or a JSON body `{ pcactn }`. By default the following checks must pass or the request is denied: `counter` (needs a `budgetStore`), `revocation` (needs `hooks.revocation`), `plan_root_authorized` (needs `context()` returning `planAuthorized: true`), plus audience, validity and grant binding. Options are those of `requirePCA`; see `@atlasauth/pca`. `insecureAllowUnenforced: true` disables the default-deny profile and is for local development only.
42
+
43
+ Nothing here authorizes on its own: the verifier decides, not the client's proof.
44
+
45
+ ## Status
46
+
47
+ Experimental. Part of Proof-Carrying Authority; the cryptography is unaudited.
34
48
 
35
- Nothing here authorizes on its own — the resource server's verifier (default-deny) decides.
49
+ ## License
36
50
 
37
- Part of Proof-Carrying Authority — see [`@atlasauth/pca`](../pca).
51
+ MIT - see LICENSE
package/dist/index.d.ts CHANGED
@@ -10,13 +10,13 @@
10
10
  * }) };
11
11
  *
12
12
  * It verifies the inbound PCActn with the framework-agnostic `requirePCA` guard from
13
- * `@atlasauth/backend` (default-deny) and, on success, calls your handler with the verdict + PCActn;
13
+ * `@atlasauth/pca` (default-deny) and, on success, calls your handler with the verdict + PCActn;
14
14
  * otherwise it returns a 401/403 `Response` with a WWW-Authenticate challenge. The client sends the
15
15
  * PCActn as `PCA-Action: <base64url>` (see `@atlasauth/pca` `pcaHeaders`) or a JSON body `{ pcactn }`.
16
16
  * Nothing here authorizes on its own — the resource server's verifier decides.
17
17
  */
18
- import { requirePCA, defaultExtract, memoryPcaStore } from '@atlasauth/backend';
19
- import type { PcaGuardResult, RequirePcaOptions, PcaStateStore } from '@atlasauth/backend';
18
+ import { requirePCA, defaultExtract, memoryPcaStore } from '@atlasauth/pca';
19
+ import type { PcaGuardResult, RequirePcaOptions, PcaStateStore } from '@atlasauth/pca';
20
20
  import type { PCActn } from '@atlasauth/pca';
21
21
  /** The verdict + PCActn handed to a guarded handler on success. */
22
22
  export interface PcaContextValue {
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@
11
11
  * }) };
12
12
  *
13
13
  * It verifies the inbound PCActn with the framework-agnostic `requirePCA` guard from
14
- * `@atlasauth/backend` (default-deny) and, on success, calls your handler with the verdict + PCActn;
14
+ * `@atlasauth/pca` (default-deny) and, on success, calls your handler with the verdict + PCActn;
15
15
  * otherwise it returns a 401/403 `Response` with a WWW-Authenticate challenge. The client sends the
16
16
  * PCActn as `PCA-Action: <base64url>` (see `@atlasauth/pca` `pcaHeaders`) or a JSON body `{ pcactn }`.
17
17
  * Nothing here authorizes on its own — the resource server's verifier decides.
@@ -20,10 +20,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.memoryPcaStore = exports.defaultExtract = exports.requirePCA = void 0;
21
21
  exports.createPcaFetchGuard = createPcaFetchGuard;
22
22
  exports.withPCA = withPCA;
23
- const backend_1 = require("@atlasauth/backend");
24
- Object.defineProperty(exports, "requirePCA", { enumerable: true, get: function () { return backend_1.requirePCA; } });
25
- Object.defineProperty(exports, "defaultExtract", { enumerable: true, get: function () { return backend_1.defaultExtract; } });
26
- Object.defineProperty(exports, "memoryPcaStore", { enumerable: true, get: function () { return backend_1.memoryPcaStore; } });
23
+ const pca_1 = require("@atlasauth/pca");
24
+ Object.defineProperty(exports, "requirePCA", { enumerable: true, get: function () { return pca_1.requirePCA; } });
25
+ Object.defineProperty(exports, "defaultExtract", { enumerable: true, get: function () { return pca_1.defaultExtract; } });
26
+ Object.defineProperty(exports, "memoryPcaStore", { enumerable: true, get: function () { return pca_1.memoryPcaStore; } });
27
27
  /** Adapt a web `Request` to the framework-agnostic `PcaRequestLike` (headers getter + parsed JSON body). */
28
28
  async function toPcaRequest(req) {
29
29
  let body;
@@ -48,7 +48,7 @@ function denyResponse(result, denyBody) {
48
48
  * (e.g. inside an existing router). Use `withPCA` for the common wrap-a-handler case.
49
49
  */
50
50
  function createPcaFetchGuard(options) {
51
- const guard = (0, backend_1.requirePCA)(options);
51
+ const guard = (0, pca_1.requirePCA)(options);
52
52
  return async (req) => guard(await toPcaRequest(req));
53
53
  }
54
54
  /** Wrap a Fetch handler so the inbound PCActn is verified first; on success your handler runs with the verdict. */
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAwCH,kDAGC;AAKD,0BAOC;AArDD,gDAAgF;AAuDvE,2FAvDA,oBAAU,OAuDA;AAAE,+FAvDA,wBAAc,OAuDA;AAAE,+FAvDA,wBAAc,OAuDA;AAxCnD,4GAA4G;AAC5G,KAAK,UAAU,YAAY,CAAC,GAAY;IACtC,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,wEAAwE;QACxE,IAAI,GAAG,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC;AAC7E,CAAC;AAED,SAAS,YAAY,CAAC,MAA8C,EAAE,QAAsC;IAC1G,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IAC1H,MAAM,OAAO,GAA2B,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;IAC/E,IAAI,MAAM,CAAC,eAAe;QAAE,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AG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC3C,OAAO,KAAK,EAAE,GAAY,EAAqB,EAAE;QAC/C,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,MAAM,CAAC,EAAE;YAAE,OAAO,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChG,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,28 @@
1
1
  {
2
2
  "name": "@atlasauth/pca-fetch",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Runtime-neutral Web Fetch guard for Proof-Carrying Authority: verify an inbound PCActn in any Request→Response runtime (Cloudflare Workers, Deno, Bun, Vercel Edge, Lambda).",
5
+ "keywords": [
6
+ "web fetch",
7
+ "cloudflare workers",
8
+ "deno",
9
+ "bun",
10
+ "edge",
11
+ "agent authorization",
12
+ "proof-carrying authority",
13
+ "pca",
14
+ "ai agents"
15
+ ],
16
+ "license": "MIT",
17
+ "homepage": "https://github.com/Atlas-Authorization/pca#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/Atlas-Authorization/pca/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/Atlas-Authorization/pca.git",
24
+ "directory": "packages/pca-fetch"
25
+ },
5
26
  "main": "./dist/index.js",
6
27
  "types": "./dist/index.d.ts",
7
28
  "exports": {
@@ -12,8 +33,7 @@
12
33
  "./package.json": "./package.json"
13
34
  },
14
35
  "dependencies": {
15
- "@atlasauth/pca": "0.1.0",
16
- "@atlasauth/backend": "0.3.0"
36
+ "@atlasauth/pca": "0.3.0"
17
37
  },
18
38
  "devDependencies": {
19
39
  "typescript": "^5.6.3",
@@ -21,8 +41,12 @@
21
41
  },
22
42
  "files": [
23
43
  "dist",
24
- "README.md"
44
+ "README.md",
45
+ "LICENSE"
25
46
  ],
47
+ "engines": {
48
+ "node": ">=20"
49
+ },
26
50
  "publishConfig": {
27
51
  "access": "public"
28
52
  },