@opendatalabs/vana-sdk 0.1.0-alpha.f0290d0 → 0.1.0-alpha.ffe4659

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.
Files changed (50) hide show
  1. package/README.md +42 -0
  2. package/dist/browser-DY8XDblx.d.ts +241 -0
  3. package/dist/browser.d.ts +1 -0
  4. package/dist/browser.js +309 -0
  5. package/dist/browser.js.map +1 -0
  6. package/dist/chains.browser.cjs +2 -2
  7. package/dist/chains.browser.cjs.map +1 -1
  8. package/dist/chains.browser.js +2 -2
  9. package/dist/chains.browser.js.map +1 -1
  10. package/dist/chains.cjs +2 -2
  11. package/dist/chains.cjs.map +1 -1
  12. package/dist/chains.js +2 -2
  13. package/dist/chains.js.map +1 -1
  14. package/dist/chains.node.cjs +2 -2
  15. package/dist/chains.node.cjs.map +1 -1
  16. package/dist/chains.node.js +2 -2
  17. package/dist/chains.node.js.map +1 -1
  18. package/dist/index.browser.d.ts +889 -286
  19. package/dist/index.browser.js +2187 -1246
  20. package/dist/index.browser.js.map +1 -1
  21. package/dist/index.node.cjs +2259 -1325
  22. package/dist/index.node.cjs.map +1 -1
  23. package/dist/index.node.d.cts +923 -293
  24. package/dist/index.node.d.ts +923 -293
  25. package/dist/index.node.js +2235 -1302
  26. package/dist/index.node.js.map +1 -1
  27. package/dist/node-D9-F9uEP.d.cts +238 -0
  28. package/dist/node-D9-F9uEP.d.ts +238 -0
  29. package/dist/node.cjs +348 -0
  30. package/dist/node.cjs.map +1 -0
  31. package/dist/node.d.cts +1 -0
  32. package/dist/node.d.ts +1 -0
  33. package/dist/node.js +311 -0
  34. package/dist/node.js.map +1 -0
  35. package/dist/platform.browser.d.ts +3 -236
  36. package/dist/platform.browser.js +31 -8
  37. package/dist/platform.browser.js.map +1 -1
  38. package/dist/platform.cjs +72 -62
  39. package/dist/platform.cjs.map +1 -1
  40. package/dist/platform.d.cts +2 -1
  41. package/dist/platform.d.ts +2 -1
  42. package/dist/platform.js +72 -62
  43. package/dist/platform.js.map +1 -1
  44. package/dist/platform.node.cjs +72 -62
  45. package/dist/platform.node.cjs.map +1 -1
  46. package/dist/platform.node.d.cts +7 -236
  47. package/dist/platform.node.d.ts +7 -236
  48. package/dist/platform.node.js +72 -62
  49. package/dist/platform.node.js.map +1 -1
  50. package/package.json +17 -12
