@atlasauth/pca-acp 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 +65 -0
- 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
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @atlasauth/pca-acp
|
|
2
|
+
|
|
3
|
+
Agentic Commerce Protocol (ACP) and x402 adapter for Proof-Carrying Authority (PCA). It mints an ACP-style delegated one-time payment token (a JWS bound to session, merchant, amount, currency and expiry) from a PCActn, and provides an x402 (HTTP 402) facilitator hook that only settles when the token and its backing proof verify.
|
|
4
|
+
|
|
5
|
+
The PCActn's capability caveats gate issuance: minting is refused (`AcpAuthorityError`) if the requested amount, currency, merchant, category or human-present modality exceeds what the proof authorizes, or if the token would outlive the proof. The token carries the proof by reference (its digest), never its contents. For the AP2 Intent/Cart/Payment chain see `@atlasauth/pca-ap2`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i @atlasauth/pca-acp
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Depends on `@atlasauth/pca` and `jose` (installed transitively).
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
spendCapCaveat, merchantAllowCaveat,
|
|
20
|
+
mintDelegatedPaymentToken, verifyDelegatedPaymentToken,
|
|
21
|
+
x402Challenge, x402Settle, acpX402Verifier,
|
|
22
|
+
} from '@atlasauth/pca-acp';
|
|
23
|
+
|
|
24
|
+
// `grant` carries payment caveats, e.g. mintRoot({ ..., caveats: [spendCapCaveat(500, 'USD'),
|
|
25
|
+
// merchantAllowCaveat(['acme'])] }); `pcActn` is a PCActn built from it with @atlasauth/pca.
|
|
26
|
+
|
|
27
|
+
const token = await mintDelegatedPaymentToken(pcActn, {
|
|
28
|
+
amount: 100, currency: 'USD', merchant: 'acme', session: 'sess-1',
|
|
29
|
+
expiresAt: Date.now() + 10 * 60_000,
|
|
30
|
+
paymentMethod: { type: 'shared_payment_token', token: 'spt_abc' },
|
|
31
|
+
signingKey: privateKey, // jose KeyLike, Uint8Array or JWK; default alg EdDSA
|
|
32
|
+
});
|
|
33
|
+
// minting 900 against the 500 cap throws AcpAuthorityError
|
|
34
|
+
|
|
35
|
+
// Settlement: check the token binding and re-verify the backing proof.
|
|
36
|
+
await verifyDelegatedPaymentToken(token, {
|
|
37
|
+
expectedMerchant: 'acme', amount: 100, verifyKey: publicKey,
|
|
38
|
+
pcActn, grant, audience: 'my-rs', // optional full proof re-verification
|
|
39
|
+
}); // { ok: true, claims, pcaResult }
|
|
40
|
+
|
|
41
|
+
// x402: answer with a 402 challenge, then gate settlement on the proof-bound token.
|
|
42
|
+
const challenge = x402Challenge('/api/report', { amount: 100, currency: 'USDC', payTo: '0xabc' });
|
|
43
|
+
const result = await x402Settle({ token, merchant: 'acme', amount: 100 }, {
|
|
44
|
+
verify: acpX402Verifier({ verifyKey: publicKey, pcActn, grant, audience: 'my-rs' }),
|
|
45
|
+
settle: async (payload, claims) => ({ charged: claims.amount }), // your facilitator call
|
|
46
|
+
}); // { settled: true, status: 200, receipt } or { settled: false, status: 402, reason }
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Pass `expectedMerchant` and `amount` to `acpX402Verifier` from your own order data when you can; by default it reads them from the client's payload.
|
|
50
|
+
|
|
51
|
+
## API
|
|
52
|
+
|
|
53
|
+
- Caveats: `spendCapCaveat`, `merchantAllowCaveat`, `merchantCategoryCaveat`, `humanPresentCaveat`, `extractPaymentAuthority`, `checkPaymentAuthority`, `AcpAuthorityError`.
|
|
54
|
+
- Tokens: `mintDelegatedPaymentToken`, `verifyDelegatedPaymentToken`.
|
|
55
|
+
- x402: `x402Challenge`, `x402Settle`, `acpX402Verifier`.
|
|
56
|
+
|
|
57
|
+
## Status
|
|
58
|
+
|
|
59
|
+
Experimental. ACP and x402 are young protocols: the token and `accepts` field names are structural and should be validated against the current Stripe/OpenAI ACP and Coinbase x402 specs before production use. The x402 helpers perform no network I/O; verification and settlement are injected. Single use of a token (`jti`) is not tracked here, so the resource server must record used ids. The cryptography is unaudited.
|
|
60
|
+
|
|
61
|
+
Source and issues: https://github.com/Atlas-Authorization/pca
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT - see LICENSE
|
package/package.json
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasauth/pca-acp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Agentic Commerce (ACP) + x402 adapter for PCA: mint an ACP delegated one-time payment token (bound to session+merchant+amount+expiry) AS a PCA proof, and an x402/HTTP-402 facilitator hook that gates settlement on a verified PCActn.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agentic commerce",
|
|
7
|
+
"x402",
|
|
8
|
+
"payments",
|
|
9
|
+
"http 402",
|
|
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-acp"
|
|
24
|
+
},
|
|
5
25
|
"main": "./dist/index.js",
|
|
6
26
|
"types": "./dist/index.d.ts",
|
|
7
27
|
"exports": {
|
|
@@ -13,7 +33,7 @@
|
|
|
13
33
|
},
|
|
14
34
|
"dependencies": {
|
|
15
35
|
"jose": "^5.9.6",
|
|
16
|
-
"@atlasauth/pca": "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
|
},
|