create-disposabl-app 0.10.0 → 0.10.1
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/dist/disposabl.js +1 -1
- package/dist/index.js +2 -2
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.api-keys.tsx +1 -1
- package/dist/templates/default/bun.lock +16 -1230
- package/dist/templates/default/packages/cli/README.md +9 -24
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/login.tsx +1 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/signUp.tsx +1 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/consent.tsx +71 -13
- package/dist/templates/default/packages/disposabl-kit/package.json +0 -12
- package/package.json +1 -1
- package/dist/templates/default/apps/web/src/components/connections/expo-connection.tsx +0 -97
- package/dist/templates/default/apps/web/src/components/connections/provider-logo.tsx +0 -44
- package/dist/templates/default/apps/web/src/components/connections/use-connection-setup.ts +0 -169
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/accordion.tsx +0 -77
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/alert-dialog.tsx +0 -185
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/alert.tsx +0 -75
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/aspect-ratio.tsx +0 -22
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/attachment.tsx +0 -207
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/avatar.tsx +0 -106
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/badge.tsx +0 -51
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/breadcrumb.tsx +0 -121
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/bubble.tsx +0 -127
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/button-group.tsx +0 -87
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/calendar.tsx +0 -241
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/carousel.tsx +0 -239
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/chart.tsx +0 -368
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/checkbox.tsx +0 -27
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/code-block.tsx +0 -243
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/collapsible.tsx +0 -19
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/combobox.tsx +0 -300
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/command.tsx +0 -194
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/context-menu.tsx +0 -271
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/dialog.tsx +0 -156
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/direction.tsx +0 -4
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/drawer.tsx +0 -224
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/dropdown-menu.tsx +0 -269
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/empty.tsx +0 -103
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/hover-card.tsx +0 -50
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/input-group.tsx +0 -158
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/input-otp.tsx +0 -83
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/item.tsx +0 -201
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/kbd.tsx +0 -26
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/marker.tsx +0 -70
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/menubar.tsx +0 -284
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/message-scroller.tsx +0 -128
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/message.tsx +0 -91
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/native-select.tsx +0 -64
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/navigation-menu.tsx +0 -170
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/pagination.tsx +0 -133
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/popover.tsx +0 -87
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/progress.tsx +0 -82
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/questionnaire.tsx +0 -330
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/radio-group.tsx +0 -35
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/resizable.tsx +0 -49
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/scroll-area.tsx +0 -51
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/select.tsx +0 -201
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/sheet.tsx +0 -132
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/sidebar.tsx +0 -723
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/skeleton.tsx +0 -13
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/slider.tsx +0 -51
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/switch.tsx +0 -31
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/table.tsx +0 -113
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/tabs.tsx +0 -81
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/textarea.tsx +0 -17
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/toast.tsx +0 -229
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/toggle-group.tsx +0 -87
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/toggle.tsx +0 -42
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/tooltip.tsx +0 -65
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/trace.tsx +0 -161
- package/dist/templates/default/packages/disposabl-kit/client/hooks/use-mobile.ts +0 -21
|
@@ -1,29 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# App CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This CLI calls your app's API. Commands come from its OpenAPI contract.
|
|
4
|
+
|
|
5
|
+
Set `productionConvexSiteUrl` in `disposabl.json` to your deployed app's Convex site URL. You can also pass `--origin <url>` or set `DISPOSABL_CLI_ORIGIN`.
|
|
4
6
|
|
|
5
7
|
```sh
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
disposabl apps get --appId <uuid>
|
|
11
|
-
disposabl previews token create --configure .
|
|
12
|
-
disposabl previews get
|
|
13
|
-
disposabl apps delete --appId <uuid> --dangerously-delete-app
|
|
14
|
-
disposabl logout
|
|
8
|
+
bun run build
|
|
9
|
+
node dist/index.js login
|
|
10
|
+
node dist/index.js users current
|
|
11
|
+
node dist/index.js logout
|
|
15
12
|
```
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`login status` returns `currentUser`. `login --no-browser` prints the OAuth URL. The CLI owns PKCE, the loopback callback, refresh, and logout. The generator only invokes these commands.
|
|
20
|
-
|
|
21
|
-
Credentials live under `~/.config/disposabl` with restricted file permissions. `DISPOSABL_CONFIG_DIR` changes the local credential directory. `DISPOSABL_API_KEY` provides an automation credential. The service origin has no public override.
|
|
22
|
-
|
|
23
|
-
Use `--json` for machine-readable preview output. Other commands return JSON; `--help` lists their arguments.
|
|
24
|
-
|
|
25
|
-
App deletion runs in the Convex action using connected provider credentials. Apps with production releases cannot be deleted. The CLI never launches EAS or asks for an Expo password.
|
|
26
|
-
|
|
27
|
-
When Expo rejects token-based deletion, the action records that Expo cleanup is pending and continues deleting GitHub and Convex. Once both are removed, it returns `expo_manual_delete_required` with the app ID, Expo project ID, and exact `projectUrl` ending in `/settings/advanced`. The CLI opens that URL in the browser and prints it. Sign in directly to Expo if needed, then use Delete project. Pass `--no-browser` to print the link without opening it.
|
|
28
|
-
|
|
29
|
-
The command exits unsuccessfully while manual cleanup is pending. Rerun the same Disposabl deletion command after deleting the Expo project. The action verifies the connected Expo account and project removal, then deletes previews and the app record. Interrupted provider cleanup remains resumable. Keep the owning accounts connected until deletion finishes; Disposabl does not accept Expo passwords or session cookies.
|
|
14
|
+
Run `node dist/index.js --help` for available commands. Use `login --no-browser` to print the sign-in URL.
|
|
@@ -21,7 +21,7 @@ import { useEffect, useRef, useState } from "react";
|
|
|
21
21
|
import { useConvexAuth } from "convex/react";
|
|
22
22
|
import { getReturnTo } from "../../lib/return-to";
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
function LogIn() {
|
|
25
25
|
const { request, returnTo } = Route.useSearch();
|
|
26
26
|
const navigate = useNavigate();
|
|
27
27
|
const { isLoading, isAuthenticated } = useConvexAuth();
|
|
@@ -22,7 +22,7 @@ import { useEffect, useRef, useState } from "react";
|
|
|
22
22
|
import { useConvexAuth } from "convex/react";
|
|
23
23
|
import { getReturnTo } from "../../lib/return-to";
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
function SignUp() {
|
|
26
26
|
const { request, returnTo } = Route.useSearch();
|
|
27
27
|
const navigate = useNavigate();
|
|
28
28
|
const { isLoading, isAuthenticated } = useConvexAuth();
|
|
@@ -14,7 +14,7 @@ export const Route = createFileRoute("/_providers/consent")({
|
|
|
14
14
|
component: ConsentPage,
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
function ConsentPage() {
|
|
18
18
|
const { request: requestId } = Route.useSearch();
|
|
19
19
|
const request = useQuery(
|
|
20
20
|
api.mcp.getAuthRequest,
|
|
@@ -24,15 +24,39 @@ export function ConsentPage() {
|
|
|
24
24
|
const { isAuthenticated, isLoading } = useConvexAuth();
|
|
25
25
|
const [pending, setPending] = useState(false);
|
|
26
26
|
const [error, setError] = useState<string | null>(null);
|
|
27
|
+
const [decision, setDecision] = useState<{
|
|
28
|
+
requestId: string;
|
|
29
|
+
approved: boolean;
|
|
30
|
+
} | null>(null);
|
|
31
|
+
const [confirmed, setConfirmed] = useState<{
|
|
32
|
+
requestId: string;
|
|
33
|
+
code: string;
|
|
34
|
+
} | null>(null);
|
|
35
|
+
const deviceConfirmed =
|
|
36
|
+
request?.kind === "device" &&
|
|
37
|
+
!!request.userCode &&
|
|
38
|
+
confirmed?.requestId === requestId &&
|
|
39
|
+
confirmed?.code === request.userCode;
|
|
27
40
|
|
|
28
41
|
const decide = async (approve: boolean) => {
|
|
29
|
-
if (!requestId || pending)
|
|
42
|
+
if (!requestId || pending || !request || request.status !== "pending")
|
|
43
|
+
return;
|
|
44
|
+
if (approve && request.kind === "device" && !deviceConfirmed) return;
|
|
30
45
|
setPending(true);
|
|
31
46
|
setError(null);
|
|
32
47
|
try {
|
|
33
|
-
const { redirectUrl } = await authorize({
|
|
48
|
+
const { redirectUrl } = await authorize({
|
|
49
|
+
requestId,
|
|
50
|
+
approve,
|
|
51
|
+
...(approve && request.kind === "device" && deviceConfirmed
|
|
52
|
+
? { userCode: request.userCode }
|
|
53
|
+
: {}),
|
|
54
|
+
});
|
|
34
55
|
if (redirectUrl) window.location.assign(redirectUrl);
|
|
35
|
-
else
|
|
56
|
+
else {
|
|
57
|
+
setDecision({ requestId, approved: approve });
|
|
58
|
+
setPending(false);
|
|
59
|
+
}
|
|
36
60
|
} catch {
|
|
37
61
|
setError("Could not save your decision. Please try again.");
|
|
38
62
|
setPending(false);
|
|
@@ -40,7 +64,15 @@ export function ConsentPage() {
|
|
|
40
64
|
};
|
|
41
65
|
|
|
42
66
|
let content;
|
|
43
|
-
if (
|
|
67
|
+
if (decision && decision.requestId === requestId) {
|
|
68
|
+
content = (
|
|
69
|
+
<p role="status">
|
|
70
|
+
{decision.approved
|
|
71
|
+
? "Connected. Return to your agent to continue."
|
|
72
|
+
: "Connection denied. You can close this page."}
|
|
73
|
+
</p>
|
|
74
|
+
);
|
|
75
|
+
} else if (!requestId) {
|
|
44
76
|
content = (
|
|
45
77
|
<p>
|
|
46
78
|
No connection request was provided. Start the connection from your
|
|
@@ -68,7 +100,7 @@ export function ConsentPage() {
|
|
|
68
100
|
<>
|
|
69
101
|
<p>
|
|
70
102
|
<strong>{request.clientName || request.clientId}</strong> wants to
|
|
71
|
-
connect to {request.serverName}.
|
|
103
|
+
connect to {request.serverName}. This name is provided by the agent.
|
|
72
104
|
</p>
|
|
73
105
|
<section className="space-y-2" aria-label="Requested permissions">
|
|
74
106
|
<h2 className="font-medium">Requested access</h2>
|
|
@@ -84,12 +116,33 @@ export function ConsentPage() {
|
|
|
84
116
|
</p>
|
|
85
117
|
)}
|
|
86
118
|
</section>
|
|
87
|
-
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
119
|
+
{request.kind === "device" ? (
|
|
120
|
+
<div className="space-y-2 text-sm">
|
|
121
|
+
<p className="font-medium">Device code: {request.userCode}</p>
|
|
122
|
+
<label className="flex items-start gap-2">
|
|
123
|
+
<input
|
|
124
|
+
type="checkbox"
|
|
125
|
+
checked={deviceConfirmed}
|
|
126
|
+
disabled={!request.userCode || pending}
|
|
127
|
+
onChange={(event) =>
|
|
128
|
+
setConfirmed(
|
|
129
|
+
event.target.checked && request.userCode
|
|
130
|
+
? { requestId, code: request.userCode }
|
|
131
|
+
: null,
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
/>
|
|
135
|
+
I verified this code matches the one shown by my agent.
|
|
136
|
+
</label>
|
|
137
|
+
</div>
|
|
138
|
+
) : (
|
|
139
|
+
<div className="space-y-1 text-sm">
|
|
140
|
+
<p className="font-medium">Return address</p>
|
|
141
|
+
<p className="break-all text-muted-foreground">
|
|
142
|
+
{request.redirectUri}
|
|
143
|
+
</p>
|
|
144
|
+
</div>
|
|
145
|
+
)}
|
|
93
146
|
{error && (
|
|
94
147
|
<p role="alert" className="text-destructive">
|
|
95
148
|
{error}
|
|
@@ -104,7 +157,12 @@ export function ConsentPage() {
|
|
|
104
157
|
>
|
|
105
158
|
Deny
|
|
106
159
|
</Button>
|
|
107
|
-
<Button
|
|
160
|
+
<Button
|
|
161
|
+
disabled={
|
|
162
|
+
pending || (request.kind === "device" && !deviceConfirmed)
|
|
163
|
+
}
|
|
164
|
+
onClick={() => decide(true)}
|
|
165
|
+
>
|
|
108
166
|
Allow
|
|
109
167
|
</Button>
|
|
110
168
|
{pending && (
|
|
@@ -11,23 +11,13 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@base-ui/react": "^1.9.0",
|
|
13
13
|
"@fontsource-variable/inter": "^5.3.0",
|
|
14
|
-
"@shadcn/react": "^0.3.1",
|
|
15
14
|
"class-variance-authority": "^0.7.1",
|
|
16
|
-
"cmdk": "^1.1.1",
|
|
17
15
|
"cn": "^0.5.0",
|
|
18
|
-
"date-fns": "^4.4.0",
|
|
19
|
-
"embla-carousel-react": "^8.6.0",
|
|
20
|
-
"input-otp": "^1.5.0",
|
|
21
16
|
"lucide-react": "catalog:",
|
|
22
17
|
"react": "catalog:",
|
|
23
|
-
"react-day-picker": "^10.0.2",
|
|
24
18
|
"react-dom": "catalog:",
|
|
25
|
-
"react-resizable-panels": "^4.15.0",
|
|
26
|
-
"recharts": "3.8.0",
|
|
27
19
|
"shadcn": "^4.22.1",
|
|
28
|
-
"shiki": "^4.5.0",
|
|
29
20
|
"tw-animate-css": "^1.4.0",
|
|
30
|
-
"zod": "^4.6.7",
|
|
31
21
|
"convex": "catalog:",
|
|
32
22
|
"@convex-dev/auth": "catalog:",
|
|
33
23
|
"@convex-dev/mcp": "catalog:",
|
|
@@ -38,7 +28,6 @@
|
|
|
38
28
|
"devDependencies": {
|
|
39
29
|
"@tailwindcss/vite": "^4",
|
|
40
30
|
"@tanstack/eslint-config": "latest",
|
|
41
|
-
"@turbo/gen": "^2.11.10",
|
|
42
31
|
"@types/node": "^22",
|
|
43
32
|
"@types/react": "^19",
|
|
44
33
|
"@types/react-dom": "^19",
|
|
@@ -54,7 +43,6 @@
|
|
|
54
43
|
"./client/styles/globals.css": "./client/styles/globals.css",
|
|
55
44
|
"./client/lib/*": "./client/lib/*.ts",
|
|
56
45
|
"./client/components/ui/*": "./client/components/ui/*.tsx",
|
|
57
|
-
"./client/hooks/*": "./client/hooks/*.ts",
|
|
58
46
|
"./server/http": "./server/http.ts",
|
|
59
47
|
"./server/lib/functions": "./server/lib/functions.ts",
|
|
60
48
|
"./client/vite.config": "./client/vite.config.ts",
|
package/package.json
CHANGED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { useAction } from "convex/react";
|
|
3
|
-
import { api } from "../../../../../packages/backend/convex/_generated/api";
|
|
4
|
-
import { Button } from "@disposabl/disposabl-kit/client/components/ui/button";
|
|
5
|
-
import { Input } from "@disposabl/disposabl-kit/client/components/ui/input";
|
|
6
|
-
|
|
7
|
-
export function ExpoConnection({
|
|
8
|
-
busy,
|
|
9
|
-
run,
|
|
10
|
-
onConnected,
|
|
11
|
-
}: {
|
|
12
|
-
busy: boolean;
|
|
13
|
-
run: (action: () => Promise<void>) => Promise<void>;
|
|
14
|
-
onConnected: () => void;
|
|
15
|
-
}) {
|
|
16
|
-
const expoAccounts = useAction(api.connections.index.expoAccounts);
|
|
17
|
-
const connectExpo = useAction(api.connections.index.connectExpo);
|
|
18
|
-
const [token, setToken] = useState("");
|
|
19
|
-
const [accounts, setAccounts] = useState<Array<{ id: string; name: string }>>(
|
|
20
|
-
[],
|
|
21
|
-
);
|
|
22
|
-
const [accountId, setAccountId] = useState("");
|
|
23
|
-
return (
|
|
24
|
-
<form
|
|
25
|
-
className="mt-5 space-y-4 border-t pt-5"
|
|
26
|
-
onSubmit={(event) => {
|
|
27
|
-
event.preventDefault();
|
|
28
|
-
void run(async () => {
|
|
29
|
-
if (!accounts.length) {
|
|
30
|
-
const result = await expoAccounts({ token });
|
|
31
|
-
if (!result.length)
|
|
32
|
-
throw new Error("No Expo accounts were found for this token.");
|
|
33
|
-
setAccounts(result);
|
|
34
|
-
setAccountId(result[0]?.id ?? "");
|
|
35
|
-
} else {
|
|
36
|
-
await connectExpo({ token, accountId });
|
|
37
|
-
setToken("");
|
|
38
|
-
setAccounts([]);
|
|
39
|
-
setAccountId("");
|
|
40
|
-
onConnected();
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}}
|
|
44
|
-
>
|
|
45
|
-
<p className="text-sm text-muted-foreground">
|
|
46
|
-
Verify an Expo access token, then choose the account to save.
|
|
47
|
-
</p>
|
|
48
|
-
<label className="block space-y-2 text-sm font-medium">
|
|
49
|
-
Access token
|
|
50
|
-
<Input
|
|
51
|
-
type="password"
|
|
52
|
-
autoComplete="off"
|
|
53
|
-
required
|
|
54
|
-
value={token}
|
|
55
|
-
onChange={(event) => {
|
|
56
|
-
setToken(event.target.value);
|
|
57
|
-
setAccounts([]);
|
|
58
|
-
setAccountId("");
|
|
59
|
-
}}
|
|
60
|
-
/>
|
|
61
|
-
</label>
|
|
62
|
-
<a
|
|
63
|
-
className="inline-block text-sm underline underline-offset-4"
|
|
64
|
-
href="https://expo.dev/settings/access-tokens"
|
|
65
|
-
target="_blank"
|
|
66
|
-
rel="noreferrer"
|
|
67
|
-
>
|
|
68
|
-
Create an Expo access token
|
|
69
|
-
</a>
|
|
70
|
-
{accounts.length > 0 && (
|
|
71
|
-
<label className="block space-y-2 text-sm font-medium">
|
|
72
|
-
Expo account
|
|
73
|
-
<select
|
|
74
|
-
className="block min-h-11 w-full rounded-md border bg-background px-3"
|
|
75
|
-
value={accountId}
|
|
76
|
-
onChange={(event) => setAccountId(event.target.value)}
|
|
77
|
-
>
|
|
78
|
-
{accounts.map((account) => (
|
|
79
|
-
<option key={account.id} value={account.id}>
|
|
80
|
-
{account.name}
|
|
81
|
-
</option>
|
|
82
|
-
))}
|
|
83
|
-
</select>
|
|
84
|
-
</label>
|
|
85
|
-
)}
|
|
86
|
-
<div>
|
|
87
|
-
<Button
|
|
88
|
-
type="submit"
|
|
89
|
-
className="min-h-11"
|
|
90
|
-
disabled={busy || !token.trim()}
|
|
91
|
-
>
|
|
92
|
-
{accounts.length ? "Save account" : "Verify token"}
|
|
93
|
-
</Button>
|
|
94
|
-
</div>
|
|
95
|
-
</form>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export function ProviderLogo({
|
|
2
|
-
provider,
|
|
3
|
-
}: {
|
|
4
|
-
provider: "github" | "convex" | "expo" | "blacksmith";
|
|
5
|
-
}) {
|
|
6
|
-
if (provider === "blacksmith")
|
|
7
|
-
return (
|
|
8
|
-
<span aria-hidden="true" className="font-mono text-xl font-bold">
|
|
9
|
-
B
|
|
10
|
-
</span>
|
|
11
|
-
);
|
|
12
|
-
if (provider === "github")
|
|
13
|
-
return (
|
|
14
|
-
<svg
|
|
15
|
-
viewBox="0 0 24 24"
|
|
16
|
-
fill="currentColor"
|
|
17
|
-
aria-hidden="true"
|
|
18
|
-
className="size-6"
|
|
19
|
-
>
|
|
20
|
-
<path d="M12 .5a12 12 0 0 0-3.79 23.39c.6.11.82-.26.82-.58v-2.23c-3.34.73-4.04-1.42-4.04-1.42-.55-1.39-1.33-1.76-1.33-1.76-1.09-.75.08-.73.08-.73 1.2.08 1.83 1.23 1.83 1.23 1.07 1.83 2.8 1.3 3.49.99.1-.77.42-1.3.76-1.6-2.67-.31-5.47-1.34-5.47-5.93 0-1.31.47-2.38 1.23-3.22-.12-.3-.53-1.52.12-3.17 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.29-1.55 3.29-1.23 3.29-1.23.65 1.65.24 2.87.12 3.17.77.84 1.23 1.91 1.23 3.22 0 4.6-2.8 5.62-5.48 5.92.43.37.81 1.1.81 2.22v3.3c0 .32.22.7.83.58A12 12 0 0 0 12 .5Z" />
|
|
21
|
-
</svg>
|
|
22
|
-
);
|
|
23
|
-
if (provider === "expo")
|
|
24
|
-
return (
|
|
25
|
-
<svg
|
|
26
|
-
viewBox="0 0 24 24"
|
|
27
|
-
fill="currentColor"
|
|
28
|
-
aria-hidden="true"
|
|
29
|
-
className="size-6"
|
|
30
|
-
>
|
|
31
|
-
<path d="M12 2c-.9 0-1.37.24-1.76.84-1.1 1.67-6.42 10.95-7.2 12.34-.52.92-.67 1.5-.45 2.19.31.96 1.26 1.65 2.18 1.65.66 0 1.11-.3 1.61-.98 1.07-1.47 3.43-5.61 4.74-7.47.28-.4.53-.61.88-.61s.6.21.88.61c1.31 1.86 3.67 6 4.74 7.47.5.68.95.98 1.61.98.92 0 1.87-.69 2.18-1.65.22-.69.07-1.27-.45-2.19-.78-1.39-6.1-10.67-7.2-12.34C13.37 2.24 12.9 2 12 2Z" />
|
|
32
|
-
</svg>
|
|
33
|
-
);
|
|
34
|
-
return (
|
|
35
|
-
<svg
|
|
36
|
-
viewBox="0 0 24 24"
|
|
37
|
-
fill="#EE342F"
|
|
38
|
-
aria-hidden="true"
|
|
39
|
-
className="size-7"
|
|
40
|
-
>
|
|
41
|
-
<path d="M15.09 18.916c3.488-.387 6.776-2.246 8.586-5.348-.857 7.673-9.247 12.522-16.095 9.545a3.47 3.47 0 0 1-1.547-1.314c-1.539-2.417-2.044-5.492-1.318-8.282 2.077 3.584 6.3 5.78 10.374 5.399m-10.501-7.65c-1.414 3.266-1.475 7.092.258 10.24-6.1-4.59-6.033-14.41-.074-18.953a3.44 3.44 0 0 1 1.893-.707c2.825-.15 5.695.942 7.708 2.977-4.09.04-8.073 2.66-9.785 6.442m11.757-5.437C14.283 2.951 11.053.992 7.515.933c6.84-3.105 15.253 1.929 16.17 9.37a3.6 3.6 0 0 1-.334 2.02c-1.278 2.594-3.647 4.607-6.416 5.352 2.029-3.763 1.778-8.36-.589-11.847" />
|
|
42
|
-
</svg>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { useAction, useMutation, useQuery } from "convex/react";
|
|
3
|
-
import { ConvexError } from "convex/values";
|
|
4
|
-
import { api } from "../../../../../packages/backend/convex/_generated/api";
|
|
5
|
-
|
|
6
|
-
type Provider = "github" | "convex";
|
|
7
|
-
type Installation = { installationId: string; owner: string };
|
|
8
|
-
const pendingKey = "disposabl.pendingConnectionProvider";
|
|
9
|
-
const isProvider = (value: string | null): value is Provider =>
|
|
10
|
-
value === "github" || value === "convex";
|
|
11
|
-
|
|
12
|
-
export function useConnectionSetup() {
|
|
13
|
-
const status = useQuery(api.connections.index.status, {});
|
|
14
|
-
const start = useAction(api.connections.index.start);
|
|
15
|
-
const resumeInstall = useAction(api.connections.index.resumeGithubInstall);
|
|
16
|
-
const confirmBlacksmith = useMutation(
|
|
17
|
-
api.connections.index.confirmBlacksmith,
|
|
18
|
-
);
|
|
19
|
-
const complete = useAction(api.connections.index.complete);
|
|
20
|
-
const selectGithub = useAction(api.connections.index.selectGithub);
|
|
21
|
-
const disconnect = useMutation(api.connections.index.disconnect);
|
|
22
|
-
const [busy, setBusy] = useState(false);
|
|
23
|
-
const [error, setError] = useState<string>();
|
|
24
|
-
const [installations, setInstallations] = useState<Installation[]>([]);
|
|
25
|
-
const [proof, setProof] = useState<string>();
|
|
26
|
-
const [installNeeded, setInstallNeeded] = useState(false);
|
|
27
|
-
const [mobile, setMobile] = useState(false);
|
|
28
|
-
const consumed = useRef(false);
|
|
29
|
-
const fail = (cause: unknown) =>
|
|
30
|
-
setError(
|
|
31
|
-
cause instanceof ConvexError && typeof cause.data === "string"
|
|
32
|
-
? cause.data
|
|
33
|
-
: cause instanceof Error
|
|
34
|
-
? cause.message
|
|
35
|
-
: "Something went wrong. Please try again.",
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (consumed.current) return;
|
|
40
|
-
consumed.current = true;
|
|
41
|
-
const url = new URL(window.location.href);
|
|
42
|
-
const mobileKey = "disposabl.setupMobile";
|
|
43
|
-
if (url.searchParams.has("mobile"))
|
|
44
|
-
sessionStorage.setItem(
|
|
45
|
-
mobileKey,
|
|
46
|
-
url.searchParams.get("mobile") === "1" ? "1" : "0",
|
|
47
|
-
);
|
|
48
|
-
setMobile(sessionStorage.getItem(mobileKey) === "1");
|
|
49
|
-
const queryProvider = url.searchParams.get("provider");
|
|
50
|
-
const pending = sessionStorage.getItem(pendingKey);
|
|
51
|
-
const provider = isProvider(queryProvider)
|
|
52
|
-
? queryProvider
|
|
53
|
-
: isProvider(pending)
|
|
54
|
-
? pending
|
|
55
|
-
: null;
|
|
56
|
-
const code = url.searchParams.get("code");
|
|
57
|
-
const state = url.searchParams.get("state");
|
|
58
|
-
const denial = url.searchParams.get("error");
|
|
59
|
-
const installationReturn =
|
|
60
|
-
url.searchParams.has("installation_id") ||
|
|
61
|
-
url.searchParams.has("setup_action");
|
|
62
|
-
// Remove callback credentials even after a denial or malformed response.
|
|
63
|
-
for (const key of [
|
|
64
|
-
"installation_id",
|
|
65
|
-
"setup_action",
|
|
66
|
-
"state",
|
|
67
|
-
"code",
|
|
68
|
-
"provider",
|
|
69
|
-
"error",
|
|
70
|
-
"error_description",
|
|
71
|
-
])
|
|
72
|
-
url.searchParams.delete(key);
|
|
73
|
-
window.history.replaceState(window.history.state, "", url.toString());
|
|
74
|
-
if (denial) {
|
|
75
|
-
sessionStorage.removeItem(pendingKey);
|
|
76
|
-
setError(
|
|
77
|
-
"Authorization was cancelled. Use the setup button to try again.",
|
|
78
|
-
);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (installationReturn) {
|
|
82
|
-
setBusy(true);
|
|
83
|
-
sessionStorage.setItem(pendingKey, "github");
|
|
84
|
-
void (state ? resumeInstall({ state }) : start({ provider: "github" }))
|
|
85
|
-
.then((next) => window.location.assign(next))
|
|
86
|
-
.catch(fail)
|
|
87
|
-
.finally(() => setBusy(false));
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const callback =
|
|
91
|
-
code !== null ||
|
|
92
|
-
state !== null ||
|
|
93
|
-
denial !== null ||
|
|
94
|
-
queryProvider !== null;
|
|
95
|
-
if (!callback) return;
|
|
96
|
-
if (!provider || !code || !state) {
|
|
97
|
-
setError(
|
|
98
|
-
"The authorization response is incomplete. Please connect again to restart authorization.",
|
|
99
|
-
);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
sessionStorage.removeItem(pendingKey);
|
|
103
|
-
setBusy(true);
|
|
104
|
-
void complete({ provider, code, state })
|
|
105
|
-
.then(async (result) => {
|
|
106
|
-
if (provider !== "github") return;
|
|
107
|
-
const installation = result.installations.at(0);
|
|
108
|
-
if (result.installations.length === 1 && installation) {
|
|
109
|
-
if (!result.proof)
|
|
110
|
-
throw new Error(
|
|
111
|
-
"GitHub did not return an account selection proof. Please connect again.",
|
|
112
|
-
);
|
|
113
|
-
await selectGithub({
|
|
114
|
-
proof: result.proof,
|
|
115
|
-
installationId: installation.installationId,
|
|
116
|
-
});
|
|
117
|
-
} else {
|
|
118
|
-
setInstallations(result.installations);
|
|
119
|
-
setProof(result.proof);
|
|
120
|
-
setInstallNeeded(result.installations.length === 0);
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
.catch(fail)
|
|
124
|
-
.finally(() => setBusy(false));
|
|
125
|
-
}, [complete, selectGithub, resumeInstall, start]);
|
|
126
|
-
|
|
127
|
-
async function run(action: () => Promise<void>) {
|
|
128
|
-
if (busy) return;
|
|
129
|
-
setBusy(true);
|
|
130
|
-
setError(undefined);
|
|
131
|
-
try {
|
|
132
|
-
await action();
|
|
133
|
-
} catch (cause) {
|
|
134
|
-
fail(cause);
|
|
135
|
-
} finally {
|
|
136
|
-
setBusy(false);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function connect(provider: Provider) {
|
|
140
|
-
void run(async () => {
|
|
141
|
-
const url = await start({ provider, install: provider === "github" });
|
|
142
|
-
sessionStorage.setItem(pendingKey, provider);
|
|
143
|
-
window.location.assign(url);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function chooseOrganization(installationId: string) {
|
|
148
|
-
void run(async () => {
|
|
149
|
-
if (!proof)
|
|
150
|
-
throw new Error("Restart GitHub setup to choose an organization.");
|
|
151
|
-
await selectGithub({ proof, installationId });
|
|
152
|
-
setInstallations([]);
|
|
153
|
-
setProof(undefined);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
status,
|
|
158
|
-
busy,
|
|
159
|
-
error,
|
|
160
|
-
run,
|
|
161
|
-
connect,
|
|
162
|
-
disconnect,
|
|
163
|
-
installations,
|
|
164
|
-
chooseOrganization,
|
|
165
|
-
installNeeded,
|
|
166
|
-
confirmBlacksmith,
|
|
167
|
-
mobile,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion";
|
|
2
|
-
import { cn } from "@disposabl/disposabl-kit/client/lib/utils";
|
|
3
|
-
import { ChevronDownIcon, ChevronUpIcon } from "lucide-react";
|
|
4
|
-
|
|
5
|
-
function Accordion({ className, ...props }: AccordionPrimitive.Root.Props) {
|
|
6
|
-
return (
|
|
7
|
-
<AccordionPrimitive.Root
|
|
8
|
-
data-slot="accordion"
|
|
9
|
-
className={cn("flex w-full flex-col", className)}
|
|
10
|
-
{...props}
|
|
11
|
-
/>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function AccordionItem({ className, ...props }: AccordionPrimitive.Item.Props) {
|
|
16
|
-
return (
|
|
17
|
-
<AccordionPrimitive.Item
|
|
18
|
-
data-slot="accordion-item"
|
|
19
|
-
className={cn("not-last:border-b", className)}
|
|
20
|
-
{...props}
|
|
21
|
-
/>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function AccordionTrigger({
|
|
26
|
-
className,
|
|
27
|
-
children,
|
|
28
|
-
...props
|
|
29
|
-
}: AccordionPrimitive.Trigger.Props) {
|
|
30
|
-
return (
|
|
31
|
-
<AccordionPrimitive.Header className="flex">
|
|
32
|
-
<AccordionPrimitive.Trigger
|
|
33
|
-
data-slot="accordion-trigger"
|
|
34
|
-
className={cn(
|
|
35
|
-
"group/accordion-trigger relative flex flex-1 items-start justify-between rounded-md border border-transparent py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",
|
|
36
|
-
className,
|
|
37
|
-
)}
|
|
38
|
-
{...props}
|
|
39
|
-
>
|
|
40
|
-
{children}
|
|
41
|
-
<ChevronDownIcon
|
|
42
|
-
data-slot="accordion-trigger-icon"
|
|
43
|
-
className="pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden"
|
|
44
|
-
/>
|
|
45
|
-
<ChevronUpIcon
|
|
46
|
-
data-slot="accordion-trigger-icon"
|
|
47
|
-
className="pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline"
|
|
48
|
-
/>
|
|
49
|
-
</AccordionPrimitive.Trigger>
|
|
50
|
-
</AccordionPrimitive.Header>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function AccordionContent({
|
|
55
|
-
className,
|
|
56
|
-
children,
|
|
57
|
-
...props
|
|
58
|
-
}: AccordionPrimitive.Panel.Props) {
|
|
59
|
-
return (
|
|
60
|
-
<AccordionPrimitive.Panel
|
|
61
|
-
data-slot="accordion-content"
|
|
62
|
-
className="overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up"
|
|
63
|
-
{...props}
|
|
64
|
-
>
|
|
65
|
-
<div
|
|
66
|
-
className={cn(
|
|
67
|
-
"h-(--accordion-panel-height) pt-0 pb-4 data-ending-style:h-0 data-starting-style:h-0 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",
|
|
68
|
-
className,
|
|
69
|
-
)}
|
|
70
|
-
>
|
|
71
|
-
{children}
|
|
72
|
-
</div>
|
|
73
|
-
</AccordionPrimitive.Panel>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|