create-disposabl-app 0.9.1 → 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.
Files changed (90) hide show
  1. package/dist/disposabl.js +1 -1
  2. package/dist/index.js +2 -2
  3. package/dist/templates/default/.github/workflows/pipeline.yml +1 -1
  4. package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.api-keys.tsx +1 -1
  5. package/dist/templates/default/bun.lock +77 -1397
  6. package/dist/templates/default/package.json +1 -2
  7. package/dist/templates/default/packages/backend/README.md +3 -1
  8. package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +6 -0
  9. package/dist/templates/default/packages/backend/convex/_generated/server.d.ts +0 -2
  10. package/dist/templates/default/packages/backend/convex/auth.config.ts +2 -10
  11. package/dist/templates/default/packages/backend/convex/convex.config.ts +3 -14
  12. package/dist/templates/default/packages/backend/convex/mcpEnterprise/README.md +42 -0
  13. package/dist/templates/default/packages/backend/convex/mcpEnterprise/internal.ts +153 -0
  14. package/dist/templates/default/packages/backend/convex/mcpEnterprise/provision.ts +102 -0
  15. package/dist/templates/default/packages/backend/convex/mcpEnterprise/validator.ts +35 -0
  16. package/dist/templates/default/packages/backend/convex/schema.ts +18 -0
  17. package/dist/templates/default/packages/backend/package.json +0 -1
  18. package/dist/templates/default/packages/cli/README.md +9 -24
  19. package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/login.tsx +1 -1
  20. package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/signUp.tsx +1 -1
  21. package/dist/templates/default/packages/disposabl-kit/client/routes/consent.tsx +71 -13
  22. package/dist/templates/default/packages/disposabl-kit/package.json +4 -14
  23. package/dist/templates/default/packages/disposabl-kit/server/http.ts +19 -12
  24. package/dist/templates/default/packages/disposabl-kit/server/lib/functions.ts +12 -0
  25. package/dist/templates/default/packages/disposabl-kit/server/mcp/enterprise.ts +267 -0
  26. package/dist/templates/default/packages/disposabl-kit/server/mcp/identity.ts +33 -0
  27. package/dist/templates/default/vendor/README.md +30 -0
  28. package/dist/templates/default/vendor/convex-auth-6c0ebf3f.tgz +0 -0
  29. package/package.json +1 -1
  30. package/dist/templates/default/apps/web/src/components/connections/expo-connection.tsx +0 -97
  31. package/dist/templates/default/apps/web/src/components/connections/provider-logo.tsx +0 -44
  32. package/dist/templates/default/apps/web/src/components/connections/use-connection-setup.ts +0 -169
  33. package/dist/templates/default/packages/disposabl-kit/client/components/ui/accordion.tsx +0 -77
  34. package/dist/templates/default/packages/disposabl-kit/client/components/ui/alert-dialog.tsx +0 -185
  35. package/dist/templates/default/packages/disposabl-kit/client/components/ui/alert.tsx +0 -75
  36. package/dist/templates/default/packages/disposabl-kit/client/components/ui/aspect-ratio.tsx +0 -22
  37. package/dist/templates/default/packages/disposabl-kit/client/components/ui/attachment.tsx +0 -207
  38. package/dist/templates/default/packages/disposabl-kit/client/components/ui/avatar.tsx +0 -106
  39. package/dist/templates/default/packages/disposabl-kit/client/components/ui/badge.tsx +0 -51
  40. package/dist/templates/default/packages/disposabl-kit/client/components/ui/breadcrumb.tsx +0 -121
  41. package/dist/templates/default/packages/disposabl-kit/client/components/ui/bubble.tsx +0 -127
  42. package/dist/templates/default/packages/disposabl-kit/client/components/ui/button-group.tsx +0 -87
  43. package/dist/templates/default/packages/disposabl-kit/client/components/ui/calendar.tsx +0 -241
  44. package/dist/templates/default/packages/disposabl-kit/client/components/ui/carousel.tsx +0 -239
  45. package/dist/templates/default/packages/disposabl-kit/client/components/ui/chart.tsx +0 -368
  46. package/dist/templates/default/packages/disposabl-kit/client/components/ui/checkbox.tsx +0 -27
  47. package/dist/templates/default/packages/disposabl-kit/client/components/ui/code-block.tsx +0 -243
  48. package/dist/templates/default/packages/disposabl-kit/client/components/ui/collapsible.tsx +0 -19
  49. package/dist/templates/default/packages/disposabl-kit/client/components/ui/combobox.tsx +0 -300
  50. package/dist/templates/default/packages/disposabl-kit/client/components/ui/command.tsx +0 -194
  51. package/dist/templates/default/packages/disposabl-kit/client/components/ui/context-menu.tsx +0 -271
  52. package/dist/templates/default/packages/disposabl-kit/client/components/ui/dialog.tsx +0 -156
  53. package/dist/templates/default/packages/disposabl-kit/client/components/ui/direction.tsx +0 -4
  54. package/dist/templates/default/packages/disposabl-kit/client/components/ui/drawer.tsx +0 -224
  55. package/dist/templates/default/packages/disposabl-kit/client/components/ui/dropdown-menu.tsx +0 -269
  56. package/dist/templates/default/packages/disposabl-kit/client/components/ui/empty.tsx +0 -103
  57. package/dist/templates/default/packages/disposabl-kit/client/components/ui/hover-card.tsx +0 -50
  58. package/dist/templates/default/packages/disposabl-kit/client/components/ui/input-group.tsx +0 -158
  59. package/dist/templates/default/packages/disposabl-kit/client/components/ui/input-otp.tsx +0 -83
  60. package/dist/templates/default/packages/disposabl-kit/client/components/ui/item.tsx +0 -201
  61. package/dist/templates/default/packages/disposabl-kit/client/components/ui/kbd.tsx +0 -26
  62. package/dist/templates/default/packages/disposabl-kit/client/components/ui/marker.tsx +0 -70
  63. package/dist/templates/default/packages/disposabl-kit/client/components/ui/menubar.tsx +0 -284
  64. package/dist/templates/default/packages/disposabl-kit/client/components/ui/message-scroller.tsx +0 -128
  65. package/dist/templates/default/packages/disposabl-kit/client/components/ui/message.tsx +0 -91
  66. package/dist/templates/default/packages/disposabl-kit/client/components/ui/native-select.tsx +0 -64
  67. package/dist/templates/default/packages/disposabl-kit/client/components/ui/navigation-menu.tsx +0 -170
  68. package/dist/templates/default/packages/disposabl-kit/client/components/ui/pagination.tsx +0 -133
  69. package/dist/templates/default/packages/disposabl-kit/client/components/ui/popover.tsx +0 -87
  70. package/dist/templates/default/packages/disposabl-kit/client/components/ui/progress.tsx +0 -82
  71. package/dist/templates/default/packages/disposabl-kit/client/components/ui/questionnaire.tsx +0 -330
  72. package/dist/templates/default/packages/disposabl-kit/client/components/ui/radio-group.tsx +0 -35
  73. package/dist/templates/default/packages/disposabl-kit/client/components/ui/resizable.tsx +0 -49
  74. package/dist/templates/default/packages/disposabl-kit/client/components/ui/scroll-area.tsx +0 -51
  75. package/dist/templates/default/packages/disposabl-kit/client/components/ui/select.tsx +0 -201
  76. package/dist/templates/default/packages/disposabl-kit/client/components/ui/sheet.tsx +0 -132
  77. package/dist/templates/default/packages/disposabl-kit/client/components/ui/sidebar.tsx +0 -723
  78. package/dist/templates/default/packages/disposabl-kit/client/components/ui/skeleton.tsx +0 -13
  79. package/dist/templates/default/packages/disposabl-kit/client/components/ui/slider.tsx +0 -51
  80. package/dist/templates/default/packages/disposabl-kit/client/components/ui/switch.tsx +0 -31
  81. package/dist/templates/default/packages/disposabl-kit/client/components/ui/table.tsx +0 -113
  82. package/dist/templates/default/packages/disposabl-kit/client/components/ui/tabs.tsx +0 -81
  83. package/dist/templates/default/packages/disposabl-kit/client/components/ui/textarea.tsx +0 -17
  84. package/dist/templates/default/packages/disposabl-kit/client/components/ui/toast.tsx +0 -229
  85. package/dist/templates/default/packages/disposabl-kit/client/components/ui/toggle-group.tsx +0 -87
  86. package/dist/templates/default/packages/disposabl-kit/client/components/ui/toggle.tsx +0 -42
  87. package/dist/templates/default/packages/disposabl-kit/client/components/ui/tooltip.tsx +0 -65
  88. package/dist/templates/default/packages/disposabl-kit/client/components/ui/trace.tsx +0 -161
  89. package/dist/templates/default/packages/disposabl-kit/client/hooks/use-mobile.ts +0 -21
  90. package/dist/templates/default/patches/@convex-dev%2Fauth@2.0.0-beta.0.patch +0 -310
