@opendatalabs/vana-sdk 0.1.0-alpha.8eb4e46 → 0.1.0-alpha.9a32094

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -116,11 +116,15 @@ const files = await vana.data.getUserFiles({
116
116
  owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
117
117
  });
118
118
 
119
- // Upload encrypted file
120
- const result = await vana.data.uploadEncryptedFile({
121
- data: encryptedBlob,
122
- schemaId: 123,
119
+ // Upload encrypted file with decryption permissions
120
+ const result = await vana.data.upload({
121
+ content: "Sensitive user data",
123
122
  filename: "user-data.json",
123
+ schemaId: 123,
124
+ permissions: [{
125
+ account: "0xServerAddress...", // Who can decrypt
126
+ publicKey: "0x04ServerKey..." // Their public key
127
+ }]
124
128
  });
125
129
  ```
126
130
 
@@ -220,43 +224,40 @@ try {
220
224
 
221
225
  ## Examples
222
226
 
223
- ### Complete Permission Flow
227
+ ### Complete Data Sharing Flow
224
228
 
225
229
  ```typescript
226
- import {
227
- Vana,
228
- generateEncryptionKey,
229
- encryptBlobWithSignedKey,
230
- } from "@opendatalabs/vana-sdk/browser";
230
+ import { Vana } from "@opendatalabs/vana-sdk/browser";
231
231
  // OR for server-side applications
232
232
  // } from "@opendatalabs/vana-sdk/node";
233
233
 
234
- async function grantDataPermission() {
234
+ async function shareDataWithServer() {
235
235
  const vana = Vana({ walletClient });
236
236
 
237
- // 1. Encrypt user data
238
- const encryptionKey = await generateEncryptionKey(walletClient);
239
- const userData = new Blob([JSON.stringify({ data: "sensitive info" })]);
240
- const encryptedData = await encryptBlobWithSignedKey(userData, encryptionKey);
241
-
242
- // 2. Upload encrypted file
243
- const uploadResult = await vana.data.uploadEncryptedFile({
244
- data: encryptedData,
237
+ // Step 1: Upload encrypted file with decryption permissions
238
+ const uploadResult = await vana.data.upload({
239
+ content: { data: "sensitive medical records" },
240
+ filename: "health-data.json",
245
241
  schemaId: 123,
246
- filename: "user-data.json",
242
+ permissions: [{
243
+ // Grant decryption access to the AI server
244
+ account: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
245
+ publicKey: "0x04abc..." // Server's public key for encryption
246
+ }]
247
247
  });
248
248
 
249
- // 3. Grant permission
250
- const permissionTx = await vana.permissions.grant({
249
+ // Step 2: Grant operation permissions for what the server can do
250
+ const permissionResult = await vana.permissions.grant({
251
251
  grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
252
- operation: "ai_training",
252
+ fileIds: [BigInt(uploadResult.fileId)],
253
+ operation: "medical_analysis",
253
254
  parameters: {
254
- files: [uploadResult.fileId],
255
- model: "llm-v1",
255
+ model: "medical-ai-v2",
256
+ analysisType: "comprehensive",
256
257
  },
257
258
  });
258
259
 
259
- return permissionTx;
260
+ return { uploadResult, permissionResult };
260
261
  }
261
262
  ```
262
263
 
@@ -294,13 +295,14 @@ vana.data.validateDataAgainstSchema(userData, schema);
294
295
  ### Permissions
295
296
 
296
297
  ```typescript
297
- // Grant permission
298
+ // Grant operation permission
298
299
  await vana.permissions.grant({
299
300
  grantee: Address,
301
+ fileIds: bigint[],
300
302
  operation: string,
301
303
  parameters: object,
302
304
  expiresAt?: number
303
- }): Promise<Hash>
305
+ }): Promise<PermissionGrantResult>
304
306
 
305
307
  // Revoke permission
306
308
  await vana.permissions.revoke({
@@ -321,11 +323,16 @@ await vana.data.getUserFiles({
321
323
  owner: Address
322
324
  }): Promise<UserFile[]>
323
325
 
324
- // Upload encrypted file
325
- await vana.data.uploadEncryptedFile({
326
- data: Blob,
326
+ // Upload data with automatic encryption
327
+ await vana.data.upload({
328
+ content: string | Blob | Buffer,
329
+ filename?: string,
327
330
  schemaId?: number,
328
- filename?: string
331
+ permissions?: Array<{
332
+ account: Address, // Who can decrypt
333
+ publicKey: string // Their public key
334
+ }>,
335
+ encrypt?: boolean // Default: true
329
336
  }): Promise<UploadResult>
330
337
 
331
338
  // Validate schema