package/README.md CHANGED
@@ -360,6 +360,48 @@ vana.data.validateDataAgainstSchema(data: unknown, schema: DataSchema): void
360
360
  - **Issues**: [GitHub Issues](https://github.com/vana-com/vana-sdk/issues)
361
361
  - **Discord**: [Join our community](https://discord.gg/vanabuilders)
362
362
 
363
+ ## Generated Code
364
+
365
+ 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**.
366
+
367
+ ### Code Generation Scripts
368
+
369
+ | Script | Purpose | Generated Files |
370
+ | ---------------------------- | -------------------------------------- | --------------------------- |
371
+ | `npm run fetch-abis` | Smart contract ABIs from blockchain | `src/generated/abi/*.ts` |
372
+ | `npm run fetch-server-types` | Personal server API types from OpenAPI | `src/generated/server/*.ts` |
373
+ | `npm run codegen:subgraph` | GraphQL types from subgraph schema | `src/generated/subgraph.ts` |
374
+
375
+ ### Network-Specific Generation
376
+
377
+ Some generation scripts support different networks:
378
+
379
+ ```bash
380
+ # Generate subgraph types for different networks
381
+ npm run codegen:subgraph:moksha # Moksha testnet (default)
382
+ npm run codegen:subgraph:mainnet # Vana mainnet
383
+
384
+ # Generate ABIs for different networks
385
+ npm run fetch-abis moksha # Moksha testnet (default)
386
+ npm run fetch-abis mainnet # Vana mainnet
387
+ ```
388
+
389
+ ### Development Workflow
390
+
391
+ When working with the SDK:
392
+
393
+ 1. **Never edit generated files** - They are overwritten on regeneration
394
+ 2. **Regenerate after schema changes** - Run generation scripts when external schemas change
395
+ 3. **Generated files are committed** - They're included in version control for consistency
396
+ 4. **ESLint ignores generated code** - Style rules don't apply to generated files
397
+
398
+ ```bash
399
+ # Regenerate all code after schema updates
400
+ npm run fetch-abis
401
+ npm run fetch-server-types
402
+ npm run codegen:subgraph
403
+ ```
404
+
363
405
  ## Development
364
406
 
365
407
  ```bash
@@ -0,0 +1,241 @@
1
+ /**
2
+ * Platform Adapter interface for environment-specific implementations
3
+ *
4
+ * This interface abstracts all environment-specific dependencies to ensure
5
+ * the SDK works seamlessly across Node.js and browser/SSR environments.
6
+ *
7
+ * **Implementation Context:**
8
+ * - Node.js: Uses native crypto modules and full OpenPGP support
9
+ * - Browser: Uses Web Crypto API and browser-compatible libraries
10
+ * - SSR: Automatically selects appropriate implementation based on runtime
11
+ *
12
+ * **Usage Notes:**
13
+ * Platform adapters are automatically selected by the SDK. Direct usage is only
14
+ * needed for custom implementations or testing.
15
+ */
16
+ /**
17
+ * Platform type identifier
18
+ */
19
+ type PlatformType = "node" | "browser";
20
+ /**
21
+ * Encryption operations that require different implementations per platform
22
+ */
23
+ interface VanaCryptoAdapter {
24
+ /**
25
+ * Encrypt data with a public key using asymmetric cryptography
26
+ *
27
+ * **Usage Context:**
28
+ * - Used internally for file encryption before storage
29
+ * - Public key format: Armored PGP public key string
30
+ * - Returns base64-encoded encrypted data
31
+ *
32
+ * @param data The data to encrypt
33
+ * @param publicKey The public key for encryption
34
+ * @returns Promise resolving to encrypted data
35
+ */
36
+ encryptWithPublicKey(data: string, publicKey: string): Promise<string>;
37
+ /**
38
+ * Decrypt data with a private key using asymmetric cryptography
39
+ *
40
+ * @param encryptedData The encrypted data
41
+ * @param privateKey The private key for decryption
42
+ * @returns Promise resolving to decrypted data
43
+ */
44
+ decryptWithPrivateKey(encryptedData: string, privateKey: string): Promise<string>;
45
+ /**
46
+ * Generate a new key pair for asymmetric cryptography
47
+ *
48
+ * @returns Promise resolving to public and private key pair
49
+ */
50
+ generateKeyPair(): Promise<{
51
+ publicKey: string;
52
+ privateKey: string;
53
+ }>;
54
+ /**
55
+ * Encrypt data with a wallet's public key using ECDH cryptography
56
+ * Uses platform-appropriate ECDH implementation (eccrypto vs eccrypto-js)
57
+ *
58
+ * **Usage Context:**
59
+ * - Used for sharing encryption keys with permission recipients
60
+ * - Public key format: Compressed or uncompressed secp256k1 hex string
61
+ * - Compatible with Ethereum wallet public keys
62
+ *
63
+ * @param data The data to encrypt (string)
64
+ * @param publicKey The wallet's public key (secp256k1)
65
+ * @returns Promise resolving to encrypted data as hex string
66
+ */
67
+ encryptWithWalletPublicKey(data: string, publicKey: string): Promise<string>;
68
+ /**
69
+ * Decrypt data with a wallet's private key using ECDH cryptography
70
+ * Uses platform-appropriate ECDH implementation (eccrypto vs eccrypto-js)
71
+ *
72
+ * @param encryptedData The encrypted data as hex string
73
+ * @param privateKey The wallet's private key (secp256k1)
74
+ * @returns Promise resolving to decrypted data as string
75
+ */
76
+ decryptWithWalletPrivateKey(encryptedData: string, privateKey: string): Promise<string>;
77
+ /**
78
+ * Encrypt data with a password using PGP password-based encryption
79
+ * Uses platform-appropriate OpenPGP implementation with consistent format
80
+ *
81
+ * @param data The data to encrypt as Uint8Array
82
+ * @param password The password for encryption (typically wallet signature)
83
+ * @returns Promise resolving to encrypted data as Uint8Array
84
+ */
85
+ encryptWithPassword(data: Uint8Array, password: string): Promise<Uint8Array>;
86
+ /**
87
+ * Decrypt data with a password using PGP password-based decryption
88
+ * Uses platform-appropriate OpenPGP implementation with consistent format
89
+ *
90
+ * @param encryptedData The encrypted data as Uint8Array
91
+ * @param password The password for decryption (typically wallet signature)
92
+ * @returns Promise resolving to decrypted data as Uint8Array
93
+ */
94
+ decryptWithPassword(encryptedData: Uint8Array, password: string): Promise<Uint8Array>;
95
+ }
96
+ /**
97
+ * PGP operations that require different configurations per platform
98
+ */
99
+ interface VanaPGPAdapter {
100
+ /**
101
+ * Encrypt data using PGP with proper platform configuration
102
+ *
103
+ * @param data The data to encrypt
104
+ * @param publicKey The PGP public key
105
+ * @returns Promise resolving to encrypted data
106
+ */
107
+ encrypt(data: string, publicKey: string): Promise<string>;
108
+ /**
109
+ * Decrypt data using PGP with proper platform configuration
110
+ *
111
+ * @param encryptedData The encrypted data
112
+ * @param privateKey The PGP private key
113
+ * @returns Promise resolving to decrypted data
114
+ */
115
+ decrypt(encryptedData: string, privateKey: string): Promise<string>;
116
+ /**
117
+ * Generate a new PGP key pair with platform-appropriate configuration
118
+ *
119
+ * @param options - Key generation options
120
+ * @param options.name - The name for the PGP key
121
+ * @param options.email - The email for the PGP key
122
+ * @param options.passphrase - Optional passphrase to protect the private key
123
+ * @returns Promise resolving to public and private key pair
124
+ */
125
+ generateKeyPair(options?: {
126
+ name?: string;
127
+ email?: string;
128
+ passphrase?: string;
129
+ }): Promise<{
130
+ publicKey: string;
131
+ privateKey: string;
132
+ }>;
133
+ }
134
+ /**
135
+ * HTTP operations that need consistent API across platforms
136
+ */
137
+ interface VanaHttpAdapter {
138
+ /**
139
+ * Perform HTTP request with platform-appropriate fetch implementation
140
+ *
141
+ * @param url The URL to request
142
+ * @param options Request options
143
+ * @returns Promise resolving to response
144
+ */
145
+ fetch(url: string, options?: RequestInit): Promise<Response>;
146
+ }
147
+ /**
148
+ * Simple cache operations that work across platforms
149
+ */
150
+ interface VanaCacheAdapter {
151
+ /**
152
+ * Get a value from the cache
153
+ *
154
+ * @param key The cache key
155
+ * @returns The cached value or null if not found/expired
156
+ */
157
+ get(key: string): string | null;
158
+ /**
159
+ * Set a value in the cache
160
+ *
161
+ * @param key The cache key
162
+ * @param value The value to cache
163
+ */
164
+ set(key: string, value: string): void;
165
+ /**
166
+ * Delete a value from the cache
167
+ *
168
+ * @param key The cache key
169
+ */
170
+ delete(key: string): void;
171
+ /**
172
+ * Clear all values from the cache
173
+ */
174
+ clear(): void;
175
+ }
176
+ /**
177
+ * Main platform adapter interface that combines all platform-specific functionality
178
+ *
179
+ * **Implementation Guidelines:**
180
+ * 1. All methods must maintain consistent behavior across platforms
181
+ * 2. Error types and messages should be unified
182
+ * 3. Data formats (encoding, serialization) must be identical
183
+ * 4. Performance characteristics can vary but API must be consistent
184
+ *
185
+ * **Custom Implementation Example:**
186
+ * ```typescript
187
+ * class CustomPlatformAdapter implements VanaPlatformAdapter {
188
+ * crypto = new CustomCryptoAdapter();
189
+ * pgp = new CustomPGPAdapter();
190
+ * http = new CustomHttpAdapter();
191
+ * platform = 'browser' as const;
192
+ * }
193
+ * ```
194
+ */
195
+ interface VanaPlatformAdapter {
196
+ /**
197
+ * Crypto operations adapter
198
+ */
199
+ crypto: VanaCryptoAdapter;
200
+ /**
201
+ * PGP operations adapter
202
+ */
203
+ pgp: VanaPGPAdapter;
204
+ /**
205
+ * HTTP operations adapter
206
+ */
207
+ http: VanaHttpAdapter;
208
+ /**
209
+ * Cache operations adapter
210
+ */
211
+ cache: VanaCacheAdapter;
212
+ /**
213
+ * Platform identifier for debugging/telemetry
214
+ */
215
+ readonly platform: PlatformType;
216
+ }
217
+
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.
223
+ *
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
227
+ */
228
+
229
+ /**
230
+ * Complete browser platform adapter implementation
231
+ */
232
+ declare class BrowserPlatformAdapter implements VanaPlatformAdapter {
233
+ crypto: VanaCryptoAdapter;
234
+ pgp: VanaPGPAdapter;
235
+ http: VanaHttpAdapter;
236
+ cache: VanaCacheAdapter;
237
+ platform: "browser";
238
+ constructor();
239
+ }
240
+
241
+ export { BrowserPlatformAdapter as B, type PlatformType as P, type VanaPlatformAdapter as V };
@@ -0,0 +1 @@
1
+ export { B as BrowserPlatformAdapter } from './browser-DY8XDblx.js';
@@ -0,0 +1,309 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // src/platform/shared/crypto-utils.ts
6
+ function processWalletPublicKey(publicKey) {
7
+ const publicKeyHex = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
8
+ const publicKeyBytes = Buffer.from(publicKeyHex, "hex");
9
+ return publicKeyBytes.length === 64 ? Buffer.concat([Buffer.from([4]), publicKeyBytes]) : publicKeyBytes;
10
+ }
11
+ function processWalletPrivateKey(privateKey) {
12
+ const privateKeyHex = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
13
+ return Buffer.from(privateKeyHex, "hex");
14
+ }
15
+ function parseEncryptedDataBuffer(encryptedBuffer) {
16
+ return {
17
+ iv: encryptedBuffer.slice(0, 16),
18
+ ephemPublicKey: encryptedBuffer.slice(16, 81),
19
+ // 65 bytes for uncompressed public key
20
+ ciphertext: encryptedBuffer.slice(81, -32),
21
+ mac: encryptedBuffer.slice(-32)
22
+ };
23
+ }
24
+
25
+ // src/platform/shared/pgp-utils.ts
26
+ var STANDARD_PGP_CONFIG = {
27
+ preferredCompressionAlgorithm: 2,
28
+ // zlib (openpgp.enums.compression.zlib)
29
+ preferredSymmetricAlgorithm: 7
30
+ // aes256 (openpgp.enums.symmetric.aes256)
31
+ };
32
+ function processPGPKeyOptions(options) {
33
+ return {
34
+ name: options?.name || "Vana User",
35
+ email: options?.email || "user@vana.org",
36
+ passphrase: options?.passphrase
37
+ };
38
+ }
39
+ function getPGPKeyGenParams(options) {
40
+ const { name, email, passphrase } = processPGPKeyOptions(options);
41
+ return {
42
+ type: "rsa",
43
+ rsaBits: 2048,
44
+ userIDs: [{ name, email }],
45
+ passphrase,
46
+ config: STANDARD_PGP_CONFIG
47
+ };
48
+ }
49
+
50
+ // src/platform/shared/error-utils.ts
51
+ function wrapCryptoError(operation, error) {
52
+ const message = error instanceof Error ? error.message : "Unknown error";
53
+ return new Error(`${operation} failed: ${message}`);
54
+ }
55
+
56
+ // src/utils/lazy-import.ts
57
+ function lazyImport(importFn) {
58
+ let cached = null;
59
+ return () => {
60
+ if (!cached) {
61
+ cached = importFn().catch((err) => {
62
+ cached = null;
63
+ throw new Error("Failed to load module", { cause: err });
64
+ });
65
+ }
66
+ return cached;
67
+ };
68
+ }
69
+
70
+ // src/platform/browser.ts
71
+ var getOpenPGP = lazyImport(() => import("openpgp"));
72
+ var BrowserCryptoAdapter = class {
73
+ async encryptWithPublicKey(data, publicKeyHex) {
74
+ try {
75
+ const eccrypto = await import("eccrypto-js");
76
+ const publicKeyBuffer = Buffer.from(publicKeyHex, "hex");
77
+ const encrypted = await eccrypto.encrypt(
78
+ publicKeyBuffer,
79
+ Buffer.from(data, "utf8")
80
+ );
81
+ const result = Buffer.concat([
82
+ encrypted.iv,
83
+ encrypted.ephemPublicKey,
84
+ encrypted.ciphertext,
85
+ encrypted.mac
86
+ ]);
87
+ return result.toString("hex");
88
+ } catch (error) {
89
+ throw new Error(`Encryption failed: ${error}`);
90
+ }
91
+ }
92
+ async decryptWithPrivateKey(encryptedData, privateKeyHex) {
93
+ try {
94
+ const eccrypto = await import("eccrypto-js");
95
+ const privateKeyBuffer = processWalletPrivateKey(privateKeyHex);
96
+ const encryptedBuffer = Buffer.from(encryptedData, "hex");
97
+ const { iv, ephemPublicKey, ciphertext, mac } = parseEncryptedDataBuffer(encryptedBuffer);
98
+ const encryptedObj = { iv, ephemPublicKey, ciphertext, mac };
99
+ const decryptedBuffer = await eccrypto.decrypt(
100
+ privateKeyBuffer,
101
+ encryptedObj
102
+ );
103
+ return decryptedBuffer.toString("utf8");
104
+ } catch (error) {
105
+ throw new Error(`Decryption failed: ${error}`);
106
+ }
107
+ }
108
+ async generateKeyPair() {
109
+ try {
110
+ const eccrypto = await import("eccrypto-js");
111
+ const privateKeyBytes = new Uint8Array(32);
112
+ crypto.getRandomValues(privateKeyBytes);
113
+ const privateKey = Buffer.from(privateKeyBytes);
114
+ const publicKey = eccrypto.getPublicCompressed(privateKey);
115
+ return {
116
+ privateKey: privateKey.toString("hex"),
117
+ publicKey: publicKey.toString("hex")
118
+ };
119
+ } catch (error) {
120
+ throw wrapCryptoError("key generation", error);
121
+ }
122
+ }
123
+ async encryptWithWalletPublicKey(data, publicKey) {
124
+ try {
125
+ const eccrypto = await import("eccrypto-js");
126
+ const uncompressedKey = processWalletPublicKey(publicKey);
127
+ const encryptedBuffer = await eccrypto.encrypt(
128
+ uncompressedKey,
129
+ Buffer.from(data)
130
+ );
131
+ const result = Buffer.concat([
132
+ encryptedBuffer.iv,
133
+ encryptedBuffer.ephemPublicKey,
134
+ encryptedBuffer.ciphertext,
135
+ encryptedBuffer.mac
136
+ ]);
137
+ return result.toString("hex");
138
+ } catch (error) {
139
+ throw wrapCryptoError("encrypt with wallet public key", error);
140
+ }
141
+ }
142
+ async decryptWithWalletPrivateKey(encryptedData, privateKey) {
143
+ try {
144
+ const eccrypto = await import("eccrypto-js");
145
+ const privateKeyBuffer = processWalletPrivateKey(privateKey);
146
+ const encryptedBuffer = Buffer.from(encryptedData, "hex");
147
+ const { iv, ephemPublicKey, ciphertext, mac } = parseEncryptedDataBuffer(encryptedBuffer);
148
+ const encryptedObj = { iv, ephemPublicKey, ciphertext, mac };
149
+ const decryptedBuffer = await eccrypto.decrypt(
150
+ privateKeyBuffer,
151
+ encryptedObj
152
+ );
153
+ return decryptedBuffer.toString("utf8");
154
+ } catch (error) {
155
+ throw wrapCryptoError("decrypt with wallet private key", error);
156
+ }
157
+ }
158
+ async encryptWithPassword(data, password) {
159
+ try {
160
+ const openpgp = await getOpenPGP();
161
+ const message = await openpgp.createMessage({
162
+ binary: data
163
+ });
164
+ const encrypted = await openpgp.encrypt({
165
+ message,
166
+ passwords: [password],
167
+ format: "binary"
168
+ });
169
+ const response = new Response(encrypted);
170
+ const arrayBuffer = await response.arrayBuffer();
171
+ return new Uint8Array(arrayBuffer);
172
+ } catch (error) {
173
+ throw new Error(`Failed to encrypt with password: ${error}`);
174
+ }
175
+ }
176
+ async decryptWithPassword(encryptedData, password) {
177
+ try {
178
+ const openpgp = await getOpenPGP();
179
+ const message = await openpgp.readMessage({
180
+ binaryMessage: encryptedData
181
+ });
182
+ const { data: decrypted } = await openpgp.decrypt({
183
+ message,
184
+ passwords: [password],
185
+ format: "binary"
186
+ });
187
+ return new Uint8Array(decrypted);
188
+ } catch (error) {
189
+ throw new Error(`Failed to decrypt with password: ${error}`);
190
+ }
191
+ }
192
+ };
193
+ var BrowserPGPAdapter = class {
194
+ async encrypt(data, publicKeyArmored) {
195
+ try {
196
+ const openpgp = await getOpenPGP();
197
+ const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
198
+ const encrypted = await openpgp.encrypt({
199
+ message: await openpgp.createMessage({ text: data }),
200
+ encryptionKeys: publicKey,
201
+ config: {
202
+ preferredCompressionAlgorithm: openpgp.enums.compression.zlib
203
+ }
204
+ });
205
+ return encrypted;
206
+ } catch (error) {
207
+ throw new Error(`PGP encryption failed: ${error}`);
208
+ }
209
+ }
210
+ async decrypt(encryptedData, privateKeyArmored) {
211
+ try {
212
+ const openpgp = await getOpenPGP();
213
+ const privateKey = await openpgp.readPrivateKey({
214
+ armoredKey: privateKeyArmored
215
+ });
216
+ const message = await openpgp.readMessage({
217
+ armoredMessage: encryptedData
218
+ });
219
+ const { data: decrypted } = await openpgp.decrypt({
220
+ message,
221
+ decryptionKeys: privateKey
222
+ });
223
+ return decrypted;
224
+ } catch (error) {
225
+ throw new Error(`PGP decryption failed: ${error}`);
226
+ }
227
+ }
228
+ async generateKeyPair(options) {
229
+ try {
230
+ const openpgp = await getOpenPGP();
231
+ const keyGenParams = getPGPKeyGenParams(options);
232
+ const { privateKey, publicKey } = await openpgp.generateKey(keyGenParams);
233
+ return { publicKey, privateKey };
234
+ } catch (error) {
235
+ throw wrapCryptoError("PGP key generation", error);
236
+ }
237
+ }
238
+ };
239
+ var BrowserHttpAdapter = class {
240
+ async fetch(url, options) {
241
+ if (typeof fetch === "undefined") {
242
+ throw new Error("Fetch API not available in this browser environment");
243
+ }
244
+ return fetch(url, options);
245
+ }
246
+ };
247
+ var BrowserCacheAdapter = class {
248
+ constructor() {
249
+ __publicField(this, "prefix", "vana_cache_");
250
+ }
251
+ get(key) {
252
+ try {
253
+ if (typeof sessionStorage === "undefined") {
254
+ return null;
255
+ }
256
+ return sessionStorage.getItem(this.prefix + key);
257
+ } catch {
258
+ return null;
259
+ }
260
+ }
261
+ set(key, value) {
262
+ try {
263
+ if (typeof sessionStorage !== "undefined") {
264
+ sessionStorage.setItem(this.prefix + key, value);
265
+ }
266
+ } catch {
267
+ }
268
+ }
269
+ delete(key) {
270
+ try {
271
+ if (typeof sessionStorage !== "undefined") {
272
+ sessionStorage.removeItem(this.prefix + key);
273
+ }
274
+ } catch {
275
+ }
276
+ }
277
+ clear() {
278
+ try {
279
+ if (typeof sessionStorage === "undefined") {
280
+ return;
281
+ }
282
+ const keys = Object.keys(sessionStorage);
283
+ for (const key of keys) {
284
+ if (key.startsWith(this.prefix)) {
285
+ sessionStorage.removeItem(key);
286
+ }
287
+ }
288
+ } catch {
289
+ }
290
+ }
291
+ };
292
+ var BrowserPlatformAdapter = class {
293
+ constructor() {
294
+ __publicField(this, "crypto");
295
+ __publicField(this, "pgp");
296
+ __publicField(this, "http");
297
+ __publicField(this, "cache");
298
+ __publicField(this, "platform", "browser");
299
+ this.crypto = new BrowserCryptoAdapter();
300
+ this.pgp = new BrowserPGPAdapter();
301
+ this.http = new BrowserHttpAdapter();
302
+ this.cache = new BrowserCacheAdapter();
303
+ }
304
+ };
305
+ var browserPlatformAdapter = new BrowserPlatformAdapter();
306
+ export {
307
+ BrowserPlatformAdapter
308
+ };
309
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/platform/shared/crypto-utils.ts","../src/platform/shared/pgp-utils.ts","../src/platform/shared/error-utils.ts","../src/utils/lazy-import.ts","../src/platform/browser.ts"],"sourcesContent":["/**\n * Shared crypto utilities for platform adapters\n *\n * IMPORTANT: This module contains NO IMPORTS to avoid affecting bundle loading.\n * All functions are pure utilities that can be safely shared across platforms.\n */\n\n/**\n * Process wallet public key for encryption operations\n * Removes 0x prefix and ensures uncompressed format (65 bytes with 0x04 prefix)\n *\n * @param publicKey The public key (with or without 0x prefix)\n * @returns Buffer containing uncompressed public key\n */\nexport function processWalletPublicKey(publicKey: string): Buffer {\n const publicKeyHex = publicKey.startsWith(\"0x\")\n ? publicKey.slice(2)\n : publicKey;\n const publicKeyBytes = Buffer.from(publicKeyHex, \"hex\");\n\n // Ensure public key is in uncompressed format (65 bytes with 0x04 prefix)\n // If it's 64 bytes, add the 0x04 prefix; if already 65 bytes, use as-is\n return publicKeyBytes.length === 64\n ? Buffer.concat([Buffer.from([4]), publicKeyBytes])\n : publicKeyBytes;\n}\n\n/**\n * Process wallet private key for decryption operations\n * Removes 0x prefix and converts to Buffer\n *\n * @param privateKey The private key (with or without 0x prefix)\n * @returns Buffer containing private key\n */\nexport function processWalletPrivateKey(privateKey: string): Buffer {\n const privateKeyHex = privateKey.startsWith(\"0x\")\n ? privateKey.slice(2)\n : privateKey;\n return Buffer.from(privateKeyHex, \"hex\");\n}\n\n/**\n * Parse encrypted data buffer into components\n * Extracts IV, ephemeral public key, ciphertext, and MAC from a concatenated buffer\n *\n * @param encryptedBuffer The buffer containing encrypted data\n * @returns Object with parsed components\n */\nexport function parseEncryptedDataBuffer(encryptedBuffer: Buffer) {\n return {\n iv: encryptedBuffer.slice(0, 16),\n ephemPublicKey: encryptedBuffer.slice(16, 81), // 65 bytes for uncompressed public key\n ciphertext: encryptedBuffer.slice(81, -32),\n mac: encryptedBuffer.slice(-32),\n };\n}\n\n/**\n * Convert hex string to Uint8Array\n *\n * @param hex The hex string to convert\n * @returns Uint8Array representation\n */\nexport function hexToUint8Array(hex: string): Uint8Array {\n const result = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n result[i / 2] = parseInt(hex.substr(i, 2), 16);\n }\n return result;\n}\n\n/**\n * Convert Uint8Array to hex string\n *\n * @param array The Uint8Array to convert\n * @returns Hex string representation\n */\nexport function uint8ArrayToHex(array: Uint8Array): string {\n return Array.from(array, (byte) => byte.toString(16).padStart(2, \"0\")).join(\n \"\",\n );\n}\n\n/**\n * Cross-platform base64 encoding\n * Works in both Node.js and browser environments\n *\n * @param str The string to encode\n * @returns Base64 encoded string\n */\nexport function toBase64(str: string): string {\n if (typeof Buffer !== \"undefined\") {\n // Node.js environment\n return Buffer.from(str, \"utf8\").toString(\"base64\");\n } else if (typeof btoa !== \"undefined\") {\n // Browser environment\n return btoa(str);\n } else {\n // Fallback manual implementation\n const chars =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n let result = \"\";\n let i = 0;\n while (i < str.length) {\n const a = str.charCodeAt(i++);\n const b = i < str.length ? str.charCodeAt(i++) : 0;\n const c = i < str.length ? str.charCodeAt(i++) : 0;\n\n const bitmap = (a << 16) | (b << 8) | c;\n\n result += chars.charAt((bitmap >> 18) & 63);\n result += chars.charAt((bitmap >> 12) & 63);\n result += i - 2 < str.length ? chars.charAt((bitmap >> 6) & 63) : \"=\";\n result += i - 1 < str.length ? chars.charAt(bitmap & 63) : \"=\";\n }\n return result;\n }\n}\n\n/**\n * Cross-platform base64 decoding\n * Works in both Node.js and browser environments\n *\n * @param str The base64 string to decode\n * @returns Decoded string\n */\nexport function fromBase64(str: string): string {\n if (typeof Buffer !== \"undefined\") {\n // Node.js environment\n return Buffer.from(str, \"base64\").toString(\"utf8\");\n } else if (typeof atob !== \"undefined\") {\n // Browser environment\n return atob(str);\n } else {\n // Fallback manual implementation\n const chars =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n let result = \"\";\n let i = 0;\n\n // Remove any characters not in the base64 character set\n str = str.replace(/[^A-Za-z0-9+/]/g, \"\");\n\n while (i < str.length) {\n const encoded1 = chars.indexOf(str.charAt(i++));\n const encoded2 = chars.indexOf(str.charAt(i++));\n const encoded3 = chars.indexOf(str.charAt(i++));\n const encoded4 = chars.indexOf(str.charAt(i++));\n\n const bitmap =\n (encoded1 << 18) | (encoded2 << 12) | (encoded3 << 6) | encoded4;\n\n result += String.fromCharCode((bitmap >> 16) & 255);\n if (encoded3 !== 64) result += String.fromCharCode((bitmap >> 8) & 255);\n if (encoded4 !== 64) result += String.fromCharCode(bitmap & 255);\n }\n return result;\n }\n}\n","/**\n * Shared PGP utilities for platform adapters\n *\n * IMPORTANT: This module contains NO IMPORTS to avoid affecting bundle loading.\n * All functions are pure utilities that can be safely shared across platforms.\n */\n\n/**\n * Standard OpenPGP configuration for consistent behavior across platforms\n * Uses enum values instead of importing openpgp to avoid loading issues\n */\nexport const STANDARD_PGP_CONFIG = {\n preferredCompressionAlgorithm: 2, // zlib (openpgp.enums.compression.zlib)\n preferredSymmetricAlgorithm: 7, // aes256 (openpgp.enums.symmetric.aes256)\n} as const;\n\n/**\n * Process PGP key generation options with sensible defaults\n *\n * @param options - Optional key generation parameters\n * @param options.name - The name for the PGP key (defaults to \"Vana User\")\n * @param options.email - The email for the PGP key (defaults to \"user@vana.org\")\n * @param options.passphrase - Optional passphrase to protect the private key\n * @returns Processed options with defaults applied\n */\nexport function processPGPKeyOptions(options?: {\n name?: string;\n email?: string;\n passphrase?: string;\n}) {\n return {\n name: options?.name || \"Vana User\",\n email: options?.email || \"user@vana.org\",\n passphrase: options?.passphrase,\n };\n}\n\n/**\n * Get standard PGP key generation parameters\n * Combines default values with standard configuration\n *\n * @param options - Optional key generation parameters\n * @param options.name - The name for the PGP key (defaults to \"Vana User\")\n * @param options.email - The email for the PGP key (defaults to \"user@vana.org\")\n * @param options.passphrase - Optional passphrase to protect the private key\n * @returns Complete key generation parameters object\n */\nexport function getPGPKeyGenParams(options?: {\n name?: string;\n email?: string;\n passphrase?: string;\n}) {\n const { name, email, passphrase } = processPGPKeyOptions(options);\n\n return {\n type: \"rsa\" as const,\n rsaBits: 2048,\n userIDs: [{ name, email }],\n passphrase,\n config: STANDARD_PGP_CONFIG,\n };\n}\n","/**\n * Shared error utilities for platform adapters\n *\n * IMPORTANT: This module contains NO IMPORTS to avoid affecting bundle loading.\n * All functions are pure utilities that can be safely shared across platforms.\n */\n\n/**\n * Wrap platform-specific errors with consistent messaging\n * Provides consistent error formatting across all crypto operations\n *\n * @param operation The operation that failed (e.g., \"encryption\", \"decryption\")\n * @param error The original error that occurred\n * @returns Wrapped error with consistent format\n */\nexport function wrapCryptoError(operation: string, error: unknown): Error {\n const message = error instanceof Error ? error.message : \"Unknown error\";\n return new Error(`${operation} failed: ${message}`);\n}\n\n/**\n * Validate encrypted data structure has required fields\n * Ensures encrypted data objects contain the expected properties\n *\n * @param data The data structure to validate\n * @throws Error if data structure is invalid\n */\nexport function validateEncryptedDataStructure(data: unknown): void {\n if (!data || typeof data !== \"object\") {\n throw new Error(\"Invalid encrypted data format\");\n }\n\n const obj = data as Record<string, unknown>;\n if (!obj.encrypted || !obj.iv || !obj.ephemeralPublicKey) {\n throw new Error(\"Invalid encrypted data format\");\n }\n}\n","/**\n * Utility for lazy-loading modules to avoid Turbopack TDZ issues\n *\n * WARNING: This is a workaround for Turbopack's strict module initialization.\n * Dependencies that access globals during init must be dynamically imported.\n */\n\n/**\n * Creates a lazy import function that caches the promise (not the module)\n * to avoid race conditions on concurrent first calls\n *\n * @param importFn - Function that returns a dynamic import promise\n * @returns Function that returns the cached import promise\n *\n * @example\n * const getOpenPGP = lazyImport(() => import('openpgp'));\n * const openpgp = await getOpenPGP();\n */\nexport function lazyImport<T>(importFn: () => Promise<T>): () => Promise<T> {\n let cached: Promise<T> | null = null;\n\n return () => {\n if (!cached) {\n cached = importFn().catch((err) => {\n // Clear cache on error so next attempt can retry\n cached = null;\n throw new Error(\"Failed to load module\", { cause: err });\n });\n }\n return cached;\n };\n}\n","/**\n * Browser implementation of the Vana Platform Adapter\n *\n * This implementation uses browser-compatible libraries and configurations\n * to provide crypto, PGP, and HTTP functionality without Node.js dependencies.\n *\n * WARNING: Dependencies that access globals during init\n * MUST be dynamically imported to support Turbopack.\n * See: https://github.com/vercel/next.js/issues/82632\n */\n\nimport type {\n VanaPlatformAdapter,\n VanaCryptoAdapter,\n VanaPGPAdapter,\n VanaHttpAdapter,\n VanaCacheAdapter,\n} from \"./interface\";\nimport {\n processWalletPublicKey,\n processWalletPrivateKey,\n parseEncryptedDataBuffer,\n} from \"./shared/crypto-utils\";\nimport { getPGPKeyGenParams } from \"./shared/pgp-utils\";\nimport { wrapCryptoError } from \"./shared/error-utils\";\nimport { lazyImport } from \"../utils/lazy-import\";\n\n// Lazy-loaded dependencies to avoid Turbopack TDZ issues\nconst getOpenPGP = lazyImport(() => import(\"openpgp\"));\n\n/**\n * Browser implementation of crypto operations using eccrypto-js\n */\nclass BrowserCryptoAdapter implements VanaCryptoAdapter {\n async encryptWithPublicKey(\n data: string,\n publicKeyHex: string,\n ): Promise<string> {\n try {\n // Import eccrypto-js for secp256k1 encryption\n const eccrypto = await import(\"eccrypto-js\");\n\n // Convert hex public key to Buffer\n const publicKeyBuffer = Buffer.from(publicKeyHex, \"hex\");\n\n // Encrypt data using secp256k1 ECDH\n const encrypted = await eccrypto.encrypt(\n publicKeyBuffer,\n Buffer.from(data, \"utf8\"),\n );\n\n // Concatenate all components and return as hex string for API consistency\n const result = Buffer.concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return result.toString(\"hex\");\n } catch (error) {\n throw new Error(`Encryption failed: ${error}`);\n }\n }\n\n async decryptWithPrivateKey(\n encryptedData: string,\n privateKeyHex: string,\n ): Promise<string> {\n try {\n // Import eccrypto-js for secp256k1 decryption\n const eccrypto = await import(\"eccrypto-js\");\n\n // Use shared utilities to process keys and parse data\n const privateKeyBuffer = processWalletPrivateKey(privateKeyHex);\n const encryptedBuffer = Buffer.from(encryptedData, \"hex\");\n const { iv, ephemPublicKey, ciphertext, mac } =\n parseEncryptedDataBuffer(encryptedBuffer);\n\n // Reconstruct the encrypted data structure for eccrypto\n const encryptedObj = { iv, ephemPublicKey, ciphertext, mac };\n\n // Decrypt using secp256k1 ECDH\n const decryptedBuffer = await eccrypto.decrypt(\n privateKeyBuffer,\n encryptedObj,\n );\n\n return decryptedBuffer.toString(\"utf8\");\n } catch (error) {\n throw new Error(`Decryption failed: ${error}`);\n }\n }\n\n async generateKeyPair(): Promise<{ publicKey: string; privateKey: string }> {\n try {\n // Import eccrypto-js for secp256k1 key generation (browser-compatible)\n const eccrypto = await import(\"eccrypto-js\");\n\n // Generate a random 32-byte private key for secp256k1\n const privateKeyBytes = new Uint8Array(32);\n crypto.getRandomValues(privateKeyBytes);\n const privateKey = Buffer.from(privateKeyBytes);\n\n // Generate the corresponding compressed public key\n const publicKey = eccrypto.getPublicCompressed(privateKey);\n\n return {\n privateKey: privateKey.toString(\"hex\"),\n publicKey: publicKey.toString(\"hex\"),\n };\n } catch (error) {\n throw wrapCryptoError(\"key generation\", error);\n }\n }\n\n async encryptWithWalletPublicKey(\n data: string,\n publicKey: string,\n ): Promise<string> {\n try {\n // Import eccrypto for ECDH encryption\n const eccrypto = await import(\"eccrypto-js\");\n\n // Use shared utility to process public key\n const uncompressedKey = processWalletPublicKey(publicKey);\n\n // Encrypt using ECDH with randomly generated parameters\n const encryptedBuffer = await eccrypto.encrypt(\n uncompressedKey,\n Buffer.from(data),\n );\n\n // Concatenate all components and return as hex\n const result = Buffer.concat([\n encryptedBuffer.iv,\n encryptedBuffer.ephemPublicKey,\n encryptedBuffer.ciphertext,\n encryptedBuffer.mac,\n ]);\n\n return result.toString(\"hex\");\n } catch (error) {\n throw wrapCryptoError(\"encrypt with wallet public key\", error);\n }\n }\n\n async decryptWithWalletPrivateKey(\n encryptedData: string,\n privateKey: string,\n ): Promise<string> {\n try {\n // Import eccrypto for ECDH decryption\n const eccrypto = await import(\"eccrypto-js\");\n\n // Use shared utilities to process keys and parse data\n const privateKeyBuffer = processWalletPrivateKey(privateKey);\n const encryptedBuffer = Buffer.from(encryptedData, \"hex\");\n const { iv, ephemPublicKey, ciphertext, mac } =\n parseEncryptedDataBuffer(encryptedBuffer);\n\n // Reconstruct the encrypted data structure for eccrypto\n const encryptedObj = { iv, ephemPublicKey, ciphertext, mac };\n\n // Decrypt using ECDH\n const decryptedBuffer = await eccrypto.decrypt(\n privateKeyBuffer,\n encryptedObj,\n );\n\n return decryptedBuffer.toString(\"utf8\");\n } catch (error) {\n throw wrapCryptoError(\"decrypt with wallet private key\", error);\n }\n }\n\n async encryptWithPassword(\n data: Uint8Array,\n password: string,\n ): Promise<Uint8Array> {\n try {\n // Import openpgp for password-based encryption\n const openpgp = await getOpenPGP();\n\n const message = await openpgp.createMessage({\n binary: data,\n });\n\n // Use password-based encryption with wallet signature as password\n // Note: For deterministic encryption, we would need to control the salt\n // This implementation is secure but not deterministic due to OpenPGP's design\n const encrypted = await openpgp.encrypt({\n message,\n passwords: [password],\n format: \"binary\",\n });\n\n // Convert WebStream<Uint8Array> to Uint8Array\n const response = new Response(encrypted as ReadableStream<Uint8Array>);\n const arrayBuffer = await response.arrayBuffer();\n return new Uint8Array(arrayBuffer);\n } catch (error) {\n throw new Error(`Failed to encrypt with password: ${error}`);\n }\n }\n\n async decryptWithPassword(\n encryptedData: Uint8Array,\n password: string,\n ): Promise<Uint8Array> {\n try {\n // Import openpgp for password-based decryption\n const openpgp = await getOpenPGP();\n\n const message = await openpgp.readMessage({\n binaryMessage: encryptedData,\n });\n\n // Use password-based decryption with wallet signature as password\n const { data: decrypted } = await openpgp.decrypt({\n message,\n passwords: [password],\n format: \"binary\",\n });\n\n // Convert decrypted data back to Uint8Array\n return new Uint8Array(decrypted as ArrayBuffer);\n } catch (error) {\n throw new Error(`Failed to decrypt with password: ${error}`);\n }\n }\n}\n\n/**\n * Browser implementation of PGP operations using openpgp with browser-specific configuration\n */\nclass BrowserPGPAdapter implements VanaPGPAdapter {\n async encrypt(data: string, publicKeyArmored: string): Promise<string> {\n try {\n const openpgp = await getOpenPGP();\n const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });\n\n const encrypted = await openpgp.encrypt({\n message: await openpgp.createMessage({ text: data }),\n encryptionKeys: publicKey,\n config: {\n preferredCompressionAlgorithm: openpgp.enums.compression.zlib,\n },\n });\n\n return encrypted as string;\n } catch (error) {\n throw new Error(`PGP encryption failed: ${error}`);\n }\n }\n\n async decrypt(\n encryptedData: string,\n privateKeyArmored: string,\n ): Promise<string> {\n try {\n const openpgp = await getOpenPGP();\n const privateKey = await openpgp.readPrivateKey({\n armoredKey: privateKeyArmored,\n });\n const message = await openpgp.readMessage({\n armoredMessage: encryptedData,\n });\n\n const { data: decrypted } = await openpgp.decrypt({\n message,\n decryptionKeys: privateKey,\n });\n\n return decrypted as string;\n } catch (error) {\n throw new Error(`PGP decryption failed: ${error}`);\n }\n }\n\n async generateKeyPair(options?: {\n name?: string;\n email?: string;\n passphrase?: string;\n }): Promise<{ publicKey: string; privateKey: string }> {\n try {\n const openpgp = await getOpenPGP();\n // Use shared utility to get standardized parameters\n const keyGenParams = getPGPKeyGenParams(options);\n\n const { privateKey, publicKey } = await openpgp.generateKey(keyGenParams);\n\n return { publicKey, privateKey };\n } catch (error) {\n throw wrapCryptoError(\"PGP key generation\", error);\n }\n }\n}\n\n/**\n * Browser implementation of HTTP operations using fetch API\n */\nclass BrowserHttpAdapter implements VanaHttpAdapter {\n async fetch(url: string, options?: RequestInit): Promise<Response> {\n if (typeof fetch === \"undefined\") {\n throw new Error(\"Fetch API not available in this browser environment\");\n }\n\n return fetch(url, options);\n }\n}\n\n/**\n * Browser implementation of cache operations using sessionStorage\n */\nclass BrowserCacheAdapter implements VanaCacheAdapter {\n private readonly prefix = \"vana_cache_\";\n\n get(key: string): string | null {\n try {\n if (typeof sessionStorage === \"undefined\") {\n return null;\n }\n return sessionStorage.getItem(this.prefix + key);\n } catch {\n return null;\n }\n }\n\n set(key: string, value: string): void {\n try {\n if (typeof sessionStorage !== \"undefined\") {\n sessionStorage.setItem(this.prefix + key, value);\n }\n } catch {\n // Silently ignore storage errors (quota exceeded, etc.)\n }\n }\n\n delete(key: string): void {\n try {\n if (typeof sessionStorage !== \"undefined\") {\n sessionStorage.removeItem(this.prefix + key);\n }\n } catch {\n // Silently ignore storage errors\n }\n }\n\n clear(): void {\n try {\n if (typeof sessionStorage === \"undefined\") {\n return;\n }\n\n const keys = Object.keys(sessionStorage);\n for (const key of keys) {\n if (key.startsWith(this.prefix)) {\n sessionStorage.removeItem(key);\n }\n }\n } catch {\n // Silently ignore storage errors\n }\n }\n}\n\n/**\n * Complete browser platform adapter implementation\n */\nexport class BrowserPlatformAdapter implements VanaPlatformAdapter {\n crypto: VanaCryptoAdapter;\n pgp: VanaPGPAdapter;\n http: VanaHttpAdapter;\n cache: VanaCacheAdapter;\n platform: \"browser\" = \"browser\" as const;\n\n constructor() {\n this.crypto = new BrowserCryptoAdapter();\n this.pgp = new BrowserPGPAdapter();\n this.http = new BrowserHttpAdapter();\n this.cache = new BrowserCacheAdapter();\n }\n}\n\n/**\n * Default instance export for backwards compatibility\n */\nexport const browserPlatformAdapter: VanaPlatformAdapter =\n new BrowserPlatformAdapter();\n"],"mappings":";;;;;AAcO,SAAS,uBAAuB,WAA2B;AAChE,QAAM,eAAe,UAAU,WAAW,IAAI,IAC1C,UAAU,MAAM,CAAC,IACjB;AACJ,QAAM,iBAAiB,OAAO,KAAK,cAAc,KAAK;AAItD,SAAO,eAAe,WAAW,KAC7B,OAAO,OAAO,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,IAChD;AACN;AASO,SAAS,wBAAwB,YAA4B;AAClE,QAAM,gBAAgB,WAAW,WAAW,IAAI,IAC5C,WAAW,MAAM,CAAC,IAClB;AACJ,SAAO,OAAO,KAAK,eAAe,KAAK;AACzC;AASO,SAAS,yBAAyB,iBAAyB;AAChE,SAAO;AAAA,IACL,IAAI,gBAAgB,MAAM,GAAG,EAAE;AAAA,IAC/B,gBAAgB,gBAAgB,MAAM,IAAI,EAAE;AAAA;AAAA,IAC5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BAAmB,aAAa;AACzC;AAAA,MACF;AAEA,YAAM,OAAO,OAAO,KAAK,cAAc;AACvC,iBAAW,OAAO,MAAM;AACtB,YAAI,IAAI,WAAW,KAAK,MAAM,GAAG;AAC/B,yBAAe,WAAW,GAAG;AAAA,QAC/B;AAAA,MACF;AAAA,IACF,QAAQ;AAAA,IAER;AAAA,EACF;AACF;AAKO,IAAM,yBAAN,MAA4D;AAAA,EAOjE,cAAc;AANd;AACA;AACA;AACA;AACA,oCAAsB;AAGpB,SAAK,SAAS,IAAI,qBAAqB;AACvC,SAAK,MAAM,IAAI,kBAAkB;AACjC,SAAK,OAAO,IAAI,mBAAmB;AACnC,SAAK,QAAQ,IAAI,oBAAoB;AAAA,EACvC;AACF;AAKO,IAAM,yBACX,IAAI,uBAAuB;","names":[]}
@@ -48,7 +48,7 @@ var vanaMainnet = {
48
48
  url: "https://vanascan.io"
49
49
  }
50
50
  },
51
- subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/vana/7.0.6/gn"
51
+ subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/vana/7.0.7/gn"
52
52
  };
53
53
  var moksha = {
54
54
  id: 14800,
@@ -69,7 +69,7 @@ var moksha = {
69
69
  url: "https://moksha.vanascan.io"
70
70
  }
71
71
  },
72
- subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/moksha/7.0.6/gn"
72
+ subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/moksha/7.0.7/gn"
73
73
  };
74
74
  function getChainConfig(chainId) {
75
75
  switch (chainId) {