vana-cli 0.15.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 (223) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +320 -0
  3. package/dist/cli/auth.d.ts +119 -0
  4. package/dist/cli/auth.d.ts.map +1 -0
  5. package/dist/cli/auth.js +528 -0
  6. package/dist/cli/auth.js.map +1 -0
  7. package/dist/cli/bin.d.ts +3 -0
  8. package/dist/cli/bin.d.ts.map +1 -0
  9. package/dist/cli/bin.js +15 -0
  10. package/dist/cli/bin.js.map +1 -0
  11. package/dist/cli/index.d.ts +92 -0
  12. package/dist/cli/index.d.ts.map +1 -0
  13. package/dist/cli/index.js +4703 -0
  14. package/dist/cli/index.js.map +1 -0
  15. package/dist/cli/main.d.ts +2 -0
  16. package/dist/cli/main.d.ts.map +1 -0
  17. package/dist/cli/main.js +10 -0
  18. package/dist/cli/main.js.map +1 -0
  19. package/dist/cli/mcp-server.d.ts +15 -0
  20. package/dist/cli/mcp-server.d.ts.map +1 -0
  21. package/dist/cli/mcp-server.js +199 -0
  22. package/dist/cli/mcp-server.js.map +1 -0
  23. package/dist/cli/queries.d.ts +128 -0
  24. package/dist/cli/queries.d.ts.map +1 -0
  25. package/dist/cli/queries.js +422 -0
  26. package/dist/cli/queries.js.map +1 -0
  27. package/dist/cli/render/capabilities.d.ts +9 -0
  28. package/dist/cli/render/capabilities.d.ts.map +1 -0
  29. package/dist/cli/render/capabilities.js +24 -0
  30. package/dist/cli/render/capabilities.js.map +1 -0
  31. package/dist/cli/render/connect-renderer.d.ts +23 -0
  32. package/dist/cli/render/connect-renderer.d.ts.map +1 -0
  33. package/dist/cli/render/connect-renderer.js +259 -0
  34. package/dist/cli/render/connect-renderer.js.map +1 -0
  35. package/dist/cli/render/flow-theme.d.ts +17 -0
  36. package/dist/cli/render/flow-theme.d.ts.map +1 -0
  37. package/dist/cli/render/flow-theme.js +26 -0
  38. package/dist/cli/render/flow-theme.js.map +1 -0
  39. package/dist/cli/render/format.d.ts +27 -0
  40. package/dist/cli/render/format.d.ts.map +1 -0
  41. package/dist/cli/render/format.js +111 -0
  42. package/dist/cli/render/format.js.map +1 -0
  43. package/dist/cli/render/index.d.ts +8 -0
  44. package/dist/cli/render/index.d.ts.map +1 -0
  45. package/dist/cli/render/index.js +8 -0
  46. package/dist/cli/render/index.js.map +1 -0
  47. package/dist/cli/render/progress.d.ts +11 -0
  48. package/dist/cli/render/progress.d.ts.map +1 -0
  49. package/dist/cli/render/progress.js +56 -0
  50. package/dist/cli/render/progress.js.map +1 -0
  51. package/dist/cli/render/symbols.d.ts +11 -0
  52. package/dist/cli/render/symbols.d.ts.map +1 -0
  53. package/dist/cli/render/symbols.js +21 -0
  54. package/dist/cli/render/symbols.js.map +1 -0
  55. package/dist/cli/render/theme.d.ts +16 -0
  56. package/dist/cli/render/theme.d.ts.map +1 -0
  57. package/dist/cli/render/theme.js +57 -0
  58. package/dist/cli/render/theme.js.map +1 -0
  59. package/dist/cli/search-select.d.ts +17 -0
  60. package/dist/cli/search-select.d.ts.map +1 -0
  61. package/dist/cli/search-select.js +29 -0
  62. package/dist/cli/search-select.js.map +1 -0
  63. package/dist/cli/telemetry-contract.d.ts +146 -0
  64. package/dist/cli/telemetry-contract.d.ts.map +1 -0
  65. package/dist/cli/telemetry-contract.js +56 -0
  66. package/dist/cli/telemetry-contract.js.map +1 -0
  67. package/dist/cli/telemetry.d.ts +60 -0
  68. package/dist/cli/telemetry.d.ts.map +1 -0
  69. package/dist/cli/telemetry.js +621 -0
  70. package/dist/cli/telemetry.js.map +1 -0
  71. package/dist/cli/update-check.d.ts +21 -0
  72. package/dist/cli/update-check.d.ts.map +1 -0
  73. package/dist/cli/update-check.js +86 -0
  74. package/dist/cli/update-check.js.map +1 -0
  75. package/dist/connectors/index.d.ts +2 -0
  76. package/dist/connectors/index.d.ts.map +1 -0
  77. package/dist/connectors/index.js +2 -0
  78. package/dist/connectors/index.js.map +1 -0
  79. package/dist/connectors/registry.d.ts +55 -0
  80. package/dist/connectors/registry.d.ts.map +1 -0
  81. package/dist/connectors/registry.js +301 -0
  82. package/dist/connectors/registry.js.map +1 -0
  83. package/dist/core/cli-types.d.ts +722 -0
  84. package/dist/core/cli-types.d.ts.map +1 -0
  85. package/dist/core/cli-types.js +328 -0
  86. package/dist/core/cli-types.js.map +1 -0
  87. package/dist/core/constants.d.ts +33 -0
  88. package/dist/core/constants.d.ts.map +1 -0
  89. package/dist/core/constants.js +25 -0
  90. package/dist/core/constants.js.map +1 -0
  91. package/dist/core/errors.d.ts +47 -0
  92. package/dist/core/errors.d.ts.map +1 -0
  93. package/dist/core/errors.js +50 -0
  94. package/dist/core/errors.js.map +1 -0
  95. package/dist/core/grants.d.ts +19 -0
  96. package/dist/core/grants.d.ts.map +1 -0
  97. package/dist/core/grants.js +31 -0
  98. package/dist/core/grants.js.map +1 -0
  99. package/dist/core/index.d.ts +9 -0
  100. package/dist/core/index.d.ts.map +1 -0
  101. package/dist/core/index.js +7 -0
  102. package/dist/core/index.js.map +1 -0
  103. package/dist/core/paths.d.ts +30 -0
  104. package/dist/core/paths.d.ts.map +1 -0
  105. package/dist/core/paths.js +95 -0
  106. package/dist/core/paths.js.map +1 -0
  107. package/dist/core/state-store.d.ts +44 -0
  108. package/dist/core/state-store.d.ts.map +1 -0
  109. package/dist/core/state-store.js +101 -0
  110. package/dist/core/state-store.js.map +1 -0
  111. package/dist/core/types.d.ts +148 -0
  112. package/dist/core/types.d.ts.map +1 -0
  113. package/dist/core/types.js +2 -0
  114. package/dist/core/types.js.map +1 -0
  115. package/dist/index.d.ts +2 -0
  116. package/dist/index.d.ts.map +1 -0
  117. package/dist/index.js +2 -0
  118. package/dist/index.js.map +1 -0
  119. package/dist/personal-server/client.d.ts +34 -0
  120. package/dist/personal-server/client.d.ts.map +1 -0
  121. package/dist/personal-server/client.js +108 -0
  122. package/dist/personal-server/client.js.map +1 -0
  123. package/dist/personal-server/index.d.ts +28 -0
  124. package/dist/personal-server/index.d.ts.map +1 -0
  125. package/dist/personal-server/index.js +157 -0
  126. package/dist/personal-server/index.js.map +1 -0
  127. package/dist/personal-server/scope-resolver.d.ts +22 -0
  128. package/dist/personal-server/scope-resolver.d.ts.map +1 -0
  129. package/dist/personal-server/scope-resolver.js +80 -0
  130. package/dist/personal-server/scope-resolver.js.map +1 -0
  131. package/dist/react/ConnectButton.d.ts +27 -0
  132. package/dist/react/ConnectButton.d.ts.map +1 -0
  133. package/dist/react/ConnectButton.js +39 -0
  134. package/dist/react/ConnectButton.js.map +1 -0
  135. package/dist/react/index.d.ts +4 -0
  136. package/dist/react/index.d.ts.map +1 -0
  137. package/dist/react/index.js +4 -0
  138. package/dist/react/index.js.map +1 -0
  139. package/dist/react/useVanaConnect.d.ts +50 -0
  140. package/dist/react/useVanaConnect.d.ts.map +1 -0
  141. package/dist/react/useVanaConnect.js +114 -0
  142. package/dist/react/useVanaConnect.js.map +1 -0
  143. package/dist/react/useVanaData.d.ts +69 -0
  144. package/dist/react/useVanaData.d.ts.map +1 -0
  145. package/dist/react/useVanaData.js +144 -0
  146. package/dist/react/useVanaData.js.map +1 -0
  147. package/dist/runtime/core/contracts.d.ts +84 -0
  148. package/dist/runtime/core/contracts.d.ts.map +1 -0
  149. package/dist/runtime/core/contracts.js +2 -0
  150. package/dist/runtime/core/contracts.js.map +1 -0
  151. package/dist/runtime/core/index.d.ts +2 -0
  152. package/dist/runtime/core/index.d.ts.map +1 -0
  153. package/dist/runtime/core/index.js +2 -0
  154. package/dist/runtime/core/index.js.map +1 -0
  155. package/dist/runtime/index.d.ts +4 -0
  156. package/dist/runtime/index.d.ts.map +1 -0
  157. package/dist/runtime/index.js +3 -0
  158. package/dist/runtime/index.js.map +1 -0
  159. package/dist/runtime/managed-playwright.d.ts +42 -0
  160. package/dist/runtime/managed-playwright.d.ts.map +1 -0
  161. package/dist/runtime/managed-playwright.js +178 -0
  162. package/dist/runtime/managed-playwright.js.map +1 -0
  163. package/dist/runtime/playwright/browser.d.ts +12 -0
  164. package/dist/runtime/playwright/browser.d.ts.map +1 -0
  165. package/dist/runtime/playwright/browser.js +229 -0
  166. package/dist/runtime/playwright/browser.js.map +1 -0
  167. package/dist/runtime/playwright/in-process-run.d.ts +6 -0
  168. package/dist/runtime/playwright/in-process-run.d.ts.map +1 -0
  169. package/dist/runtime/playwright/in-process-run.js +625 -0
  170. package/dist/runtime/playwright/in-process-run.js.map +1 -0
  171. package/dist/runtime/playwright/index.d.ts +3 -0
  172. package/dist/runtime/playwright/index.d.ts.map +1 -0
  173. package/dist/runtime/playwright/index.js +3 -0
  174. package/dist/runtime/playwright/index.js.map +1 -0
  175. package/dist/runtime/repo-paths.d.ts +2 -0
  176. package/dist/runtime/repo-paths.d.ts.map +1 -0
  177. package/dist/runtime/repo-paths.js +36 -0
  178. package/dist/runtime/repo-paths.js.map +1 -0
  179. package/dist/server/config.d.ts +38 -0
  180. package/dist/server/config.d.ts.map +1 -0
  181. package/dist/server/config.js +45 -0
  182. package/dist/server/config.js.map +1 -0
  183. package/dist/server/connect.d.ts +43 -0
  184. package/dist/server/connect.d.ts.map +1 -0
  185. package/dist/server/connect.js +115 -0
  186. package/dist/server/connect.js.map +1 -0
  187. package/dist/server/data-client.d.ts +31 -0
  188. package/dist/server/data-client.d.ts.map +1 -0
  189. package/dist/server/data-client.js +95 -0
  190. package/dist/server/data-client.js.map +1 -0
  191. package/dist/server/index.d.ts +8 -0
  192. package/dist/server/index.d.ts.map +1 -0
  193. package/dist/server/index.js +8 -0
  194. package/dist/server/index.js.map +1 -0
  195. package/dist/server/manifest-signer.d.ts +25 -0
  196. package/dist/server/manifest-signer.d.ts.map +1 -0
  197. package/dist/server/manifest-signer.js +51 -0
  198. package/dist/server/manifest-signer.js.map +1 -0
  199. package/dist/server/request-signer.d.ts +31 -0
  200. package/dist/server/request-signer.d.ts.map +1 -0
  201. package/dist/server/request-signer.js +72 -0
  202. package/dist/server/request-signer.js.map +1 -0
  203. package/dist/server/session-relay.d.ts +39 -0
  204. package/dist/server/session-relay.d.ts.map +1 -0
  205. package/dist/server/session-relay.js +74 -0
  206. package/dist/server/session-relay.js.map +1 -0
  207. package/dist/server/webhook.d.ts +11 -0
  208. package/dist/server/webhook.d.ts.map +1 -0
  209. package/dist/server/webhook.js +18 -0
  210. package/dist/server/webhook.js.map +1 -0
  211. package/dist/skills/index.d.ts +4 -0
  212. package/dist/skills/index.d.ts.map +1 -0
  213. package/dist/skills/index.js +3 -0
  214. package/dist/skills/index.js.map +1 -0
  215. package/dist/skills/paths.d.ts +33 -0
  216. package/dist/skills/paths.d.ts.map +1 -0
  217. package/dist/skills/paths.js +81 -0
  218. package/dist/skills/paths.js.map +1 -0
  219. package/dist/skills/registry.d.ts +48 -0
  220. package/dist/skills/registry.d.ts.map +1 -0
  221. package/dist/skills/registry.js +173 -0
  222. package/dist/skills/registry.js.map +1 -0
  223. package/package.json +147 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OpenDataLabs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,320 @@
