@neus/sdk 1.0.12 → 1.1.0
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/CHANGELOG.md +3 -0
- package/README.md +37 -39
- package/cjs/client.cjs +50 -20
- package/cjs/index.cjs +50 -20
- package/cli/neus.mjs +1205 -118
- package/client.js +59 -29
- package/package.json +10 -2
- package/types.d.ts +61 -13
- package/widgets/verify-gate/dist/ProofBadge.js +8 -16
- package/widgets/verify-gate/dist/VerifyGate.js +8 -10
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# @neus/sdk
|
|
2
2
|
|
|
3
|
-
Create, check, and reuse NEUS trust receipts from apps and backends. The same package ships the **`neus`** CLI for
|
|
3
|
+
Create, check, and reuse NEUS trust receipts from apps and backends. The same package ships the **`neus`** CLI for hosted MCP setup and portable agent import.
|
|
4
4
|
|
|
5
|
-
NEUS makes trust portable across
|
|
5
|
+
NEUS makes trust portable across apps, agents, and ecosystems before access, payment, or action.
|
|
6
|
+
|
|
7
|
+
**Status:** [Live and Operational for Production Apps](https://docs.neus.network/platform/status).
|
|
6
8
|
|
|
7
9
|
## Install (library)
|
|
8
10
|
|
|
@@ -10,44 +12,39 @@ NEUS makes trust portable across the internet so people, apps, and AI agents can
|
|
|
10
12
|
npm install @neus/sdk
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
Use one command to merge NEUS into Cursor, VS Code, and Claude Code when those tools are detected. No separate NEUS editor extension is required.
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npx -y -p @neus/sdk neus setup
|
|
19
|
-
```
|
|
15
|
+
## Bring Your Own Agent (BYOA) in 30 Seconds
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
Already have an agent setup? Use the CLI to instantly scan and import your local agent setups—including instructions, memories, rules, skills, and MCP servers from **OpenClaw, Cursor, Claude Code, and Claude Desktop**—straight into the NEUS trust network:
|
|
22
18
|
|
|
23
19
|
```bash
|
|
24
|
-
npx -y -p @neus/sdk neus
|
|
20
|
+
npx -y -p @neus/sdk neus import
|
|
25
21
|
```
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
This automatically prepares your portable NEUS agent manifest, maps your credentials, and secures a reusable trust receipt for your workflows.
|
|
28
24
|
|
|
25
|
+
*To check what will be imported without writing changes:*
|
|
29
26
|
```bash
|
|
30
|
-
npx -y -p @neus/sdk neus
|
|
27
|
+
npx -y -p @neus/sdk neus import --dry-run
|
|
31
28
|
```
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
## Connect editors and assistants
|
|
34
31
|
|
|
35
|
-
| Topic
|
|
36
|
-
|
|
|
37
|
-
| Setup, JSON snippets, and headers | [MCP setup](https://docs.neus.network/mcp/setup)
|
|
38
|
-
| Tools and session order
|
|
39
|
-
| Discovery URLs
|
|
40
|
-
|
|
|
32
|
+
| Topic | Link |
|
|
33
|
+
| --------------------------------- | ----------------------------------------------------------------------------- |
|
|
34
|
+
| Setup, JSON snippets, and headers | [MCP setup](https://docs.neus.network/mcp/setup) |
|
|
35
|
+
| Tools and session order | [MCP overview](https://docs.neus.network/mcp/overview) |
|
|
36
|
+
| Discovery URLs | [Discovery and endpoints](https://docs.neus.network/mcp/endpoints) |
|
|
37
|
+
| Claude Code skill bundle | [NEUS for Claude Code](https://docs.neus.network/mcp/claude-code-marketplace) |
|
|
41
38
|
|
|
42
39
|
Prefer `neus setup` over hand-editing config files so every host stays on **`https://mcp.neus.network/mcp`**.
|
|
43
40
|
|
|
44
|
-
## What you can
|
|
41
|
+
## What you can ship
|
|
45
42
|
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
43
|
+
- Hosted verification flows that return a reusable receipt
|
|
44
|
+
- Server checks before access, rewards, payments, or actions
|
|
45
|
+
- React gates with `VerifyGate`
|
|
46
|
+
- Agent identity and scoped delegation
|
|
47
|
+
- MCP setup for assistants and agent tools
|
|
51
48
|
|
|
52
49
|
## Fastest path: Hosted Verify
|
|
53
50
|
|
|
@@ -64,13 +61,11 @@ const url = getHostedCheckoutUrl({
|
|
|
64
61
|
window.location.assign(url);
|
|
65
62
|
```
|
|
66
63
|
|
|
67
|
-
After completion, NEUS redirects back with a
|
|
64
|
+
After completion, NEUS redirects back with a receipt ID. Store it with your user or record.
|
|
68
65
|
|
|
69
|
-
|
|
66
|
+
## Create a receipt directly
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
When your app handles signing. This example is EVM. For non-EVM wallets, pass the provider explicitly and include `chain` as a CAIP-2 value; see the CAIP-380 standards page in the docs.
|
|
68
|
+
Use this when your app handles signing. This example is EVM. For non-EVM wallets, pass the provider explicitly and include `chain` as a CAIP-2 value.
|
|
74
69
|
|
|
75
70
|
```js
|
|
76
71
|
import { NeusClient } from '@neus/sdk';
|
|
@@ -128,7 +123,7 @@ export function Page() {
|
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
125
|
}}
|
|
131
|
-
onVerified={
|
|
126
|
+
onVerified={result => {
|
|
132
127
|
console.log(result.qHash || result.qHashes);
|
|
133
128
|
}}
|
|
134
129
|
/>
|
|
@@ -165,11 +160,11 @@ Never ship access keys in browser code.
|
|
|
165
160
|
| ------------------------------- | ------------------------------------------- |
|
|
166
161
|
| `getHostedCheckoutUrl()` | Send a user to Hosted Verify |
|
|
167
162
|
| `client.verify()` | Create a proof |
|
|
168
|
-
| `client.getProof()` | Fetch a
|
|
163
|
+
| `client.getProof()` | Fetch a receipt by `qHash` |
|
|
169
164
|
| `client.pollProofStatus()` | Wait for async completion |
|
|
170
165
|
| `client.gateCheck()` | Server-side eligibility checks |
|
|
171
166
|
| `client.checkGate()` | Local preview against already-loaded proofs |
|
|
172
|
-
| `client.createWalletLinkData()` |
|
|
167
|
+
| `client.createWalletLinkData()` | Wallet-link payloads |
|
|
173
168
|
|
|
174
169
|
## Configuration
|
|
175
170
|
|
|
@@ -184,19 +179,22 @@ const client = new NeusClient({
|
|
|
184
179
|
`appId` is public attribution for your app.
|
|
185
180
|
`apiKey` / `npk_*` is optional and server-side only.
|
|
186
181
|
|
|
187
|
-
## MCP
|
|
182
|
+
## MCP step-by-step
|
|
188
183
|
|
|
189
184
|
```bash
|
|
190
|
-
npx -y -p @neus/sdk neus
|
|
185
|
+
npx -y -p @neus/sdk neus setup
|
|
186
|
+
npx -y -p @neus/sdk neus auth
|
|
187
|
+
npx -y -p @neus/sdk neus doctor --live
|
|
191
188
|
```
|
|
192
189
|
|
|
193
|
-
|
|
190
|
+
Re-sign in or rotate credentials:
|
|
194
191
|
|
|
195
192
|
```bash
|
|
196
|
-
npx -y -p @neus/sdk neus auth
|
|
193
|
+
npx -y -p @neus/sdk neus auth
|
|
194
|
+
npx -y -p @neus/sdk neus auth --access-key <npk_...> # servers and CI only
|
|
197
195
|
```
|
|
198
196
|
|
|
199
|
-
Claude Code
|
|
197
|
+
Claude Code users can add the optional **`neus-mcp@neus`** skill bundle, then run **`neus setup`** and **`neus auth`**. See [NEUS for Claude Code](https://docs.neus.network/mcp/claude-code-marketplace).
|
|
200
198
|
|
|
201
199
|
## Docs
|
|
202
200
|
|
package/cjs/client.cjs
CHANGED
|
@@ -599,6 +599,17 @@ var validateVerifierData = (verifierId, data) => {
|
|
|
599
599
|
if (data.agentType && !["ai", "bot", "service", "automation", "agent"].includes(data.agentType)) {
|
|
600
600
|
return { valid: false, error: "agentType must be one of: ai, bot, service, automation, agent" };
|
|
601
601
|
}
|
|
602
|
+
if (data.defaultRuntime && typeof data.defaultRuntime === "object") {
|
|
603
|
+
if (data.defaultRuntime.provider && typeof data.defaultRuntime.provider === "string" && data.defaultRuntime.provider.length > 64) {
|
|
604
|
+
return { valid: false, error: "defaultRuntime.provider must be 64 chars or less" };
|
|
605
|
+
}
|
|
606
|
+
if (data.defaultRuntime.model && typeof data.defaultRuntime.model === "string" && data.defaultRuntime.model.length > 128) {
|
|
607
|
+
return { valid: false, error: "defaultRuntime.model must be 128 chars or less" };
|
|
608
|
+
}
|
|
609
|
+
if (data.defaultRuntime.mode && typeof data.defaultRuntime.mode === "string" && data.defaultRuntime.mode.length > 64) {
|
|
610
|
+
return { valid: false, error: "defaultRuntime.mode must be 64 chars or less" };
|
|
611
|
+
}
|
|
612
|
+
}
|
|
602
613
|
break;
|
|
603
614
|
case "agent-delegation":
|
|
604
615
|
if (!data.controllerWallet || !validateWalletAddress(data.controllerWallet)) {
|
|
@@ -613,6 +624,18 @@ var validateVerifierData = (verifierId, data) => {
|
|
|
613
624
|
if (data.expiresAt && (typeof data.expiresAt !== "number" || data.expiresAt < Date.now())) {
|
|
614
625
|
return { valid: false, error: "expiresAt must be a future timestamp" };
|
|
615
626
|
}
|
|
627
|
+
if (data.model && typeof data.model === "string" && data.model.length > 128) {
|
|
628
|
+
return { valid: false, error: "model must be 128 chars or less" };
|
|
629
|
+
}
|
|
630
|
+
if (data.provider && typeof data.provider === "string" && data.provider.length > 64) {
|
|
631
|
+
return { valid: false, error: "provider must be 64 chars or less" };
|
|
632
|
+
}
|
|
633
|
+
if (data.allowedActions && Array.isArray(data.allowedActions) && data.allowedActions.length > 32) {
|
|
634
|
+
return { valid: false, error: "allowedActions must have 32 items or less" };
|
|
635
|
+
}
|
|
636
|
+
if (data.deniedActions && Array.isArray(data.deniedActions) && data.deniedActions.length > 32) {
|
|
637
|
+
return { valid: false, error: "deniedActions must have 32 items or less" };
|
|
638
|
+
}
|
|
616
639
|
break;
|
|
617
640
|
case "ai-content-moderation":
|
|
618
641
|
if (!data.content || typeof data.content !== "string") {
|
|
@@ -1146,9 +1169,13 @@ var NeusClient = class {
|
|
|
1146
1169
|
verificationData = {
|
|
1147
1170
|
agentId: data2.agentId,
|
|
1148
1171
|
agentWallet: data2?.agentWallet || walletAddress2,
|
|
1172
|
+
...data2?.agentChainRef && { agentChainRef: data2.agentChainRef },
|
|
1173
|
+
...data2?.agentAccountId && { agentAccountId: data2.agentAccountId },
|
|
1149
1174
|
...data2?.agentLabel && { agentLabel: data2.agentLabel },
|
|
1150
1175
|
...data2?.agentType && { agentType: data2.agentType },
|
|
1176
|
+
...data2?.avatar && { avatar: data2.avatar },
|
|
1151
1177
|
...data2?.description && { description: data2.description },
|
|
1178
|
+
...data2?.defaultRuntime && { defaultRuntime: data2.defaultRuntime },
|
|
1152
1179
|
...data2?.capabilities && { capabilities: data2.capabilities },
|
|
1153
1180
|
...data2?.instructions && { instructions: data2.instructions },
|
|
1154
1181
|
...data2?.skills && { skills: data2.skills },
|
|
@@ -1160,7 +1187,11 @@ var NeusClient = class {
|
|
|
1160
1187
|
}
|
|
1161
1188
|
verificationData = {
|
|
1162
1189
|
controllerWallet: data2?.controllerWallet || walletAddress2,
|
|
1190
|
+
...data2?.controllerChainRef && { controllerChainRef: data2.controllerChainRef },
|
|
1163
1191
|
agentWallet: data2.agentWallet,
|
|
1192
|
+
...data2?.agentChainRef && { agentChainRef: data2.agentChainRef },
|
|
1193
|
+
...data2?.controllerAccountId && { controllerAccountId: data2.controllerAccountId },
|
|
1194
|
+
...data2?.agentAccountId && { agentAccountId: data2.agentAccountId },
|
|
1164
1195
|
...data2?.agentId && { agentId: data2.agentId },
|
|
1165
1196
|
...data2?.scope && { scope: data2.scope },
|
|
1166
1197
|
...data2?.permissions && { permissions: data2.permissions },
|
|
@@ -1169,7 +1200,13 @@ var NeusClient = class {
|
|
|
1169
1200
|
...data2?.receiptDisclosure && { receiptDisclosure: data2.receiptDisclosure },
|
|
1170
1201
|
...data2?.expiresAt && { expiresAt: data2.expiresAt },
|
|
1171
1202
|
...data2?.instructions && { instructions: data2.instructions },
|
|
1172
|
-
...data2?.skills && { skills: data2.skills }
|
|
1203
|
+
...data2?.skills && { skills: data2.skills },
|
|
1204
|
+
...data2?.model && { model: data2.model },
|
|
1205
|
+
...data2?.provider && { provider: data2.provider },
|
|
1206
|
+
...data2?.runtimePolicy && { runtimePolicy: data2.runtimePolicy },
|
|
1207
|
+
...data2?.allowedActions && { allowedActions: data2.allowedActions },
|
|
1208
|
+
...data2?.deniedActions && { deniedActions: data2.deniedActions },
|
|
1209
|
+
...data2?.approvalPolicy && { approvalPolicy: data2.approvalPolicy }
|
|
1173
1210
|
};
|
|
1174
1211
|
} else if (verifier === "ai-content-moderation") {
|
|
1175
1212
|
if (!data2?.content) {
|
|
@@ -1388,19 +1425,17 @@ ${bytes.length}`;
|
|
|
1388
1425
|
return this._formatResponse(response);
|
|
1389
1426
|
}
|
|
1390
1427
|
async getProof(qHash) {
|
|
1391
|
-
|
|
1392
|
-
if (!resolvedQHash || typeof resolvedQHash !== "string") {
|
|
1428
|
+
if (!qHash || typeof qHash !== "string") {
|
|
1393
1429
|
throw new ValidationError("qHash is required");
|
|
1394
1430
|
}
|
|
1395
|
-
const response = await this._makeRequest("GET", `/api/v1/proofs/${
|
|
1431
|
+
const response = await this._makeRequest("GET", `/api/v1/proofs/${qHash}`);
|
|
1396
1432
|
if (!response.success) {
|
|
1397
1433
|
throw new ApiError(`Failed to get proof: ${response.error?.message || "Unknown error"}`, response.error);
|
|
1398
1434
|
}
|
|
1399
1435
|
return this._formatResponse(response);
|
|
1400
1436
|
}
|
|
1401
1437
|
async getPrivateProof(qHash, wallet = null) {
|
|
1402
|
-
|
|
1403
|
-
if (!resolvedQHash || typeof resolvedQHash !== "string") {
|
|
1438
|
+
if (!qHash || typeof qHash !== "string") {
|
|
1404
1439
|
throw new ValidationError("qHash is required");
|
|
1405
1440
|
}
|
|
1406
1441
|
const isPreSignedAuth = wallet && typeof wallet === "object" && typeof wallet.walletAddress === "string" && typeof wallet.signature === "string" && typeof wallet.signedTimestamp === "number";
|
|
@@ -1413,7 +1448,7 @@ ${bytes.length}`;
|
|
|
1413
1448
|
...typeof auth.chain === "string" && auth.chain.trim() ? { "x-chain": auth.chain.trim() } : {},
|
|
1414
1449
|
...typeof auth.signatureMethod === "string" && auth.signatureMethod.trim() ? { "x-signature-method": auth.signatureMethod.trim() } : {}
|
|
1415
1450
|
};
|
|
1416
|
-
const response2 = await this._makeRequest("GET", `/api/v1/proofs/${
|
|
1451
|
+
const response2 = await this._makeRequest("GET", `/api/v1/proofs/${qHash}`, null, headers);
|
|
1417
1452
|
if (!response2.success) {
|
|
1418
1453
|
throw new ApiError(
|
|
1419
1454
|
`Failed to access private proof: ${response2.error?.message || "Unauthorized"}`,
|
|
@@ -1434,7 +1469,7 @@ ${bytes.length}`;
|
|
|
1434
1469
|
const message = constructVerificationMessage({
|
|
1435
1470
|
walletAddress,
|
|
1436
1471
|
signedTimestamp,
|
|
1437
|
-
data: { action: "access_private_proof", qHash
|
|
1472
|
+
data: { action: "access_private_proof", qHash },
|
|
1438
1473
|
verifierIds: ["ownership-basic"],
|
|
1439
1474
|
...signerIsEvm ? { chainId: this._getHubChainId() } : { chain }
|
|
1440
1475
|
});
|
|
@@ -1452,7 +1487,7 @@ ${bytes.length}`;
|
|
|
1452
1487
|
}
|
|
1453
1488
|
throw new ValidationError(`Failed to sign message: ${error.message}`);
|
|
1454
1489
|
}
|
|
1455
|
-
const response = await this._makeRequest("GET", `/api/v1/proofs/${
|
|
1490
|
+
const response = await this._makeRequest("GET", `/api/v1/proofs/${qHash}`, null, {
|
|
1456
1491
|
"x-wallet-address": walletAddress,
|
|
1457
1492
|
"x-signature": signature,
|
|
1458
1493
|
"x-signed-timestamp": signedTimestamp.toString(),
|
|
@@ -1490,20 +1525,19 @@ ${bytes.length}`;
|
|
|
1490
1525
|
};
|
|
1491
1526
|
}
|
|
1492
1527
|
async pollProofStatus(qHash, options = {}) {
|
|
1493
|
-
const resolvedQHash = qHash;
|
|
1494
1528
|
const {
|
|
1495
1529
|
interval = 5e3,
|
|
1496
1530
|
timeout = 12e4,
|
|
1497
1531
|
onProgress
|
|
1498
1532
|
} = options;
|
|
1499
|
-
if (!
|
|
1533
|
+
if (!qHash || typeof qHash !== "string") {
|
|
1500
1534
|
throw new ValidationError("qHash is required");
|
|
1501
1535
|
}
|
|
1502
1536
|
const startTime = Date.now();
|
|
1503
1537
|
let consecutiveRateLimits = 0;
|
|
1504
1538
|
while (Date.now() - startTime < timeout) {
|
|
1505
1539
|
try {
|
|
1506
|
-
const status = await this.getProof(
|
|
1540
|
+
const status = await this.getProof(qHash);
|
|
1507
1541
|
consecutiveRateLimits = 0;
|
|
1508
1542
|
if (onProgress && typeof onProgress === "function") {
|
|
1509
1543
|
onProgress(status.data || status);
|
|
@@ -1546,8 +1580,7 @@ ${bytes.length}`;
|
|
|
1546
1580
|
}
|
|
1547
1581
|
}
|
|
1548
1582
|
async revokeOwnProof(qHash, wallet) {
|
|
1549
|
-
|
|
1550
|
-
if (!resolvedQHash || typeof resolvedQHash !== "string") {
|
|
1583
|
+
if (!qHash || typeof qHash !== "string") {
|
|
1551
1584
|
throw new ValidationError("qHash is required");
|
|
1552
1585
|
}
|
|
1553
1586
|
const providerWallet = wallet || this._getDefaultBrowserWallet();
|
|
@@ -1562,7 +1595,7 @@ ${bytes.length}`;
|
|
|
1562
1595
|
const message = constructVerificationMessage({
|
|
1563
1596
|
walletAddress: address,
|
|
1564
1597
|
signedTimestamp,
|
|
1565
|
-
data: { action: "revoke_proof", qHash
|
|
1598
|
+
data: { action: "revoke_proof", qHash },
|
|
1566
1599
|
verifierIds: ["ownership-basic"],
|
|
1567
1600
|
...signerIsEvm ? { chainId: this._getHubChainId() } : { chain }
|
|
1568
1601
|
});
|
|
@@ -1580,7 +1613,7 @@ ${bytes.length}`;
|
|
|
1580
1613
|
}
|
|
1581
1614
|
throw new ValidationError(`Failed to sign revocation: ${error.message}`);
|
|
1582
1615
|
}
|
|
1583
|
-
const res = await this._makeRequest("POST", `/api/v1/proofs/revoke-self/${
|
|
1616
|
+
const res = await this._makeRequest("POST", `/api/v1/proofs/revoke-self/${qHash}`, {
|
|
1584
1617
|
walletAddress: address,
|
|
1585
1618
|
signature,
|
|
1586
1619
|
signedTimestamp,
|
|
@@ -1987,10 +2020,7 @@ ${bytes.length}`;
|
|
|
1987
2020
|
}
|
|
1988
2021
|
}
|
|
1989
2022
|
_formatResponse(response) {
|
|
1990
|
-
const qHash = response?.data?.qHash || response?.qHash || response?.data?.resource?.qHash || response?.data?.
|
|
1991
|
-
response?.proofId || // Legacy input compatibility only. Do not expose or store proofId.
|
|
1992
|
-
response?.data?.resource?.proofId || // Legacy input compatibility only. Do not expose or store proofId.
|
|
1993
|
-
response?.data?.id;
|
|
2023
|
+
const qHash = response?.data?.qHash || response?.qHash || response?.data?.resource?.qHash || response?.data?.id;
|
|
1994
2024
|
const status = response?.data?.status || response?.status || response?.data?.resource?.status || (response?.success ? "completed" : "unknown");
|
|
1995
2025
|
return {
|
|
1996
2026
|
success: response.success,
|
package/cjs/index.cjs
CHANGED
|
@@ -1283,6 +1283,17 @@ var init_client = __esm({
|
|
|
1283
1283
|
if (data.agentType && !["ai", "bot", "service", "automation", "agent"].includes(data.agentType)) {
|
|
1284
1284
|
return { valid: false, error: "agentType must be one of: ai, bot, service, automation, agent" };
|
|
1285
1285
|
}
|
|
1286
|
+
if (data.defaultRuntime && typeof data.defaultRuntime === "object") {
|
|
1287
|
+
if (data.defaultRuntime.provider && typeof data.defaultRuntime.provider === "string" && data.defaultRuntime.provider.length > 64) {
|
|
1288
|
+
return { valid: false, error: "defaultRuntime.provider must be 64 chars or less" };
|
|
1289
|
+
}
|
|
1290
|
+
if (data.defaultRuntime.model && typeof data.defaultRuntime.model === "string" && data.defaultRuntime.model.length > 128) {
|
|
1291
|
+
return { valid: false, error: "defaultRuntime.model must be 128 chars or less" };
|
|
1292
|
+
}
|
|
1293
|
+
if (data.defaultRuntime.mode && typeof data.defaultRuntime.mode === "string" && data.defaultRuntime.mode.length > 64) {
|
|
1294
|
+
return { valid: false, error: "defaultRuntime.mode must be 64 chars or less" };
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1286
1297
|
break;
|
|
1287
1298
|
case "agent-delegation":
|
|
1288
1299
|
if (!data.controllerWallet || !validateWalletAddress(data.controllerWallet)) {
|
|
@@ -1297,6 +1308,18 @@ var init_client = __esm({
|
|
|
1297
1308
|
if (data.expiresAt && (typeof data.expiresAt !== "number" || data.expiresAt < Date.now())) {
|
|
1298
1309
|
return { valid: false, error: "expiresAt must be a future timestamp" };
|
|
1299
1310
|
}
|
|
1311
|
+
if (data.model && typeof data.model === "string" && data.model.length > 128) {
|
|
1312
|
+
return { valid: false, error: "model must be 128 chars or less" };
|
|
1313
|
+
}
|
|
1314
|
+
if (data.provider && typeof data.provider === "string" && data.provider.length > 64) {
|
|
1315
|
+
return { valid: false, error: "provider must be 64 chars or less" };
|
|
1316
|
+
}
|
|
1317
|
+
if (data.allowedActions && Array.isArray(data.allowedActions) && data.allowedActions.length > 32) {
|
|
1318
|
+
return { valid: false, error: "allowedActions must have 32 items or less" };
|
|
1319
|
+
}
|
|
1320
|
+
if (data.deniedActions && Array.isArray(data.deniedActions) && data.deniedActions.length > 32) {
|
|
1321
|
+
return { valid: false, error: "deniedActions must have 32 items or less" };
|
|
1322
|
+
}
|
|
1300
1323
|
break;
|
|
1301
1324
|
case "ai-content-moderation":
|
|
1302
1325
|
if (!data.content || typeof data.content !== "string") {
|
|
@@ -1830,9 +1853,13 @@ var init_client = __esm({
|
|
|
1830
1853
|
verificationData = {
|
|
1831
1854
|
agentId: data2.agentId,
|
|
1832
1855
|
agentWallet: data2?.agentWallet || walletAddress2,
|
|
1856
|
+
...data2?.agentChainRef && { agentChainRef: data2.agentChainRef },
|
|
1857
|
+
...data2?.agentAccountId && { agentAccountId: data2.agentAccountId },
|
|
1833
1858
|
...data2?.agentLabel && { agentLabel: data2.agentLabel },
|
|
1834
1859
|
...data2?.agentType && { agentType: data2.agentType },
|
|
1860
|
+
...data2?.avatar && { avatar: data2.avatar },
|
|
1835
1861
|
...data2?.description && { description: data2.description },
|
|
1862
|
+
...data2?.defaultRuntime && { defaultRuntime: data2.defaultRuntime },
|
|
1836
1863
|
...data2?.capabilities && { capabilities: data2.capabilities },
|
|
1837
1864
|
...data2?.instructions && { instructions: data2.instructions },
|
|
1838
1865
|
...data2?.skills && { skills: data2.skills },
|
|
@@ -1844,7 +1871,11 @@ var init_client = __esm({
|
|
|
1844
1871
|
}
|
|
1845
1872
|
verificationData = {
|
|
1846
1873
|
controllerWallet: data2?.controllerWallet || walletAddress2,
|
|
1874
|
+
...data2?.controllerChainRef && { controllerChainRef: data2.controllerChainRef },
|
|
1847
1875
|
agentWallet: data2.agentWallet,
|
|
1876
|
+
...data2?.agentChainRef && { agentChainRef: data2.agentChainRef },
|
|
1877
|
+
...data2?.controllerAccountId && { controllerAccountId: data2.controllerAccountId },
|
|
1878
|
+
...data2?.agentAccountId && { agentAccountId: data2.agentAccountId },
|
|
1848
1879
|
...data2?.agentId && { agentId: data2.agentId },
|
|
1849
1880
|
...data2?.scope && { scope: data2.scope },
|
|
1850
1881
|
...data2?.permissions && { permissions: data2.permissions },
|
|
@@ -1853,7 +1884,13 @@ var init_client = __esm({
|
|
|
1853
1884
|
...data2?.receiptDisclosure && { receiptDisclosure: data2.receiptDisclosure },
|
|
1854
1885
|
...data2?.expiresAt && { expiresAt: data2.expiresAt },
|
|
1855
1886
|
...data2?.instructions && { instructions: data2.instructions },
|
|
1856
|
-
...data2?.skills && { skills: data2.skills }
|
|
1887
|
+
...data2?.skills && { skills: data2.skills },
|
|
1888
|
+
...data2?.model && { model: data2.model },
|
|
1889
|
+
...data2?.provider && { provider: data2.provider },
|
|
1890
|
+
...data2?.runtimePolicy && { runtimePolicy: data2.runtimePolicy },
|
|
1891
|
+
...data2?.allowedActions && { allowedActions: data2.allowedActions },
|
|
1892
|
+
...data2?.deniedActions && { deniedActions: data2.deniedActions },
|
|
1893
|
+
...data2?.approvalPolicy && { approvalPolicy: data2.approvalPolicy }
|
|
1857
1894
|
};
|
|
1858
1895
|
} else if (verifier === "ai-content-moderation") {
|
|
1859
1896
|
if (!data2?.content) {
|
|
@@ -2072,19 +2109,17 @@ ${bytes.length}`;
|
|
|
2072
2109
|
return this._formatResponse(response);
|
|
2073
2110
|
}
|
|
2074
2111
|
async getProof(qHash) {
|
|
2075
|
-
|
|
2076
|
-
if (!resolvedQHash || typeof resolvedQHash !== "string") {
|
|
2112
|
+
if (!qHash || typeof qHash !== "string") {
|
|
2077
2113
|
throw new ValidationError("qHash is required");
|
|
2078
2114
|
}
|
|
2079
|
-
const response = await this._makeRequest("GET", `/api/v1/proofs/${
|
|
2115
|
+
const response = await this._makeRequest("GET", `/api/v1/proofs/${qHash}`);
|
|
2080
2116
|
if (!response.success) {
|
|
2081
2117
|
throw new ApiError(`Failed to get proof: ${response.error?.message || "Unknown error"}`, response.error);
|
|
2082
2118
|
}
|
|
2083
2119
|
return this._formatResponse(response);
|
|
2084
2120
|
}
|
|
2085
2121
|
async getPrivateProof(qHash, wallet = null) {
|
|
2086
|
-
|
|
2087
|
-
if (!resolvedQHash || typeof resolvedQHash !== "string") {
|
|
2122
|
+
if (!qHash || typeof qHash !== "string") {
|
|
2088
2123
|
throw new ValidationError("qHash is required");
|
|
2089
2124
|
}
|
|
2090
2125
|
const isPreSignedAuth = wallet && typeof wallet === "object" && typeof wallet.walletAddress === "string" && typeof wallet.signature === "string" && typeof wallet.signedTimestamp === "number";
|
|
@@ -2097,7 +2132,7 @@ ${bytes.length}`;
|
|
|
2097
2132
|
...typeof auth.chain === "string" && auth.chain.trim() ? { "x-chain": auth.chain.trim() } : {},
|
|
2098
2133
|
...typeof auth.signatureMethod === "string" && auth.signatureMethod.trim() ? { "x-signature-method": auth.signatureMethod.trim() } : {}
|
|
2099
2134
|
};
|
|
2100
|
-
const response2 = await this._makeRequest("GET", `/api/v1/proofs/${
|
|
2135
|
+
const response2 = await this._makeRequest("GET", `/api/v1/proofs/${qHash}`, null, headers);
|
|
2101
2136
|
if (!response2.success) {
|
|
2102
2137
|
throw new ApiError(
|
|
2103
2138
|
`Failed to access private proof: ${response2.error?.message || "Unauthorized"}`,
|
|
@@ -2118,7 +2153,7 @@ ${bytes.length}`;
|
|
|
2118
2153
|
const message = constructVerificationMessage({
|
|
2119
2154
|
walletAddress,
|
|
2120
2155
|
signedTimestamp,
|
|
2121
|
-
data: { action: "access_private_proof", qHash
|
|
2156
|
+
data: { action: "access_private_proof", qHash },
|
|
2122
2157
|
verifierIds: ["ownership-basic"],
|
|
2123
2158
|
...signerIsEvm ? { chainId: this._getHubChainId() } : { chain }
|
|
2124
2159
|
});
|
|
@@ -2136,7 +2171,7 @@ ${bytes.length}`;
|
|
|
2136
2171
|
}
|
|
2137
2172
|
throw new ValidationError(`Failed to sign message: ${error.message}`);
|
|
2138
2173
|
}
|
|
2139
|
-
const response = await this._makeRequest("GET", `/api/v1/proofs/${
|
|
2174
|
+
const response = await this._makeRequest("GET", `/api/v1/proofs/${qHash}`, null, {
|
|
2140
2175
|
"x-wallet-address": walletAddress,
|
|
2141
2176
|
"x-signature": signature,
|
|
2142
2177
|
"x-signed-timestamp": signedTimestamp.toString(),
|
|
@@ -2174,20 +2209,19 @@ ${bytes.length}`;
|
|
|
2174
2209
|
};
|
|
2175
2210
|
}
|
|
2176
2211
|
async pollProofStatus(qHash, options = {}) {
|
|
2177
|
-
const resolvedQHash = qHash;
|
|
2178
2212
|
const {
|
|
2179
2213
|
interval = 5e3,
|
|
2180
2214
|
timeout = 12e4,
|
|
2181
2215
|
onProgress
|
|
2182
2216
|
} = options;
|
|
2183
|
-
if (!
|
|
2217
|
+
if (!qHash || typeof qHash !== "string") {
|
|
2184
2218
|
throw new ValidationError("qHash is required");
|
|
2185
2219
|
}
|
|
2186
2220
|
const startTime = Date.now();
|
|
2187
2221
|
let consecutiveRateLimits = 0;
|
|
2188
2222
|
while (Date.now() - startTime < timeout) {
|
|
2189
2223
|
try {
|
|
2190
|
-
const status = await this.getProof(
|
|
2224
|
+
const status = await this.getProof(qHash);
|
|
2191
2225
|
consecutiveRateLimits = 0;
|
|
2192
2226
|
if (onProgress && typeof onProgress === "function") {
|
|
2193
2227
|
onProgress(status.data || status);
|
|
@@ -2230,8 +2264,7 @@ ${bytes.length}`;
|
|
|
2230
2264
|
}
|
|
2231
2265
|
}
|
|
2232
2266
|
async revokeOwnProof(qHash, wallet) {
|
|
2233
|
-
|
|
2234
|
-
if (!resolvedQHash || typeof resolvedQHash !== "string") {
|
|
2267
|
+
if (!qHash || typeof qHash !== "string") {
|
|
2235
2268
|
throw new ValidationError("qHash is required");
|
|
2236
2269
|
}
|
|
2237
2270
|
const providerWallet = wallet || this._getDefaultBrowserWallet();
|
|
@@ -2246,7 +2279,7 @@ ${bytes.length}`;
|
|
|
2246
2279
|
const message = constructVerificationMessage({
|
|
2247
2280
|
walletAddress: address,
|
|
2248
2281
|
signedTimestamp,
|
|
2249
|
-
data: { action: "revoke_proof", qHash
|
|
2282
|
+
data: { action: "revoke_proof", qHash },
|
|
2250
2283
|
verifierIds: ["ownership-basic"],
|
|
2251
2284
|
...signerIsEvm ? { chainId: this._getHubChainId() } : { chain }
|
|
2252
2285
|
});
|
|
@@ -2264,7 +2297,7 @@ ${bytes.length}`;
|
|
|
2264
2297
|
}
|
|
2265
2298
|
throw new ValidationError(`Failed to sign revocation: ${error.message}`);
|
|
2266
2299
|
}
|
|
2267
|
-
const res = await this._makeRequest("POST", `/api/v1/proofs/revoke-self/${
|
|
2300
|
+
const res = await this._makeRequest("POST", `/api/v1/proofs/revoke-self/${qHash}`, {
|
|
2268
2301
|
walletAddress: address,
|
|
2269
2302
|
signature,
|
|
2270
2303
|
signedTimestamp,
|
|
@@ -2671,10 +2704,7 @@ ${bytes.length}`;
|
|
|
2671
2704
|
}
|
|
2672
2705
|
}
|
|
2673
2706
|
_formatResponse(response) {
|
|
2674
|
-
const qHash = response?.data?.qHash || response?.qHash || response?.data?.resource?.qHash || response?.data?.
|
|
2675
|
-
response?.proofId || // Legacy input compatibility only. Do not expose or store proofId.
|
|
2676
|
-
response?.data?.resource?.proofId || // Legacy input compatibility only. Do not expose or store proofId.
|
|
2677
|
-
response?.data?.id;
|
|
2707
|
+
const qHash = response?.data?.qHash || response?.qHash || response?.data?.resource?.qHash || response?.data?.id;
|
|
2678
2708
|
const status = response?.data?.status || response?.status || response?.data?.resource?.status || (response?.success ? "completed" : "unknown");
|
|
2679
2709
|
return {
|
|
2680
2710
|
success: response.success,
|