@opendatalabs/vana-sdk 2.2.1 → 2.2.2
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/dist/config/features.cjs +1 -24
- package/dist/config/features.cjs.map +1 -1
- package/dist/config/features.d.ts +13 -44
- package/dist/config/features.js +1 -24
- package/dist/config/features.js.map +1 -1
- package/dist/crypto/ecies/index.cjs.map +1 -1
- package/dist/crypto/ecies/index.d.ts +10 -2
- package/dist/crypto/ecies/index.js.map +1 -1
- package/dist/index.browser.d.ts +2 -0
- package/dist/index.browser.js +10 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +12 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +3 -0
- package/dist/index.node.js +12 -0
- package/dist/index.node.js.map +1 -1
- package/dist/platform/browser.cjs +40 -119
- package/dist/platform/browser.cjs.map +1 -1
- package/dist/platform/browser.d.ts +7 -7
- package/dist/platform/browser.js +40 -119
- package/dist/platform/browser.js.map +1 -1
- package/dist/platform/node.cjs +51 -129
- package/dist/platform/node.cjs.map +1 -1
- package/dist/platform/node.d.ts +5 -5
- package/dist/platform/node.js +51 -129
- package/dist/platform/node.js.map +1 -1
- package/package.json +1 -2
- package/dist/types/eccrypto-js.d.cjs +0 -2
- package/dist/types/eccrypto-js.d.cjs.map +0 -1
- package/dist/types/eccrypto-js.d.js +0 -1
- package/dist/types/eccrypto-js.d.js.map +0 -1
package/dist/config/features.cjs
CHANGED
|
@@ -21,30 +21,7 @@ __export(features_exports, {
|
|
|
21
21
|
features: () => features
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(features_exports);
|
|
24
|
-
const features = {
|
|
25
|
-
/**
|
|
26
|
-
* Use custom ECIES implementation instead of eccrypto
|
|
27
|
-
*
|
|
28
|
-
* When false (default): Uses the original eccrypto/eccrypto-js libraries for stability
|
|
29
|
-
* When true: Uses the custom platform-specific ECIES implementation
|
|
30
|
-
*
|
|
31
|
-
* Enable by setting environment variable: VANA_USE_CUSTOM_ECIES=true
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```bash
|
|
35
|
-
* # Use eccrypto-js (default)
|
|
36
|
-
* VANA_USE_CUSTOM_ECIES=false npm run your-app
|
|
37
|
-
*
|
|
38
|
-
* # Use custom ECIES implementation
|
|
39
|
-
* VANA_USE_CUSTOM_ECIES=true npm run your-app
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @returns Whether to use custom ECIES implementation
|
|
43
|
-
*/
|
|
44
|
-
get useCustomECIES() {
|
|
45
|
-
return process.env.VANA_USE_CUSTOM_ECIES === "true";
|
|
46
|
-
}
|
|
47
|
-
};
|
|
24
|
+
const features = {};
|
|
48
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
26
|
0 && (module.exports = {
|
|
50
27
|
features
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/features.ts"],"sourcesContent":["/**\n * Feature flags for the Vana SDK\n *\n * @remarks\n * This module controls feature toggles that allow switching between different\n * implementations or enabling experimental features.\n *\n * The getter pattern is used to allow dynamic evaluation of environment variables,\n * which is necessary for tests to override the default before modules are loaded.\n *\n * ##
|
|
1
|
+
{"version":3,"sources":["../../src/config/features.ts"],"sourcesContent":["/**\n * Feature flags for the Vana SDK\n *\n * @remarks\n * This module controls feature toggles that allow switching between different\n * implementations or enabling experimental features.\n *\n * The getter pattern is used to allow dynamic evaluation of environment variables,\n * which is necessary for tests to override the default before modules are loaded.\n *\n * ## ECIES Encryption\n *\n * The SDK uses a custom ECIES implementation:\n * - **Node.js**: Uses native `secp256k1` module for optimal performance\n * - **Browser**: Uses `@noble/secp256k1` (pure JavaScript)\n * - Fully compatible with eccrypto format for backward compatibility\n *\n * ### Architecture Notes\n * - Browser builds: Use `@noble/secp256k1` (no native dependencies)\n * - Node builds: Use native `secp256k1` when available for better performance\n * - `secp256k1`: Remains an `optionalDependency` so browser-only users don't face build issues\n * - All encrypted data is compatible with the eccrypto format specification\n */\n\n/**\n * Feature flag configuration\n *\n * @remarks\n * Currently empty as all feature flags have been graduated to default behavior.\n * This module is kept for future feature flag additions.\n */\nexport const features = {};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BO,MAAM,WAAW,CAAC;","names":[]}
|
|
@@ -8,55 +8,24 @@
|
|
|
8
8
|
* The getter pattern is used to allow dynamic evaluation of environment variables,
|
|
9
9
|
* which is necessary for tests to override the default before modules are loaded.
|
|
10
10
|
*
|
|
11
|
-
* ##
|
|
11
|
+
* ## ECIES Encryption
|
|
12
12
|
*
|
|
13
|
-
* The SDK
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* - Works everywhere (Node.js and browsers)
|
|
18
|
-
* - No native dependencies
|
|
19
|
-
* - Good performance for most use cases
|
|
20
|
-
*
|
|
21
|
-
* 2. **Custom ECIES** (Opt-in)
|
|
22
|
-
* - Uses native `secp256k1` module in Node.js for optimal performance
|
|
23
|
-
* - Uses `@noble/secp256k1` in browsers (pure JS)
|
|
24
|
-
* - Slightly faster in Node.js environments
|
|
25
|
-
* - Currently used by tests to ensure compatibility
|
|
13
|
+
* The SDK uses a custom ECIES implementation:
|
|
14
|
+
* - **Node.js**: Uses native `secp256k1` module for optimal performance
|
|
15
|
+
* - **Browser**: Uses `@noble/secp256k1` (pure JavaScript)
|
|
16
|
+
* - Fully compatible with eccrypto format for backward compatibility
|
|
26
17
|
*
|
|
27
18
|
* ### Architecture Notes
|
|
28
|
-
* - Browser builds:
|
|
29
|
-
* - Node builds:
|
|
19
|
+
* - Browser builds: Use `@noble/secp256k1` (no native dependencies)
|
|
20
|
+
* - Node builds: Use native `secp256k1` when available for better performance
|
|
30
21
|
* - `secp256k1`: Remains an `optionalDependency` so browser-only users don't face build issues
|
|
31
|
-
*
|
|
32
|
-
* ### Future Plans
|
|
33
|
-
* Once the custom ECIES implementation is battle-tested:
|
|
34
|
-
* 1. Make custom ECIES the default
|
|
35
|
-
* 2. Eventually remove eccrypto-js dependency
|
|
36
|
-
* 3. Keep the same architecture (native for Node, @noble for browser)
|
|
22
|
+
* - All encrypted data is compatible with the eccrypto format specification
|
|
37
23
|
*/
|
|
38
24
|
/**
|
|
39
25
|
* Feature flag configuration
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Currently empty as all feature flags have been graduated to default behavior.
|
|
29
|
+
* This module is kept for future feature flag additions.
|
|
40
30
|
*/
|
|
41
|
-
export declare const features: {
|
|
42
|
-
/**
|
|
43
|
-
* Use custom ECIES implementation instead of eccrypto
|
|
44
|
-
*
|
|
45
|
-
* When false (default): Uses the original eccrypto/eccrypto-js libraries for stability
|
|
46
|
-
* When true: Uses the custom platform-specific ECIES implementation
|
|
47
|
-
*
|
|
48
|
-
* Enable by setting environment variable: VANA_USE_CUSTOM_ECIES=true
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```bash
|
|
52
|
-
* # Use eccrypto-js (default)
|
|
53
|
-
* VANA_USE_CUSTOM_ECIES=false npm run your-app
|
|
54
|
-
*
|
|
55
|
-
* # Use custom ECIES implementation
|
|
56
|
-
* VANA_USE_CUSTOM_ECIES=true npm run your-app
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* @returns Whether to use custom ECIES implementation
|
|
60
|
-
*/
|
|
61
|
-
readonly useCustomECIES: boolean;
|
|
62
|
-
};
|
|
31
|
+
export declare const features: {};
|
package/dist/config/features.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
const features = {
|
|
2
|
-
/**
|
|
3
|
-
* Use custom ECIES implementation instead of eccrypto
|
|
4
|
-
*
|
|
5
|
-
* When false (default): Uses the original eccrypto/eccrypto-js libraries for stability
|
|
6
|
-
* When true: Uses the custom platform-specific ECIES implementation
|
|
7
|
-
*
|
|
8
|
-
* Enable by setting environment variable: VANA_USE_CUSTOM_ECIES=true
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```bash
|
|
12
|
-
* # Use eccrypto-js (default)
|
|
13
|
-
* VANA_USE_CUSTOM_ECIES=false npm run your-app
|
|
14
|
-
*
|
|
15
|
-
* # Use custom ECIES implementation
|
|
16
|
-
* VANA_USE_CUSTOM_ECIES=true npm run your-app
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @returns Whether to use custom ECIES implementation
|
|
20
|
-
*/
|
|
21
|
-
get useCustomECIES() {
|
|
22
|
-
return process.env.VANA_USE_CUSTOM_ECIES === "true";
|
|
23
|
-
}
|
|
24
|
-
};
|
|
1
|
+
const features = {};
|
|
25
2
|
export {
|
|
26
3
|
features
|
|
27
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/features.ts"],"sourcesContent":["/**\n * Feature flags for the Vana SDK\n *\n * @remarks\n * This module controls feature toggles that allow switching between different\n * implementations or enabling experimental features.\n *\n * The getter pattern is used to allow dynamic evaluation of environment variables,\n * which is necessary for tests to override the default before modules are loaded.\n *\n * ##
|
|
1
|
+
{"version":3,"sources":["../../src/config/features.ts"],"sourcesContent":["/**\n * Feature flags for the Vana SDK\n *\n * @remarks\n * This module controls feature toggles that allow switching between different\n * implementations or enabling experimental features.\n *\n * The getter pattern is used to allow dynamic evaluation of environment variables,\n * which is necessary for tests to override the default before modules are loaded.\n *\n * ## ECIES Encryption\n *\n * The SDK uses a custom ECIES implementation:\n * - **Node.js**: Uses native `secp256k1` module for optimal performance\n * - **Browser**: Uses `@noble/secp256k1` (pure JavaScript)\n * - Fully compatible with eccrypto format for backward compatibility\n *\n * ### Architecture Notes\n * - Browser builds: Use `@noble/secp256k1` (no native dependencies)\n * - Node builds: Use native `secp256k1` when available for better performance\n * - `secp256k1`: Remains an `optionalDependency` so browser-only users don't face build issues\n * - All encrypted data is compatible with the eccrypto format specification\n */\n\n/**\n * Feature flag configuration\n *\n * @remarks\n * Currently empty as all feature flags have been graduated to default behavior.\n * This module is kept for future feature flag additions.\n */\nexport const features = {};\n"],"mappings":"AA+BO,MAAM,WAAW,CAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/crypto/ecies/index.ts"],"sourcesContent":["/**\n * ECIES Module Entry Point\n *\n * Exports interface and utilities for ECIES encryption/decryption
|
|
1
|
+
{"version":3,"sources":["../../../src/crypto/ecies/index.ts"],"sourcesContent":["/**\n * ECIES Module Entry Point\n *\n * Exports interface and utilities for ECIES encryption/decryption.\n * Platform-specific implementations (BrowserECIESProvider, NodeECIESProvider)\n * are exported from the platform entry points.\n *\n * @remarks\n * Import from platform-specific entry points:\n * - Browser: `import { BrowserECIESProvider, serializeECIES } from '@opendatalabs/vana-sdk/browser'`\n * - Node: `import { NodeECIESProvider, serializeECIES } from '@opendatalabs/vana-sdk/node'`\n *\n * @category Cryptography\n */\n\nexport type { ECIESProvider, ECIESEncrypted, ECIESOptions } from \"./interface\";\n\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./interface\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,uBAKO;","names":[]}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ECIES Module Entry Point
|
|
3
3
|
*
|
|
4
|
-
* Exports interface and utilities for ECIES encryption/decryption
|
|
5
|
-
* Platform-specific implementations
|
|
4
|
+
* Exports interface and utilities for ECIES encryption/decryption.
|
|
5
|
+
* Platform-specific implementations (BrowserECIESProvider, NodeECIESProvider)
|
|
6
|
+
* are exported from the platform entry points.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Import from platform-specific entry points:
|
|
10
|
+
* - Browser: `import { BrowserECIESProvider, serializeECIES } from '@opendatalabs/vana-sdk/browser'`
|
|
11
|
+
* - Node: `import { NodeECIESProvider, serializeECIES } from '@opendatalabs/vana-sdk/node'`
|
|
12
|
+
*
|
|
13
|
+
* @category Cryptography
|
|
6
14
|
*/
|
|
7
15
|
export type { ECIESProvider, ECIESEncrypted, ECIESOptions } from "./interface";
|
|
8
16
|
export { ECIESError, isECIESEncrypted, serializeECIES, deserializeECIES, } from "./interface";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/crypto/ecies/index.ts"],"sourcesContent":["/**\n * ECIES Module Entry Point\n *\n * Exports interface and utilities for ECIES encryption/decryption
|
|
1
|
+
{"version":3,"sources":["../../../src/crypto/ecies/index.ts"],"sourcesContent":["/**\n * ECIES Module Entry Point\n *\n * Exports interface and utilities for ECIES encryption/decryption.\n * Platform-specific implementations (BrowserECIESProvider, NodeECIESProvider)\n * are exported from the platform entry points.\n *\n * @remarks\n * Import from platform-specific entry points:\n * - Browser: `import { BrowserECIESProvider, serializeECIES } from '@opendatalabs/vana-sdk/browser'`\n * - Node: `import { NodeECIESProvider, serializeECIES } from '@opendatalabs/vana-sdk/node'`\n *\n * @category Cryptography\n */\n\nexport type { ECIESProvider, ECIESEncrypted, ECIESOptions } from \"./interface\";\n\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./interface\";\n"],"mappings":"AAiBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -147,6 +147,8 @@ export { BaseController, RetryUtility, RateLimiter, MemoryCache, EventEmitter, M
|
|
|
147
147
|
export { BrowserPlatformAdapter } from "./platform/browser";
|
|
148
148
|
export { BrowserECIESUint8Provider as BrowserECIESProvider } from "./crypto/ecies/browser";
|
|
149
149
|
export type { VanaPlatformAdapter } from "./platform/interface";
|
|
150
|
+
export { ECIESError, isECIESEncrypted, serializeECIES, deserializeECIES, } from "./crypto/ecies";
|
|
151
|
+
export type { ECIESProvider, ECIESEncrypted, ECIESOptions, } from "./crypto/ecies";
|
|
150
152
|
export { createBrowserPlatformAdapter, createPlatformAdapterSafe, } from "./platform/browser-only";
|
|
151
153
|
export { detectPlatform, isPlatformSupported, getPlatformCapabilities, } from "./platform/utils";
|
|
152
154
|
export { ApiClient } from "./core/apiClient";
|
package/dist/index.browser.js
CHANGED
|
@@ -67,6 +67,12 @@ import {
|
|
|
67
67
|
} from "./core/generics";
|
|
68
68
|
import { BrowserPlatformAdapter as BrowserPlatformAdapter2 } from "./platform/browser";
|
|
69
69
|
import { BrowserECIESUint8Provider } from "./crypto/ecies/browser";
|
|
70
|
+
import {
|
|
71
|
+
ECIESError,
|
|
72
|
+
isECIESEncrypted,
|
|
73
|
+
serializeECIES,
|
|
74
|
+
deserializeECIES
|
|
75
|
+
} from "./crypto/ecies";
|
|
70
76
|
import {
|
|
71
77
|
createBrowserPlatformAdapter,
|
|
72
78
|
createPlatformAdapterSafe
|
|
@@ -86,6 +92,7 @@ export {
|
|
|
86
92
|
CONTRACTS,
|
|
87
93
|
CircuitBreaker,
|
|
88
94
|
DataController,
|
|
95
|
+
ECIESError,
|
|
89
96
|
EnhancedTransactionResponse,
|
|
90
97
|
EventEmitter,
|
|
91
98
|
MemoryCache,
|
|
@@ -106,6 +113,7 @@ export {
|
|
|
106
113
|
createBrowserPlatformAdapter,
|
|
107
114
|
createPlatformAdapterSafe,
|
|
108
115
|
index_browser_default as default,
|
|
116
|
+
deserializeECIES,
|
|
109
117
|
detectPlatform,
|
|
110
118
|
enhanceResponse,
|
|
111
119
|
getAbi,
|
|
@@ -116,6 +124,7 @@ export {
|
|
|
116
124
|
getPlatformCapabilities,
|
|
117
125
|
getServiceEndpoints,
|
|
118
126
|
isAPIResponse,
|
|
127
|
+
isECIESEncrypted,
|
|
119
128
|
isPlatformSupported,
|
|
120
129
|
isReplicateAPIResponse,
|
|
121
130
|
mainnetServices,
|
|
@@ -124,6 +133,7 @@ export {
|
|
|
124
133
|
mokshaTestnet,
|
|
125
134
|
parseReplicateOutput,
|
|
126
135
|
safeParseJSON,
|
|
136
|
+
serializeECIES,
|
|
127
137
|
vanaMainnet
|
|
128
138
|
};
|
|
129
139
|
//# sourceMappingURL=index.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.browser.ts"],"sourcesContent":["/**\n * @module Browser\n * Browser-specific implementation of the Vana SDK\n */\n\nimport { BrowserPlatformAdapter } from \"./platform/browser\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n} from \"./types\";\n\n/**\n * Internal implementation class for browser environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaBrowserImpl extends VanaCore {\n constructor(config: VanaConfig) {\n super(new BrowserPlatformAdapter(), config);\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for browser environments.\n *\n * @remarks\n * This is the primary entry point for browser applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The SDK supports multiple wallet configurations (direct WalletClient or chain config),\n * various storage providers (IPFS, Pinata, Google Drive), and gasless transactions via relayers.\n * All operations are optimized for browser environments with proper bundle size optimization.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for browser use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/browser';\n * import { createWalletClient, custom } from 'viem';\n * import { IPFSStorage } from '@opendatalabs/vana-sdk/browser';\n *\n * // Complete setup with storage and wallet\n * const walletClient = createWalletClient({\n * chain: mokshaTestnet,\n * transport: custom(window.ethereum)\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' }),\n * pinata: new PinataStorage({ apiKey: process.env.PINATA_KEY })\n * },\n * defaultProvider: 'ipfs'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * const response = await fetch('/api/relay/grant', {\n * method: 'POST',\n * body: JSON.stringify({ typedData, signature })\n * });\n * return (await response.json()).transactionHash;\n * }\n * }\n * });\n *\n * // All operations now available\n * const files = await vana.data.getUserFiles();\n * const permissions = await vana.permissions.getUserPermissions();\n * await vana.data.upload({ content: 'My data', filename: 'data.txt' });\n * ```\n *\n * @example\n * ```typescript\n * // Minimal setup without storage (read-only operations)\n * const vanaReadOnly = Vana({ walletClient });\n *\n * // These work without storage\n * const files = await vanaReadOnly.data.getUserFiles();\n * const permissions = await vanaReadOnly.permissions.getUserPermissions();\n *\n * // This would throw a runtime error\n * // await vanaReadOnly.data.upload(params); // ❌ InvalidConfigurationError\n *\n * // Safe runtime check\n * if (vanaReadOnly.isStorageEnabled()) {\n * await vanaReadOnly.data.upload(params); // ✅ TypeScript allows this\n * } else {\n * console.log('Storage not configured - upload unavailable');\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Using chain configuration instead of wallet client\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',\n * rpcUrl: 'https://rpc.moksha.vana.org',\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/getting-started | Getting Started Guide} for setup tutorials\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\nexport function Vana(\n config: VanaConfigWithStorage,\n): VanaBrowserImpl & StorageRequiredMarker;\nexport function Vana(config: VanaConfig): VanaBrowserImpl;\n/**\n * Creates a new Vana SDK instance.\n *\n * @param config - The configuration for the Vana SDK\n * @returns A new Vana SDK instance\n */\nexport function Vana(config: VanaConfig) {\n return new VanaBrowserImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in browser environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaBrowserImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\n\n// Types - modular exports\nexport type * from \"./types\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Platform adapters - browser-safe exports\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { BrowserECIESUint8Provider as BrowserECIESProvider } from \"./crypto/ecies/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Browser-only platform adapter utilities\nexport {\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-only\";\n\n// Note: createNodePlatformAdapter is not exported in browser bundle to avoid Node.js dependencies\n\n// NodePlatformAdapter is available through dynamic import to avoid bundling Node.js dependencies\n// Use createNodePlatformAdapter() for dynamic import\n\n// Platform utilities - browser-safe only\nexport {\n detectPlatform,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n\n// For testing purposes, we also export the implementation class\nexport { VanaBrowserImpl };\n"],"mappings":"AAKA,SAAS,8BAA8B;AACvC,SAAS,gBAAgB;AAWzB,MAAM,wBAAwB,SAAS;AAAA,EACrC,YAAY,QAAoB;AAC9B,UAAM,IAAI,uBAAuB,GAAG,MAAM;AAAA,EAC5C;AACF;AAwGO,SAAS,KAAK,QAAoB;AACvC,SAAO,IAAI,gBAAgB,MAAM;AACnC;AAWA,IAAO,wBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAM1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAGrC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAWd,cAAc;AAGd,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,0BAAAC,+BAA8B;AACvC,SAAsC,iCAA4B;AAIlE;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","BrowserPlatformAdapter"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.browser.ts"],"sourcesContent":["/**\n * @module Browser\n * Browser-specific implementation of the Vana SDK\n */\n\nimport { BrowserPlatformAdapter } from \"./platform/browser\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n} from \"./types\";\n\n/**\n * Internal implementation class for browser environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaBrowserImpl extends VanaCore {\n constructor(config: VanaConfig) {\n super(new BrowserPlatformAdapter(), config);\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for browser environments.\n *\n * @remarks\n * This is the primary entry point for browser applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The SDK supports multiple wallet configurations (direct WalletClient or chain config),\n * various storage providers (IPFS, Pinata, Google Drive), and gasless transactions via relayers.\n * All operations are optimized for browser environments with proper bundle size optimization.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for browser use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/browser';\n * import { createWalletClient, custom } from 'viem';\n * import { IPFSStorage } from '@opendatalabs/vana-sdk/browser';\n *\n * // Complete setup with storage and wallet\n * const walletClient = createWalletClient({\n * chain: mokshaTestnet,\n * transport: custom(window.ethereum)\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' }),\n * pinata: new PinataStorage({ apiKey: process.env.PINATA_KEY })\n * },\n * defaultProvider: 'ipfs'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * const response = await fetch('/api/relay/grant', {\n * method: 'POST',\n * body: JSON.stringify({ typedData, signature })\n * });\n * return (await response.json()).transactionHash;\n * }\n * }\n * });\n *\n * // All operations now available\n * const files = await vana.data.getUserFiles();\n * const permissions = await vana.permissions.getUserPermissions();\n * await vana.data.upload({ content: 'My data', filename: 'data.txt' });\n * ```\n *\n * @example\n * ```typescript\n * // Minimal setup without storage (read-only operations)\n * const vanaReadOnly = Vana({ walletClient });\n *\n * // These work without storage\n * const files = await vanaReadOnly.data.getUserFiles();\n * const permissions = await vanaReadOnly.permissions.getUserPermissions();\n *\n * // This would throw a runtime error\n * // await vanaReadOnly.data.upload(params); // ❌ InvalidConfigurationError\n *\n * // Safe runtime check\n * if (vanaReadOnly.isStorageEnabled()) {\n * await vanaReadOnly.data.upload(params); // ✅ TypeScript allows this\n * } else {\n * console.log('Storage not configured - upload unavailable');\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Using chain configuration instead of wallet client\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',\n * rpcUrl: 'https://rpc.moksha.vana.org',\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/getting-started | Getting Started Guide} for setup tutorials\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\nexport function Vana(\n config: VanaConfigWithStorage,\n): VanaBrowserImpl & StorageRequiredMarker;\nexport function Vana(config: VanaConfig): VanaBrowserImpl;\n/**\n * Creates a new Vana SDK instance.\n *\n * @param config - The configuration for the Vana SDK\n * @returns A new Vana SDK instance\n */\nexport function Vana(config: VanaConfig) {\n return new VanaBrowserImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in browser environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaBrowserImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\n\n// Types - modular exports\nexport type * from \"./types\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Platform adapters - browser-safe exports\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { BrowserECIESUint8Provider as BrowserECIESProvider } from \"./crypto/ecies/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// ECIES utilities and types (exported via module index for consistency)\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./crypto/ecies\";\nexport type {\n ECIESProvider,\n ECIESEncrypted,\n ECIESOptions,\n} from \"./crypto/ecies\";\n\n// Browser-only platform adapter utilities\nexport {\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-only\";\n\n// Note: createNodePlatformAdapter is not exported in browser bundle to avoid Node.js dependencies\n\n// NodePlatformAdapter is available through dynamic import to avoid bundling Node.js dependencies\n// Use createNodePlatformAdapter() for dynamic import\n\n// Platform utilities - browser-safe only\nexport {\n detectPlatform,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n\n// For testing purposes, we also export the implementation class\nexport { VanaBrowserImpl };\n"],"mappings":"AAKA,SAAS,8BAA8B;AACvC,SAAS,gBAAgB;AAWzB,MAAM,wBAAwB,SAAS;AAAA,EACrC,YAAY,QAAoB;AAC9B,UAAM,IAAI,uBAAuB,GAAG,MAAM;AAAA,EAC5C;AACF;AAwGO,SAAS,KAAK,QAAoB;AACvC,SAAO,IAAI,gBAAgB,MAAM;AACnC;AAWA,IAAO,wBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAM1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAGrC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAWd,cAAc;AAGd,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,0BAAAC,+BAA8B;AACvC,SAAsC,iCAA4B;AAIlE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","BrowserPlatformAdapter"]}
|
package/dist/index.node.cjs
CHANGED
|
@@ -27,11 +27,13 @@ __export(index_node_exports, {
|
|
|
27
27
|
CircuitBreaker: () => import_generics.CircuitBreaker,
|
|
28
28
|
DataController: () => import_data.DataController,
|
|
29
29
|
DistributedNonceManager: () => import_nonceManager.DistributedNonceManager,
|
|
30
|
+
ECIESError: () => import_ecies.ECIESError,
|
|
30
31
|
EnhancedTransactionResponse: () => import_enhancedResponse.EnhancedTransactionResponse,
|
|
31
32
|
EventEmitter: () => import_generics.EventEmitter,
|
|
32
33
|
InMemoryNonceManager: () => import_inMemoryNonceManager.InMemoryNonceManager,
|
|
33
34
|
MemoryCache: () => import_generics.MemoryCache,
|
|
34
35
|
MiddlewarePipeline: () => import_generics.MiddlewarePipeline,
|
|
36
|
+
NodeECIESProvider: () => import_node3.NodeECIESUint8Provider,
|
|
35
37
|
NodePlatformAdapter: () => import_node2.NodePlatformAdapter,
|
|
36
38
|
OperationsController: () => import_operations.OperationsController,
|
|
37
39
|
PermissionsController: () => import_permissions.PermissionsController,
|
|
@@ -54,6 +56,7 @@ __export(index_node_exports, {
|
|
|
54
56
|
createPlatformAdapterFor: () => import_utils.createPlatformAdapterFor,
|
|
55
57
|
createPlatformAdapterSafe: () => import_browser_safe.createPlatformAdapterSafe,
|
|
56
58
|
default: () => index_node_default,
|
|
59
|
+
deserializeECIES: () => import_ecies.deserializeECIES,
|
|
57
60
|
detectPlatform: () => import_utils.detectPlatform,
|
|
58
61
|
enhanceResponse: () => import_enhancedResponse.enhanceResponse,
|
|
59
62
|
getAbi: () => import_abi.getAbi,
|
|
@@ -65,6 +68,7 @@ __export(index_node_exports, {
|
|
|
65
68
|
getServiceEndpoints: () => import_default_services.getServiceEndpoints,
|
|
66
69
|
handleRelayerOperation: () => import_relayerHandler.handleRelayerOperation,
|
|
67
70
|
isAPIResponse: () => import_external_apis.isAPIResponse,
|
|
71
|
+
isECIESEncrypted: () => import_ecies.isECIESEncrypted,
|
|
68
72
|
isPlatformSupported: () => import_utils.isPlatformSupported,
|
|
69
73
|
isReplicateAPIResponse: () => import_external_apis.isReplicateAPIResponse,
|
|
70
74
|
mainnetServices: () => import_default_services.mainnetServices,
|
|
@@ -73,6 +77,7 @@ __export(index_node_exports, {
|
|
|
73
77
|
mokshaTestnet: () => import_chains2.mokshaTestnet,
|
|
74
78
|
parseReplicateOutput: () => import_external_apis.parseReplicateOutput,
|
|
75
79
|
safeParseJSON: () => import_external_apis.safeParseJSON,
|
|
80
|
+
serializeECIES: () => import_ecies.serializeECIES,
|
|
76
81
|
vanaMainnet: () => import_chains2.vanaMainnet
|
|
77
82
|
});
|
|
78
83
|
module.exports = __toCommonJS(index_node_exports);
|
|
@@ -112,6 +117,8 @@ var import_generics = require("./core/generics");
|
|
|
112
117
|
var import_relayerHandler = require("./server/relayerHandler");
|
|
113
118
|
var import_node2 = require("./platform/node");
|
|
114
119
|
var import_browser = require("./platform/browser");
|
|
120
|
+
var import_node3 = require("./crypto/ecies/node");
|
|
121
|
+
var import_ecies = require("./crypto/ecies");
|
|
115
122
|
var import_utils = require("./platform/utils");
|
|
116
123
|
var import_browser_safe = require("./platform/browser-safe");
|
|
117
124
|
var import_apiClient = require("./core/apiClient");
|
|
@@ -138,11 +145,13 @@ var index_node_default = Vana;
|
|
|
138
145
|
CircuitBreaker,
|
|
139
146
|
DataController,
|
|
140
147
|
DistributedNonceManager,
|
|
148
|
+
ECIESError,
|
|
141
149
|
EnhancedTransactionResponse,
|
|
142
150
|
EventEmitter,
|
|
143
151
|
InMemoryNonceManager,
|
|
144
152
|
MemoryCache,
|
|
145
153
|
MiddlewarePipeline,
|
|
154
|
+
NodeECIESProvider,
|
|
146
155
|
NodePlatformAdapter,
|
|
147
156
|
OperationsController,
|
|
148
157
|
PermissionsController,
|
|
@@ -164,6 +173,7 @@ var index_node_default = Vana;
|
|
|
164
173
|
createPlatformAdapter,
|
|
165
174
|
createPlatformAdapterFor,
|
|
166
175
|
createPlatformAdapterSafe,
|
|
176
|
+
deserializeECIES,
|
|
167
177
|
detectPlatform,
|
|
168
178
|
enhanceResponse,
|
|
169
179
|
getAbi,
|
|
@@ -175,6 +185,7 @@ var index_node_default = Vana;
|
|
|
175
185
|
getServiceEndpoints,
|
|
176
186
|
handleRelayerOperation,
|
|
177
187
|
isAPIResponse,
|
|
188
|
+
isECIESEncrypted,
|
|
178
189
|
isPlatformSupported,
|
|
179
190
|
isReplicateAPIResponse,
|
|
180
191
|
mainnetServices,
|
|
@@ -183,6 +194,7 @@ var index_node_default = Vana;
|
|
|
183
194
|
mokshaTestnet,
|
|
184
195
|
parseReplicateOutput,
|
|
185
196
|
safeParseJSON,
|
|
197
|
+
serializeECIES,
|
|
186
198
|
vanaMainnet,
|
|
187
199
|
...require("./errors"),
|
|
188
200
|
...require("./contracts/contractController"),
|
package/dist/index.node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,kBAAoC;AACpC,kBAAyB;AA2MzB,IAAAA,eAA0C;AAC1C,0BAAwC;AACxC,kCAAqC;AACrC,oBAAoC;AAUpC,8BAAiC;AAcjC,2BAKO;AAMP,8BAIO;AAGP,+BAAc,qBA9Pd;AAiQA,yBAAsC;AACtC,kBAA+B;AAC/B,oBAAiC;AACjC,sBAAmC;AACnC,qBAAiC;AACjC,wBAAqC;AAGrC,+BAAc,2CAzQd;AA4QA,+BAAc,+BA5Qd;AA6QA,+BAAc,+BA7Qd;AA8QA,+BAAc,+BA9Qd;AA+QA,+BAAc,oCA/Qd;AAgRA,+BAAc,2BAhRd;AAiRA,+BAAc,yBAjRd;AAkRA,+BAAc,qCAlRd;AAmRA,+BAAc,mCAnRd;AAsRA,+BAAc,sBAtRd;AAyRA,uBAA8C;AAC9C,oBAAuB;AACvB,8BAMO;AAGP,IAAAC,iBAOO;AACP,+BAAc,qBA5Sd;AA+SA,iBAAuB;AAIvB,sBASO;AAGP,4BAGO;AAeP,IAAAC,eAAoC;AACpC,qBAAuC;AAIvC,mBAMO;AAGP,0BAIO;AAEP,uBAA0B;AAzT1B,MAAM,qBAAqB,qBAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,gCAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;","names":["import_core","import_chains","import_node"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { NodeECIESUint8Provider as NodeECIESProvider } from \"./crypto/ecies/node\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// ECIES utilities and types (platform-agnostic, exported via module index)\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./crypto/ecies\";\nexport type {\n ECIESProvider,\n ECIESEncrypted,\n ECIESOptions,\n} from \"./crypto/ecies\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,kBAAoC;AACpC,kBAAyB;AA2MzB,IAAAA,eAA0C;AAC1C,0BAAwC;AACxC,kCAAqC;AACrC,oBAAoC;AAUpC,8BAAiC;AAcjC,2BAKO;AAMP,8BAIO;AAGP,+BAAc,qBA9Pd;AAiQA,yBAAsC;AACtC,kBAA+B;AAC/B,oBAAiC;AACjC,sBAAmC;AACnC,qBAAiC;AACjC,wBAAqC;AAGrC,+BAAc,2CAzQd;AA4QA,+BAAc,+BA5Qd;AA6QA,+BAAc,+BA7Qd;AA8QA,+BAAc,+BA9Qd;AA+QA,+BAAc,oCA/Qd;AAgRA,+BAAc,2BAhRd;AAiRA,+BAAc,yBAjRd;AAkRA,+BAAc,qCAlRd;AAmRA,+BAAc,mCAnRd;AAsRA,+BAAc,sBAtRd;AAyRA,uBAA8C;AAC9C,oBAAuB;AACvB,8BAMO;AAGP,IAAAC,iBAOO;AACP,+BAAc,qBA5Sd;AA+SA,iBAAuB;AAIvB,sBASO;AAGP,4BAGO;AAeP,IAAAC,eAAoC;AACpC,qBAAuC;AACvC,IAAAA,eAA4D;AAI5D,mBAKO;AAQP,mBAMO;AAGP,0BAIO;AAEP,uBAA0B;AAvU1B,MAAM,qBAAqB,qBAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,gCAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;","names":["import_core","import_chains","import_node"]}
|
package/dist/index.node.d.ts
CHANGED
|
@@ -211,7 +211,10 @@ export type { UnifiedRelayerRequest, UnifiedRelayerResponse, } from "./types/rel
|
|
|
211
211
|
export type { Operation, TransactionResult, TransactionReceipt, PollingOptions, TransactionWaitOptions, } from "./types/operations";
|
|
212
212
|
export { NodePlatformAdapter } from "./platform/node";
|
|
213
213
|
export { BrowserPlatformAdapter } from "./platform/browser";
|
|
214
|
+
export { NodeECIESUint8Provider as NodeECIESProvider } from "./crypto/ecies/node";
|
|
214
215
|
export type { VanaPlatformAdapter } from "./platform/interface";
|
|
216
|
+
export { ECIESError, isECIESEncrypted, serializeECIES, deserializeECIES, } from "./crypto/ecies";
|
|
217
|
+
export type { ECIESProvider, ECIESEncrypted, ECIESOptions, } from "./crypto/ecies";
|
|
215
218
|
export { detectPlatform, createPlatformAdapter, createPlatformAdapterFor, isPlatformSupported, getPlatformCapabilities, } from "./platform/utils";
|
|
216
219
|
export { createNodePlatformAdapter, createBrowserPlatformAdapter, createPlatformAdapterSafe, } from "./platform/browser-safe";
|
|
217
220
|
export { ApiClient } from "./core/apiClient";
|
package/dist/index.node.js
CHANGED
|
@@ -78,6 +78,13 @@ import {
|
|
|
78
78
|
} from "./server/relayerHandler";
|
|
79
79
|
import { NodePlatformAdapter as NodePlatformAdapter2 } from "./platform/node";
|
|
80
80
|
import { BrowserPlatformAdapter } from "./platform/browser";
|
|
81
|
+
import { NodeECIESUint8Provider } from "./crypto/ecies/node";
|
|
82
|
+
import {
|
|
83
|
+
ECIESError,
|
|
84
|
+
isECIESEncrypted,
|
|
85
|
+
serializeECIES,
|
|
86
|
+
deserializeECIES
|
|
87
|
+
} from "./crypto/ecies";
|
|
81
88
|
import {
|
|
82
89
|
detectPlatform,
|
|
83
90
|
createPlatformAdapter,
|
|
@@ -100,11 +107,13 @@ export {
|
|
|
100
107
|
CircuitBreaker,
|
|
101
108
|
DataController,
|
|
102
109
|
DistributedNonceManager,
|
|
110
|
+
ECIESError,
|
|
103
111
|
EnhancedTransactionResponse,
|
|
104
112
|
EventEmitter,
|
|
105
113
|
InMemoryNonceManager,
|
|
106
114
|
MemoryCache,
|
|
107
115
|
MiddlewarePipeline,
|
|
116
|
+
NodeECIESUint8Provider as NodeECIESProvider,
|
|
108
117
|
NodePlatformAdapter2 as NodePlatformAdapter,
|
|
109
118
|
OperationsController,
|
|
110
119
|
PermissionsController,
|
|
@@ -127,6 +136,7 @@ export {
|
|
|
127
136
|
createPlatformAdapterFor,
|
|
128
137
|
createPlatformAdapterSafe,
|
|
129
138
|
index_node_default as default,
|
|
139
|
+
deserializeECIES,
|
|
130
140
|
detectPlatform,
|
|
131
141
|
enhanceResponse,
|
|
132
142
|
getAbi,
|
|
@@ -138,6 +148,7 @@ export {
|
|
|
138
148
|
getServiceEndpoints,
|
|
139
149
|
handleRelayerOperation,
|
|
140
150
|
isAPIResponse,
|
|
151
|
+
isECIESEncrypted,
|
|
141
152
|
isPlatformSupported,
|
|
142
153
|
isReplicateAPIResponse,
|
|
143
154
|
mainnetServices,
|
|
@@ -146,6 +157,7 @@ export {
|
|
|
146
157
|
mokshaTestnet,
|
|
147
158
|
parseReplicateOutput,
|
|
148
159
|
safeParseJSON,
|
|
160
|
+
serializeECIES,
|
|
149
161
|
vanaMainnet
|
|
150
162
|
};
|
|
151
163
|
//# sourceMappingURL=index.node.js.map
|
package/dist/index.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":"AAKA,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AAsCzB,MAAM,qBAAqB,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,oBAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAC1C,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AAUpC,SAAS,wBAAwB;AAcjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAGrC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,OAEK;AAeP,SAAS,uBAAAC,4BAA2B;AACpC,SAAS,8BAA8B;AAIvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","NodePlatformAdapter"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { NodeECIESUint8Provider as NodeECIESProvider } from \"./crypto/ecies/node\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// ECIES utilities and types (platform-agnostic, exported via module index)\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./crypto/ecies\";\nexport type {\n ECIESProvider,\n ECIESEncrypted,\n ECIESOptions,\n} from \"./crypto/ecies\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":"AAKA,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AAsCzB,MAAM,qBAAqB,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,oBAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAC1C,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AAUpC,SAAS,wBAAwB;AAcjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAGrC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,OAEK;AAeP,SAAS,uBAAAC,4BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAmC,8BAAyB;AAI5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","NodePlatformAdapter"]}
|