@opendatalabs/connect 0.8.0 → 0.8.1-canary.1d2cf51
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 +74 -0
- package/package.json +32 -4
- package/dist/core/constants.d.ts +0 -33
- package/dist/core/constants.d.ts.map +0 -1
- package/dist/core/constants.js +0 -25
- package/dist/core/constants.js.map +0 -1
- package/dist/core/errors.d.ts +0 -47
- package/dist/core/errors.d.ts.map +0 -1
- package/dist/core/errors.js +0 -50
- package/dist/core/errors.js.map +0 -1
- package/dist/core/grants.d.ts +0 -19
- package/dist/core/grants.d.ts.map +0 -1
- package/dist/core/grants.js +0 -31
- package/dist/core/grants.js.map +0 -1
- package/dist/core/index.d.ts +0 -5
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -4
- package/dist/core/index.js.map +0 -1
- package/dist/core/types.d.ts +0 -131
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js +0 -2
- package/dist/core/types.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/react/ConnectButton.d.ts +0 -27
- package/dist/react/ConnectButton.d.ts.map +0 -1
- package/dist/react/ConnectButton.js +0 -39
- package/dist/react/ConnectButton.js.map +0 -1
- package/dist/react/index.d.ts +0 -4
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -4
- package/dist/react/index.js.map +0 -1
- package/dist/react/useVanaConnect.d.ts +0 -50
- package/dist/react/useVanaConnect.d.ts.map +0 -1
- package/dist/react/useVanaConnect.js +0 -114
- package/dist/react/useVanaConnect.js.map +0 -1
- package/dist/react/useVanaData.d.ts +0 -69
- package/dist/react/useVanaData.d.ts.map +0 -1
- package/dist/react/useVanaData.js +0 -131
- package/dist/react/useVanaData.js.map +0 -1
- package/dist/server/config.d.ts +0 -36
- package/dist/server/config.d.ts.map +0 -1
- package/dist/server/config.js +0 -44
- package/dist/server/config.js.map +0 -1
- package/dist/server/connect.d.ts +0 -43
- package/dist/server/connect.d.ts.map +0 -1
- package/dist/server/connect.js +0 -98
- package/dist/server/connect.js.map +0 -1
- package/dist/server/data-client.d.ts +0 -31
- package/dist/server/data-client.d.ts.map +0 -1
- package/dist/server/data-client.js +0 -92
- package/dist/server/data-client.js.map +0 -1
- package/dist/server/index.d.ts +0 -8
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js +0 -8
- package/dist/server/index.js.map +0 -1
- package/dist/server/manifest-signer.d.ts +0 -25
- package/dist/server/manifest-signer.d.ts.map +0 -1
- package/dist/server/manifest-signer.js +0 -51
- package/dist/server/manifest-signer.js.map +0 -1
- package/dist/server/request-signer.d.ts +0 -31
- package/dist/server/request-signer.d.ts.map +0 -1
- package/dist/server/request-signer.js +0 -69
- package/dist/server/request-signer.js.map +0 -1
- package/dist/server/session-relay.d.ts +0 -39
- package/dist/server/session-relay.d.ts.map +0 -1
- package/dist/server/session-relay.js +0 -74
- package/dist/server/session-relay.js.map +0 -1
- package/dist/server/webhook.d.ts +0 -11
- package/dist/server/webhook.d.ts.map +0 -1
- package/dist/server/webhook.js +0 -18
- package/dist/server/webhook.js.map +0 -1
package/README.md
CHANGED
|
@@ -72,6 +72,80 @@ Then, in your dev version of DataConnect (likely built from the `main` branch) y
|
|
|
72
72
|
|
|
73
73
|
If you prefer to integrate the SDK into an existing project, follow the steps below.
|
|
74
74
|
|
|
75
|
+
## Headless CLI
|
|
76
|
+
|
|
77
|
+
`vana-connect` now also ships a local collection CLI for connector setup and data export flows.
|
|
78
|
+
|
|
79
|
+
### Install
|
|
80
|
+
|
|
81
|
+
macOS and Linux:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
curl -fsSL https://raw.githubusercontent.com/vana-com/vana-connect/main/install/install.sh | sh
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Windows PowerShell:
|
|
88
|
+
|
|
89
|
+
```powershell
|
|
90
|
+
iwr https://raw.githubusercontent.com/vana-com/vana-connect/main/install/install.ps1 -useb | iex
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Both installers fetch the latest GitHub release asset for your platform, verify its checksum, and install `vana` without requiring Node or npm.
|
|
94
|
+
|
|
95
|
+
If you want the npm package path as a fallback:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npx -y @opendatalabs/connect status
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Commands
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
vana sources
|
|
105
|
+
vana connect github
|
|
106
|
+
vana status
|
|
107
|
+
vana setup
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Local development
|
|
111
|
+
|
|
112
|
+
From this repo:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
pnpm install
|
|
116
|
+
pnpm build
|
|
117
|
+
node dist/cli/bin.js status
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The CLI installs its local browser runtime under `~/.dataconnect/`.
|
|
121
|
+
That runtime is bundled from `vana-connect` itself, so `vana setup` does not require a separate `data-connect` checkout.
|
|
122
|
+
|
|
123
|
+
To build a standalone launcher plus app payload locally:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pnpm build
|
|
127
|
+
pnpm build:sea
|
|
128
|
+
./artifacts/sea/vana-linux-x64/vana status --json
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`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/`.
|
|
132
|
+
It produces a platform-specific release directory plus a release archive and matching checksum file under `artifacts/sea/`.
|
|
133
|
+
|
|
134
|
+
### Programmatic runtime access
|
|
135
|
+
|
|
136
|
+
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.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { ManagedPlaywrightRuntime } from "@opendatalabs/connect/runtime";
|
|
140
|
+
import { listAvailableSources } from "@opendatalabs/connect/connectors";
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Intended split:
|
|
144
|
+
|
|
145
|
+
- app surfaces consume SDK/runtime APIs
|
|
146
|
+
- agent skills consume the CLI
|
|
147
|
+
- `data-connectors` remains the connector and schema source of truth
|
|
148
|
+
|
|
75
149
|
### Installation
|
|
76
150
|
|
|
77
151
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendatalabs/connect",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1-canary.1d2cf51",
|
|
4
4
|
"description": "SDK for integrating Vana Data Portability 'Connect data' flows",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"vana": "./dist/cli/bin.js"
|
|
21
|
+
},
|
|
19
22
|
"files": [
|
|
20
23
|
"dist"
|
|
21
24
|
],
|
|
@@ -35,12 +38,29 @@
|
|
|
35
38
|
"./core": {
|
|
36
39
|
"types": "./dist/core/index.d.ts",
|
|
37
40
|
"import": "./dist/core/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./runtime": {
|
|
43
|
+
"types": "./dist/runtime/index.d.ts",
|
|
44
|
+
"import": "./dist/runtime/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./connectors": {
|
|
47
|
+
"types": "./dist/connectors/index.d.ts",
|
|
48
|
+
"import": "./dist/connectors/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./cli": {
|
|
51
|
+
"types": "./dist/cli/main.d.ts",
|
|
52
|
+
"import": "./dist/cli/main.js"
|
|
38
53
|
}
|
|
39
54
|
},
|
|
40
55
|
"scripts": {
|
|
41
56
|
"build": "tsc --build",
|
|
42
|
-
"
|
|
57
|
+
"build:sea": "npx -y node@25 ./scripts/build-sea.mjs",
|
|
58
|
+
"build:sea:smoke": "npx -y node@25 ./scripts/build-sea.mjs --smoke",
|
|
59
|
+
"clean": "node ./scripts/clean-build.mjs",
|
|
60
|
+
"cli": "node dist/cli/bin.js",
|
|
43
61
|
"skills:sync": "node scripts/sync-skills.js",
|
|
62
|
+
"test:install:unix": "sh ./scripts/test-install-unix.sh",
|
|
63
|
+
"test:install:windows": "pwsh -File ./scripts/test-install-windows.ps1",
|
|
44
64
|
"test": "vitest run",
|
|
45
65
|
"test:watch": "vitest",
|
|
46
66
|
"test:e2e": "vitest run --config test/e2e/vitest.config.ts",
|
|
@@ -64,9 +84,16 @@
|
|
|
64
84
|
"engines": {
|
|
65
85
|
"node": ">=20.0.0"
|
|
66
86
|
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"@inquirer/prompts": "8.3.0",
|
|
89
|
+
"chromium-bidi": "15.0.0",
|
|
90
|
+
"commander": "14.0.3",
|
|
91
|
+
"playwright": "1.58.2",
|
|
92
|
+
"zod": "4.3.6"
|
|
93
|
+
},
|
|
67
94
|
"peerDependencies": {
|
|
68
|
-
"
|
|
69
|
-
"
|
|
95
|
+
"react": ">=18.0.0",
|
|
96
|
+
"viem": "^2.0.0"
|
|
70
97
|
},
|
|
71
98
|
"peerDependenciesMeta": {
|
|
72
99
|
"react": {
|
|
@@ -84,6 +111,7 @@
|
|
|
84
111
|
"@types/node": "^25.2.0",
|
|
85
112
|
"@types/react": "^19.0.0",
|
|
86
113
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
114
|
+
"esbuild": "^0.27.4",
|
|
87
115
|
"eslint": "^9.39.2",
|
|
88
116
|
"eslint-config-prettier": "^10.1.8",
|
|
89
117
|
"husky": "^9.1.7",
|
package/dist/core/constants.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** SDK environment selector. */
|
|
2
|
-
export type VanaEnvironment = "dev" | "prod";
|
|
3
|
-
/** URL configuration for each SDK environment. */
|
|
4
|
-
export declare const ENV_CONFIG: {
|
|
5
|
-
readonly dev: {
|
|
6
|
-
readonly sessionRelayUrl: "https://dev.session-relay.vana.org";
|
|
7
|
-
readonly gatewayUrl: "https://dev.data-gateway.vana.org";
|
|
8
|
-
readonly accountUrl: "https://account-dev.vana.org";
|
|
9
|
-
};
|
|
10
|
-
readonly prod: {
|
|
11
|
-
readonly sessionRelayUrl: "https://session-relay.vana.org";
|
|
12
|
-
readonly gatewayUrl: "https://data-gateway.vana.org";
|
|
13
|
-
readonly accountUrl: "https://account.vana.org";
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
/** Default environment used when none is specified. */
|
|
17
|
-
export declare const DEFAULT_ENVIRONMENT: VanaEnvironment;
|
|
18
|
-
/**
|
|
19
|
-
* Returns the URL configuration for the given environment.
|
|
20
|
-
*
|
|
21
|
-
* @param environment - `"dev"` or `"prod"`. Defaults to {@link DEFAULT_ENVIRONMENT}.
|
|
22
|
-
* @returns An object with `sessionRelayUrl` and `gatewayUrl`.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getEnvConfig(environment?: VanaEnvironment): {
|
|
25
|
-
readonly sessionRelayUrl: "https://dev.session-relay.vana.org";
|
|
26
|
-
readonly gatewayUrl: "https://dev.data-gateway.vana.org";
|
|
27
|
-
readonly accountUrl: "https://account-dev.vana.org";
|
|
28
|
-
} | {
|
|
29
|
-
readonly sessionRelayUrl: "https://session-relay.vana.org";
|
|
30
|
-
readonly gatewayUrl: "https://data-gateway.vana.org";
|
|
31
|
-
readonly accountUrl: "https://account.vana.org";
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,CAAC;AAE7C,kDAAkD;AAClD,eAAO,MAAM,UAAU;;;;;;;;;;;CAWb,CAAC;AAEX,uDAAuD;AACvD,eAAO,MAAM,mBAAmB,EAAE,eAAwB,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,WAAW,CAAC,EAAE,eAAe;;;;;;;;EAEzD"}
|
package/dist/core/constants.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** URL configuration for each SDK environment. */
|
|
2
|
-
export const ENV_CONFIG = {
|
|
3
|
-
dev: {
|
|
4
|
-
sessionRelayUrl: "https://dev.session-relay.vana.org",
|
|
5
|
-
gatewayUrl: "https://dev.data-gateway.vana.org",
|
|
6
|
-
accountUrl: "https://account-dev.vana.org",
|
|
7
|
-
},
|
|
8
|
-
prod: {
|
|
9
|
-
sessionRelayUrl: "https://session-relay.vana.org",
|
|
10
|
-
gatewayUrl: "https://data-gateway.vana.org",
|
|
11
|
-
accountUrl: "https://account.vana.org",
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
/** Default environment used when none is specified. */
|
|
15
|
-
export const DEFAULT_ENVIRONMENT = "prod";
|
|
16
|
-
/**
|
|
17
|
-
* Returns the URL configuration for the given environment.
|
|
18
|
-
*
|
|
19
|
-
* @param environment - `"dev"` or `"prod"`. Defaults to {@link DEFAULT_ENVIRONMENT}.
|
|
20
|
-
* @returns An object with `sessionRelayUrl` and `gatewayUrl`.
|
|
21
|
-
*/
|
|
22
|
-
export function getEnvConfig(environment) {
|
|
23
|
-
return ENV_CONFIG[environment ?? DEFAULT_ENVIRONMENT];
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAGA,kDAAkD;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE;QACH,eAAe,EAAE,oCAAoC;QACrD,UAAU,EAAE,mCAAmC;QAC/C,UAAU,EAAE,8BAA8B;KAC3C;IACD,IAAI,EAAE;QACJ,eAAe,EAAE,gCAAgC;QACjD,UAAU,EAAE,+BAA+B;QAC3C,UAAU,EAAE,0BAA0B;KACvC;CACO,CAAC;AAEX,uDAAuD;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAAoB,MAAM,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,WAA6B;IACxD,OAAO,UAAU,CAAC,WAAW,IAAI,mBAAmB,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/core/errors.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Known error codes thrown by the SDK.
|
|
3
|
-
*
|
|
4
|
-
* Use these constants for typed `catch` handling instead of comparing raw strings.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import { ConnectError, ConnectErrorCode } from "@opendatalabs/connect/core";
|
|
9
|
-
*
|
|
10
|
-
* try {
|
|
11
|
-
* await getData({ privateKey, grant });
|
|
12
|
-
* } catch (err) {
|
|
13
|
-
* if (err instanceof ConnectError && err.code === ConnectErrorCode.SERVER_NOT_FOUND) {
|
|
14
|
-
* // handle missing server
|
|
15
|
-
* }
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare const ConnectErrorCode: {
|
|
20
|
-
readonly SESSION_INIT_FAILED: "SESSION_INIT_FAILED";
|
|
21
|
-
readonly SESSION_EXPIRED: "SESSION_EXPIRED";
|
|
22
|
-
readonly POLL_FAILED: "POLL_FAILED";
|
|
23
|
-
readonly POLL_TIMEOUT: "POLL_TIMEOUT";
|
|
24
|
-
readonly SERVER_NOT_FOUND: "SERVER_NOT_FOUND";
|
|
25
|
-
readonly GATEWAY_ERROR: "GATEWAY_ERROR";
|
|
26
|
-
readonly DATA_FETCH_FAILED: "DATA_FETCH_FAILED";
|
|
27
|
-
readonly LIST_SCOPES_FAILED: "LIST_SCOPES_FAILED";
|
|
28
|
-
readonly LIST_VERSIONS_FAILED: "LIST_VERSIONS_FAILED";
|
|
29
|
-
readonly CONFIG_INVALID: "CONFIG_INVALID";
|
|
30
|
-
readonly WEBHOOK_INVALID: "WEBHOOK_INVALID";
|
|
31
|
-
};
|
|
32
|
-
/** Union type of all known error code string values. */
|
|
33
|
-
export type ConnectErrorCode = (typeof ConnectErrorCode)[keyof typeof ConnectErrorCode];
|
|
34
|
-
/**
|
|
35
|
-
* Error class thrown by all SDK operations.
|
|
36
|
-
*
|
|
37
|
-
* Includes a typed {@link code} for programmatic handling and an optional
|
|
38
|
-
* {@link statusCode} from HTTP responses.
|
|
39
|
-
*/
|
|
40
|
-
export declare class ConnectError extends Error {
|
|
41
|
-
/** Machine-readable error code. One of {@link ConnectErrorCode} or an arbitrary server-returned string. */
|
|
42
|
-
readonly code: ConnectErrorCode | (string & {});
|
|
43
|
-
/** HTTP status code from the upstream response, if applicable. */
|
|
44
|
-
readonly statusCode?: number;
|
|
45
|
-
constructor(message: string, code: ConnectErrorCode | (string & {}), statusCode?: number);
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;CAYnB,CAAC;AAEX,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE3D;;;;;GAKG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,2GAA2G;IAC3G,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAChD,kEAAkE;IAClE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAG3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,gBAAgB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EACtC,UAAU,CAAC,EAAE,MAAM;CAOtB"}
|
package/dist/core/errors.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Known error codes thrown by the SDK.
|
|
3
|
-
*
|
|
4
|
-
* Use these constants for typed `catch` handling instead of comparing raw strings.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import { ConnectError, ConnectErrorCode } from "@opendatalabs/connect/core";
|
|
9
|
-
*
|
|
10
|
-
* try {
|
|
11
|
-
* await getData({ privateKey, grant });
|
|
12
|
-
* } catch (err) {
|
|
13
|
-
* if (err instanceof ConnectError && err.code === ConnectErrorCode.SERVER_NOT_FOUND) {
|
|
14
|
-
* // handle missing server
|
|
15
|
-
* }
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export const ConnectErrorCode = {
|
|
20
|
-
SESSION_INIT_FAILED: "SESSION_INIT_FAILED",
|
|
21
|
-
SESSION_EXPIRED: "SESSION_EXPIRED",
|
|
22
|
-
POLL_FAILED: "POLL_FAILED",
|
|
23
|
-
POLL_TIMEOUT: "POLL_TIMEOUT",
|
|
24
|
-
SERVER_NOT_FOUND: "SERVER_NOT_FOUND",
|
|
25
|
-
GATEWAY_ERROR: "GATEWAY_ERROR",
|
|
26
|
-
DATA_FETCH_FAILED: "DATA_FETCH_FAILED",
|
|
27
|
-
LIST_SCOPES_FAILED: "LIST_SCOPES_FAILED",
|
|
28
|
-
LIST_VERSIONS_FAILED: "LIST_VERSIONS_FAILED",
|
|
29
|
-
CONFIG_INVALID: "CONFIG_INVALID",
|
|
30
|
-
WEBHOOK_INVALID: "WEBHOOK_INVALID",
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Error class thrown by all SDK operations.
|
|
34
|
-
*
|
|
35
|
-
* Includes a typed {@link code} for programmatic handling and an optional
|
|
36
|
-
* {@link statusCode} from HTTP responses.
|
|
37
|
-
*/
|
|
38
|
-
export class ConnectError extends Error {
|
|
39
|
-
/** Machine-readable error code. One of {@link ConnectErrorCode} or an arbitrary server-returned string. */
|
|
40
|
-
code;
|
|
41
|
-
/** HTTP status code from the upstream response, if applicable. */
|
|
42
|
-
statusCode;
|
|
43
|
-
constructor(message, code, statusCode) {
|
|
44
|
-
super(message);
|
|
45
|
-
this.name = "ConnectError";
|
|
46
|
-
this.code = code;
|
|
47
|
-
this.statusCode = statusCode;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/core/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,mBAAmB,EAAE,qBAAqB;IAC1C,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,gBAAgB,EAAE,kBAAkB;IACpC,aAAa,EAAE,eAAe;IAC9B,iBAAiB,EAAE,mBAAmB;IACtC,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,sBAAsB;IAC5C,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;CAC1B,CAAC;AAMX;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,2GAA2G;IAClG,IAAI,CAAmC;IAChD,kEAAkE;IACzD,UAAU,CAAU;IAE7B,YACE,OAAe,EACf,IAAsC,EACtC,UAAmB;QAEnB,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"}
|
package/dist/core/grants.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { GrantPayload } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Type guard that checks whether an unknown value has the shape of a {@link GrantPayload}.
|
|
4
|
-
*
|
|
5
|
-
* Validates the presence and types of required fields: `grantId`, `userAddress`,
|
|
6
|
-
* `builderAddress`, and `scopes` (non-empty string array).
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const body = await request.json();
|
|
11
|
-
* if (!isValidGrant(body.grant)) {
|
|
12
|
-
* return NextResponse.json({ error: "Invalid grant" }, { status: 400 });
|
|
13
|
-
* }
|
|
14
|
-
* // body.grant is now typed as GrantPayload
|
|
15
|
-
* const data = await getData({ privateKey, grant: body.grant });
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function isValidGrant(value: unknown): value is GrantPayload;
|
|
19
|
-
//# sourceMappingURL=grants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../src/core/grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAgBlE"}
|
package/dist/core/grants.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type guard that checks whether an unknown value has the shape of a {@link GrantPayload}.
|
|
3
|
-
*
|
|
4
|
-
* Validates the presence and types of required fields: `grantId`, `userAddress`,
|
|
5
|
-
* `builderAddress`, and `scopes` (non-empty string array).
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const body = await request.json();
|
|
10
|
-
* if (!isValidGrant(body.grant)) {
|
|
11
|
-
* return NextResponse.json({ error: "Invalid grant" }, { status: 400 });
|
|
12
|
-
* }
|
|
13
|
-
* // body.grant is now typed as GrantPayload
|
|
14
|
-
* const data = await getData({ privateKey, grant: body.grant });
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export function isValidGrant(value) {
|
|
18
|
-
if (value === null || typeof value !== "object")
|
|
19
|
-
return false;
|
|
20
|
-
const obj = value;
|
|
21
|
-
return (typeof obj.grantId === "string" &&
|
|
22
|
-
obj.grantId.length > 0 &&
|
|
23
|
-
typeof obj.userAddress === "string" &&
|
|
24
|
-
obj.userAddress.length > 0 &&
|
|
25
|
-
typeof obj.builderAddress === "string" &&
|
|
26
|
-
obj.builderAddress.length > 0 &&
|
|
27
|
-
Array.isArray(obj.scopes) &&
|
|
28
|
-
obj.scopes.length > 0 &&
|
|
29
|
-
obj.scopes.every((s) => typeof s === "string" && s.length > 0));
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=grants.js.map
|
package/dist/core/grants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../../src/core/grants.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE9D,MAAM,GAAG,GAAG,KAAgC,CAAC;IAE7C,OAAO,CACL,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;QAC/B,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QACtB,OAAO,GAAG,CAAC,WAAW,KAAK,QAAQ;QACnC,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;QAC1B,OAAO,GAAG,CAAC,cAAc,KAAK,QAAQ;QACtC,GAAG,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC;QAC7B,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;QACzB,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;QACrB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CACxE,CAAC;AACJ,CAAC"}
|
package/dist/core/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { ConnectError, ConnectErrorCode } from "./errors.js";
|
|
2
|
-
export { isValidGrant } from "./grants.js";
|
|
3
|
-
export { getEnvConfig, ENV_CONFIG, DEFAULT_ENVIRONMENT, type VanaEnvironment, } from "./constants.js";
|
|
4
|
-
export type { ConnectionStatus, SessionInitParams, SessionInitResult, SessionPollResult, GrantPayload, DataFetchParams, RequestSignerConfig, SessionRelayConfig, DataClientConfig, ConnectConfig, GetDataConfig, VanaManifestConfig, VanaManifestBlock, } from "./types.js";
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
package/dist/core/index.js
DELETED
package/dist/core/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,UAAU,EACV,mBAAmB,GAEpB,MAAM,gBAAgB,CAAC"}
|
package/dist/core/types.d.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/** Possible states of a Vana Connect session from the client's perspective. */
|
|
2
|
-
export type ConnectionStatus = "idle" | "connecting" | "waiting" | "approved" | "denied" | "expired" | "error";
|
|
3
|
-
/** Parameters for creating a new session on the Session Relay. */
|
|
4
|
-
export interface SessionInitParams {
|
|
5
|
-
/** Data scopes to request (e.g. `["chatgpt.conversations"]`). */
|
|
6
|
-
scopes: string[];
|
|
7
|
-
/** Public HTTPS URL for grant event notifications. Localhost is rejected. */
|
|
8
|
-
webhookUrl?: string;
|
|
9
|
-
/** Your app's user ID for correlation. */
|
|
10
|
-
appUserId?: string;
|
|
11
|
-
}
|
|
12
|
-
/** Result returned by {@link SessionRelay.initSession}. */
|
|
13
|
-
export interface SessionInitResult {
|
|
14
|
-
/** Unique session identifier used for polling. */
|
|
15
|
-
sessionId: string;
|
|
16
|
-
/** URL to account.vana.org where the user signs in and launches Data Connect. */
|
|
17
|
-
connectUrl: string;
|
|
18
|
-
/** ISO 8601 expiration timestamp for the session. */
|
|
19
|
-
expiresAt: string;
|
|
20
|
-
}
|
|
21
|
-
/** Result returned by {@link SessionRelay.pollSession}. */
|
|
22
|
-
export interface SessionPollResult {
|
|
23
|
-
/** Current session status. */
|
|
24
|
-
status: "pending" | "claimed" | "approved" | "denied" | "expired";
|
|
25
|
-
/** Grant payload, present when status is `"approved"`. */
|
|
26
|
-
grant?: GrantPayload;
|
|
27
|
-
/** Reason for denial, present when status is `"denied"`. */
|
|
28
|
-
reason?: string;
|
|
29
|
-
}
|
|
30
|
-
/** Payload describing a user's approved data grant. */
|
|
31
|
-
export interface GrantPayload {
|
|
32
|
-
/** On-chain permission ID. */
|
|
33
|
-
grantId: string;
|
|
34
|
-
/** User's wallet address. */
|
|
35
|
-
userAddress: string;
|
|
36
|
-
/** Builder's registered wallet address. */
|
|
37
|
-
builderAddress: string;
|
|
38
|
-
/** Approved data scopes. */
|
|
39
|
-
scopes: string[];
|
|
40
|
-
/** User's Personal Server address, if known. */
|
|
41
|
-
serverAddress?: string;
|
|
42
|
-
/** Your app's user ID, if provided during session init. */
|
|
43
|
-
appUserId?: string;
|
|
44
|
-
}
|
|
45
|
-
/** Parameters for fetching data from a Personal Server. */
|
|
46
|
-
export interface DataFetchParams {
|
|
47
|
-
/** Base URL of the user's Personal Server. */
|
|
48
|
-
serverUrl: string;
|
|
49
|
-
/** Data scope to fetch (e.g. `"instagram.profile"`). */
|
|
50
|
-
scope: string;
|
|
51
|
-
/** Grant ID authorizing the data access. */
|
|
52
|
-
grantId: string;
|
|
53
|
-
/** Optional file ID for a specific file within the scope. */
|
|
54
|
-
fileId?: string;
|
|
55
|
-
/** Optional ISO 8601 timestamp to fetch data at a specific point in time. */
|
|
56
|
-
at?: string;
|
|
57
|
-
}
|
|
58
|
-
/** Configuration for {@link createRequestSigner}. */
|
|
59
|
-
export interface RequestSignerConfig {
|
|
60
|
-
/** Builder private key in hex format. */
|
|
61
|
-
privateKey: `0x${string}`;
|
|
62
|
-
}
|
|
63
|
-
/** Configuration for {@link createSessionRelay}. */
|
|
64
|
-
export interface SessionRelayConfig {
|
|
65
|
-
/** Builder private key in hex format. */
|
|
66
|
-
privateKey: `0x${string}`;
|
|
67
|
-
/** Builder's wallet address derived from the private key. */
|
|
68
|
-
granteeAddress: `0x${string}`;
|
|
69
|
-
/** Base URL of the Session Relay service. */
|
|
70
|
-
sessionRelayUrl: string;
|
|
71
|
-
}
|
|
72
|
-
/** Configuration for {@link createDataClient}. */
|
|
73
|
-
export interface DataClientConfig {
|
|
74
|
-
/** Builder private key in hex format. */
|
|
75
|
-
privateKey: `0x${string}`;
|
|
76
|
-
/** Base URL of the Data Portability Gateway. */
|
|
77
|
-
gatewayUrl: string;
|
|
78
|
-
}
|
|
79
|
-
/** Configuration for the high-level {@link connect} function. */
|
|
80
|
-
export interface ConnectConfig {
|
|
81
|
-
/** Builder private key in hex format. */
|
|
82
|
-
privateKey: `0x${string}`;
|
|
83
|
-
/** Data scopes to request. */
|
|
84
|
-
scopes: string[];
|
|
85
|
-
/** Public HTTPS URL for grant event notifications. */
|
|
86
|
-
webhookUrl?: string;
|
|
87
|
-
/** Your app's user ID for correlation. */
|
|
88
|
-
appUserId?: string;
|
|
89
|
-
/** SDK environment (`"dev"` or `"prod"`). Defaults to `"prod"`. */
|
|
90
|
-
environment?: "dev" | "prod";
|
|
91
|
-
}
|
|
92
|
-
/** Configuration for the high-level {@link getData} function. */
|
|
93
|
-
export interface GetDataConfig {
|
|
94
|
-
/** Builder private key in hex format. */
|
|
95
|
-
privateKey: `0x${string}`;
|
|
96
|
-
/** Grant from the approval step. */
|
|
97
|
-
grant: GrantPayload;
|
|
98
|
-
/** SDK environment (`"dev"` or `"prod"`). Defaults to `"prod"`. */
|
|
99
|
-
environment?: "dev" | "prod";
|
|
100
|
-
}
|
|
101
|
-
/** Configuration for {@link signVanaManifest}. */
|
|
102
|
-
export interface VanaManifestConfig {
|
|
103
|
-
/** Builder private key in hex format. */
|
|
104
|
-
privateKey: `0x${string}`;
|
|
105
|
-
/** Canonical URL of your application. */
|
|
106
|
-
appUrl: string;
|
|
107
|
-
/** URL to your privacy policy. */
|
|
108
|
-
privacyPolicyUrl: string;
|
|
109
|
-
/** URL to your terms of service. */
|
|
110
|
-
termsUrl: string;
|
|
111
|
-
/** URL for user support. */
|
|
112
|
-
supportUrl: string;
|
|
113
|
-
/** Public webhook URL for grant notifications. */
|
|
114
|
-
webhookUrl: string;
|
|
115
|
-
}
|
|
116
|
-
/** Signed manifest block included in your web app manifest under the `vana` key. */
|
|
117
|
-
export interface VanaManifestBlock {
|
|
118
|
-
/** Canonical URL of your application. */
|
|
119
|
-
appUrl: string;
|
|
120
|
-
/** URL to your privacy policy. */
|
|
121
|
-
privacyPolicyUrl: string;
|
|
122
|
-
/** URL to your terms of service. */
|
|
123
|
-
termsUrl: string;
|
|
124
|
-
/** URL for user support. */
|
|
125
|
-
supportUrl: string;
|
|
126
|
-
/** Public webhook URL for grant notifications. */
|
|
127
|
-
webhookUrl: string;
|
|
128
|
-
/** Cryptographic signature of the manifest block. */
|
|
129
|
-
signature: string;
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/core/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,YAAY,GACZ,SAAS,GACT,UAAU,GACV,QAAQ,GACR,SAAS,GACT,OAAO,CAAC;AAEZ,kEAAkE;AAClE,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,2DAA2D;AAC3D,MAAM,WAAW,iBAAiB;IAChC,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,2DAA2D;AAC3D,MAAM,WAAW,iBAAiB;IAChC,8BAA8B;IAC9B,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,SA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":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { GrantPayload } from "../core/types.js";
|
|
2
|
-
/** Props for the {@link ConnectButton} component. */
|
|
3
|
-
export interface ConnectButtonProps {
|
|
4
|
-
/** Session ID from the server-side `connect()` call. */
|
|
5
|
-
sessionId: string;
|
|
6
|
-
/** URL to account.vana.org/connect. */
|
|
7
|
-
connectUrl?: string;
|
|
8
|
-
/** Called when the user approves the grant. */
|
|
9
|
-
onComplete?: (grant: GrantPayload) => void;
|
|
10
|
-
/** Called on polling errors. */
|
|
11
|
-
onError?: (error: string) => void;
|
|
12
|
-
/** Called when the user denies the request. */
|
|
13
|
-
onDenied?: (reason: string) => void;
|
|
14
|
-
/** CSS class name for the wrapper element. */
|
|
15
|
-
className?: string;
|
|
16
|
-
/** Label for the connect anchor (default: `"Connect with Vana"`). */
|
|
17
|
-
label?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Pre-built React component that displays connection status and a deep link.
|
|
21
|
-
*
|
|
22
|
-
* For full control over the UI, use {@link useVanaConnect} or {@link useVanaData} directly.
|
|
23
|
-
*
|
|
24
|
-
* @param props - Component props.
|
|
25
|
-
*/
|
|
26
|
-
export declare function ConnectButton(props: ConnectButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
//# sourceMappingURL=ConnectButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3C,gCAAgC;IAChC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAiDtD"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useVanaConnect } from "./useVanaConnect.js";
|
|
4
|
-
/**
|
|
5
|
-
* Pre-built React component that displays connection status and a deep link.
|
|
6
|
-
*
|
|
7
|
-
* For full control over the UI, use {@link useVanaConnect} or {@link useVanaData} directly.
|
|
8
|
-
*
|
|
9
|
-
* @param props - Component props.
|
|
10
|
-
*/
|
|
11
|
-
export function ConnectButton(props) {
|
|
12
|
-
const { sessionId, connectUrl: connectUrlProp, onComplete, onError, onDenied, className, label, } = props;
|
|
13
|
-
const { connect, status, grant, error, connectUrl } = useVanaConnect();
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
connect({ sessionId, connectUrl: connectUrlProp });
|
|
16
|
-
}, [sessionId, connectUrlProp, connect]);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (status === "approved" && grant && onComplete) {
|
|
19
|
-
onComplete(grant);
|
|
20
|
-
}
|
|
21
|
-
if (status === "error" && error && onError) {
|
|
22
|
-
onError(error);
|
|
23
|
-
}
|
|
24
|
-
if (status === "denied" && onDenied) {
|
|
25
|
-
onDenied(error ?? "User denied the request");
|
|
26
|
-
}
|
|
27
|
-
}, [status, grant, error, onComplete, onError, onDenied]);
|
|
28
|
-
const statusText = {
|
|
29
|
-
idle: "Initializing...",
|
|
30
|
-
connecting: "Connecting...",
|
|
31
|
-
waiting: "Waiting for approval...",
|
|
32
|
-
approved: "Connected!",
|
|
33
|
-
denied: "Request denied",
|
|
34
|
-
expired: "Session expired",
|
|
35
|
-
error: "Connection error",
|
|
36
|
-
};
|
|
37
|
-
return (_jsxs("div", { className: className, children: [_jsx("p", { children: statusText[status] ?? status }), connectUrl && status === "waiting" && (_jsx("a", { href: connectUrl, target: "_blank", rel: "noopener noreferrer", children: label ?? "Connect with Vana" }))] }));
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=ConnectButton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAoBrD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,EACJ,SAAS,EACT,UAAU,EAAE,cAAc,EAC1B,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,GACN,GAAG,KAAK,CAAC;IAEV,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,cAAc,EAAE,CAAC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