@neus/sdk 1.0.2 → 1.0.4
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 +53 -75
- package/SECURITY.md +33 -29
- package/cjs/client.cjs +678 -337
- package/cjs/errors.cjs +1 -0
- package/cjs/gates.cjs +1 -0
- package/cjs/index.cjs +927 -362
- package/cjs/utils.cjs +408 -32
- package/cli/neus.mjs +58 -0
- package/client.js +1957 -1728
- package/errors.js +5 -5
- package/gates.js +18 -18
- package/index.js +18 -3
- package/neus-logo.svg +3 -0
- package/package.json +21 -11
- package/types.d.ts +303 -53
- package/utils.js +1291 -777
- package/widgets/README.md +12 -20
- package/widgets/index.js +9 -9
- package/widgets/verify-gate/dist/ProofBadge.js +57 -52
- package/widgets/verify-gate/dist/VerifyGate.js +357 -121
- package/widgets/verify-gate/index.js +13 -13
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @neus/sdk
|
|
2
2
|
|
|
3
|
-
|
|
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.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
@@ -8,105 +10,81 @@ JavaScript client (and optional widgets) for the NEUS Network verification API.
|
|
|
8
10
|
npm install @neus/sdk
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## One-command onboarding
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx -y -p @neus/sdk neus init
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Prints the hosted MCP URL and documentation links in your terminal - fast setup in IDEs and agent clients.
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
## Minimal working example
|
|
14
22
|
|
|
15
23
|
```javascript
|
|
16
24
|
import { NeusClient } from '@neus/sdk';
|
|
17
25
|
|
|
18
|
-
const client = new NeusClient(
|
|
26
|
+
const client = new NeusClient();
|
|
19
27
|
|
|
20
|
-
const
|
|
28
|
+
const proof = await client.verify({
|
|
21
29
|
verifier: 'ownership-basic',
|
|
22
30
|
content: 'Hello NEUS',
|
|
23
|
-
wallet: window.ethereum
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Proof ID (qHash): stable identifier you can store and use for status polling
|
|
27
|
-
const proofId = res.qHash;
|
|
28
|
-
const status = await client.getStatus(proofId);
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Client configuration
|
|
32
|
-
|
|
33
|
-
```javascript
|
|
34
|
-
const client = new NeusClient({
|
|
35
|
-
// Optional: point at a self-hosted deployment
|
|
36
|
-
apiUrl: 'https://api.neus.network',
|
|
37
|
-
// Optional: request timeout (ms)
|
|
38
|
-
timeout: 30000,
|
|
31
|
+
wallet: window.ethereum,
|
|
39
32
|
});
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Create a proof (server / manual signing)
|
|
43
33
|
|
|
44
|
-
|
|
34
|
+
const proofId = proof.proofId;
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
const check = await client.gateCheck({
|
|
37
|
+
address: '0x...',
|
|
48
38
|
verifierIds: ['ownership-basic'],
|
|
49
|
-
data: {
|
|
50
|
-
owner: '0x1111111111111111111111111111111111111111',
|
|
51
|
-
content: 'Hello NEUS',
|
|
52
|
-
reference: { type: 'url', id: 'https://example.com' }
|
|
53
|
-
},
|
|
54
|
-
walletAddress: '0x1111111111111111111111111111111111111111',
|
|
55
|
-
signature: '0x...',
|
|
56
|
-
signedTimestamp: Date.now(),
|
|
57
|
-
chainId: 84532,
|
|
58
|
-
options: { privacyLevel: 'private' }
|
|
59
39
|
});
|
|
60
40
|
```
|
|
61
41
|
|
|
62
|
-
|
|
42
|
+
> [Hosted Verify](https://docs.neus.network/cookbook/auth-hosted-verify) | [Get started](https://docs.neus.network/get-started)
|
|
63
43
|
|
|
64
|
-
|
|
44
|
+
## Core methods
|
|
65
45
|
|
|
66
|
-
|
|
46
|
+
| Method | Purpose |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `client.verify()` | Create proof |
|
|
49
|
+
| `client.getProof()` | Fetch by `proofId` |
|
|
50
|
+
| `client.pollProofStatus()` | Wait for async completion |
|
|
51
|
+
| `client.gateCheck()` | **Server eligibility** (use for real gates) |
|
|
52
|
+
| `client.checkGate()` | Local preview only |
|
|
53
|
+
| `getHostedCheckoutUrl()` | Hosted verify URL |
|
|
67
54
|
|
|
68
|
-
##
|
|
55
|
+
## VerifyGate (React)
|
|
69
56
|
|
|
70
|
-
|
|
57
|
+
Defaults: unlisted public create (`privacyLevel: 'public'`, `publicDisplay: false`). Set `proofOptions` for other visibility.
|
|
71
58
|
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
address: '0x...',
|
|
75
|
-
verifierIds: ['token-holding'],
|
|
76
|
-
contractAddress: '0x...',
|
|
77
|
-
minBalance: '100',
|
|
78
|
-
chainId: 1,
|
|
79
|
-
// Optional: require a recent proof for point-in-time verifiers (example: last hour)
|
|
80
|
-
since: Date.now() - 60 * 60 * 1000
|
|
81
|
-
});
|
|
59
|
+
```jsx
|
|
60
|
+
import { VerifyGate } from '@neus/sdk/widgets';
|
|
82
61
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
62
|
+
<VerifyGate appId="your-app-id" requiredVerifiers={['ownership-basic']}>
|
|
63
|
+
<ProtectedContent />
|
|
64
|
+
</VerifyGate>
|
|
86
65
|
```
|
|
87
66
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
## Resilience & Polling
|
|
91
|
-
|
|
92
|
-
The SDK is designed for production stability:
|
|
93
|
-
- **Automatic Backoff**: `pollProofStatus()` automatically detects rate limiting (`429`) and applies jittered exponential backoff.
|
|
94
|
-
- **Wallet Identification**: Automatically attaches headers to preferred wallet-based limiting for higher reliability behind shared IPs (NATs).
|
|
95
|
-
|
|
96
|
-
- Private proof by Proof ID (qHash): `client.getPrivateStatus(qHash, wallet)`
|
|
97
|
-
- Private proofs by wallet/DID: `client.getPrivateProofsByWallet(walletOrDid, { limit, offset }, wallet)`
|
|
67
|
+
[Widgets README](./widgets/README.md)
|
|
98
68
|
|
|
99
|
-
##
|
|
100
|
-
|
|
101
|
-
For UI gating, see `./widgets/README.md`.
|
|
102
|
-
|
|
103
|
-
Widget imports:
|
|
69
|
+
## Config
|
|
104
70
|
|
|
105
71
|
```javascript
|
|
106
|
-
|
|
72
|
+
const client = new NeusClient({
|
|
73
|
+
apiUrl: 'https://api.neus.network',
|
|
74
|
+
appId: 'my-app',
|
|
75
|
+
timeout: 30000,
|
|
76
|
+
});
|
|
107
77
|
```
|
|
108
78
|
|
|
109
|
-
##
|
|
79
|
+
## Docs
|
|
80
|
+
|
|
81
|
+
- [Quickstart](https://docs.neus.network/quickstart)
|
|
82
|
+
- [SDK](https://docs.neus.network/sdks/javascript)
|
|
83
|
+
- [MCP](https://docs.neus.network/mcp/overview) (IDEs and assistants)
|
|
84
|
+
- [Widgets](https://docs.neus.network/widgets/overview)
|
|
85
|
+
- [API](https://docs.neus.network/api/overview)
|
|
86
|
+
- [Hosted Verify](https://docs.neus.network/cookbook/auth-hosted-verify)
|
|
87
|
+
|
|
88
|
+
## Contributing
|
|
110
89
|
|
|
111
|
-
|
|
112
|
-
- OpenAPI (JSON): `../docs/api/public-api.json`
|
|
90
|
+
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`**.
|