@neus/sdk 1.0.10 → 1.1.0
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/CHANGELOG.md +3 -0
- package/README.md +55 -26
- package/SECURITY.md +1 -1
- package/cjs/client.cjs +117 -27
- package/cjs/index.cjs +117 -27
- package/cli/neus.mjs +1288 -92
- package/client.js +139 -26
- package/errors.js +1 -1
- package/package.json +11 -3
- package/types.d.ts +79 -14
- package/widgets/README.md +1 -1
- package/widgets/verify-gate/dist/ProofBadge.js +8 -16
- package/widgets/verify-gate/dist/VerifyGate.js +17 -19
package/client.js
CHANGED
|
@@ -48,6 +48,13 @@ function normalizeBrowserSignerString(raw) {
|
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/** Treats SDK placeholder signatures as absent so the protocol can use session or app-link delegation. */
|
|
52
|
+
function isPlaceholderNeusSignature(signature) {
|
|
53
|
+
const s = typeof signature === 'string' ? signature.trim() : '';
|
|
54
|
+
if (!s) return true;
|
|
55
|
+
return /^0x0+$/i.test(s);
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
const validateVerifierData = (verifierId, data) => {
|
|
52
59
|
if (!data || typeof data !== 'object') {
|
|
53
60
|
return { valid: false, error: 'Data object is required' };
|
|
@@ -232,6 +239,17 @@ const validateVerifierData = (verifierId, data) => {
|
|
|
232
239
|
if (data.agentType && !['ai', 'bot', 'service', 'automation', 'agent'].includes(data.agentType)) {
|
|
233
240
|
return { valid: false, error: 'agentType must be one of: ai, bot, service, automation, agent' };
|
|
234
241
|
}
|
|
242
|
+
if (data.defaultRuntime && typeof data.defaultRuntime === 'object') {
|
|
243
|
+
if (data.defaultRuntime.provider && typeof data.defaultRuntime.provider === 'string' && data.defaultRuntime.provider.length > 64) {
|
|
244
|
+
return { valid: false, error: 'defaultRuntime.provider must be 64 chars or less' };
|
|
245
|
+
}
|
|
246
|
+
if (data.defaultRuntime.model && typeof data.defaultRuntime.model === 'string' && data.defaultRuntime.model.length > 128) {
|
|
247
|
+
return { valid: false, error: 'defaultRuntime.model must be 128 chars or less' };
|
|
248
|
+
}
|
|
249
|
+
if (data.defaultRuntime.mode && typeof data.defaultRuntime.mode === 'string' && data.defaultRuntime.mode.length > 64) {
|
|
250
|
+
return { valid: false, error: 'defaultRuntime.mode must be 64 chars or less' };
|
|
251
|
+
}
|
|
252
|
+
}
|
|
235
253
|
break;
|
|
236
254
|
case 'agent-delegation':
|
|
237
255
|
if (!data.controllerWallet || !validateWalletAddress(data.controllerWallet)) {
|
|
@@ -246,6 +264,18 @@ const validateVerifierData = (verifierId, data) => {
|
|
|
246
264
|
if (data.expiresAt && (typeof data.expiresAt !== 'number' || data.expiresAt < Date.now())) {
|
|
247
265
|
return { valid: false, error: 'expiresAt must be a future timestamp' };
|
|
248
266
|
}
|
|
267
|
+
if (data.model && typeof data.model === 'string' && data.model.length > 128) {
|
|
268
|
+
return { valid: false, error: 'model must be 128 chars or less' };
|
|
269
|
+
}
|
|
270
|
+
if (data.provider && typeof data.provider === 'string' && data.provider.length > 64) {
|
|
271
|
+
return { valid: false, error: 'provider must be 64 chars or less' };
|
|
272
|
+
}
|
|
273
|
+
if (data.allowedActions && Array.isArray(data.allowedActions) && data.allowedActions.length > 32) {
|
|
274
|
+
return { valid: false, error: 'allowedActions must have 32 items or less' };
|
|
275
|
+
}
|
|
276
|
+
if (data.deniedActions && Array.isArray(data.deniedActions) && data.deniedActions.length > 32) {
|
|
277
|
+
return { valid: false, error: 'deniedActions must have 32 items or less' };
|
|
278
|
+
}
|
|
249
279
|
break;
|
|
250
280
|
case 'ai-content-moderation':
|
|
251
281
|
if (!data.content || typeof data.content !== 'string') {
|
|
@@ -452,7 +482,9 @@ export class NeusClient {
|
|
|
452
482
|
|
|
453
483
|
_getDefaultBrowserWallet() {
|
|
454
484
|
if (typeof window === 'undefined') return null;
|
|
455
|
-
|
|
485
|
+
// Legacy convenience fallback only. Non-EVM wallets must be passed explicitly
|
|
486
|
+
// with CAIP-2 chain context so the SDK does not route them through EVM RPC.
|
|
487
|
+
return window.ethereum || null;
|
|
456
488
|
}
|
|
457
489
|
|
|
458
490
|
async _buildPrivateGateAuth({ address, wallet, chain, signatureMethod } = {}) {
|
|
@@ -595,8 +627,74 @@ export class NeusClient {
|
|
|
595
627
|
};
|
|
596
628
|
}
|
|
597
629
|
|
|
630
|
+
async verifyFromApp(params) {
|
|
631
|
+
if (!params || typeof params !== 'object') {
|
|
632
|
+
throw new ValidationError('verifyFromApp requires a params object');
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
const {
|
|
636
|
+
user,
|
|
637
|
+
verifier = 'ownership-basic',
|
|
638
|
+
content,
|
|
639
|
+
data: explicitData = null,
|
|
640
|
+
options = {}
|
|
641
|
+
} = params;
|
|
642
|
+
|
|
643
|
+
if (!user || typeof user !== 'object') {
|
|
644
|
+
throw new ValidationError('verifyFromApp requires user object');
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
const walletAddress =
|
|
648
|
+
user.walletAddress ||
|
|
649
|
+
user.address ||
|
|
650
|
+
user.identity;
|
|
651
|
+
if (!walletAddress || typeof walletAddress !== 'string') {
|
|
652
|
+
throw new ValidationError('verifyFromApp requires user.walletAddress');
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const delegationQHash =
|
|
656
|
+
this.config.appLinkQHash ||
|
|
657
|
+
(typeof process !== 'undefined' && process.env && process.env.NEUS_APP_LINK_QHASH) ||
|
|
658
|
+
null;
|
|
659
|
+
|
|
660
|
+
let data;
|
|
661
|
+
if (explicitData && typeof explicitData === 'object') {
|
|
662
|
+
data = { owner: walletAddress, ...explicitData };
|
|
663
|
+
} else if (content && typeof content === 'object') {
|
|
664
|
+
data = {
|
|
665
|
+
owner: walletAddress,
|
|
666
|
+
content: JSON.stringify(content),
|
|
667
|
+
contentType: typeof content.contentType === 'string' ? content.contentType : 'application/json',
|
|
668
|
+
reference: content.reference || { type: 'other' }
|
|
669
|
+
};
|
|
670
|
+
} else if (typeof content === 'string') {
|
|
671
|
+
data = {
|
|
672
|
+
owner: walletAddress,
|
|
673
|
+
content,
|
|
674
|
+
reference: { type: 'other' }
|
|
675
|
+
};
|
|
676
|
+
} else {
|
|
677
|
+
data = { owner: walletAddress, reference: { type: 'other' } };
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
const signedTimestamp = Date.now();
|
|
681
|
+
const verifierIds = [verifier];
|
|
682
|
+
|
|
683
|
+
return this.verify({
|
|
684
|
+
verifierIds,
|
|
685
|
+
data,
|
|
686
|
+
walletAddress,
|
|
687
|
+
signedTimestamp,
|
|
688
|
+
...(delegationQHash ? { delegationQHash } : {}),
|
|
689
|
+
options
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
|
|
598
693
|
async verify(params) {
|
|
599
|
-
if (
|
|
694
|
+
if (
|
|
695
|
+
(isPlaceholderNeusSignature(params?.signature) || !params?.signature || !params?.walletAddress) &&
|
|
696
|
+
(params?.verifier || params?.content || params?.data)
|
|
697
|
+
) {
|
|
600
698
|
const { content, verifier = 'ownership-basic', data = null, wallet = null, options = {} } = params;
|
|
601
699
|
|
|
602
700
|
if (verifier === 'ownership-basic' && !data && (!content || typeof content !== 'string')) {
|
|
@@ -659,7 +757,7 @@ export class NeusClient {
|
|
|
659
757
|
}
|
|
660
758
|
} else {
|
|
661
759
|
if (typeof window === 'undefined' || !window.ethereum) {
|
|
662
|
-
throw new ConfigurationError('No
|
|
760
|
+
throw new ConfigurationError('No EVM browser wallet detected. Provide wallet explicitly for non-EVM flows and include chain as a CAIP-2 value.');
|
|
663
761
|
}
|
|
664
762
|
await window.ethereum.request({ method: 'eth_requestAccounts' });
|
|
665
763
|
provider = window.ethereum;
|
|
@@ -777,9 +875,13 @@ export class NeusClient {
|
|
|
777
875
|
verificationData = {
|
|
778
876
|
agentId: data.agentId,
|
|
779
877
|
agentWallet: data?.agentWallet || walletAddress,
|
|
878
|
+
...(data?.agentChainRef && { agentChainRef: data.agentChainRef }),
|
|
879
|
+
...(data?.agentAccountId && { agentAccountId: data.agentAccountId }),
|
|
780
880
|
...(data?.agentLabel && { agentLabel: data.agentLabel }),
|
|
781
881
|
...(data?.agentType && { agentType: data.agentType }),
|
|
882
|
+
...(data?.avatar && { avatar: data.avatar }),
|
|
782
883
|
...(data?.description && { description: data.description }),
|
|
884
|
+
...(data?.defaultRuntime && { defaultRuntime: data.defaultRuntime }),
|
|
783
885
|
...(data?.capabilities && { capabilities: data.capabilities }),
|
|
784
886
|
...(data?.instructions && { instructions: data.instructions }),
|
|
785
887
|
...(data?.skills && { skills: data.skills }),
|
|
@@ -791,7 +893,11 @@ export class NeusClient {
|
|
|
791
893
|
}
|
|
792
894
|
verificationData = {
|
|
793
895
|
controllerWallet: data?.controllerWallet || walletAddress,
|
|
896
|
+
...(data?.controllerChainRef && { controllerChainRef: data.controllerChainRef }),
|
|
794
897
|
agentWallet: data.agentWallet,
|
|
898
|
+
...(data?.agentChainRef && { agentChainRef: data.agentChainRef }),
|
|
899
|
+
...(data?.controllerAccountId && { controllerAccountId: data.controllerAccountId }),
|
|
900
|
+
...(data?.agentAccountId && { agentAccountId: data.agentAccountId }),
|
|
795
901
|
...(data?.agentId && { agentId: data.agentId }),
|
|
796
902
|
...(data?.scope && { scope: data.scope }),
|
|
797
903
|
...(data?.permissions && { permissions: data.permissions }),
|
|
@@ -800,7 +906,13 @@ export class NeusClient {
|
|
|
800
906
|
...(data?.receiptDisclosure && { receiptDisclosure: data.receiptDisclosure }),
|
|
801
907
|
...(data?.expiresAt && { expiresAt: data.expiresAt }),
|
|
802
908
|
...(data?.instructions && { instructions: data.instructions }),
|
|
803
|
-
...(data?.skills && { skills: data.skills })
|
|
909
|
+
...(data?.skills && { skills: data.skills }),
|
|
910
|
+
...(data?.model && { model: data.model }),
|
|
911
|
+
...(data?.provider && { provider: data.provider }),
|
|
912
|
+
...(data?.runtimePolicy && { runtimePolicy: data.runtimePolicy }),
|
|
913
|
+
...(data?.allowedActions && { allowedActions: data.allowedActions }),
|
|
914
|
+
...(data?.deniedActions && { deniedActions: data.deniedActions }),
|
|
915
|
+
...(data?.approvalPolicy && { approvalPolicy: data.approvalPolicy })
|
|
804
916
|
};
|
|
805
917
|
} else if (verifier === 'ai-content-moderation') {
|
|
806
918
|
if (!data?.content) {
|
|
@@ -962,14 +1074,17 @@ export class NeusClient {
|
|
|
962
1074
|
verifierIds,
|
|
963
1075
|
data,
|
|
964
1076
|
walletAddress,
|
|
965
|
-
signature,
|
|
1077
|
+
signature: rawSignature,
|
|
966
1078
|
signedTimestamp,
|
|
967
1079
|
chainId,
|
|
968
1080
|
chain,
|
|
969
1081
|
signatureMethod,
|
|
1082
|
+
delegationQHash,
|
|
970
1083
|
options = {}
|
|
971
1084
|
} = params;
|
|
972
1085
|
|
|
1086
|
+
const signature = isPlaceholderNeusSignature(rawSignature) ? undefined : rawSignature;
|
|
1087
|
+
|
|
973
1088
|
const resolvedChainId = chainId || (chain ? null : NEUS_CONSTANTS.HUB_CHAIN_ID);
|
|
974
1089
|
|
|
975
1090
|
const normalizeVerifierId = (id) => {
|
|
@@ -988,8 +1103,12 @@ export class NeusClient {
|
|
|
988
1103
|
if (!walletAddress || typeof walletAddress !== 'string') {
|
|
989
1104
|
throw new ValidationError('walletAddress is required');
|
|
990
1105
|
}
|
|
991
|
-
|
|
992
|
-
|
|
1106
|
+
const hasAppAttribution =
|
|
1107
|
+
typeof this.config.appId === 'string' && this.config.appId.trim().length > 0;
|
|
1108
|
+
if (!signature && !delegationQHash && !hasAppAttribution) {
|
|
1109
|
+
throw new ValidationError(
|
|
1110
|
+
'signature, delegationQHash, or NeusClient config appId (sent as X-Neus-App) is required'
|
|
1111
|
+
);
|
|
993
1112
|
}
|
|
994
1113
|
if (!signedTimestamp || typeof signedTimestamp !== 'number') {
|
|
995
1114
|
throw new ValidationError('signedTimestamp is required');
|
|
@@ -1019,11 +1138,12 @@ export class NeusClient {
|
|
|
1019
1138
|
verifierIds: normalizedVerifierIds,
|
|
1020
1139
|
data,
|
|
1021
1140
|
walletAddress,
|
|
1022
|
-
signature,
|
|
1141
|
+
...(signature ? { signature } : {}),
|
|
1023
1142
|
signedTimestamp,
|
|
1024
1143
|
...(resolvedChainId !== null && { chainId: resolvedChainId }),
|
|
1025
1144
|
...(chain && { chain }),
|
|
1026
1145
|
...(signatureMethod && { signatureMethod }),
|
|
1146
|
+
...(delegationQHash && { delegationQHash }),
|
|
1027
1147
|
options: optionsPayload
|
|
1028
1148
|
};
|
|
1029
1149
|
|
|
@@ -1037,11 +1157,10 @@ export class NeusClient {
|
|
|
1037
1157
|
}
|
|
1038
1158
|
|
|
1039
1159
|
async getProof(qHash) {
|
|
1040
|
-
|
|
1041
|
-
if (!resolvedQHash || typeof resolvedQHash !== 'string') {
|
|
1160
|
+
if (!qHash || typeof qHash !== 'string') {
|
|
1042
1161
|
throw new ValidationError('qHash is required');
|
|
1043
1162
|
}
|
|
1044
|
-
const response = await this._makeRequest('GET', `/api/v1/proofs/${
|
|
1163
|
+
const response = await this._makeRequest('GET', `/api/v1/proofs/${qHash}`);
|
|
1045
1164
|
|
|
1046
1165
|
if (!response.success) {
|
|
1047
1166
|
throw new ApiError(`Failed to get proof: ${response.error?.message || 'Unknown error'}`, response.error);
|
|
@@ -1051,8 +1170,7 @@ export class NeusClient {
|
|
|
1051
1170
|
}
|
|
1052
1171
|
|
|
1053
1172
|
async getPrivateProof(qHash, wallet = null) {
|
|
1054
|
-
|
|
1055
|
-
if (!resolvedQHash || typeof resolvedQHash !== 'string') {
|
|
1173
|
+
if (!qHash || typeof qHash !== 'string') {
|
|
1056
1174
|
throw new ValidationError('qHash is required');
|
|
1057
1175
|
}
|
|
1058
1176
|
|
|
@@ -1070,7 +1188,7 @@ export class NeusClient {
|
|
|
1070
1188
|
...(typeof auth.chain === 'string' && auth.chain.trim() ? { 'x-chain': auth.chain.trim() } : {}),
|
|
1071
1189
|
...(typeof auth.signatureMethod === 'string' && auth.signatureMethod.trim() ? { 'x-signature-method': auth.signatureMethod.trim() } : {})
|
|
1072
1190
|
};
|
|
1073
|
-
const response = await this._makeRequest('GET', `/api/v1/proofs/${
|
|
1191
|
+
const response = await this._makeRequest('GET', `/api/v1/proofs/${qHash}`, null, headers);
|
|
1074
1192
|
if (!response.success) {
|
|
1075
1193
|
throw new ApiError(
|
|
1076
1194
|
`Failed to access private proof: ${response.error?.message || 'Unauthorized'}`,
|
|
@@ -1094,7 +1212,7 @@ export class NeusClient {
|
|
|
1094
1212
|
const message = constructVerificationMessage({
|
|
1095
1213
|
walletAddress,
|
|
1096
1214
|
signedTimestamp,
|
|
1097
|
-
data: { action: 'access_private_proof', qHash:
|
|
1215
|
+
data: { action: 'access_private_proof', qHash: qHash },
|
|
1098
1216
|
verifierIds: ['ownership-basic'],
|
|
1099
1217
|
...(signerIsEvm ? { chainId: this._getHubChainId() } : { chain })
|
|
1100
1218
|
});
|
|
@@ -1114,7 +1232,7 @@ export class NeusClient {
|
|
|
1114
1232
|
throw new ValidationError(`Failed to sign message: ${error.message}`);
|
|
1115
1233
|
}
|
|
1116
1234
|
|
|
1117
|
-
const response = await this._makeRequest('GET', `/api/v1/proofs/${
|
|
1235
|
+
const response = await this._makeRequest('GET', `/api/v1/proofs/${qHash}`, null, {
|
|
1118
1236
|
'x-wallet-address': walletAddress,
|
|
1119
1237
|
'x-signature': signature,
|
|
1120
1238
|
'x-signed-timestamp': signedTimestamp.toString(),
|
|
@@ -1164,14 +1282,13 @@ export class NeusClient {
|
|
|
1164
1282
|
}
|
|
1165
1283
|
|
|
1166
1284
|
async pollProofStatus(qHash, options = {}) {
|
|
1167
|
-
const resolvedQHash = qHash; // Legacy input compatibility only. Do not expose or store proofId.
|
|
1168
1285
|
const {
|
|
1169
1286
|
interval = 5000,
|
|
1170
1287
|
timeout = 120000,
|
|
1171
1288
|
onProgress
|
|
1172
1289
|
} = options;
|
|
1173
1290
|
|
|
1174
|
-
if (!
|
|
1291
|
+
if (!qHash || typeof qHash !== 'string') {
|
|
1175
1292
|
throw new ValidationError('qHash is required');
|
|
1176
1293
|
}
|
|
1177
1294
|
|
|
@@ -1180,7 +1297,7 @@ export class NeusClient {
|
|
|
1180
1297
|
|
|
1181
1298
|
while (Date.now() - startTime < timeout) {
|
|
1182
1299
|
try {
|
|
1183
|
-
const status = await this.getProof(
|
|
1300
|
+
const status = await this.getProof(qHash);
|
|
1184
1301
|
consecutiveRateLimits = 0;
|
|
1185
1302
|
|
|
1186
1303
|
if (onProgress && typeof onProgress === 'function') {
|
|
@@ -1233,8 +1350,7 @@ export class NeusClient {
|
|
|
1233
1350
|
}
|
|
1234
1351
|
|
|
1235
1352
|
async revokeOwnProof(qHash, wallet) {
|
|
1236
|
-
|
|
1237
|
-
if (!resolvedQHash || typeof resolvedQHash !== 'string') {
|
|
1353
|
+
if (!qHash || typeof qHash !== 'string') {
|
|
1238
1354
|
throw new ValidationError('qHash is required');
|
|
1239
1355
|
}
|
|
1240
1356
|
const providerWallet = wallet || this._getDefaultBrowserWallet();
|
|
@@ -1250,7 +1366,7 @@ export class NeusClient {
|
|
|
1250
1366
|
const message = constructVerificationMessage({
|
|
1251
1367
|
walletAddress: address,
|
|
1252
1368
|
signedTimestamp,
|
|
1253
|
-
data: { action: 'revoke_proof', qHash:
|
|
1369
|
+
data: { action: 'revoke_proof', qHash: qHash },
|
|
1254
1370
|
verifierIds: ['ownership-basic'],
|
|
1255
1371
|
...(signerIsEvm ? { chainId: this._getHubChainId() } : { chain })
|
|
1256
1372
|
});
|
|
@@ -1270,7 +1386,7 @@ export class NeusClient {
|
|
|
1270
1386
|
throw new ValidationError(`Failed to sign revocation: ${error.message}`);
|
|
1271
1387
|
}
|
|
1272
1388
|
|
|
1273
|
-
const res = await this._makeRequest('POST', `/api/v1/proofs/revoke-self/${
|
|
1389
|
+
const res = await this._makeRequest('POST', `/api/v1/proofs/revoke-self/${qHash}`, {
|
|
1274
1390
|
walletAddress: address,
|
|
1275
1391
|
signature,
|
|
1276
1392
|
signedTimestamp,
|
|
@@ -1765,9 +1881,6 @@ export class NeusClient {
|
|
|
1765
1881
|
const qHash = response?.data?.qHash ||
|
|
1766
1882
|
response?.qHash ||
|
|
1767
1883
|
response?.data?.resource?.qHash ||
|
|
1768
|
-
response?.data?.proofId || // Legacy input compatibility only. Do not expose or store proofId.
|
|
1769
|
-
response?.proofId || // Legacy input compatibility only. Do not expose or store proofId.
|
|
1770
|
-
response?.data?.resource?.proofId || // Legacy input compatibility only. Do not expose or store proofId.
|
|
1771
1884
|
response?.data?.id;
|
|
1772
1885
|
|
|
1773
1886
|
const status = response?.data?.status ||
|
package/errors.js
CHANGED
|
@@ -79,7 +79,7 @@ export class NetworkError extends SDKError {
|
|
|
79
79
|
super(message, code);
|
|
80
80
|
this.name = 'NetworkError';
|
|
81
81
|
this.originalError = originalError;
|
|
82
|
-
this.isRetryable = true; // Network errors are
|
|
82
|
+
this.isRetryable = true; // Network errors are retryable
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
static isNetworkError(error) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neus/sdk",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "NEUS makes trust portable across the internet — so people, apps, and AI agents can prove what is real before access, payout, or execution.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"neus": "cli/neus.mjs"
|
|
7
7
|
},
|
|
@@ -67,7 +67,10 @@
|
|
|
67
67
|
"universal-protocol",
|
|
68
68
|
"proof",
|
|
69
69
|
"ownership",
|
|
70
|
-
"sdk"
|
|
70
|
+
"sdk",
|
|
71
|
+
"mcp",
|
|
72
|
+
"model-context-protocol",
|
|
73
|
+
"oauth"
|
|
71
74
|
],
|
|
72
75
|
"author": "NEUS Network",
|
|
73
76
|
"license": "Apache-2.0",
|
|
@@ -80,6 +83,10 @@
|
|
|
80
83
|
"url": "https://github.com/neus/network/issues"
|
|
81
84
|
},
|
|
82
85
|
"homepage": "https://neus.network",
|
|
86
|
+
"publishConfig": {
|
|
87
|
+
"access": "public",
|
|
88
|
+
"registry": "https://registry.npmjs.org"
|
|
89
|
+
},
|
|
83
90
|
"engines": {
|
|
84
91
|
"node": ">=20.0.0"
|
|
85
92
|
},
|
|
@@ -124,6 +131,7 @@
|
|
|
124
131
|
"widgets.cjs",
|
|
125
132
|
"types.d.ts",
|
|
126
133
|
"README.md",
|
|
134
|
+
"CHANGELOG.md",
|
|
127
135
|
"SECURITY.md",
|
|
128
136
|
"LICENSE",
|
|
129
137
|
"neus-logo.svg",
|
package/types.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ declare module '@neus/sdk' {
|
|
|
7
7
|
|
|
8
8
|
export class NeusClient {
|
|
9
9
|
constructor(config?: NeusClientConfig);
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
verifyFromApp(params: VerifyFromAppParams): Promise<VerificationResult>;
|
|
12
|
+
|
|
11
13
|
verify(params: VerifyParams): Promise<VerificationResult>;
|
|
12
14
|
|
|
13
15
|
getProof(qHash: string): Promise<StatusResult>;
|
|
@@ -57,6 +59,8 @@ declare module '@neus/sdk' {
|
|
|
57
59
|
apiUrl?: string;
|
|
58
60
|
apiKey?: string;
|
|
59
61
|
appId?: string;
|
|
62
|
+
/** Optional: only when using legacy `delegationQHash` on verify requests. App-linked servers rely on `appId` + Origin + stored delegation. */
|
|
63
|
+
appLinkQHash?: string;
|
|
60
64
|
paymentSignature?: string;
|
|
61
65
|
extraHeaders?: Record<string, string>;
|
|
62
66
|
timeout?: number;
|
|
@@ -77,8 +81,12 @@ declare module '@neus/sdk' {
|
|
|
77
81
|
export interface VerifierCatalogMetadataEntry {
|
|
78
82
|
category?: string;
|
|
79
83
|
description?: string;
|
|
84
|
+
accessLevel?: 'public' | 'pro' | 'custom' | 'admin' | string;
|
|
80
85
|
flowType?: 'instant' | 'interactive' | 'external_lookup' | string;
|
|
81
86
|
expiryType?: 'permanent' | 'point_in_time' | 'expiring' | string;
|
|
87
|
+
allowsDelegatedSubject?: boolean;
|
|
88
|
+
compatibleWith?: string[];
|
|
89
|
+
conflictsWith?: string[];
|
|
82
90
|
supportsDirectApi?: boolean;
|
|
83
91
|
supportsHostedVerify?: boolean;
|
|
84
92
|
dataSchema?: Record<string, any>;
|
|
@@ -92,6 +100,18 @@ declare module '@neus/sdk' {
|
|
|
92
100
|
meta?: Record<string, any>;
|
|
93
101
|
}
|
|
94
102
|
|
|
103
|
+
export interface VerifyFromAppParams {
|
|
104
|
+
user: {
|
|
105
|
+
walletAddress?: string;
|
|
106
|
+
address?: string;
|
|
107
|
+
identity?: string;
|
|
108
|
+
};
|
|
109
|
+
verifier?: VerifierId;
|
|
110
|
+
content?: string | Record<string, any>;
|
|
111
|
+
data?: VerificationData;
|
|
112
|
+
options?: VerifyOptions;
|
|
113
|
+
}
|
|
114
|
+
|
|
95
115
|
export interface VerifyParams {
|
|
96
116
|
verifier?: VerifierId;
|
|
97
117
|
content?: string;
|
|
@@ -105,6 +125,7 @@ declare module '@neus/sdk' {
|
|
|
105
125
|
chainId?: number;
|
|
106
126
|
chain?: string;
|
|
107
127
|
signatureMethod?: string;
|
|
128
|
+
delegationQHash?: string;
|
|
108
129
|
wallet?: WalletLike;
|
|
109
130
|
}
|
|
110
131
|
|
|
@@ -582,6 +603,8 @@ declare module '@neus/sdk' {
|
|
|
582
603
|
| 'doc'
|
|
583
604
|
| 'media'
|
|
584
605
|
| 'username-claim'
|
|
606
|
+
| 'job'
|
|
607
|
+
| 'job-status'
|
|
585
608
|
| 'other';
|
|
586
609
|
id?: string;
|
|
587
610
|
title?: string;
|
|
@@ -629,7 +652,8 @@ declare module '@neus/sdk' {
|
|
|
629
652
|
contractAddress: string;
|
|
630
653
|
tokenId: string;
|
|
631
654
|
tokenType?: 'erc721' | 'erc1155';
|
|
632
|
-
chainId
|
|
655
|
+
chainId?: number;
|
|
656
|
+
chain?: string;
|
|
633
657
|
blockNumber?: number;
|
|
634
658
|
[key: string]: any;
|
|
635
659
|
};
|
|
@@ -638,24 +662,29 @@ declare module '@neus/sdk' {
|
|
|
638
662
|
ownerAddress?: string;
|
|
639
663
|
contractAddress: string;
|
|
640
664
|
minBalance: string;
|
|
641
|
-
chainId
|
|
665
|
+
chainId?: number;
|
|
666
|
+
chain?: string;
|
|
642
667
|
blockNumber?: number;
|
|
643
668
|
[key: string]: any;
|
|
644
669
|
};
|
|
645
670
|
|
|
646
671
|
type WalletRiskData = {
|
|
672
|
+
walletAddress: string;
|
|
647
673
|
provider?: string;
|
|
648
|
-
walletAddress?: string;
|
|
649
674
|
chainId?: number;
|
|
650
|
-
|
|
675
|
+
chain?: string;
|
|
651
676
|
[key: string]: any;
|
|
652
677
|
};
|
|
653
678
|
|
|
654
679
|
type WalletLinkData = {
|
|
655
|
-
primaryWalletAddress
|
|
656
|
-
secondaryWalletAddress
|
|
680
|
+
primaryWalletAddress?: string;
|
|
681
|
+
secondaryWalletAddress?: string;
|
|
682
|
+
primaryAccountId?: string;
|
|
683
|
+
secondaryAccountId?: string;
|
|
684
|
+
primaryChainRef?: string;
|
|
685
|
+
secondaryChainRef?: string;
|
|
657
686
|
signature: string;
|
|
658
|
-
chain
|
|
687
|
+
chain?: string;
|
|
659
688
|
signatureMethod: string;
|
|
660
689
|
signedTimestamp: number;
|
|
661
690
|
relationshipType?: 'primary' | 'personal' | 'org' | 'affiliate' | 'agent' | 'linked';
|
|
@@ -679,36 +708,70 @@ declare module '@neus/sdk' {
|
|
|
679
708
|
[key: string]: any;
|
|
680
709
|
};
|
|
681
710
|
|
|
711
|
+
type AgentSkillRef = {
|
|
712
|
+
id: string;
|
|
713
|
+
label?: string;
|
|
714
|
+
version?: string;
|
|
715
|
+
provider?: string;
|
|
716
|
+
kind?: 'native' | 'integration' | 'plugin' | 'mcp' | 'toolkit';
|
|
717
|
+
configId?: string;
|
|
718
|
+
enabled?: boolean;
|
|
719
|
+
};
|
|
720
|
+
|
|
682
721
|
type AgentIdentityData = {
|
|
683
722
|
agentId: string;
|
|
684
723
|
agentWallet: string;
|
|
724
|
+
agentChainRef: string;
|
|
725
|
+
agentAccountId?: string;
|
|
685
726
|
agentLabel?: string;
|
|
686
727
|
agentType?: 'ai' | 'bot' | 'service' | 'automation' | 'agent';
|
|
728
|
+
avatar?: string;
|
|
687
729
|
description?: string;
|
|
688
|
-
|
|
730
|
+
defaultRuntime?: {
|
|
731
|
+
provider?: string;
|
|
732
|
+
model?: string;
|
|
733
|
+
mode?: string;
|
|
734
|
+
};
|
|
735
|
+
capabilities?: Record<string, boolean>;
|
|
689
736
|
instructions?: string;
|
|
690
|
-
skills?:
|
|
737
|
+
skills?: AgentSkillRef[];
|
|
691
738
|
services?: Array<{
|
|
692
739
|
name: string;
|
|
693
740
|
endpoint: string;
|
|
694
741
|
version?: string;
|
|
695
742
|
}>;
|
|
696
|
-
[key: string]: any;
|
|
697
743
|
};
|
|
698
744
|
|
|
699
745
|
type AgentDelegationData = {
|
|
700
746
|
controllerWallet: string;
|
|
747
|
+
controllerChainRef: string;
|
|
701
748
|
agentWallet: string;
|
|
749
|
+
agentChainRef: string;
|
|
750
|
+
controllerAccountId?: string;
|
|
751
|
+
agentAccountId?: string;
|
|
702
752
|
agentId?: string;
|
|
703
753
|
scope?: string;
|
|
704
|
-
permissions?:
|
|
754
|
+
permissions?: string[];
|
|
705
755
|
maxSpend?: string;
|
|
706
756
|
allowedPaymentTypes?: string[];
|
|
707
757
|
receiptDisclosure?: 'none' | 'summary' | 'full';
|
|
708
758
|
expiresAt?: number;
|
|
709
759
|
instructions?: string;
|
|
710
|
-
skills?:
|
|
711
|
-
|
|
760
|
+
skills?: AgentSkillRef[];
|
|
761
|
+
model?: string;
|
|
762
|
+
provider?: string;
|
|
763
|
+
runtimePolicy?: {
|
|
764
|
+
allowedProviders?: string[];
|
|
765
|
+
allowedModelClasses?: string[];
|
|
766
|
+
requiresHumanApproval?: boolean;
|
|
767
|
+
secretsExposedToReceipt?: boolean;
|
|
768
|
+
};
|
|
769
|
+
allowedActions?: string[];
|
|
770
|
+
deniedActions?: string[];
|
|
771
|
+
approvalPolicy?: {
|
|
772
|
+
humanApprovalRequiredForNewClaims?: boolean;
|
|
773
|
+
preApprovedContentOnly?: boolean;
|
|
774
|
+
};
|
|
712
775
|
};
|
|
713
776
|
|
|
714
777
|
type CoreVerificationData =
|
|
@@ -768,6 +831,8 @@ declare module '@neus/sdk' {
|
|
|
768
831
|
| 'doc'
|
|
769
832
|
| 'media'
|
|
770
833
|
| 'username-claim'
|
|
834
|
+
| 'job'
|
|
835
|
+
| 'job-status'
|
|
771
836
|
| 'other';
|
|
772
837
|
id?: string;
|
|
773
838
|
title?: string;
|
package/widgets/README.md
CHANGED
|
@@ -10,7 +10,7 @@ npm install @neus/sdk react react-dom
|
|
|
10
10
|
|
|
11
11
|
## VerifyGate
|
|
12
12
|
|
|
13
|
-
Create mode defaults to **private**. Override `proofOptions` only when you
|
|
13
|
+
Create mode defaults to **private**. Override `proofOptions` only when you need public visibility for link-based or public checks.
|
|
14
14
|
|
|
15
15
|
```jsx
|
|
16
16
|
import { VerifyGate } from '@neus/sdk/widgets';
|
|
@@ -28,7 +28,7 @@ var NeusLogo = ({ size = 12, logoUrl }) => /* @__PURE__ */ jsx(
|
|
|
28
28
|
}
|
|
29
29
|
);
|
|
30
30
|
function ProofBadge({
|
|
31
|
-
qHash
|
|
31
|
+
qHash,
|
|
32
32
|
proofUrlPattern = "/proof/:qHash",
|
|
33
33
|
size = "sm",
|
|
34
34
|
uiLinkBase = "https://neus.network",
|
|
@@ -38,10 +38,8 @@ function ProofBadge({
|
|
|
38
38
|
showLabel = true,
|
|
39
39
|
logoUrl = void 0,
|
|
40
40
|
onClick = void 0,
|
|
41
|
-
className = ""
|
|
42
|
-
...legacyProps
|
|
41
|
+
className = ""
|
|
43
42
|
}) {
|
|
44
|
-
const qHash = qHashProp ?? legacyProps.proofId;
|
|
45
43
|
const resolvedQHash = qHash;
|
|
46
44
|
const [status, setStatus] = useState(() => {
|
|
47
45
|
if (proof) {
|
|
@@ -149,7 +147,7 @@ function ProofBadge({
|
|
|
149
147
|
);
|
|
150
148
|
}
|
|
151
149
|
function SimpleProofBadge({
|
|
152
|
-
qHash
|
|
150
|
+
qHash,
|
|
153
151
|
proofUrlPattern = "/proof/:qHash",
|
|
154
152
|
uiLinkBase = "https://neus.network",
|
|
155
153
|
apiUrl = DEFAULT_API_BASE,
|
|
@@ -158,10 +156,8 @@ function SimpleProofBadge({
|
|
|
158
156
|
logoUrl = void 0,
|
|
159
157
|
proof = void 0,
|
|
160
158
|
onClick = void 0,
|
|
161
|
-
className = ""
|
|
162
|
-
...legacyProps
|
|
159
|
+
className = ""
|
|
163
160
|
}) {
|
|
164
|
-
const qHash = qHashProp ?? legacyProps.proofId;
|
|
165
161
|
const resolvedQHash = qHash;
|
|
166
162
|
const [status, setStatus] = useState(() => {
|
|
167
163
|
if (proof) {
|
|
@@ -244,17 +240,15 @@ function SimpleProofBadge({
|
|
|
244
240
|
);
|
|
245
241
|
}
|
|
246
242
|
function NeusPillLink({
|
|
247
|
-
qHash
|
|
243
|
+
qHash,
|
|
248
244
|
proofUrlPattern = "/proof/:qHash",
|
|
249
245
|
uiLinkBase = "https://neus.network",
|
|
250
246
|
label = "View",
|
|
251
247
|
size = "sm",
|
|
252
248
|
logoUrl = void 0,
|
|
253
249
|
onClick = void 0,
|
|
254
|
-
className = ""
|
|
255
|
-
...legacyProps
|
|
250
|
+
className = ""
|
|
256
251
|
}) {
|
|
257
|
-
const qHash = qHashProp ?? legacyProps.proofId;
|
|
258
252
|
const resolvedQHash = qHash;
|
|
259
253
|
const base = String(uiLinkBase).replace(/\/$/, "");
|
|
260
254
|
const href = resolvedQHash ? `${base}${String(proofUrlPattern).replace(":qHash", resolvedQHash)}` : base;
|
|
@@ -304,17 +298,15 @@ function NeusPillLink({
|
|
|
304
298
|
);
|
|
305
299
|
}
|
|
306
300
|
function VerifiedIcon({
|
|
307
|
-
qHash
|
|
301
|
+
qHash,
|
|
308
302
|
proofUrlPattern = "/proof/:qHash",
|
|
309
303
|
uiLinkBase = "https://neus.network",
|
|
310
304
|
size = 14,
|
|
311
305
|
logoUrl = void 0,
|
|
312
306
|
tooltip = "Proof",
|
|
313
307
|
onClick = void 0,
|
|
314
|
-
className = ""
|
|
315
|
-
...legacyProps
|
|
308
|
+
className = ""
|
|
316
309
|
}) {
|
|
317
|
-
const qHash = qHashProp ?? legacyProps.proofId;
|
|
318
310
|
const resolvedQHash = qHash;
|
|
319
311
|
const href = resolvedQHash ? `${String(uiLinkBase).replace(/\/$/, "")}${String(proofUrlPattern).replace(":qHash", resolvedQHash)}` : void 0;
|
|
320
312
|
const handleClick = (e) => {
|