@neus/sdk 1.1.0 → 1.1.2
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 +31 -53
- package/cjs/client.cjs +162 -15
- package/cjs/errors.cjs +2 -35
- package/cjs/gates.cjs +1 -21
- package/cjs/index.cjs +174 -15
- package/cjs/mcp-hosts.cjs +125 -0
- package/cjs/utils.cjs +2 -0
- package/cli/neus.mjs +628 -349
- package/client.js +119 -15
- package/errors.js +154 -189
- package/gates.js +0 -20
- package/index.js +2 -0
- package/mcp-hosts.js +121 -0
- package/package.json +9 -5
- package/sponsor.js +95 -0
- package/types.d.ts +66 -6
- package/utils.js +2 -0
- package/widgets/README.md +7 -11
- package/widgets/verify-gate/dist/ProofBadge.js +14 -4
- package/widgets/verify-gate/dist/VerifyGate.js +73 -195
- package/CHANGELOG.md +0 -3
- package/neus-logo.svg +0 -3
package/README.md
CHANGED
|
@@ -1,10 +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 hosted MCP setup
|
|
3
|
+
Create, check, and reuse NEUS trust receipts from apps and backends. The same package ships the **`neus`** CLI for hosted MCP setup.
|
|
4
4
|
|
|
5
5
|
NEUS makes trust portable across apps, agents, and ecosystems before access, payment, or action.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Roadmap: [docs.neus.network/platform/status](https://docs.neus.network/platform/status)
|
|
8
8
|
|
|
9
9
|
## Install (library)
|
|
10
10
|
|
|
@@ -12,29 +12,25 @@ NEUS makes trust portable across apps, agents, and ecosystems before access, pay
|
|
|
12
12
|
npm install @neus/sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Connect editors and assistants
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
One command detects your environment and configures hosted MCP for Claude Code, Codex, Cursor, or VS Code.
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npx -y -p @neus/sdk neus
|
|
20
|
+
npx -y -p @neus/sdk neus setup
|
|
21
|
+
npx -y -p @neus/sdk neus doctor --live
|
|
21
22
|
```
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
Call `neus_context` in your MCP client. For agent workflows, call `neus_agent_link` before assuming identity or delegation is ready.
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npx -y -p @neus/sdk neus import --dry-run
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Connect editors and assistants
|
|
26
|
+
## MCP docs
|
|
31
27
|
|
|
32
28
|
| Topic | Link |
|
|
33
29
|
| --------------------------------- | ----------------------------------------------------------------------------- |
|
|
34
30
|
| Setup, JSON snippets, and headers | [MCP setup](https://docs.neus.network/mcp/setup) |
|
|
35
31
|
| Tools and session order | [MCP overview](https://docs.neus.network/mcp/overview) |
|
|
36
32
|
| Discovery URLs | [Discovery and endpoints](https://docs.neus.network/mcp/endpoints) |
|
|
37
|
-
|
|
|
33
|
+
| NEUS for AI assistants | [NEUS for AI assistants](https://docs.neus.network/mcp/ide-plugin) |
|
|
38
34
|
|
|
39
35
|
Prefer `neus setup` over hand-editing config files so every host stays on **`https://mcp.neus.network/mcp`**.
|
|
40
36
|
|
|
@@ -46,32 +42,32 @@ Prefer `neus setup` over hand-editing config files so every host stays on **`htt
|
|
|
46
42
|
- Agent identity and scoped delegation
|
|
47
43
|
- MCP setup for assistants and agent tools
|
|
48
44
|
|
|
49
|
-
##
|
|
45
|
+
## Hosted Verify
|
|
50
46
|
|
|
51
|
-
Use Hosted Verify when you want NEUS to handle the signing/verification flow outside your app UI.
|
|
47
|
+
Use Hosted Verify when you want NEUS to handle the signing/verification flow outside your app UI. Prefer a **published gate**:
|
|
52
48
|
|
|
53
49
|
```js
|
|
54
50
|
import { getHostedCheckoutUrl } from '@neus/sdk';
|
|
55
51
|
|
|
56
52
|
const url = getHostedCheckoutUrl({
|
|
57
|
-
|
|
53
|
+
gateId: 'gate_abc123',
|
|
58
54
|
returnUrl: 'https://yourapp.com/auth/callback'
|
|
59
55
|
});
|
|
60
56
|
|
|
61
57
|
window.location.assign(url);
|
|
62
58
|
```
|
|
63
59
|
|
|
64
|
-
After completion, NEUS redirects back with a
|
|
60
|
+
After completion, NEUS redirects back with a `qHash`. Store it with your user or record.
|
|
65
61
|
|
|
66
|
-
##
|
|
62
|
+
## Advanced: in-app signing
|
|
67
63
|
|
|
68
|
-
Use this when your app handles signing. This example is EVM. For non-EVM
|
|
64
|
+
Use this only when your app intentionally handles signing. This example is EVM. For non-EVM accounts, pass the provider explicitly and include `chain` as a CAIP-2 value.
|
|
69
65
|
|
|
70
66
|
```js
|
|
71
67
|
import { NeusClient } from '@neus/sdk';
|
|
72
68
|
|
|
73
69
|
const client = new NeusClient({
|
|
74
|
-
|
|
70
|
+
apiUrl: 'https://api.neus.network'
|
|
75
71
|
});
|
|
76
72
|
|
|
77
73
|
const proof = await client.verify({
|
|
@@ -99,7 +95,7 @@ console.log(proof.proofUrl);
|
|
|
99
95
|
|
|
100
96
|
## React widget
|
|
101
97
|
|
|
102
|
-
Use `VerifyGate`
|
|
98
|
+
Use `VerifyGate` with your published `gateId`:
|
|
103
99
|
|
|
104
100
|
```jsx
|
|
105
101
|
import { VerifyGate } from '@neus/sdk/widgets';
|
|
@@ -107,44 +103,29 @@ import { VerifyGate } from '@neus/sdk/widgets';
|
|
|
107
103
|
export function Page() {
|
|
108
104
|
return (
|
|
109
105
|
<VerifyGate
|
|
110
|
-
|
|
111
|
-
requiredVerifiers={['ownership-basic']}
|
|
112
|
-
verifierData={{
|
|
113
|
-
'ownership-basic': {
|
|
114
|
-
owner: '0x...',
|
|
115
|
-
contentType: 'application/json',
|
|
116
|
-
content: JSON.stringify({
|
|
117
|
-
title: 'Verified claim',
|
|
118
|
-
summary: 'Public summary of what is being proven.'
|
|
119
|
-
}),
|
|
120
|
-
reference: {
|
|
121
|
-
type: 'url',
|
|
122
|
-
id: 'https://example.com/source'
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}}
|
|
106
|
+
gateId="gate_abc123"
|
|
126
107
|
onVerified={result => {
|
|
127
108
|
console.log(result.qHash || result.qHashes);
|
|
128
109
|
}}
|
|
129
|
-
|
|
110
|
+
>
|
|
111
|
+
<section>Unlocked content</section>
|
|
112
|
+
</VerifyGate>
|
|
130
113
|
);
|
|
131
114
|
}
|
|
132
115
|
```
|
|
133
116
|
|
|
134
117
|
## Check receipts
|
|
135
118
|
|
|
136
|
-
Use `gateCheck` from trusted server code when you need allow/deny
|
|
119
|
+
Use `gateCheck` from trusted server code when you need allow/deny before access:
|
|
137
120
|
|
|
138
121
|
```js
|
|
139
122
|
import { NeusClient } from '@neus/sdk';
|
|
140
123
|
|
|
141
|
-
const client = new NeusClient(
|
|
142
|
-
appId: 'your-app-id'
|
|
143
|
-
});
|
|
124
|
+
const client = new NeusClient();
|
|
144
125
|
|
|
145
126
|
const result = await client.gateCheck({
|
|
146
|
-
|
|
147
|
-
|
|
127
|
+
gateId: 'gate_abc123',
|
|
128
|
+
address: '0x...'
|
|
148
129
|
});
|
|
149
130
|
|
|
150
131
|
if (!result.data?.eligible) {
|
|
@@ -171,30 +152,27 @@ Never ship access keys in browser code.
|
|
|
171
152
|
```js
|
|
172
153
|
const client = new NeusClient({
|
|
173
154
|
apiUrl: 'https://api.neus.network',
|
|
174
|
-
appId: 'your-app-id',
|
|
175
155
|
timeout: 30000
|
|
176
156
|
});
|
|
177
157
|
```
|
|
178
158
|
|
|
179
|
-
`appId` is public attribution for
|
|
159
|
+
`appId` is optional public attribution for advanced server/app flows. Published gate checkout and `gateCheck({ gateId })` do not require it.
|
|
180
160
|
`apiKey` / `npk_*` is optional and server-side only.
|
|
181
161
|
|
|
182
162
|
## MCP step-by-step
|
|
183
163
|
|
|
184
164
|
```bash
|
|
185
165
|
npx -y -p @neus/sdk neus setup
|
|
186
|
-
npx -y -p @neus/sdk neus auth
|
|
187
166
|
npx -y -p @neus/sdk neus doctor --live
|
|
188
167
|
```
|
|
189
168
|
|
|
190
|
-
|
|
169
|
+
`neus setup` configures MCP and signs you in: `NEUS_ACCESS_KEY` from the environment when set, otherwise the selected host starts OAuth. Cursor, VS Code, and Claude Code use browser sign-in on NEUS. Pass `--access-key <npk_...>` only to override.
|
|
191
170
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
```
|
|
171
|
+
Codex owns its local MCP OAuth session. Use `npx -y -p @neus/sdk neus setup --client codex`, then `npx -y -p @neus/sdk neus auth --client codex`.
|
|
172
|
+
|
|
173
|
+
Integrators embedding install UX in apps should import **`@neus/sdk/mcp-hosts`** (setup commands, deeplinks, host labels) instead of duplicating strings.
|
|
196
174
|
|
|
197
|
-
|
|
175
|
+
Editors with plugin marketplaces can install **`neus-trust@neus`** for the bundled session workflow. In Claude Code, run `/plugin marketplace add https://github.com/neus/network` and `/plugin install neus-trust@neus` inside chat. Other hosts: [NEUS for AI assistants](https://docs.neus.network/mcp/ide-plugin).
|
|
198
176
|
|
|
199
177
|
## Docs
|
|
200
178
|
|
package/cjs/client.cjs
CHANGED
|
@@ -129,6 +129,83 @@ var ConfigurationError = class extends SDKError {
|
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
+
// sponsor.js
|
|
133
|
+
async function fetchSponsorGrant(params = {}) {
|
|
134
|
+
const {
|
|
135
|
+
apiUrl = "https://api.neus.network",
|
|
136
|
+
appId,
|
|
137
|
+
orgWallet,
|
|
138
|
+
verifierIds = [],
|
|
139
|
+
targetChains = [],
|
|
140
|
+
origin,
|
|
141
|
+
expiresInSeconds = 900,
|
|
142
|
+
fetchImpl = fetch
|
|
143
|
+
} = params;
|
|
144
|
+
const normalizedAppId = typeof appId === "string" ? appId.trim() : "";
|
|
145
|
+
const normalizedOrg = typeof orgWallet === "string" ? orgWallet.trim().toLowerCase() : "";
|
|
146
|
+
if (!normalizedAppId) {
|
|
147
|
+
throw new ValidationError("appId is required for sponsor grant");
|
|
148
|
+
}
|
|
149
|
+
if (!normalizedOrg || !/^0x[a-f0-9]{40}$/.test(normalizedOrg)) {
|
|
150
|
+
throw new ValidationError("orgWallet must be a valid EVM address");
|
|
151
|
+
}
|
|
152
|
+
let base = String(apiUrl || "https://api.neus.network").replace(/\/+$/, "");
|
|
153
|
+
try {
|
|
154
|
+
const url = new URL(base);
|
|
155
|
+
if (url.hostname.endsWith("neus.network") && url.protocol === "http:") {
|
|
156
|
+
url.protocol = "https:";
|
|
157
|
+
}
|
|
158
|
+
base = url.toString().replace(/\/+$/, "");
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
const headers = {
|
|
162
|
+
"Content-Type": "application/json",
|
|
163
|
+
Accept: "application/json",
|
|
164
|
+
"X-Neus-App": normalizedAppId,
|
|
165
|
+
"X-Neus-Sdk": "js"
|
|
166
|
+
};
|
|
167
|
+
if (typeof origin === "string" && origin.trim()) {
|
|
168
|
+
headers.Origin = origin.trim();
|
|
169
|
+
}
|
|
170
|
+
const body = {
|
|
171
|
+
orgWallet: normalizedOrg,
|
|
172
|
+
scope: "sponsored-verification",
|
|
173
|
+
expiresInSeconds,
|
|
174
|
+
...Array.isArray(verifierIds) && verifierIds.length > 0 ? { verifierIds: verifierIds.map((v) => String(v).trim()).filter(Boolean).slice(0, 25) } : {},
|
|
175
|
+
...Array.isArray(targetChains) && targetChains.length > 0 ? { targetChains: targetChains.filter((n) => Number.isFinite(Number(n))).slice(0, 25) } : {}
|
|
176
|
+
};
|
|
177
|
+
let response;
|
|
178
|
+
try {
|
|
179
|
+
response = await fetchImpl(`${base}/api/v1/sponsor/grant`, {
|
|
180
|
+
method: "POST",
|
|
181
|
+
headers,
|
|
182
|
+
body: JSON.stringify(body)
|
|
183
|
+
});
|
|
184
|
+
} catch (error) {
|
|
185
|
+
throw new NetworkError(`Sponsor grant request failed: ${error?.message || String(error)}`);
|
|
186
|
+
}
|
|
187
|
+
let payload;
|
|
188
|
+
try {
|
|
189
|
+
payload = await response.json();
|
|
190
|
+
} catch {
|
|
191
|
+
payload = { success: false, error: { message: "Invalid JSON response" } };
|
|
192
|
+
}
|
|
193
|
+
if (!response.ok || payload?.success !== true) {
|
|
194
|
+
throw ApiError.fromResponse(response, payload);
|
|
195
|
+
}
|
|
196
|
+
const token = payload?.data?.sponsorGrant;
|
|
197
|
+
if (!token || typeof token !== "string") {
|
|
198
|
+
throw new ApiError("Sponsor grant response missing sponsorGrant token", payload?.error);
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
sponsorGrant: token,
|
|
202
|
+
exp: payload?.data?.exp,
|
|
203
|
+
orgWallet: payload?.data?.orgWallet || normalizedOrg,
|
|
204
|
+
appId: payload?.data?.appId || normalizedAppId,
|
|
205
|
+
maxCredits: payload?.data?.maxCredits
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
132
209
|
// utils.js
|
|
133
210
|
var PORTABLE_PROOF_SIGNER_HEADER = "Portable Proof Verification Request";
|
|
134
211
|
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
@@ -746,6 +823,54 @@ var NeusClient = class {
|
|
|
746
823
|
}
|
|
747
824
|
} catch {
|
|
748
825
|
}
|
|
826
|
+
this._sponsorGrantCache = null;
|
|
827
|
+
}
|
|
828
|
+
_getBillingWallet() {
|
|
829
|
+
const raw = this.config.billingWallet || this.config.sponsorOrgWallet || this.config.orgWallet || null;
|
|
830
|
+
if (typeof raw !== "string") return null;
|
|
831
|
+
const trimmed = raw.trim().toLowerCase();
|
|
832
|
+
return /^0x[a-f0-9]{40}$/.test(trimmed) ? trimmed : null;
|
|
833
|
+
}
|
|
834
|
+
_resolveIntegratorOrigin() {
|
|
835
|
+
if (typeof this.config.appOrigin === "string" && this.config.appOrigin.trim()) {
|
|
836
|
+
return this.config.appOrigin.trim();
|
|
837
|
+
}
|
|
838
|
+
try {
|
|
839
|
+
if (typeof window !== "undefined" && window.location?.origin) {
|
|
840
|
+
return window.location.origin;
|
|
841
|
+
}
|
|
842
|
+
} catch {
|
|
843
|
+
}
|
|
844
|
+
return null;
|
|
845
|
+
}
|
|
846
|
+
async _resolveSponsorGrantHeaders(verifierIds = []) {
|
|
847
|
+
const appId = typeof this.config.appId === "string" ? this.config.appId.trim() : "";
|
|
848
|
+
const orgWallet = this._getBillingWallet();
|
|
849
|
+
if (!appId || !orgWallet) {
|
|
850
|
+
return {};
|
|
851
|
+
}
|
|
852
|
+
const normalizedVerifierIds = Array.isArray(verifierIds) ? verifierIds.map((v) => String(v || "").trim()).filter(Boolean).slice(0, 25) : [];
|
|
853
|
+
const cacheKey = `${appId}:${orgWallet}:${normalizedVerifierIds.join(",")}`;
|
|
854
|
+
const now = Date.now();
|
|
855
|
+
if (this._sponsorGrantCache && this._sponsorGrantCache.key === cacheKey && this._sponsorGrantCache.expMs > now + 3e4) {
|
|
856
|
+
return { "X-Sponsor-Grant": this._sponsorGrantCache.token };
|
|
857
|
+
}
|
|
858
|
+
const origin = this._resolveIntegratorOrigin();
|
|
859
|
+
const grant = await fetchSponsorGrant({
|
|
860
|
+
apiUrl: this.baseUrl,
|
|
861
|
+
appId,
|
|
862
|
+
orgWallet,
|
|
863
|
+
verifierIds: normalizedVerifierIds,
|
|
864
|
+
origin
|
|
865
|
+
});
|
|
866
|
+
const expSeconds = Number(grant?.exp);
|
|
867
|
+
const expMs = Number.isFinite(expSeconds) && expSeconds > 0 ? expSeconds * 1e3 : now + 15 * 60 * 1e3;
|
|
868
|
+
this._sponsorGrantCache = {
|
|
869
|
+
key: cacheKey,
|
|
870
|
+
token: grant.sponsorGrant,
|
|
871
|
+
expMs
|
|
872
|
+
};
|
|
873
|
+
return { "X-Sponsor-Grant": grant.sponsorGrant };
|
|
749
874
|
}
|
|
750
875
|
_getHubChainId() {
|
|
751
876
|
const configured = Number(this.config?.hubChainId);
|
|
@@ -1271,21 +1396,20 @@ var NeusClient = class {
|
|
|
1271
1396
|
return hex;
|
|
1272
1397
|
}
|
|
1273
1398
|
};
|
|
1274
|
-
const
|
|
1399
|
+
const isBaseMiniAppWallet = (() => {
|
|
1275
1400
|
if (typeof window === "undefined") return false;
|
|
1276
1401
|
try {
|
|
1277
1402
|
const w = window;
|
|
1278
|
-
const
|
|
1279
|
-
if (!
|
|
1280
|
-
const
|
|
1281
|
-
if (
|
|
1282
|
-
if (w.
|
|
1283
|
-
if (w.ethereum === provider && fc && fc.context) return true;
|
|
1403
|
+
const mini = w.mini;
|
|
1404
|
+
if (!mini) return false;
|
|
1405
|
+
const miniProvider = mini.wallet || mini.provider;
|
|
1406
|
+
if (miniProvider === provider) return true;
|
|
1407
|
+
if (w.ethereum === provider && mini) return true;
|
|
1284
1408
|
} catch {
|
|
1285
1409
|
}
|
|
1286
1410
|
return false;
|
|
1287
1411
|
})();
|
|
1288
|
-
if (
|
|
1412
|
+
if (isBaseMiniAppWallet) {
|
|
1289
1413
|
try {
|
|
1290
1414
|
const hexMsg = toHexUtf82(message);
|
|
1291
1415
|
signature2 = await provider.request({ method: "personal_sign", params: [hexMsg, walletAddress2] });
|
|
@@ -1418,7 +1542,8 @@ ${bytes.length}`;
|
|
|
1418
1542
|
...delegationQHash && { delegationQHash },
|
|
1419
1543
|
options: optionsPayload
|
|
1420
1544
|
};
|
|
1421
|
-
const
|
|
1545
|
+
const sponsorHeaders = await this._resolveSponsorGrantHeaders(normalizedVerifierIds);
|
|
1546
|
+
const response = await this._makeRequest("POST", "/api/v1/verification", requestData, sponsorHeaders);
|
|
1422
1547
|
if (!response.success) {
|
|
1423
1548
|
throw new ApiError(`Verification failed: ${response.error?.message || "Unknown error"}`, response.error);
|
|
1424
1549
|
}
|
|
@@ -1633,7 +1758,9 @@ ${bytes.length}`;
|
|
|
1633
1758
|
const pathId = /^0x[a-fA-F0-9]{40}$/i.test(id) ? id.toLowerCase() : id;
|
|
1634
1759
|
const qs = [];
|
|
1635
1760
|
if (options.limit) qs.push(`limit=${encodeURIComponent(String(options.limit))}`);
|
|
1636
|
-
|
|
1761
|
+
const cursorRaw = options.cursor !== null && options.cursor !== void 0 ? String(options.cursor).trim() : "";
|
|
1762
|
+
if (cursorRaw) qs.push(`cursor=${encodeURIComponent(cursorRaw)}`);
|
|
1763
|
+
else if (options.offset) qs.push(`offset=${encodeURIComponent(String(options.offset))}`);
|
|
1637
1764
|
if (options.qHash) qs.push(`qHash=${encodeURIComponent(options.qHash.toLowerCase())}`);
|
|
1638
1765
|
const query = qs.length ? `?${qs.join("&")}` : "";
|
|
1639
1766
|
const response = await this._makeRequest(
|
|
@@ -1649,7 +1776,8 @@ ${bytes.length}`;
|
|
|
1649
1776
|
proofs: Array.isArray(proofs) ? proofs : [],
|
|
1650
1777
|
totalCount: response.data?.totalCount ?? proofs.length,
|
|
1651
1778
|
hasMore: Boolean(response.data?.hasMore),
|
|
1652
|
-
nextOffset: response.data?.nextOffset ?? null
|
|
1779
|
+
nextOffset: response.data?.nextOffset ?? null,
|
|
1780
|
+
nextCursor: typeof response.data?.nextCursor === "string" && response.data.nextCursor.trim() ? response.data.nextCursor.trim() : null
|
|
1653
1781
|
};
|
|
1654
1782
|
}
|
|
1655
1783
|
async getPrivateProofsByWallet(walletAddress, options = {}, wallet = null) {
|
|
@@ -1701,7 +1829,9 @@ ${bytes.length}`;
|
|
|
1701
1829
|
}
|
|
1702
1830
|
const qs = [];
|
|
1703
1831
|
if (options.limit) qs.push(`limit=${encodeURIComponent(String(options.limit))}`);
|
|
1704
|
-
|
|
1832
|
+
const cursorRaw = options.cursor !== null && options.cursor !== void 0 ? String(options.cursor).trim() : "";
|
|
1833
|
+
if (cursorRaw) qs.push(`cursor=${encodeURIComponent(cursorRaw)}`);
|
|
1834
|
+
else if (options.offset) qs.push(`offset=${encodeURIComponent(String(options.offset))}`);
|
|
1705
1835
|
if (options.qHash) qs.push(`qHash=${encodeURIComponent(options.qHash.toLowerCase())}`);
|
|
1706
1836
|
const query = qs.length ? `?${qs.join("&")}` : "";
|
|
1707
1837
|
const response = await this._makeRequest("GET", `/api/v1/proofs/by-wallet/${encodeURIComponent(pathId)}${query}`, null, {
|
|
@@ -1719,7 +1849,8 @@ ${bytes.length}`;
|
|
|
1719
1849
|
proofs: Array.isArray(proofs) ? proofs : [],
|
|
1720
1850
|
totalCount: response.data?.totalCount ?? proofs.length,
|
|
1721
1851
|
hasMore: Boolean(response.data?.hasMore),
|
|
1722
|
-
nextOffset: response.data?.nextOffset ?? null
|
|
1852
|
+
nextOffset: response.data?.nextOffset ?? null,
|
|
1853
|
+
nextCursor: typeof response.data?.nextCursor === "string" && response.data.nextCursor.trim() ? response.data.nextCursor.trim() : null
|
|
1723
1854
|
};
|
|
1724
1855
|
}
|
|
1725
1856
|
async gateCheck(params = {}) {
|
|
@@ -1727,6 +1858,8 @@ ${bytes.length}`;
|
|
|
1727
1858
|
if (!validateUniversalAddress(address, params.chain)) {
|
|
1728
1859
|
throw new ValidationError("Valid address is required");
|
|
1729
1860
|
}
|
|
1861
|
+
const gateIdParam = typeof params.gateId === "string" ? params.gateId.trim() : "";
|
|
1862
|
+
const verifierIds = gateIdParam ? void 0 : params.verifierIds;
|
|
1730
1863
|
const qs = new URLSearchParams();
|
|
1731
1864
|
qs.set("address", address);
|
|
1732
1865
|
const setIfPresent = (key, value) => {
|
|
@@ -1748,7 +1881,8 @@ ${bytes.length}`;
|
|
|
1748
1881
|
}
|
|
1749
1882
|
setIfPresent(key, value);
|
|
1750
1883
|
};
|
|
1751
|
-
|
|
1884
|
+
setIfPresent("gateId", gateIdParam);
|
|
1885
|
+
setCsvIfPresent("verifierIds", verifierIds);
|
|
1752
1886
|
setBoolIfPresent("requireAll", params.requireAll);
|
|
1753
1887
|
setIfPresent("minCount", params.minCount);
|
|
1754
1888
|
setIfPresent("sinceDays", params.sinceDays);
|
|
@@ -1811,7 +1945,20 @@ ${bytes.length}`;
|
|
|
1811
1945
|
};
|
|
1812
1946
|
}
|
|
1813
1947
|
}
|
|
1814
|
-
|
|
1948
|
+
let mergedHeaders = headersOverride;
|
|
1949
|
+
if (!mergedHeaders && !gateIdParam) {
|
|
1950
|
+
try {
|
|
1951
|
+
const sponsorHeaders = await this._resolveSponsorGrantHeaders(
|
|
1952
|
+
Array.isArray(verifierIds) ? verifierIds : verifierIds ? [verifierIds] : []
|
|
1953
|
+
);
|
|
1954
|
+
if (sponsorHeaders && Object.keys(sponsorHeaders).length > 0) {
|
|
1955
|
+
mergedHeaders = sponsorHeaders;
|
|
1956
|
+
}
|
|
1957
|
+
} catch (error) {
|
|
1958
|
+
this._log("Sponsor grant unavailable for gateCheck (continuing without)", error?.message || String(error));
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
const response = await this._makeRequest("GET", `/api/v1/proofs/check?${qs.toString()}`, null, mergedHeaders);
|
|
1815
1962
|
if (!response.success) {
|
|
1816
1963
|
throw new ApiError(`Gate check failed: ${response.error?.message || "Unknown error"}`, response.error);
|
|
1817
1964
|
}
|
package/cjs/errors.cjs
CHANGED
|
@@ -26,9 +26,7 @@ __export(errors_exports, {
|
|
|
26
26
|
NetworkError: () => NetworkError,
|
|
27
27
|
SDKError: () => SDKError,
|
|
28
28
|
ValidationError: () => ValidationError,
|
|
29
|
-
VerificationError: () => VerificationError
|
|
30
|
-
createErrorFromGeneric: () => createErrorFromGeneric,
|
|
31
|
-
default: () => errors_default
|
|
29
|
+
VerificationError: () => VerificationError
|
|
32
30
|
});
|
|
33
31
|
module.exports = __toCommonJS(errors_exports);
|
|
34
32
|
var SDKError = class _SDKError extends Error {
|
|
@@ -160,36 +158,6 @@ var AuthenticationError = class extends SDKError {
|
|
|
160
158
|
};
|
|
161
159
|
}
|
|
162
160
|
};
|
|
163
|
-
function createErrorFromGeneric(error, context = {}) {
|
|
164
|
-
if (error instanceof SDKError) {
|
|
165
|
-
return error;
|
|
166
|
-
}
|
|
167
|
-
if (NetworkError.isNetworkError(error)) {
|
|
168
|
-
return new NetworkError(
|
|
169
|
-
error.message || "Network error occurred",
|
|
170
|
-
error.code || "NETWORK_ERROR",
|
|
171
|
-
error
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
if (error.name === "AbortError" || error.message.includes("timeout")) {
|
|
175
|
-
return new NetworkError("Request timeout", "TIMEOUT", error);
|
|
176
|
-
}
|
|
177
|
-
return new SDKError(
|
|
178
|
-
error.message || "Unknown error occurred",
|
|
179
|
-
error.code || "UNKNOWN_ERROR",
|
|
180
|
-
{ originalError: error, context }
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
var errors_default = {
|
|
184
|
-
SDKError,
|
|
185
|
-
ApiError,
|
|
186
|
-
ValidationError,
|
|
187
|
-
NetworkError,
|
|
188
|
-
ConfigurationError,
|
|
189
|
-
VerificationError,
|
|
190
|
-
AuthenticationError,
|
|
191
|
-
createErrorFromGeneric
|
|
192
|
-
};
|
|
193
161
|
// Annotate the CommonJS export names for ESM import in node:
|
|
194
162
|
0 && (module.exports = {
|
|
195
163
|
ApiError,
|
|
@@ -198,6 +166,5 @@ var errors_default = {
|
|
|
198
166
|
NetworkError,
|
|
199
167
|
SDKError,
|
|
200
168
|
ValidationError,
|
|
201
|
-
VerificationError
|
|
202
|
-
createErrorFromGeneric
|
|
169
|
+
VerificationError
|
|
203
170
|
});
|
package/cjs/gates.cjs
CHANGED
|
@@ -36,8 +36,7 @@ __export(gates_exports, {
|
|
|
36
36
|
WEEK: () => WEEK,
|
|
37
37
|
YEAR: () => YEAR,
|
|
38
38
|
combineGates: () => combineGates,
|
|
39
|
-
createGate: () => createGate
|
|
40
|
-
default: () => gates_default
|
|
39
|
+
createGate: () => createGate
|
|
41
40
|
});
|
|
42
41
|
module.exports = __toCommonJS(gates_exports);
|
|
43
42
|
var HOUR = 60 * 60 * 1e3;
|
|
@@ -77,25 +76,6 @@ function combineGates(...gates) {
|
|
|
77
76
|
}
|
|
78
77
|
return combined;
|
|
79
78
|
}
|
|
80
|
-
var gates_default = {
|
|
81
|
-
HOUR,
|
|
82
|
-
DAY,
|
|
83
|
-
WEEK,
|
|
84
|
-
MONTH,
|
|
85
|
-
YEAR,
|
|
86
|
-
GATE_NFT_HOLDER,
|
|
87
|
-
GATE_TOKEN_HOLDER,
|
|
88
|
-
GATE_CONTRACT_ADMIN,
|
|
89
|
-
GATE_DOMAIN_OWNER,
|
|
90
|
-
GATE_LINKED_WALLETS,
|
|
91
|
-
GATE_AGENT_IDENTITY,
|
|
92
|
-
GATE_AGENT_DELEGATION,
|
|
93
|
-
GATE_CONTENT_MODERATION,
|
|
94
|
-
GATE_WALLET_RISK,
|
|
95
|
-
GATE_PSEUDONYM,
|
|
96
|
-
createGate,
|
|
97
|
-
combineGates
|
|
98
|
-
};
|
|
99
79
|
// Annotate the CommonJS export names for ESM import in node:
|
|
100
80
|
0 && (module.exports = {
|
|
101
81
|
DAY,
|