@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/gates.js CHANGED
@@ -51,23 +51,3 @@ export function combineGates(...gates) {
51
51
 
52
52
  return combined;
53
53
  }
54
-
55
- export default {
56
- HOUR,
57
- DAY,
58
- WEEK,
59
- MONTH,
60
- YEAR,
61
- GATE_NFT_HOLDER,
62
- GATE_TOKEN_HOLDER,
63
- GATE_CONTRACT_ADMIN,
64
- GATE_DOMAIN_OWNER,
65
- GATE_LINKED_WALLETS,
66
- GATE_AGENT_IDENTITY,
67
- GATE_AGENT_DELEGATION,
68
- GATE_CONTENT_MODERATION,
69
- GATE_WALLET_RISK,
70
- GATE_PSEUDONYM,
71
- createGate,
72
- combineGates
73
- };
package/index.js CHANGED
@@ -55,6 +55,8 @@ export {
55
55
  combineGates
56
56
  } from './gates.js';
57
57
 
58
+ export { fetchSponsorGrant } from './sponsor.js';
59
+
58
60
  export {
59
61
  SDKError,
60
62
  ApiError,
package/package.json CHANGED
@@ -1,135 +1,142 @@
1
- {
2
- "name": "@neus/sdk",
3
- "version": "1.0.12",
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
- "bin": {
6
- "neus": "cli/neus.mjs"
7
- },
8
- "main": "index.js",
9
- "type": "module",
10
- "types": "types.d.ts",
11
- "exports": {
12
- ".": {
13
- "types": "./types.d.ts",
14
- "import": "./index.js",
15
- "require": "./cjs/index.cjs"
16
- },
17
- "./client": {
18
- "types": "./types.d.ts",
19
- "import": "./client.js",
20
- "require": "./cjs/client.cjs"
21
- },
22
- "./utils": {
23
- "import": "./utils.js",
24
- "require": "./cjs/utils.cjs"
25
- },
26
- "./errors": {
27
- "import": "./errors.js",
28
- "require": "./cjs/errors.cjs"
29
- },
30
- "./gates": {
31
- "import": "./gates.js",
32
- "require": "./cjs/gates.cjs"
33
- },
34
- "./widgets": {
35
- "types": "./types.d.ts",
36
- "import": "./widgets/index.js",
37
- "require": "./widgets.cjs"
38
- },
39
- "./widgets/verify-gate": {
40
- "types": "./types.d.ts",
41
- "import": "./widgets/verify-gate/index.js",
42
- "require": "./widgets.cjs"
43
- }
44
- },
45
- "sideEffects": false,
46
- "scripts": {
47
- "test": "npm run build:cjs && vitest run",
48
- "test:coverage": "vitest run --coverage",
49
- "lint": "eslint . --ignore-pattern widgets/verify-gate/dist/**",
50
- "format": "prettier --write \"**/*.js\"",
51
- "build": "npm run build:widgets && npm run build:cjs",
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",
54
- "prepack": "npm run build",
55
- "prepublishOnly": "npm run lint && npm test && npm run build"
56
- },
57
- "keywords": [
58
- "neus",
59
- "verification",
60
- "cryptographic-proofs",
61
- "identity",
62
- "authentication",
63
- "blockchain",
64
- "cross-chain",
65
- "web3",
66
- "passwordless",
67
- "universal-protocol",
68
- "proof",
69
- "ownership",
70
- "sdk"
71
- ],
72
- "author": "NEUS Network",
73
- "license": "Apache-2.0",
74
- "repository": {
75
- "type": "git",
76
- "url": "git+https://github.com/neus/network.git",
77
- "directory": "sdk"
78
- },
79
- "bugs": {
80
- "url": "https://github.com/neus/network/issues"
81
- },
82
- "homepage": "https://neus.network",
83
- "engines": {
84
- "node": ">=20.0.0"
85
- },
86
- "peerDependencies": {
87
- "ethers": "^6.0.0",
88
- "react": ">=17.0.0",
89
- "react-dom": ">=17.0.0"
90
- },
91
- "peerDependenciesMeta": {
92
- "@zkpassport/sdk": {
93
- "optional": true
94
- },
95
- "react": {
96
- "optional": true
97
- },
98
- "react-dom": {
99
- "optional": true
100
- }
101
- },
102
- "optionalDependencies": {
103
- "@zkpassport/sdk": "^0.14.0"
104
- },
105
- "dependencies": {
106
- "bs58": "^6.0.0"
107
- },
108
- "devDependencies": {
109
- "@vitest/coverage-v8": "^4.1.3",
110
- "esbuild": "^0.28.0",
111
- "eslint": "^8.56.0",
112
- "eslint-plugin-react": "^7.37.2",
113
- "prettier": "^3.2.0",
114
- "vitest": "^4.1.3"
115
- },
116
- "files": [
117
- "cli/neus.mjs",
118
- "index.js",
119
- "client.js",
120
- "utils.js",
121
- "errors.js",
122
- "gates.js",
123
- "cjs/**",
124
- "widgets.cjs",
125
- "types.d.ts",
126
- "README.md",
127
- "SECURITY.md",
128
- "LICENSE",
129
- "neus-logo.svg",
130
- "widgets/index.js",
131
- "widgets/verify-gate/index.js",
132
- "widgets/verify-gate/dist/VerifyGate.js",
133
- "widgets/verify-gate/dist/ProofBadge.js"
134
- ]
135
- }
1
+ {
2
+ "name": "@neus/sdk",
3
+ "version": "1.1.1",
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
+ "bin": {
6
+ "neus": "cli/neus.mjs"
7
+ },
8
+ "main": "index.js",
9
+ "type": "module",
10
+ "types": "types.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./types.d.ts",
14
+ "import": "./index.js",
15
+ "require": "./cjs/index.cjs"
16
+ },
17
+ "./client": {
18
+ "types": "./types.d.ts",
19
+ "import": "./client.js",
20
+ "require": "./cjs/client.cjs"
21
+ },
22
+ "./utils": {
23
+ "import": "./utils.js",
24
+ "require": "./cjs/utils.cjs"
25
+ },
26
+ "./errors": {
27
+ "import": "./errors.js",
28
+ "require": "./cjs/errors.cjs"
29
+ },
30
+ "./gates": {
31
+ "import": "./gates.js",
32
+ "require": "./cjs/gates.cjs"
33
+ },
34
+ "./widgets": {
35
+ "types": "./types.d.ts",
36
+ "import": "./widgets/index.js",
37
+ "require": "./widgets.cjs"
38
+ },
39
+ "./widgets/verify-gate": {
40
+ "types": "./types.d.ts",
41
+ "import": "./widgets/verify-gate/index.js",
42
+ "require": "./widgets.cjs"
43
+ }
44
+ },
45
+ "sideEffects": false,
46
+ "scripts": {
47
+ "test": "npm run build:cjs && vitest run",
48
+ "test:coverage": "vitest run --coverage",
49
+ "lint": "eslint . --ignore-pattern widgets/verify-gate/dist/**",
50
+ "format": "prettier --write \"**/*.js\"",
51
+ "build": "npm run build:widgets && npm run build:cjs",
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",
54
+ "prepack": "npm run build",
55
+ "prepublishOnly": "npm run lint && npm test && npm run build"
56
+ },
57
+ "keywords": [
58
+ "neus",
59
+ "verification",
60
+ "cryptographic-proofs",
61
+ "identity",
62
+ "authentication",
63
+ "blockchain",
64
+ "cross-chain",
65
+ "web3",
66
+ "passwordless",
67
+ "universal-protocol",
68
+ "proof",
69
+ "ownership",
70
+ "sdk",
71
+ "mcp",
72
+ "model-context-protocol",
73
+ "oauth"
74
+ ],
75
+ "author": "NEUS Network",
76
+ "license": "Apache-2.0",
77
+ "repository": {
78
+ "type": "git",
79
+ "url": "git+https://github.com/neus/network.git",
80
+ "directory": "sdk"
81
+ },
82
+ "bugs": {
83
+ "url": "https://github.com/neus/network/issues"
84
+ },
85
+ "homepage": "https://neus.network",
86
+ "publishConfig": {
87
+ "access": "public",
88
+ "registry": "https://registry.npmjs.org"
89
+ },
90
+ "engines": {
91
+ "node": ">=20.0.0"
92
+ },
93
+ "peerDependencies": {
94
+ "ethers": "^6.0.0",
95
+ "react": ">=17.0.0",
96
+ "react-dom": ">=17.0.0"
97
+ },
98
+ "peerDependenciesMeta": {
99
+ "@zkpassport/sdk": {
100
+ "optional": true
101
+ },
102
+ "react": {
103
+ "optional": true
104
+ },
105
+ "react-dom": {
106
+ "optional": true
107
+ }
108
+ },
109
+ "optionalDependencies": {
110
+ "@zkpassport/sdk": "^0.14.0"
111
+ },
112
+ "dependencies": {
113
+ "bs58": "^6.0.0"
114
+ },
115
+ "devDependencies": {
116
+ "@vitest/coverage-v8": "^4.1.3",
117
+ "esbuild": "^0.28.0",
118
+ "eslint": "^8.56.0",
119
+ "eslint-plugin-react": "^7.37.2",
120
+ "prettier": "^3.2.0",
121
+ "vitest": "^4.1.3"
122
+ },
123
+ "files": [
124
+ "cli/neus.mjs",
125
+ "index.js",
126
+ "client.js",
127
+ "utils.js",
128
+ "errors.js",
129
+ "gates.js",
130
+ "sponsor.js",
131
+ "cjs/**",
132
+ "widgets.cjs",
133
+ "types.d.ts",
134
+ "README.md",
135
+ "SECURITY.md",
136
+ "LICENSE",
137
+ "widgets/index.js",
138
+ "widgets/verify-gate/index.js",
139
+ "widgets/verify-gate/dist/VerifyGate.js",
140
+ "widgets/verify-gate/dist/ProofBadge.js"
141
+ ]
142
+ }
package/sponsor.js ADDED
@@ -0,0 +1,95 @@
1
+ import { ValidationError, ApiError, NetworkError } from './errors.js';
2
+
3
+ /**
4
+ * Request short-lived billing authorization so verification usage bills the app owner.
5
+ * Requires a completed app registration (`sponsor-grants` delegation) on orgWallet.
6
+ */
7
+ export async function fetchSponsorGrant(params = {}) {
8
+ const {
9
+ apiUrl = 'https://api.neus.network',
10
+ appId,
11
+ orgWallet,
12
+ verifierIds = [],
13
+ targetChains = [],
14
+ origin,
15
+ expiresInSeconds = 900,
16
+ fetchImpl = fetch
17
+ } = params;
18
+
19
+ const normalizedAppId = typeof appId === 'string' ? appId.trim() : '';
20
+ const normalizedOrg = typeof orgWallet === 'string' ? orgWallet.trim().toLowerCase() : '';
21
+ if (!normalizedAppId) {
22
+ throw new ValidationError('appId is required for sponsor grant');
23
+ }
24
+ if (!normalizedOrg || !/^0x[a-f0-9]{40}$/.test(normalizedOrg)) {
25
+ throw new ValidationError('orgWallet must be a valid EVM address');
26
+ }
27
+
28
+ let base = String(apiUrl || 'https://api.neus.network').replace(/\/+$/, '');
29
+ try {
30
+ const url = new URL(base);
31
+ if (url.hostname.endsWith('neus.network') && url.protocol === 'http:') {
32
+ url.protocol = 'https:';
33
+ }
34
+ base = url.toString().replace(/\/+$/, '');
35
+ } catch {
36
+ void 0;
37
+ }
38
+
39
+ const headers = {
40
+ 'Content-Type': 'application/json',
41
+ Accept: 'application/json',
42
+ 'X-Neus-App': normalizedAppId,
43
+ 'X-Neus-Sdk': 'js'
44
+ };
45
+ if (typeof origin === 'string' && origin.trim()) {
46
+ headers.Origin = origin.trim();
47
+ }
48
+
49
+ const body = {
50
+ orgWallet: normalizedOrg,
51
+ scope: 'sponsored-verification',
52
+ expiresInSeconds,
53
+ ...(Array.isArray(verifierIds) && verifierIds.length > 0
54
+ ? { verifierIds: verifierIds.map((v) => String(v).trim()).filter(Boolean).slice(0, 25) }
55
+ : {}),
56
+ ...(Array.isArray(targetChains) && targetChains.length > 0
57
+ ? { targetChains: targetChains.filter((n) => Number.isFinite(Number(n))).slice(0, 25) }
58
+ : {})
59
+ };
60
+
61
+ let response;
62
+ try {
63
+ response = await fetchImpl(`${base}/api/v1/sponsor/grant`, {
64
+ method: 'POST',
65
+ headers,
66
+ body: JSON.stringify(body)
67
+ });
68
+ } catch (error) {
69
+ throw new NetworkError(`Sponsor grant request failed: ${error?.message || String(error)}`);
70
+ }
71
+
72
+ let payload;
73
+ try {
74
+ payload = await response.json();
75
+ } catch {
76
+ payload = { success: false, error: { message: 'Invalid JSON response' } };
77
+ }
78
+
79
+ if (!response.ok || payload?.success !== true) {
80
+ throw ApiError.fromResponse(response, payload);
81
+ }
82
+
83
+ const token = payload?.data?.sponsorGrant;
84
+ if (!token || typeof token !== 'string') {
85
+ throw new ApiError('Sponsor grant response missing sponsorGrant token', payload?.error);
86
+ }
87
+
88
+ return {
89
+ sponsorGrant: token,
90
+ exp: payload?.data?.exp,
91
+ orgWallet: payload?.data?.orgWallet || normalizedOrg,
92
+ appId: payload?.data?.appId || normalizedAppId,
93
+ maxCredits: payload?.data?.maxCredits
94
+ };
95
+ }
package/types.d.ts CHANGED
@@ -57,9 +57,18 @@ declare module '@neus/sdk' {
57
57
 
58
58
  export interface NeusClientConfig {
59
59
  apiUrl?: string;
60
+ /** Optional server profile key — MCP/CI only; not required for VerifyGate or gateCheck. */
60
61
  apiKey?: string;
62
+ /** Public app attribution id (non-secret). */
61
63
  appId?: string;
62
- /** Optional: only when using legacy `delegationQHash` on verify requests. App-linked servers rely on `appId` + Origin + stored delegation. */
64
+ /** Hub wallet that pays for user verification checks (your NEUS account). */
65
+ billingWallet?: string;
66
+ /** Alias for billingWallet. */
67
+ sponsorOrgWallet?: string;
68
+ orgWallet?: string;
69
+ /** Site origin used when issuing billing authorization (defaults to browser origin). */
70
+ appOrigin?: string;
71
+ /** @deprecated Advanced server path only — use appId + billingWallet for the default app flow. */
63
72
  appLinkQHash?: string;
64
73
  paymentSignature?: string;
65
74
  extraHeaders?: Record<string, string>;
@@ -68,6 +77,26 @@ declare module '@neus/sdk' {
68
77
  enableLogging?: boolean;
69
78
  }
70
79
 
80
+ export interface FetchSponsorGrantParams {
81
+ apiUrl?: string;
82
+ appId: string;
83
+ orgWallet: string;
84
+ verifierIds?: string[];
85
+ targetChains?: number[];
86
+ origin?: string;
87
+ expiresInSeconds?: number;
88
+ }
89
+
90
+ export interface FetchSponsorGrantResult {
91
+ sponsorGrant: string;
92
+ exp?: number;
93
+ orgWallet: string;
94
+ appId: string;
95
+ maxCredits?: number;
96
+ }
97
+
98
+ export function fetchSponsorGrant(params: FetchSponsorGrantParams): Promise<FetchSponsorGrantResult>;
99
+
71
100
  export interface VerificationOptions {
72
101
  privacyLevel?: PrivacyLevel;
73
102
  enableIpfs?: boolean;
@@ -81,8 +110,12 @@ declare module '@neus/sdk' {
81
110
  export interface VerifierCatalogMetadataEntry {
82
111
  category?: string;
83
112
  description?: string;
113
+ accessLevel?: 'public' | 'pro' | 'custom' | 'admin' | string;
84
114
  flowType?: 'instant' | 'interactive' | 'external_lookup' | string;
85
115
  expiryType?: 'permanent' | 'point_in_time' | 'expiring' | string;
116
+ allowsDelegatedSubject?: boolean;
117
+ compatibleWith?: string[];
118
+ conflictsWith?: string[];
86
119
  supportsDirectApi?: boolean;
87
120
  supportsHostedVerify?: boolean;
88
121
  dataSchema?: Record<string, any>;
@@ -599,6 +632,8 @@ declare module '@neus/sdk' {
599
632
  | 'doc'
600
633
  | 'media'
601
634
  | 'username-claim'
635
+ | 'job'
636
+ | 'job-status'
602
637
  | 'other';
603
638
  id?: string;
604
639
  title?: string;
@@ -646,7 +681,8 @@ declare module '@neus/sdk' {
646
681
  contractAddress: string;
647
682
  tokenId: string;
648
683
  tokenType?: 'erc721' | 'erc1155';
649
- chainId: number;
684
+ chainId?: number;
685
+ chain?: string;
650
686
  blockNumber?: number;
651
687
  [key: string]: any;
652
688
  };
@@ -655,24 +691,29 @@ declare module '@neus/sdk' {
655
691
  ownerAddress?: string;
656
692
  contractAddress: string;
657
693
  minBalance: string;
658
- chainId: number;
694
+ chainId?: number;
695
+ chain?: string;
659
696
  blockNumber?: number;
660
697
  [key: string]: any;
661
698
  };
662
699
 
663
700
  type WalletRiskData = {
701
+ walletAddress: string;
664
702
  provider?: string;
665
- walletAddress?: string;
666
703
  chainId?: number;
667
- includeDetails?: boolean;
704
+ chain?: string;
668
705
  [key: string]: any;
669
706
  };
670
707
 
671
708
  type WalletLinkData = {
672
- primaryWalletAddress: string;
673
- secondaryWalletAddress: string;
709
+ primaryWalletAddress?: string;
710
+ secondaryWalletAddress?: string;
711
+ primaryAccountId?: string;
712
+ secondaryAccountId?: string;
713
+ primaryChainRef?: string;
714
+ secondaryChainRef?: string;
674
715
  signature: string;
675
- chain: string;
716
+ chain?: string;
676
717
  signatureMethod: string;
677
718
  signedTimestamp: number;
678
719
  relationshipType?: 'primary' | 'personal' | 'org' | 'affiliate' | 'agent' | 'linked';
@@ -696,36 +737,70 @@ declare module '@neus/sdk' {
696
737
  [key: string]: any;
697
738
  };
698
739
 
740
+ type AgentSkillRef = {
741
+ id: string;
742
+ label?: string;
743
+ version?: string;
744
+ provider?: string;
745
+ kind?: 'native' | 'integration' | 'plugin' | 'mcp' | 'toolkit';
746
+ configId?: string;
747
+ enabled?: boolean;
748
+ };
749
+
699
750
  type AgentIdentityData = {
700
751
  agentId: string;
701
752
  agentWallet: string;
753
+ agentChainRef: string;
754
+ agentAccountId?: string;
702
755
  agentLabel?: string;
703
756
  agentType?: 'ai' | 'bot' | 'service' | 'automation' | 'agent';
757
+ avatar?: string;
704
758
  description?: string;
705
- capabilities?: any[];
759
+ defaultRuntime?: {
760
+ provider?: string;
761
+ model?: string;
762
+ mode?: string;
763
+ };
764
+ capabilities?: Record<string, boolean>;
706
765
  instructions?: string;
707
- skills?: string[];
766
+ skills?: AgentSkillRef[];
708
767
  services?: Array<{
709
768
  name: string;
710
769
  endpoint: string;
711
770
  version?: string;
712
771
  }>;
713
- [key: string]: any;
714
772
  };
715
773
 
716
774
  type AgentDelegationData = {
717
775
  controllerWallet: string;
776
+ controllerChainRef: string;
718
777
  agentWallet: string;
778
+ agentChainRef: string;
779
+ controllerAccountId?: string;
780
+ agentAccountId?: string;
719
781
  agentId?: string;
720
782
  scope?: string;
721
- permissions?: any[];
783
+ permissions?: string[];
722
784
  maxSpend?: string;
723
785
  allowedPaymentTypes?: string[];
724
786
  receiptDisclosure?: 'none' | 'summary' | 'full';
725
787
  expiresAt?: number;
726
788
  instructions?: string;
727
- skills?: string[];
728
- [key: string]: any;
789
+ skills?: AgentSkillRef[];
790
+ model?: string;
791
+ provider?: string;
792
+ runtimePolicy?: {
793
+ allowedProviders?: string[];
794
+ allowedModelClasses?: string[];
795
+ requiresHumanApproval?: boolean;
796
+ secretsExposedToReceipt?: boolean;
797
+ };
798
+ allowedActions?: string[];
799
+ deniedActions?: string[];
800
+ approvalPolicy?: {
801
+ humanApprovalRequiredForNewClaims?: boolean;
802
+ preApprovedContentOnly?: boolean;
803
+ };
729
804
  };
730
805
 
731
806
  type CoreVerificationData =
@@ -785,6 +860,8 @@ declare module '@neus/sdk' {
785
860
  | 'doc'
786
861
  | 'media'
787
862
  | 'username-claim'
863
+ | 'job'
864
+ | 'job-status'
788
865
  | 'other';
789
866
  id?: string;
790
867
  title?: string;
package/utils.js CHANGED
@@ -1023,6 +1023,8 @@ export function getHostedCheckoutUrl(opts = {}) {
1023
1023
  if (opts.intent) params.set('intent', String(opts.intent));
1024
1024
  if (opts.origin) params.set('origin', String(opts.origin));
1025
1025
  if (opts.oauthProvider) params.set('oauthProvider', String(opts.oauthProvider));
1026
+ if (opts.appId) params.set('appId', String(opts.appId));
1027
+ if (opts.billingWallet) params.set('billingWallet', String(opts.billingWallet).trim().toLowerCase());
1026
1028
  const qs = params.toString();
1027
1029
  return qs ? `${base}?${qs}` : base;
1028
1030
  }
package/widgets/README.md CHANGED
@@ -35,7 +35,7 @@ export function Page() {
35
35
  ```jsx
36
36
  import { ProofBadge } from '@neus/sdk/widgets';
37
37
 
38
- <ProofBadge qHash="0x..." showChains />
38
+ <ProofBadge qHash={proof.qHash} showChains />
39
39
  ```
40
40
 
41
41
  ## Docs