@opendatalabs/connect 0.6.0-canary.e07e97e → 0.7.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.
- package/README.md +29 -15
- package/dist/react/useVanaConnect.d.ts +2 -2
- package/dist/react/useVanaConnect.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,25 +32,39 @@ The [Data Portability Protocol](https://docs.vana.org/) defines how users collec
|
|
|
32
32
|
|
|
33
33
|
## Getting started
|
|
34
34
|
|
|
35
|
-
The fastest way to get up and running is with the
|
|
35
|
+
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:
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
38
|
git clone https://github.com/vana-com/vana-connect.git
|
|
39
39
|
cd vana-connect/examples/nextjs-starter
|
|
40
40
|
cp .env.local.example .env.local
|
|
41
|
-
# Edit .env.local with your private key and APP_URL
|
|
42
|
-
pnpm install
|
|
43
|
-
pnpm dev
|
|
44
41
|
```
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
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.
|
|
47
44
|
|
|
48
45
|
```
|
|
49
46
|
VANA_PRIVATE_KEY=0x3c05ac1a00546bc0b1b8d3a11fb908409005fac3f26d25f70711e4f632e720d3
|
|
50
47
|
APP_URL=http://localhost:3001
|
|
51
48
|
```
|
|
52
49
|
|
|
53
|
-
|
|
50
|
+
Install and run
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pnpm install
|
|
54
|
+
pnpm dev
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
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).
|
|
58
|
+
|
|
59
|
+
There is one caveat in development: the deep-link for DataConnect app doesn't open the dev version of the app.
|
|
60
|
+
This means that when testing your app from the end user perspective, once you see this screen:
|
|
61
|
+
<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" />
|
|
62
|
+
|
|
63
|
+
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=...`.
|
|
64
|
+
|
|
65
|
+
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:
|
|
66
|
+
|
|
67
|
+
<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" />
|
|
54
68
|
|
|
55
69
|
---
|
|
56
70
|
|
|
@@ -83,13 +97,13 @@ const session = await connect({
|
|
|
83
97
|
privateKey: process.env.VANA_APP_PRIVATE_KEY as `0x${string}`,
|
|
84
98
|
scopes: ["chatgpt.conversations"],
|
|
85
99
|
webhookUrl: "https://yourapp.com/api/webhook", // optional, data can be pushed to a web hook after a grant is approved
|
|
86
|
-
appUserId: "yourapp-user-42", // optional:
|
|
100
|
+
appUserId: "yourapp-user-42", // optional: correlate your app user with the data they provided
|
|
87
101
|
});
|
|
88
102
|
|
|
89
103
|
// Return to your frontend:
|
|
90
|
-
// session.sessionId
|
|
91
|
-
// session.
|
|
92
|
-
// session.expiresAt
|
|
104
|
+
// session.sessionId — used for polling
|
|
105
|
+
// session.connectUrl — opens the Vana account page → launches DataConnect
|
|
106
|
+
// session.expiresAt — ISO 8601 expiration
|
|
93
107
|
```
|
|
94
108
|
|
|
95
109
|
#### 2. Poll for user approval (client)
|
|
@@ -98,14 +112,14 @@ const session = await connect({
|
|
|
98
112
|
import { useVanaConnect } from "@opendatalabs/connect/react";
|
|
99
113
|
|
|
100
114
|
function ConnectData({ sessionId }: { sessionId: string }) {
|
|
101
|
-
const { connect, status, grant,
|
|
115
|
+
const { connect, status, grant, connectUrl } = useVanaConnect();
|
|
102
116
|
|
|
103
117
|
useEffect(() => {
|
|
104
118
|
connect({ sessionId });
|
|
105
119
|
}, [sessionId]);
|
|
106
120
|
|
|
107
|
-
if (status === "waiting" &&
|
|
108
|
-
return <a href={
|
|
121
|
+
if (status === "waiting" && connectUrl) {
|
|
122
|
+
return <a href={connectUrl}>Connect your data</a>;
|
|
109
123
|
}
|
|
110
124
|
if (status === "approved" && grant) {
|
|
111
125
|
// grant.grantId, grant.userAddress, grant.scopes are available
|
|
@@ -186,7 +200,7 @@ Available data connectors and their scopes (schema definitions):
|
|
|
186
200
|
|
|
187
201
|
### `connect(config): Promise<SessionInitResult>`
|
|
188
202
|
|
|
189
|
-
Creates a session on the Session Relay. Returns `sessionId`, `
|
|
203
|
+
Creates a session on the Session Relay. Returns `sessionId`, `connectUrl`, and `expiresAt`.
|
|
190
204
|
|
|
191
205
|
| Param | Type | Required | Description |
|
|
192
206
|
| ------------ | ------------------- | -------- | ---------------------------------------------------------------------- |
|
|
@@ -209,7 +223,7 @@ Fetches user data from their Personal Server using a signed grant.
|
|
|
209
223
|
React hook that polls the Session Relay and manages connection state.
|
|
210
224
|
|
|
211
225
|
```typescript
|
|
212
|
-
const { connect, status, grant, error,
|
|
226
|
+
const { connect, status, grant, error, connectUrl, reset } = useVanaConnect();
|
|
213
227
|
```
|
|
214
228
|
|
|
215
229
|
`status` transitions: `idle` → `connecting` → `waiting` → `approved` | `denied` | `expired` | `error`
|
|
@@ -36,13 +36,13 @@ export interface UseVanaConnectResult {
|
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
38
|
* ```tsx
|
|
39
|
-
* const { connect, status, grant,
|
|
39
|
+
* const { connect, status, grant, connectUrl } = useVanaConnect();
|
|
40
40
|
*
|
|
41
41
|
* useEffect(() => {
|
|
42
42
|
* connect({ sessionId: "sess-123" });
|
|
43
43
|
* }, []);
|
|
44
44
|
*
|
|
45
|
-
* if (status === "waiting") return <a href={
|
|
45
|
+
* if (status === "waiting") return <a href={connectUrl!}>Open Vana</a>;
|
|
46
46
|
* if (status === "approved") return <p>Connected! Grant: {grant!.grantId}</p>;
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
@@ -12,13 +12,13 @@ import { getEnvConfig } from "../core/constants.js";
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```tsx
|
|
15
|
-
* const { connect, status, grant,
|
|
15
|
+
* const { connect, status, grant, connectUrl } = useVanaConnect();
|
|
16
16
|
*
|
|
17
17
|
* useEffect(() => {
|
|
18
18
|
* connect({ sessionId: "sess-123" });
|
|
19
19
|
* }, []);
|
|
20
20
|
*
|
|
21
|
-
* if (status === "waiting") return <a href={
|
|
21
|
+
* if (status === "waiting") return <a href={connectUrl!}>Open Vana</a>;
|
|
22
22
|
* if (status === "approved") return <p>Connected! Grant: {grant!.grantId}</p>;
|
|
23
23
|
* ```
|
|
24
24
|
*/
|