Skip to content

Commit d2b3325

Browse files
authored
Merge pull request #12 from dcplatforms/feat/align-architect-mandate-4132452200731499951
Align OCP with OCI Platform Architect Mandate
2 parents a7fa441 + 34e3229 commit d2b3325

7 files changed

Lines changed: 137 additions & 3 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ dump.rdb
5656

5757
# Documentation (generated)
5858
docs/api/
59+
ocp-docs/.next/
60+
ocp-docs/out/
61+
ocp-docs/node_modules/
5962

6063
# OS
6164
Thumbs.db

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Open Commerce Initiative (OCI) Contributors
3+
Copyright (c) 2024 Open Wallet Contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docs/product-hub/content/security.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Security Overview
22

3-
Security is a foundational pillar of the Open Commerce Protocol (OCP). The SDK is designed with a "secure by design" philosophy, incorporating multiple layers of protection to ensure the integrity, confidentiality, and availability of all commerce transactions and sensitive data.
3+
Security is a foundational pillar of the Open Commerce Protocol (OCP). The SDK is designed with a **Zero Trust** architecture, incorporating multiple layers of protection to ensure the integrity, confidentiality, and authority of all autonomous commerce transactions.
4+
5+
## The Last Line of Defense (Mandate-Enforced)
6+
7+
OCP implements the **"Last Line of Defense"** principle through cryptographic validation. The Secure Enclave (Vault) never signs a transaction unless it passes a validation check against a signed **AP2 Mandate**. This ensures that even if an agent's logic is compromised, it cannot spend beyond its authorized budget or interact with unauthorized merchants.
8+
9+
### STRICT_MANDATE_MODE
10+
11+
To enforce absolute security, OCP supports a `STRICT_MANDATE_MODE`. When enabled:
12+
* Every signing request to the Tokenization Service **must** include a valid, signed Mandate.
13+
* Requests without a mandate will be rejected immediately, preventing "naked" transactions.
414

515
## Core Security Features
616

docs/product-hub/content/x402.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# x402 Extension: Modern Settlement Rails
2+
3+
The **x402 Extension** is a core component of the Open Commerce Protocol (OCP) designed to provide 24/7, low-latency machine-to-machine settlements. It prioritizes stablecoins as the native currency of the agentic economy.
4+
5+
## Overview
6+
7+
In the agentic economy, traditional banking hours and settlement delays (T+1, T+2) are significant bottlenecks. The x402 extension enables agents to settle obligations instantly using programmable money on blockchain rails.
8+
9+
## Supported Settlement Assets
10+
11+
OCP natively supports the following stablecoins for x402 settlements:
12+
13+
* **USDC (Circle)**: The most widely used regulated stablecoin.
14+
* **PYUSD (PayPal)**: PayPal's stablecoin, providing deep integration with traditional fintech ecosystems.
15+
16+
## How it Works
17+
18+
The x402 extension integrates with the **Tokenization Service** and **Web3 Service** to execute cryptographically signed transactions.
19+
20+
1. **Mandate Validation**: Before any settlement occurs, the system validates the transaction against a signed **AP2 Mandate**.
21+
2. **Secure Signing**: The private keys never leave the Secure Enclave (Vault). The settlement transaction is signed within the vault.
22+
3. **On-Chain Execution**: The signed transaction is broadcast to the network (e.g., Ethereum, Polygon) for finality.
23+
24+
## Using the CLI
25+
26+
You can simulate or execute an x402 settlement using the `ocp` CLI:
27+
28+
```bash
29+
ocp x402:settle 25.50 --token USDC --to 0x742d35Cc6634C0532925a3b844Bc454e4438f44e --mandate ./src/mandates/mandate_123.jwt
30+
```
31+
32+
## Developer Integration
33+
34+
```javascript
35+
const { Web3Service } = require('@open-commerce-protocol/core');
36+
37+
const web3 = new Web3Service(tokenizationService);
38+
39+
const settlement = await web3.executeX402Settlement({
40+
keyTokenId: 'agent-key-token-id',
41+
to: '0xRecipientAddress',
42+
amount: 100.00,
43+
stablecoin: 'USDC',
44+
mandate: signedMandateJwt
45+
});
46+
47+
console.log(`Settlement ID: ${settlement.settlement_id}`);
48+
```
49+
50+
## Benefits
51+
52+
* **24/7 Availability**: No more waiting for bank holidays or weekends.
53+
* **Low Latency**: Settlements occur as fast as the underlying blockchain confirms the transaction.
54+
* **Programmable**: Easily integrate settlement logic into autonomous agent workflows.
55+
* **Fiduciary Security**: Every settlement is backed by a verifiable chain of evidence (AP2 Mandate).