@@ -27,7 +27,7 @@
27
27
  "packages/*"
28
28
  ],
29
29
  "catalog": {
30
- "@convex-dev/auth": "2.0.0-beta.0",
30
+ "@convex-dev/auth": "file:vendor/convex-auth-6c0ebf3f.tgz",
31
31
  "convex": "^1.49.0",
32
32
  "lucide-react": "^1.61.0",
33
33
  "react": "^19.3.1",
@@ -36,7 +36,6 @@
36
36
  "@convex-dev/static-hosting": "0.2.1"
37
37
  },
38
38
  "patchedDependencies": {
39
- "@convex-dev/auth@2.0.0-beta.0": "patches/@convex-dev%2Fauth@2.0.0-beta.0.patch",
40
39
  "@convex-dev/static-hosting@0.2.1": "patches/@convex-dev%2Fstatic-hosting@0.2.1.patch"
41
40
  }
42
41
  }
@@ -1,6 +1,8 @@
1
1
  # Backend
2
2
 
3
- Fresh apps start with only a `users` table. Authentication, API/MCP access, and static hosting use the shared kit and Convex components. Add your app's tables to `convex/schema.ts` and its operations in feature folders.
3
+ Fresh apps start with a `users` table and organization/member records for optional Claude auto-connect. Authentication, API/MCP access, and static hosting use the shared kit and Convex components. Add your app's tables to `convex/schema.ts` and its operations in feature folders.
4
+
5
+ See `convex/mcpEnterprise/README.md` for Claude organization setup and `../../vendor/README.md` for the pinned Convex Auth source.
4
6
 
