@neus/sdk 1.0.12 → 1.1.1
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 +206 -208
- package/cjs/client.cjs +191 -22
- package/cjs/errors.cjs +2 -35
- package/cjs/gates.cjs +1 -21
- package/cjs/index.cjs +203 -22
- package/cjs/utils.cjs +2 -0
- package/cli/neus.mjs +1215 -120
- package/client.js +150 -31
- package/errors.js +154 -189
- package/gates.js +0 -20
- package/index.js +2 -0
- package/package.json +142 -135
- package/sponsor.js +95 -0
- package/types.d.ts +91 -14
- package/utils.js +2 -0
- package/widgets/README.md +1 -1
- package/widgets/verify-gate/dist/ProofBadge.js +8 -16
- package/widgets/verify-gate/dist/VerifyGate.js +28 -15
- package/neus-logo.svg +0 -3
package/README.md
CHANGED
|
@@ -1,208 +1,206 @@
|
|
|
1
|
-
# @neus/sdk
|
|
2
|
-
|
|
3
|
-
Create, check, and reuse NEUS trust receipts from apps and backends. The same package ships the **`neus`** CLI for
|
|
4
|
-
|
|
5
|
-
NEUS makes trust portable across
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
|
165
|
-
|
|
|
166
|
-
| `
|
|
167
|
-
| `client.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
206
|
-
-
|
|
207
|
-
- MCP: https://docs.neus.network/mcp/overview
|
|
208
|
-
- API: https://docs.neus.network/api/overview
|
|
1
|
+
# @neus/sdk
|
|
2
|
+
|
|
3
|
+
Create, check, and reuse NEUS trust receipts from apps and backends. The same package ships the **`neus`** CLI for hosted MCP setup and portable agent import.
|
|
4
|
+
|
|
5
|
+
NEUS makes trust portable across apps, agents, and ecosystems before access, payment, or action.
|
|
6
|
+
|
|
7
|
+
Roadmap: [docs.neus.network/platform/status](https://docs.neus.network/platform/status)
|
|
8
|
+
|
|
9
|
+
## Install (library)
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @neus/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Bring Your Own Agent (BYOA)
|
|
16
|
+
|
|
17
|
+
Already have an agent setup? Use the CLI to package supported local agent context, including instructions, rules, skills, and MCP server references from **OpenClaw, Cursor, Claude Code, and Claude Desktop**:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx -y -p @neus/sdk neus import
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This prepares a local portable-agent manifest. In MCP, call `neus_agent_link` first; if setup is missing, use `neus_agent_create`, complete the hosted or signing steps, then call `neus_agent_link` again until `linked: true`.
|
|
24
|
+
|
|
25
|
+
*To check what will be imported without writing changes:*
|
|
26
|
+
```bash
|
|
27
|
+
npx -y -p @neus/sdk neus import --dry-run
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Connect editors and assistants
|
|
31
|
+
|
|
32
|
+
| Topic | Link |
|
|
33
|
+
| --------------------------------- | ----------------------------------------------------------------------------- |
|
|
34
|
+
| Setup, JSON snippets, and headers | [MCP setup](https://docs.neus.network/mcp/setup) |
|
|
35
|
+
| Tools and session order | [MCP overview](https://docs.neus.network/mcp/overview) |
|
|
36
|
+
| Discovery URLs | [Discovery and endpoints](https://docs.neus.network/mcp/endpoints) |
|
|
37
|
+
| NEUS for AI assistants | [NEUS for AI assistants](https://docs.neus.network/mcp/ide-plugin) |
|
|
38
|
+
|
|
39
|
+
Prefer `neus setup` over hand-editing config files so every host stays on **`https://mcp.neus.network/mcp`**.
|
|
40
|
+
|
|
41
|
+
## What you can ship
|
|
42
|
+
|
|
43
|
+
- Hosted verification flows that return a reusable receipt
|
|
44
|
+
- Server checks before access, rewards, payments, or actions
|
|
45
|
+
- React gates with `VerifyGate`
|
|
46
|
+
- Agent identity and scoped delegation
|
|
47
|
+
- MCP setup for assistants and agent tools
|
|
48
|
+
|
|
49
|
+
## Fastest path: Hosted Verify
|
|
50
|
+
|
|
51
|
+
Use Hosted Verify when you want NEUS to handle the signing/verification flow outside your app UI.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { getHostedCheckoutUrl } from '@neus/sdk';
|
|
55
|
+
|
|
56
|
+
const url = getHostedCheckoutUrl({
|
|
57
|
+
verifiers: ['ownership-basic'],
|
|
58
|
+
returnUrl: 'https://yourapp.com/auth/callback'
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
window.location.assign(url);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
After completion, NEUS redirects back with a `qHash`. Store it with your user or record.
|
|
65
|
+
|
|
66
|
+
## Advanced: in-app signing
|
|
67
|
+
|
|
68
|
+
Use this only when your app intentionally handles signing. This example is EVM. For non-EVM accounts, pass the provider explicitly and include `chain` as a CAIP-2 value.
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
import { NeusClient } from '@neus/sdk';
|
|
72
|
+
|
|
73
|
+
const client = new NeusClient({
|
|
74
|
+
appId: 'your-app-id'
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const proof = await client.verify({
|
|
78
|
+
verifier: 'ownership-basic',
|
|
79
|
+
data: {
|
|
80
|
+
owner: '0x...',
|
|
81
|
+
contentType: 'application/json',
|
|
82
|
+
content: JSON.stringify({
|
|
83
|
+
title: 'Verified claim',
|
|
84
|
+
type: 'project-update',
|
|
85
|
+
summary: 'Public summary of what is being proven.'
|
|
86
|
+
}),
|
|
87
|
+
reference: {
|
|
88
|
+
type: 'url',
|
|
89
|
+
id: 'https://example.com/source',
|
|
90
|
+
title: 'Source record'
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
wallet: window.ethereum // EVM provider
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
console.log(proof.qHash);
|
|
97
|
+
console.log(proof.proofUrl);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## React widget
|
|
101
|
+
|
|
102
|
+
Use `VerifyGate` when you want a drop-in verification flow in React.
|
|
103
|
+
|
|
104
|
+
```jsx
|
|
105
|
+
import { VerifyGate } from '@neus/sdk/widgets';
|
|
106
|
+
|
|
107
|
+
export function Page() {
|
|
108
|
+
return (
|
|
109
|
+
<VerifyGate
|
|
110
|
+
appId="your-app-id"
|
|
111
|
+
requiredVerifiers={['ownership-basic']}
|
|
112
|
+
verifierData={{
|
|
113
|
+
'ownership-basic': {
|
|
114
|
+
owner: '0x...',
|
|
115
|
+
contentType: 'application/json',
|
|
116
|
+
content: JSON.stringify({
|
|
117
|
+
title: 'Verified claim',
|
|
118
|
+
summary: 'Public summary of what is being proven.'
|
|
119
|
+
}),
|
|
120
|
+
reference: {
|
|
121
|
+
type: 'url',
|
|
122
|
+
id: 'https://example.com/source'
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}}
|
|
126
|
+
onVerified={result => {
|
|
127
|
+
console.log(result.qHash || result.qHashes);
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Check receipts
|
|
135
|
+
|
|
136
|
+
Use `gateCheck` from trusted server code when you need allow/deny or eligibility checks.
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
import { NeusClient } from '@neus/sdk';
|
|
140
|
+
|
|
141
|
+
const client = new NeusClient({
|
|
142
|
+
appId: 'your-app-id'
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const result = await client.gateCheck({
|
|
146
|
+
address: '0x...',
|
|
147
|
+
verifierIds: ['ownership-basic']
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
if (!result.data?.eligible) {
|
|
151
|
+
throw new Error('Access denied');
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Never ship access keys in browser code.
|
|
156
|
+
|
|
157
|
+
## Core methods
|
|
158
|
+
|
|
159
|
+
| Method | Use it for |
|
|
160
|
+
| ------------------------------- | ------------------------------------------- |
|
|
161
|
+
| `getHostedCheckoutUrl()` | Send a user to Hosted Verify |
|
|
162
|
+
| `client.verify()` | Create a proof |
|
|
163
|
+
| `client.getProof()` | Fetch a receipt by `qHash` |
|
|
164
|
+
| `client.pollProofStatus()` | Wait for async completion |
|
|
165
|
+
| `client.gateCheck()` | Server-side eligibility checks |
|
|
166
|
+
| `client.checkGate()` | Local preview against already-loaded proofs |
|
|
167
|
+
| `client.createWalletLinkData()` | Wallet-link payloads |
|
|
168
|
+
|
|
169
|
+
## Configuration
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
const client = new NeusClient({
|
|
173
|
+
apiUrl: 'https://api.neus.network',
|
|
174
|
+
appId: 'your-app-id',
|
|
175
|
+
timeout: 30000
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
`appId` is public attribution for your app.
|
|
180
|
+
`apiKey` / `npk_*` is optional and server-side only.
|
|
181
|
+
|
|
182
|
+
## MCP step-by-step
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npx -y -p @neus/sdk neus setup
|
|
186
|
+
npx -y -p @neus/sdk neus auth
|
|
187
|
+
npx -y -p @neus/sdk neus doctor --live
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Re-sign in or rotate credentials:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npx -y -p @neus/sdk neus auth
|
|
194
|
+
npx -y -p @neus/sdk neus auth --access-key <npk_...> # servers and CI only
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Editors with plugin marketplaces can install **`neus-trust@neus`** for the bundled session workflow. OpenClaw, Hermes, and other runtimes: see [NEUS for AI assistants](https://docs.neus.network/mcp/ide-plugin) for exact paths.
|
|
198
|
+
|
|
199
|
+
## Docs
|
|
200
|
+
|
|
201
|
+
- Quickstart: https://docs.neus.network/quickstart
|
|
202
|
+
- JavaScript SDK: https://docs.neus.network/sdks/javascript
|
|
203
|
+
- Ownership Basic: https://docs.neus.network/verification/ownership-basic
|
|
204
|
+
- Widgets: https://docs.neus.network/widgets/overview
|
|
205
|
+
- MCP: https://docs.neus.network/mcp/overview
|
|
206
|
+
- API: https://docs.neus.network/api/overview
|