@atlasauth/pca-agent 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 +21 -0
- package/README.md +34 -10
- package/package.json +27 -3
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,8 @@
|
|
|
1
1
|
# @atlasauth/pca-agent
|
|
2
2
|
|
|
3
|
-
Agent-side client for Proof-Carrying Authority
|
|
3
|
+
Agent-side client for Proof-Carrying Authority (PCA). It commits a plan, builds and signs a PCActn (a proof-carrying action) for a plan node, posts it to a resource server, handles step-up approval, delegates attenuated authority to sub-agents, and checks ledger inclusion receipts.
|
|
4
|
+
|
|
5
|
+
The client talks to a resource server that exposes the PCA HTTP surface: `POST /v1/pca/plans`, `POST /v1/pca/actions` and `GET /v1/pca/stepups/:id` (the hosted Atlas API does, and so can your own server). `act` emits a proof; it does not authorize anything on its own. The resource server's verifier decides allow, step-up or deny.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
@@ -8,7 +10,7 @@ Agent-side client for Proof-Carrying Authority: commit a plan, act with a PCActn
|
|
|
8
10
|
npm i @atlasauth/pca-agent
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
Depends on
|
|
13
|
+
Depends on `@atlasauth/pca` (installed transitively).
|
|
12
14
|
|
|
13
15
|
## Usage
|
|
14
16
|
|
|
@@ -16,25 +18,47 @@ Depends on the core `@atlasauth/pca` (installed transitively).
|
|
|
16
18
|
import { createAgent } from '@atlasauth/pca-agent';
|
|
17
19
|
|
|
18
20
|
const client = createAgent({
|
|
19
|
-
grant, // principal-signed Capability
|
|
20
|
-
agentSecret, // Ed25519 secret (32 bytes) of the leaf holder
|
|
21
|
+
grant, // principal-signed Capability (see @atlasauth/pca)
|
|
22
|
+
agentSecret, // Ed25519 secret key (32 bytes) of the leaf holder
|
|
21
23
|
rsBaseUrl: 'https://api.example.com',
|
|
22
|
-
audience: 'ins_acme', // the
|
|
24
|
+
audience: 'ins_acme', // required: the id the resource server verifies against
|
|
23
25
|
});
|
|
24
26
|
|
|
25
27
|
// 1. Commit the principal-authorised plan (once).
|
|
26
28
|
await client.commitPlan([{ id: 'refund-1', verb: 'stripe.refund', resource: 'ch_123' }]);
|
|
27
29
|
|
|
28
|
-
// 2. Act on a plan node
|
|
30
|
+
// 2. Act on a plan node: builds and signs a PCActn, then POSTs it.
|
|
29
31
|
const res = await client.act('refund-1', { amount: 500 });
|
|
30
32
|
|
|
31
33
|
if (res.status === 'allowed') {
|
|
32
|
-
client.verifyReceipt(res.receipt);
|
|
34
|
+
client.verifyReceipt(res.receipt); // ledger inclusion proof -> boolean
|
|
33
35
|
} else if (res.status === 'step_up') {
|
|
34
|
-
const outcome = await client.awaitStepUp(res.stepupId);
|
|
36
|
+
const outcome = await client.awaitStepUp(res.stepupId); // polls for human co-sign
|
|
37
|
+
} else if (res.status === 'denied') {
|
|
38
|
+
console.log(res.verdict.reason);
|
|
35
39
|
}
|
|
40
|
+
|
|
41
|
+
// 3. Hand a narrower slice of authority to a sub-agent.
|
|
42
|
+
const sub = client.delegate({
|
|
43
|
+
toPublic: subAgentPublicKey,
|
|
44
|
+
addedCaveats: [{ type: 'ttl', secs: 60 }],
|
|
45
|
+
agentSecret: subAgentSecret,
|
|
46
|
+
});
|
|
36
47
|
```
|
|
37
48
|
|
|
38
|
-
`
|
|
49
|
+
`audience` is required because a PCActn only verifies at the audience it names, which stops it being replayed at another server. A fresh random nonce is stamped on each action by default, and the per-action counter only moves forward. `act` resolves to `{ status: 'error', error }` (a `PcaAgentError`) for local failures such as calling before `commitPlan` or an unknown node id. Pass `fetch` to supply your own HTTP client.
|
|
50
|
+
|
|
51
|
+
## API
|
|
52
|
+
|
|
53
|
+
- `createAgent(options)` returns an `AgentClient` with `commitPlan`, `act`, `awaitStepUp`, `delegate`, `verifyReceipt`, plus `grant`, `chain`, `counter`, `budget`, `planRoot`.
|
|
54
|
+
- Types: `ActResult`, `StepUpOutcome`, `Receipt`, `Verdict`, `ActSlots` (optional signed slots such as `caution`), `PcaAgentError`.
|
|
55
|
+
|
|
56
|
+
## Status
|
|
57
|
+
|
|
58
|
+
Experimental. The underlying cryptography in `@atlasauth/pca` has not been independently audited.
|
|
59
|
+
|
|
60
|
+
Source and issues: https://github.com/Atlas-Authorization/pca
|
|
61
|
+
|
|
62
|
+
## License
|
|
39
63
|
|
|
40
|
-
|
|
64
|
+
MIT - see LICENSE
|
package/package.json
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasauth/pca-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Agent-side client for Proof-Carrying Authority: commit a plan, act with a PCActn + threshold share, handle step-up, delegate to sub-agents, verify receipts.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agent client",
|
|
7
|
+
"step-up",
|
|
8
|
+
"delegation",
|
|
9
|
+
"receipts",
|
|
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-agent"
|
|
24
|
+
},
|
|
5
25
|
"main": "./dist/index.js",
|
|
6
26
|
"types": "./dist/index.d.ts",
|
|
7
27
|
"exports": {
|
|
@@ -12,7 +32,7 @@
|
|
|
12
32
|
"./package.json": "./package.json"
|
|
13
33
|
},
|
|
14
34
|
"dependencies": {
|
|
15
|
-
"@atlasauth/pca": "0.
|
|
35
|
+
"@atlasauth/pca": "0.3.0"
|
|
16
36
|
},
|
|
17
37
|
"devDependencies": {
|
|
18
38
|
"typescript": "^5.6.3",
|
|
@@ -20,8 +40,12 @@
|
|
|
20
40
|
},
|
|
21
41
|
"files": [
|
|
22
42
|
"dist",
|
|
23
|
-
"README.md"
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
24
45
|
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20"
|
|
48
|
+
},
|
|
25
49
|
"publishConfig": {
|
|
26
50
|
"access": "public"
|
|
27
51
|
},
|