create-disposabl-app 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/README.md +62 -30
  2. package/dist/disposabl.js +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/templates/default/.github/workflows/pipeline.yml +1 -1
  5. package/dist/templates/default/bun.lock +72 -178
  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/disposabl-kit/package.json +4 -2
  19. package/dist/templates/default/packages/disposabl-kit/server/http.ts +19 -12
  20. package/dist/templates/default/packages/disposabl-kit/server/lib/functions.ts +12 -0
  21. package/dist/templates/default/packages/disposabl-kit/server/mcp/enterprise.ts +267 -0
  22. package/dist/templates/default/packages/disposabl-kit/server/mcp/identity.ts +33 -0
  23. package/dist/templates/default/vendor/README.md +30 -0
  24. package/dist/templates/default/vendor/convex-auth-6c0ebf3f.tgz +0 -0
  25. package/package.json +1 -1
  26. package/dist/templates/default/patches/@convex-dev%2Fauth@2.0.0-beta.0.patch +0 -310
@@ -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",
@@ -32,7 +32,8 @@
32
32
  "@convex-dev/auth": "catalog:",
33
33
  "@convex-dev/mcp": "catalog:",
34
34
  "@convex-dev/static-hosting": "catalog:",
35
- "@tanstack/react-router": "latest"
35
+ "@tanstack/react-router": "latest",
36
+ "jose": "^6.2.15"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@tailwindcss/vite": "^4",
@@ -60,7 +61,8 @@
60
61
  "./platforms": "./platforms.ts",
61
62
  "./mobile": "./mobile/index.ts",
62
63
  "./features": "./features.ts",
63
- "./mobile/expo-plugin": "./mobile/expo-plugin.cjs"
64
+ "./mobile/expo-plugin": "./mobile/expo-plugin.cjs",
65
+ "./server/mcp/identity": "./server/mcp/identity.ts"
64
66
  },
65
67
  "peerDependencies": {
66
68
  "expo": "~58.0.19",
@@ -1,5 +1,6 @@
1
- import { getAuthUserId } from "@convex-dev/auth/server";
1
+ import { getSessionUserId } from "./lib/functions";
2
2
  import { McpServer } from "@convex-dev/mcp";
3
+ import { EnterpriseMcpServer } from "./mcp/enterprise";
3
4
  import { httpActionGeneric, httpRouter } from "convex/server";
4
5
  import { components } from "../../backend/convex/_generated/api";
5
6
  import { env } from "../../backend/convex/_generated/server";
@@ -27,16 +28,22 @@ if (
27
28
  export const platformSpec = platforms.spec;
28
29
 
29
30
  const enabled = validatePlatforms(config.platforms);
30
- const mcp = enabled.some((platform) => platform === "mcp" || platform === "api")
31
- ? new McpServer(components.mcp, {
32
- name: "disposabl",
33
- title: "Disposabl",
34
- version: "1.0.0",
35
- siteUrl: env.CONVEX_SITE_URL,
36
- consentUrl: `${env.CONVEX_SITE_URL}/consent`,
37
- scopes: {},
38
- tools: platforms.tools,
39
- })
31
+ const mcp: McpServer | undefined = enabled.some(
32
+ (platform) => platform === "mcp" || platform === "api",
33
+ )
34
+ ? new (enabled.includes("mcp") ? EnterpriseMcpServer : McpServer)(
35
+ components.mcp,
36
+ {
37
+ name: "disposabl",
38
+ title: "Disposabl",
39
+ version: "1.0.0",
40
+ siteUrl: env.CONVEX_SITE_URL,
41
+ consentUrl: `${env.CONVEX_SITE_URL}/consent`,
42
+ scopes: {},
43
+ clientMetadataDocumentHosts: ["claude.ai"],
44
+ tools: platforms.tools,
45
+ },
46
+ )
40
47
  : undefined;
41
48
 
42
49
  // Keep the enabled API types for consumers; disabled exports are absent at runtime.
@@ -47,7 +54,7 @@ export const {
47
54
  revokeConnection,
48
55
  createApiKey,
49
56
  } =
50
- mcp?.api({ getUserId: getAuthUserId }) ??
57
+ mcp?.api({ getUserId: getSessionUserId }) ??
51
58
  ({} as ReturnType<McpServer["api"]>);
52
59
 
53
60
  export default function createHttpRouter() {
@@ -1,3 +1,5 @@
1
+ import { getAuthUserId } from "@convex-dev/auth/server";
2
+ import type { Auth } from "convex/server";
1
3
  import {
2
4
  v,
3
5
  type GenericValidator,
@@ -35,3 +37,13 @@ const withPlatforms = <TDefinition, TResult extends object>(
35
37
  export const internalQuery = withPlatforms(nativeQuery);
36
38
  export const internalMutation = withPlatforms(nativeMutation);
37
39
  export const internalAction = withPlatforms(nativeAction);
40
+
41
+ // The MCP alpha types its callback as auth-only; Convex Auth reboot also
42
+ // checks the live session via runQuery. Actual Convex function contexts have it.
43
+ export async function getSessionUserId(ctx: { auth: Auth }) {
44
+ if (!("runQuery" in ctx) || typeof ctx.runQuery !== "function")
45
+ throw new Error(
46
+ "Session authentication requires a Convex function context.",
47
+ );
48
+ return getAuthUserId(ctx as Parameters<typeof getAuthUserId>[0]);
49
+ }