@opendatalabs/vana-sdk 0.1.0-alpha.e64ec83 → 0.1.0-alpha.ee24d86
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 +211 -436
- package/dist/chains.browser.cjs +5 -2
- package/dist/chains.browser.cjs.map +1 -1
- package/dist/chains.browser.d.cts +2 -1
- package/dist/chains.browser.d.ts +2 -1
- package/dist/chains.browser.js +4 -2
- package/dist/chains.browser.js.map +1 -1
- package/dist/chains.cjs +5 -2
- package/dist/chains.cjs.map +1 -1
- package/dist/chains.d.cts +1 -1
- package/dist/chains.d.ts +1 -1
- package/dist/chains.js +4 -2
- package/dist/chains.js.map +1 -1
- package/dist/chains.node.cjs +5 -2
- package/dist/chains.node.cjs.map +1 -1
- package/dist/chains.node.d.cts +1 -1
- package/dist/chains.node.d.ts +1 -1
- package/dist/chains.node.js +4 -2
- package/dist/chains.node.js.map +1 -1
- package/dist/index.browser.d.ts +10186 -4394
- package/dist/index.browser.js +5534 -2049
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.cts +1 -31277
- package/dist/index.node.cjs +5618 -2099
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +10211 -4391
- package/dist/index.node.d.ts +10211 -4391
- package/dist/index.node.js +5549 -2032
- package/dist/index.node.js.map +1 -1
- package/dist/platform.browser.d.ts +69 -0
- package/dist/platform.browser.js +79 -181
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.cjs +122 -197
- package/dist/platform.cjs.map +1 -1
- package/dist/platform.js +122 -197
- package/dist/platform.js.map +1 -1
- package/dist/platform.node.cjs +122 -197
- package/dist/platform.node.cjs.map +1 -1
- package/dist/platform.node.d.cts +70 -0
- package/dist/platform.node.d.ts +70 -0
- package/dist/platform.node.js +122 -197
- package/dist/platform.node.js.map +1 -1
- package/package.json +24 -18
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This interface abstracts all environment-specific dependencies to ensure
|
|
5
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.
|
|
6
15
|
*/
|
|
7
16
|
/**
|
|
8
17
|
* Platform type identifier
|
|
@@ -15,6 +24,11 @@ interface VanaCryptoAdapter {
|
|
|
15
24
|
/**
|
|
16
25
|
* Encrypt data with a public key using asymmetric cryptography
|
|
17
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
|
+
*
|
|
18
32
|
* @param data The data to encrypt
|
|
19
33
|
* @param publicKey The public key for encryption
|
|
20
34
|
* @returns Promise resolving to encrypted data
|
|
@@ -41,6 +55,11 @@ interface VanaCryptoAdapter {
|
|
|
41
55
|
* Encrypt data with a wallet's public key using ECDH cryptography
|
|
42
56
|
* Uses platform-appropriate ECDH implementation (eccrypto vs eccrypto-js)
|
|
43
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
|
+
*
|
|
44
63
|
* @param data The data to encrypt (string)
|
|
45
64
|
* @param publicKey The wallet's public key (secp256k1)
|
|
46
65
|
* @returns Promise resolving to encrypted data as hex string
|
|
@@ -125,8 +144,53 @@ interface VanaHttpAdapter {
|
|
|
125
144
|
*/
|
|
126
145
|
fetch(url: string, options?: RequestInit): Promise<Response>;
|
|
127
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
|
+
}
|
|
128
176
|
/**
|
|
129
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
|
+
* ```
|
|
130
194
|
*/
|
|
131
195
|
interface VanaPlatformAdapter {
|
|
132
196
|
/**
|
|
@@ -141,6 +205,10 @@ interface VanaPlatformAdapter {
|
|
|
141
205
|
* HTTP operations adapter
|
|
142
206
|
*/
|
|
143
207
|
http: VanaHttpAdapter;
|
|
208
|
+
/**
|
|
209
|
+
* Cache operations adapter
|
|
210
|
+
*/
|
|
211
|
+
cache: VanaCacheAdapter;
|
|
144
212
|
/**
|
|
145
213
|
* Platform identifier for debugging/telemetry
|
|
146
214
|
*/
|
|
@@ -161,6 +229,7 @@ declare class BrowserPlatformAdapter implements VanaPlatformAdapter {
|
|
|
161
229
|
crypto: VanaCryptoAdapter;
|
|
162
230
|
pgp: VanaPGPAdapter;
|
|
163
231
|
http: VanaHttpAdapter;
|
|
232
|
+
cache: VanaCacheAdapter;
|
|
164
233
|
platform: "browser";
|
|
165
234
|
constructor();
|
|
166
235
|
}
|
package/dist/platform.browser.js
CHANGED
|
@@ -25,11 +25,6 @@ function parseEncryptedDataBuffer(encryptedBuffer) {
|
|
|
25
25
|
mac: encryptedBuffer.slice(-32)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
function uint8ArrayToHex(array) {
|
|
29
|
-
return Array.from(array, (byte) => byte.toString(16).padStart(2, "0")).join(
|
|
30
|
-
""
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
28
|
var init_crypto_utils = __esm({
|
|
34
29
|
"src/platform/shared/crypto-utils.ts"() {
|
|
35
30
|
"use strict";
|
|
@@ -80,147 +75,59 @@ var init_error_utils = __esm({
|
|
|
80
75
|
|
|
81
76
|
// src/platform/browser.ts
|
|
82
77
|
import * as openpgp from "openpgp";
|
|
83
|
-
|
|
84
|
-
const result = new Uint8Array(hex.length / 2);
|
|
85
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
86
|
-
result[i / 2] = parseInt(hex.substr(i, 2), 16);
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
var BrowserECDH, BrowserCryptoAdapter, BrowserPGPAdapter, BrowserHttpAdapter, BrowserPlatformAdapter, browserPlatformAdapter;
|
|
78
|
+
var BrowserCryptoAdapter, BrowserPGPAdapter, BrowserHttpAdapter, BrowserCacheAdapter, BrowserPlatformAdapter, browserPlatformAdapter;
|
|
91
79
|
var init_browser = __esm({
|
|
92
80
|
"src/platform/browser.ts"() {
|
|
93
81
|
"use strict";
|
|
94
82
|
init_crypto_utils();
|
|
95
83
|
init_pgp_utils();
|
|
96
84
|
init_error_utils();
|
|
97
|
-
BrowserECDH = class {
|
|
98
|
-
async generateKeyPair() {
|
|
99
|
-
const keyPair = await crypto.subtle.generateKey(
|
|
100
|
-
{
|
|
101
|
-
name: "ECDH",
|
|
102
|
-
namedCurve: "P-256"
|
|
103
|
-
},
|
|
104
|
-
true,
|
|
105
|
-
["deriveKey", "deriveBits"]
|
|
106
|
-
);
|
|
107
|
-
return keyPair;
|
|
108
|
-
}
|
|
109
|
-
async encrypt(publicKeyHex, message) {
|
|
110
|
-
const ephemeralKeyPair = await this.generateKeyPair();
|
|
111
|
-
const publicKeyData = hexToUint8Array(publicKeyHex);
|
|
112
|
-
const importedPublicKey = await crypto.subtle.importKey(
|
|
113
|
-
"raw",
|
|
114
|
-
publicKeyData,
|
|
115
|
-
{ name: "ECDH", namedCurve: "P-256" },
|
|
116
|
-
false,
|
|
117
|
-
[]
|
|
118
|
-
);
|
|
119
|
-
const sharedKey = await crypto.subtle.deriveKey(
|
|
120
|
-
{ name: "ECDH", public: importedPublicKey },
|
|
121
|
-
ephemeralKeyPair.privateKey,
|
|
122
|
-
{ name: "AES-GCM", length: 256 },
|
|
123
|
-
false,
|
|
124
|
-
["encrypt"]
|
|
125
|
-
);
|
|
126
|
-
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
127
|
-
const encoder = new TextEncoder();
|
|
128
|
-
const data = encoder.encode(message);
|
|
129
|
-
const encrypted = await crypto.subtle.encrypt(
|
|
130
|
-
{ name: "AES-GCM", iv },
|
|
131
|
-
sharedKey,
|
|
132
|
-
data
|
|
133
|
-
);
|
|
134
|
-
const ephemeralPublicKeyData = await crypto.subtle.exportKey(
|
|
135
|
-
"raw",
|
|
136
|
-
ephemeralKeyPair.publicKey
|
|
137
|
-
);
|
|
138
|
-
return JSON.stringify({
|
|
139
|
-
encrypted: Array.from(new Uint8Array(encrypted)),
|
|
140
|
-
iv: Array.from(iv),
|
|
141
|
-
ephemeralPublicKey: Array.from(new Uint8Array(ephemeralPublicKeyData)),
|
|
142
|
-
publicKey: publicKeyHex
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
async decrypt(privateKeyHex, encryptedData) {
|
|
146
|
-
try {
|
|
147
|
-
const data = JSON.parse(encryptedData);
|
|
148
|
-
if (!data.encrypted || !data.iv || !data.ephemeralPublicKey) {
|
|
149
|
-
throw new Error("Invalid encrypted data format");
|
|
150
|
-
}
|
|
151
|
-
const privateKeyData = hexToUint8Array(privateKeyHex);
|
|
152
|
-
const importedPrivateKey = await crypto.subtle.importKey(
|
|
153
|
-
"pkcs8",
|
|
154
|
-
privateKeyData,
|
|
155
|
-
{ name: "ECDH", namedCurve: "P-256" },
|
|
156
|
-
false,
|
|
157
|
-
["deriveKey"]
|
|
158
|
-
);
|
|
159
|
-
const ephemeralPublicKey = await crypto.subtle.importKey(
|
|
160
|
-
"raw",
|
|
161
|
-
new Uint8Array(data.ephemeralPublicKey),
|
|
162
|
-
{ name: "ECDH", namedCurve: "P-256" },
|
|
163
|
-
false,
|
|
164
|
-
[]
|
|
165
|
-
);
|
|
166
|
-
const sharedKey = await crypto.subtle.deriveKey(
|
|
167
|
-
{ name: "ECDH", public: ephemeralPublicKey },
|
|
168
|
-
importedPrivateKey,
|
|
169
|
-
{ name: "AES-GCM", length: 256 },
|
|
170
|
-
false,
|
|
171
|
-
["decrypt"]
|
|
172
|
-
);
|
|
173
|
-
const decrypted = await crypto.subtle.decrypt(
|
|
174
|
-
{ name: "AES-GCM", iv: new Uint8Array(data.iv) },
|
|
175
|
-
sharedKey,
|
|
176
|
-
new Uint8Array(data.encrypted)
|
|
177
|
-
);
|
|
178
|
-
return new TextDecoder().decode(decrypted);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
throw new Error(
|
|
181
|
-
`Decryption failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
85
|
BrowserCryptoAdapter = class {
|
|
187
86
|
async encryptWithPublicKey(data, publicKeyHex) {
|
|
188
87
|
try {
|
|
189
|
-
const
|
|
190
|
-
|
|
88
|
+
const eccrypto = await import("eccrypto-js");
|
|
89
|
+
const publicKeyBuffer = Buffer.from(publicKeyHex, "hex");
|
|
90
|
+
const encrypted = await eccrypto.encrypt(
|
|
91
|
+
publicKeyBuffer,
|
|
92
|
+
Buffer.from(data, "utf8")
|
|
93
|
+
);
|
|
94
|
+
const result = Buffer.concat([
|
|
95
|
+
encrypted.iv,
|
|
96
|
+
encrypted.ephemPublicKey,
|
|
97
|
+
encrypted.ciphertext,
|
|
98
|
+
encrypted.mac
|
|
99
|
+
]);
|
|
100
|
+
return result.toString("hex");
|
|
191
101
|
} catch (error) {
|
|
192
102
|
throw new Error(`Encryption failed: ${error}`);
|
|
193
103
|
}
|
|
194
104
|
}
|
|
195
105
|
async decryptWithPrivateKey(encryptedData, privateKeyHex) {
|
|
196
106
|
try {
|
|
197
|
-
const
|
|
198
|
-
|
|
107
|
+
const eccrypto = await import("eccrypto-js");
|
|
108
|
+
const privateKeyBuffer = processWalletPrivateKey(privateKeyHex);
|
|
109
|
+
const encryptedBuffer = Buffer.from(encryptedData, "hex");
|
|
110
|
+
const { iv, ephemPublicKey, ciphertext, mac } = parseEncryptedDataBuffer(encryptedBuffer);
|
|
111
|
+
const encryptedObj = { iv, ephemPublicKey, ciphertext, mac };
|
|
112
|
+
const decryptedBuffer = await eccrypto.decrypt(
|
|
113
|
+
privateKeyBuffer,
|
|
114
|
+
encryptedObj
|
|
115
|
+
);
|
|
116
|
+
return decryptedBuffer.toString("utf8");
|
|
199
117
|
} catch (error) {
|
|
200
118
|
throw new Error(`Decryption failed: ${error}`);
|
|
201
119
|
}
|
|
202
120
|
}
|
|
203
121
|
async generateKeyPair() {
|
|
204
122
|
try {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
true,
|
|
211
|
-
["deriveKey", "deriveBits"]
|
|
212
|
-
);
|
|
213
|
-
const publicKeyBuffer = await crypto.subtle.exportKey(
|
|
214
|
-
"raw",
|
|
215
|
-
keyPair.publicKey
|
|
216
|
-
);
|
|
217
|
-
const privateKeyBuffer = await crypto.subtle.exportKey(
|
|
218
|
-
"pkcs8",
|
|
219
|
-
keyPair.privateKey
|
|
220
|
-
);
|
|
123
|
+
const eccrypto = await import("eccrypto-js");
|
|
124
|
+
const privateKeyBytes = new Uint8Array(32);
|
|
125
|
+
crypto.getRandomValues(privateKeyBytes);
|
|
126
|
+
const privateKey = Buffer.from(privateKeyBytes);
|
|
127
|
+
const publicKey = eccrypto.getPublicCompressed(privateKey);
|
|
221
128
|
return {
|
|
222
|
-
|
|
223
|
-
|
|
129
|
+
privateKey: privateKey.toString("hex"),
|
|
130
|
+
publicKey: publicKey.toString("hex")
|
|
224
131
|
};
|
|
225
132
|
} catch (error) {
|
|
226
133
|
throw wrapCryptoError("key generation", error);
|
|
@@ -230,65 +137,9 @@ var init_browser = __esm({
|
|
|
230
137
|
try {
|
|
231
138
|
const eccrypto = await import("eccrypto-js");
|
|
232
139
|
const uncompressedKey = processWalletPublicKey(publicKey);
|
|
233
|
-
const iv = Buffer.from([
|
|
234
|
-
1,
|
|
235
|
-
2,
|
|
236
|
-
3,
|
|
237
|
-
4,
|
|
238
|
-
5,
|
|
239
|
-
6,
|
|
240
|
-
7,
|
|
241
|
-
8,
|
|
242
|
-
9,
|
|
243
|
-
10,
|
|
244
|
-
11,
|
|
245
|
-
12,
|
|
246
|
-
13,
|
|
247
|
-
14,
|
|
248
|
-
15,
|
|
249
|
-
16
|
|
250
|
-
]);
|
|
251
|
-
const ephemeralKey = Buffer.from([
|
|
252
|
-
17,
|
|
253
|
-
34,
|
|
254
|
-
51,
|
|
255
|
-
68,
|
|
256
|
-
85,
|
|
257
|
-
102,
|
|
258
|
-
119,
|
|
259
|
-
136,
|
|
260
|
-
153,
|
|
261
|
-
170,
|
|
262
|
-
187,
|
|
263
|
-
204,
|
|
264
|
-
221,
|
|
265
|
-
238,
|
|
266
|
-
255,
|
|
267
|
-
0,
|
|
268
|
-
16,
|
|
269
|
-
32,
|
|
270
|
-
48,
|
|
271
|
-
64,
|
|
272
|
-
80,
|
|
273
|
-
96,
|
|
274
|
-
112,
|
|
275
|
-
128,
|
|
276
|
-
144,
|
|
277
|
-
160,
|
|
278
|
-
176,
|
|
279
|
-
192,
|
|
280
|
-
208,
|
|
281
|
-
224,
|
|
282
|
-
240,
|
|
283
|
-
0
|
|
284
|
-
]);
|
|
285
140
|
const encryptedBuffer = await eccrypto.encrypt(
|
|
286
141
|
uncompressedKey,
|
|
287
|
-
Buffer.from(data)
|
|
288
|
-
{
|
|
289
|
-
iv,
|
|
290
|
-
ephemPrivateKey: ephemeralKey
|
|
291
|
-
}
|
|
142
|
+
Buffer.from(data)
|
|
292
143
|
);
|
|
293
144
|
const result = Buffer.concat([
|
|
294
145
|
encryptedBuffer.iv,
|
|
@@ -403,15 +254,62 @@ var init_browser = __esm({
|
|
|
403
254
|
return fetch(url, options);
|
|
404
255
|
}
|
|
405
256
|
};
|
|
257
|
+
BrowserCacheAdapter = class {
|
|
258
|
+
constructor() {
|
|
259
|
+
__publicField(this, "prefix", "vana_cache_");
|
|
260
|
+
}
|
|
261
|
+
get(key) {
|
|
262
|
+
try {
|
|
263
|
+
if (typeof sessionStorage === "undefined") {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
return sessionStorage.getItem(this.prefix + key);
|
|
267
|
+
} catch {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
set(key, value) {
|
|
272
|
+
try {
|
|
273
|
+
if (typeof sessionStorage !== "undefined") {
|
|
274
|
+
sessionStorage.setItem(this.prefix + key, value);
|
|
275
|
+
}
|
|
276
|
+
} catch {
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
delete(key) {
|
|
280
|
+
try {
|
|
281
|
+
if (typeof sessionStorage !== "undefined") {
|
|
282
|
+
sessionStorage.removeItem(this.prefix + key);
|
|
283
|
+
}
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
clear() {
|
|
288
|
+
try {
|
|
289
|
+
if (typeof sessionStorage === "undefined") {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const keys = Object.keys(sessionStorage);
|
|
293
|
+
for (const key of keys) {
|
|
294
|
+
if (key.startsWith(this.prefix)) {
|
|
295
|
+
sessionStorage.removeItem(key);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
} catch {
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
};
|
|
406
302
|
BrowserPlatformAdapter = class {
|
|
407
303
|
constructor() {
|
|
408
304
|
__publicField(this, "crypto");
|
|
409
305
|
__publicField(this, "pgp");
|
|
410
306
|
__publicField(this, "http");
|
|
307
|
+
__publicField(this, "cache");
|
|
411
308
|
__publicField(this, "platform", "browser");
|
|
412
309
|
this.crypto = new BrowserCryptoAdapter();
|
|
413
310
|
this.pgp = new BrowserPGPAdapter();
|
|
414
311
|
this.http = new BrowserHttpAdapter();
|
|
312
|
+
this.cache = new BrowserCacheAdapter();
|
|
415
313
|
}
|
|
416
314
|
};
|
|
417
315
|
browserPlatformAdapter = new BrowserPlatformAdapter();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/platform/shared/crypto-utils.ts","../src/platform/shared/pgp-utils.ts","../src/platform/shared/error-utils.ts","../src/platform/browser.ts","../src/platform.browser.ts","../src/platform/browser-only.ts","../src/platform/utils.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 * 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 * 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\nimport * as openpgp from \"openpgp\";\nimport {\n VanaPlatformAdapter,\n VanaCryptoAdapter,\n VanaPGPAdapter,\n VanaHttpAdapter,\n} from \"./interface\";\nimport {\n processWalletPublicKey,\n processWalletPrivateKey,\n parseEncryptedDataBuffer,\n uint8ArrayToHex,\n} from \"./shared/crypto-utils\";\nimport { getPGPKeyGenParams } from \"./shared/pgp-utils\";\nimport { wrapCryptoError } from \"./shared/error-utils\";\n\n// Browser-native crypto implementation using Web Crypto API\nclass BrowserECDH {\n async generateKeyPair() {\n const keyPair = await crypto.subtle.generateKey(\n {\n name: \"ECDH\",\n namedCurve: \"P-256\",\n },\n true,\n [\"deriveKey\", \"deriveBits\"],\n );\n return keyPair;\n }\n\n async encrypt(publicKeyHex: string, message: string): Promise<string> {\n // Generate ephemeral key pair for this encryption\n const ephemeralKeyPair = await this.generateKeyPair();\n\n // Import the provided public key\n const publicKeyData = hexToUint8Array(publicKeyHex);\n const importedPublicKey = await crypto.subtle.importKey(\n \"raw\",\n publicKeyData,\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [],\n );\n\n // Derive shared secret using ephemeral private key and provided public key\n const sharedKey = await crypto.subtle.deriveKey(\n { name: \"ECDH\", public: importedPublicKey },\n ephemeralKeyPair.privateKey,\n { name: \"AES-GCM\", length: 256 },\n false,\n [\"encrypt\"],\n );\n\n // Generate IV\n const iv = crypto.getRandomValues(new Uint8Array(12));\n\n // Encrypt the message\n const encoder = new TextEncoder();\n const data = encoder.encode(message);\n const encrypted = await crypto.subtle.encrypt(\n { name: \"AES-GCM\", iv },\n sharedKey,\n data,\n );\n\n // Export ephemeral public key for sender\n const ephemeralPublicKeyData = await crypto.subtle.exportKey(\n \"raw\",\n ephemeralKeyPair.publicKey,\n );\n\n return JSON.stringify({\n encrypted: Array.from(new Uint8Array(encrypted)),\n iv: Array.from(iv),\n ephemeralPublicKey: Array.from(new Uint8Array(ephemeralPublicKeyData)),\n publicKey: publicKeyHex,\n });\n }\n\n async decrypt(privateKeyHex: string, encryptedData: string): Promise<string> {\n try {\n const data = JSON.parse(encryptedData);\n\n // Validate that we have the expected data structure\n if (!data.encrypted || !data.iv || !data.ephemeralPublicKey) {\n throw new Error(\"Invalid encrypted data format\");\n }\n\n // Import the private key\n const privateKeyData = hexToUint8Array(privateKeyHex);\n const importedPrivateKey = await crypto.subtle.importKey(\n \"pkcs8\",\n privateKeyData,\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [\"deriveKey\"],\n );\n\n // Import ephemeral public key\n const ephemeralPublicKey = await crypto.subtle.importKey(\n \"raw\",\n new Uint8Array(data.ephemeralPublicKey),\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [],\n );\n\n // Derive the same shared secret\n const sharedKey = await crypto.subtle.deriveKey(\n { name: \"ECDH\", public: ephemeralPublicKey },\n importedPrivateKey,\n { name: \"AES-GCM\", length: 256 },\n false,\n [\"decrypt\"],\n );\n\n // Decrypt\n const decrypted = await crypto.subtle.decrypt(\n { name: \"AES-GCM\", iv: new Uint8Array(data.iv) },\n sharedKey,\n new Uint8Array(data.encrypted),\n );\n\n return new TextDecoder().decode(decrypted);\n } catch (error) {\n throw new Error(\n `Decryption failed: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n );\n }\n }\n}\n\n// Utility functions for browser crypto\n/**\n * Converts a hexadecimal string to a Uint8Array\n *\n * @param hex - The hexadecimal string to convert\n * @returns Uint8Array representation of the hex string\n */\nfunction 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// Utility functions for browser crypto remain available if needed in future\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 const ecdh = new BrowserECDH();\n return await ecdh.encrypt(publicKeyHex, data);\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 const ecdh = new BrowserECDH();\n return await ecdh.decrypt(privateKeyHex, encryptedData);\n } catch (error) {\n throw new Error(`Decryption failed: ${error}`);\n }\n }\n\n async generateKeyPair(): Promise<{ publicKey: string; privateKey: string }> {\n try {\n // Generate a secp256k1 compatible key pair using Web Crypto API\n const keyPair = await crypto.subtle.generateKey(\n {\n name: \"ECDH\",\n namedCurve: \"P-256\",\n },\n true,\n [\"deriveKey\", \"deriveBits\"],\n );\n\n // Export keys as hex strings using shared utility\n const publicKeyBuffer = await crypto.subtle.exportKey(\n \"raw\",\n keyPair.publicKey,\n );\n const privateKeyBuffer = await crypto.subtle.exportKey(\n \"pkcs8\",\n keyPair.privateKey,\n );\n\n return {\n publicKey: uint8ArrayToHex(new Uint8Array(publicKeyBuffer)),\n privateKey: uint8ArrayToHex(new Uint8Array(privateKeyBuffer)),\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 // Generate consistent encryption parameters (for deterministic encryption)\n const iv = Buffer.from([\n 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,\n 0x0d, 0x0e, 0x0f, 0x10,\n ]);\n\n const ephemeralKey = Buffer.from([\n 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc,\n 0xdd, 0xee, 0xff, 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80,\n 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0x00,\n ]);\n\n // Encrypt using ECDH\n const encryptedBuffer = await eccrypto.encrypt(\n uncompressedKey,\n Buffer.from(data),\n {\n iv: iv,\n ephemPrivateKey: ephemeralKey,\n },\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 import(\"openpgp\");\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 import(\"openpgp\");\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 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 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 // 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 * Complete browser platform adapter implementation\n */\nexport class BrowserPlatformAdapter implements VanaPlatformAdapter {\n crypto: VanaCryptoAdapter;\n pgp: VanaPGPAdapter;\n http: VanaHttpAdapter;\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 }\n}\n\n/**\n * Default instance export for backwards compatibility\n */\nexport const browserPlatformAdapter: VanaPlatformAdapter =\n new BrowserPlatformAdapter();\n","/**\n * Browser-specific platform adapters entry point\n *\n * This module provides browser-safe platform utilities without Node.js dependencies.\n */\n\n// Export browser platform adapter\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\n\n// Export platform interface\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Export browser-safe utilities only\nexport {\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-only\";\n\n// Export safe platform utilities (no Node.js imports)\nexport {\n detectPlatform,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n","/**\n * Browser-only exports for platform adapters\n *\n * This file provides browser-only exports that completely avoid Node.js imports\n * when bundling for browser environments. This is used by the browser entry point.\n */\n\nimport type { VanaPlatformAdapter } from \"./interface\";\nimport { BrowserPlatformAdapter } from \"./browser\";\n\n/**\n * Creates a BrowserPlatformAdapter instance\n *\n * @returns A BrowserPlatformAdapter instance\n */\nexport function createBrowserPlatformAdapter(): VanaPlatformAdapter {\n return new BrowserPlatformAdapter();\n}\n\n/**\n * Browser-only platform adapter factory\n * This version does not include Node.js imports at all\n *\n * @returns A BrowserPlatformAdapter instance\n */\nexport function createPlatformAdapterSafe(): VanaPlatformAdapter {\n // Always return browser adapter in browser environments\n return createBrowserPlatformAdapter();\n}\n\n// Export types\nexport type { VanaPlatformAdapter } from \"./interface\";\nexport type { BrowserPlatformAdapter } from \"./browser\";\n","/**\n * Platform detection and adapter utilities\n *\n * This module provides utilities for detecting the current runtime environment\n * and creating appropriate platform adapters automatically.\n */\n\nimport type { VanaPlatformAdapter, PlatformType } from \"./interface\";\n\n/**\n * Detects the current runtime environment\n *\n * @returns The detected platform type\n */\nexport function detectPlatform(): PlatformType {\n // Check for Node.js environment\n if (\n typeof process !== \"undefined\" &&\n process.versions &&\n process.versions.node\n ) {\n return \"node\";\n }\n\n // Check for browser environment\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n return \"browser\";\n }\n\n // Default to Node.js if we can't determine (e.g., SSR environments)\n return \"node\";\n}\n\n/**\n * Creates the appropriate platform adapter based on the current environment\n *\n * @returns A platform adapter instance for the current environment\n * @throws {Error} If platform adapters cannot be imported or created\n */\nexport async function createPlatformAdapter(): Promise<VanaPlatformAdapter> {\n const platform = detectPlatform();\n\n try {\n if (platform === \"node\") {\n // Check if we're in a browser environment\n if (typeof window !== \"undefined\") {\n throw new Error(\n \"NodePlatformAdapter is not available in browser environments. Use BrowserPlatformAdapter instead.\",\n );\n }\n\n // Use string concatenation to avoid static analysis\n const moduleName = \"./node\";\n const { NodePlatformAdapter } = await import(moduleName);\n return new NodePlatformAdapter();\n } else {\n const { BrowserPlatformAdapter } = await import(\"./browser\");\n return new BrowserPlatformAdapter();\n }\n } catch (error) {\n throw new Error(\n `Failed to create platform adapter for ${platform}: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n );\n }\n}\n\n/**\n * Creates a platform adapter for a specific platform type\n *\n * @param platformType - The platform type to create an adapter for\n * @returns A platform adapter instance for the specified platform\n * @throws {Error} If platform adapters cannot be imported or created\n */\nexport async function createPlatformAdapterFor(\n platformType: PlatformType,\n): Promise<VanaPlatformAdapter> {\n try {\n if (platformType === \"node\") {\n // Check if we're in a browser environment\n if (typeof window !== \"undefined\") {\n throw new Error(\n \"NodePlatformAdapter is not available in browser environments. Use BrowserPlatformAdapter instead.\",\n );\n }\n\n // Use string concatenation to avoid static analysis\n const moduleName = \"./node\";\n const { NodePlatformAdapter } = await import(moduleName);\n return new NodePlatformAdapter();\n } else {\n const { BrowserPlatformAdapter } = await import(\"./browser\");\n return new BrowserPlatformAdapter();\n }\n } catch (error) {\n throw new Error(\n `Failed to create platform adapter for ${platformType}: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n );\n }\n}\n\n/**\n * Checks if the current environment supports the given platform adapter\n *\n * @param platformType - The platform type to check\n * @returns True if the platform is supported, false otherwise\n */\nexport function isPlatformSupported(platformType: PlatformType): boolean {\n const currentPlatform = detectPlatform();\n return currentPlatform === platformType;\n}\n\n/**\n * Gets platform-specific capabilities\n *\n * @returns Object describing available platform capabilities\n */\nexport function getPlatformCapabilities() {\n const platform = detectPlatform();\n\n return {\n platform,\n crypto: {\n webCrypto: typeof crypto !== \"undefined\" && crypto.subtle,\n nodeCrypto:\n typeof process !== \"undefined\" &&\n process.versions &&\n process.versions.node,\n },\n fetch:\n typeof fetch !== \"undefined\" || typeof globalThis.fetch !== \"undefined\",\n streams: typeof ReadableStream !== \"undefined\",\n };\n}\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,IAC5C,YAAY,gBAAgB,MAAM,IAAI,GAAG;AAAA,IACzC,KAAK,gBAAgB,MAAM,GAAG;AAAA,EAChC;AACF;AAsBO,SAAS,gBAAgB,OAA2B;AACzD,SAAO,MAAM,KAAK,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE;AAAA,IACrE;AAAA,EACF;AACF;AAjFA;AAAA;AAAA;AAAA;AAAA;;;ACyBO,SAAS,qBAAqB,SAIlC;AACD,SAAO;AAAA,IACL,MAAM,SAAS,QAAQ;AAAA,IACvB,OAAO,SAAS,SAAS;AAAA,IACzB,YAAY,SAAS;AAAA,EACvB;AACF;AAYO,SAAS,mBAAmB,SAIhC;AACD,QAAM,EAAE,MAAM,OAAO,WAAW,I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O,oBAAoB;AAC7B;AAOO,SAAS,0BAA0B;AACxC,QAAM,WAAW,eAAe;AAEhC,SAAO;AAAA,IACL;AAAA,IACA,QAAQ;AAAA,MACN,WAAW,OAAO,WAAW,eAAe,OAAO;AAAA,MACnD,YACE,OAAO,YAAY,eACnB,QAAQ,YACR,QAAQ,SAAS;AAAA,IACrB;AAAA,IACA,OACE,OAAO,UAAU,eAAe,OAAO,WAAW,UAAU;AAAA,IAC9D,SAAS,OAAO,mBAAmB;AAAA,EACrC;AACF;","names":["openpgp"]}
|
|
1
|
+
{"version":3,"sources":["../src/platform/shared/crypto-utils.ts","../src/platform/shared/pgp-utils.ts","../src/platform/shared/error-utils.ts","../src/platform/browser.ts","../src/platform.browser.ts","../src/platform/browser-only.ts","../src/platform/utils.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 * 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\nimport * as openpgp from \"openpgp\";\nimport {\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\";\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 import(\"openpgp\");\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 import(\"openpgp\");\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 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 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 // 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","/**\n * Browser-specific platform adapters entry point\n *\n * This module provides browser-safe platform utilities without Node.js dependencies.\n */\n\n// Export browser platform adapter\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\n\n// Export platform interface\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Export browser-safe utilities only\nexport {\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-only\";\n\n// Export safe platform utilities (no Node.js imports)\nexport {\n detectPlatform,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n","/**\n * Browser-only exports for platform adapters\n *\n * This file provides browser-only exports that completely avoid Node.js imports\n * when bundling for browser environments. This is used by the browser entry point.\n */\n\nimport type { VanaPlatformAdapter } from \"./interface\";\nimport { BrowserPlatformAdapter } from \"./browser\";\n\n/**\n * Creates a BrowserPlatformAdapter instance\n *\n * @returns A BrowserPlatformAdapter instance\n */\nexport function createBrowserPlatformAdapter(): VanaPlatformAdapter {\n return new BrowserPlatformAdapter();\n}\n\n/**\n * Browser-only platform adapter factory\n * This version does not include Node.js imports at all\n *\n * @returns A BrowserPlatformAdapter instance\n */\nexport function createPlatformAdapterSafe(): VanaPlatformAdapter {\n // Always return browser adapter in browser environments\n return createBrowserPlatformAdapter();\n}\n\n// Export types\nexport type { VanaPlatformAdapter } from \"./interface\";\nexport type { BrowserPlatformAdapter } from \"./browser\";\n","/**\n * Platform detection and adapter utilities\n *\n * This module provides utilities for detecting the current runtime environment\n * and creating appropriate platform adapters automatically.\n */\n\nimport type { VanaPlatformAdapter, PlatformType } from \"./interface\";\n\n/**\n * Detects the current runtime environment\n *\n * @returns The detected platform type\n */\nexport function detectPlatform(): PlatformType {\n // Check for Node.js environment\n if (\n typeof process !== \"undefined\" &&\n process.versions &&\n process.versions.node\n ) {\n return \"node\";\n }\n\n // Check for browser environment\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n return \"browser\";\n }\n\n // Default to Node.js if we can't determine (e.g., SSR environments)\n return \"node\";\n}\n\n/**\n * Creates the appropriate platform adapter based on the current environment\n *\n * @returns A platform adapter instance for the current environment\n * @throws {Error} If platform adapters cannot be imported or created\n */\nexport async function createPlatformAdapter(): Promise<VanaPlatformAdapter> {\n const platform = detectPlatform();\n\n try {\n if (platform === \"node\") {\n // Check if we're in a browser environment\n if (typeof window !== \"undefined\") {\n throw new Error(\n \"NodePlatformAdapter is not available in browser environments. Use BrowserPlatformAdapter instead.\",\n );\n }\n\n // Use string concatenation to avoid static analysis\n const moduleName = \"./node\";\n const { NodePlatformAdapter } = await import(moduleName);\n return new NodePlatformAdapter();\n } else {\n const { BrowserPlatformAdapter } = await import(\"./browser\");\n return new BrowserPlatformAdapter();\n }\n } catch (error) {\n throw new Error(\n `Failed to create platform adapter for ${platform}: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n );\n }\n}\n\n/**\n * Creates a platform adapter for a specific platform type\n *\n * @param platformType - The platform type to create an adapter for\n * @returns A platform adapter instance for the specified platform\n * @throws {Error} If platform adapters cannot be imported or created\n */\nexport async function createPlatformAdapterFor(\n platformType: PlatformType,\n): Promise<VanaPlatformAdapter> {\n try {\n if (platformType === \"node\") {\n // Check if we're in a browser environment\n if (typeof window !== \"undefined\") {\n throw new Error(\n \"NodePlatformAdapter is not available in browser environments. Use BrowserPlatformAdapter instead.\",\n );\n }\n\n // Use string concatenation to avoid static analysis\n const moduleName = \"./node\";\n const { NodePlatformAdapter } = await import(moduleName);\n return new NodePlatformAdapter();\n } else {\n const { BrowserPlatformAdapter } = await import(\"./browser\");\n return new BrowserPlatformAdapter();\n }\n } catch (error) {\n throw new Error(\n `Failed to create platform adapter for ${platformType}: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n );\n }\n}\n\n/**\n * Checks if the current environment supports the given platform adapter\n *\n * @param platformType - The platform type to check\n * @returns True if the platform is supported, false otherwise\n */\nexport function isPlatformSupported(platformType: PlatformType): boolean {\n const currentPlatform = detectPlatform();\n return currentPlatform === platformType;\n}\n\n/**\n * Gets platform-specific capabilities\n *\n * @returns Object describing available platform capabilities\n */\nexport function getPlatformCapabilities() {\n const platform = detectPlatform();\n\n return {\n platform,\n crypto: {\n webCrypto: typeof crypto !== \"undefined\" && crypto.subtle,\n nodeCrypto:\n typeof process !== \"undefined\" &&\n process.versions &&\n process.versions.node,\n },\n fetch:\n typeof fetch !== \"undefined\" || typeof globalThis.fetch !== \"undefined\",\n streams: typeof ReadableStream !== \"undefined\",\n };\n}\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,OAA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