@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 +90 -150
- package/SECURITY.md +33 -29
- package/cjs/client.cjs +235 -264
- package/cjs/index.cjs +330 -310
- package/cjs/utils.cjs +138 -97
- package/cli/neus.mjs +58 -0
- package/client.js +464 -457
- package/errors.js +5 -5
- package/gates.js +18 -18
- package/index.js +79 -75
- package/package.json +16 -10
- package/types.d.ts +124 -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 +108 -97
- package/widgets/verify-gate/index.js +5 -5
package/widgets/README.md
CHANGED
|
@@ -1,64 +1,45 @@
|
|
|
1
|
-
# NEUS Widgets
|
|
2
|
-
|
|
3
|
-
React components
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @neus/sdk react react-dom
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## VerifyGate
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```jsx
|
|
16
|
-
import { VerifyGate } from '@neus/sdk/widgets';
|
|
17
|
-
|
|
18
|
-
export function Page() {
|
|
19
|
-
return (
|
|
20
|
-
<VerifyGate
|
|
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
|
-
- 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
|
@@ -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/
|
|
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/
|
|
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();
|