1
+ # OpenDataLabs Context Gateway JavaScript SDK
2
+
3
+ `vana-cli` is the JavaScript client SDK for
4
+ [OpenDataLabs Context Gateway](https://www.opendatalabs.com/context-gateway).
5
+ Use it to let users connect their own data to your app.
6
+
7
+ ## CLI
8
+
9
+ The `vana` CLI collects your personal data from any platform. See the **[CLI README](./cli/README.md)**.
10
+
11
+ Install on macOS with Homebrew:
12
+
13
+ ```bash
14
+ brew tap vana-com/tap
15
+ brew install vana
16
+ vana status
17
+ ```
18
+
19
+ Or use the hosted prerelease installer on macOS/Linux:
20
+
21
+ ```bash
22
+ curl -fsSL https://raw.githubusercontent.com/vana-com/vana-cli/main/install/install.sh | sh
23
+ ```
24
+
25
+ Branch prerelease:
26
+
27
+ - `https://github.com/vana-com/vana-cli/releases/tag/canary-feat-connect-cli-v1`
28
+
29
+ Once installed:
30
+
31
+ ```bash
32
+ vana connect linkedin
33
+ ```
34
+
35
+ ## What problem this solves
36
+
37
+ Your users already have rich personal data — ChatGPT conversations, Instagram activity, Gmail, purchase history — but it's locked inside the platforms that collected it. As a builder, you can't easily use that data to personalize onboarding, tailor recommendations, or skip lengthy signup forms.
38
+
39
+ **Data portability** means users can export their data from these platforms and grant your app scoped access to it — with their explicit consent, cryptographic verification, and full control over what's shared and when to revoke it.
40
+
41
+ Today, getting access to user data means asking for manual file uploads (high friction), scraping on their behalf (fragile and legally risky), or negotiating enterprise API deals (slow and expensive). This SDK gives you a standardized way to request and receive personal data through Vana's [Data Portability Protocol](https://docs.vana.org/), handling session creation, grant verification, and data fetching in three function calls.
42
+
43
+ ## How it works
44
+
45
+ ```
46
+ Your App Vana Protocol
47
+ ────────────────────────────── ──────────────────────────────
48
+
49
+ 1. connect({ scopes })
50
+ → creates session
51
+ → returns deep link ──▶ 2. User opens DataConnect
52
+ reviews scopes, exports data,
53
+ approves grant
54
+
55
+ 3. Poll resolves with grant ◀── Grant signed & registered
56
+
57
+ 4. getData({ grant }) ──▶ 5. Personal Server returns
58
+ → structured JSON user data over TLS
59
+ ```
60
+
61
+ The [Data Portability Protocol](https://docs.vana.org/) defines how users collect data from platforms, store it under their control (on-device or hosted), and grant third-party apps scoped access. This SDK handles session creation, cryptographic request signing, polling, and data fetching. You write three function calls; the protocol handles the rest.
62
+
63
+ ## Getting started
64
+
65
+ The fastest way to get up and running is with the `examples/nextjs-starter` — a complete working app which uses the development environment and has full flow of data portability wired up:
66
+
67
+ ```bash
68
+ git clone https://github.com/vana-com/vana-cli.git
69
+ cd vana-connect/examples/nextjs-starter
70
+ cp .env.local.example .env.local
71
+ ```
72
+
73
+ Use the pre-registered dev key in .env.local. Note that this private key is ONLY for testing and works only with a testing Vana environment.
74
+
75
+ ```
76
+ VANA_PRIVATE_KEY=0x3c05ac1a00546bc0b1b8d3a11fb908409005fac3f26d25f70711e4f632e720d3
77
+ APP_URL=http://localhost:3001
78
+ ```
79
+
80
+ Install and run
81
+
82
+ ```
83
+ pnpm install
84
+ pnpm dev
85
+ ```
86
+
87
+ Note that while testing this example app, you should have a development version of the [DataConnect app](https://github.com/vana-com/data-connect?tab=readme-ov-file#development).
88
+
89
+ There is one caveat in development: the deep-link for DataConnect app doesn't open the dev version of the app.
90
+ This means that when testing your app from the end user perspective, once you see this screen:
91
+ <img width="627" height="560" alt="Screenshot 2026-02-21 at 15 02 58" src="https://github.com/user-attachments/assets/477ae78f-d84d-4178-a1e9-48abedf36946" />
92
+
93
+ Instead of clicking the "Launch DataConnect" button, you should right-click on it and copy its address. The address will be something like `vana://connect?sessionId=...`.
94
+
95
+ Then, in your dev version of DataConnect (likely built from the `main` branch) you will see a place to copy the link in the right-bottom corner of the app:
96
+
97
+ <img width="348" height="258" alt="Screenshot 2026-02-21 at 15 09 18" src="https://github.com/user-attachments/assets/9f9d7a14-c92e-4185-bdc2-a2d93282c748" />
98
+
99
+ ---
100
+
101
+ ## Manual integration
102
+
103
+ If you prefer to integrate the SDK into an existing project, follow the steps below.
104
+
105
+ ## Headless CLI
106
+
107
+ `vana-connect` now also ships a local collection CLI for connector setup and data export flows.
108
+
109
+ If you only care about the CLI, start with [docs/CLI-README.md](./docs/CLI-README.md).
110
+
111
+ For the full CLI review surface, use:
112
+
113
+ - [CLI review surface](./docs/CLI-REVIEW-SURFACE.md)
114
+ - [CLI transcripts](./docs/transcripts/README.md)
115
+ - [CLI demos](./docs/vhs/README.md)
116
+
117
+ `pnpm build:sea` uses Node 25's `--build-sea` flow to create a small `vana` launcher and packages the real app payload next to it under `app/`.
118
+ It produces a platform-specific release directory plus a release archive and matching checksum file under `artifacts/sea/`.
119
+
120
+ ### Programmatic runtime access
121
+
122
+ If you are building an app surface like DataConnect Desktop or a hosted orchestration layer, use the SDK modules instead of shelling out to the CLI where possible.
123
+
124
+ ```ts
125
+ import { ManagedPlaywrightRuntime } from "vana-cli/runtime";
126
+ import { listAvailableSources } from "vana-cli/connectors";
127
+ ```
128
+
129
+ Intended split:
130
+
131
+ - app surfaces consume SDK/runtime APIs
132
+ - agent skills consume the CLI
133
+ - `data-connectors` remains the connector and schema source of truth
134
+
135
+ ### Installation
136
+
137
+ ```bash
138
+ pnpm add vana-cli
139
+ ```
140
+
141
+ ### Package manager
142
+
143
+ This repo is pnpm-only for local development and examples. Use `pnpm` commands, not `npm`.
144
+
145
+ ### Prerequisites
146
+
147
+ First, register your app in the [Developer Portal](https://vana-developers.replit.app/). You will need to provide the URL where your app will be deployed, and then be given a private key after registration.
148
+
149
+ ### Quickstart
150
+
151
+ #### 1. Create a session (server)
152
+
153
+ ```typescript
154
+ import { connect } from "vana-cli/server";
155
+
156
+ const session = await connect({
157
+ privateKey: process.env.VANA_APP_PRIVATE_KEY as `0x${string}`,
158
+ scopes: ["chatgpt.conversations"],
159
+ webhookUrl: "https://yourapp.com/api/webhook", // optional, data can be pushed to a web hook after a grant is approved
160
+ appUserId: "yourapp-user-42", // optional: correlate your app user with the data they provided
161
+ });
162
+
163
+ // Return to your frontend:
164
+ // session.sessionId — used for polling
165
+ // session.connectUrl — opens the Vana account page → launches DataConnect
166
+ // session.expiresAt — ISO 8601 expiration
167
+ ```
168
+
169
+ #### 2. Poll for user approval (client)
170
+
171
+ ```tsx
172
+ import { useVanaConnect } from "vana-cli/react";
173
+
174
+ function ConnectData({ sessionId }: { sessionId: string }) {
175
+ const { connect, status, grant, connectUrl } = useVanaConnect();
176
+
177
+ useEffect(() => {
178
+ connect({ sessionId });
179
+ }, [sessionId]);
180
+
181
+ if (status === "waiting" && connectUrl) {
182
+ return <a href={connectUrl}>Connect your data</a>;
183
+ }
184
+ if (status === "approved" && grant) {
185
+ // grant.grantId, grant.userAddress, grant.scopes are available
186
+ return <p>Connected.</p>;
187
+ }
188
+ return <p>{status}</p>;
189
+ }
190
+ ```
191
+
192
+ Or use the pre-built button:
193
+
194
+ ```tsx
195
+ import { ConnectButton } from "vana-cli/react";
196
+
197
+ <ConnectButton
198
+ sessionId={sessionId}
199
+ onComplete={(grant) => saveGrant(grant)}
200
+ onError={(err) => console.error(err)}
201
+ />;
202
+ ```
203
+
204
+ #### 3. Fetch user data (server)
205
+
206
+ ```typescript
207
+ import { getData } from "vana-cli/server";
208
+
209
+ const data = await getData({
210
+ privateKey: process.env.VANA_APP_PRIVATE_KEY as `0x${string}`,
211
+ grant, // GrantPayload from step 2
212
+ });
213
+
214
+ // Record<string, unknown> keyed by scope
215
+ const conversations = data["chatgpt.conversations"];
216
+ ```
217
+
218
+ #### Web App Manifest
219
+
220
+ The DataConnect App verifies your identity by fetching your manifest. Use `signVanaManifest()` to generate it:
221
+
222
+ ```typescript
223
+ import { signVanaManifest } from "vana-cli/server";
224
+
225
+ // In your manifest route handler (e.g. Next.js /manifest.json/route.ts):
226
+ const vanaBlock = await signVanaManifest({
227
+ privateKey: process.env.VANA_APP_PRIVATE_KEY as `0x${string}`,
228
+ appUrl: "https://yourapp.com",
229
+ privacyPolicyUrl: "https://yourapp.com/privacy",
230
+ termsUrl: "https://yourapp.com/terms",
231
+ supportUrl: "https://yourapp.com/support",
232
+ webhookUrl: "https://yourapp.com/api/webhook",
233
+ });
234
+
235
+ const manifest = {
236
+ name: "Your App",
237
+ short_name: "YourApp",
238
+ start_url: "/",
239
+ display: "standalone",
240
+ vana: vanaBlock, // signed identity block
241
+ };
242
+ ```
243
+
244
+ Make sure your HTML includes `<link rel="manifest" href="/manifest.json">`.
245
+
246
+ ## Connectors
247
+
248
+ Available data connectors and their scopes (schema definitions):
249
+ [`vana-com/data-connectors/schemas`](https://github.com/vana-com/data-connectors/tree/main/schemas)
250
+
251
+ ## API Reference
252
+
253
+ ### Entrypoints
254
+
255
+ | Import | Environment | Exports |
256
+ | ----------------- | ----------- | ----------------------------------------------------------------- |
257
+ | `vana-cli/server` | Node.js | `connect()`, `getData()`, `signVanaManifest()`, low-level clients |
258
+ | `vana-cli/react` | Browser | `useVanaConnect()`, `useVanaData()`, `ConnectButton` |
259
+ | `vana-cli/core` | Universal | Types, `ConnectError`, constants |
260
+
261
+ ### `connect(config): Promise<SessionInitResult>`
262
+
263
+ Creates a session on the Session Relay. Returns `sessionId`, `connectUrl`, and `expiresAt`.
264
+
265
+ | Param | Type | Required | Description |
266
+ | ------------ | ------------------- | -------- | ---------------------------------------------------------------------- |
267
+ | `privateKey` | `` `0x${string}` `` | Yes | Builder private key |
268
+ | `scopes` | `string[]` | Yes | Data scopes to request |
269
+ | `webhookUrl` | `string` | No | Public HTTPS URL for grant event notifications (localhost is rejected) |
270
+ | `appUserId` | `string` | No | Your app's user ID for correlation |
271
+
272
+ ### `getData(config): Promise<Record<string, unknown>>`
273
+
274
+ Fetches user data from their Personal Server using a signed grant.
275
+
276
+ | Param | Type | Required | Description |
277
+ | ------------ | ------------------- | -------- | ---------------------------- |
278
+ | `privateKey` | `` `0x${string}` `` | Yes | Builder private key |
279
+ | `grant` | `GrantPayload` | Yes | Grant from the approval step |
280
+
281
+ ### `useVanaConnect(config?): UseVanaConnectResult`
282
+
283
+ React hook that polls the Session Relay and manages connection state.
284
+
285
+ ```typescript
286
+ const { connect, status, grant, error, connectUrl, reset } = useVanaConnect();
287
+ ```
288
+
289
+ `status` transitions: `idle` &rarr; `connecting` &rarr; `waiting` &rarr; `approved` | `denied` | `expired` | `error`
290
+
291
+ ### `GrantPayload`
292
+
293
+ Returned when a user approves access:
294
+
295
+ ```typescript
296
+ interface GrantPayload {
297
+ grantId: string; // on-chain permission ID
298
+ userAddress: string; // user's wallet address
299
+ builderAddress: string; // your registered address
300
+ scopes: string[]; // approved data scopes
301
+ serverAddress?: string; // user's Personal Server
302
+ appUserId?: string; // your app's user ID (if provided)
303
+ }
304
+ ```
305
+
306
+ ### Low-level clients
307
+
308
+ For full control over individual protocol interactions:
309
+
310
+ ```typescript
311
+ import {
312
+ createRequestSigner, // Web3Signed header generation
313
+ createSessionRelay, // Session Relay HTTP client
314
+ createDataClient, // Data Gateway HTTP client
315
+ } from "vana-cli/server";
316
+ ```
317
+
318
+ ## License
319
+
320
+ MIT
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Credential management for Vana CLI authentication.
3
+ *
4
+ * Stores and retrieves auth credentials from ~/.vana/auth.json.
5
+ * Supports the device code flow for browser-based login and
6
+ * env var overrides for CI/automation.
7
+ */
8
+ export interface VanaCredentials {
9
+ account: {
10
+ address: string;
11
+ session_token: string;
12
+ expires_at: string;
13
+ };
14
+ personal_server: {
15
+ url: string;
16
+ session_token: string;
17
+ expires_at: string;
18
+ } | null;
19
+ }
20
+ /**
21
+ * Load credentials from disk or env vars.
22
+ *
23
+ * Priority:
24
+ * 1. Env vars (VANA_SESSION_TOKEN, VANA_PS_TOKEN, VANA_PS_URL)
25
+ * 2. File (~/.vana/auth.json)
26
+ *
27
+ * Returns null if no credentials are available or if they are expired.
28
+ */
29
+ export declare function loadCredentials(): VanaCredentials | null;
30
+ /**
31
+ * Save credentials to ~/.vana/auth.json with 0600 permissions.
32
+ */
33
+ export declare function saveCredentials(creds: VanaCredentials): Promise<void>;
34
+ /**
35
+ * Delete ~/.vana/auth.json.
36
+ */
37
+ export declare function clearCredentials(): Promise<void>;
38
+ /**
39
+ * Check if the account session token has expired.
40
+ */
41
+ export declare function isExpired(creds: VanaCredentials): boolean;
42
+ /**
43
+ * Format an address for display: 0x2Ab3...fa1
44
+ */
45
+ export declare function formatAddress(address: string): string;
46
+ /**
47
+ * Return human-readable time until expiry: "29 days", "3 hours", etc.
48
+ */
49
+ export declare function formatExpiresIn(expiresAt: string): string;
50
+ export interface DeviceCodeResponse {
51
+ device_code: string;
52
+ user_code: string;
53
+ verification_uri: string;
54
+ verification_uri_complete?: string;
55
+ expires_in: number;
56
+ interval: number;
57
+ }
58
+ export interface DeviceCodePollAuthorized {
59
+ status: "authorized";
60
+ session_token: string;
61
+ personal_server_url?: string;
62
+ personal_server_session_token?: string;
63
+ ps_access_token?: string;
64
+ address: string;
65
+ expires_in?: number;
66
+ expires_at?: string;
67
+ }
68
+ export interface DeviceCodePollPending {
69
+ status: "pending";
70
+ }
71
+ export interface DeviceCodePollSlowDown {
72
+ status: "slow_down";
73
+ }
74
+ export interface DeviceCodePollExpired {
75
+ status: "expired";
76
+ }
77
+ export type DeviceCodePollResponse = DeviceCodePollAuthorized | DeviceCodePollPending | DeviceCodePollSlowDown | DeviceCodePollExpired;
78
+ export interface DeviceCodeFlowOptions {
79
+ clientId?: string;
80
+ }
81
+ interface DeviceCodeFlowCallbacks {
82
+ onCode: (code: string, verificationUri: string) => void;
83
+ onWaiting: () => void;
84
+ onAuthorized: (creds: VanaCredentials) => void | Promise<void>;
85
+ onExpired: () => void;
86
+ onError: (error: Error) => void;
87
+ }
88
+ export declare function resolveOAuthClientId(accountUrl?: string): string;
89
+ /**
90
+ * Request a device code from the auth server.
91
+ */
92
+ export declare function requestDeviceCode(): Promise<DeviceCodeResponse>;
93
+ /**
94
+ * Poll for device code authorization.
95
+ */
96
+ export declare function pollDeviceCode(deviceCode: string): Promise<DeviceCodePollResponse>;
97
+ /**
98
+ * Open a URL in the user's default browser.
99
+ * Best-effort — failures are silently ignored.
100
+ */
101
+ export declare function openBrowser(url: string): void;
102
+ /**
103
+ * Run the full device code login flow.
104
+ *
105
+ * Returns credentials on success, or null if the code expired.
106
+ * Calls the provided callbacks for UI updates.
107
+ */
108
+ export declare function runDeviceCodeFlow(callbacks: DeviceCodeFlowCallbacks, options?: DeviceCodeFlowOptions): Promise<VanaCredentials | null>;
109
+ export type AuthTarget = "cloud" | "self-hosted";
110
+ export declare function getAuthTarget(psUrl: string | null): AuthTarget;
111
+ export declare function resolvePersonalServerUrl(): string | undefined;
112
+ export declare function runSelfHostedLoginFlow(serverUrl: string, onLoginUrl: (url: string) => void): Promise<{
113
+ server: string;
114
+ address: string;
115
+ session_token: string;
116
+ expires_at: string;
117
+ }>;
118
+ export {};
119
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/cli/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,eAAe,EAAE;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,IAAI,CAAC;CACV;AAwCD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,eAAe,GAAG,IAAI,CA8CxD;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ3E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAUtD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,eAAe,GAA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