@atlasauth/pca-a2a 0.0.0-stage → 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,3 +1,64 @@
1
- # Temporary Holding Version
1
+ # @atlasauth/pca-a2a
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
+ A2A (Agent2Agent) adapter for Proof-Carrying Authority (PCA). A2A defines how agents discover each other and exchange tasks; it does not prove that a relayed request is authorized by the principal behind it. This package binds PCA proofs onto three A2A surfaces, failing closed throughout:
4
+
5
+ 1. **Proof-carrying tasks** - attach a PCActn (a signed single-action proof with its capability chain) to a Task or Message under a namespaced `metadata` key, and verify it on receipt.
6
+ 2. **Signed Agent Cards** - issue and validate an A2A `AgentCardSignature` (a detached JWS, via `jose`) whose protected header commits to the agent's PCA passport id.
7
+ 3. **AP2 payment profile** - map a PCActn to an AP2-shaped Payment Mandate that carries its authority by reference to the proof.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm i @atlasauth/pca-a2a
13
+ ```
14
+
15
+ Depends on `@atlasauth/pca` and `jose` (installed transitively). For the full AP2 Intent/Cart/Payment chain and settlement hooks, see `@atlasauth/pca-ap2`.
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import { buildPCActn } from '@atlasauth/pca';
21
+ import {
22
+ attachPcaToA2ATask, pcaA2AMiddleware,
23
+ issueSignedAgentCard, verifyAgentCard,
24
+ a2aPaymentMandateFromPca, verifyA2APaymentMandate,
25
+ } from '@atlasauth/pca-a2a';
26
+
27
+ // Sender: build a PCActn with @atlasauth/pca, then ride it on the task.
28
+ const pcActn = buildPCActn({ grant, chain: [grant], plan, nodeId: 'buy-1', counter: 1,
29
+ signerSecret: agentSecret, aud: 'my-rs' });
30
+ const task = attachPcaToA2ATask({ id: 't1', status: { state: 'submitted' } }, pcActn);
31
+
32
+ // Receiver: guard incoming tasks. Pin the principal you trust.
33
+ const guard = pcaA2AMiddleware({ aud: 'my-rs', expectedRootIssuer: principalPublicKey });
34
+ const verdict = await guard(task); // { ok: true, result, pcActn } | { ok: false, reason }
35
+
36
+ // Signed Agent Card (key is a jose KeyLike, Uint8Array or JWK).
37
+ const card = await issueSignedAgentCard({ name: 'Buyer', url: 'https://a.example' }, privateKey,
38
+ { passport: { id: 'pp_1' } });
39
+ await verifyAgentCard(card, { key: publicKey }); // { ok: true, passportRef: 'pp_1', ... }
40
+
41
+ // Payment mandate that points at the PCActn.
42
+ const mandate = a2aPaymentMandateFromPca(pcActn, {
43
+ amount: { currency: 'USD', value: 120 }, paymentMethod: { type: 'card' }, merchant: 'acme',
44
+ });
45
+ await verifyA2APaymentMandate(mandate, pcActn, { aud: 'my-rs', expectedRootIssuer: principalPublicKey });
46
+ ```
47
+
48
+ By default a guard requires a proof (`require: true`); with `require: false` a task without a proof passes, but a proof that is present and invalid is still rejected. Always pin `expectedRootIssuer` (or `grant`): otherwise the chain root is taken from the proof itself and only proves internal consistency, not that a principal you trust issued it.
49
+
50
+ ## API
51
+
52
+ - Tasks: `attachPcaToA2ATask`, `attachPcaToA2AMessage`, `extractPca`, `extractPcaFromMessage`, `verifyA2ATask`, `pcaA2AMiddleware`, `PCA_A2A_EXTENSION_URI`.
53
+ - Agent Cards: `issueSignedAgentCard`, `verifyAgentCard` (verify with a single `key` or a `jwks`).
54
+ - Payments: `a2aPaymentMandateFromPca`, `pcaBindingFromA2APaymentMandate`, `verifyA2APaymentMandate`, `A2A_AP2_CONTEXT`.
55
+
56
+ ## Status
57
+
58
+ Experimental. The A2A object model here is structural and permissive, not a full A2A SDK. The Payment Mandate shape follows the AP2 vocabulary but its JSON-LD context is a placeholder and PCA-specific fields live in a non-standard `x_pca` extension; validate against the official AP2 schemas before production use. The cryptography is unaudited.
59
+
60
+ Source and issues: https://github.com/Atlas-Authorization/pca
61
+
62
+ ## License
63
+
64
+ MIT - see LICENSE
@@ -0,0 +1,288 @@
1
+ /**
2
+ * @atlasauth/pca-a2a — A2A (Agent2Agent) adapter for PCA.
3
+ *
4
+ * ┌──────────────────────────────────────────────────────────────────────────────────────────────┐
5
+ * │ PCA GOVERNS. A2A is the agent-to-agent delegation + task wire. AP2 carries the payment mandate. │
6
+ * └──────────────────────────────────────────────────────────────────────────────────────────────┘
7
+ *
8
+ * A2A (Agent2Agent — originated at Google, donated to the Linux Foundation; v1.0 GA Apr 2026) is the
9
+ * open protocol for how autonomous agents discover one another (the Agent Card at
10
+ * `/.well-known/agent-card.json`), hand each other work (Tasks carrying Messages), and settle payment
11
+ * (the AP2 payment profile). A2A says HOW agents talk; it does not, on its own, prove that a request an
12
+ * agent relays is actually AUTHORIZED by the principal behind it. That is exactly the gap PCA closes.
13
+ *
14
+ * This adapter binds PCA's proof-carrying authority onto A2A's three surfaces, FAIL-CLOSED throughout:
15
+ *
16
+ * 1. Proof-carrying A2A Tasks — a PCActn (a signed, single-action proof of authority with its
17
+ * attenuating capability chain) rides on a Task's metadata. A receiving agent re-verifies it before
18
+ * acting, so a relayed task cannot exceed what the principal actually delegated.
19
+ * 2. Signed Agent Cards — an A2A Agent Card is validated against an `AgentCardSignature` (a JWS over
20
+ * the card, per A2A 1.0) via `jose`, and an issued card embeds a reference to the agent's PCA
21
+ * passport, so the card points at verifiable proof-of-authority instead of being a self-declaration.
22
+ * 3. AP2 payment profile — a PCActn maps to an AP2 Payment Mandate whose authority is carried by
23
+ * reference to the proof (the mandate is PCA-verifiable: resolve the referenced PCActn and verify it).
24
+ *
25
+ * The full AP2 Intent→Cart→Payment VDC chain, its non-amplifying-narrowing verifier and the settlement
26
+ * rails live in `@atlasauth/pca-ap2`; this module does NOT duplicate them. It emits only the single
27
+ * Payment-Mandate profile an A2A payment Task needs, using the SAME field vocabulary (`amount`,
28
+ * `payment_method`, `human_present`, `merchant`, namespaced `x_pca`) so the two stay wire-compatible.
29
+ * When `@atlasauth/pca-ap2` is on the dependency path, prefer composing with its full chain + settlement
30
+ * backends and treat this profile as the A2A-task envelope around a verified PCActn.
31
+ */
32
+ import { type Capability, type PCActn, type VerifyResult } from '@atlasauth/pca';
33
+ import { type JSONWebKeySet, type JWK, type KeyLike } from 'jose';
34
+ /**
35
+ * The URI-namespaced A2A extension key a PCActn rides under on a Task's / Message's `metadata`. A2A
36
+ * extensions are identified by URI and carried in `metadata`, so a non-PCA-aware peer simply ignores it.
37
+ */
38
+ export declare const PCA_A2A_EXTENSION_URI: "https://atlasauth.net/a2a/ext/pca/v2";
39
+ /** An A2A message part (text / file / data). Structural only; `kind` discriminates in the wild. */
40
+ export interface A2APart {
41
+ kind: string;
42
+ [k: string]: unknown;
43
+ }
44
+ /** An A2A Message — a turn exchanged within a Task. */
45
+ export interface A2AMessage {
46
+ role: 'user' | 'agent';
47
+ parts: A2APart[];
48
+ messageId?: string;
49
+ kind?: 'message';
50
+ taskId?: string;
51
+ contextId?: string;
52
+ metadata?: Record<string, unknown>;
53
+ }
54
+ /** An A2A Task status. */
55
+ export interface A2ATaskStatus {
56
+ state: string;
57
+ message?: A2AMessage;
58
+ timestamp?: string;
59
+ }
60
+ /** An A2A Task — the unit of work one agent hands another. */
61
+ export interface A2ATask {
62
+ id: string;
63
+ contextId?: string;
64
+ kind?: 'task';
65
+ status: A2ATaskStatus;
66
+ history?: A2AMessage[];
67
+ metadata?: Record<string, unknown>;
68
+ }
69
+ /** Attach a PCActn to a Task (returns a copy; the input is not mutated). */
70
+ export declare function attachPcaToA2ATask(task: A2ATask, pcActn: PCActn): A2ATask;
71
+ /** Attach a PCActn to a single Message (returns a copy; the input is not mutated). */
72
+ export declare function attachPcaToA2AMessage(message: A2AMessage, pcActn: PCActn): A2AMessage;
73
+ /**
74
+ * Extract the PCActn carried on a Task. Looks, in order, at the Task metadata, the current
75
+ * `status.message` metadata, then the most recent history message's metadata. Returns `undefined`
76
+ * when no well-formed proof is present (the verify step then fails closed).
77
+ */
78
+ export declare function extractPca(task: A2ATask): PCActn | undefined;
79
+ /** Extract the PCActn carried on a single Message (fail-closed). */
80
+ export declare function extractPcaFromMessage(message: A2AMessage): PCActn | undefined;
81
+ /** Options shared by every PCActn verification surface in this module. */
82
+ export interface PcaVerifyOptions {
83
+ /** This resource server / Atlas instance id. Compared against the PCActn's signed `aud` (fail-closed). */
84
+ aud: string;
85
+ /** Verification clock (epoch ms). Default `Date.now()`. */
86
+ now?: number;
87
+ /**
88
+ * The trusted root grant (capability). When omitted, the grant is taken from the embedded chain root
89
+ * (`cap_chain[0]`); the full chain cryptography is still verified either way, but pinning `grant` (or
90
+ * `expectedRootIssuer`) is what ties the proof to a KNOWN principal rather than whatever the chain claims.
91
+ */
92
+ grant?: Capability;
93
+ /** When set, the chain root's issuer MUST equal this principal key (b64u), else verification fails. */
94
+ expectedRootIssuer?: string;
95
+ }
96
+ /** The result of verifying a proof-carrying A2A artifact. */
97
+ export interface A2AVerification {
98
+ ok: boolean;
99
+ reason?: string;
100
+ /** The underlying PCA core verification result (present once a PCActn was found and evaluated). */
101
+ result?: VerifyResult;
102
+ /** The extracted PCActn (present when one was carried). */
103
+ pcActn?: PCActn;
104
+ }
105
+ /**
106
+ * Verify the proof-carrying action on an A2A Task. Fail-closed: a Task with no attached PCActn, or one
107
+ * whose PCActn does not verify (bad signature, wrong audience, expired, out-of-plan, tampered chain …),
108
+ * is rejected.
109
+ */
110
+ export declare function verifyA2ATask(task: A2ATask, opts: PcaVerifyOptions): Promise<A2AVerification>;
111
+ /** Configuration for the server-side A2A guard. */
112
+ export interface PcaA2AMiddlewareOptions extends PcaVerifyOptions {
113
+ /**
114
+ * When `true` (the default), a Task MUST carry a valid PCActn or it is rejected. When `false`, a Task
115
+ * with NO proof is allowed through — but a Task that DOES carry a proof must still verify (a present
116
+ * but invalid/tampered proof is always rejected; this guard never fails open on tampering).
117
+ */
118
+ require?: boolean;
119
+ }
120
+ /** The per-Task guard returned by {@link pcaA2AMiddleware}. */
121
+ export type PcaA2AGuard = (task: A2ATask) => Promise<A2AVerification>;
122
+ /**
123
+ * Build a server guard that verifies the proof-carrying action on each incoming A2A Task and rejects
124
+ * unauthorized ones. Framework-agnostic: wire the returned function into your JSON-RPC `message/send` /
125
+ * `tasks/send` handler and reject when `ok` is false.
126
+ */
127
+ export declare function pcaA2AMiddleware(opts: PcaA2AMiddlewareOptions): PcaA2AGuard;
128
+ /** A reference to the agent's PCA passport (see `@atlasauth/pca` `AgentPassport`). */
129
+ export interface A2APassportRef {
130
+ /** The content-addressed passport id (`AgentPassport.id`). */
131
+ id: string;
132
+ /** Optional URL where the full, verifiable passport can be resolved. */
133
+ uri?: string;
134
+ }
135
+ /**
136
+ * An A2A Agent Card signature: a detached JWS (JWS JSON serialization) over the canonicalized card with
137
+ * its `signatures` removed, per A2A 1.0. `protected` is the base64url JWS protected header; `signature`
138
+ * is the base64url signature. The payload is detached (recomputed from the card on verify).
139
+ */
140
+ export interface AgentCardSignature {
141
+ protected: string;
142
+ signature: string;
143
+ header?: Record<string, unknown>;
144
+ }
145
+ /** A minimal, permissive A2A Agent Card. Real cards carry many more fields; all are preserved + signed. */
146
+ export interface AgentCard {
147
+ name: string;
148
+ description?: string;
149
+ url?: string;
150
+ version?: string;
151
+ /** The PCA passport this card's authority is rooted in (embedded + signed by {@link issueSignedAgentCard}). */
152
+ pcaPassport?: A2APassportRef;
153
+ signatures?: AgentCardSignature[];
154
+ [k: string]: unknown;
155
+ }
156
+ /** A key usable to verify a card signature. A plain JWK is imported; other forms are passed through. */
157
+ export type VerifyKeyInput = KeyLike | Uint8Array | JWK;
158
+ /** A key usable to sign a card. A plain JWK is imported; other forms are passed through. */
159
+ export type SignKeyInput = KeyLike | Uint8Array | JWK;
160
+ export interface IssueAgentCardOptions {
161
+ /** JWS algorithm for the signature. Default `'EdDSA'`. */
162
+ alg?: string;
163
+ /** The PCA passport reference to embed so the card points at verifiable proof-of-authority. */
164
+ passport?: A2APassportRef | {
165
+ id: string;
166
+ };
167
+ /** Optional JWS `kid` (set it when verifiers resolve the key from a JWKS). */
168
+ kid?: string;
169
+ }
170
+ /**
171
+ * Issue a signed A2A Agent Card. Embeds the PCA passport reference into the card (`pcaPassport`) AND into
172
+ * the signed JWS protected header, then signs the canonicalized card (minus `signatures`) with `jose`,
173
+ * appending the detached-payload `AgentCardSignature`. Because the passport reference is covered by the
174
+ * signature, the card is a verifiable pointer to proof-of-authority — not a self-declaration.
175
+ */
176
+ export declare function issueSignedAgentCard(card: AgentCard, signingKey: SignKeyInput, opts?: IssueAgentCardOptions): Promise<AgentCard>;
177
+ export interface VerifyAgentCardOptions {
178
+ /** A JWKS to resolve the signing key from (matched by the JWS `kid` / `alg`). */
179
+ jwks?: JSONWebKeySet;
180
+ /** A single verification key (JWK, raw secret, or a crypto key). */
181
+ key?: VerifyKeyInput;
182
+ /** Expected JWS algorithm for `importJWK` of a plain JWK `key` (default `'EdDSA'`). */
183
+ alg?: string;
184
+ }
185
+ /** The outcome of validating a signed Agent Card. */
186
+ export interface AgentCardVerification {
187
+ ok: boolean;
188
+ reason?: string;
189
+ /** The passport id recovered from a verified signature's protected header (proof-of-authority pointer). */
190
+ passportRef?: string;
191
+ /** The passport reference embedded in the (verified) card body, when present. */
192
+ passport?: A2APassportRef;
193
+ }
194
+ /**
195
+ * Validate an A2A Agent Card against its `AgentCardSignature`(s). Fail-closed: a card with no signatures,
196
+ * an unresolvable key, or ANY signature that does not verify is rejected. Every present signature must
197
+ * verify over the canonicalized card (minus `signatures`). On success, returns the PCA passport id the
198
+ * signature commits to so a caller can resolve + check it against a `PassportRegistry`.
199
+ */
200
+ export declare function verifyAgentCard(card: AgentCard, opts: VerifyAgentCardOptions): Promise<AgentCardVerification>;
201
+ /**
202
+ * JSON-LD contexts for the AP2 VDC envelope — the SAME values `@atlasauth/pca-ap2` uses, so this profile
203
+ * is wire-compatible with the full AP2 chain. The second entry is a placeholder for the canonical AP2
204
+ * context URL (replace before production).
205
+ */
206
+ export declare const A2A_AP2_CONTEXT: readonly string[];
207
+ /** ISO-4217 currency + decimal value (use minor units in production to avoid float drift). */
208
+ export interface A2AMonetaryAmount {
209
+ currency: string;
210
+ value: number;
211
+ }
212
+ /** The payment instrument an AP2 Payment Mandate authorizes (never a raw PAN). */
213
+ export interface A2APaymentMethod {
214
+ type: string;
215
+ display?: string;
216
+ token?: string;
217
+ }
218
+ /**
219
+ * The PCA-native binding carried inside the Payment Mandate's `x_pca` extension. It makes the mandate
220
+ * PCA-VERIFIABLE: a verifier resolves `pcactn_digest` to the referenced PCActn and verifies that proof,
221
+ * rather than trusting the mandate on its own. NON-STANDARD by construction (namespaced `x_pca`).
222
+ */
223
+ export interface PcaPaymentBinding {
224
+ /** `pcactnDigest()` of the PCActn whose authority backs this mandate. */
225
+ pcactn_digest: string;
226
+ /** The resource server / instance the backing PCActn is audience-bound to. */
227
+ aud: string;
228
+ /** The backing action's verb / resource / params digest (from the PCActn's committed plan node). */
229
+ verb: string;
230
+ resource: string;
231
+ params_digest: string;
232
+ /** The grant the backing PCActn's chain is rooted at. */
233
+ grant_ref: string;
234
+ /** The acting (leaf) holder key, b64u — the agent the authority was ultimately delegated to. */
235
+ leaf_holder: string;
236
+ }
237
+ /** AP2 Payment Mandate contents (credentialSubject). Mirrors `@atlasauth/pca-ap2`'s field vocabulary. */
238
+ export interface A2APaymentMandateContents {
239
+ amount: A2AMonetaryAmount;
240
+ payment_method: A2APaymentMethod;
241
+ /**
242
+ * The AP2 human-present modality. MAPPING: a PCActn carrying a risk-adaptive `threshold` (a
243
+ * guardian/principal co-signature) ⇒ `human_present = true`; an agent-only (t=1) action ⇒ `false`.
244
+ * Override explicitly via `humanPresent`.
245
+ */
246
+ human_present: boolean;
247
+ merchant?: string;
248
+ /** The PCA-verifiable backreference (see {@link PcaPaymentBinding}). */
249
+ x_pca: PcaPaymentBinding;
250
+ }
251
+ /** An AP2 Payment Mandate VDC carrying a PCA-verifiable backreference. */
252
+ export interface A2APaymentMandate {
253
+ '@context': readonly string[];
254
+ type: readonly ['VerifiableCredential', 'PaymentMandate'];
255
+ /** Issuer (payer / acting agent) public key, b64u. Defaults to the PCActn's leaf holder. */
256
+ issuer: string;
257
+ issuanceDate: string;
258
+ credentialSubject: A2APaymentMandateContents;
259
+ }
260
+ export interface PaymentMandateOptions {
261
+ /** The amount to authorize. */
262
+ amount: A2AMonetaryAmount;
263
+ /** The payment instrument. */
264
+ paymentMethod: A2APaymentMethod;
265
+ /** The merchant, if constrained. */
266
+ merchant?: string;
267
+ /** Override the human-present modality (else derived from whether the PCActn carries a `threshold`). */
268
+ humanPresent?: boolean;
269
+ /** Override the VDC issuer (defaults to the PCActn's leaf holder key). */
270
+ issuerPublic?: string;
271
+ /** Issuance clock (epoch ms). Default `Date.now()`. */
272
+ now?: number;
273
+ }
274
+ /**
275
+ * Map a PCA proof (a PCActn) to an AP2 Payment Mandate so an A2A payment Task can carry it. The mandate's
276
+ * authority is carried BY REFERENCE: `x_pca.pcactn_digest` binds it to the PCActn, and the mandate is
277
+ * verified by resolving + verifying that proof (see {@link verifyA2APaymentMandate}).
278
+ */
279
+ export declare function a2aPaymentMandateFromPca(pcActn: PCActn, opts: PaymentMandateOptions): A2APaymentMandate;
280
+ /** Read the PCA binding back out of an AP2 Payment Mandate (the round-trip of `x_pca`). */
281
+ export declare function pcaBindingFromA2APaymentMandate(mandate: A2APaymentMandate): PcaPaymentBinding;
282
+ /**
283
+ * Verify an AP2 Payment Mandate against the PCActn it references. Fail-closed: the mandate's
284
+ * `x_pca.pcactn_digest` MUST equal `pcactnDigest(pcActn)` (so the mandate is bound to THIS proof), and
285
+ * the PCActn itself must verify (signature, audience, validity, chain, plan inclusion). This is what makes
286
+ * the AP2 payment mandate PCA-verifiable rather than a bare assertion.
287
+ */
288
+ export declare function verifyA2APaymentMandate(mandate: A2APaymentMandate, pcActn: PCActn, opts: PcaVerifyOptions): Promise<A2AVerification>;
package/dist/index.js ADDED
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+ /**
3
+ * @atlasauth/pca-a2a — A2A (Agent2Agent) adapter for PCA.
4
+ *
5
+ * ┌──────────────────────────────────────────────────────────────────────────────────────────────┐
6
+ * │ PCA GOVERNS. A2A is the agent-to-agent delegation + task wire. AP2 carries the payment mandate. │
7
+ * └──────────────────────────────────────────────────────────────────────────────────────────────┘
8
+ *
9
+ * A2A (Agent2Agent — originated at Google, donated to the Linux Foundation; v1.0 GA Apr 2026) is the
10
+ * open protocol for how autonomous agents discover one another (the Agent Card at
11
+ * `/.well-known/agent-card.json`), hand each other work (Tasks carrying Messages), and settle payment
12
+ * (the AP2 payment profile). A2A says HOW agents talk; it does not, on its own, prove that a request an
13
+ * agent relays is actually AUTHORIZED by the principal behind it. That is exactly the gap PCA closes.
14
+ *
15
+ * This adapter binds PCA's proof-carrying authority onto A2A's three surfaces, FAIL-CLOSED throughout:
16
+ *
17
+ * 1. Proof-carrying A2A Tasks — a PCActn (a signed, single-action proof of authority with its
18
+ * attenuating capability chain) rides on a Task's metadata. A receiving agent re-verifies it before
19
+ * acting, so a relayed task cannot exceed what the principal actually delegated.
20
+ * 2. Signed Agent Cards — an A2A Agent Card is validated against an `AgentCardSignature` (a JWS over
21
+ * the card, per A2A 1.0) via `jose`, and an issued card embeds a reference to the agent's PCA
22
+ * passport, so the card points at verifiable proof-of-authority instead of being a self-declaration.
23
+ * 3. AP2 payment profile — a PCActn maps to an AP2 Payment Mandate whose authority is carried by
24
+ * reference to the proof (the mandate is PCA-verifiable: resolve the referenced PCActn and verify it).
25
+ *
26
+ * The full AP2 Intent→Cart→Payment VDC chain, its non-amplifying-narrowing verifier and the settlement
27
+ * rails live in `@atlasauth/pca-ap2`; this module does NOT duplicate them. It emits only the single
28
+ * Payment-Mandate profile an A2A payment Task needs, using the SAME field vocabulary (`amount`,
29
+ * `payment_method`, `human_present`, `merchant`, namespaced `x_pca`) so the two stay wire-compatible.
30
+ * When `@atlasauth/pca-ap2` is on the dependency path, prefer composing with its full chain + settlement
31
+ * backends and treat this profile as the A2A-task envelope around a verified PCActn.
32
+ */
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.A2A_AP2_CONTEXT = exports.PCA_A2A_EXTENSION_URI = void 0;
35
+ exports.attachPcaToA2ATask = attachPcaToA2ATask;
36
+ exports.attachPcaToA2AMessage = attachPcaToA2AMessage;
37
+ exports.extractPca = extractPca;
38
+ exports.extractPcaFromMessage = extractPcaFromMessage;
39
+ exports.verifyA2ATask = verifyA2ATask;
40
+ exports.pcaA2AMiddleware = pcaA2AMiddleware;
41
+ exports.issueSignedAgentCard = issueSignedAgentCard;
42
+ exports.verifyAgentCard = verifyAgentCard;
43
+ exports.a2aPaymentMandateFromPca = a2aPaymentMandateFromPca;
44
+ exports.pcaBindingFromA2APaymentMandate = pcaBindingFromA2APaymentMandate;
45
+ exports.verifyA2APaymentMandate = verifyA2APaymentMandate;
46
+ const pca_1 = require("@atlasauth/pca");
47
+ const jose_1 = require("jose");
48
+ // ===================================================================================================
49
+ // Extension identifier
50
+ // ===================================================================================================
51
+ /**
52
+ * The URI-namespaced A2A extension key a PCActn rides under on a Task's / Message's `metadata`. A2A
53
+ * extensions are identified by URI and carried in `metadata`, so a non-PCA-aware peer simply ignores it.
54
+ */
55
+ exports.PCA_A2A_EXTENSION_URI = 'https://atlasauth.net/a2a/ext/pca/v2';
56
+ // ===================================================================================================
57
+ // 1. Proof-carrying A2A Tasks
58
+ // ===================================================================================================
59
+ function withPca(metadata, pcActn) {
60
+ return { ...(metadata ?? {}), [exports.PCA_A2A_EXTENSION_URI]: pcActn };
61
+ }
62
+ /** Read a PCActn out of a metadata bag (fail-closed: a missing / non-object value yields `undefined`). */
63
+ function readPca(metadata) {
64
+ if (!metadata)
65
+ return undefined;
66
+ const v = metadata[exports.PCA_A2A_EXTENSION_URI];
67
+ if (v !== null && typeof v === 'object' && !Array.isArray(v))
68
+ return v;
69
+ return undefined;
70
+ }
71
+ /** Attach a PCActn to a Task (returns a copy; the input is not mutated). */
72
+ function attachPcaToA2ATask(task, pcActn) {
73
+ return { ...task, metadata: withPca(task.metadata, pcActn) };
74
+ }
75
+ /** Attach a PCActn to a single Message (returns a copy; the input is not mutated). */
76
+ function attachPcaToA2AMessage(message, pcActn) {
77
+ return { ...message, metadata: withPca(message.metadata, pcActn) };
78
+ }
79
+ /**
80
+ * Extract the PCActn carried on a Task. Looks, in order, at the Task metadata, the current
81
+ * `status.message` metadata, then the most recent history message's metadata. Returns `undefined`
82
+ * when no well-formed proof is present (the verify step then fails closed).
83
+ */
84
+ function extractPca(task) {
85
+ const onTask = readPca(task.metadata);
86
+ if (onTask)
87
+ return onTask;
88
+ const onStatus = readPca(task.status.message?.metadata);
89
+ if (onStatus)
90
+ return onStatus;
91
+ const history = task.history;
92
+ if (history && history.length > 0) {
93
+ for (let i = history.length - 1; i >= 0; i--) {
94
+ const m = history[i];
95
+ const onMsg = readPca(m?.metadata);
96
+ if (onMsg)
97
+ return onMsg;
98
+ }
99
+ }
100
+ return undefined;
101
+ }
102
+ /** Extract the PCActn carried on a single Message (fail-closed). */
103
+ function extractPcaFromMessage(message) {
104
+ return readPca(message.metadata);
105
+ }
106
+ function chainRoot(chain) {
107
+ if (!Array.isArray(chain) || chain.length === 0)
108
+ return undefined;
109
+ return chain[0];
110
+ }
111
+ /** Core PCActn verification shared by the Task and payment-mandate surfaces. Fail-closed. */
112
+ async function verifyPcActn(pcActn, opts) {
113
+ const root = chainRoot(pcActn.cap_chain);
114
+ if (!root)
115
+ return { ok: false, reason: 'PCActn carries no capability chain', pcActn };
116
+ if (opts.expectedRootIssuer !== undefined && root.issuer !== opts.expectedRootIssuer) {
117
+ return {
118
+ ok: false,
119
+ reason: 'chain root issuer does not match the expected principal',
120
+ pcActn,
121
+ };
122
+ }
123
+ const grant = opts.grant ?? root;
124
+ const result = await (0, pca_1.verifyPCActnCore)(pcActn, {
125
+ grant,
126
+ audience: opts.aud,
127
+ ...(opts.now !== undefined ? { nowEpoch: opts.now } : {}),
128
+ });
129
+ return result.allow
130
+ ? { ok: true, result, pcActn }
131
+ : { ok: false, reason: result.reason ?? 'PCActn verification failed', result, pcActn };
132
+ }
133
+ /**
134
+ * Verify the proof-carrying action on an A2A Task. Fail-closed: a Task with no attached PCActn, or one
135
+ * whose PCActn does not verify (bad signature, wrong audience, expired, out-of-plan, tampered chain …),
136
+ * is rejected.
137
+ */
138
+ async function verifyA2ATask(task, opts) {
139
+ const pcActn = extractPca(task);
140
+ if (!pcActn)
141
+ return { ok: false, reason: 'no proof-carrying action attached to this task' };
142
+ return verifyPcActn(pcActn, opts);
143
+ }
144
+ /**
145
+ * Build a server guard that verifies the proof-carrying action on each incoming A2A Task and rejects
146
+ * unauthorized ones. Framework-agnostic: wire the returned function into your JSON-RPC `message/send` /
147
+ * `tasks/send` handler and reject when `ok` is false.
148
+ */
149
+ function pcaA2AMiddleware(opts) {
150
+ const require = opts.require ?? true;
151
+ return async (task) => {
152
+ const pcActn = extractPca(task);
153
+ if (!pcActn) {
154
+ return require
155
+ ? { ok: false, reason: 'proof-carrying action required but none attached to task' }
156
+ : { ok: true };
157
+ }
158
+ return verifyPcActn(pcActn, opts);
159
+ };
160
+ }
161
+ const PCA_PASSPORT_HEADER = 'pca_passport';
162
+ function isJwk(k) {
163
+ return typeof k === 'object' && k !== null && !(k instanceof Uint8Array) && 'kty' in k;
164
+ }
165
+ /** The canonical bytes a card signature covers: the card with `signatures` removed (everything else kept). */
166
+ function cardSigningBytes(card) {
167
+ const { signatures: _signatures, ...rest } = card;
168
+ void _signatures;
169
+ return (0, pca_1.canonicalBytes)(rest);
170
+ }
171
+ /**
172
+ * Issue a signed A2A Agent Card. Embeds the PCA passport reference into the card (`pcaPassport`) AND into
173
+ * the signed JWS protected header, then signs the canonicalized card (minus `signatures`) with `jose`,
174
+ * appending the detached-payload `AgentCardSignature`. Because the passport reference is covered by the
175
+ * signature, the card is a verifiable pointer to proof-of-authority — not a self-declaration.
176
+ */
177
+ async function issueSignedAgentCard(card, signingKey, opts = {}) {
178
+ const alg = opts.alg ?? 'EdDSA';
179
+ const passport = opts.passport
180
+ ? { id: opts.passport.id, ...('uri' in opts.passport && opts.passport.uri !== undefined ? { uri: opts.passport.uri } : {}) }
181
+ : card.pcaPassport;
182
+ // Embed the passport reference BEFORE signing so the signature covers it.
183
+ const toSign = { ...card, ...(passport ? { pcaPassport: passport } : {}) };
184
+ const payload = cardSigningBytes(toSign);
185
+ const key = isJwk(signingKey) ? await (0, jose_1.importJWK)(signingKey, alg) : signingKey;
186
+ const protectedHeader = {
187
+ alg,
188
+ b64: false,
189
+ crit: ['b64'],
190
+ ...(opts.kid !== undefined ? { kid: opts.kid } : {}),
191
+ ...(passport ? { [PCA_PASSPORT_HEADER]: passport.id } : {}),
192
+ };
193
+ const jws = await new jose_1.FlattenedSign(payload).setProtectedHeader(protectedHeader).sign(key);
194
+ if (jws.protected === undefined)
195
+ throw new Error('issueSignedAgentCard: JWS is missing its protected header');
196
+ const signature = { protected: jws.protected, signature: jws.signature };
197
+ const existing = toSign.signatures ?? [];
198
+ return { ...toSign, signatures: [...existing, signature] };
199
+ }
200
+ /**
201
+ * Validate an A2A Agent Card against its `AgentCardSignature`(s). Fail-closed: a card with no signatures,
202
+ * an unresolvable key, or ANY signature that does not verify is rejected. Every present signature must
203
+ * verify over the canonicalized card (minus `signatures`). On success, returns the PCA passport id the
204
+ * signature commits to so a caller can resolve + check it against a `PassportRegistry`.
205
+ */
206
+ async function verifyAgentCard(card, opts) {
207
+ const signatures = card.signatures;
208
+ if (!Array.isArray(signatures) || signatures.length === 0) {
209
+ return { ok: false, reason: 'agent card carries no signatures' };
210
+ }
211
+ let resolver;
212
+ try {
213
+ if (opts.jwks) {
214
+ resolver = (0, jose_1.createLocalJWKSet)(opts.jwks);
215
+ }
216
+ else if (opts.key !== undefined) {
217
+ resolver = isJwk(opts.key) ? await (0, jose_1.importJWK)(opts.key, opts.alg ?? 'EdDSA') : opts.key;
218
+ }
219
+ else {
220
+ return { ok: false, reason: 'no verification key or JWKS supplied' };
221
+ }
222
+ }
223
+ catch (e) {
224
+ return { ok: false, reason: `could not resolve verification key: ${e.message}` };
225
+ }
226
+ const payload = cardSigningBytes(card);
227
+ let passportRef;
228
+ for (let i = 0; i < signatures.length; i++) {
229
+ const sig = signatures[i];
230
+ if (!sig || typeof sig.protected !== 'string' || typeof sig.signature !== 'string') {
231
+ return { ok: false, reason: `signature ${i} is malformed` };
232
+ }
233
+ const input = { protected: sig.protected, payload, signature: sig.signature };
234
+ try {
235
+ // Split the call so each branch matches a single flattenedVerify overload (key vs. key-resolver).
236
+ const verified = typeof resolver === 'function'
237
+ ? await (0, jose_1.flattenedVerify)(input, resolver)
238
+ : await (0, jose_1.flattenedVerify)(input, resolver);
239
+ const ref = verified.protectedHeader?.[PCA_PASSPORT_HEADER];
240
+ if (typeof ref === 'string' && passportRef === undefined)
241
+ passportRef = ref;
242
+ }
243
+ catch (e) {
244
+ return { ok: false, reason: `signature ${i} did not verify: ${e.message}` };
245
+ }
246
+ }
247
+ return {
248
+ ok: true,
249
+ ...(passportRef !== undefined ? { passportRef } : {}),
250
+ ...(card.pcaPassport ? { passport: card.pcaPassport } : {}),
251
+ };
252
+ }
253
+ // ===================================================================================================
254
+ // 3. AP2 payment profile (the A2A payment-Task envelope — PCA-verifiable by reference)
255
+ // ===================================================================================================
256
+ /**
257
+ * JSON-LD contexts for the AP2 VDC envelope — the SAME values `@atlasauth/pca-ap2` uses, so this profile
258
+ * is wire-compatible with the full AP2 chain. The second entry is a placeholder for the canonical AP2
259
+ * context URL (replace before production).
260
+ */
261
+ exports.A2A_AP2_CONTEXT = [
262
+ 'https://www.w3.org/2018/credentials/v1',
263
+ 'https://ap2-protocol.org/context/v0.2',
264
+ ];
265
+ function leafHolderOf(chain) {
266
+ if (!Array.isArray(chain) || chain.length === 0)
267
+ return undefined;
268
+ const leaf = chain[chain.length - 1];
269
+ return leaf?.holder;
270
+ }
271
+ /**
272
+ * Map a PCA proof (a PCActn) to an AP2 Payment Mandate so an A2A payment Task can carry it. The mandate's
273
+ * authority is carried BY REFERENCE: `x_pca.pcactn_digest` binds it to the PCActn, and the mandate is
274
+ * verified by resolving + verifying that proof (see {@link verifyA2APaymentMandate}).
275
+ */
276
+ function a2aPaymentMandateFromPca(pcActn, opts) {
277
+ const leaf = leafHolderOf(pcActn.cap_chain);
278
+ const issuer = opts.issuerPublic ?? leaf;
279
+ if (issuer === undefined) {
280
+ throw new Error('a2aPaymentMandateFromPca: no issuerPublic given and the PCActn has no capability chain');
281
+ }
282
+ const humanPresent = opts.humanPresent ?? pcActn.threshold !== undefined;
283
+ const now = opts.now ?? Date.now();
284
+ const x_pca = {
285
+ pcactn_digest: (0, pca_1.pcactnDigest)(pcActn),
286
+ aud: pcActn.aud,
287
+ verb: pcActn.action.verb,
288
+ resource: pcActn.action.resource,
289
+ params_digest: pcActn.action.params_digest,
290
+ grant_ref: pcActn.grant_ref,
291
+ leaf_holder: leaf ?? issuer,
292
+ };
293
+ const contents = {
294
+ amount: { ...opts.amount },
295
+ payment_method: { ...opts.paymentMethod },
296
+ human_present: humanPresent,
297
+ ...(opts.merchant !== undefined ? { merchant: opts.merchant } : {}),
298
+ x_pca,
299
+ };
300
+ return {
301
+ '@context': exports.A2A_AP2_CONTEXT,
302
+ type: ['VerifiableCredential', 'PaymentMandate'],
303
+ issuer,
304
+ issuanceDate: new Date(now).toISOString(),
305
+ credentialSubject: contents,
306
+ };
307
+ }
308
+ /** Read the PCA binding back out of an AP2 Payment Mandate (the round-trip of `x_pca`). */
309
+ function pcaBindingFromA2APaymentMandate(mandate) {
310
+ return { ...mandate.credentialSubject.x_pca };
311
+ }
312
+ /**
313
+ * Verify an AP2 Payment Mandate against the PCActn it references. Fail-closed: the mandate's
314
+ * `x_pca.pcactn_digest` MUST equal `pcactnDigest(pcActn)` (so the mandate is bound to THIS proof), and
315
+ * the PCActn itself must verify (signature, audience, validity, chain, plan inclusion). This is what makes
316
+ * the AP2 payment mandate PCA-verifiable rather than a bare assertion.
317
+ */
318
+ async function verifyA2APaymentMandate(mandate, pcActn, opts) {
319
+ const bound = mandate.credentialSubject.x_pca.pcactn_digest;
320
+ if (bound !== (0, pca_1.pcactnDigest)(pcActn)) {
321
+ return { ok: false, reason: 'payment mandate is not bound to this PCActn (pcactn_digest mismatch)', pcActn };
322
+ }
323
+ return verifyPcActn(pcActn, opts);
324
+ }
325
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;AAuFH,gDAEC;AAGD,sDAEC;AAOD,gCAcC;AAGD,sDAEC;AA8DD,sCAIC;AAoBD,4CAWC;AAsED,oDA4BC;AA6BD,0CAiDC;AAoGD,4DAkCC;AAGD,0EAEC;AAQD,0DAUC;AApiBD,wCAQwB;AACxB,+BASc;AAEd,s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AG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,KAAK;KACN,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,uBAAe;QAC3B,IAAI,EAAE,CAAC,sBAAsB,EAAE,gBAAgB,CAAC;QAChD,MAAM;QACN,YAAY,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE;QACzC,iBAAiB,EAAE,QAAQ;KAC5B,CAAC;AACJ,CAAC;AAED,2FAA2F;AAC3F,SAAgB,+BAA+B,CAAC,OAA0B;IACxE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,uBAAuB,CAC3C,OAA0B,EAC1B,MAAc,EACd,IAAsB;IAEtB,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,aAAa,CAAC;IAC5D,IAAI,KAAK,KAAK,IAAA,kBAAY,EAAC,MAAM,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,sEAAsE,EAAE,MAAM,EAAE,CAAC;IAC/G,CAAC;IACD,OAAO,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@atlasauth/pca-a2a",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "A2A (Agent2Agent) adapter for PCA: verify/attach proof-carrying actions on A2A task send/receive, validate Signed Agent Cards, and an AP2 payment-mandate profile.",
5
+ "keywords": [
6
+ "a2a",
7
+ "agent2agent",
8
+ "agent card",
9
+ "ap2",
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-a2a"
24
+ },
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.js"
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
34
+ "dependencies": {
35
+ "jose": "^5.9.6",
36
+ "@atlasauth/pca": "0.2.0"
37
+ },
38
+ "devDependencies": {
39
+ "typescript": "^5.6.3",
40
+ "vitest": "^2.1.4"
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "README.md",
45
+ "LICENSE"
46
+ ],
47
+ "engines": {
48
+ "node": ">=20"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "scripts": {
54
+ "build": "tsc -p tsconfig.build.json",
55
+ "typecheck": "tsc -p tsconfig.json --noEmit",
56
+ "test": "vitest run"
57
+ }
6
58
  }