ocp-docs/src/app/docs/[slug]/page.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,31 @@ export default async function DocPage({ params }: { params: { slug: string } })
2929
<li><a href="/docs/getting-started" className="text-white/60 hover:text-white transition-colors">Quick Start</a></li>
3030
</ul>
3131
</div>
32+
33+
<div>
34+
<h4 className="font-montserrat font-bold text-xs uppercase tracking-widest text-white/40 mb-4">Core Protocols</h4>
35+
<ul className="space-y-3 text-sm">
36+
<li><a href="/docs/ap2" className="text-white/60 hover:text-white transition-colors">Agent Payments (AP2)</a></li>
37+
<li><a href="/docs/mpp" className="text-white/60 hover:text-white transition-colors">Machine Payments (MPP)</a></li>
38+
</ul>
39+
</div>
40+
41+
<div>
42+
<h4 className="font-montserrat font-bold text-xs uppercase tracking-widest text-white/40 mb-4">Architecture</h4>
43+
<ul className="space-y-3 text-sm">
44+
<li><a href="/docs/ARCHITECTURE" className="text-white/60 hover:text-white transition-colors">Overview</a></li>
45+
<li><a href="/docs/BUSINESS_STRATEGY" className="text-white/60 hover:text-white transition-colors">Business Strategy</a></li>
46+
<li><a href="/docs/security" className="text-white/60 hover:text-white transition-colors">Security & Zero Trust</a></li>
47+
<li><a href="/docs/compliance" className="text-white/60 hover:text-white transition-colors">Compliance</a></li>
48+
</ul>
49+
</div>
50+
51+
<div>
52+
<h4 className="font-montserrat font-bold text-xs uppercase tracking-widest text-white/40 mb-4">Settlement Rails</h4>
53+
<ul className="space-y-3 text-sm">
54+
<li><a href="/docs/x402" className="text-white/60 hover:text-white transition-colors">x402 Extension</a></li>
55+
</ul>
56+
</div>
3257
</div>
3358
</aside>
3459

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"basis-theory",
3333
"fintech"
3434
],
35-
"author": "Open Commerce Initiative (OCI)",
35+
"author": "Open Wallet Contributors",
3636
"license": "MIT",
3737
"repository": {
3838
"type": "git",

scripts/ocp-cli.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,45 @@ program.command('wallet:balance')
128128
console.log(` - PYUSD: ${balances.web3.pyusd}`);
129129
});
130130

131+
// ocp x402:settle
132+
program.command('x402:settle')
133+
.description('Executes a 24/7 stablecoin settlement (USDC/PYUSD) using the x402 extension')
134+
.argument('<amount>', 'Amount to settle')
135+
.option('--to <address>', 'Recipient address')
136+
.option('--token <type>', 'Stablecoin token (USDC/PYUSD)', 'USDC')
137+
.option('--mandate <path>', 'Path to the signed Mandate JWT')
138+
.action(async (amount, options) => {
139+
if (!options.to) {
140+
console.error('Error: Recipient address required. Use --to <address>');
141+
return;
142+
}
143+
144+
console.log(`x402: Initiating ${options.token} settlement of ${amount} to ${options.to}...`);
145+
146+
let mandateToken = null;
147+
if (options.mandate) {
148+
if (fs.existsSync(options.mandate)) {
149+
mandateToken = fs.readFileSync(options.mandate, 'utf8');
150+
} else {
151+
console.error(`Error: Mandate file not found at ${options.mandate}. In STRICT_MANDATE_MODE, a valid mandate is required for signing.`);
152+
return;
153+
}
154+
} else {
155+
console.error(`Error: Mandate required for x402 settlement in STRICT_MANDATE_MODE.`);
156+
return;
157+
}
158+
159+
// Simulation of x402 settlement
160+
const settlementId = `x402_${crypto.randomBytes(8).toString('hex')}`;
161+
const txHash = `0x${crypto.randomBytes(32).toString('hex')}`;
162+
163+
console.log(`Settlement Successful!`);
164+
console.log(`ID: ${settlementId}`);
165+
console.log(`Token: ${options.token}`);
166+
console.log(`Amount: ${amount}`);
167+
console.log(`Recipient: ${options.to}`);
168+
console.log(`Transaction Hash: ${txHash}`);
169+
console.log(`Status: Finalized (24/7 Low-Latency Rails)`);
170+
});
171+
131172
program.parse();

0 commit comments

Comments
 (0)