@neus/sdk 1.0.5 → 1.0.6
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 +4 -24
- package/SECURITY.md +11 -6
- package/cjs/client.cjs +59 -220
- package/cjs/gates.cjs +10 -33
- package/cjs/index.cjs +69 -251
- package/cjs/utils.cjs +0 -6
- package/client.js +1742 -1945
- package/errors.js +0 -34
- package/gates.js +73 -175
- package/index.js +0 -9
- package/package.json +4 -3
- package/types.d.ts +4 -463
- package/utils.js +1 -265
- package/widgets/README.md +45 -45
- package/widgets/index.js +0 -8
- package/widgets/verify-gate/dist/ProofBadge.js +0 -3
- package/widgets/verify-gate/dist/VerifyGate.js +57 -77
- package/widgets/verify-gate/index.js +0 -4
package/cjs/index.cjs
CHANGED
|
@@ -322,7 +322,6 @@ function createVerificationData(content, owner, reference = null) {
|
|
|
322
322
|
content,
|
|
323
323
|
owner: validateWalletAddress(owner) ? owner.toLowerCase() : owner,
|
|
324
324
|
reference: reference || {
|
|
325
|
-
// Must be a valid backend enum value; 'content' is not supported.
|
|
326
325
|
type: "other",
|
|
327
326
|
id: stableRefId(content)
|
|
328
327
|
}
|
|
@@ -1034,9 +1033,7 @@ var init_utils = __esm({
|
|
|
1034
1033
|
}
|
|
1035
1034
|
};
|
|
1036
1035
|
NEUS_CONSTANTS = {
|
|
1037
|
-
/** Default EVM chain id for NEUS protocol signing context (`HUB_CHAIN_ID` name kept for compatibility). */
|
|
1038
1036
|
HUB_CHAIN_ID: 84532,
|
|
1039
|
-
// Supported target chains for cross-chain propagation
|
|
1040
1037
|
TESTNET_CHAINS: [
|
|
1041
1038
|
11155111,
|
|
1042
1039
|
// Ethereum Sepolia
|
|
@@ -1047,15 +1044,12 @@ var init_utils = __esm({
|
|
|
1047
1044
|
80002
|
|
1048
1045
|
// Polygon Amoy
|
|
1049
1046
|
],
|
|
1050
|
-
// API endpoints
|
|
1051
1047
|
API_BASE_URL: "https://api.neus.network",
|
|
1052
1048
|
API_VERSION: "v1",
|
|
1053
|
-
// Timeouts and limits
|
|
1054
1049
|
SIGNATURE_MAX_AGE_MS: 5 * 60 * 1e3,
|
|
1055
1050
|
// 5 minutes
|
|
1056
1051
|
REQUEST_TIMEOUT_MS: 30 * 1e3,
|
|
1057
1052
|
// 30 seconds
|
|
1058
|
-
// Default verifier set for quick starts
|
|
1059
1053
|
DEFAULT_VERIFIERS: [
|
|
1060
1054
|
"ownership-basic",
|
|
1061
1055
|
"nft-ownership",
|
|
@@ -1077,6 +1071,16 @@ function normalizeWalletLinkRelationshipType(value) {
|
|
|
1077
1071
|
const normalized = String(value || "").trim().toLowerCase();
|
|
1078
1072
|
return WALLET_LINK_RELATIONSHIP_TYPES.has(normalized) ? normalized : "linked";
|
|
1079
1073
|
}
|
|
1074
|
+
function normalizeBrowserSignerString(raw) {
|
|
1075
|
+
if (raw === null || raw === void 0) {
|
|
1076
|
+
return null;
|
|
1077
|
+
}
|
|
1078
|
+
if (typeof raw === "string") {
|
|
1079
|
+
const t = raw.trim();
|
|
1080
|
+
return t.length > 0 ? t : null;
|
|
1081
|
+
}
|
|
1082
|
+
return null;
|
|
1083
|
+
}
|
|
1080
1084
|
var FALLBACK_PUBLIC_VERIFIER_CATALOG, EVM_ADDRESS_RE, WALLET_LINK_RELATIONSHIP_TYPES, validateVerifierData, NeusClient;
|
|
1081
1085
|
var init_client = __esm({
|
|
1082
1086
|
"client.js"() {
|
|
@@ -1429,26 +1433,49 @@ var init_client = __esm({
|
|
|
1429
1433
|
if (!wallet) {
|
|
1430
1434
|
throw new ConfigurationError("No wallet provider available");
|
|
1431
1435
|
}
|
|
1432
|
-
if (wallet.address) {
|
|
1433
|
-
|
|
1436
|
+
if (wallet.address !== null && wallet.address !== void 0) {
|
|
1437
|
+
const s = normalizeBrowserSignerString(
|
|
1438
|
+
typeof wallet.address === "string" ? wallet.address : null
|
|
1439
|
+
);
|
|
1440
|
+
if (s) {
|
|
1441
|
+
return { signerWalletAddress: s, provider: wallet };
|
|
1442
|
+
}
|
|
1434
1443
|
}
|
|
1435
1444
|
if (wallet.publicKey && typeof wallet.publicKey.toBase58 === "function") {
|
|
1436
|
-
|
|
1445
|
+
const b58 = wallet.publicKey.toBase58();
|
|
1446
|
+
const s = normalizeBrowserSignerString(typeof b58 === "string" ? b58 : null);
|
|
1447
|
+
if (s) {
|
|
1448
|
+
return { signerWalletAddress: s, provider: wallet };
|
|
1449
|
+
}
|
|
1437
1450
|
}
|
|
1438
1451
|
if (typeof wallet.getAddress === "function") {
|
|
1439
|
-
const
|
|
1440
|
-
|
|
1452
|
+
const got = await wallet.getAddress().catch(() => null);
|
|
1453
|
+
const s = normalizeBrowserSignerString(
|
|
1454
|
+
got === null || got === void 0 ? null : typeof got === "string" ? got : null
|
|
1455
|
+
);
|
|
1456
|
+
if (s) {
|
|
1457
|
+
return { signerWalletAddress: s, provider: wallet };
|
|
1458
|
+
}
|
|
1441
1459
|
}
|
|
1442
1460
|
if (wallet.selectedAddress || wallet.request) {
|
|
1443
1461
|
const provider = wallet;
|
|
1444
1462
|
if (wallet.selectedAddress) {
|
|
1445
|
-
|
|
1463
|
+
const s2 = normalizeBrowserSignerString(
|
|
1464
|
+
typeof wallet.selectedAddress === "string" ? wallet.selectedAddress : null
|
|
1465
|
+
);
|
|
1466
|
+
if (s2) {
|
|
1467
|
+
return { signerWalletAddress: s2, provider };
|
|
1468
|
+
}
|
|
1446
1469
|
}
|
|
1447
1470
|
const accounts = await provider.request({ method: "eth_accounts" });
|
|
1448
1471
|
if (!accounts || accounts.length === 0) {
|
|
1449
1472
|
throw new ConfigurationError("No wallet accounts available");
|
|
1450
1473
|
}
|
|
1451
|
-
|
|
1474
|
+
const s = normalizeBrowserSignerString(accounts[0]);
|
|
1475
|
+
if (!s) {
|
|
1476
|
+
throw new ConfigurationError("No wallet accounts available");
|
|
1477
|
+
}
|
|
1478
|
+
return { signerWalletAddress: s, provider };
|
|
1452
1479
|
}
|
|
1453
1480
|
throw new ConfigurationError("Invalid wallet provider");
|
|
1454
1481
|
}
|
|
@@ -1579,47 +1606,6 @@ var init_client = __esm({
|
|
|
1579
1606
|
...label ? { label } : {}
|
|
1580
1607
|
};
|
|
1581
1608
|
}
|
|
1582
|
-
/**
|
|
1583
|
-
* Create a verification proof.
|
|
1584
|
-
*
|
|
1585
|
-
* Supports two paths:
|
|
1586
|
-
* - **Auto:** Supply `verifier`, `content`, and/or `data` with an optional
|
|
1587
|
-
* `wallet` provider. The SDK performs signing in the client.
|
|
1588
|
-
* - **Manual:** Supply pre-signed `verifierIds`, `data`, `walletAddress`,
|
|
1589
|
-
* `signature`, and `signedTimestamp`.
|
|
1590
|
-
*
|
|
1591
|
-
* @param {Object} params - Verification parameters
|
|
1592
|
-
* @param {string} [params.verifier] - Verifier ID (auto path, e.g. 'ownership-basic')
|
|
1593
|
-
* @param {string} [params.content] - Content to verify (auto path)
|
|
1594
|
-
* @param {Object} [params.data] - Structured verification data
|
|
1595
|
-
* @param {Object} [params.wallet] - Wallet provider (auto path)
|
|
1596
|
-
* @param {Object} [params.options] - Additional options
|
|
1597
|
-
* @param {Array<string>} [params.verifierIds] - Array of verifier IDs (manual path)
|
|
1598
|
-
* @param {string} [params.walletAddress] - Wallet address that signed the request (manual path)
|
|
1599
|
-
* @param {string} [params.signature] - EIP-191 signature (manual path)
|
|
1600
|
-
* @param {number} [params.signedTimestamp] - Unix timestamp when signature was created (manual path)
|
|
1601
|
-
* @param {number} [params.chainId] - EVM signing-context hint; when omitted, resolved to the NEUS protocol primary chain for signing
|
|
1602
|
-
* @returns {Promise<Object>} Verification result with proofId
|
|
1603
|
-
*
|
|
1604
|
-
* @example
|
|
1605
|
-
* // Auto path
|
|
1606
|
-
* const proof = await client.verify({
|
|
1607
|
-
* verifier: 'ownership-basic',
|
|
1608
|
-
* content: 'Hello World',
|
|
1609
|
-
* wallet: window.ethereum
|
|
1610
|
-
* });
|
|
1611
|
-
*
|
|
1612
|
-
* @example
|
|
1613
|
-
* // Manual path
|
|
1614
|
-
* const proof = await client.verify({
|
|
1615
|
-
* verifierIds: ['ownership-basic'],
|
|
1616
|
-
* data: { content: "My content", owner: walletAddress },
|
|
1617
|
-
* walletAddress: '0x...',
|
|
1618
|
-
* signature: '0x...',
|
|
1619
|
-
* signedTimestamp: Date.now(),
|
|
1620
|
-
* options: { targetChains: [421614, 11155111] }
|
|
1621
|
-
* });
|
|
1622
|
-
*/
|
|
1623
1609
|
async verify(params) {
|
|
1624
1610
|
if ((!params?.signature || !params?.walletAddress) && (params?.verifier || params?.content || params?.data)) {
|
|
1625
1611
|
const { content, verifier = "ownership-basic", data: data2 = null, wallet = null, options: options2 = {} } = params;
|
|
@@ -1661,11 +1647,16 @@ var init_client = __esm({
|
|
|
1661
1647
|
}
|
|
1662
1648
|
let walletAddress2, provider;
|
|
1663
1649
|
if (wallet) {
|
|
1664
|
-
walletAddress2 = wallet.address || wallet.selectedAddress || wallet.walletAddress || (typeof wallet.getAddress === "function" ? await wallet.getAddress() : null);
|
|
1650
|
+
walletAddress2 = wallet.address || wallet.selectedAddress || wallet.walletAddress || (typeof wallet.getAddress === "function" ? await wallet.getAddress().catch(() => null) : null);
|
|
1665
1651
|
provider = wallet.provider || wallet;
|
|
1666
1652
|
if (!walletAddress2 && provider && typeof provider.request === "function") {
|
|
1667
|
-
|
|
1668
|
-
walletAddress2 = Array.isArray(accounts) ? accounts[0] : null;
|
|
1653
|
+
let accounts = await provider.request({ method: "eth_accounts" });
|
|
1654
|
+
walletAddress2 = Array.isArray(accounts) && accounts.length > 0 ? accounts[0] : null;
|
|
1655
|
+
if (!walletAddress2) {
|
|
1656
|
+
await provider.request({ method: "eth_requestAccounts" });
|
|
1657
|
+
accounts = await provider.request({ method: "eth_accounts" });
|
|
1658
|
+
walletAddress2 = Array.isArray(accounts) && accounts.length > 0 ? accounts[0] : null;
|
|
1659
|
+
}
|
|
1669
1660
|
}
|
|
1670
1661
|
} else {
|
|
1671
1662
|
if (typeof window === "undefined" || !window.ethereum) {
|
|
@@ -1676,6 +1667,15 @@ var init_client = __esm({
|
|
|
1676
1667
|
const accounts = await provider.request({ method: "eth_accounts" });
|
|
1677
1668
|
walletAddress2 = accounts[0];
|
|
1678
1669
|
}
|
|
1670
|
+
{
|
|
1671
|
+
const normalized = normalizeBrowserSignerString(
|
|
1672
|
+
typeof walletAddress2 === "string" ? walletAddress2 : null
|
|
1673
|
+
);
|
|
1674
|
+
if (!normalized) {
|
|
1675
|
+
throw new ConfigurationError("No wallet accounts available. Connect a wallet to continue.");
|
|
1676
|
+
}
|
|
1677
|
+
walletAddress2 = normalized;
|
|
1678
|
+
}
|
|
1679
1679
|
let verificationData;
|
|
1680
1680
|
if (verifier === "ownership-basic") {
|
|
1681
1681
|
if (data2 && typeof data2 === "object") {
|
|
@@ -1827,8 +1827,6 @@ var init_client = __esm({
|
|
|
1827
1827
|
verificationData = {
|
|
1828
1828
|
walletAddress: data2?.walletAddress || walletAddress2,
|
|
1829
1829
|
...data2?.provider && { provider: data2.provider },
|
|
1830
|
-
// Mainnet-first semantics: if caller doesn't provide chainId, default to Ethereum mainnet (1).
|
|
1831
|
-
// This avoids accidental testnet semantics for risk providers.
|
|
1832
1830
|
chainId: typeof data2?.chainId === "number" && Number.isFinite(data2.chainId) ? data2.chainId : 1,
|
|
1833
1831
|
...data2?.includeDetails !== void 0 && { includeDetails: data2.includeDetails }
|
|
1834
1832
|
};
|
|
@@ -1850,7 +1848,6 @@ var init_client = __esm({
|
|
|
1850
1848
|
data: verificationData,
|
|
1851
1849
|
verifierIds: verifierIds2,
|
|
1852
1850
|
chainId: this._getHubChainId()
|
|
1853
|
-
// Protocol-managed chain
|
|
1854
1851
|
});
|
|
1855
1852
|
let signature2;
|
|
1856
1853
|
try {
|
|
@@ -1886,6 +1883,7 @@ var init_client = __esm({
|
|
|
1886
1883
|
const hexMsg = toHexUtf82(message);
|
|
1887
1884
|
signature2 = await provider.request({ method: "personal_sign", params: [hexMsg, walletAddress2] });
|
|
1888
1885
|
} catch (e) {
|
|
1886
|
+
void e;
|
|
1889
1887
|
}
|
|
1890
1888
|
}
|
|
1891
1889
|
if (!signature2) {
|
|
@@ -1995,7 +1993,6 @@ ${bytes.length}`;
|
|
|
1995
1993
|
const optionsPayload = {
|
|
1996
1994
|
...options && typeof options === "object" ? options : {},
|
|
1997
1995
|
targetChains: Array.isArray(options?.targetChains) ? options.targetChains : [],
|
|
1998
|
-
// Privacy and storage options (defaults)
|
|
1999
1996
|
privacyLevel: options?.privacyLevel || "private",
|
|
2000
1997
|
publicDisplay: options?.publicDisplay || false,
|
|
2001
1998
|
storeOriginalContent: typeof options?.storeOriginalContent === "boolean" ? options.storeOriginalContent : true
|
|
@@ -2018,16 +2015,6 @@ ${bytes.length}`;
|
|
|
2018
2015
|
}
|
|
2019
2016
|
return this._formatResponse(response);
|
|
2020
2017
|
}
|
|
2021
|
-
/**
|
|
2022
|
-
* Get proof record by proof receipt id.
|
|
2023
|
-
*
|
|
2024
|
-
* @param {string} proofId - Proof receipt ID (0x + 64 hex).
|
|
2025
|
-
* @returns {Promise<Object>} Proof record and verification state
|
|
2026
|
-
*
|
|
2027
|
-
* @example
|
|
2028
|
-
* const result = await client.getProof('0x...');
|
|
2029
|
-
* console.log('Status:', result.status);
|
|
2030
|
-
*/
|
|
2031
2018
|
async getProof(proofId) {
|
|
2032
2019
|
if (!proofId || typeof proofId !== "string") {
|
|
2033
2020
|
throw new ValidationError("proofId is required");
|
|
@@ -2038,16 +2025,6 @@ ${bytes.length}`;
|
|
|
2038
2025
|
}
|
|
2039
2026
|
return this._formatResponse(response);
|
|
2040
2027
|
}
|
|
2041
|
-
/**
|
|
2042
|
-
* Get private proof record with wallet signature
|
|
2043
|
-
*
|
|
2044
|
-
* @param {string} proofId - Proof receipt ID.
|
|
2045
|
-
* @param {Object} wallet - Wallet provider (window.ethereum or ethers Wallet)
|
|
2046
|
-
* @returns {Promise<Object>} Private proof record and verification state
|
|
2047
|
-
*
|
|
2048
|
-
* @example
|
|
2049
|
-
* const privateData = await client.getPrivateProof(proofId, window.ethereum);
|
|
2050
|
-
*/
|
|
2051
2028
|
async getPrivateProof(proofId, wallet = null) {
|
|
2052
2029
|
if (!proofId || typeof proofId !== "string") {
|
|
2053
2030
|
throw new ValidationError("proofId is required");
|
|
@@ -2115,11 +2092,6 @@ ${bytes.length}`;
|
|
|
2115
2092
|
}
|
|
2116
2093
|
return this._formatResponse(response);
|
|
2117
2094
|
}
|
|
2118
|
-
/**
|
|
2119
|
-
* Check API health
|
|
2120
|
-
*
|
|
2121
|
-
* @returns {Promise<boolean>} True if API is healthy
|
|
2122
|
-
*/
|
|
2123
2095
|
async isHealthy() {
|
|
2124
2096
|
try {
|
|
2125
2097
|
const response = await this._makeRequest("GET", "/api/v1/health");
|
|
@@ -2128,19 +2100,10 @@ ${bytes.length}`;
|
|
|
2128
2100
|
return false;
|
|
2129
2101
|
}
|
|
2130
2102
|
}
|
|
2131
|
-
/**
|
|
2132
|
-
* List available verifiers
|
|
2133
|
-
*
|
|
2134
|
-
* @returns {Promise<string[]>} Array of verifier IDs
|
|
2135
|
-
*/
|
|
2136
2103
|
async getVerifiers() {
|
|
2137
2104
|
const catalog = await this.getVerifierCatalog();
|
|
2138
2105
|
return Array.isArray(catalog?.data) ? catalog.data : [];
|
|
2139
2106
|
}
|
|
2140
|
-
/**
|
|
2141
|
-
* Get the public verifier catalog with per-verifier capabilities.
|
|
2142
|
-
* @returns {Promise<{data: string[], metadata: Record<string, { supportsDirectApi?: boolean }>, meta?: object}>}
|
|
2143
|
-
*/
|
|
2144
2107
|
async getVerifierCatalog() {
|
|
2145
2108
|
const response = await this._makeRequest("GET", "/api/v1/verification/verifiers");
|
|
2146
2109
|
if (!response.success) {
|
|
@@ -2152,31 +2115,6 @@ ${bytes.length}`;
|
|
|
2152
2115
|
meta: response.meta && typeof response.meta === "object" && !Array.isArray(response.meta) ? response.meta : {}
|
|
2153
2116
|
};
|
|
2154
2117
|
}
|
|
2155
|
-
/**
|
|
2156
|
-
* POLL PROOF STATUS - Wait for verification completion
|
|
2157
|
-
*
|
|
2158
|
-
* Polls the verification status until it reaches a terminal state (completed or failed).
|
|
2159
|
-
* Useful for providing real-time feedback to users during verification.
|
|
2160
|
-
*
|
|
2161
|
-
* @param {string} proofId - Proof ID to poll.
|
|
2162
|
-
* @param {Object} [options] - Polling options
|
|
2163
|
-
* @param {number} [options.interval=5000] - Polling interval in ms
|
|
2164
|
-
* @param {number} [options.timeout=120000] - Total timeout in ms
|
|
2165
|
-
* @param {Function} [options.onProgress] - Progress callback function
|
|
2166
|
-
* @returns {Promise<Object>} Final verification status
|
|
2167
|
-
*
|
|
2168
|
-
* @example
|
|
2169
|
-
* const finalStatus = await client.pollProofStatus(proofId, {
|
|
2170
|
-
* interval: 3000,
|
|
2171
|
-
* timeout: 60000,
|
|
2172
|
-
* onProgress: (status) => {
|
|
2173
|
-
* console.log('Current status:', status.status);
|
|
2174
|
-
* if (status.crosschain) {
|
|
2175
|
-
* console.log(`Cross-chain: ${status.crosschain.finalized}/${status.crosschain.totalChains}`);
|
|
2176
|
-
* }
|
|
2177
|
-
* }
|
|
2178
|
-
* });
|
|
2179
|
-
*/
|
|
2180
2118
|
async pollProofStatus(proofId, options = {}) {
|
|
2181
2119
|
const {
|
|
2182
2120
|
interval = 5e3,
|
|
@@ -2221,11 +2159,6 @@ ${bytes.length}`;
|
|
|
2221
2159
|
}
|
|
2222
2160
|
throw new NetworkError(`Polling timeout after ${timeout}ms`, "POLLING_TIMEOUT");
|
|
2223
2161
|
}
|
|
2224
|
-
/**
|
|
2225
|
-
* DETECT CHAIN ID - Get current wallet chain
|
|
2226
|
-
*
|
|
2227
|
-
* @returns {Promise<number>} Current chain ID
|
|
2228
|
-
*/
|
|
2229
2162
|
async detectChainId() {
|
|
2230
2163
|
if (typeof window === "undefined" || !window.ethereum) {
|
|
2231
2164
|
throw new ConfigurationError("No Web3 wallet detected");
|
|
@@ -2237,7 +2170,6 @@ ${bytes.length}`;
|
|
|
2237
2170
|
throw new NetworkError(`Failed to detect chain ID: ${error.message}`);
|
|
2238
2171
|
}
|
|
2239
2172
|
}
|
|
2240
|
-
/** Revoke your own proof (owner-signed) */
|
|
2241
2173
|
async revokeOwnProof(proofId, wallet) {
|
|
2242
2174
|
if (!proofId || typeof proofId !== "string") {
|
|
2243
2175
|
throw new ValidationError("proofId is required");
|
|
@@ -2288,22 +2220,6 @@ ${bytes.length}`;
|
|
|
2288
2220
|
}
|
|
2289
2221
|
return true;
|
|
2290
2222
|
}
|
|
2291
|
-
/**
|
|
2292
|
-
* GET PROOFS BY WALLET - Fetch proofs for a wallet address
|
|
2293
|
-
*
|
|
2294
|
-
* @param {string} walletAddress - Wallet identity (EVM/Solana/DID)
|
|
2295
|
-
* @param {Object} [options] - Filter options
|
|
2296
|
-
* @param {number} [options.limit] - Max results (default: 50; higher limits require owner access)
|
|
2297
|
-
* @param {number} [options.offset] - Pagination offset (default: 0)
|
|
2298
|
-
* @param {string} [options.qHash] - Filter to single proof by qHash
|
|
2299
|
-
* @returns {Promise<Object>} Proofs result
|
|
2300
|
-
*
|
|
2301
|
-
* @example
|
|
2302
|
-
* const result = await client.getProofsByWallet('0x...', {
|
|
2303
|
-
* limit: 50,
|
|
2304
|
-
* offset: 0
|
|
2305
|
-
* });
|
|
2306
|
-
*/
|
|
2307
2223
|
async getProofsByWallet(walletAddress, options = {}) {
|
|
2308
2224
|
if (!walletAddress || typeof walletAddress !== "string") {
|
|
2309
2225
|
throw new ValidationError("walletAddress is required");
|
|
@@ -2331,18 +2247,6 @@ ${bytes.length}`;
|
|
|
2331
2247
|
nextOffset: response.data?.nextOffset ?? null
|
|
2332
2248
|
};
|
|
2333
2249
|
}
|
|
2334
|
-
/**
|
|
2335
|
-
* Get proofs by wallet (owner access)
|
|
2336
|
-
*
|
|
2337
|
-
* Signs an owner-access intent and requests private proofs via signature headers.
|
|
2338
|
-
*
|
|
2339
|
-
* @param {string} walletAddress - Wallet identity (EVM/Solana/DID)
|
|
2340
|
-
* @param {Object} [options]
|
|
2341
|
-
* @param {number} [options.limit] - Max results (server enforces caps)
|
|
2342
|
-
* @param {number} [options.offset] - Pagination offset
|
|
2343
|
-
* @param {string} [options.qHash] - Filter to single proof by qHash
|
|
2344
|
-
* @param {Object} [wallet] - Optional injected wallet/provider (MetaMask/ethers Wallet)
|
|
2345
|
-
*/
|
|
2346
2250
|
async getPrivateProofsByWallet(walletAddress, options = {}, wallet = null) {
|
|
2347
2251
|
if (!walletAddress || typeof walletAddress !== "string") {
|
|
2348
2252
|
throw new ValidationError("walletAddress is required");
|
|
@@ -2413,31 +2317,6 @@ ${bytes.length}`;
|
|
|
2413
2317
|
nextOffset: response.data?.nextOffset ?? null
|
|
2414
2318
|
};
|
|
2415
2319
|
}
|
|
2416
|
-
/**
|
|
2417
|
-
* Gate check (HTTP API) — minimal eligibility response.
|
|
2418
|
-
*
|
|
2419
|
-
* Calls the gate endpoint and returns a **minimal** yes/no response.
|
|
2420
|
-
* By default this checks **public + unlisted** proofs.
|
|
2421
|
-
*
|
|
2422
|
-
* When `includePrivate=true`, this can perform owner-signed private checks
|
|
2423
|
-
* (no full proof payloads returned) by providing a wallet/provider.
|
|
2424
|
-
*
|
|
2425
|
-
* Prefer this over `checkGate()` when you need the smallest, most stable
|
|
2426
|
-
* response shape and do not need full proof payloads.
|
|
2427
|
-
*
|
|
2428
|
-
* @param {Object} params - Gate check query params
|
|
2429
|
-
* @param {string} params.address - Wallet identity to check (EVM/Solana/DID)
|
|
2430
|
-
* @param {Array<string>|string} [params.verifierIds] - Verifier IDs to match (array or comma-separated)
|
|
2431
|
-
* @param {boolean} [params.requireAll] - Require all verifierIds on a single proof
|
|
2432
|
-
* @param {number} [params.minCount] - Minimum number of matching proofs
|
|
2433
|
-
* @param {number} [params.sinceDays] - Optional time window in days
|
|
2434
|
-
* @param {number} [params.since] - Optional unix timestamp in ms (lower bound)
|
|
2435
|
-
* @param {number} [params.limit] - Max rows to scan (server may clamp)
|
|
2436
|
-
* @param {boolean} [params.includePrivate] - Include private proofs for owner-authenticated requests
|
|
2437
|
-
* @param {boolean} [params.includeQHashes] - Include matched qHashes in response (minimal IDs only)
|
|
2438
|
-
* @param {Object} [params.wallet] - Optional wallet/provider used to sign includePrivate owner checks
|
|
2439
|
-
* @returns {Promise<Object>} API response ({ success, data })
|
|
2440
|
-
*/
|
|
2441
2320
|
async gateCheck(params = {}) {
|
|
2442
2321
|
const address = (params.address || "").toString();
|
|
2443
2322
|
if (!validateUniversalAddress(address, params.chain)) {
|
|
@@ -2509,8 +2388,7 @@ ${bytes.length}`;
|
|
|
2509
2388
|
});
|
|
2510
2389
|
}
|
|
2511
2390
|
}
|
|
2512
|
-
if (
|
|
2513
|
-
} else {
|
|
2391
|
+
if (auth) {
|
|
2514
2392
|
const normalizedAuthWallet = this._normalizeIdentity(auth.walletAddress);
|
|
2515
2393
|
const normalizedAddress = this._normalizeIdentity(address);
|
|
2516
2394
|
if (!normalizedAuthWallet || normalizedAuthWallet !== normalizedAddress) {
|
|
@@ -2533,45 +2411,6 @@ ${bytes.length}`;
|
|
|
2533
2411
|
}
|
|
2534
2412
|
return response;
|
|
2535
2413
|
}
|
|
2536
|
-
/**
|
|
2537
|
-
* CHECK GATE — Local preview against proofs you already have in memory or from `getProofsByWallet`.
|
|
2538
|
-
*
|
|
2539
|
-
* **Not authoritative for access control.** For production allow/deny, use {@link NeusClient#gateCheck}
|
|
2540
|
-
* (`GET /api/v1/proofs/check`), which applies the same rules as the NEUS API. This method is useful for
|
|
2541
|
-
* UI previews, offline-ish flows, or when you already fetched proofs and want a quick match without
|
|
2542
|
-
* another round trip — but it can disagree with the server (e.g. `contentHash` matching uses a local
|
|
2543
|
-
* approximation when proof data only has inline `content`; the API uses the standard server-side hash).
|
|
2544
|
-
*
|
|
2545
|
-
* Gate-first verification: checks if wallet has valid proofs satisfying requirements.
|
|
2546
|
-
* Returns which requirements are missing/expired.
|
|
2547
|
-
*
|
|
2548
|
-
* @param {Object} params - Gate check parameters
|
|
2549
|
-
* @param {string} params.walletAddress - Target wallet
|
|
2550
|
-
* @param {Array<Object>} params.requirements - Array of gate requirements
|
|
2551
|
-
* @param {string} params.requirements[].verifierId - Required verifier ID
|
|
2552
|
-
* @param {number} [params.requirements[].maxAgeMs] - Max proof age in ms (TTL)
|
|
2553
|
-
* @param {boolean} [params.requirements[].optional] - If true, not required for gate satisfaction
|
|
2554
|
-
* @param {number} [params.requirements[].minCount] - Minimum proofs needed (default: 1)
|
|
2555
|
-
* @param {Object} [params.requirements[].match] - Verifier data match criteria
|
|
2556
|
-
* Supports nested fields: 'reference.type', 'reference.id', 'content', 'contentHash', 'input.*', 'license.*'
|
|
2557
|
-
* Supports verifier-specific:
|
|
2558
|
-
* - NFT/Token: 'contractAddress', 'tokenId', 'chainId', 'ownerAddress', 'minBalance'
|
|
2559
|
-
* - DNS: 'domain', 'walletAddress'
|
|
2560
|
-
* - Wallet-link: 'primaryWalletAddress', 'secondaryWalletAddress', 'chain', 'signatureMethod'
|
|
2561
|
-
* - Contract-ownership: 'contractAddress', 'chainId', 'owner', 'verificationMethod'
|
|
2562
|
-
* Note: contentHash matching uses approximation in SDK; for exact SHA-256 matching, use backend API
|
|
2563
|
-
* @param {Array} [params.proofs] - Pre-fetched proofs (skip API call)
|
|
2564
|
-
* @returns {Promise<Object>} Gate result with satisfied, missing, existing
|
|
2565
|
-
*
|
|
2566
|
-
* @example
|
|
2567
|
-
* // Basic gate check
|
|
2568
|
-
* const result = await client.checkGate({
|
|
2569
|
-
* walletAddress: '0x...',
|
|
2570
|
-
* requirements: [
|
|
2571
|
-
* { verifierId: 'nft-ownership', match: { contractAddress: '0x...' } }
|
|
2572
|
-
* ]
|
|
2573
|
-
* });
|
|
2574
|
-
*/
|
|
2575
2414
|
async checkGate(params) {
|
|
2576
2415
|
const { walletAddress, requirements, proofs: preloadedProofs } = params;
|
|
2577
2416
|
if (!validateUniversalAddress(walletAddress)) {
|
|
@@ -2803,7 +2642,6 @@ ${bytes.length}`;
|
|
|
2803
2642
|
];
|
|
2804
2643
|
return typeof status === "string" && terminalStates.some((state) => status.includes(state));
|
|
2805
2644
|
}
|
|
2806
|
-
/** SDK logging (opt-in via config.enableLogging) */
|
|
2807
2645
|
_log(message, data = {}) {
|
|
2808
2646
|
if (this.config.enableLogging) {
|
|
2809
2647
|
try {
|
|
@@ -2892,36 +2730,16 @@ var DAY = 24 * HOUR;
|
|
|
2892
2730
|
var WEEK = 7 * DAY;
|
|
2893
2731
|
var MONTH = 30 * DAY;
|
|
2894
2732
|
var YEAR = 365 * DAY;
|
|
2895
|
-
var GATE_NFT_HOLDER = [
|
|
2896
|
-
|
|
2897
|
-
];
|
|
2898
|
-
var
|
|
2899
|
-
|
|
2900
|
-
];
|
|
2901
|
-
var
|
|
2902
|
-
|
|
2903
|
-
];
|
|
2904
|
-
var
|
|
2905
|
-
{ verifierId: "ownership-dns-txt" }
|
|
2906
|
-
];
|
|
2907
|
-
var GATE_LINKED_WALLETS = [
|
|
2908
|
-
{ verifierId: "wallet-link" }
|
|
2909
|
-
];
|
|
2910
|
-
var GATE_AGENT_IDENTITY = [
|
|
2911
|
-
{ verifierId: "agent-identity" }
|
|
2912
|
-
];
|
|
2913
|
-
var GATE_AGENT_DELEGATION = [
|
|
2914
|
-
{ verifierId: "agent-delegation", maxAgeMs: 7 * DAY }
|
|
2915
|
-
];
|
|
2916
|
-
var GATE_CONTENT_MODERATION = [
|
|
2917
|
-
{ verifierId: "ai-content-moderation" }
|
|
2918
|
-
];
|
|
2919
|
-
var GATE_WALLET_RISK = [
|
|
2920
|
-
{ verifierId: "wallet-risk" }
|
|
2921
|
-
];
|
|
2922
|
-
var GATE_PSEUDONYM = [
|
|
2923
|
-
{ verifierId: "ownership-pseudonym" }
|
|
2924
|
-
];
|
|
2733
|
+
var GATE_NFT_HOLDER = [{ verifierId: "nft-ownership" }];
|
|
2734
|
+
var GATE_TOKEN_HOLDER = [{ verifierId: "token-holding" }];
|
|
2735
|
+
var GATE_CONTRACT_ADMIN = [{ verifierId: "contract-ownership", maxAgeMs: HOUR }];
|
|
2736
|
+
var GATE_DOMAIN_OWNER = [{ verifierId: "ownership-dns-txt" }];
|
|
2737
|
+
var GATE_LINKED_WALLETS = [{ verifierId: "wallet-link" }];
|
|
2738
|
+
var GATE_AGENT_IDENTITY = [{ verifierId: "agent-identity" }];
|
|
2739
|
+
var GATE_AGENT_DELEGATION = [{ verifierId: "agent-delegation", maxAgeMs: 7 * DAY }];
|
|
2740
|
+
var GATE_CONTENT_MODERATION = [{ verifierId: "ai-content-moderation" }];
|
|
2741
|
+
var GATE_WALLET_RISK = [{ verifierId: "wallet-risk" }];
|
|
2742
|
+
var GATE_PSEUDONYM = [{ verifierId: "ownership-pseudonym" }];
|
|
2925
2743
|
function createGate(requirements) {
|
|
2926
2744
|
return requirements.map((req) => {
|
|
2927
2745
|
if (typeof req === "string") {
|
package/cjs/utils.cjs
CHANGED
|
@@ -287,7 +287,6 @@ function createVerificationData(content, owner, reference = null) {
|
|
|
287
287
|
content,
|
|
288
288
|
owner: validateWalletAddress(owner) ? owner.toLowerCase() : owner,
|
|
289
289
|
reference: reference || {
|
|
290
|
-
// Must be a valid backend enum value; 'content' is not supported.
|
|
291
290
|
type: "other",
|
|
292
291
|
id: stableRefId(content)
|
|
293
292
|
}
|
|
@@ -761,9 +760,7 @@ var StatusPoller = class {
|
|
|
761
760
|
}
|
|
762
761
|
};
|
|
763
762
|
var NEUS_CONSTANTS = {
|
|
764
|
-
/** Default EVM chain id for NEUS protocol signing context (`HUB_CHAIN_ID` name kept for compatibility). */
|
|
765
763
|
HUB_CHAIN_ID: 84532,
|
|
766
|
-
// Supported target chains for cross-chain propagation
|
|
767
764
|
TESTNET_CHAINS: [
|
|
768
765
|
11155111,
|
|
769
766
|
// Ethereum Sepolia
|
|
@@ -774,15 +771,12 @@ var NEUS_CONSTANTS = {
|
|
|
774
771
|
80002
|
|
775
772
|
// Polygon Amoy
|
|
776
773
|
],
|
|
777
|
-
// API endpoints
|
|
778
774
|
API_BASE_URL: "https://api.neus.network",
|
|
779
775
|
API_VERSION: "v1",
|
|
780
|
-
// Timeouts and limits
|
|
781
776
|
SIGNATURE_MAX_AGE_MS: 5 * 60 * 1e3,
|
|
782
777
|
// 5 minutes
|
|
783
778
|
REQUEST_TIMEOUT_MS: 30 * 1e3,
|
|
784
779
|
// 30 seconds
|
|
785
|
-
// Default verifier set for quick starts
|
|
786
780
|
DEFAULT_VERIFIERS: [
|
|
787
781
|
"ownership-basic",
|
|
788
782
|
"nft-ownership",
|