@opendatalabs/vana-sdk 3.8.3 → 3.10.0

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 (52) hide show
  1. package/README.md +31 -10
  2. package/dist/index.browser.d.ts +1 -1
  3. package/dist/index.browser.js +8 -0
  4. package/dist/index.browser.js.map +2 -2
  5. package/dist/index.node.cjs +8 -0
  6. package/dist/index.node.cjs.map +2 -2
  7. package/dist/index.node.d.ts +1 -1
  8. package/dist/index.node.js +8 -0
  9. package/dist/index.node.js.map +2 -2
  10. package/dist/protocol/gateway.cjs +8 -0
  11. package/dist/protocol/gateway.cjs.map +1 -1
  12. package/dist/protocol/gateway.d.ts +24 -0
  13. package/dist/protocol/gateway.js +8 -0
  14. package/dist/protocol/gateway.js.map +1 -1
  15. package/dist/session-relay/client.cjs +215 -0
  16. package/dist/session-relay/client.cjs.map +1 -0
  17. package/dist/session-relay/client.d.ts +16 -0
  18. package/dist/session-relay/client.js +190 -0
  19. package/dist/session-relay/client.js.map +1 -0
  20. package/dist/session-relay/client.test.d.ts +1 -0
  21. package/dist/session-relay/endpoints.cjs +37 -0
  22. package/dist/session-relay/endpoints.cjs.map +1 -0
  23. package/dist/session-relay/endpoints.d.ts +7 -0
  24. package/dist/session-relay/endpoints.js +11 -0
  25. package/dist/session-relay/endpoints.js.map +1 -0
  26. package/dist/session-relay/errors.cjs +36 -0
  27. package/dist/session-relay/errors.cjs.map +1 -0
  28. package/dist/session-relay/errors.d.ts +13 -0
  29. package/dist/session-relay/errors.js +12 -0
  30. package/dist/session-relay/errors.js.map +1 -0
  31. package/dist/session-relay/index.cjs +46 -0
  32. package/dist/session-relay/index.cjs.map +1 -0
  33. package/dist/session-relay/index.d.ts +5 -0
  34. package/dist/session-relay/index.js +25 -0
  35. package/dist/session-relay/index.js.map +1 -0
  36. package/dist/session-relay/signing.cjs +62 -0
  37. package/dist/session-relay/signing.cjs.map +1 -0
  38. package/dist/session-relay/signing.d.ts +21 -0
  39. package/dist/session-relay/signing.js +39 -0
  40. package/dist/session-relay/signing.js.map +1 -0
  41. package/dist/session-relay/signing.test.d.ts +1 -0
  42. package/dist/session-relay/types.cjs +17 -0
  43. package/dist/session-relay/types.cjs.map +1 -0
  44. package/dist/session-relay/types.d.ts +119 -0
  45. package/dist/session-relay/types.js +1 -0
  46. package/dist/session-relay/types.js.map +1 -0
  47. package/dist/session-relay.cjs +46 -0
  48. package/dist/session-relay.cjs.map +1 -0
  49. package/dist/session-relay.d.ts +27 -0
  50. package/dist/session-relay.js +27 -0
  51. package/dist/session-relay.js.map +1 -0
  52. package/package.json +10 -1
package/README.md CHANGED
@@ -29,6 +29,10 @@ encryption, storage providers, and a shared isomorphic platform layer.
29
29
  - **Storage providers** — `VanaStorage` (default, talks to `storage.vana.org`),
30
30
  `R2Storage`, `StorageManager`, `IpfsStorage`, `PinataStorage`,
31
31
  `GoogleDriveStorage`, `DropboxStorage`, `CallbackStorage`.
32
+ - **Vana service integrations** — `@opendatalabs/vana-sdk/server`,
33
+ `@opendatalabs/vana-sdk/react`, and `@opendatalabs/vana-sdk/session-relay`
34
+ for Vana-operated app handoff flows. These are integration helpers, not
35
+ protocol-core modules.
32
36
  - **Platform adapters** — `NodePlatformAdapter` and `BrowserPlatformAdapter`
33
37
  with a shared `VanaPlatformAdapter` interface, plus detection helpers
