@neus/sdk 1.0.3 → 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 CHANGED
@@ -1,150 +1,90 @@
1
- # NEUS SDK
2
-
3
- JavaScript client (and optional widgets) for the NEUS Network verification API.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install @neus/sdk
9
- ```
10
-
11
- ## Create a proof (browser wallet flow)
12
-
13
- This path requests a wallet signature in the browser and submits the verification request:
14
-
15
- ```javascript
16
- import { NeusClient } from '@neus/sdk';
17
-
18
- const client = new NeusClient({ apiUrl: 'https://api.neus.network' });
19
-
20
- const res = await client.verify({
21
- verifier: 'ownership-basic',
22
- content: 'Hello NEUS'
23
- });
24
-
25
- // Proof ID (standard). qHash is a deprecated alias.
26
- const proofId = res.proofId;
27
- const status = await client.getStatus(proofId);
28
- ```
29
-
30
- ## Client configuration
31
-
32
- ```javascript
33
- const client = new NeusClient({
34
- // Optional: API base URL (default: https://api.neus.network)
35
- apiUrl: 'https://api.neus.network',
36
- // Optional: request timeout (ms)
37
- timeout: 30000,
38
- });
39
- ```
40
-
41
- ## Create a proof (server / manual signing)
42
-
43
- If you already have a signature over the NEUS Standard Signing String, submit it directly:
44
-
45
- ```javascript
46
- const res = await client.verify({
47
- verifierIds: ['ownership-basic'],
48
- data: {
49
- owner: '0x1111111111111111111111111111111111111111',
50
- content: 'Hello NEUS',
51
- reference: { type: 'url', id: 'https://example.com' }
52
- },
53
- walletAddress: '0x1111111111111111111111111111111111111111',
54
- signature: '0x...',
55
- signedTimestamp: Date.now(),
56
- chainId: 84532,
57
- options: { privacyLevel: 'private' }
58
- });
59
- ```
60
-
61
- ## What verifiers are available?
62
-
63
- Use the API directly (avoids drift):
64
-
65
- - `GET /api/v1/verification/verifiers`
66
-
67
- ## Hosted interactive verifiers
68
-
69
- For interactive verifiers (`ownership-social`, `ownership-org-oauth`, `proof-of-human`), use `VerifyGate` hosted checkout mode.
70
- These flows require NEUS-hosted popup/redirect UX (OAuth/ZK), not direct wallet-only creation via `client.verify(...)`.
71
-
72
- ```jsx
73
- import { VerifyGate } from '@neus/sdk/widgets';
74
-
75
- export default function HostedGateExample() {
76
- return (
77
- <VerifyGate
78
- requiredVerifiers={['ownership-social']}
79
- onVerified={(result) => {
80
- console.log('Hosted verification complete:', result.proofId);
81
- }}
82
- >
83
- <button>Unlock with Social</button>
84
- </VerifyGate>
85
- );
86
- }
87
- ```
88
-
89
- ## Gate checks (recommended for server-side gating)
90
-
91
- For production server-side gating, prefer the minimal public endpoint:
92
-
93
- ```javascript
94
- const res = await client.gateCheck({
95
- address: 'YOUR_WALLET_OR_DID',
96
- verifierIds: ['token-holding'],
97
- contractAddress: '0x...',
98
- minBalance: '100',
99
- chainId: 8453,
100
- // Optional: require a recent proof for point-in-time verifiers (example: last hour)
101
- since: Date.now() - 60 * 60 * 1000
102
- });
103
-
104
- if (!res.data?.eligible) {
105
- throw new Error('Access denied');
106
- }
107
- ```
108
-
109
- Note: `gateCheck` evaluates **existing public/discoverable proofs**. For strict real-time decisions, create a new proof via `client.verify(...)` (or `POST /api/v1/verification`) and use the final status.
110
-
111
- ## Resilience & Polling
112
-
113
- The SDK is designed for production stability:
114
- - **Automatic Backoff**: `pollProofStatus()` automatically detects rate limiting (`429`) and applies jittered exponential backoff.
115
- - **Wallet Identification**: Automatically attaches headers to preferred wallet-based limiting for higher reliability behind shared IPs (NATs).
116
-
117
- - Private proof by Proof ID: `client.getPrivateStatus(proofId, wallet)`
118
- - Private proofs by wallet/DID: `client.getPrivateProofsByWallet(walletOrDid, { limit, offset }, wallet)` (owner dashboard / first-party UX only; not recommended for integrator gating)
119
- - Revoke your proof: `client.revokeOwnProof(proofId, wallet)`
120
-
121
- Example:
122
-
123
- ```javascript
124
- const privateData = await client.getPrivateStatus(proofId, window.ethereum);
125
-
126
- const privateProofs = await client.getPrivateProofsByWallet(
127
- 'YOUR_WALLET_OR_DID',
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
+ [![npm](https://img.shields.io/npm/v/%40neus%2Fsdk?logo=npm&label=%40neus%2Fsdk&color=98C0EF)](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
+ Prints the hosted MCP URL and documentation links in your terminal - fast setup in IDEs and agent clients.
20
+
21
+ ## Minimal working example
22
+
23
+ ```javascript
24
+ import { NeusClient } from '@neus/sdk';
25
+
26
+ const client = new NeusClient();
27
+
28
+ const proof = await client.verify({
29
+ verifier: 'ownership-basic',
30
+ content: 'Hello NEUS',
31
+ wallet: window.ethereum,
32
+ });
33
+
34
+ const proofId = proof.proofId;
35
+
36
+ const check = await client.gateCheck({
37
+ address: '0x...',
38
+ verifierIds: ['ownership-basic'],
39
+ });
40
+ ```
41
+
42
+ > [Hosted Verify](https://docs.neus.network/cookbook/auth-hosted-verify) | [Get started](https://docs.neus.network/get-started)
43
+
44
+ ## Core methods
45
+
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 |
54
+
55
+ ## VerifyGate (React)
56
+
57
+ Defaults: unlisted public create (`privacyLevel: 'public'`, `publicDisplay: false`). Set `proofOptions` for other visibility.
58
+
59
+ ```jsx
60
+ import { VerifyGate } from '@neus/sdk/widgets';
61
+
62
+ <VerifyGate appId="your-app-id" requiredVerifiers={['ownership-basic']}>
63
+ <ProtectedContent />
64
+ </VerifyGate>
65
+ ```
66
+
67
+ [Widgets README](./widgets/README.md)
68
+
69
+ ## Config
70
+
71
+ ```javascript
72
+ const client = new NeusClient({
73
+ apiUrl: 'https://api.neus.network',
74
+ appId: 'my-app',
75
+ timeout: 30000,
76
+ });
77
+ ```
78
+
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
89
+
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 (public surface)
6
-
7
- - **Verification submission** (`POST /api/v1/verification`) is authenticated by a signature over the **NEUS Standard Signing String**.
8
- - **Status by Proof ID (qHash)** (`GET /api/v1/verification/status/{qHash}`) is safe to call publicly.
9
- - **Owner-only reads** of private proof payloads require an additional owner signature. The SDK uses:
10
- - `x-wallet-address`
11
- - `x-signature`
12
- - `x-signed-timestamp`
13
-
14
- ## Do not
15
-
16
- - Do not treat proof signatures as bearer tokens (they are request-bound).
17
- - Do not embed API keys in browser apps. Keep API keys server-side only.
18
- - Do not log or persist:
19
- - proof signatures
20
- - API keys
21
- - third-party auth credentials or provider tokens (if your integration uses them)
22
-
23
- ## Recommended privacy defaults
24
-
25
- - `privacyLevel: 'private'`
26
- - `publicDisplay: false`
27
- - `storeOriginalContent: false`
28
-
29
- “Discoverable” proofs are **public** (`privacyLevel='public'`) and explicitly opted into discovery (`publicDisplay=true`).
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`**.