@opendatalabs/vana-sdk 0.1.0-alpha.c209e6c → 0.1.0-alpha.c7ed15d
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 +13 -4
- package/dist/{browser-DY8XDblx.d.ts → browser-Bb8gLWHp.d.ts} +61 -14
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +653 -106
- package/dist/browser.js.map +1 -1
- package/dist/index.browser.d.ts +1033 -151
- package/dist/index.browser.js +34864 -33511
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +35172 -33668
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +738 -152
- package/dist/index.node.d.ts +738 -152
- package/dist/index.node.js +35325 -33812
- package/dist/index.node.js.map +1 -1
- package/dist/node.cjs +635 -53
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +647 -52
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.d.ts +2 -2
- package/dist/platform.browser.js +701 -116
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.cjs +890 -156
- package/dist/platform.cjs.map +1 -1
- package/dist/platform.js +901 -156
- package/dist/platform.js.map +1 -1
- package/dist/platform.node.cjs +890 -156
- package/dist/platform.node.cjs.map +1 -1
- package/dist/platform.node.d.cts +61 -14
- package/dist/platform.node.d.ts +61 -14
- package/dist/platform.node.js +901 -156
- package/dist/platform.node.js.map +1 -1
- package/package.json +31 -15
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)
|
|
@@ -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
|
-
*
|
|
225
|
-
*
|
|
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
|
-
*
|
|
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:
|
|
234
|
-
pgp:
|
|
235
|
-
http:
|
|
236
|
-
cache:
|
|
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-
|
|
1
|
+
export { B as BrowserPlatformAdapter } from './browser-Bb8gLWHp.js';
|