34
38
  (`detectPlatform`, `isPlatformSupported`, `createPlatformAdapter`,
@@ -104,12 +108,12 @@ const result = await storage.upload(myBlob, "report.json");
104
108
  console.log(result.url);
105
109
  ```
106
110
 
107
- ## Build a direct Vana app
111
+ ## Build a Vana app
108
112
 
109
113
  Request user-approved data, read it from the user's Personal Server, and pay
110
114
  for the read — without the browser ever seeing your app private key or choosing
111
- scopes. Your **backend** owns the controller (`@opendatalabs/vana-sdk/server`);
112
- your **frontend** drives a two-tab approval flow with a React hook
115
+ scopes. Your **backend** owns the Data Portability controller
116
+ (`@opendatalabs/vana-sdk/server`); your **frontend** drives a two-tab approval flow with a React hook
113
117
  (`@opendatalabs/vana-sdk/react`).
114
118
 
115
119
  > **How it fits together.** Access requests are created through the Vana Account
@@ -136,12 +140,12 @@ export const vana = createDirectDataController({
136
140
  network: process.env.VANA_NETWORK === "moksha" ? "moksha" : "mainnet",
137
141
  appPrivateKey: process.env.VANA_APP_PRIVATE_KEY!,
138
142
  app: {
139
- id: "notes-lens",
140
- name: "Notes Lens",
143
+ id: "spotify-taste",
144
+ name: "Spotify Taste",
141
145
  homepageUrl: process.env.VANA_APP_URL!,
142
146
  },
143
- source: "icloud_notes",
144
- scopes: ["icloud_notes.notes"],
147
+ source: "spotify",
148
+ scopes: ["spotify.savedTracks"],
145
149
  // Settle paid reads through the DPv2 escrow gateway. The controller signs the
146
150
  // GenericPayment with your app key; you supply the gateway client + contract.
147
151
  escrow: {
@@ -172,7 +176,7 @@ const status = await vana.getAccessRequestStatus(requestId);
172
176
  // GET /api/vana/data?requestId=...
173
177
  const result = await vana.readApprovedData({ requestId });
174
178
  // -> {
175
- // scope: "icloud_notes.notes",
179
+ // scope: "spotify.savedTracks",
176
180
  // data: ...,
177
181
  // payment?: { // present only when this read settled a payment
178
182
  // amount, asset, paymentNonce, paidAt,
@@ -194,7 +198,7 @@ amount and asset owed.
194
198
  "use client";
195
199
  import { useDirectVanaConnect } from "@opendatalabs/vana-sdk/react";
196
200
 
197
- export function ConnectNotesButton() {
201
+ export function ConnectSpotifyButton() {
198
202
  const connect = useDirectVanaConnect({
199
203
  createRequest: () =>
200
204
  fetch("/api/vana/request", { method: "POST" }).then((r) => r.json()),
@@ -214,7 +218,7 @@ export function ConnectNotesButton() {
214
218
  onClick={connect.start}
215
219
  type="button"
216
220
  >
217
- {connect.state.type === "idle" ? "Connect Apple Notes" : "Connecting..."}
221
+ {connect.state.type === "idle" ? "Connect Spotify" : "Connecting..."}
218
222
  </button>
219
223
  );
220
224
  }
@@ -225,6 +229,23 @@ until the request is approved, then calls `readResult`. `react` is an optional
225
229
  peer dependency. The underlying `createDirectConnectFlow` store is also exported
226
230
  for non-React frontends.
227
231
 
232
+ ### Test with large sample data
233
+
234
+ When testing with realistic exports, use the public fixture catalog in
235
+ [`vana-com/data-connectors`](https://github.com/vana-com/data-connectors). Keep
236
+ the payload in a file or raw URL and point your app or agent at that location.
237
+ Do not paste large JSON into the terminal.
238
+
239
+ The controller can run against local test data by injecting an
240
+ `accessRequestClient` that returns an approved request and a
241
+ `personalServerFetch` that loads the sample payload, while the rest of your app
242
+ still calls `readApprovedData`.
243
+
244
+ See [`examples/vana-app`](../../examples/vana-app) for a runnable Next.js Vana
245
+ app. It includes the route handlers, return page, and React connect button from
246
+ this flow, defaults to sample-data mode using `vana-com/data-connectors`, and
247
+ can be switched to live protocol mode with environment variables.
248
+
228
249
  ## Networks
229
250
 
230
251
  | Network | Chain ID | RPC URL |
@@ -48,6 +48,6 @@ export { DATA_REGISTRY_STATUS_ABI, DataPointStatus, dataRegistryContractAddress,
48
48
  export { personalServerDataReadPath, buildPersonalServerDataReadRequest, readPersonalServerData, type BuildPersonalServerDataReadRequestParams, type ReadPersonalServerDataParams, } from "./protocol/personal-server-data";
49
49
  export { ScopeSchema, parseScope, scopeToPathSegments, scopeMatchesPattern, scopeCoveredByGrant, type Scope, type ParsedScope, } from "./protocol/scopes";
50
50
  export { DataFileEnvelopeSchema, createDataFileEnvelope, IngestResponseSchema, type DataFileEnvelope, type IngestResponse, } from "./protocol/data-file";
51
- export { createGatewayClient, type GatewayEnvelope, type GatewayProof, type Builder, type Schema, type ServerInfo, type GatewayGrantFee, type GatewayGrantStatus, type GatewayGrantResponse, type GrantListItem, type DataPointRecord, type DataPointListResult, type ListDataPointsOptions, type RegisterServerParams, type RegisterServerResult, type RegisterBuilderParams, type RegisterBuilderResult, type RegisterDataPointParams, type RegisterDataPointResult, type CreateGrantParams, type RevokeGrantParams, type AccessRecord, type PayForOperationParams, type PayForOperationResult, type SettleOpType, type SettleItem, type SettlePromoteResult, type SettleReconcileItem, type SettleParams, type SettleResult, type GatewayClient, } from "./protocol/gateway";
51
+ export { createGatewayClient, type GatewayEnvelope, type GatewayProof, type Builder, type Schema, type ServerInfo, type OwnerServerRecord, type OwnerServersResult, type GatewayGrantFee, type GatewayGrantStatus, type GatewayGrantResponse, type GrantListItem, type DataPointRecord, type DataPointListResult, type ListDataPointsOptions, type RegisterServerParams, type RegisterServerResult, type RegisterBuilderParams, type RegisterBuilderResult, type RegisterDataPointParams, type RegisterDataPointResult, type CreateGrantParams, type RevokeGrantParams, type AccessRecord, type PayForOperationParams, type PayForOperationResult, type SettleOpType, type SettleItem, type SettlePromoteResult, type SettleReconcileItem, type SettleParams, type SettleResult, type GatewayClient, } from "./protocol/gateway";
52
52
  export { createEscrowGatewayClient, genericPaymentDomain, GENERIC_PAYMENT_TYPES, ESCROW_DEPOSIT_ABI, NATIVE_ASSET_ADDRESS, type GenericPaymentMessage, type EscrowBalanceEntry, type EscrowBalanceResult, type EscrowBalanceSyncResult, type DepositSubmissionResult, type PaymentBreakdown, type EscrowPayResult, type SubmitDepositParams, type PayForOpParams, type EscrowGatewayClient, type SubmittedDepositEntry, type FinalizedDepositEntry, type FailedDepositEntry, } from "./protocol/escrow";
53
53
  export { PSError, parsePSError, type PSErrorCode } from "./types/ps-errors";
@@ -32921,6 +32921,14 @@ function createGatewayClient(baseUrl) {
32921
32921
  }
32922
32922
  return unwrapEnvelope(res);
32923
32923
  },
32924
+ async listServersByOwner(owner) {
32925
+ const params = new URLSearchParams({ owner });
32926
+ const res = await fetch(`${base}/v1/servers?${params.toString()}`);
32927
+ if (!res.ok) {
32928
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32929
+ }
32930
+ return await res.json();
32931
+ },
32924
32932
  async getDataPoint(dataPointId) {
32925
32933
  const res = await fetch(`${base}/v1/data/${dataPointId}`);
32926
32934
  if (res.status === 404) return null;