@neus/sdk 1.0.3 → 1.0.5
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 +127 -150
- package/SECURITY.md +33 -29
- package/cjs/client.cjs +308 -264
- package/cjs/index.cjs +403 -310
- package/cjs/utils.cjs +138 -97
- package/cli/neus.mjs +606 -0
- package/client.js +559 -470
- package/errors.js +5 -5
- package/gates.js +18 -18
- package/index.js +79 -75
- package/package.json +16 -10
- package/types.d.ts +138 -59
- package/utils.js +1291 -1180
- package/widgets/README.md +45 -64
- package/widgets/index.js +1 -1
- package/widgets/verify-gate/dist/ProofBadge.js +10 -18
- package/widgets/verify-gate/dist/VerifyGate.js +109 -98
- package/widgets/verify-gate/index.js +5 -5
package/README.md
CHANGED
|
@@ -1,150 +1,127 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
{ limit: 50, offset: 0 },
|
|
129
|
-
window.ethereum
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
await client.revokeOwnProof(proofId, window.ethereum);
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
Compatibility note: `qHash` remains supported as a deprecated alias (`proofId === qHash`).
|
|
136
|
-
|
|
137
|
-
## React widgets
|
|
138
|
-
|
|
139
|
-
For UI gating, see `./widgets/README.md`.
|
|
140
|
-
|
|
141
|
-
Widget imports:
|
|
142
|
-
|
|
143
|
-
```javascript
|
|
144
|
-
import { VerifyGate, ProofBadge } from '@neus/sdk/widgets';
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Reference docs
|
|
148
|
-
|
|
149
|
-
- API Reference: `../docs/api/README.md`
|
|
150
|
-
- OpenAPI (JSON): `../docs/api/public-api.json`
|
|
1
|
+
# @neus/sdk
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@neus/sdk)
|
|
4
|
+
|
|
5
|
+
**Portable trust, shipped as APIs and widgets.** The JavaScript SDK runs NEUS verification, polling, and **`gateCheck`**. Store **`proofId`** (your **proof ID**) once, then reuse. NEUS runs the checks; you do not fork verifier logic into your repo.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @neus/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## One-command onboarding
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx -y -p @neus/sdk neus init
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Configures supported MCP clients automatically. By default the command installs NEUS into user-level Claude Code, Cursor, and VS Code MCP config when those clients are detected.
|
|
20
|
+
|
|
21
|
+
## CLI
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Autopilot setup for detected clients
|
|
25
|
+
npx -y -p @neus/sdk neus init
|
|
26
|
+
|
|
27
|
+
# Enable personal account tools such as neus_me and private reads
|
|
28
|
+
npx -y -p @neus/sdk neus auth --access-key <npk_...>
|
|
29
|
+
|
|
30
|
+
# Inspect current NEUS MCP setup
|
|
31
|
+
npx -y -p @neus/sdk neus status --json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Use `neus init --project` when you want shared repo config instead of personal user-scope setup. Access keys stay user-scope only so secrets do not land in checked-in config.
|
|
35
|
+
|
|
36
|
+
## Minimal working example
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
import { NeusClient } from '@neus/sdk';
|
|
40
|
+
|
|
41
|
+
const client = new NeusClient();
|
|
42
|
+
|
|
43
|
+
const proof = await client.verify({
|
|
44
|
+
verifier: 'ownership-basic',
|
|
45
|
+
content: 'Hello NEUS',
|
|
46
|
+
wallet: window.ethereum,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const proofId = proof.proofId;
|
|
50
|
+
|
|
51
|
+
const check = await client.gateCheck({
|
|
52
|
+
address: '0x...',
|
|
53
|
+
verifierIds: ['ownership-basic'],
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
> [Hosted Verify](https://docs.neus.network/cookbook/auth-hosted-verify) | [Get started](https://docs.neus.network/get-started)
|
|
58
|
+
|
|
59
|
+
## Core methods
|
|
60
|
+
|
|
61
|
+
| Method | Purpose |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `client.verify()` | Create proof |
|
|
64
|
+
| `client.getProof()` | Fetch by `proofId` |
|
|
65
|
+
| `client.pollProofStatus()` | Wait for async completion |
|
|
66
|
+
| `client.gateCheck()` | **Server eligibility** (use for real gates) |
|
|
67
|
+
| `client.checkGate()` | Local preview only |
|
|
68
|
+
| `getHostedCheckoutUrl()` | Hosted verify URL |
|
|
69
|
+
| `client.createWalletLinkData()` | Build advanced direct wallet-link payload |
|
|
70
|
+
|
|
71
|
+
## VerifyGate (React)
|
|
72
|
+
|
|
73
|
+
Defaults: unlisted public create (`privacyLevel: 'public'`, `publicDisplay: false`). Set `proofOptions` for other visibility.
|
|
74
|
+
|
|
75
|
+
```jsx
|
|
76
|
+
import { VerifyGate } from '@neus/sdk/widgets';
|
|
77
|
+
|
|
78
|
+
<VerifyGate appId="your-app-id" requiredVerifiers={['ownership-basic']}>
|
|
79
|
+
<ProtectedContent />
|
|
80
|
+
</VerifyGate>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
[Widgets README](./widgets/README.md)
|
|
84
|
+
|
|
85
|
+
## Config
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
const client = new NeusClient({
|
|
89
|
+
apiUrl: 'https://api.neus.network',
|
|
90
|
+
appId: 'my-app',
|
|
91
|
+
timeout: 30000,
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Wallet-link
|
|
96
|
+
|
|
97
|
+
For user-facing browser flows, prefer Hosted Verify so the user can select a secondary wallet, sign once, see the linked state, and only then continue to proof creation.
|
|
98
|
+
|
|
99
|
+
Use `client.createWalletLinkData()` only for advanced direct/API flows where your app already controls the secondary-wallet provider:
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
const walletLinkData = await client.createWalletLinkData({
|
|
103
|
+
primaryWalletAddress: '0xprimary...',
|
|
104
|
+
secondaryWalletAddress: '0xsecondary...',
|
|
105
|
+
wallet: window.ethereum,
|
|
106
|
+
relationshipType: 'linked',
|
|
107
|
+
label: 'ops-wallet'
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
await client.verify({
|
|
111
|
+
verifier: 'wallet-link',
|
|
112
|
+
data: walletLinkData
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Docs
|
|
117
|
+
|
|
118
|
+
- [Quickstart](https://docs.neus.network/quickstart)
|
|
119
|
+
- [SDK](https://docs.neus.network/sdks/javascript)
|
|
120
|
+
- [MCP](https://docs.neus.network/mcp/overview) (IDEs and assistants)
|
|
121
|
+
- [Widgets](https://docs.neus.network/widgets/overview)
|
|
122
|
+
- [API](https://docs.neus.network/api/overview)
|
|
123
|
+
- [Hosted Verify](https://docs.neus.network/cookbook/auth-hosted-verify)
|
|
124
|
+
|
|
125
|
+
## Contributing
|
|
126
|
+
|
|
127
|
+
See [CONTRIBUTING.md](../CONTRIBUTING.md) for how to propose documentation, SDK, and example changes.
|
package/SECURITY.md
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
# NEUS SDK security notes
|
|
2
|
-
|
|
3
|
-
Treat **wallet signatures** and **API keys** as secrets. Do not log them, expose them to clients, or store them in analytics.
|
|
4
|
-
|
|
5
|
-
## Authentication model
|
|
6
|
-
|
|
7
|
-
- **Verification
|
|
8
|
-
- **
|
|
9
|
-
- **Owner-only reads** of private proof payloads require an
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
# NEUS SDK security notes
|
|
2
|
+
|
|
3
|
+
Treat **wallet signatures** and **API keys** as secrets. Do not log them, expose them to clients, or store them in analytics.
|
|
4
|
+
|
|
5
|
+
## Authentication model
|
|
6
|
+
|
|
7
|
+
- **Verification requests** are authenticated with a wallet signature over the **CAIP-380 Portable Proof** six-line signing string. Never roll your own message format in production—use the SDK or the hosted preparation step documented for HTTP integrations.
|
|
8
|
+
- **Proof lookups by `proofId`** are safe for public proofs. Private proofs return a minimal payload unless the caller proves ownership (authenticated owner or signed request).
|
|
9
|
+
- **Owner-only reads** of private proof payloads require an extra owner-signed request. The SDK attaches the required signed headers for you.
|
|
10
|
+
|
|
11
|
+
## Do not
|
|
12
|
+
|
|
13
|
+
- Do not treat proof signatures as bearer tokens (they are request-bound).
|
|
14
|
+
- Do not embed API keys in browser apps. Keep API keys server-side only.
|
|
15
|
+
- Do not log or persist proof signatures, API keys, or third-party auth credentials (if your integration uses them).
|
|
16
|
+
|
|
17
|
+
## Privacy defaults
|
|
18
|
+
|
|
19
|
+
**`client.verify()`** defaults to **private** stored results with **original content stored** (owner-authenticated reads).
|
|
20
|
+
|
|
21
|
+
**`VerifyGate`** create mode defaults to **unlisted public** (`privacyLevel: 'public'`, `publicDisplay: false`, `storeOriginalContent: true`) so gates and `gateCheck` work without extra options.
|
|
22
|
+
|
|
23
|
+
For raw SDK flows that must power **`gateCheck`** without owner-authenticated access, set **unlisted public** explicitly (`privacyLevel: 'public'`, `publicDisplay: false`). Anyone with the proof id can resolve public proofs. Do not treat unlisted as secret.
|
|
24
|
+
|
|
25
|
+
**Hide original content** (metadata/hash only): set `storeOriginalContent: false` when your product must not persist original bytes.
|
|
26
|
+
|
|
27
|
+
Controls:
|
|
28
|
+
|
|
29
|
+
- `privacyLevel` - private (vaulted to the wallet) vs public (eligible for policy checks without proving owner identity)
|
|
30
|
+
- `publicDisplay` - discovery vs unlisted
|
|
31
|
+
- `storeOriginalContent` - retain original content vs hash/metadata only
|
|
32
|
+
|
|
33
|
+
Discoverable listings require **`privacyLevel: 'public'`** and **`publicDisplay: true`**.
|