5
7
  Run `bun run dev` at the workspace root. Run `bun run generate` after changing operations to regenerate the API/MCP contract and selected SDK.
6
8
 
@@ -11,6 +11,9 @@
11
11
  import type * as auth from "../auth.js";
12
12
  import type * as http from "../http.js";
13
13
  import type * as mcp from "../mcp.js";
14
+ import type * as mcpEnterprise_internal from "../mcpEnterprise/internal.js";
15
+ import type * as mcpEnterprise_provision from "../mcpEnterprise/provision.js";
16
+ import type * as mcpEnterprise_validator from "../mcpEnterprise/validator.js";
14
17
  import type * as users_index from "../users/index.js";
15
18
  import type * as users_internal from "../users/internal.js";
16
19
 
@@ -24,6 +27,9 @@ declare const fullApi: ApiFromModules<{
24
27
  auth: typeof auth;
25
28
  http: typeof http;
26
29
  mcp: typeof mcp;
30
+ "mcpEnterprise/internal": typeof mcpEnterprise_internal;
31
+ "mcpEnterprise/provision": typeof mcpEnterprise_provision;
32
+ "mcpEnterprise/validator": typeof mcpEnterprise_validator;
27
33
  "users/index": typeof users_index;
28
34
  "users/internal": typeof users_internal;
29
35
  }>;
@@ -30,8 +30,6 @@ import type { DataModel } from "./dataModel.js";
30
30
  type Env = {
31
31
  readonly CONVEX_CLOUD_URL: string;
32
32
  readonly CONVEX_SITE_URL: string;
33
- readonly AUTH_JWKS: string;
34
- readonly AUTH_PRIVATE_KEY: string;
35
33
  };
