opmsec 0.1.0 → 0.1.3
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/.env.example +23 -13
- package/README.md +256 -173
- package/docs/architecture/agents.mdx +77 -0
- package/docs/architecture/benchmarks.mdx +65 -0
- package/docs/architecture/overview.mdx +58 -0
- package/docs/architecture/scanner.mdx +53 -0
- package/docs/cli/audit.mdx +35 -0
- package/docs/cli/check.mdx +44 -0
- package/docs/cli/fix.mdx +49 -0
- package/docs/cli/info.mdx +44 -0
- package/docs/cli/install.mdx +71 -0
- package/docs/cli/push.mdx +99 -0
- package/docs/cli/register-agent.mdx +80 -0
- package/docs/cli/view.mdx +52 -0
- package/docs/concepts/multi-agent-consensus.mdx +58 -0
- package/docs/concepts/on-chain-registry.mdx +74 -0
- package/docs/concepts/security-model.mdx +76 -0
- package/docs/concepts/zk-agent-verification.mdx +82 -0
- package/docs/configuration.mdx +82 -0
- package/docs/contract/deployment.mdx +57 -0
- package/docs/contract/events.mdx +115 -0
- package/docs/contract/functions.mdx +220 -0
- package/docs/contract/overview.mdx +58 -0
- package/docs/favicon.svg +5 -0
- package/docs/introduction.mdx +43 -0
- package/docs/logo/dark.svg +5 -0
- package/docs/logo/light.svg +5 -0
- package/docs/mint.json +106 -0
- package/docs/quickstart.mdx +133 -0
- package/package.json +3 -3
- package/packages/cli/src/commands/author-view.tsx +9 -1
- package/packages/cli/src/commands/check.tsx +318 -0
- package/packages/cli/src/commands/fix.tsx +294 -0
- package/packages/cli/src/commands/install.tsx +229 -33
- package/packages/cli/src/commands/push.tsx +53 -22
- package/packages/cli/src/commands/register-agent.tsx +227 -0
- package/packages/cli/src/components/AgentScores.tsx +20 -6
- package/packages/cli/src/components/Hyperlink.tsx +30 -0
- package/packages/cli/src/components/ScanReport.tsx +3 -2
- package/packages/cli/src/index.tsx +41 -5
- package/packages/cli/src/services/avatar.ts +43 -6
- package/packages/cli/src/services/chainpatrol.ts +20 -17
- package/packages/cli/src/services/contract.ts +41 -8
- package/packages/cli/src/services/ens.ts +3 -5
- package/packages/cli/src/services/fileverse.ts +12 -13
- package/packages/cli/src/services/typosquat.ts +166 -0
- package/packages/contracts/circuits/accuracy_verifier.circom +101 -0
- package/packages/contracts/contracts/OPMRegistry.sol +63 -0
- package/packages/contracts/scripts/deploy.ts +22 -3
- package/packages/core/src/abi.ts +221 -0
- package/packages/core/src/benchmarks.ts +450 -0
- package/packages/core/src/constants.ts +20 -0
- package/packages/core/src/index.ts +2 -0
- package/packages/core/src/model-rankings.ts +115 -0
- package/packages/core/src/prompt.ts +58 -0
- package/packages/core/src/types.ts +41 -0
- package/packages/core/src/utils.ts +7 -3
- package/packages/scanner/src/agents/base-agent.ts +13 -3
- package/packages/scanner/src/index.ts +5 -2
- package/packages/scanner/src/queue/memory-queue.ts +8 -3
- package/packages/scanner/src/services/benchmark-runner.ts +114 -0
- package/packages/scanner/src/services/contract-writer.ts +2 -3
- package/packages/scanner/src/services/fileverse.ts +26 -7
- package/packages/scanner/src/services/openrouter.ts +46 -0
- package/packages/scanner/src/services/report-formatter.ts +122 -3
- package/packages/scanner/src/services/zk-verifier.ts +118 -0
- package/packages/web/.next/app-build-manifest.json +15 -0
- package/packages/web/.next/build-manifest.json +20 -0
- package/packages/web/.next/package.json +1 -0
- package/packages/web/.next/prerender-manifest.json +11 -0
- package/packages/web/.next/react-loadable-manifest.json +1 -0
- package/packages/web/.next/routes-manifest.json +1 -0
- package/packages/web/.next/server/app/page.js +272 -0
- package/packages/web/.next/server/app/page_client-reference-manifest.js +1 -0
- package/packages/web/.next/server/app-paths-manifest.json +3 -0
- package/packages/web/.next/server/interception-route-rewrite-manifest.js +1 -0
- package/packages/web/.next/server/middleware-build-manifest.js +22 -0
- package/packages/web/.next/server/middleware-manifest.json +6 -0
- package/packages/web/.next/server/middleware-react-loadable-manifest.js +1 -0
- package/packages/web/.next/server/next-font-manifest.js +1 -0
- package/packages/web/.next/server/next-font-manifest.json +1 -0
- package/packages/web/.next/server/pages-manifest.json +1 -0
- package/packages/web/.next/server/server-reference-manifest.js +1 -0
- package/packages/web/.next/server/server-reference-manifest.json +5 -0
- package/packages/web/.next/server/vendor-chunks/@swc.js +55 -0
- package/packages/web/.next/server/vendor-chunks/next.js +3010 -0
- package/packages/web/.next/server/webpack-runtime.js +209 -0
- package/packages/web/.next/static/chunks/app/layout.js +39 -0
- package/packages/web/.next/static/chunks/app/page.js +61 -0
- package/packages/web/.next/static/chunks/app-pages-internals.js +182 -0
- package/packages/web/.next/static/chunks/main-app.js +1882 -0
- package/packages/web/.next/static/chunks/polyfills.js +1 -0
- package/packages/web/.next/static/chunks/webpack.js +1393 -0
- package/packages/web/.next/static/css/app/layout.css +1237 -0
- package/packages/web/.next/static/development/_buildManifest.js +1 -0
- package/packages/web/.next/static/development/_ssgManifest.js +1 -0
- package/packages/web/.next/static/webpack/633457081244afec._.hot-update.json +1 -0
- package/packages/web/.next/static/webpack/6fee6306e0f98869.webpack.hot-update.json +1 -0
- package/packages/web/.next/static/webpack/73e341375c8d429e.webpack.hot-update.json +1 -0
- package/packages/web/.next/static/webpack/app/layout.6fee6306e0f98869.hot-update.js +22 -0
- package/packages/web/.next/static/webpack/app/layout.73e341375c8d429e.hot-update.js +22 -0
- package/packages/web/.next/static/webpack/app/page.6fee6306e0f98869.hot-update.js +22 -0
- package/packages/web/.next/static/webpack/app/page.73e341375c8d429e.hot-update.js +22 -0
- package/packages/web/.next/static/webpack/webpack.6fee6306e0f98869.hot-update.js +12 -0
- package/packages/web/.next/static/webpack/webpack.73e341375c8d429e.hot-update.js +12 -0
- package/packages/web/.next/trace +5 -0
- package/packages/web/.next/types/app/layout.ts +84 -0
- package/packages/web/.next/types/app/page.ts +84 -0
- package/packages/web/.next/types/cache-life.d.ts +141 -0
- package/packages/web/.next/types/package.json +1 -0
- package/packages/web/.next/types/routes.d.ts +57 -0
- package/packages/web/.next/types/validator.ts +61 -0
- package/packages/web/app/globals.css +75 -0
- package/packages/web/app/layout.tsx +26 -0
- package/packages/web/app/page.tsx +358 -0
- package/packages/web/bun.lock +300 -0
- package/packages/web/next-env.d.ts +6 -0
- package/packages/web/next.config.ts +5 -0
- package/packages/web/package.json +26 -0
- package/packages/web/postcss.config.mjs +8 -0
- package/packages/web/public/favicon.svg +5 -0
- package/packages/web/public/logo.svg +7 -0
- package/packages/web/tailwind.config.ts +48 -0
- package/packages/web/tsconfig.json +21 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Contract Functions'
|
|
3
|
+
description: 'All OPMRegistry functions with parameters and behavior.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Contract Functions
|
|
7
|
+
|
|
8
|
+
## Admin (Owner Only)
|
|
9
|
+
|
|
10
|
+
### setAgent
|
|
11
|
+
|
|
12
|
+
```solidity
|
|
13
|
+
function setAgent(address agent, bool status) external onlyOwner
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Authorize or deauthorize an agent. Only the contract owner can call this.
|
|
17
|
+
|
|
18
|
+
| Parameter | Type | Description |
|
|
19
|
+
|-----------|------|-------------|
|
|
20
|
+
| agent | address | Agent wallet address |
|
|
21
|
+
| status | bool | true = authorized, false = deauthorized |
|
|
22
|
+
|
|
23
|
+
### revokeAgent
|
|
24
|
+
|
|
25
|
+
```solidity
|
|
26
|
+
function revokeAgent(address agent) external onlyOwner
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Deactivate a registered agent. Sets <code>active</code> to false and removes from <code>authorizedAgents</code>.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Package Registration (Public)
|
|
34
|
+
|
|
35
|
+
### registerPackage
|
|
36
|
+
|
|
37
|
+
```solidity
|
|
38
|
+
function registerPackage(
|
|
39
|
+
string calldata name,
|
|
40
|
+
string calldata version,
|
|
41
|
+
bytes32 checksum,
|
|
42
|
+
bytes calldata sig,
|
|
43
|
+
string calldata ensName
|
|
44
|
+
) external
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Register a package version. Callable by anyone; the sender becomes the author.
|
|
48
|
+
|
|
49
|
+
| Parameter | Type | Description |
|
|
50
|
+
|-----------|------|-------------|
|
|
51
|
+
| name | string | Package name |
|
|
52
|
+
| version | string | Semantic version |
|
|
53
|
+
| checksum | bytes32 | SHA-256 of tarball |
|
|
54
|
+
| sig | bytes | ECDSA signature of checksum |
|
|
55
|
+
| ensName | string | Author ENS name (e.g. vitalik.eth) |
|
|
56
|
+
|
|
57
|
+
Reverts if the version is already registered.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Agent-Only (Authorized Agents)
|
|
62
|
+
|
|
63
|
+
### submitScore
|
|
64
|
+
|
|
65
|
+
```solidity
|
|
66
|
+
function submitScore(
|
|
67
|
+
string calldata name,
|
|
68
|
+
string calldata version,
|
|
69
|
+
uint8 riskScore,
|
|
70
|
+
string calldata reasoning
|
|
71
|
+
) external onlyAgent
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Submit a risk score (0–100) for a package version. Each agent may score a version only once.
|
|
75
|
+
|
|
76
|
+
| Parameter | Type | Description |
|
|
77
|
+
|-----------|------|-------------|
|
|
78
|
+
| name | string | Package name |
|
|
79
|
+
| version | string | Semantic version |
|
|
80
|
+
| riskScore | uint8 | Risk score 0–100 |
|
|
81
|
+
| reasoning | string | Agent reasoning |
|
|
82
|
+
|
|
83
|
+
### setReportURI
|
|
84
|
+
|
|
85
|
+
```solidity
|
|
86
|
+
function setReportURI(
|
|
87
|
+
string calldata name,
|
|
88
|
+
string calldata version,
|
|
89
|
+
string calldata uri
|
|
90
|
+
) external onlyAgent
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Set the Fileverse/IPFS report URI for a package version.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Permissionless Agent Registration
|
|
98
|
+
|
|
99
|
+
### registerAgent
|
|
100
|
+
|
|
101
|
+
```solidity
|
|
102
|
+
function registerAgent(
|
|
103
|
+
string calldata name,
|
|
104
|
+
string calldata model,
|
|
105
|
+
bytes32 systemPromptHash,
|
|
106
|
+
bytes32 proofHash
|
|
107
|
+
) external
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Register a new agent with ZK-verified benchmark proof. Callable by anyone; the sender becomes the agent.
|
|
111
|
+
|
|
112
|
+
| Parameter | Type | Description |
|
|
113
|
+
|-----------|------|-------------|
|
|
114
|
+
| name | string | Agent identifier |
|
|
115
|
+
| model | string | LLM model (e.g. anthropic/claude-sonnet-4) |
|
|
116
|
+
| systemPromptHash | bytes32 | Keccak256 of system prompt |
|
|
117
|
+
| proofHash | bytes32 | Keccak256 of ZK proof |
|
|
118
|
+
|
|
119
|
+
Reverts if the sender is already authorized or registered, or if <code>proofHash</code> is zero.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## View Functions
|
|
124
|
+
|
|
125
|
+
### getPackageInfo
|
|
126
|
+
|
|
127
|
+
```solidity
|
|
128
|
+
function getPackageInfo(string calldata name, string calldata version)
|
|
129
|
+
external view returns (
|
|
130
|
+
address author,
|
|
131
|
+
bytes32 checksum,
|
|
132
|
+
bytes memory sig,
|
|
133
|
+
string memory ensName,
|
|
134
|
+
string memory reportURI,
|
|
135
|
+
uint8 aggregateScore,
|
|
136
|
+
bool exists
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Returns full package info for a version. <code>aggregateScore</code> is the mean of all agent scores.
|
|
141
|
+
|
|
142
|
+
### getScores
|
|
143
|
+
|
|
144
|
+
```solidity
|
|
145
|
+
function getScores(string calldata name, string calldata version)
|
|
146
|
+
external view returns (AgentScore[] memory)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Returns all agent scores for a package version. Each <code>AgentScore</code> has <code>agent</code>, <code>riskScore</code>, <code>reasoning</code>.
|
|
150
|
+
|
|
151
|
+
### getAggregateScore
|
|
152
|
+
|
|
153
|
+
```solidity
|
|
154
|
+
function getAggregateScore(string calldata name, string calldata version)
|
|
155
|
+
external view returns (uint8)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Returns the mean risk score (0 if no scores).
|
|
159
|
+
|
|
160
|
+
### getSafestVersion
|
|
161
|
+
|
|
162
|
+
```solidity
|
|
163
|
+
function getSafestVersion(string calldata name, uint8 lookback)
|
|
164
|
+
external view returns (string memory)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Returns the lowest-risk version among the last <code>lookback</code> versions. Default lookback is 3.
|
|
168
|
+
|
|
169
|
+
### getVersions
|
|
170
|
+
|
|
171
|
+
```solidity
|
|
172
|
+
function getVersions(string calldata name)
|
|
173
|
+
external view returns (string[] memory)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Returns all registered versions for a package.
|
|
177
|
+
|
|
178
|
+
### getAuthorByAddress
|
|
179
|
+
|
|
180
|
+
```solidity
|
|
181
|
+
function getAuthorByAddress(address addr)
|
|
182
|
+
external view returns (AuthorProfile memory)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Returns author profile by wallet address. <code>AuthorProfile</code> includes <code>addr</code>, <code>ensName</code>, <code>reputationTotal</code>, <code>reputationCount</code>, <code>packagesPublished</code>.
|
|
186
|
+
|
|
187
|
+
### getAuthorByENS
|
|
188
|
+
|
|
189
|
+
```solidity
|
|
190
|
+
function getAuthorByENS(string calldata ensName)
|
|
191
|
+
external view returns (AuthorProfile memory)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Returns author profile by ENS name. Reverts if ENS not found.
|
|
195
|
+
|
|
196
|
+
### getAuthorReputation
|
|
197
|
+
|
|
198
|
+
```solidity
|
|
199
|
+
function getAuthorReputation(address addr)
|
|
200
|
+
external view returns (uint256)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Returns average reputation (mean of all scores received) for an author. 0 if no scores.
|
|
204
|
+
|
|
205
|
+
### getRegisteredAgent
|
|
206
|
+
|
|
207
|
+
```solidity
|
|
208
|
+
function getRegisteredAgent(address agent)
|
|
209
|
+
external view returns (RegisteredAgent memory)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Returns registered agent info: <code>agentAddress</code>, <code>name</code>, <code>model</code>, <code>systemPromptHash</code>, <code>proofHash</code>, <code>registeredAt</code>, <code>active</code>.
|
|
213
|
+
|
|
214
|
+
### getAgentCount
|
|
215
|
+
|
|
216
|
+
```solidity
|
|
217
|
+
function getAgentCount() external view returns (uint256)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Returns the number of registered agents.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Contract Overview'
|
|
3
|
+
description: 'OPMRegistry smart contract deployed on Base Sepolia.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Contract Overview
|
|
7
|
+
|
|
8
|
+
The **OPMRegistry** is the core on-chain component of OPM. It stores package metadata, agent scores, author profiles, and registered agents on Base Sepolia.
|
|
9
|
+
|
|
10
|
+
## Deployment
|
|
11
|
+
|
|
12
|
+
| Property | Value |
|
|
13
|
+
|----------|-------|
|
|
14
|
+
| Contract | OPMRegistry.sol |
|
|
15
|
+
| Network | Base Sepolia (chain ID 84532) |
|
|
16
|
+
| Address | <code>0x16684391fc9bf48246B08Afe16d1a57BFa181d48</code> |
|
|
17
|
+
| Solidity | 0.8.20 |
|
|
18
|
+
|
|
19
|
+
<Note>
|
|
20
|
+
View the contract on [BaseScan](https://sepolia.basescan.org/address/0x16684391fc9bf48246B08Afe16d1a57BFa181d48).
|
|
21
|
+
</Note>
|
|
22
|
+
|
|
23
|
+
## Design
|
|
24
|
+
|
|
25
|
+
### Owner Pattern
|
|
26
|
+
|
|
27
|
+
The contract uses an owner pattern for initial agent authorization. The deployer is the owner and can:
|
|
28
|
+
|
|
29
|
+
- Authorize or deauthorize agents via <code>setAgent(address, bool)</code>
|
|
30
|
+
- Revoke permissionless agents via <code>revokeAgent(address)</code>
|
|
31
|
+
|
|
32
|
+
### Permissionless Agent Registration
|
|
33
|
+
|
|
34
|
+
New agents can register without owner approval by passing the benchmark verification:
|
|
35
|
+
|
|
36
|
+
1. Run 10 labeled benchmark cases
|
|
37
|
+
2. Achieve 100% accuracy
|
|
38
|
+
3. Generate a ZK proof of accuracy
|
|
39
|
+
4. Call <code>registerAgent(name, model, systemPromptHash, proofHash)</code>
|
|
40
|
+
|
|
41
|
+
On success, the agent is automatically authorized to submit scores.
|
|
42
|
+
|
|
43
|
+
### Data Stored
|
|
44
|
+
|
|
45
|
+
| Data | Description |
|
|
46
|
+
|------|-------------|
|
|
47
|
+
| **Packages** | Name → versions mapping |
|
|
48
|
+
| **Version data** | Per (name, version): author, checksum, signature, report URI, agent scores |
|
|
49
|
+
| **Authors** | Address → profile (ENS name, reputation, packages published) |
|
|
50
|
+
| **Agents** | Authorized agents (owner-set or ZK-verified) |
|
|
51
|
+
| **Registered agents** | Permissionless agents with name, model, proof hash |
|
|
52
|
+
|
|
53
|
+
## Risk Thresholds
|
|
54
|
+
|
|
55
|
+
| Constant | Value | Purpose |
|
|
56
|
+
|----------|-------|---------|
|
|
57
|
+
| <code>HIGH_RISK_THRESHOLD</code> | 70 | Blocks install; high-risk packages |
|
|
58
|
+
| <code>MEDIUM_RISK_THRESHOLD</code> | 40 | Warning threshold |
|
package/docs/favicon.svg
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="none">
|
|
2
|
+
<rect width="32" height="32" rx="6" fill="#0a0a0a"/>
|
|
3
|
+
<path d="M8 10L12 22L16 13L20 22L24 10" stroke="#ededed" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
<circle cx="16" cy="24" r="1.5" fill="#4ade80"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Introduction'
|
|
3
|
+
description: 'OPM is a drop-in npm replacement that adds cryptographic signing, multi-agent AI security auditing, on-chain risk scoring, and ZK-verified permissionless agent registration to the JavaScript supply chain.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Introduction
|
|
7
|
+
|
|
8
|
+
**OPM (On-chain Package Manager)** is a security-hardened CLI wrapper around npm that introduces cryptographic package attestation, multi-agent AI threat analysis, on-chain audit registries, and decentralized report storage to the JavaScript dependency supply chain. It functions as a drop-in npm replacement while interposing a verification pipeline between the developer and the npm registry.
|
|
9
|
+
|
|
10
|
+
## The Problem
|
|
11
|
+
|
|
12
|
+
The npm ecosystem faces persistent supply chain threats:
|
|
13
|
+
|
|
14
|
+
- **Supply chain injection**: Malicious postinstall scripts, obfuscated payloads, environment variable exfiltration, and runtime code generation
|
|
15
|
+
- **Typosquatting**: Package names designed to mimic popular packages (e.g., `lodash` vs `lodahs`)
|
|
16
|
+
- **Malicious packages**: Deliberately harmful code in dependencies, often introduced via maintainer takeover
|
|
17
|
+
- **Dependency confusion**: Scoped vs unscoped name conflicts and internal package shadowing
|
|
18
|
+
- **Known vulnerabilities**: Unpatched CVEs and GHSA advisories in transitive dependencies
|
|
19
|
+
|
|
20
|
+
Traditional package managers lack cryptographic provenance, real-time threat intelligence, and decentralized trust signals. OPM addresses these gaps.
|
|
21
|
+
|
|
22
|
+
## The Solution
|
|
23
|
+
|
|
24
|
+
OPM combines four layers of defense:
|
|
25
|
+
|
|
26
|
+
1. **Cryptographic attestation**: SHA-256 checksums and ECDSA signatures (secp256k1) derived from Ethereum wallets, with on-chain registration
|
|
27
|
+
2. **Multi-agent AI auditing**: Three heterogeneous LLMs (Claude, Gemini, DeepSeek) analyze packages in parallel and submit intelligence-weighted risk scores on-chain
|
|
28
|
+
3. **On-chain registry**: Risk scores, author profiles, and report URIs stored on **Base Sepolia** (chain ID 84532) in the `OPMRegistry` smart contract
|
|
29
|
+
4. **ZK-verified agent registration**: Permissionless agents must pass a benchmark suite and prove 100% accuracy via zero-knowledge proofs before participating
|
|
30
|
+
|
|
31
|
+
## Key Integrations
|
|
32
|
+
|
|
33
|
+
| Integration | Purpose |
|
|
34
|
+
|-------------|---------|
|
|
35
|
+
| **Base Sepolia** | EVM chain for OPMRegistry deployment and score submission |
|
|
36
|
+
| **ENS** | Author identity resolution (forward/reverse) and profile metadata |
|
|
37
|
+
| **Fileverse** | IPFS-backed encrypted storage for AI scan reports (dDocs protocol) |
|
|
38
|
+
| **OSV** | Real-time CVE/GHSA advisory data with CVSS v3 scoring |
|
|
39
|
+
| **ChainPatrol** | Blocklist fallback for packages absent from the registry |
|
|
40
|
+
|
|
41
|
+
## Architecture Overview
|
|
42
|
+
|
|
43
|
+
OPM implements a domain-specific instantiation of the [ERC-8004 (Trustless Agents)](https://eips.ethereum.org/EIPS/eip-8004) pattern: agents hold on-chain identities, submit structured reputation signals (risk scores + reasoning), and attach off-chain validation evidence as Fileverse report URIs. Consumers invoking `opm install` query the registry, verify signatures, cross-reference OSV, and enforce configurable risk thresholds before permitting installation.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 32" fill="none">
|
|
2
|
+
<path d="M4 8L8 24L12 14L16 24L20 8" stroke="#ededed" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
+
<circle cx="12" cy="27" r="1.5" fill="#4ade80"/>
|
|
4
|
+
<text x="28" y="22" font-family="system-ui, -apple-system, sans-serif" font-size="18" font-weight="600" fill="#ededed" letter-spacing="-0.5">opm</text>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 32" fill="none">
|
|
2
|
+
<path d="M4 8L8 24L12 14L16 24L20 8" stroke="#0a0a0a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
+
<circle cx="12" cy="27" r="1.5" fill="#16a34a"/>
|
|
4
|
+
<text x="28" y="22" font-family="system-ui, -apple-system, sans-serif" font-size="18" font-weight="600" fill="#0a0a0a" letter-spacing="-0.5">opm</text>
|
|
5
|
+
</svg>
|
package/docs/mint.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://mintlify.com/schema.json",
|
|
3
|
+
"name": "OPM Documentation",
|
|
4
|
+
"logo": {
|
|
5
|
+
"dark": "/logo/dark.svg",
|
|
6
|
+
"light": "/logo/light.svg"
|
|
7
|
+
},
|
|
8
|
+
"favicon": "/favicon.svg",
|
|
9
|
+
"colors": {
|
|
10
|
+
"primary": "#ffffff",
|
|
11
|
+
"light": "#ededed",
|
|
12
|
+
"dark": "#0a0a0a",
|
|
13
|
+
"background": {
|
|
14
|
+
"dark": "#0a0a0a"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"topbarLinks": [
|
|
18
|
+
{
|
|
19
|
+
"name": "Website",
|
|
20
|
+
"url": "https://opm.dev"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"topbarCtaButton": {
|
|
24
|
+
"name": "GitHub",
|
|
25
|
+
"url": "https://github.com/dhananjaypai08/opm"
|
|
26
|
+
},
|
|
27
|
+
"tabs": [
|
|
28
|
+
{
|
|
29
|
+
"name": "CLI Reference",
|
|
30
|
+
"url": "cli"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Smart Contract",
|
|
34
|
+
"url": "contract"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Architecture",
|
|
38
|
+
"url": "architecture"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"anchors": [
|
|
42
|
+
{
|
|
43
|
+
"name": "BaseScan",
|
|
44
|
+
"icon": "cube",
|
|
45
|
+
"url": "https://sepolia.basescan.org/address/0x16684391fc9bf48246B08Afe16d1a57BFa181d48"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "npm",
|
|
49
|
+
"icon": "npm",
|
|
50
|
+
"url": "https://www.npmjs.com/package/opmsec"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"navigation": [
|
|
54
|
+
{
|
|
55
|
+
"group": "Getting Started",
|
|
56
|
+
"pages": [
|
|
57
|
+
"introduction",
|
|
58
|
+
"quickstart",
|
|
59
|
+
"configuration"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"group": "Core Concepts",
|
|
64
|
+
"pages": [
|
|
65
|
+
"concepts/security-model",
|
|
66
|
+
"concepts/multi-agent-consensus",
|
|
67
|
+
"concepts/on-chain-registry",
|
|
68
|
+
"concepts/zk-agent-verification"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"group": "CLI Reference",
|
|
73
|
+
"pages": [
|
|
74
|
+
"cli/push",
|
|
75
|
+
"cli/install",
|
|
76
|
+
"cli/check",
|
|
77
|
+
"cli/fix",
|
|
78
|
+
"cli/audit",
|
|
79
|
+
"cli/info",
|
|
80
|
+
"cli/view",
|
|
81
|
+
"cli/register-agent"
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"group": "Smart Contract",
|
|
86
|
+
"pages": [
|
|
87
|
+
"contract/overview",
|
|
88
|
+
"contract/functions",
|
|
89
|
+
"contract/events",
|
|
90
|
+
"contract/deployment"
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"group": "Architecture",
|
|
95
|
+
"pages": [
|
|
96
|
+
"architecture/overview",
|
|
97
|
+
"architecture/scanner",
|
|
98
|
+
"architecture/agents",
|
|
99
|
+
"architecture/benchmarks"
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"footerSocials": {
|
|
104
|
+
"github": "https://github.com/dhananjaypai08/opm"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Quickstart'
|
|
3
|
+
description: 'Get OPM up and running in minutes. Install the CLI, configure environment variables, and run your first security-verified install.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Quickstart
|
|
7
|
+
|
|
8
|
+
## 1. Install
|
|
9
|
+
|
|
10
|
+
<CodeGroup>
|
|
11
|
+
|
|
12
|
+
```bash npm
|
|
13
|
+
npm i -g opmsec
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```bash bun
|
|
17
|
+
bun add -g opmsec
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
</CodeGroup>
|
|
21
|
+
|
|
22
|
+
The `opm` binary is available globally after installation.
|
|
23
|
+
|
|
24
|
+
## 2. Set Environment Variables
|
|
25
|
+
|
|
26
|
+
<Note>
|
|
27
|
+
**Read-only commands** (`install`, `audit`, `info`, `view`, `whois`, `check`) require **no configuration**. Defaults for RPC, contract address, and API URLs are built-in.
|
|
28
|
+
</Note>
|
|
29
|
+
|
|
30
|
+
For **author-side commands** (`push`, `register-agent`), configure:
|
|
31
|
+
|
|
32
|
+
<CodeGroup>
|
|
33
|
+
|
|
34
|
+
```bash .env
|
|
35
|
+
# Required for opm push
|
|
36
|
+
OPM_SIGNING_KEY=0x... # Your Ethereum private key for package signing
|
|
37
|
+
AGENT_PRIVATE_KEY=0x... # Agent wallet key for score submission
|
|
38
|
+
NPM_TOKEN=... # npm automation token (optional; use --token flag otherwise)
|
|
39
|
+
|
|
40
|
+
# At least one required for AI scanning
|
|
41
|
+
OPENROUTER_API_KEY=... # Multi-model access (Claude, Gemini, DeepSeek)
|
|
42
|
+
# OR
|
|
43
|
+
OPENAI_API_KEY=... # Fallback (GPT-4.1 family)
|
|
44
|
+
|
|
45
|
+
# Optional: report uploads to IPFS
|
|
46
|
+
FILEVERSE_API_KEY=...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
</CodeGroup>
|
|
50
|
+
|
|
51
|
+
## 3. Basic Usage
|
|
52
|
+
|
|
53
|
+
### Security-Verified Install
|
|
54
|
+
|
|
55
|
+
<CodeGroup>
|
|
56
|
+
|
|
57
|
+
```bash Install specific package
|
|
58
|
+
opm install lodash
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```bash Install with version
|
|
62
|
+
opm install lodash@4.17.21
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```bash Verify all dependencies
|
|
66
|
+
opm install
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
</CodeGroup>
|
|
70
|
+
|
|
71
|
+
`opm install` resolves versions against the on-chain registry, verifies ECDSA signatures, checks OSV for CVEs, and blocks installation if risk exceeds the threshold (80).
|
|
72
|
+
|
|
73
|
+
### Sign, Scan, and Publish
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
opm push
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Computes SHA-256 checksum, signs with your wallet, dispatches 3 AI agents in parallel, submits scores on-chain, uploads report to Fileverse, publishes to npm, and registers on OPMRegistry.
|
|
80
|
+
|
|
81
|
+
### Scan Dependencies
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
opm check
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Scans all `dependencies` and `devDependencies` for typosquats, CVEs, and AI-detected risks. Outputs categorized findings.
|
|
88
|
+
|
|
89
|
+
### On-Chain Audit
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
opm audit
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Audits all dependencies against on-chain risk scores and CVE data.
|
|
96
|
+
|
|
97
|
+
### View Package Info
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
opm info lodash
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Displays on-chain security metadata: author, checksum, aggregate score, report URI.
|
|
104
|
+
|
|
105
|
+
### View Author Profile
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
opm view vitalik.eth
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Resolves ENS identity, fetches avatar and text records, and displays on-chain author reputation and published packages.
|
|
112
|
+
|
|
113
|
+
## What Happens Under the Hood
|
|
114
|
+
|
|
115
|
+
### `opm push` Verification Pipeline
|
|
116
|
+
|
|
117
|
+
1. **Checksum**: SHA-256 over packed tarball
|
|
118
|
+
2. **Sign**: ECDSA signature with author's Ethereum private key
|
|
119
|
+
3. **ENS**: Resolve author identity (Sepolia, Mainnet fallback)
|
|
120
|
+
4. **AI agents**: 3 models run in parallel—static analysis, risk scoring (0–100), structured JSON
|
|
121
|
+
5. **On-chain**: Agent wallets call `OPMRegistry.submitScore()`; aggregate computed; publish blocked if score ≥ 80
|
|
122
|
+
6. **Fileverse**: Upload formatted markdown report (encrypted, IPFS-synced)
|
|
123
|
+
7. **npm**: Publish tarball (automation token or OTP for 2FA)
|
|
124
|
+
8. **Registry**: `registerPackage()` stores checksum, signature, ENS name, report URI
|
|
125
|
+
|
|
126
|
+
### `opm install` Verification Pipeline
|
|
127
|
+
|
|
128
|
+
1. Resolve version against on-chain registry
|
|
129
|
+
2. Query OSV API for CVE/GHSA advisories (CRITICAL blocks install)
|
|
130
|
+
3. Fetch on-chain risk score and agent consensus
|
|
131
|
+
4. Verify ECDSA signature against tarball checksum
|
|
132
|
+
5. ChainPatrol API fallback for packages not in registry
|
|
133
|
+
6. Delegate to `npm install` if all gates pass
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opmsec",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"opm": "packages/cli/src/index.tsx"
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"bun-types": "latest"
|
|
32
32
|
},
|
|
33
33
|
"opm": {
|
|
34
|
-
"signature": "
|
|
34
|
+
"signature": "0xacf623c584df3b03a13588107cb0024212b50a20078a74d3a19394ea7378f2b23c679f3e351fd27393c5212f09ead8c826af1f103f535b9a802944e27b5ffa081b",
|
|
35
35
|
"author": "0x2a3942EbDd8c5ea3E66D3fC4301F56d0F15d4bE2",
|
|
36
36
|
"ensName": "djpaiethg.eth",
|
|
37
|
-
"checksum": "
|
|
37
|
+
"checksum": "0x5e73c81a9f22b1381766bbea30dee60a945ece4d320f3c4f65597beb0bc19269"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -5,6 +5,7 @@ import type { AuthorProfile } from '@opm/core';
|
|
|
5
5
|
import { Header } from '../components/Header';
|
|
6
6
|
import { StatusLine } from '../components/StatusLine';
|
|
7
7
|
import { RiskBadge } from '../components/RiskBadge';
|
|
8
|
+
import { Hyperlink } from '../components/Hyperlink';
|
|
8
9
|
import { resolveAddress, getENSTextRecords, type ENSProfile } from '../services/ens';
|
|
9
10
|
import {
|
|
10
11
|
getAuthorProfile,
|
|
@@ -71,6 +72,10 @@ export function AuthorViewCommand({ ensName }: AuthorViewProps) {
|
|
|
71
72
|
setEnsProfile(profile);
|
|
72
73
|
update('profile', 'done');
|
|
73
74
|
|
|
75
|
+
const avatarPromise = profile.avatar
|
|
76
|
+
? renderAvatar(profile.avatar).catch(() => null)
|
|
77
|
+
: Promise.resolve(null);
|
|
78
|
+
|
|
74
79
|
update('onchain', 'running');
|
|
75
80
|
let authorProfile: AuthorProfile | null = null;
|
|
76
81
|
if (addr) {
|
|
@@ -100,6 +105,9 @@ export function AuthorViewCommand({ ensName }: AuthorViewProps) {
|
|
|
100
105
|
update('packages', 'skip');
|
|
101
106
|
}
|
|
102
107
|
|
|
108
|
+
const art = await avatarPromise;
|
|
109
|
+
if (art) setAvatarArt(art);
|
|
110
|
+
|
|
103
111
|
setDone(true);
|
|
104
112
|
}
|
|
105
113
|
|
|
@@ -218,7 +226,7 @@ export function AuthorViewCommand({ ensName }: AuthorViewProps) {
|
|
|
218
226
|
{pkg.reportURI && !pkg.reportURI.startsWith('local://') && (
|
|
219
227
|
<Box>
|
|
220
228
|
<Text color="gray">Report: </Text>
|
|
221
|
-
<
|
|
229
|
+
<Hyperlink url={pkg.reportURI} />
|
|
222
230
|
</Box>
|
|
223
231
|
)}
|
|
224
232
|
</Box>
|