@neus/sdk 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -150
- package/SECURITY.md +33 -29
- package/cjs/client.cjs +235 -264
- package/cjs/index.cjs +330 -310
- package/cjs/utils.cjs +138 -97
- package/cli/neus.mjs +58 -0
- package/client.js +464 -457
- package/errors.js +5 -5
- package/gates.js +18 -18
- package/index.js +79 -75
- package/package.json +16 -10
- package/types.d.ts +124 -59
- package/utils.js +1291 -1180
- package/widgets/README.md +45 -64
- package/widgets/index.js +1 -1
- package/widgets/verify-gate/dist/ProofBadge.js +10 -18
- package/widgets/verify-gate/dist/VerifyGate.js +108 -97
- package/widgets/verify-gate/index.js +5 -5
package/errors.js
CHANGED
|
@@ -12,7 +12,7 @@ export class SDKError extends Error {
|
|
|
12
12
|
this.code = code;
|
|
13
13
|
this.details = details;
|
|
14
14
|
this.timestamp = Date.now();
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
// Ensure proper prototype chain
|
|
17
17
|
if (Error.captureStackTrace) {
|
|
18
18
|
Error.captureStackTrace(this, SDKError);
|
|
@@ -39,7 +39,7 @@ export class ApiError extends SDKError {
|
|
|
39
39
|
this.name = 'ApiError';
|
|
40
40
|
this.statusCode = statusCode;
|
|
41
41
|
this.response = response;
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
// Additional classification
|
|
44
44
|
this.isClientError = statusCode >= 400 && statusCode < 500;
|
|
45
45
|
this.isServerError = statusCode >= 500;
|
|
@@ -48,11 +48,11 @@ export class ApiError extends SDKError {
|
|
|
48
48
|
|
|
49
49
|
static fromResponse(response, responseData) {
|
|
50
50
|
const statusCode = response.status;
|
|
51
|
-
const message = responseData?.error?.message ||
|
|
52
|
-
responseData?.message ||
|
|
51
|
+
const message = responseData?.error?.message ||
|
|
52
|
+
responseData?.message ||
|
|
53
53
|
`API request failed with status ${statusCode}`;
|
|
54
54
|
const code = responseData?.error?.code || 'API_ERROR';
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
return new ApiError(message, statusCode, code, responseData);
|
|
57
57
|
}
|
|
58
58
|
|
package/gates.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NEUS SDK Gate Recipes
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* These are EXAMPLES, not defaults.
|
|
5
5
|
* Pick or copy-paste what fits your use case.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* @license Apache-2.0
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -23,7 +23,7 @@ export const YEAR = 365 * DAY;
|
|
|
23
23
|
* Integrator should add match: { contractAddress: '0x...' } when using
|
|
24
24
|
*/
|
|
25
25
|
export const GATE_NFT_HOLDER = [
|
|
26
|
-
{ verifierId: 'nft-ownership' }
|
|
26
|
+
{ verifierId: 'nft-ownership' }
|
|
27
27
|
];
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -31,7 +31,7 @@ export const GATE_NFT_HOLDER = [
|
|
|
31
31
|
* Integrator should add match: { contractAddress: '0x...', minBalance: '...' }
|
|
32
32
|
*/
|
|
33
33
|
export const GATE_TOKEN_HOLDER = [
|
|
34
|
-
{ verifierId: 'token-holding' }
|
|
34
|
+
{ verifierId: 'token-holding' }
|
|
35
35
|
];
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -39,7 +39,7 @@ export const GATE_TOKEN_HOLDER = [
|
|
|
39
39
|
* Short TTL (1h) because ownership can transfer (point-in-time proof)
|
|
40
40
|
*/
|
|
41
41
|
export const GATE_CONTRACT_ADMIN = [
|
|
42
|
-
{ verifierId: 'contract-ownership', maxAgeMs: HOUR }
|
|
42
|
+
{ verifierId: 'contract-ownership', maxAgeMs: HOUR }
|
|
43
43
|
];
|
|
44
44
|
|
|
45
45
|
/**
|
|
@@ -47,7 +47,7 @@ export const GATE_CONTRACT_ADMIN = [
|
|
|
47
47
|
* For verified organization badges, creator platforms
|
|
48
48
|
*/
|
|
49
49
|
export const GATE_DOMAIN_OWNER = [
|
|
50
|
-
{ verifierId: 'ownership-dns-txt' }
|
|
50
|
+
{ verifierId: 'ownership-dns-txt' }
|
|
51
51
|
];
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -55,7 +55,7 @@ export const GATE_DOMAIN_OWNER = [
|
|
|
55
55
|
* For multi-wallet identity features
|
|
56
56
|
*/
|
|
57
57
|
export const GATE_LINKED_WALLETS = [
|
|
58
|
-
{ verifierId: 'wallet-link' }
|
|
58
|
+
{ verifierId: 'wallet-link' }
|
|
59
59
|
];
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -63,7 +63,7 @@ export const GATE_LINKED_WALLETS = [
|
|
|
63
63
|
* For agent/bot verification features
|
|
64
64
|
*/
|
|
65
65
|
export const GATE_AGENT_IDENTITY = [
|
|
66
|
-
{ verifierId: 'agent-identity' }
|
|
66
|
+
{ verifierId: 'agent-identity' }
|
|
67
67
|
];
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -71,7 +71,7 @@ export const GATE_AGENT_IDENTITY = [
|
|
|
71
71
|
* With recommended 7-day TTL for security
|
|
72
72
|
*/
|
|
73
73
|
export const GATE_AGENT_DELEGATION = [
|
|
74
|
-
{ verifierId: 'agent-delegation', maxAgeMs: 7 * DAY }
|
|
74
|
+
{ verifierId: 'agent-delegation', maxAgeMs: 7 * DAY }
|
|
75
75
|
];
|
|
76
76
|
|
|
77
77
|
/**
|
|
@@ -79,7 +79,7 @@ export const GATE_AGENT_DELEGATION = [
|
|
|
79
79
|
* Proof is permanent (policy snapshot); re-run only if your policy/provider requirements change.
|
|
80
80
|
*/
|
|
81
81
|
export const GATE_CONTENT_MODERATION = [
|
|
82
|
-
{ verifierId: 'ai-content-moderation' }
|
|
82
|
+
{ verifierId: 'ai-content-moderation' }
|
|
83
83
|
];
|
|
84
84
|
|
|
85
85
|
/**
|
|
@@ -87,7 +87,7 @@ export const GATE_CONTENT_MODERATION = [
|
|
|
87
87
|
* Provider-backed risk signal
|
|
88
88
|
*/
|
|
89
89
|
export const GATE_WALLET_RISK = [
|
|
90
|
-
{ verifierId: 'wallet-risk' }
|
|
90
|
+
{ verifierId: 'wallet-risk' }
|
|
91
91
|
];
|
|
92
92
|
|
|
93
93
|
/**
|
|
@@ -95,7 +95,7 @@ export const GATE_WALLET_RISK = [
|
|
|
95
95
|
* For anonymous reputation systems
|
|
96
96
|
*/
|
|
97
97
|
export const GATE_PSEUDONYM = [
|
|
98
|
-
{ verifierId: 'ownership-pseudonym' }
|
|
98
|
+
{ verifierId: 'ownership-pseudonym' }
|
|
99
99
|
];
|
|
100
100
|
|
|
101
101
|
// ============================================================================
|
|
@@ -106,11 +106,11 @@ export const GATE_PSEUDONYM = [
|
|
|
106
106
|
* Create a custom gate from verifier IDs
|
|
107
107
|
* @param {Array<string|Object>} requirements - Array of verifier IDs or requirement objects
|
|
108
108
|
* @returns {Array} Gate requirements array
|
|
109
|
-
*
|
|
109
|
+
*
|
|
110
110
|
* @example
|
|
111
111
|
* // Simple: just verifier IDs
|
|
112
112
|
* const gate = createGate(['nft-ownership', 'token-holding']);
|
|
113
|
-
*
|
|
113
|
+
*
|
|
114
114
|
* // With options
|
|
115
115
|
* const gate = createGate([
|
|
116
116
|
* { verifierId: 'nft-ownership', match: { contractAddress: '0x...' } },
|
|
@@ -130,14 +130,14 @@ export function createGate(requirements) {
|
|
|
130
130
|
* Combine multiple gates (union of requirements)
|
|
131
131
|
* @param {...Array} gates - Gate arrays to combine
|
|
132
132
|
* @returns {Array} Combined gate requirements
|
|
133
|
-
*
|
|
133
|
+
*
|
|
134
134
|
* @example
|
|
135
135
|
* const strictGate = combineGates(GATE_NFT_HOLDER, GATE_TOKEN_HOLDER);
|
|
136
136
|
*/
|
|
137
137
|
export function combineGates(...gates) {
|
|
138
138
|
const combined = [];
|
|
139
139
|
const seen = new Set();
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
for (const gate of gates) {
|
|
142
142
|
for (const req of gate) {
|
|
143
143
|
const key = req.verifierId + JSON.stringify(req.match || {});
|
|
@@ -147,7 +147,7 @@ export function combineGates(...gates) {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
return combined;
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -171,5 +171,5 @@ export default {
|
|
|
171
171
|
GATE_PSEUDONYM,
|
|
172
172
|
// Helpers
|
|
173
173
|
createGate,
|
|
174
|
-
combineGates
|
|
174
|
+
combineGates
|
|
175
175
|
};
|
package/index.js
CHANGED
|
@@ -1,76 +1,80 @@
|
|
|
1
|
-
// NEUS SDK - Create and verify cryptographic proofs
|
|
2
|
-
|
|
3
|
-
// Core client
|
|
4
|
-
export { NeusClient } from './client.js';
|
|
5
|
-
|
|
6
|
-
// Essential utilities
|
|
7
|
-
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
// NEUS SDK - Create and verify cryptographic proofs
|
|
2
|
+
|
|
3
|
+
// Core client
|
|
4
|
+
export { NeusClient } from './client.js';
|
|
5
|
+
|
|
6
|
+
// Essential utilities
|
|
7
|
+
export {
|
|
8
|
+
PORTABLE_PROOF_SIGNER_HEADER,
|
|
9
|
+
constructVerificationMessage,
|
|
10
|
+
validateWalletAddress,
|
|
11
|
+
validateUniversalAddress,
|
|
12
|
+
validateTimestamp,
|
|
13
|
+
validateQHash,
|
|
14
|
+
normalizeAddress,
|
|
15
|
+
isTerminalStatus,
|
|
16
|
+
isSuccessStatus,
|
|
17
|
+
isFailureStatus,
|
|
18
|
+
formatVerificationStatus,
|
|
19
|
+
formatTimestamp,
|
|
20
|
+
isSupportedChain,
|
|
21
|
+
StatusPoller,
|
|
22
|
+
computeContentHash,
|
|
23
|
+
deriveDid,
|
|
24
|
+
toHexUtf8,
|
|
25
|
+
resolveDID,
|
|
26
|
+
signMessage,
|
|
27
|
+
standardizeVerificationRequest,
|
|
28
|
+
resolveZkPassportConfig,
|
|
29
|
+
validateVerifierPayload,
|
|
30
|
+
buildVerificationRequest,
|
|
31
|
+
createVerificationData,
|
|
32
|
+
validateSignatureComponents,
|
|
33
|
+
withRetry,
|
|
34
|
+
delay,
|
|
35
|
+
NEUS_CONSTANTS,
|
|
36
|
+
DEFAULT_HOSTED_VERIFY_URL,
|
|
37
|
+
getHostedCheckoutUrl,
|
|
38
|
+
toAgentDelegationMaxSpend
|
|
39
|
+
} from './utils.js';
|
|
40
|
+
|
|
41
|
+
// Example gate presets (choose per product; not defaults)
|
|
42
|
+
export {
|
|
43
|
+
// Time constants
|
|
44
|
+
HOUR,
|
|
45
|
+
DAY,
|
|
46
|
+
WEEK,
|
|
47
|
+
MONTH,
|
|
48
|
+
YEAR,
|
|
49
|
+
// Recipe gates
|
|
50
|
+
GATE_NFT_HOLDER,
|
|
51
|
+
GATE_TOKEN_HOLDER,
|
|
52
|
+
GATE_CONTRACT_ADMIN,
|
|
53
|
+
GATE_DOMAIN_OWNER,
|
|
54
|
+
GATE_LINKED_WALLETS,
|
|
55
|
+
GATE_AGENT_IDENTITY,
|
|
56
|
+
GATE_AGENT_DELEGATION,
|
|
57
|
+
GATE_CONTENT_MODERATION,
|
|
58
|
+
GATE_WALLET_RISK,
|
|
59
|
+
GATE_PSEUDONYM,
|
|
60
|
+
// Helpers
|
|
61
|
+
createGate,
|
|
62
|
+
combineGates
|
|
63
|
+
} from './gates.js';
|
|
64
|
+
|
|
65
|
+
// Error classes
|
|
66
|
+
export {
|
|
67
|
+
SDKError,
|
|
68
|
+
ApiError,
|
|
69
|
+
ValidationError,
|
|
70
|
+
NetworkError,
|
|
71
|
+
ConfigurationError,
|
|
72
|
+
VerificationError,
|
|
73
|
+
AuthenticationError
|
|
74
|
+
} from './errors.js';
|
|
75
|
+
|
|
76
|
+
// Default export
|
|
77
|
+
export default {
|
|
78
|
+
NeusClient: () => import('./client.js').then(m => m.NeusClient),
|
|
79
|
+
toString: () => '[neus/sdk]'
|
|
76
80
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neus/sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Portable trust for people, apps, and agents. Store a proof ID; check gates across surfaces.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"neus": "./cli/neus.mjs"
|
|
7
|
+
},
|
|
5
8
|
"main": "index.js",
|
|
6
9
|
"type": "module",
|
|
7
10
|
"types": "types.d.ts",
|
|
@@ -46,8 +49,8 @@
|
|
|
46
49
|
"lint": "eslint . --ignore-pattern widgets/verify-gate/dist/**",
|
|
47
50
|
"format": "prettier --write \"**/*.js\"",
|
|
48
51
|
"build": "npm run build:widgets && npm run build:cjs",
|
|
49
|
-
"build:widgets": "esbuild widgets/verify-gate/VerifyGate.jsx widgets/verify-gate/ProofBadge.jsx --bundle --platform=browser --format=esm --outdir=widgets/verify-gate/dist --jsx=automatic --legal-comments=none --loader:.svg=dataurl --external:react --external:react-dom --external:react/jsx-runtime --external:@neus/sdk/client",
|
|
50
|
-
"build:cjs": "esbuild index.js client.js utils.js errors.js gates.js --bundle --platform=node --format=cjs --outdir=cjs --out-extension:.js=.cjs --legal-comments=none --external:ethers --external:@zkpassport/sdk --external:react --external:react-dom --external:react/jsx-runtime",
|
|
52
|
+
"build:widgets": "npx esbuild widgets/verify-gate/VerifyGate.jsx widgets/verify-gate/ProofBadge.jsx --bundle --platform=browser --format=esm --outdir=widgets/verify-gate/dist --jsx=automatic --legal-comments=none --loader:.svg=dataurl --external:react --external:react-dom --external:react/jsx-runtime --external:@neus/sdk/client",
|
|
53
|
+
"build:cjs": "npx esbuild index.js client.js utils.js errors.js gates.js --bundle --platform=node --format=cjs --outdir=cjs --out-extension:.js=.cjs --legal-comments=none --external:ethers --external:@zkpassport/sdk --external:react --external:react-dom --external:react/jsx-runtime",
|
|
51
54
|
"prepack": "npm run build",
|
|
52
55
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
53
56
|
},
|
|
@@ -78,9 +81,10 @@
|
|
|
78
81
|
},
|
|
79
82
|
"homepage": "https://neus.network",
|
|
80
83
|
"engines": {
|
|
81
|
-
"node": ">=
|
|
84
|
+
"node": ">=20.0.0"
|
|
82
85
|
},
|
|
83
86
|
"peerDependencies": {
|
|
87
|
+
"@zkpassport/sdk": "0.12.5",
|
|
84
88
|
"ethers": "^6.0.0",
|
|
85
89
|
"react": ">=17.0.0",
|
|
86
90
|
"react-dom": ">=17.0.0"
|
|
@@ -97,19 +101,20 @@
|
|
|
97
101
|
}
|
|
98
102
|
},
|
|
99
103
|
"optionalDependencies": {
|
|
100
|
-
"@zkpassport/sdk": "
|
|
104
|
+
"@zkpassport/sdk": "0.12.5"
|
|
101
105
|
},
|
|
102
106
|
"dependencies": {
|
|
103
107
|
"bs58": "^6.0.0"
|
|
104
108
|
},
|
|
105
109
|
"devDependencies": {
|
|
106
|
-
"@vitest/coverage-v8": "^1.
|
|
107
|
-
"esbuild": "^0.
|
|
110
|
+
"@vitest/coverage-v8": "^4.1.3",
|
|
111
|
+
"esbuild": "^0.28.0",
|
|
108
112
|
"eslint": "^8.56.0",
|
|
109
113
|
"prettier": "^3.2.0",
|
|
110
|
-
"vitest": "^1.
|
|
114
|
+
"vitest": "^4.1.3"
|
|
111
115
|
},
|
|
112
116
|
"files": [
|
|
117
|
+
"cli/neus.mjs",
|
|
113
118
|
"index.js",
|
|
114
119
|
"client.js",
|
|
115
120
|
"utils.js",
|
|
@@ -124,6 +129,7 @@
|
|
|
124
129
|
"neus-logo.svg",
|
|
125
130
|
"widgets/index.js",
|
|
126
131
|
"widgets/verify-gate/index.js",
|
|
127
|
-
"widgets/verify-gate/dist
|
|
132
|
+
"widgets/verify-gate/dist/VerifyGate.js",
|
|
133
|
+
"widgets/verify-gate/dist/ProofBadge.js"
|
|
128
134
|
]
|
|
129
135
|
}
|