@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/widgets/README.md CHANGED
@@ -1,64 +1,45 @@
1
- # NEUS Widgets (VerifyGate + ProofBadge)
2
-
3
- React components for NEUS verification and access gating.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install @neus/sdk react react-dom
9
- ```
10
-
11
- ## VerifyGate
12
-
13
- Gate UI behind verification requirements.
14
-
15
- ```jsx
16
- import { VerifyGate } from '@neus/sdk/widgets';
17
-
18
- export function Page() {
19
- return (
20
- <VerifyGate
21
- requiredVerifiers={['nft-ownership']}
22
- verifierData={{
23
- 'nft-ownership': { contractAddress: '0x...', tokenId: '1', chainId: 8453 }
24
- }}
25
- >
26
- <div>Unlocked</div>
27
- </VerifyGate>
28
- );
29
- }
30
- ```
31
-
32
- ### Key props
33
-
34
- - `requiredVerifiers`: `string[]` (default: `['ownership-basic']`)
35
- - `verifierData`: object keyed by verifier id
36
- - `strategy`: `'reuse-or-create' | 'reuse' | 'fresh'` (default: `'reuse-or-create'`)
37
- - `proofOptions`: `{ privacyLevel, publicDisplay, storeOriginalContent, enableIpfs? }` (defaults: private)
38
- - `mode`: `'create' | 'access'` (default: `'create'`)
39
- - `proofId`: string (required for `mode="access"`)
40
- - `maxProofAgeMs`: `number` (optional) - max proof age override in milliseconds for reuse checks
41
- - `onError`: `(error: Error) => void` (optional) - called when verification/gating errors occur
42
- - `apiUrl`: protocol API base URL (optional)
43
- - `hostedCheckoutUrl`: hosted verify page URL (optional, recommended when `apiUrl` is custom)
44
-
45
- Notes:
46
- - Reuse without prompting can only see **public + discoverable** proofs.
47
- - Reusing private proofs requires an **owner signature** (wallet grants read access).
48
- - Interactive verifiers (`ownership-social`, `ownership-org-oauth`, `proof-of-human`) use NEUS hosted checkout automatically when required.
49
- - If you set a custom `apiUrl`, also set `hostedCheckoutUrl` to your hosted verify UI (for example `https://neus.network/verify`).
50
- `apiUrl` is used for API calls; `hostedCheckoutUrl` is used for popup checkout routing.
51
-
52
- ## ProofBadge
53
-
54
- Display verification status by Proof ID (`proofId`).
55
-
56
- ```jsx
57
- import { ProofBadge } from '@neus/sdk/widgets';
58
-
59
- <ProofBadge proofId="0x..." showChains />
60
- ```
61
-
62
- Notes:
63
- - Widgets default to a bundled NEUS logo asset (inlined at build time), so no external logo fetch is required.
64
- - You can override with `logoUrl` in `ProofBadge`, `SimpleProofBadge`, `NeusPillLink`, and `VerifiedIcon`.
1
+ # NEUS Widgets
2
+
3
+ **Proof-aware React components** (VerifyGate, ProofBadge) so your UI can show verified state and gate content **using the same checks your server already trusts** - avoid re-implementing verifier rules only in the browser.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @neus/sdk react react-dom
9
+ ```
10
+
11
+ ## VerifyGate
12
+
13
+ Create mode defaults to **unlisted public** for gate-friendly reuse. Override `proofOptions` when you need listed public or private.
14
+
15
+ ```jsx
16
+ import { VerifyGate } from '@neus/sdk/widgets';
17
+
18
+ export function Page() {
19
+ return (
20
+ <VerifyGate
21
+ appId="your-app-id"
22
+ requiredVerifiers={['nft-ownership']}
23
+ verifierData={{
24
+ 'nft-ownership': { contractAddress: '0x...', tokenId: '1', chainId: 8453 }
25
+ }}
26
+ >
27
+ <div>Unlocked</div>
28
+ </VerifyGate>
29
+ );
30
+ }
31
+ ```
32
+
33
+ ## ProofBadge
34
+
35
+ ```jsx
36
+ import { ProofBadge } from '@neus/sdk/widgets';
37
+
38
+ <ProofBadge proofId="0x..." showChains />
39
+ ```
40
+
41
+ ## Docs
42
+
43
+ - [Widgets Overview](https://docs.neus.network/widgets/overview)
44
+ - [Verify Component](https://docs.neus.network/widgets/verifygate)
45
+ - [Quickstart](https://docs.neus.network/quickstart)
package/widgets/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * NEUS Widgets
3
- *
3
+ *
4
4
  * Core Widgets:
5
5
  * - VerifyGate: Universal verification gate component
6
6
  * - ProofBadge: Display verification status
@@ -58,22 +58,19 @@ function ProofBadge({
58
58
  return 0;
59
59
  });
60
60
  useEffect(() => {
61
- if (!resolvedProofId || proof)
62
- return;
61
+ if (!resolvedProofId || proof) return;
63
62
  let cancelled = false;
64
63
  async function checkStatus() {
65
64
  try {
66
- const res = await fetch(`${apiUrl}/api/v1/verification/status/${resolvedProofId}`, {
65
+ const res = await fetch(`${apiUrl}/api/v1/proofs/${resolvedProofId}`, {
67
66
  headers: { Accept: "application/json" }
68
67
  });
69
68
  if (!res.ok) {
70
- if (!cancelled)
71
- setStatus("failed");
69
+ if (!cancelled) setStatus("failed");
72
70
  return;
73
71
  }
74
72
  const json = await res.json();
75
- if (cancelled)
76
- return;
73
+ if (cancelled) return;
77
74
  const proofStatus = json?.data?.status || "";
78
75
  const isVerified = proofStatus.toLowerCase().includes("verified");
79
76
  const isPending = proofStatus.toLowerCase().includes("processing") || proofStatus.toLowerCase().includes("pending");
@@ -86,8 +83,7 @@ function ProofBadge({
86
83
  setChainCount(count);
87
84
  }
88
85
  } catch (_) {
89
- if (!cancelled)
90
- setStatus("failed");
86
+ if (!cancelled) setStatus("failed");
91
87
  }
92
88
  }
93
89
  checkStatus();
@@ -174,27 +170,23 @@ function SimpleProofBadge({
174
170
  return resolvedProofId ? "pending" : "unknown";
175
171
  });
176
172
  useEffect(() => {
177
- if (!resolvedProofId || proof)
178
- return;
173
+ if (!resolvedProofId || proof) return;
179
174
  let cancelled = false;
180
175
  async function checkStatus() {
181
176
  try {
182
- const res = await fetch(`${apiUrl}/api/v1/verification/status/${resolvedProofId}`, {
177
+ const res = await fetch(`${apiUrl}/api/v1/proofs/${resolvedProofId}`, {
183
178
  headers: { Accept: "application/json" }
184
179
  });
185
180
  if (!res.ok) {
186
- if (!cancelled)
187
- setStatus("failed");
181
+ if (!cancelled) setStatus("failed");
188
182
  return;
189
183
  }
190
184
  const json = await res.json();
191
- if (cancelled)
192
- return;
185
+ if (cancelled) return;
193
186
  const isVerified = json?.success === true || json?.data?.status?.toLowerCase()?.includes("verified");
194
187
  setStatus(isVerified ? "verified" : "failed");
195
188
  } catch (_) {
196
- if (!cancelled)
197
- setStatus("failed");
189
+ if (!cancelled) setStatus("failed");
198
190
  }
199
191
  }
200
192
  checkStatus();