@atlasauth/pca-agent 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,40 @@
1
- # Temporary Holding Version
1
+ # @atlasauth/pca-agent
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 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.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm i @atlasauth/pca-agent
9
+ ```
10
+
11
+ Depends on the core `@atlasauth/pca` (installed transitively).
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { createAgent } from '@atlasauth/pca-agent';
17
+
18
+ const client = createAgent({
19
+ grant, // principal-signed Capability
20
+ agentSecret, // Ed25519 secret (32 bytes) of the leaf holder
21
+ rsBaseUrl: 'https://api.example.com',
22
+ audience: 'ins_acme', // the resource-server / Atlas instance id the PCActn is FOR
23
+ });
24
+
25
+ // 1. Commit the principal-authorised plan (once).
26
+ await client.commitPlan([{ id: 'refund-1', verb: 'stripe.refund', resource: 'ch_123' }]);
27
+
28
+ // 2. Act on a plan node — builds + signs a PCActn and POSTs it to the resource server.
29
+ const res = await client.act('refund-1', { amount: 500 });
30
+
31
+ if (res.status === 'allowed') {
32
+ client.verifyReceipt(res.receipt); // check the ledger inclusion proof
33
+ } else if (res.status === 'step_up') {
34
+ const outcome = await client.awaitStepUp(res.stepupId); // poll for human co-sign
35
+ }
36
+ ```
37
+
38
+ `act` emits a proof-carrying action; it does not authorize on its own. The resource server's verifier decides allow / step-up / deny.
39
+
40
+ Part of Proof-Carrying Authority — see `@atlasauth/pca`.
@@ -0,0 +1,128 @@
1
+ import { type Capability, type CapabilityChain, type Caveat, type InclusionProof, type PCActn, type PlanNode } from '@atlasauth/pca';
2
+ export type FetchLike = (url: string, init?: {
3
+ method?: string;
4
+ headers?: Record<string, string>;
5
+ body?: string;
6
+ }) => Promise<{
7
+ status: number;
8
+ json(): Promise<unknown>;
9
+ }>;
10
+ export interface TrustBudget {
11
+ B: number;
12
+ tau: number;
13
+ asOf: number;
14
+ }
15
+ export interface Verdict {
16
+ allow: boolean;
17
+ checks?: Record<string, string>;
18
+ reason?: string;
19
+ budget?: TrustBudget;
20
+ [k: string]: unknown;
21
+ }
22
+ export interface Receipt {
23
+ grant_ref?: string;
24
+ index: number;
25
+ commit: string;
26
+ root: string;
27
+ size?: number;
28
+ inclusion_proof: InclusionProof;
29
+ }
30
+ export type StepUpOutcome = {
31
+ status: 'approved';
32
+ pcactn?: PCActn;
33
+ [k: string]: unknown;
34
+ } | {
35
+ status: 'denied';
36
+ [k: string]: unknown;
37
+ } | {
38
+ status: 'expired';
39
+ [k: string]: unknown;
40
+ } | {
41
+ status: 'timeout';
42
+ };
43
+ export type ActResult = {
44
+ status: 'allowed';
45
+ verdict: Verdict;
46
+ receipt: Receipt;
47
+ pcactn: PCActn;
48
+ } | {
49
+ status: 'denied';
50
+ verdict: Verdict;
51
+ httpStatus: number;
52
+ pcactn: PCActn;
53
+ } | {
54
+ status: 'step_up';
55
+ stepupId: string;
56
+ requiredT: number;
57
+ pcactn: PCActn;
58
+ } | {
59
+ status: 'error';
60
+ error: PcaAgentError;
61
+ };
62
+ export declare class PcaAgentError extends Error {
63
+ readonly code: 'no_plan' | 'unknown_node' | 'no_secret' | 'network' | 'bad_response' | 'build_failed';
64
+ readonly httpStatus?: number | undefined;
65
+ constructor(code: 'no_plan' | 'unknown_node' | 'no_secret' | 'network' | 'bad_response' | 'build_failed', message: string, httpStatus?: number | undefined);
66
+ }
67
+ export interface CreateAgentOptions {
68
+ grant: Capability;
69
+ /** Capability chain starting at the grant; defaults to `[grant]`. */
70
+ chain?: CapabilityChain;
71
+ /** Ed25519 secret key (32 bytes) of the leaf holder. Omit only for a sub-agent client you do not drive. */
72
+ agentSecret?: Uint8Array;
73
+ /** b64u public key of the agent (informational). */
74
+ agentPublic?: string;
75
+ rsBaseUrl: string;
76
+ /**
77
+ * REQUIRED. The audience the PCActns are FOR (wire v2 `aud`): for the hosted Atlas API this is the Atlas
78
+ * INSTANCE id (`ins_...`); for your own resource server, the id it passes to `requirePCA({ audience })`.
79
+ * A PCActn only verifies at the audience it names, so it cannot be replayed at another server / instance.
80
+ */
81
+ audience: string;
82
+ /** Lifetime stamped into each PCActn (`exp = iat + ttlMs`), default 20 min (covers the 15-min step-up window). */
83
+ ttlMs?: number;
84
+ /** Clock (epoch ms) for `iat`; default `Date.now`. */
85
+ now?: () => number;
86
+ /** Stamp a fresh random per-action `nonce` (default true). */
87
+ nonce?: boolean;
88
+ fetch?: FetchLike;
89
+ /** Initial counter (last used); the first act() uses counter+1. Default 0. */
90
+ counter?: number;
91
+ budget?: TrustBudget;
92
+ }
93
+ /** Optional signed slots of wire v2 (all signed into the PCActn when present; absent = current behaviour). */
94
+ export interface ActSlots {
95
+ /** Uncertainty attestation in [0,1]; MONOTONE (the verifier takes max with its own risk). */
96
+ caution?: number;
97
+ /** b64u(32) commitment to your rationale. */
98
+ rationaleCommitment?: string;
99
+ progressStep?: Record<string, unknown>;
100
+ prohibitionEvidence?: Record<string, unknown> | unknown[];
101
+ /** The tool signature you will dispatch to (hashed with `hashCanonical`) or its b64u(32) digest. */
102
+ toolBinding?: string;
103
+ /** Override the generated nonce. */
104
+ nonce?: string;
105
+ }
106
+ export interface AgentClient {
107
+ readonly grant: Capability;
108
+ readonly chain: CapabilityChain;
109
+ readonly agentPublic?: string;
110
+ readonly counter: number;
111
+ readonly budget: TrustBudget | undefined;
112
+ readonly planRoot: string | undefined;
113
+ commitPlan(nodes: PlanNode[]): Promise<{
114
+ planRoot: string;
115
+ }>;
116
+ act(nodeId: string, params?: Record<string, unknown>, slots?: ActSlots): Promise<ActResult>;
117
+ awaitStepUp(stepupId: string, opts?: {
118
+ pollMs?: number;
119
+ timeoutMs?: number;
120
+ }): Promise<StepUpOutcome>;
121
+ delegate(opts: {
122
+ toPublic: string;
123
+ addedCaveats?: Caveat[];
124
+ agentSecret?: Uint8Array;
125
+ }): AgentClient;
126
+ verifyReceipt(receipt: Receipt): boolean;
127
+ }
128
+ export declare function createAgent(opts: CreateAgentOptions): AgentClient;
package/dist/agent.js ADDED
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PcaAgentError = void 0;
4
+ exports.createAgent = createAgent;
5
+ const pca_1 = require("@atlasauth/pca");
6
+ class PcaAgentError extends Error {
7
+ code;
8
+ httpStatus;
9
+ constructor(code, message, httpStatus) {
10
+ super(message);
11
+ this.code = code;
12
+ this.httpStatus = httpStatus;
13
+ this.name = 'PcaAgentError';
14
+ }
15
+ }
16
+ exports.PcaAgentError = PcaAgentError;
17
+ const newNonce = () => {
18
+ const b = new Uint8Array(16);
19
+ globalThis.crypto.getRandomValues(b);
20
+ return Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');
21
+ };
22
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
23
+ function createAgent(opts) {
24
+ if (typeof opts.audience !== 'string' || opts.audience.length === 0) {
25
+ throw new PcaAgentError('build_failed', 'createAgent: `audience` is required (the resource-server / Atlas instance id PCActns are for)');
26
+ }
27
+ const base = opts.rsBaseUrl.replace(/\/+$/, '');
28
+ const doFetch = opts.fetch ?? ((u, i) => globalThis.fetch(u, i));
29
+ const chain = opts.chain ?? [opts.grant];
30
+ let counter = opts.counter ?? 0;
31
+ let budget = opts.budget;
32
+ let plan;
33
+ let planRoot;
34
+ const call = async (method, path, body) => {
35
+ const res = await doFetch(`${base}${path}`, {
36
+ method,
37
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
38
+ body: body === undefined ? undefined : JSON.stringify(body),
39
+ });
40
+ let json = {};
41
+ try {
42
+ json = ((await res.json()) ?? {});
43
+ }
44
+ catch {
45
+ /* non-JSON body */
46
+ }
47
+ return { status: res.status, json };
48
+ };
49
+ const client = {
50
+ grant: opts.grant,
51
+ chain,
52
+ agentPublic: opts.agentPublic,
53
+ get counter() {
54
+ return counter;
55
+ },
56
+ get budget() {
57
+ return budget;
58
+ },
59
+ get planRoot() {
60
+ return planRoot;
61
+ },
62
+ async commitPlan(nodes) {
63
+ const local = (0, pca_1.commitPlan)(nodes).root;
64
+ const res = await call('POST', '/v1/pca/plans', { grant_ref: opts.grant.id, nodes });
65
+ if (res.status < 200 || res.status >= 300) {
66
+ throw new PcaAgentError('bad_response', `plan commit failed (${res.status})`, res.status);
67
+ }
68
+ const remote = res.json.plan_root;
69
+ if (typeof remote === 'string' && remote !== local) {
70
+ throw new PcaAgentError('bad_response', 'server plan_root differs from the locally computed root', res.status);
71
+ }
72
+ plan = nodes;
73
+ planRoot = local;
74
+ return { planRoot: local };
75
+ },
76
+ async act(nodeId, params, slots) {
77
+ if (!plan)
78
+ return { status: 'error', error: new PcaAgentError('no_plan', 'commitPlan() first') };
79
+ if (!opts.agentSecret)
80
+ return { status: 'error', error: new PcaAgentError('no_secret', 'no agentSecret for this client') };
81
+ if (!plan.some((n) => n.id === nodeId)) {
82
+ return { status: 'error', error: new PcaAgentError('unknown_node', `unknown plan node ${nodeId}`) };
83
+ }
84
+ const next = counter + 1;
85
+ let pcactn;
86
+ try {
87
+ // The leaf `sig` IS the agent's threshold share: no separate agent share is carried.
88
+ pcactn = (0, pca_1.buildPCActn)({
89
+ grant: opts.grant,
90
+ chain,
91
+ plan,
92
+ nodeId,
93
+ params,
94
+ counter: next,
95
+ signerSecret: opts.agentSecret,
96
+ aud: opts.audience,
97
+ now: (opts.now ?? Date.now)(),
98
+ ...(opts.ttlMs !== undefined ? { ttlMs: opts.ttlMs } : {}),
99
+ ...(slots?.nonce !== undefined ? { nonce: slots.nonce } : opts.nonce !== false ? { nonce: newNonce() } : {}),
100
+ ...(slots?.caution !== undefined ? { caution: slots.caution } : {}),
101
+ ...(slots?.rationaleCommitment !== undefined ? { rationaleCommitment: slots.rationaleCommitment } : {}),
102
+ ...(slots?.progressStep !== undefined ? { progressStep: slots.progressStep } : {}),
103
+ ...(slots?.prohibitionEvidence !== undefined ? { prohibitionEvidence: slots.prohibitionEvidence } : {}),
104
+ ...(slots?.toolBinding !== undefined ? { toolBinding: slots.toolBinding } : {}),
105
+ });
106
+ }
107
+ catch (e) {
108
+ return { status: 'error', error: new PcaAgentError('build_failed', e.message) };
109
+ }
110
+ counter = next; // monotonic: never reuse a counter, even if the call fails
111
+ let res;
112
+ try {
113
+ res = await call('POST', '/v1/pca/actions', { pcactn });
114
+ }
115
+ catch (e) {
116
+ return { status: 'error', error: new PcaAgentError('network', e.message) };
117
+ }
118
+ const j = res.json;
119
+ if (res.status === 202 || j.status === 'step_up_required' || j.step_up_required === true) {
120
+ const id = (j.stepup_id ?? j.stepupId ?? j.id);
121
+ const t = (j.required_t ?? j.requiredT ?? j.t);
122
+ if (typeof id !== 'string') {
123
+ return { status: 'error', error: new PcaAgentError('bad_response', 'step-up response missing stepup_id', res.status) };
124
+ }
125
+ return { status: 'step_up', stepupId: id, requiredT: typeof t === 'number' ? t : 2, pcactn };
126
+ }
127
+ const verdict = (j.verdict ?? { allow: j.allow === true });
128
+ if (verdict.budget)
129
+ budget = verdict.budget;
130
+ if (res.status >= 200 && res.status < 300 && (j.allow === true || verdict.allow)) {
131
+ const receipt = j.receipt;
132
+ if (!receipt)
133
+ return { status: 'error', error: new PcaAgentError('bad_response', 'allow without receipt', res.status) };
134
+ return { status: 'allowed', verdict, receipt, pcactn };
135
+ }
136
+ return { status: 'denied', verdict, httpStatus: res.status, pcactn };
137
+ },
138
+ async awaitStepUp(stepupId, o = {}) {
139
+ const pollMs = o.pollMs ?? 1000;
140
+ const deadline = Date.now() + (o.timeoutMs ?? 5 * 60_000);
141
+ for (;;) {
142
+ const res = await call('GET', `/v1/pca/stepups/${encodeURIComponent(stepupId)}`);
143
+ const s = res.json.status;
144
+ if (s === 'approved' || s === 'denied' || s === 'expired') {
145
+ return { ...res.json, status: s };
146
+ }
147
+ if (Date.now() + pollMs > deadline)
148
+ return { status: 'timeout' };
149
+ await sleep(pollMs);
150
+ }
151
+ },
152
+ delegate({ toPublic, addedCaveats = [], agentSecret }) {
153
+ if (!opts.agentSecret)
154
+ throw new PcaAgentError('no_secret', 'cannot delegate without agentSecret');
155
+ const leaf = chain[chain.length - 1];
156
+ const child = (0, pca_1.delegate)(leaf, toPublic, addedCaveats, opts.agentSecret);
157
+ const sub = createAgent({
158
+ grant: opts.grant,
159
+ chain: [...chain, child],
160
+ agentSecret,
161
+ agentPublic: toPublic,
162
+ rsBaseUrl: base,
163
+ audience: opts.audience,
164
+ ...(opts.ttlMs !== undefined ? { ttlMs: opts.ttlMs } : {}),
165
+ ...(opts.now ? { now: opts.now } : {}),
166
+ ...(opts.nonce !== undefined ? { nonce: opts.nonce } : {}),
167
+ fetch: doFetch,
168
+ counter: 0,
169
+ });
170
+ return sub;
171
+ },
172
+ verifyReceipt(r) {
173
+ try {
174
+ return (0, pca_1.verifyLedgerInclusion)(r.root, r.inclusion_proof, r.commit);
175
+ }
176
+ catch {
177
+ return false;
178
+ }
179
+ },
180
+ };
181
+ return client;
182
+ }
183
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;;AA+HA,kCA4JC;AA3RD,wCAWwB;AA0CxB,MAAa,aAAc,SAAQ,KAAK;IAEpB;IAEA;IAHlB,YACkB,IAA4F,EAC5G,OAAe,EACC,UAAmB;QAEnC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAJ,IAAI,CAAwF;QAE5F,eAAU,GAAV,UAAU,CAAS;QAGnC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AATD,sCASC;AAyDD,MAAM,QAAQ,GAAG,GAAW,EAAE;IAC5B,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC5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EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACtC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,CAAC;aACX,CAAC,CAAC;YACH,OAAO,GAAG,CAAC;QACb,CAAC;QAED,aAAa,CAAC,CAAC;YACb,IAAI,CAAC;gBACH,OAAO,IAAA,2BAAqB,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;YACpE,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KACF,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './agent';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./agent"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "@atlasauth/pca-agent",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
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
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "dependencies": {
15
+ "@atlasauth/pca": "0.1.0"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.6.3",
19
+ "vitest": "^2.1.4"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc -p tsconfig.build.json",
30
+ "typecheck": "tsc -p tsconfig.json --noEmit",
31
+ "test": "vitest run"
32
+ }
6
33
  }