36
34
 
37
35
  /**
@@ -1,14 +1,6 @@
1
1
  import type { AuthConfig } from "convex/server";
2
- import { env } from "./_generated/server";
2
+ import { convexAuthProvider } from "@convex-dev/auth/server";
3
3
 
4
4
  export default {
5
- providers: [
6
- {
7
- type: "customJwt",
8
- applicationID: "convex",
9
- issuer: env.CONVEX_SITE_URL,
10
- jwks: `${env.CONVEX_SITE_URL}/auth/.well-known/jwks.json`,
11
- algorithm: "RS256",
12
- },
13
- ],
5
+ providers: [convexAuthProvider()],
14
6
  } satisfies AuthConfig;
@@ -4,22 +4,11 @@ import auth from "@convex-dev/auth/convex.config.js";
4
4
  import mcp from "@convex-dev/mcp/convex.config.js";
5
5
  import staticHosting from "@convex-dev/static-hosting/convex.config";
6
6
  import { defineApp } from "convex/server";
7
- import { v } from "convex/values";
8
7
 
9
- const app = defineApp({
10
- env: {
11
- AUTH_PRIVATE_KEY: v.string(),
12
- AUTH_JWKS: v.string(),
13
- },
14
- });
8
+ const app = defineApp();
9
+
10
+ app.use(auth);
15
11
 
16
- app.use(auth, {
17
- httpPrefix: "/auth",
18
- env: {
19
- AUTH_PRIVATE_KEY: app.env.AUTH_PRIVATE_KEY,
20
- AUTH_JWKS: app.env.AUTH_JWKS,
21
- },
22
- });
23
12
  app.use(passwordProvider);
24
13
  app.use(username);
25
14
  app.use(staticHosting);
@@ -0,0 +1,42 @@
1
+ # Claude auto-connect
2
+
3
+ When MCP is enabled, the shared server supports Claude-issued enterprise-managed authorization. Generated apps include it. Each customer organization has its own trusted Claude issuer and member mappings. No organization is trusted by default.
4
+
5
+ **Status:** organization provisioning is administrator-only. Customer-facing enrollment is not included, and a successful exchange with a real Claude Team/Enterprise organization still needs verification. Disposabl currently uses username/password sign-in, so it has no verified email or organization membership source to connect automatically. Do not announce auto-connect as available until those are wired and Claude's connection test passes.
6
+
7
+ ## Set up an organization
8
+
9
+ These internal operations are available to deployment administrators. They are absent from public APIs and MCP tools. A customer-facing setup screen must first check the signed-in user's administrator role in the selected organization. A personal Disposabl account does not authorize managing other users.
10
+
11
+ 1. In Claude, open Organization settings → Connectors → your connector → Managed authorization. Choose Claude-issued and copy the organization's issuer URL.
12
+ 2. Call `mcpEnterprise/provision:configure` with your app's stable `tenantId`, that exact `issuer`, `enabled: true`, and allowed `scopes`. The starter has no named tool scopes, so use `[]`.
13
+ 3. For each existing member, call `mcpEnterprise/provision:addMember` with the returned `organizationId`, their existing app `userId`, and `verifiedEmail`. Obtain the email and membership from a verified sign-in or directory integration. Never copy an email from a client form into this function.
14
+ 4. In Claude, leave Tenant ID empty. The issuer identifies the organization. Run Test connection, then enable the connector for the desired roles.
15
+ 5. Confirm a real tool request as two members and as a member of another organization before rolling out.
16
+
17
+ An unknown email does not create an account. The first successful grant binds the Claude subject to an existing member. Later grants use that stable subject; a different subject cannot reuse the email to take over the membership.
18
+
19
+ ## Google sign-in
20
+
21
+ Convex Auth's Google method returns `profile.email` and `profile.emailVerified` from Google's validated ID token. Only use the email when `emailVerified === true`.
22
+
23
+ Google proves the app account's email. Your app's organization model decides whether that account is a member. Claude proves the member is signed into the configured Claude organization. All three checks are needed.
24
+
25
+ Wire membership provisioning from a trusted Google `createUser` or `onSignIn` callback after resolving app membership. Account creation alone must not enroll someone in every organization with a matching domain. Existing username accounts need a verified account-linking flow; do not silently merge them by username or an unverified email.
26
+
27
+ ## Disable access
28
+
29
+ - `configure` with `enabled: false` immediately invalidates the organization's tokens. Every configuration update also invalidates prior tokens.
30
+ - `removeMember` immediately invalidates that member's tokens. Re-adding a member creates a new binding, so old tokens stay invalid.
31
+ - Removing a user from Claude prevents new assertions. Issued tokens last at most five minutes. Remove the app membership too when someone leaves.
32
+ - OAuth token revocation is supported. Managed access has no refresh token.
33
+
34
+ ## Protocol and isolation
35
+
36
+ Discovery advertises the JWT bearer grant and ID-JAG profile. The server accepts Claude's published public client `https://claude.ai/oauth/mcp-oauth-client-metadata`. It validates the signature, issuer, JWT type, algorithm, audience, client ID, expiry, and optional resource and tenant claims. Unsupported authorization details are rejected.
37
+
38
+ Discovery and key fetches stay on `https://identity.anthropic.com`, reject redirects, and limit response size. Unknown issuers are rejected before any network request. Assertions are single-use. Tokens are stored as hashes and only work at this app's MCP endpoint. Every request checks membership and organization state. Browser OAuth, device flow, and API keys remain available. API-only apps use the original authorization server.
39
+
40
+ The adapter wraps the pinned MCP package's routes using Convex's HTTP action invocation method. Recheck that boundary when upgrading either package. No code is patched in `node_modules`.
41
+
42
+ References: [Claude setup](https://support.claude.com/en/articles/15537633-auto-connect-your-organization-s-apps-to-claude), [MCP enterprise-managed authorization](https://modelcontextprotocol.io/extensions/auth/enterprise-managed-authorization).
@@ -0,0 +1,153 @@
1
+ import { v } from "convex/values";
2
+ import {
3
+ internalMutation,
4
+ internalQuery,
5
+ } from "@disposabl/disposabl-kit/server/lib/functions";
6
+ import {
7
+ normalizeEmail,
8
+ CLAUDE_CLIENT_ID,
9
+ } from "@disposabl/disposabl-kit/server/mcp/identity";
10
+ import { internal } from "../_generated/api";
11
+ import { exchangeArgs, organizationFields } from "./validator";
12
+
13
+ export const organization = internalQuery({
14
+ args: { issuer: v.string() },
15
+ returns: v.union(v.null(), v.object(organizationFields)),
16
+ handler: async (ctx, { issuer }) => {
17
+ const org = await ctx.db
18
+ .query("mcpOrganizations")
19
+ .withIndex("by_issuer", (q) => q.eq("issuer", issuer))
20
+ .unique();
21
+ if (!org?.enabled) return null;
22
+ return {
23
+ tenantId: org.tenantId,
24
+ issuer: org.issuer,
25
+ enabled: org.enabled,
26
+ scopes: org.scopes,
27
+ revision: org.revision,
28
+ };
29
+ },
30
+ });
31
+
32
+ // One transaction binds the subject, consumes the assertion, and issues a token.
33
+ export const exchange = internalMutation({
34
+ args: exchangeArgs,
35
+ returns: v.union(v.null(), v.object({ expiresIn: v.number() })),
36
+ handler: async (ctx, args) => {
37
+ const org = await ctx.db
38
+ .query("mcpOrganizations")
39
+ .withIndex("by_issuer", (q) => q.eq("issuer", args.issuer))
40
+ .unique();
41
+ if (
42
+ !org?.enabled ||
43
+ org.revision !== args.revision ||
44
+ args.assertionExpiresAt <= Date.now() ||
45
+ args.scopes.some((s) => !org.scopes.includes(s))
46
+ )
47
+ return null;
48
+ const replay = await ctx.db
49
+ .query("mcpEnterpriseTokens")
50
+ .withIndex("by_organizationId_jti", (q) =>
51
+ q.eq("organizationId", org._id).eq("jti", args.jti),
52
+ )
53
+ .unique();
54
+ if (replay) return null;
55
+ let member = await ctx.db
56
+ .query("mcpMembers")
57
+ .withIndex("by_organizationId_subject", (q) =>
58
+ q.eq("organizationId", org._id).eq("subject", args.subject),
59
+ )
60
+ .unique();
61
+ if (!member && args.email) {
62
+ member = await ctx.db
63
+ .query("mcpMembers")
64
+ .withIndex("by_organizationId_verifiedEmail", (q) =>
65
+ q
66
+ .eq("organizationId", org._id)
67
+ .eq("verifiedEmail", normalizeEmail(args.email!)),
68
+ )
69
+ .unique();
70
+ if (member?.subject) return null;
71
+ }
72
+ if (!member || !(await ctx.db.get("users", member.userId))) return null;
73
+ if (!member.subject)
74
+ await ctx.db.patch("mcpMembers", member._id, { subject: args.subject });
75
+ const expiresAt = Date.now() + 300_000;
76
+ const tokenId = await ctx.db.insert("mcpEnterpriseTokens", {
77
+ organizationId: org._id,
78
+ memberId: member._id,
79
+ revision: org.revision,
80
+ hash: args.hash,
81
+ jti: args.jti,
82
+ expiresAt,
83
+ scopes: args.scopes,
84
+ revoked: false,
85
+ });
86
+ // Retain consumed jti until both the assertion and token expire.
87
+ await ctx.scheduler.runAt(
88
+ Math.max(expiresAt, args.assertionExpiresAt) + 30_000,
89
+ internal.mcpEnterprise.internal.expire,
90
+ { tokenId },
91
+ );
92
+ return { expiresIn: 300 };
93
+ },
94
+ });
95
+
96
+ export const verify = internalQuery({
97
+ args: { hash: v.string(), now: v.number() },
98
+ returns: v.union(
99
+ v.null(),
100
+ v.object({
101
+ userId: v.string(),
102
+ scopes: v.array(v.string()),
103
+ clientId: v.string(),
104
+ connectionId: v.string(),
105
+ }),
106
+ ),
107
+ handler: async (ctx, { hash, now }) => {
108
+ const token = await ctx.db
109
+ .query("mcpEnterpriseTokens")
110
+ .withIndex("by_hash", (q) => q.eq("hash", hash))
111
+ .unique();
112
+ if (!token || token.revoked || token.expiresAt <= now) return null;
113
+ const org = await ctx.db.get("mcpOrganizations", token.organizationId);
114
+ const member = await ctx.db.get("mcpMembers", token.memberId);
115
+ if (
116
+ !org?.enabled ||
117
+ org.revision !== token.revision ||
118
+ !member ||
119
+ member.organizationId !== org._id ||
120
+ !(await ctx.db.get("users", member.userId))
121
+ )
122
+ return null;
123
+ return {
124
+ userId: member.userId,
125
+ scopes: token.scopes,
126
+ clientId: CLAUDE_CLIENT_ID,
127
+ connectionId: token._id,
128
+ };
129
+ },
130
+ });
131
+
132
+ export const revoke = internalMutation({
133
+ args: { hash: v.string() },
134
+ returns: v.null(),
135
+ handler: async (ctx, { hash }) => {
136
+ const token = await ctx.db
137
+ .query("mcpEnterpriseTokens")
138
+ .withIndex("by_hash", (q) => q.eq("hash", hash))
139
+ .unique();
140
+ if (token)
141
+ await ctx.db.patch("mcpEnterpriseTokens", token._id, { revoked: true });
142
+ return null;
143
+ },
144
+ });
145
+
146
+ export const expire = internalMutation({
147
+ args: { tokenId: v.id("mcpEnterpriseTokens") },
148
+ returns: v.null(),
149
+ handler: async (ctx, { tokenId }) => {
150
+ await ctx.db.delete("mcpEnterpriseTokens", tokenId);
151
+ return null;
152
+ },
153
+ });
@@ -0,0 +1,102 @@
1
+ import { v } from "convex/values";
2
+ import { internalMutation } from "@disposabl/disposabl-kit/server/lib/functions";
3
+ import {
4
+ claudeIssuer,
5
+ normalizeEmail,
6
+ } from "@disposabl/disposabl-kit/server/mcp/identity";
7
+
8
+ // Internal only. Call from a tenant-admin entrypoint after checking its role,
9
+ // or use the Convex dashboard/CLI as a deployment administrator.
10
+ export const configure = internalMutation({
11
+ args: {
12
+ tenantId: v.string(),
13
+ issuer: v.string(),
14
+ enabled: v.boolean(),
15
+ scopes: v.array(v.string()),
16
+ },
17
+ returns: v.id("mcpOrganizations"),
18
+ handler: async (ctx, args) => {
19
+ claudeIssuer(args.issuer);
20
+ if (
21
+ !args.tenantId.trim() ||
22
+ args.tenantId.length > 200 ||
23
+ args.scopes.length > 100
24
+ )
25
+ throw new Error("Invalid organization configuration.");
26
+ const existing = await ctx.db
27
+ .query("mcpOrganizations")
28
+ .withIndex("by_tenantId", (q) => q.eq("tenantId", args.tenantId))
29
+ .unique();
30
+ const claimed = await ctx.db
31
+ .query("mcpOrganizations")
32
+ .withIndex("by_issuer", (q) => q.eq("issuer", args.issuer))
33
+ .unique();
34
+ if (claimed && claimed._id !== existing?._id)
35
+ throw new Error("Issuer already belongs to another organization.");
36
+ // Issuer replacement needs new member bindings; never silently reuse subjects.
37
+ if (existing && existing.issuer !== args.issuer)
38
+ throw new Error(
39
+ "Disable the old organization and provision a new tenant ID for a new issuer.",
40
+ );
41
+ if (existing) {
42
+ await ctx.db.patch("mcpOrganizations", existing._id, {
43
+ ...args,
44
+ revision: existing.revision + 1,
45
+ });
46
+ return existing._id;
47
+ }
48
+ return ctx.db.insert("mcpOrganizations", { ...args, revision: 1 });
49
+ },
50
+ });
51
+
52
+ // The email must come from a verified authentication callback or a verified
53
+ // directory membership. Never expose this operation with client-supplied email.
54
+ export const addMember = internalMutation({
55
+ args: {
56
+ organizationId: v.id("mcpOrganizations"),
57
+ userId: v.id("users"),
58
+ verifiedEmail: v.string(),
59
+ },
60
+ returns: v.id("mcpMembers"),
61
+ handler: async (ctx, args) => {
62
+ if (
63
+ !(await ctx.db.get("mcpOrganizations", args.organizationId)) ||
64
+ !(await ctx.db.get("users", args.userId))
65
+ )
66
+ throw new Error("Organization and existing user are required.");
67
+ const verifiedEmail = normalizeEmail(args.verifiedEmail);
68
+ const member = await ctx.db
69
+ .query("mcpMembers")
70
+ .withIndex("by_organizationId_userId", (q) =>
71
+ q.eq("organizationId", args.organizationId).eq("userId", args.userId),
72
+ )
73
+ .unique();
74
+ const other = await ctx.db
75
+ .query("mcpMembers")
76
+ .withIndex("by_organizationId_verifiedEmail", (q) =>
77
+ q
78
+ .eq("organizationId", args.organizationId)
79
+ .eq("verifiedEmail", verifiedEmail),
80
+ )
81
+ .unique();
82
+ if (other && other.userId !== args.userId)
83
+ throw new Error("Email already belongs to another member.");
84
+ if (member) {
85
+ if (member.verifiedEmail !== verifiedEmail)
86
+ throw new Error(
87
+ "Remove the old membership before changing its verified email.",
88
+ );
89
+ return member._id;
90
+ }
91
+ return ctx.db.insert("mcpMembers", { ...args, verifiedEmail });
92
+ },
93
+ });
94
+
95
+ export const removeMember = internalMutation({
96
+ args: { memberId: v.id("mcpMembers") },
97
+ returns: v.null(),
98
+ handler: async (ctx, { memberId }) => {
99
+ await ctx.db.delete("mcpMembers", memberId);
100
+ return null;
101
+ },
102
+ });
@@ -0,0 +1,35 @@
1
+ import { v } from "convex/values";
2
+
3
+ export const organizationFields = {
4
+ tenantId: v.string(),
5
+ issuer: v.string(),
6
+ enabled: v.boolean(),
7
+ scopes: v.array(v.string()),
8
+ revision: v.number(),
9
+ };
10
+ export const memberFields = {
11
+ organizationId: v.id("mcpOrganizations"),
12
+ userId: v.id("users"),
13
+ verifiedEmail: v.string(),
14
+ subject: v.optional(v.string()),
15
+ };
16
+ export const tokenFields = {
17
+ organizationId: v.id("mcpOrganizations"),
18
+ memberId: v.id("mcpMembers"),
19
+ revision: v.number(),
20
+ hash: v.string(),
21
+ jti: v.string(),
22
+ expiresAt: v.number(),
23
+ scopes: v.array(v.string()),
24
+ revoked: v.boolean(),
25
+ };
26
+ export const exchangeArgs = {
27
+ issuer: v.string(),
28
+ revision: v.number(),
29
+ subject: v.string(),
30
+ email: v.optional(v.string()),
31
+ jti: v.string(),
32
+ assertionExpiresAt: v.number(),
33
+ scopes: v.array(v.string()),
34
+ hash: v.string(),
35
+ };
@@ -1,5 +1,23 @@
1
+ import {
2
+ organizationFields,
3
+ memberFields,
4
+ tokenFields,
5
+ } from "./mcpEnterprise/validator";
1
6
  import { defineSchema, defineTable } from "convex/server";
2
7
 
3
8
  export default defineSchema({
9
+ mcpOrganizations: defineTable(organizationFields)
10
+ .index("by_tenantId", ["tenantId"])
11
+ .index("by_issuer", ["issuer"]),
12
+ mcpMembers: defineTable(memberFields)
13
+ .index("by_organizationId_userId", ["organizationId", "userId"])
14
+ .index("by_organizationId_verifiedEmail", [
15
+ "organizationId",
16
+ "verifiedEmail",
17
+ ])
18
+ .index("by_organizationId_subject", ["organizationId", "subject"]),
19
+ mcpEnterpriseTokens: defineTable(tokenFields)
20
+ .index("by_hash", ["hash"])
21
+ .index("by_organizationId_jti", ["organizationId", "jti"]),
4
22
  users: defineTable({}),
5
23
  });
@@ -5,7 +5,6 @@
5
5
  "scripts": {
6
6
  "generate": "bun generate.ts",
7
7
  "generate:watch": "bun generate.ts --watch",
8
- "predev": "bun x --no-install --package @convex-dev/auth auth --keys-only",
9
8
  "dev": "convex dev",
10
9
  "logs": "convex logs",
11
10
  "typecheck": "tsc -p convex",
@@ -1,29 +1,14 @@
1
- # Disposabl CLI
1
+ # App CLI
2
2
 
3
- The CLI connects to `https://www.disposabl.dev`.
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
- disposabl login status
7
- disposabl login
8
- disposabl apps create --name my-app --platforms '["web","android","api","mcp","cli","typescript-sdk"]'
9
- disposabl apps list --paginationOpts '{"numItems":20,"cursor":null}'
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
- Save the returned app UUID as `appId` in `disposabl.json`. Preview commands read it automatically. Both preview commands detect the current Git branch, or the worktree name when detached. Use `--reference` only to select a different preview. Token creation reuses that preview and issues a fresh development key. `--configure .` writes ignored local environment files without printing the key.
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
- export function LogIn() {
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
- export function SignUp() {
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
- export function ConsentPage() {
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) return;
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({ requestId, approve });
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 setPending(false);
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 (!requestId) {
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
- <div className="space-y-1 text-sm">
88
- <p className="font-medium">Return address</p>
89
- <p className="break-all text-muted-foreground">
90
- {request.redirectUri}
91
- </p>
92
- </div>
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 disabled={pending} onClick={() => decide(true)}>
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 && (