@neus/sdk 1.0.12 → 1.1.1
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 +206 -208
- package/cjs/client.cjs +191 -22
- package/cjs/errors.cjs +2 -35
- package/cjs/gates.cjs +1 -21
- package/cjs/index.cjs +203 -22
- package/cjs/utils.cjs +2 -0
- package/cli/neus.mjs +1215 -120
- package/client.js +150 -31
- package/errors.js +154 -189
- package/gates.js +0 -20
- package/index.js +2 -0
- package/package.json +142 -135
- package/sponsor.js +95 -0
- package/types.d.ts +91 -14
- package/utils.js +2 -0
- package/widgets/README.md +1 -1
- package/widgets/verify-gate/dist/ProofBadge.js +8 -16
- package/widgets/verify-gate/dist/VerifyGate.js +28 -15
- package/neus-logo.svg +0 -3
package/cjs/index.cjs
CHANGED
|
@@ -167,6 +167,89 @@ var init_errors = __esm({
|
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
+
// sponsor.js
|
|
171
|
+
async function fetchSponsorGrant(params = {}) {
|
|
172
|
+
const {
|
|
173
|
+
apiUrl = "https://api.neus.network",
|
|
174
|
+
appId,
|
|
175
|
+
orgWallet,
|
|
176
|
+
verifierIds = [],
|
|
177
|
+
targetChains = [],
|
|
178
|
+
origin,
|
|
179
|
+
expiresInSeconds = 900,
|
|
180
|
+
fetchImpl = fetch
|
|
181
|
+
} = params;
|
|
182
|
+
const normalizedAppId = typeof appId === "string" ? appId.trim() : "";
|
|
183
|
+
const normalizedOrg = typeof orgWallet === "string" ? orgWallet.trim().toLowerCase() : "";
|
|
184
|
+
if (!normalizedAppId) {
|
|
185
|
+
throw new ValidationError("appId is required for sponsor grant");
|
|
186
|
+
}
|
|
187
|
+
if (!normalizedOrg || !/^0x[a-f0-9]{40}$/.test(normalizedOrg)) {
|
|
188
|
+
throw new ValidationError("orgWallet must be a valid EVM address");
|
|
189
|
+
}
|
|
190
|
+
let base = String(apiUrl || "https://api.neus.network").replace(/\/+$/, "");
|
|
191
|
+
try {
|
|
192
|
+
const url = new URL(base);
|
|
193
|
+
if (url.hostname.endsWith("neus.network") && url.protocol === "http:") {
|
|
194
|
+
url.protocol = "https:";
|
|
195
|
+
}
|
|
196
|
+
base = url.toString().replace(/\/+$/, "");
|
|
197
|
+
} catch {
|
|
198
|
+
}
|
|
199
|
+
const headers = {
|
|
200
|
+
"Content-Type": "application/json",
|
|
201
|
+
Accept: "application/json",
|
|
202
|
+
"X-Neus-App": normalizedAppId,
|
|
203
|
+
"X-Neus-Sdk": "js"
|
|
204
|
+
};
|
|
205
|
+
if (typeof origin === "string" && origin.trim()) {
|
|
206
|
+
headers.Origin = origin.trim();
|
|
207
|
+
}
|
|
208
|
+
const body = {
|
|
209
|
+
orgWallet: normalizedOrg,
|
|
210
|
+
scope: "sponsored-verification",
|
|
211
|
+
expiresInSeconds,
|
|
212
|
+
...Array.isArray(verifierIds) && verifierIds.length > 0 ? { verifierIds: verifierIds.map((v) => String(v).trim()).filter(Boolean).slice(0, 25) } : {},
|
|
213
|
+
...Array.isArray(targetChains) && targetChains.length > 0 ? { targetChains: targetChains.filter((n) => Number.isFinite(Number(n))).slice(0, 25) } : {}
|
|
214
|
+
};
|
|
215
|
+
let response;
|
|
216
|
+
try {
|
|
217
|
+
response = await fetchImpl(`${base}/api/v1/sponsor/grant`, {
|
|
218
|
+
method: "POST",
|
|
219
|
+
headers,
|
|
220
|
+
body: JSON.stringify(body)
|
|
221
|
+
});
|
|
222
|
+
} catch (error) {
|
|
223
|
+
throw new NetworkError(`Sponsor grant request failed: ${error?.message || String(error)}`);
|
|
224
|
+
}
|
|
225
|
+
let payload;
|
|
226
|
+
try {
|
|
227
|
+
payload = await response.json();
|
|
228
|
+
} catch {
|
|
229
|
+
payload = { success: false, error: { message: "Invalid JSON response" } };
|
|
230
|
+
}
|
|
231
|
+
if (!response.ok || payload?.success !== true) {
|
|
232
|
+
throw ApiError.fromResponse(response, payload);
|
|
233
|
+
}
|
|
234
|
+
const token = payload?.data?.sponsorGrant;
|
|
235
|
+
if (!token || typeof token !== "string") {
|
|
236
|
+
throw new ApiError("Sponsor grant response missing sponsorGrant token", payload?.error);
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
sponsorGrant: token,
|
|
240
|
+
exp: payload?.data?.exp,
|
|
241
|
+
orgWallet: payload?.data?.orgWallet || normalizedOrg,
|
|
242
|
+
appId: payload?.data?.appId || normalizedAppId,
|
|
243
|
+
maxCredits: payload?.data?.maxCredits
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
var init_sponsor = __esm({
|
|
247
|
+
"sponsor.js"() {
|
|
248
|
+
"use strict";
|
|
249
|
+
init_errors();
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
170
253
|
// utils.js
|
|
171
254
|
function encodeBase58Bytes(input) {
|
|
172
255
|
let source;
|
|
@@ -956,6 +1039,8 @@ function getHostedCheckoutUrl(opts = {}) {
|
|
|
956
1039
|
if (opts.intent) params.set("intent", String(opts.intent));
|
|
957
1040
|
if (opts.origin) params.set("origin", String(opts.origin));
|
|
958
1041
|
if (opts.oauthProvider) params.set("oauthProvider", String(opts.oauthProvider));
|
|
1042
|
+
if (opts.appId) params.set("appId", String(opts.appId));
|
|
1043
|
+
if (opts.billingWallet) params.set("billingWallet", String(opts.billingWallet).trim().toLowerCase());
|
|
959
1044
|
const qs = params.toString();
|
|
960
1045
|
return qs ? `${base}?${qs}` : base;
|
|
961
1046
|
}
|
|
@@ -1091,6 +1176,7 @@ var init_client = __esm({
|
|
|
1091
1176
|
"client.js"() {
|
|
1092
1177
|
"use strict";
|
|
1093
1178
|
init_errors();
|
|
1179
|
+
init_sponsor();
|
|
1094
1180
|
init_utils();
|
|
1095
1181
|
FALLBACK_PUBLIC_VERIFIER_CATALOG = {
|
|
1096
1182
|
"ownership-basic": { supportsDirectApi: true },
|
|
@@ -1283,6 +1369,17 @@ var init_client = __esm({
|
|
|
1283
1369
|
if (data.agentType && !["ai", "bot", "service", "automation", "agent"].includes(data.agentType)) {
|
|
1284
1370
|
return { valid: false, error: "agentType must be one of: ai, bot, service, automation, agent" };
|
|
1285
1371
|
}
|
|
1372
|
+
if (data.defaultRuntime && typeof data.defaultRuntime === "object") {
|
|
1373
|
+
if (data.defaultRuntime.provider && typeof data.defaultRuntime.provider === "string" && data.defaultRuntime.provider.length > 64) {
|
|
1374
|
+
return { valid: false, error: "defaultRuntime.provider must be 64 chars or less" };
|
|
1375
|
+
}
|
|
1376
|
+
if (data.defaultRuntime.model && typeof data.defaultRuntime.model === "string" && data.defaultRuntime.model.length > 128) {
|
|
1377
|
+
return { valid: false, error: "defaultRuntime.model must be 128 chars or less" };
|
|
1378
|
+
}
|
|
1379
|
+
if (data.defaultRuntime.mode && typeof data.defaultRuntime.mode === "string" && data.defaultRuntime.mode.length > 64) {
|
|
1380
|
+
return { valid: false, error: "defaultRuntime.mode must be 64 chars or less" };
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1286
1383
|
break;
|
|
1287
1384
|
case "agent-delegation":
|
|
1288
1385
|
if (!data.controllerWallet || !validateWalletAddress(data.controllerWallet)) {
|
|
@@ -1297,6 +1394,18 @@ var init_client = __esm({
|
|
|
1297
1394
|
if (data.expiresAt && (typeof data.expiresAt !== "number" || data.expiresAt < Date.now())) {
|
|
1298
1395
|
return { valid: false, error: "expiresAt must be a future timestamp" };
|
|
1299
1396
|
}
|
|
1397
|
+
if (data.model && typeof data.model === "string" && data.model.length > 128) {
|
|
1398
|
+
return { valid: false, error: "model must be 128 chars or less" };
|
|
1399
|
+
}
|
|
1400
|
+
if (data.provider && typeof data.provider === "string" && data.provider.length > 64) {
|
|
1401
|
+
return { valid: false, error: "provider must be 64 chars or less" };
|
|
1402
|
+
}
|
|
1403
|
+
if (data.allowedActions && Array.isArray(data.allowedActions) && data.allowedActions.length > 32) {
|
|
1404
|
+
return { valid: false, error: "allowedActions must have 32 items or less" };
|
|
1405
|
+
}
|
|
1406
|
+
if (data.deniedActions && Array.isArray(data.deniedActions) && data.deniedActions.length > 32) {
|
|
1407
|
+
return { valid: false, error: "deniedActions must have 32 items or less" };
|
|
1408
|
+
}
|
|
1300
1409
|
break;
|
|
1301
1410
|
case "ai-content-moderation":
|
|
1302
1411
|
if (!data.content || typeof data.content !== "string") {
|
|
@@ -1407,6 +1516,54 @@ var init_client = __esm({
|
|
|
1407
1516
|
}
|
|
1408
1517
|
} catch {
|
|
1409
1518
|
}
|
|
1519
|
+
this._sponsorGrantCache = null;
|
|
1520
|
+
}
|
|
1521
|
+
_getBillingWallet() {
|
|
1522
|
+
const raw = this.config.billingWallet || this.config.sponsorOrgWallet || this.config.orgWallet || null;
|
|
1523
|
+
if (typeof raw !== "string") return null;
|
|
1524
|
+
const trimmed = raw.trim().toLowerCase();
|
|
1525
|
+
return /^0x[a-f0-9]{40}$/.test(trimmed) ? trimmed : null;
|
|
1526
|
+
}
|
|
1527
|
+
_resolveIntegratorOrigin() {
|
|
1528
|
+
if (typeof this.config.appOrigin === "string" && this.config.appOrigin.trim()) {
|
|
1529
|
+
return this.config.appOrigin.trim();
|
|
1530
|
+
}
|
|
1531
|
+
try {
|
|
1532
|
+
if (typeof window !== "undefined" && window.location?.origin) {
|
|
1533
|
+
return window.location.origin;
|
|
1534
|
+
}
|
|
1535
|
+
} catch {
|
|
1536
|
+
}
|
|
1537
|
+
return null;
|
|
1538
|
+
}
|
|
1539
|
+
async _resolveSponsorGrantHeaders(verifierIds = []) {
|
|
1540
|
+
const appId = typeof this.config.appId === "string" ? this.config.appId.trim() : "";
|
|
1541
|
+
const orgWallet = this._getBillingWallet();
|
|
1542
|
+
if (!appId || !orgWallet) {
|
|
1543
|
+
return {};
|
|
1544
|
+
}
|
|
1545
|
+
const normalizedVerifierIds = Array.isArray(verifierIds) ? verifierIds.map((v) => String(v || "").trim()).filter(Boolean).slice(0, 25) : [];
|
|
1546
|
+
const cacheKey = `${appId}:${orgWallet}:${normalizedVerifierIds.join(",")}`;
|
|
1547
|
+
const now = Date.now();
|
|
1548
|
+
if (this._sponsorGrantCache && this._sponsorGrantCache.key === cacheKey && this._sponsorGrantCache.expMs > now + 3e4) {
|
|
1549
|
+
return { "X-Sponsor-Grant": this._sponsorGrantCache.token };
|
|
1550
|
+
}
|
|
1551
|
+
const origin = this._resolveIntegratorOrigin();
|
|
1552
|
+
const grant = await fetchSponsorGrant({
|
|
1553
|
+
apiUrl: this.baseUrl,
|
|
1554
|
+
appId,
|
|
1555
|
+
orgWallet,
|
|
1556
|
+
verifierIds: normalizedVerifierIds,
|
|
1557
|
+
origin
|
|
1558
|
+
});
|
|
1559
|
+
const expSeconds = Number(grant?.exp);
|
|
1560
|
+
const expMs = Number.isFinite(expSeconds) && expSeconds > 0 ? expSeconds * 1e3 : now + 15 * 60 * 1e3;
|
|
1561
|
+
this._sponsorGrantCache = {
|
|
1562
|
+
key: cacheKey,
|
|
1563
|
+
token: grant.sponsorGrant,
|
|
1564
|
+
expMs
|
|
1565
|
+
};
|
|
1566
|
+
return { "X-Sponsor-Grant": grant.sponsorGrant };
|
|
1410
1567
|
}
|
|
1411
1568
|
_getHubChainId() {
|
|
1412
1569
|
const configured = Number(this.config?.hubChainId);
|
|
@@ -1830,9 +1987,13 @@ var init_client = __esm({
|
|
|
1830
1987
|
verificationData = {
|
|
1831
1988
|
agentId: data2.agentId,
|
|
1832
1989
|
agentWallet: data2?.agentWallet || walletAddress2,
|
|
1990
|
+
...data2?.agentChainRef && { agentChainRef: data2.agentChainRef },
|
|
1991
|
+
...data2?.agentAccountId && { agentAccountId: data2.agentAccountId },
|
|
1833
1992
|
...data2?.agentLabel && { agentLabel: data2.agentLabel },
|
|
1834
1993
|
...data2?.agentType && { agentType: data2.agentType },
|
|
1994
|
+
...data2?.avatar && { avatar: data2.avatar },
|
|
1835
1995
|
...data2?.description && { description: data2.description },
|
|
1996
|
+
...data2?.defaultRuntime && { defaultRuntime: data2.defaultRuntime },
|
|
1836
1997
|
...data2?.capabilities && { capabilities: data2.capabilities },
|
|
1837
1998
|
...data2?.instructions && { instructions: data2.instructions },
|
|
1838
1999
|
...data2?.skills && { skills: data2.skills },
|
|
@@ -1844,7 +2005,11 @@ var init_client = __esm({
|
|
|
1844
2005
|
}
|
|
1845
2006
|
verificationData = {
|
|
1846
2007
|
controllerWallet: data2?.controllerWallet || walletAddress2,
|
|
2008
|
+
...data2?.controllerChainRef && { controllerChainRef: data2.controllerChainRef },
|
|
1847
2009
|
agentWallet: data2.agentWallet,
|
|
2010
|
+
...data2?.agentChainRef && { agentChainRef: data2.agentChainRef },
|
|
2011
|
+
...data2?.controllerAccountId && { controllerAccountId: data2.controllerAccountId },
|
|
2012
|
+
...data2?.agentAccountId && { agentAccountId: data2.agentAccountId },
|
|
1848
2013
|
...data2?.agentId && { agentId: data2.agentId },
|
|
1849
2014
|
...data2?.scope && { scope: data2.scope },
|
|
1850
2015
|
...data2?.permissions && { permissions: data2.permissions },
|
|
@@ -1853,7 +2018,13 @@ var init_client = __esm({
|
|
|
1853
2018
|
...data2?.receiptDisclosure && { receiptDisclosure: data2.receiptDisclosure },
|
|
1854
2019
|
...data2?.expiresAt && { expiresAt: data2.expiresAt },
|
|
1855
2020
|
...data2?.instructions && { instructions: data2.instructions },
|
|
1856
|
-
...data2?.skills && { skills: data2.skills }
|
|
2021
|
+
...data2?.skills && { skills: data2.skills },
|
|
2022
|
+
...data2?.model && { model: data2.model },
|
|
2023
|
+
...data2?.provider && { provider: data2.provider },
|
|
2024
|
+
...data2?.runtimePolicy && { runtimePolicy: data2.runtimePolicy },
|
|
2025
|
+
...data2?.allowedActions && { allowedActions: data2.allowedActions },
|
|
2026
|
+
...data2?.deniedActions && { deniedActions: data2.deniedActions },
|
|
2027
|
+
...data2?.approvalPolicy && { approvalPolicy: data2.approvalPolicy }
|
|
1857
2028
|
};
|
|
1858
2029
|
} else if (verifier === "ai-content-moderation") {
|
|
1859
2030
|
if (!data2?.content) {
|
|
@@ -2065,26 +2236,25 @@ ${bytes.length}`;
|
|
|
2065
2236
|
...delegationQHash && { delegationQHash },
|
|
2066
2237
|
options: optionsPayload
|
|
2067
2238
|
};
|
|
2068
|
-
const
|
|
2239
|
+
const sponsorHeaders = await this._resolveSponsorGrantHeaders(normalizedVerifierIds);
|
|
2240
|
+
const response = await this._makeRequest("POST", "/api/v1/verification", requestData, sponsorHeaders);
|
|
2069
2241
|
if (!response.success) {
|
|
2070
2242
|
throw new ApiError(`Verification failed: ${response.error?.message || "Unknown error"}`, response.error);
|
|
2071
2243
|
}
|
|
2072
2244
|
return this._formatResponse(response);
|
|
2073
2245
|
}
|
|
2074
2246
|
async getProof(qHash) {
|
|
2075
|
-
|
|
2076
|
-
if (!resolvedQHash || typeof resolvedQHash !== "string") {
|
|
2247
|
+
if (!qHash || typeof qHash !== "string") {
|
|
2077
2248
|
throw new ValidationError("qHash is required");
|
|
2078
2249
|
}
|
|
2079
|
-
const response = await this._makeRequest("GET", `/api/v1/proofs/${
|
|
2250
|
+
const response = await this._makeRequest("GET", `/api/v1/proofs/${qHash}`);
|
|
2080
2251
|
if (!response.success) {
|
|
2081
2252
|
throw new ApiError(`Failed to get proof: ${response.error?.message || "Unknown error"}`, response.error);
|
|
2082
2253
|
}
|
|
2083
2254
|
return this._formatResponse(response);
|
|
2084
2255
|
}
|
|
2085
2256
|
async getPrivateProof(qHash, wallet = null) {
|
|
2086
|
-
|
|
2087
|
-
if (!resolvedQHash || typeof resolvedQHash !== "string") {
|
|
2257
|
+
if (!qHash || typeof qHash !== "string") {
|
|
2088
2258
|
throw new ValidationError("qHash is required");
|
|
2089
2259
|
}
|
|
2090
2260
|
const isPreSignedAuth = wallet && typeof wallet === "object" && typeof wallet.walletAddress === "string" && typeof wallet.signature === "string" && typeof wallet.signedTimestamp === "number";
|
|
@@ -2097,7 +2267,7 @@ ${bytes.length}`;
|
|
|
2097
2267
|
...typeof auth.chain === "string" && auth.chain.trim() ? { "x-chain": auth.chain.trim() } : {},
|
|
2098
2268
|
...typeof auth.signatureMethod === "string" && auth.signatureMethod.trim() ? { "x-signature-method": auth.signatureMethod.trim() } : {}
|
|
2099
2269
|
};
|
|
2100
|
-
const response2 = await this._makeRequest("GET", `/api/v1/proofs/${
|
|
2270
|
+
const response2 = await this._makeRequest("GET", `/api/v1/proofs/${qHash}`, null, headers);
|
|
2101
2271
|
if (!response2.success) {
|
|
2102
2272
|
throw new ApiError(
|
|
2103
2273
|
`Failed to access private proof: ${response2.error?.message || "Unauthorized"}`,
|
|
@@ -2118,7 +2288,7 @@ ${bytes.length}`;
|
|
|
2118
2288
|
const message = constructVerificationMessage({
|
|
2119
2289
|
walletAddress,
|
|
2120
2290
|
signedTimestamp,
|
|
2121
|
-
data: { action: "access_private_proof", qHash
|
|
2291
|
+
data: { action: "access_private_proof", qHash },
|
|
2122
2292
|
verifierIds: ["ownership-basic"],
|
|
2123
2293
|
...signerIsEvm ? { chainId: this._getHubChainId() } : { chain }
|
|
2124
2294
|
});
|
|
@@ -2136,7 +2306,7 @@ ${bytes.length}`;
|
|
|
2136
2306
|
}
|
|
2137
2307
|
throw new ValidationError(`Failed to sign message: ${error.message}`);
|
|
2138
2308
|
}
|
|
2139
|
-
const response = await this._makeRequest("GET", `/api/v1/proofs/${
|
|
2309
|
+
const response = await this._makeRequest("GET", `/api/v1/proofs/${qHash}`, null, {
|
|
2140
2310
|
"x-wallet-address": walletAddress,
|
|
2141
2311
|
"x-signature": signature,
|
|
2142
2312
|
"x-signed-timestamp": signedTimestamp.toString(),
|
|
@@ -2174,20 +2344,19 @@ ${bytes.length}`;
|
|
|
2174
2344
|
};
|
|
2175
2345
|
}
|
|
2176
2346
|
async pollProofStatus(qHash, options = {}) {
|
|
2177
|
-
const resolvedQHash = qHash;
|
|
2178
2347
|
const {
|
|
2179
2348
|
interval = 5e3,
|
|
2180
2349
|
timeout = 12e4,
|
|
2181
2350
|
onProgress
|
|
2182
2351
|
} = options;
|
|
2183
|
-
if (!
|
|
2352
|
+
if (!qHash || typeof qHash !== "string") {
|
|
2184
2353
|
throw new ValidationError("qHash is required");
|
|
2185
2354
|
}
|
|
2186
2355
|
const startTime = Date.now();
|
|
2187
2356
|
let consecutiveRateLimits = 0;
|
|
2188
2357
|
while (Date.now() - startTime < timeout) {
|
|
2189
2358
|
try {
|
|
2190
|
-
const status = await this.getProof(
|
|
2359
|
+
const status = await this.getProof(qHash);
|
|
2191
2360
|
consecutiveRateLimits = 0;
|
|
2192
2361
|
if (onProgress && typeof onProgress === "function") {
|
|
2193
2362
|
onProgress(status.data || status);
|
|
@@ -2230,8 +2399,7 @@ ${bytes.length}`;
|
|
|
2230
2399
|
}
|
|
2231
2400
|
}
|
|
2232
2401
|
async revokeOwnProof(qHash, wallet) {
|
|
2233
|
-
|
|
2234
|
-
if (!resolvedQHash || typeof resolvedQHash !== "string") {
|
|
2402
|
+
if (!qHash || typeof qHash !== "string") {
|
|
2235
2403
|
throw new ValidationError("qHash is required");
|
|
2236
2404
|
}
|
|
2237
2405
|
const providerWallet = wallet || this._getDefaultBrowserWallet();
|
|
@@ -2246,7 +2414,7 @@ ${bytes.length}`;
|
|
|
2246
2414
|
const message = constructVerificationMessage({
|
|
2247
2415
|
walletAddress: address,
|
|
2248
2416
|
signedTimestamp,
|
|
2249
|
-
data: { action: "revoke_proof", qHash
|
|
2417
|
+
data: { action: "revoke_proof", qHash },
|
|
2250
2418
|
verifierIds: ["ownership-basic"],
|
|
2251
2419
|
...signerIsEvm ? { chainId: this._getHubChainId() } : { chain }
|
|
2252
2420
|
});
|
|
@@ -2264,7 +2432,7 @@ ${bytes.length}`;
|
|
|
2264
2432
|
}
|
|
2265
2433
|
throw new ValidationError(`Failed to sign revocation: ${error.message}`);
|
|
2266
2434
|
}
|
|
2267
|
-
const res = await this._makeRequest("POST", `/api/v1/proofs/revoke-self/${
|
|
2435
|
+
const res = await this._makeRequest("POST", `/api/v1/proofs/revoke-self/${qHash}`, {
|
|
2268
2436
|
walletAddress: address,
|
|
2269
2437
|
signature,
|
|
2270
2438
|
signedTimestamp,
|
|
@@ -2462,7 +2630,20 @@ ${bytes.length}`;
|
|
|
2462
2630
|
};
|
|
2463
2631
|
}
|
|
2464
2632
|
}
|
|
2465
|
-
|
|
2633
|
+
let mergedHeaders = headersOverride;
|
|
2634
|
+
if (!mergedHeaders) {
|
|
2635
|
+
try {
|
|
2636
|
+
const sponsorHeaders = await this._resolveSponsorGrantHeaders(
|
|
2637
|
+
Array.isArray(params.verifierIds) ? params.verifierIds : params.verifierIds ? [params.verifierIds] : []
|
|
2638
|
+
);
|
|
2639
|
+
if (sponsorHeaders && Object.keys(sponsorHeaders).length > 0) {
|
|
2640
|
+
mergedHeaders = sponsorHeaders;
|
|
2641
|
+
}
|
|
2642
|
+
} catch (error) {
|
|
2643
|
+
this._log("Sponsor grant unavailable for gateCheck (continuing without)", error?.message || String(error));
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
const response = await this._makeRequest("GET", `/api/v1/proofs/check?${qs.toString()}`, null, mergedHeaders);
|
|
2466
2647
|
if (!response.success) {
|
|
2467
2648
|
throw new ApiError(`Gate check failed: ${response.error?.message || "Unknown error"}`, response.error);
|
|
2468
2649
|
}
|
|
@@ -2671,10 +2852,7 @@ ${bytes.length}`;
|
|
|
2671
2852
|
}
|
|
2672
2853
|
}
|
|
2673
2854
|
_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;
|
|
2855
|
+
const qHash = response?.data?.qHash || response?.qHash || response?.data?.resource?.qHash || response?.data?.id;
|
|
2678
2856
|
const status = response?.data?.status || response?.status || response?.data?.resource?.status || (response?.success ? "completed" : "unknown");
|
|
2679
2857
|
return {
|
|
2680
2858
|
success: response.success,
|
|
@@ -2754,6 +2932,7 @@ __export(index_exports, {
|
|
|
2754
2932
|
default: () => index_default,
|
|
2755
2933
|
delay: () => delay,
|
|
2756
2934
|
deriveDid: () => deriveDid,
|
|
2935
|
+
fetchSponsorGrant: () => fetchSponsorGrant,
|
|
2757
2936
|
formatTimestamp: () => formatTimestamp,
|
|
2758
2937
|
formatVerificationStatus: () => formatVerificationStatus,
|
|
2759
2938
|
getHostedCheckoutUrl: () => getHostedCheckoutUrl,
|
|
@@ -2820,6 +2999,7 @@ function combineGates(...gates) {
|
|
|
2820
2999
|
}
|
|
2821
3000
|
|
|
2822
3001
|
// index.js
|
|
3002
|
+
init_sponsor();
|
|
2823
3003
|
init_errors();
|
|
2824
3004
|
var index_default = {
|
|
2825
3005
|
NeusClient: () => Promise.resolve().then(() => (init_client(), client_exports)).then((m) => m.NeusClient),
|
|
@@ -2862,6 +3042,7 @@ var index_default = {
|
|
|
2862
3042
|
createVerificationData,
|
|
2863
3043
|
delay,
|
|
2864
3044
|
deriveDid,
|
|
3045
|
+
fetchSponsorGrant,
|
|
2865
3046
|
formatTimestamp,
|
|
2866
3047
|
formatVerificationStatus,
|
|
2867
3048
|
getHostedCheckoutUrl,
|
package/cjs/utils.cjs
CHANGED
|
@@ -1012,6 +1012,8 @@ function getHostedCheckoutUrl(opts = {}) {
|
|
|
1012
1012
|
if (opts.intent) params.set("intent", String(opts.intent));
|
|
1013
1013
|
if (opts.origin) params.set("origin", String(opts.origin));
|
|
1014
1014
|
if (opts.oauthProvider) params.set("oauthProvider", String(opts.oauthProvider));
|
|
1015
|
+
if (opts.appId) params.set("appId", String(opts.appId));
|
|
1016
|
+
if (opts.billingWallet) params.set("billingWallet", String(opts.billingWallet).trim().toLowerCase());
|
|
1015
1017
|
const qs = params.toString();
|
|
1016
1018
|
return qs ? `${base}?${qs}` : base;
|
|
1017
1019
|
}
|