@opendatalabs/connect 0.1.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/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/core/errors.d.ts +6 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +11 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +43 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/react/ConnectButton.d.ts +12 -0
- package/dist/react/ConnectButton.d.ts.map +1 -0
- package/dist/react/ConnectButton.js +34 -0
- package/dist/react/ConnectButton.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/useVanaConnect.d.ts +17 -0
- package/dist/react/useVanaConnect.d.ts.map +1 -0
- package/dist/react/useVanaConnect.js +76 -0
- package/dist/react/useVanaConnect.js.map +1 -0
- package/dist/server/data-client.d.ts +14 -0
- package/dist/server/data-client.d.ts.map +1 -0
- package/dist/server/data-client.js +75 -0
- package/dist/server/data-client.js.map +1 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +4 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/request-signer.d.ts +13 -0
- package/dist/server/request-signer.d.ts.map +1 -0
- package/dist/server/request-signer.js +63 -0
- package/dist/server/request-signer.js.map +1 -0
- package/dist/server/session-relay.d.ts +11 -0
- package/dist/server/session-relay.d.ts.map +1 -0
- package/dist/server/session-relay.js +66 -0
- package/dist/server/session-relay.js.map +1 -0
- package/package.json +100 -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,81 @@
|
|
|
1
|
+
# @opendatalabs/connect
|
|
2
|
+
|
|
3
|
+
SDK for integrating Vana Data Portability "Connect data" flows into builder applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @opendatalabs/connect
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Entrypoints
|
|
12
|
+
|
|
13
|
+
| Entrypoint | Environment | Description |
|
|
14
|
+
| ------------------------------ | ----------- | ------------------------------------------ |
|
|
15
|
+
| `@opendatalabs/connect/server` | Node.js | Session relay, request signer, data client |
|
|
16
|
+
| `@opendatalabs/connect/react` | Browser | Polling hook, connect button |
|
|
17
|
+
| `@opendatalabs/connect/core` | Universal | Shared types and errors |
|
|
18
|
+
|
|
19
|
+
## Quick Start (Server)
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import {
|
|
23
|
+
createSessionRelay,
|
|
24
|
+
createDataClient,
|
|
25
|
+
} from "@opendatalabs/connect/server";
|
|
26
|
+
|
|
27
|
+
// Create a session for your user
|
|
28
|
+
const relay = createSessionRelay({
|
|
29
|
+
privateKey: process.env.VANA_APP_PRIVATE_KEY,
|
|
30
|
+
granteeAddress: "0x...",
|
|
31
|
+
sessionRelayUrl: "https://session-relay.vana.org",
|
|
32
|
+
});
|
|
33
|
+
const session = await relay.initSession({
|
|
34
|
+
scopes: ["instagram.profile"],
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Poll until user approves in Desktop App
|
|
38
|
+
const result = await relay.pollUntilComplete(session.sessionId);
|
|
39
|
+
|
|
40
|
+
// Fetch user data with the grant
|
|
41
|
+
const data = createDataClient({
|
|
42
|
+
privateKey: process.env.VANA_APP_PRIVATE_KEY,
|
|
43
|
+
gatewayUrl: "https://gateway.vana.org",
|
|
44
|
+
});
|
|
45
|
+
const serverUrl = await data.resolveServerUrl(result.grant.userAddress);
|
|
46
|
+
const profile = await data.fetchData({
|
|
47
|
+
serverUrl,
|
|
48
|
+
scope: "instagram.profile",
|
|
49
|
+
grantId: result.grant.grantId,
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick Start (React)
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { useVanaConnect } from "@opendatalabs/connect/react";
|
|
57
|
+
|
|
58
|
+
function ConnectPage({ sessionId }: { sessionId: string }) {
|
|
59
|
+
const { connect, status, grant, deepLinkUrl } = useVanaConnect({
|
|
60
|
+
sessionRelayUrl: "https://session-relay.vana.org",
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
connect({ sessionId });
|
|
65
|
+
}, [sessionId]);
|
|
66
|
+
|
|
67
|
+
if (status === "waiting" && deepLinkUrl) {
|
|
68
|
+
return <a href={deepLinkUrl}>Open Vana Desktop App</a>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (status === "approved" && grant) {
|
|
72
|
+
return <p>Connected! Grant: {grant.grantId}</p>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return <p>Status: {status}</p>;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAM/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,IAAI,CAAS;IACb,UAAU,CAAU;IAE7B,YAAY,OAAe,EAAE,IAAY,EAAE,UAAmB;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ConnectError } from "./errors.js";
|
|
2
|
+
export type { ConnectionStatus, SessionInitParams, SessionInitResult, SessionPollResult, GrantPayload, DataFetchParams, RequestSignerConfig, SessionRelayConfig, DataClientConfig, } from "./types.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type ConnectionStatus = "idle" | "connecting" | "waiting" | "approved" | "denied" | "expired" | "error";
|
|
2
|
+
export interface SessionInitParams {
|
|
3
|
+
scopes: string[];
|
|
4
|
+
webhookUrl?: string;
|
|
5
|
+
appUserId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SessionInitResult {
|
|
8
|
+
sessionId: string;
|
|
9
|
+
deepLinkUrl: string;
|
|
10
|
+
expiresAt: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SessionPollResult {
|
|
13
|
+
status: "pending" | "claimed" | "approved" | "denied" | "expired";
|
|
14
|
+
grant?: GrantPayload;
|
|
15
|
+
reason?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface GrantPayload {
|
|
18
|
+
grantId: string;
|
|
19
|
+
userAddress: string;
|
|
20
|
+
builderAddress: string;
|
|
21
|
+
scopes: string[];
|
|
22
|
+
appUserId?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface DataFetchParams {
|
|
25
|
+
serverUrl: string;
|
|
26
|
+
scope: string;
|
|
27
|
+
grantId: string;
|
|
28
|
+
fileId?: string;
|
|
29
|
+
at?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface RequestSignerConfig {
|
|
32
|
+
privateKey: `0x${string}`;
|
|
33
|
+
}
|
|
34
|
+
export interface SessionRelayConfig {
|
|
35
|
+
privateKey: `0x${string}`;
|
|
36
|
+
granteeAddress: `0x${string}`;
|
|
37
|
+
sessionRelayUrl: string;
|
|
38
|
+
}
|
|
39
|
+
export interface DataClientConfig {
|
|
40
|
+
privateKey: `0x${string}`;
|
|
41
|
+
gatewayUrl: string;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,YAAY,GACZ,SAAS,GACT,UAAU,GACV,QAAQ,GACR,SAAS,GACT,OAAO,CAAC;AAEZ,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;IAClE,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,cAAc,EAAE,KAAK,MAAM,EAAE,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GrantPayload } from "../core/types.js";
|
|
2
|
+
export interface ConnectButtonProps {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
sessionRelayUrl: string;
|
|
5
|
+
onComplete?: (grant: GrantPayload) => void;
|
|
6
|
+
onError?: (error: string) => void;
|
|
7
|
+
onDenied?: (reason: string) => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function ConnectButton(props: ConnectButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=ConnectButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectButton.d.ts","sourceRoot":"","sources":["../../src/react/ConnectButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAiDtD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { useVanaConnect } from "./useVanaConnect.js";
|
|
4
|
+
export function ConnectButton(props) {
|
|
5
|
+
const { sessionId, sessionRelayUrl, onComplete, onError, onDenied, className, label, } = props;
|
|
6
|
+
const { connect, status, grant, error, deepLinkUrl } = useVanaConnect({
|
|
7
|
+
sessionRelayUrl,
|
|
8
|
+
});
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
connect({ sessionId });
|
|
11
|
+
}, [sessionId, connect]);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (status === "approved" && grant && onComplete) {
|
|
14
|
+
onComplete(grant);
|
|
15
|
+
}
|
|
16
|
+
if (status === "error" && error && onError) {
|
|
17
|
+
onError(error);
|
|
18
|
+
}
|
|
19
|
+
if (status === "denied" && onDenied) {
|
|
20
|
+
onDenied(error ?? "User denied the request");
|
|
21
|
+
}
|
|
22
|
+
}, [status, grant, error, onComplete, onError, onDenied]);
|
|
23
|
+
const statusText = {
|
|
24
|
+
idle: "Initializing...",
|
|
25
|
+
connecting: "Connecting...",
|
|
26
|
+
waiting: "Waiting for approval...",
|
|
27
|
+
approved: "Connected!",
|
|
28
|
+
denied: "Request denied",
|
|
29
|
+
expired: "Session expired",
|
|
30
|
+
error: "Connection error",
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs("div", { className: className, children: [_jsx("p", { children: statusText[status] ?? status }), deepLinkUrl && status === "waiting" && (_jsx("a", { href: deepLinkUrl, children: label ?? "Open Vana Desktop App" }))] }));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ConnectButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectButton.js","sourceRoot":"","sources":["../../src/react/ConnectButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAYrD,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,EACJ,SAAS,EACT,eAAe,EACf,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,GACN,GAAG,KAAK,CAAC;IAEV,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,cAAc,CAAC;QACpE,eAAe;KAChB,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IACzB,CAAC,EAAE,CAAC,SAAS,EAAE,O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C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAA2B,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ConnectionStatus, GrantPayload } from "../core/types.js";
|
|
2
|
+
export interface UseVanaConnectConfig {
|
|
3
|
+
sessionRelayUrl: string;
|
|
4
|
+
pollingInterval?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface UseVanaConnectResult {
|
|
7
|
+
connect: (params: {
|
|
8
|
+
sessionId: string;
|
|
9
|
+
}) => void;
|
|
10
|
+
status: ConnectionStatus;
|
|
11
|
+
grant: GrantPayload | null;
|
|
12
|
+
error: string | null;
|
|
13
|
+
deepLinkUrl: string | null;
|
|
14
|
+
reset: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function useVanaConnect(config: UseVanaConnectConfig): UseVanaConnectResult;
|
|
17
|
+
//# sourceMappingURL=useVanaConnect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVanaConnect.d.ts","sourceRoot":"","sources":["../../src/react/useVanaConnect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EAEb,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjD,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,oBAAoB,GAC3B,oBAAoB,CAwFtB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useState, useCallback, useRef, useEffect } from "react";
|
|
2
|
+
export function useVanaConnect(config) {
|
|
3
|
+
const baseUrl = config.sessionRelayUrl.replace(/\/+$/, "");
|
|
4
|
+
const interval = config.pollingInterval ?? 2000;
|
|
5
|
+
const [status, setStatus] = useState("idle");
|
|
6
|
+
const [grant, setGrant] = useState(null);
|
|
7
|
+
const [error, setError] = useState(null);
|
|
8
|
+
const [deepLinkUrl, setDeepLinkUrl] = useState(null);
|
|
9
|
+
const timerRef = useRef(null);
|
|
10
|
+
const stopPolling = useCallback(() => {
|
|
11
|
+
if (timerRef.current !== null) {
|
|
12
|
+
clearInterval(timerRef.current);
|
|
13
|
+
timerRef.current = null;
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
const reset = useCallback(() => {
|
|
17
|
+
stopPolling();
|
|
18
|
+
setStatus("idle");
|
|
19
|
+
setGrant(null);
|
|
20
|
+
setError(null);
|
|
21
|
+
setDeepLinkUrl(null);
|
|
22
|
+
}, [stopPolling]);
|
|
23
|
+
const connect = useCallback((params) => {
|
|
24
|
+
stopPolling();
|
|
25
|
+
setStatus("connecting");
|
|
26
|
+
setGrant(null);
|
|
27
|
+
setError(null);
|
|
28
|
+
setDeepLinkUrl(`vana://connect?sessionId=${params.sessionId}`);
|
|
29
|
+
const pollUrl = `${baseUrl}/v1/session/${params.sessionId}/poll`;
|
|
30
|
+
const poll = async () => {
|
|
31
|
+
try {
|
|
32
|
+
const res = await fetch(pollUrl);
|
|
33
|
+
if (!res.ok) {
|
|
34
|
+
setStatus("error");
|
|
35
|
+
setError(`Poll failed: ${res.status}`);
|
|
36
|
+
stopPolling();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const result = (await res.json());
|
|
40
|
+
switch (result.status) {
|
|
41
|
+
case "pending":
|
|
42
|
+
case "claimed":
|
|
43
|
+
setStatus("waiting");
|
|
44
|
+
break;
|
|
45
|
+
case "approved":
|
|
46
|
+
setStatus("approved");
|
|
47
|
+
setGrant(result.grant ?? null);
|
|
48
|
+
stopPolling();
|
|
49
|
+
break;
|
|
50
|
+
case "denied":
|
|
51
|
+
setStatus("denied");
|
|
52
|
+
setError(result.reason ?? "User denied the request");
|
|
53
|
+
stopPolling();
|
|
54
|
+
break;
|
|
55
|
+
case "expired":
|
|
56
|
+
setStatus("expired");
|
|
57
|
+
setError("Session expired");
|
|
58
|
+
stopPolling();
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
setStatus("error");
|
|
64
|
+
setError(err instanceof Error ? err.message : "Unknown polling error");
|
|
65
|
+
stopPolling();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// First poll immediately, then at interval
|
|
69
|
+
void poll();
|
|
70
|
+
timerRef.current = setInterval(() => void poll(), interval);
|
|
71
|
+
}, [baseUrl, interval, stopPolling]);
|
|
72
|
+
// Cleanup on unmount
|
|
73
|
+
useEffect(() => stopPolling, [stopPolling]);
|
|
74
|
+
return { connect, status, grant, error, deepLinkUrl, reset };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=useVanaConnect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVanaConnect.js","sourceRoot":"","sources":["../../src/react/useVanaConnect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAqBjE,MAAM,UAAU,cAAc,CAC5B,MAA4B;IAE5B,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC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AAC;gBACF,WAAW,EAAE,CAAC;YAChB,CAAC;QACH,CAAC,CAAC;QAEF,2CAA2C;QAC3C,KAAK,IAAI,EAAE,CAAC;QACZ,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC,EACD,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CACjC,CAAC;IAEF,qBAAqB;IACrB,SAAS,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DataClientConfig, DataFetchParams } from "../core/types.js";
|
|
2
|
+
export interface DataClient {
|
|
3
|
+
resolveServerUrl(userAddress: string): Promise<string>;
|
|
4
|
+
fetchData(params: DataFetchParams): Promise<unknown>;
|
|
5
|
+
listScopes(params: {
|
|
6
|
+
serverUrl: string;
|
|
7
|
+
}): Promise<unknown>;
|
|
8
|
+
listVersions(params: {
|
|
9
|
+
serverUrl: string;
|
|
10
|
+
scope: string;
|
|
11
|
+
}): Promise<unknown>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createDataClient(config: DataClientConfig): DataClient;
|
|
14
|
+
//# sourceMappingURL=data-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-client.d.ts","sourceRoot":"","sources":["../../src/server/data-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG1E,MAAM,WAAW,UAAU;IACzB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,UAAU,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,YAAY,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAiHrE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ConnectError } from "../core/errors.js";
|
|
2
|
+
import { createRequestSigner } from "./request-signer.js";
|
|
3
|
+
export function createDataClient(config) {
|
|
4
|
+
const gatewayBase = config.gatewayUrl.replace(/\/+$/, "");
|
|
5
|
+
const signer = createRequestSigner({ privateKey: config.privateKey });
|
|
6
|
+
return {
|
|
7
|
+
async resolveServerUrl(userAddress) {
|
|
8
|
+
const res = await fetch(`${gatewayBase}/v1/servers/${userAddress}`);
|
|
9
|
+
if (res.status === 404) {
|
|
10
|
+
throw new ConnectError(`No server registered for ${userAddress}`, "SERVER_NOT_FOUND", 404);
|
|
11
|
+
}
|
|
12
|
+
if (!res.ok) {
|
|
13
|
+
throw new ConnectError(`Gateway error: ${res.status}`, "GATEWAY_ERROR", res.status);
|
|
14
|
+
}
|
|
15
|
+
const envelope = (await res.json());
|
|
16
|
+
return envelope.data.serverUrl;
|
|
17
|
+
},
|
|
18
|
+
async fetchData(params) {
|
|
19
|
+
const base = params.serverUrl.replace(/\/+$/, "");
|
|
20
|
+
const queryParams = new URLSearchParams();
|
|
21
|
+
if (params.fileId)
|
|
22
|
+
queryParams.set("fileId", params.fileId);
|
|
23
|
+
if (params.at)
|
|
24
|
+
queryParams.set("at", params.at);
|
|
25
|
+
const qs = queryParams.toString();
|
|
26
|
+
const uri = `/v1/data/${params.scope}${qs ? `?${qs}` : ""}`;
|
|
27
|
+
const authHeader = await signer.signRequest({
|
|
28
|
+
aud: base,
|
|
29
|
+
method: "GET",
|
|
30
|
+
uri,
|
|
31
|
+
grantId: params.grantId,
|
|
32
|
+
});
|
|
33
|
+
const res = await fetch(`${base}${uri}`, {
|
|
34
|
+
headers: { Authorization: authHeader },
|
|
35
|
+
});
|
|
36
|
+
if (!res.ok) {
|
|
37
|
+
throw new ConnectError(`Data fetch failed: ${res.status}`, "DATA_FETCH_FAILED", res.status);
|
|
38
|
+
}
|
|
39
|
+
return res.json();
|
|
40
|
+
},
|
|
41
|
+
async listScopes(params) {
|
|
42
|
+
const base = params.serverUrl.replace(/\/+$/, "");
|
|
43
|
+
const uri = "/v1/data";
|
|
44
|
+
const authHeader = await signer.signRequest({
|
|
45
|
+
aud: base,
|
|
46
|
+
method: "GET",
|
|
47
|
+
uri,
|
|
48
|
+
});
|
|
49
|
+
const res = await fetch(`${base}${uri}`, {
|
|
50
|
+
headers: { Authorization: authHeader },
|
|
51
|
+
});
|
|
52
|
+
if (!res.ok) {
|
|
53
|
+
throw new ConnectError(`List scopes failed: ${res.status}`, "LIST_SCOPES_FAILED", res.status);
|
|
54
|
+
}
|
|
55
|
+
return res.json();
|
|
56
|
+
},
|
|
57
|
+
async listVersions(params) {
|
|
58
|
+
const base = params.serverUrl.replace(/\/+$/, "");
|
|
59
|
+
const uri = `/v1/data/${params.scope}/versions`;
|
|
60
|
+
const authHeader = await signer.signRequest({
|
|
61
|
+
aud: base,
|
|
62
|
+
method: "GET",
|
|
63
|
+
uri,
|
|
64
|
+
});
|
|
65
|
+
const res = await fetch(`${base}${uri}`, {
|
|
66
|
+
headers: { Authorization: authHeader },
|
|
67
|
+
});
|
|
68
|
+
if (!res.ok) {
|
|
69
|
+
throw new ConnectError(`List versions failed: ${res.status}`, "LIST_VERSIONS_FAILED", res.status);
|
|
70
|
+
}
|
|
71
|
+
return res.json();
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//#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a,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAsB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAqB,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RequestSignerConfig } from "../core/types.js";
|
|
2
|
+
export interface RequestSigner {
|
|
3
|
+
signRequest(params: {
|
|
4
|
+
aud: string;
|
|
5
|
+
method: string;
|
|
6
|
+
uri: string;
|
|
7
|
+
body?: string;
|
|
8
|
+
grantId?: string;
|
|
9
|
+
}): Promise<string>;
|
|
10
|
+
readonly address: `0x${string}`;
|
|
11
|
+
}
|
|
12
|
+
export declare function createRequestSigner(config: RequestSignerConfig): RequestSigner;
|
|
13
|
+
//# sourceMappingURL=request-signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-signer.d.ts","sourceRoot":"","sources":["../../src/server/request-signer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AA+B5D,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,MAAM,EAAE;QAClB,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;CACjC;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,mBAAmB,GAC1B,aAAa,CAsCf"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
3
|
+
function base64urlEncode(input) {
|
|
4
|
+
return Buffer.from(input, "utf-8")
|
|
5
|
+
.toString("base64")
|
|
6
|
+
.replace(/\+/g, "-")
|
|
7
|
+
.replace(/\//g, "_")
|
|
8
|
+
.replace(/=+$/, "");
|
|
9
|
+
}
|
|
10
|
+
function canonicalizeJson(obj) {
|
|
11
|
+
if (obj === null || typeof obj !== "object")
|
|
12
|
+
return obj;
|
|
13
|
+
if (Array.isArray(obj))
|
|
14
|
+
return obj.map(canonicalizeJson);
|
|
15
|
+
const sorted = {};
|
|
16
|
+
for (const key of Object.keys(obj).sort()) {
|
|
17
|
+
if (key === "signature")
|
|
18
|
+
continue;
|
|
19
|
+
sorted[key] = canonicalizeJson(obj[key]);
|
|
20
|
+
}
|
|
21
|
+
return sorted;
|
|
22
|
+
}
|
|
23
|
+
function computeBodyHash(body) {
|
|
24
|
+
if (!body || body.length === 0) {
|
|
25
|
+
return "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
|
26
|
+
}
|
|
27
|
+
const parsed = JSON.parse(body);
|
|
28
|
+
const canonical = canonicalizeJson(parsed);
|
|
29
|
+
const canonicalStr = JSON.stringify(canonical);
|
|
30
|
+
return `sha256:${createHash("sha256").update(canonicalStr).digest("hex")}`;
|
|
31
|
+
}
|
|
32
|
+
export function createRequestSigner(config) {
|
|
33
|
+
const account = privateKeyToAccount(config.privateKey);
|
|
34
|
+
return {
|
|
35
|
+
address: account.address,
|
|
36
|
+
async signRequest(params) {
|
|
37
|
+
const now = Math.floor(Date.now() / 1000);
|
|
38
|
+
const payload = {
|
|
39
|
+
aud: params.aud,
|
|
40
|
+
bodyHash: computeBodyHash(params.body),
|
|
41
|
+
exp: now + 300,
|
|
42
|
+
iat: now,
|
|
43
|
+
method: params.method,
|
|
44
|
+
uri: params.uri,
|
|
45
|
+
};
|
|
46
|
+
if (params.grantId !== undefined) {
|
|
47
|
+
payload["grantId"] = params.grantId;
|
|
48
|
+
}
|
|
49
|
+
// Sort keys for deterministic serialization
|
|
50
|
+
const sortedPayload = Object.keys(payload)
|
|
51
|
+
.sort()
|
|
52
|
+
.reduce((acc, key) => {
|
|
53
|
+
acc[key] = payload[key];
|
|
54
|
+
return acc;
|
|
55
|
+
}, {});
|
|
56
|
+
const payloadJson = JSON.stringify(sortedPayload);
|
|
57
|
+
const payloadBase64 = base64urlEncode(payloadJson);
|
|
58
|
+
const signature = await account.signMessage({ message: payloadBase64 });
|
|
59
|
+
return `Web3Signed ${payloadBase64}.${signature}`;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=request-signer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-signer.js","sourceRoot":"","sources":["../../src/server/request-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC;SAC/B,QAAQ,CAAC,QAAQ,CAAC;SAClB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAY;IACpC,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC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gBACf,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC;gBACtC,GAAG,EAAE,GAAG,GAAG,GAAG;gBACd,GAAG,EAAE,GAAG;gBACR,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,EAAE,MAAM,CAAC,GAAG;aAChB,CAAC;YAEF,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBACjC,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;YACtC,CAAC;YAED,4CAA4C;YAC5C,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;iBACvC,IAAI,EAAE;iBACN,MAAM,CAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;gBAC5C,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;gBACxB,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,EAAE,CAAC,CAAC;YAET,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;YAClD,MAAM,aAAa,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;YAEnD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;YAExE,OAAO,cAAc,aAAa,IAAI,SAAS,EAAE,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SessionRelayConfig, SessionInitParams, SessionInitResult, SessionPollResult } from "../core/types.js";
|
|
2
|
+
export interface SessionRelay {
|
|
3
|
+
initSession(params: SessionInitParams): Promise<SessionInitResult>;
|
|
4
|
+
pollSession(sessionId: string): Promise<SessionPollResult>;
|
|
5
|
+
pollUntilComplete(sessionId: string, opts?: {
|
|
6
|
+
interval?: number;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
}): Promise<SessionPollResult>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createSessionRelay(config: SessionRelayConfig): SessionRelay;
|
|
11
|
+
//# sourceMappingURL=session-relay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-relay.d.ts","sourceRoot":"","sources":["../../src/server/session-relay.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnE,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC3D,iBAAiB,CACf,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7C,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC/B;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAyF3E"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ConnectError } from "../core/errors.js";
|
|
2
|
+
import { createRequestSigner } from "./request-signer.js";
|
|
3
|
+
export function createSessionRelay(config) {
|
|
4
|
+
const baseUrl = config.sessionRelayUrl.replace(/\/+$/, "");
|
|
5
|
+
const signer = createRequestSigner({ privateKey: config.privateKey });
|
|
6
|
+
return {
|
|
7
|
+
async initSession(params) {
|
|
8
|
+
const body = JSON.stringify({
|
|
9
|
+
granteeAddress: config.granteeAddress,
|
|
10
|
+
scopes: params.scopes,
|
|
11
|
+
...(params.webhookUrl && { webhookUrl: params.webhookUrl }),
|
|
12
|
+
...(params.appUserId && { app_user_id: params.appUserId }),
|
|
13
|
+
});
|
|
14
|
+
const authHeader = await signer.signRequest({
|
|
15
|
+
aud: baseUrl,
|
|
16
|
+
method: "POST",
|
|
17
|
+
uri: "/v1/session/init",
|
|
18
|
+
body,
|
|
19
|
+
});
|
|
20
|
+
const res = await fetch(`${baseUrl}/v1/session/init`, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: {
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
Authorization: authHeader,
|
|
25
|
+
},
|
|
26
|
+
body,
|
|
27
|
+
});
|
|
28
|
+
if (!res.ok) {
|
|
29
|
+
const errorBody = await res.json().catch(() => ({}));
|
|
30
|
+
const errorMsg = errorBody.error &&
|
|
31
|
+
typeof errorBody.error === "object"
|
|
32
|
+
? errorBody.error
|
|
33
|
+
.message
|
|
34
|
+
: `Session init failed: ${res.status}`;
|
|
35
|
+
throw new ConnectError(errorMsg, errorBody.error
|
|
36
|
+
?.errorCode ?? "SESSION_INIT_FAILED", res.status);
|
|
37
|
+
}
|
|
38
|
+
return (await res.json());
|
|
39
|
+
},
|
|
40
|
+
async pollSession(sessionId) {
|
|
41
|
+
const res = await fetch(`${baseUrl}/v1/session/${sessionId}/poll`);
|
|
42
|
+
if (!res.ok) {
|
|
43
|
+
const errorBody = await res.json().catch(() => ({}));
|
|
44
|
+
throw new ConnectError(`Poll failed: ${res.status}`, errorBody.error
|
|
45
|
+
?.errorCode ?? "POLL_FAILED", res.status);
|
|
46
|
+
}
|
|
47
|
+
return (await res.json());
|
|
48
|
+
},
|
|
49
|
+
async pollUntilComplete(sessionId, opts) {
|
|
50
|
+
const interval = opts?.interval ?? 2000;
|
|
51
|
+
const timeout = opts?.timeout ?? 900_000; // 15 minutes
|
|
52
|
+
const deadline = Date.now() + timeout;
|
|
53
|
+
while (Date.now() < deadline) {
|
|
54
|
+
const result = await this.pollSession(sessionId);
|
|
55
|
+
if (result.status === "approved" ||
|
|
56
|
+
result.status === "denied" ||
|
|
57
|
+
result.status === "expired") {
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
61
|
+
}
|
|
62
|
+
throw new ConnectError("Polling timed out", "POLL_TIMEOUT");
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=session-relay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-relay.js","sourceRoot":"","sources":["../../src/server/session-relay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAW1D,MAAM,UAAU,kBAAkB,CAAC,MAA0B;IAC3D,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,mBAAmB,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAEtE,OAAO;QACL,KAAK,CAAC,WAAW,CAAC,MAAyB;YACzC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;gBAC1B,cAAc,EAAE,MAAM,CAAC,cAAc;gBACrC,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC3D,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;aAC3D,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;gBAC1C,GAAG,EAAE,OAAO;gBACZ,MAAM,EAAE,MAAM;gBACd,GAAG,EAAE,kBAAkB;gBACvB,IAAI;aACL,CAAC,CAAC;YAEH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,kBAAkB,EAAE;gBACpD,MAAM,EAAE,MAAM;gBACd,O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,KAAK,CAAC,iBAAiB,CACrB,SAAiB,EACjB,IAA8C;YAE9C,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,IAAI,CAAC;YACxC,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,OAAO,CAAC,CAAC,aAAa;YACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;YAEtC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;gBAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;gBAEjD,IACE,MAAM,CAAC,MAAM,KAAK,UAAU;oBAC5B,MAAM,CAAC,MAAM,KAAK,QAAQ;oBAC1B,MAAM,CAAC,MAAM,KAAK,SAAS,EAC3B,CAAC;oBACD,OAAO,MAAM,CAAC;gBAChB,CAAC;gBAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;YAChE,CAAC;YAED,MAAM,IAAI,YAAY,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opendatalabs/connect",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SDK for integrating Vana Data Portability 'Connect data' flows",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/vana-com/vana-connect.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/vana-com/vana-connect#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/vana-com/vana-connect/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./server": {
|
|
27
|
+
"types": "./dist/server/index.d.ts",
|
|
28
|
+
"import": "./dist/server/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./react": {
|
|
31
|
+
"types": "./dist/react/index.d.ts",
|
|
32
|
+
"import": "./dist/react/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./core": {
|
|
35
|
+
"types": "./dist/core/index.d.ts",
|
|
36
|
+
"import": "./dist/core/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc --build",
|
|
41
|
+
"clean": "tsc --build --clean",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest",
|
|
44
|
+
"test:e2e": "vitest run --config test/e2e/vitest.config.ts",
|
|
45
|
+
"lint": "tsc --noEmit",
|
|
46
|
+
"lint:eslint": "eslint 'src/**/*.ts' 'src/**/*.tsx'",
|
|
47
|
+
"lint:eslint:fix": "eslint --fix 'src/**/*.ts' 'src/**/*.tsx'",
|
|
48
|
+
"format": "prettier --write .",
|
|
49
|
+
"format:check": "prettier --check .",
|
|
50
|
+
"validate": "npm run lint && npm run lint:eslint && npm run format:check && npm test",
|
|
51
|
+
"prepare": "husky"
|
|
52
|
+
},
|
|
53
|
+
"lint-staged": {
|
|
54
|
+
"*.{ts,tsx,js}": [
|
|
55
|
+
"eslint --fix",
|
|
56
|
+
"prettier --write"
|
|
57
|
+
],
|
|
58
|
+
"*.{json,md,yml,yaml}": [
|
|
59
|
+
"prettier --write"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=20.0.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"viem": "^2.0.0",
|
|
67
|
+
"react": ">=18.0.0"
|
|
68
|
+
},
|
|
69
|
+
"peerDependenciesMeta": {
|
|
70
|
+
"react": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"viem": {
|
|
74
|
+
"optional": true
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@commitlint/cli": "^20.4.1",
|
|
79
|
+
"@commitlint/config-conventional": "^20.4.1",
|
|
80
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
81
|
+
"@semantic-release/git": "^10.0.1",
|
|
82
|
+
"@semantic-release/github": "^12.0.3",
|
|
83
|
+
"@semantic-release/npm": "^13.1.3",
|
|
84
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
85
|
+
"@types/node": "^25.2.0",
|
|
86
|
+
"@types/react": "^19.0.0",
|
|
87
|
+
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
88
|
+
"eslint": "^9.39.2",
|
|
89
|
+
"eslint-config-prettier": "^10.1.8",
|
|
90
|
+
"husky": "^9.1.7",
|
|
91
|
+
"lint-staged": "^16.2.7",
|
|
92
|
+
"prettier": "^3.8.1",
|
|
93
|
+
"react": "^19.0.0",
|
|
94
|
+
"semantic-release": "^25.0.3",
|
|
95
|
+
"typescript": "^5.7.0",
|
|
96
|
+
"typescript-eslint": "^8.54.0",
|
|
97
|
+
"viem": "^2.45.0",
|
|
98
|
+
"vitest": "^4.0.18"
|
|
99
|
+
}
|
|
100
|
+
}
|