@opendatalabs/vana-sdk 0.1.0-alpha.c209e6c → 0.1.0-alpha.ca99685

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 CHANGED
@@ -28,12 +28,19 @@ npm install viem@^2.31.7
28
28
 
29
29
  ## Quick Start
30
30
 
31
- The Vana SDK supports both browser and Node.js environments with explicit entry points:
31
+ The Vana SDK provides optimized builds for different environments:
32
32
 
33
- ### Browser Applications (React, Vue, etc.)
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
- // For browser-based applications (React, Vue, etc.)
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 (Next.js API routes, Express)
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)
@@ -216,26 +216,73 @@ interface VanaPlatformAdapter {
216
216
  }
217
217
 
218
218
  /**
219
- * Browser implementation of the Vana Platform Adapter
220
- *
221
- * This implementation uses browser-compatible libraries and configurations
222
- * to provide crypto, PGP, and HTTP functionality without Node.js dependencies.
219
+ * Browser implementation of the Vana Platform Adapter using Uint8Array
223
220
  *
224
- * WARNING: Dependencies that access globals during init
225
- * MUST be dynamically imported to support Turbopack.
226
- * See: https://github.com/vercel/next.js/issues/82632
221
+ * This implementation uses browser-compatible libraries and native APIs
222
+ * without requiring Buffer or other Node.js polyfills.
227
223
  */
228
224
 
229
225
  /**
230
- * Complete browser platform adapter implementation
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.
231
279
  */
232
280
  declare class BrowserPlatformAdapter implements VanaPlatformAdapter {
233
- crypto: VanaCryptoAdapter;
234
- pgp: VanaPGPAdapter;
235
- http: VanaHttpAdapter;
236
- cache: VanaCacheAdapter;
237
- platform: "browser";
238
- constructor();
281
+ readonly crypto: BrowserCryptoAdapter;
282
+ readonly pgp: BrowserPGPAdapter;
283
+ readonly http: BrowserHttpAdapter;
284
+ readonly cache: BrowserCacheAdapter;
285
+ readonly platform: "browser";
239
286
  }
240
287
 
241
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-DY8XDblx.js';
1
+ export { B as BrowserPlatformAdapter } from './browser-Bb8gLWHp.js';