@opendatalabs/vana-sdk 0.1.0-alpha.5f8458e → 0.1.0-alpha.606fa2d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -4
- package/dist/{browser-cRpdLQ3-.d.ts → browser-Bb8gLWHp.d.ts} +61 -10
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +745 -113
- package/dist/browser.js.map +1 -1
- package/dist/chains.browser.cjs +2 -2
- package/dist/chains.browser.cjs.map +1 -1
- package/dist/chains.browser.js +2 -2
- package/dist/chains.browser.js.map +1 -1
- package/dist/chains.cjs +2 -2
- package/dist/chains.cjs.map +1 -1
- package/dist/chains.js +2 -2
- package/dist/chains.js.map +1 -1
- package/dist/chains.node.cjs +2 -2
- package/dist/chains.node.cjs.map +1 -1
- package/dist/chains.node.js +2 -2
- package/dist/chains.node.js.map +1 -1
- package/dist/index.browser.d.ts +1348 -243
- package/dist/index.browser.js +35080 -32770
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +35587 -33174
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +1136 -250
- package/dist/index.node.d.ts +1136 -250
- package/dist/index.node.js +35459 -33037
- package/dist/index.node.js.map +1 -1
- package/dist/{node-CkdgwBiv.d.cts → node-D9-F9uEP.d.cts} +3 -2
- package/dist/{node-CkdgwBiv.d.ts → node-D9-F9uEP.d.ts} +3 -2
- package/dist/node.cjs +704 -67
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +716 -66
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.d.ts +2 -2
- package/dist/platform.browser.js +808 -121
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.cjs +973 -186
- package/dist/platform.cjs.map +1 -1
- package/dist/platform.d.cts +1 -1
- package/dist/platform.d.ts +1 -1
- package/dist/platform.js +985 -186
- package/dist/platform.js.map +1 -1
- package/dist/platform.node.cjs +973 -186
- package/dist/platform.node.cjs.map +1 -1
- package/dist/platform.node.d.cts +63 -12
- package/dist/platform.node.d.ts +63 -12
- package/dist/platform.node.js +985 -186
- package/dist/platform.node.js.map +1 -1
- package/package.json +40 -23
package/README.md
CHANGED
|
@@ -28,12 +28,19 @@ npm install viem@^2.31.7
|
|
|
28
28
|
|
|
29
29
|
## Quick Start
|
|
30
30
|
|
|
31
|
-
The Vana SDK
|
|
31
|
+
The Vana SDK provides optimized builds for different environments:
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
| Build | Use Case | Crypto Implementation | Configuration |
|
|
34
|
+
| -------------- | --------------------------------- | ---------------------------------- | ----------------- |
|
|
35
|
+
| **`/browser`** | Browser apps (React, Vue) | Pure JavaScript (@noble/secp256k1) | **Zero config** ✓ |
|
|
36
|
+
| **`/node`** | Server-side (Node.js, API routes) | Native bindings (secp256k1) | Zero config ✓ |
|
|
37
|
+
|
|
38
|
+
### Browser Applications
|
|
39
|
+
|
|
40
|
+
The browser build uses pure JavaScript cryptography and requires **no special configuration**:
|
|
34
41
|
|
|
35
42
|
```typescript
|
|
36
|
-
//
|
|
43
|
+
// Browser build - works out of the box with any bundler
|
|
37
44
|
import { Vana, mokshaTestnet } from "@opendatalabs/vana-sdk/browser";
|
|
38
45
|
import { createWalletClient, http } from "viem";
|
|
39
46
|
import { privateKeyToAccount } from "viem/accounts";
|
|
@@ -53,7 +60,9 @@ const vana = Vana({
|
|
|
53
60
|
});
|
|
54
61
|
```
|
|
55
62
|
|
|
56
|
-
### Server-side Applications (
|
|
63
|
+
### Server-side Applications (Node.js)
|
|
64
|
+
|
|
65
|
+
The Node.js build uses native secp256k1 bindings for optimal performance:
|
|
57
66
|
|
|
58
67
|
```typescript
|
|
59
68
|
// For server-side applications (Next.js API routes, Express)
|
|
@@ -360,6 +369,48 @@ vana.data.validateDataAgainstSchema(data: unknown, schema: DataSchema): void
|
|
|
360
369
|
- **Issues**: [GitHub Issues](https://github.com/vana-com/vana-sdk/issues)
|
|
361
370
|
- **Discord**: [Join our community](https://discord.gg/vanabuilders)
|
|
362
371
|
|
|
372
|
+
## Generated Code
|
|
373
|
+
|
|
374
|
+
The SDK includes automatically generated code from various sources to provide type-safe interfaces. All generated files are located in `src/generated/` and should **never be edited manually**.
|
|
375
|
+
|
|
376
|
+
### Code Generation Scripts
|
|
377
|
+
|
|
378
|
+
| Script | Purpose | Generated Files |
|
|
379
|
+
| ---------------------------- | -------------------------------------- | --------------------------- |
|
|
380
|
+
| `npm run fetch-abis` | Smart contract ABIs from blockchain | `src/generated/abi/*.ts` |
|
|
381
|
+
| `npm run fetch-server-types` | Personal server API types from OpenAPI | `src/generated/server/*.ts` |
|
|
382
|
+
| `npm run codegen:subgraph` | GraphQL types from subgraph schema | `src/generated/subgraph.ts` |
|
|
383
|
+
|
|
384
|
+
### Network-Specific Generation
|
|
385
|
+
|
|
386
|
+
Some generation scripts support different networks:
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
# Generate subgraph types for different networks
|
|
390
|
+
npm run codegen:subgraph:moksha # Moksha testnet (default)
|
|
391
|
+
npm run codegen:subgraph:mainnet # Vana mainnet
|
|
392
|
+
|
|
393
|
+
# Generate ABIs for different networks
|
|
394
|
+
npm run fetch-abis moksha # Moksha testnet (default)
|
|
395
|
+
npm run fetch-abis mainnet # Vana mainnet
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Development Workflow
|
|
399
|
+
|
|
400
|
+
When working with the SDK:
|
|
401
|
+
|
|
402
|
+
1. **Never edit generated files** - They are overwritten on regeneration
|
|
403
|
+
2. **Regenerate after schema changes** - Run generation scripts when external schemas change
|
|
404
|
+
3. **Generated files are committed** - They're included in version control for consistency
|
|
405
|
+
4. **ESLint ignores generated code** - Style rules don't apply to generated files
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
# Regenerate all code after schema updates
|
|
409
|
+
npm run fetch-abis
|
|
410
|
+
npm run fetch-server-types
|
|
411
|
+
npm run codegen:subgraph
|
|
412
|
+
```
|
|
413
|
+
|
|
363
414
|
## Development
|
|
364
415
|
|
|
365
416
|
```bash
|
|
@@ -216,22 +216,73 @@ interface VanaPlatformAdapter {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
/**
|
|
219
|
-
* Browser implementation of the Vana Platform Adapter
|
|
219
|
+
* Browser implementation of the Vana Platform Adapter using Uint8Array
|
|
220
220
|
*
|
|
221
|
-
* This implementation uses browser-compatible libraries and
|
|
222
|
-
*
|
|
221
|
+
* This implementation uses browser-compatible libraries and native APIs
|
|
222
|
+
* without requiring Buffer or other Node.js polyfills.
|
|
223
223
|
*/
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
|
-
*
|
|
226
|
+
* Browser implementation of crypto operations using Uint8Array
|
|
227
|
+
*/
|
|
228
|
+
declare class BrowserCryptoAdapter implements VanaCryptoAdapter {
|
|
229
|
+
private eciesProvider;
|
|
230
|
+
private walletKeyEncryptionService;
|
|
231
|
+
encryptWithPublicKey(data: string, publicKeyHex: string): Promise<string>;
|
|
232
|
+
decryptWithPrivateKey(encryptedData: string, privateKeyHex: string): Promise<string>;
|
|
233
|
+
encryptWithWalletPublicKey(data: string, publicKey: string): Promise<string>;
|
|
234
|
+
decryptWithWalletPrivateKey(encryptedData: string, privateKey: string): Promise<string>;
|
|
235
|
+
generateKeyPair(): Promise<{
|
|
236
|
+
privateKey: string;
|
|
237
|
+
publicKey: string;
|
|
238
|
+
}>;
|
|
239
|
+
encryptWithPassword(data: Uint8Array, password: string): Promise<Uint8Array>;
|
|
240
|
+
decryptWithPassword(encryptedData: Uint8Array, password: string): Promise<Uint8Array>;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Browser implementation of PGP operations
|
|
244
|
+
*/
|
|
245
|
+
declare class BrowserPGPAdapter implements VanaPGPAdapter {
|
|
246
|
+
encrypt(data: string, publicKeyArmored: string): Promise<string>;
|
|
247
|
+
decrypt(encryptedData: string, privateKeyArmored: string): Promise<string>;
|
|
248
|
+
generateKeyPair(options?: {
|
|
249
|
+
name?: string;
|
|
250
|
+
email?: string;
|
|
251
|
+
passphrase?: string;
|
|
252
|
+
}): Promise<{
|
|
253
|
+
publicKey: string;
|
|
254
|
+
privateKey: string;
|
|
255
|
+
}>;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Browser implementation of HTTP operations using Fetch API
|
|
259
|
+
*/
|
|
260
|
+
declare class BrowserHttpAdapter implements VanaHttpAdapter {
|
|
261
|
+
fetch(url: string, options?: RequestInit): Promise<Response>;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Browser implementation of caching using sessionStorage for security
|
|
265
|
+
* SessionStorage is cleared when the tab closes, making it more secure for signature caching
|
|
266
|
+
*/
|
|
267
|
+
declare class BrowserCacheAdapter implements VanaCacheAdapter {
|
|
268
|
+
private readonly prefix;
|
|
269
|
+
get(key: string): string | null;
|
|
270
|
+
set(key: string, value: string): void;
|
|
271
|
+
delete(key: string): void;
|
|
272
|
+
clear(): void;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Browser implementation of the Vana Platform Adapter
|
|
276
|
+
*
|
|
277
|
+
* This adapter provides all platform-specific functionality for browser environments
|
|
278
|
+
* without requiring any Node.js polyfills.
|
|
227
279
|
*/
|
|
228
280
|
declare class BrowserPlatformAdapter implements VanaPlatformAdapter {
|
|
229
|
-
crypto:
|
|
230
|
-
pgp:
|
|
231
|
-
http:
|
|
232
|
-
cache:
|
|
233
|
-
platform: "browser";
|
|
234
|
-
constructor();
|
|
281
|
+
readonly crypto: BrowserCryptoAdapter;
|
|
282
|
+
readonly pgp: BrowserPGPAdapter;
|
|
283
|
+
readonly http: BrowserHttpAdapter;
|
|
284
|
+
readonly cache: BrowserCacheAdapter;
|
|
285
|
+
readonly platform: "browser";
|
|
235
286
|
}
|
|
236
287
|
|
|
237
288
|
export { BrowserPlatformAdapter as B, type PlatformType as P, type VanaPlatformAdapter as V };
|
package/dist/browser.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BrowserPlatformAdapter } from './browser-
|
|
1
|
+
export { B as BrowserPlatformAdapter } from './browser-Bb8gLWHp.js';
|