@neus/sdk 1.0.2 → 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 +53 -75
- package/SECURITY.md +33 -29
- package/cjs/client.cjs +678 -337
- package/cjs/errors.cjs +1 -0
- package/cjs/gates.cjs +1 -0
- package/cjs/index.cjs +927 -362
- package/cjs/utils.cjs +408 -32
- package/cli/neus.mjs +58 -0
- package/client.js +1957 -1728
- package/errors.js +5 -5
- package/gates.js +18 -18
- package/index.js +18 -3
- package/neus-logo.svg +3 -0
- package/package.json +21 -11
- package/types.d.ts +303 -53
- package/utils.js +1291 -777
- package/widgets/README.md +12 -20
- package/widgets/index.js +9 -9
- package/widgets/verify-gate/dist/ProofBadge.js +57 -52
- package/widgets/verify-gate/dist/VerifyGate.js +357 -121
- package/widgets/verify-gate/index.js +13 -13
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
|
@@ -5,8 +5,10 @@ export { NeusClient } from './client.js';
|
|
|
5
5
|
|
|
6
6
|
// Essential utilities
|
|
7
7
|
export {
|
|
8
|
+
PORTABLE_PROOF_SIGNER_HEADER,
|
|
8
9
|
constructVerificationMessage,
|
|
9
10
|
validateWalletAddress,
|
|
11
|
+
validateUniversalAddress,
|
|
10
12
|
validateTimestamp,
|
|
11
13
|
validateQHash,
|
|
12
14
|
normalizeAddress,
|
|
@@ -19,16 +21,24 @@ export {
|
|
|
19
21
|
StatusPoller,
|
|
20
22
|
computeContentHash,
|
|
21
23
|
deriveDid,
|
|
24
|
+
toHexUtf8,
|
|
25
|
+
resolveDID,
|
|
26
|
+
signMessage,
|
|
27
|
+
standardizeVerificationRequest,
|
|
28
|
+
resolveZkPassportConfig,
|
|
22
29
|
validateVerifierPayload,
|
|
23
30
|
buildVerificationRequest,
|
|
24
31
|
createVerificationData,
|
|
25
32
|
validateSignatureComponents,
|
|
26
33
|
withRetry,
|
|
27
34
|
delay,
|
|
28
|
-
NEUS_CONSTANTS
|
|
35
|
+
NEUS_CONSTANTS,
|
|
36
|
+
DEFAULT_HOSTED_VERIFY_URL,
|
|
37
|
+
getHostedCheckoutUrl,
|
|
38
|
+
toAgentDelegationMaxSpend
|
|
29
39
|
} from './utils.js';
|
|
30
40
|
|
|
31
|
-
//
|
|
41
|
+
// Example gate presets (choose per product; not defaults)
|
|
32
42
|
export {
|
|
33
43
|
// Time constants
|
|
34
44
|
HOUR,
|
|
@@ -42,9 +52,14 @@ export {
|
|
|
42
52
|
GATE_CONTRACT_ADMIN,
|
|
43
53
|
GATE_DOMAIN_OWNER,
|
|
44
54
|
GATE_LINKED_WALLETS,
|
|
55
|
+
GATE_AGENT_IDENTITY,
|
|
56
|
+
GATE_AGENT_DELEGATION,
|
|
57
|
+
GATE_CONTENT_MODERATION,
|
|
58
|
+
GATE_WALLET_RISK,
|
|
59
|
+
GATE_PSEUDONYM,
|
|
45
60
|
// Helpers
|
|
46
61
|
createGate,
|
|
47
|
-
combineGates
|
|
62
|
+
combineGates
|
|
48
63
|
} from './gates.js';
|
|
49
64
|
|
|
50
65
|
// Error classes
|