@vvedantb/server 0.20.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/convex/clerk.d.ts +24 -0
- package/dist/convex/clerk.js +17 -0
- package/dist/convex/index.d.ts +1 -1
- package/dist/convex/index.js +1 -1
- package/dist/mcp/http.d.ts +10 -1
- package/dist/mcp/http.js +30 -11
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/upstreamUser.d.ts +17 -0
- package/dist/mcp/upstreamUser.js +43 -0
- package/docs/convex.md +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`0e8d549`](https://github.com/vvedantb/v/commit/0e8d549701ab15e5b39555e301c594f3bb9ebc9b) Thanks [@vvedantb](https://github.com/vvedantb)! - `createMcpHttpHandler`'s `upstreamUser` hook is now async and gets `{ clerkUserId, request, ctx }`, so an app can look up the principal (for example a stored plan) before it runs. Returning `null` answers 401. Breaking for callers of the 0.21.0 form `upstreamUser: (clerkUserId) => principal`; change it to `upstreamUser: async ({ clerkUserId }) => principal`. Adds `fetchClerkUserProfile(clerk, clerkUserId)`, which returns a Clerk user's primary email and names for creating an app's users row.
|
|
8
|
+
|
|
9
|
+
## 0.21.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`049f81d`](https://github.com/vvedantb/v/commit/049f81d8974651bb44210214b4b82e9710c352d1) Thanks [@vvedantb](https://github.com/vvedantb)! - Add `signUpstreamUser`, `verifyUpstreamUser` and `UPSTREAM_USER_HEADER`, plus an optional `upstreamUser` hook on `createMcpHttpHandler` that trusts a signed first-party user assertion.
|
|
14
|
+
|
|
3
15
|
## 0.20.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/convex/clerk.d.ts
CHANGED
|
@@ -11,3 +11,27 @@ export declare function getClerkClient<T>(createClerkClient: (opts: {
|
|
|
11
11
|
secretKey: string;
|
|
12
12
|
publishableKey: string;
|
|
13
13
|
}) => T, env?: ClerkClientEnv): T;
|
|
14
|
+
export type ClerkUserProfile = {
|
|
15
|
+
email?: string;
|
|
16
|
+
firstName?: string;
|
|
17
|
+
lastName?: string;
|
|
18
|
+
fullName?: string;
|
|
19
|
+
};
|
|
20
|
+
type ClerkUsersApi = {
|
|
21
|
+
users: {
|
|
22
|
+
getUser(userId: string): Promise<{
|
|
23
|
+
primaryEmailAddress: {
|
|
24
|
+
emailAddress: string;
|
|
25
|
+
} | null;
|
|
26
|
+
firstName: string | null;
|
|
27
|
+
lastName: string | null;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A Clerk user's primary email and names, for creating an app's users row
|
|
33
|
+
* when a request has no session identity (an MCP bearer or a signed upstream
|
|
34
|
+
* user). Throws when Clerk does.
|
|
35
|
+
*/
|
|
36
|
+
export declare function fetchClerkUserProfile(clerk: ClerkUsersApi, clerkUserId: string): Promise<ClerkUserProfile>;
|
|
37
|
+
export {};
|
package/dist/convex/clerk.js
CHANGED
|
@@ -15,3 +15,20 @@ export function getClerkClient(createClerkClient, env = process.env) {
|
|
|
15
15
|
}
|
|
16
16
|
return createClerkClient({ secretKey, publishableKey });
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* A Clerk user's primary email and names, for creating an app's users row
|
|
20
|
+
* when a request has no session identity (an MCP bearer or a signed upstream
|
|
21
|
+
* user). Throws when Clerk does.
|
|
22
|
+
*/
|
|
23
|
+
export async function fetchClerkUserProfile(clerk, clerkUserId) {
|
|
24
|
+
const user = await clerk.users.getUser(clerkUserId);
|
|
25
|
+
const firstName = user.firstName ?? undefined;
|
|
26
|
+
const lastName = user.lastName ?? undefined;
|
|
27
|
+
const fullName = [firstName, lastName].filter(Boolean).join(" ");
|
|
28
|
+
return {
|
|
29
|
+
email: user.primaryEmailAddress?.emailAddress,
|
|
30
|
+
firstName,
|
|
31
|
+
lastName,
|
|
32
|
+
fullName: fullName.length > 0 ? fullName : undefined,
|
|
33
|
+
};
|
|
34
|
+
}
|
package/dist/convex/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { clerkAuthConfig, type ClerkAuthConfigEnv } from "./authConfig.js";
|
|
2
2
|
export { createAuthFunctions, type AuthCustomFunctions, type AuthFunctions, type AuthReadCtx, type CreateAuthFunctionsConfig, } from "./authFunctions.js";
|
|
3
3
|
export { extractBearerToken } from "./bearerToken.js";
|
|
4
|
-
export { getClerkClient, type ClerkClientEnv } from "./clerk.js";
|
|
4
|
+
export { fetchClerkUserProfile, getClerkClient, type ClerkClientEnv, type ClerkUserProfile, } from "./clerk.js";
|
|
5
5
|
export { activePlanSlugs, applyBillingChange, applyItemToPlanSlugs, GRANTING_ITEM_STATUSES, GRANTING_STATUSES_ACTIVE_ONLY, GRANTING_STATUSES_ACTIVE_PAST_DUE, itemGrantsPlan, parseClerkBillingEvent, type ClerkBillingChange, type ClerkBillingOptions, type ClerkWebhookEventLike, type PlanItem, } from "./clerkBilling.js";
|
|
6
6
|
export { CLERK_BILLING_PAGE_SIZE, CLERK_BILLING_USERS_TABLE, createClerkBillingFunctions, runClerkBillingWebhook, type ClerkBillingApplyChangeRef, type ClerkBillingFunctionsConfig, type ClerkBillingListArgs, type ClerkBillingListRef, type ClerkBillingListResult, type ClerkBillingListStyle, type ClerkBillingQueryCtx, type ClerkBillingSetPlanSlugsRef, type RunClerkBillingWebhookOptions, } from "./clerkBillingFunctions.js";
|
|
7
7
|
export { createClerkBillingNodeFunctions, createClerkBillingWebhookNodeAction, type ClerkBillingBackfillArgs, type ClerkBillingBackfillCtx, type ClerkBillingBackfillResult, type ClerkBillingBackfillReturnStyle, type ClerkBillingBackfillSelfRef, type ClerkBillingClerkLike, type ClerkBillingNodeFunctionsConfig, type ClerkBillingWebhookNodeActionConfig, } from "./clerkBillingNodeFunctions.js";
|
package/dist/convex/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { clerkAuthConfig } from "./authConfig.js";
|
|
2
2
|
export { createAuthFunctions, } from "./authFunctions.js";
|
|
3
3
|
export { extractBearerToken } from "./bearerToken.js";
|
|
4
|
-
export { getClerkClient } from "./clerk.js";
|
|
4
|
+
export { fetchClerkUserProfile, getClerkClient, } from "./clerk.js";
|
|
5
5
|
export { activePlanSlugs, applyBillingChange, applyItemToPlanSlugs, GRANTING_ITEM_STATUSES, GRANTING_STATUSES_ACTIVE_ONLY, GRANTING_STATUSES_ACTIVE_PAST_DUE, itemGrantsPlan, parseClerkBillingEvent, } from "./clerkBilling.js";
|
|
6
6
|
export { CLERK_BILLING_PAGE_SIZE, CLERK_BILLING_USERS_TABLE, createClerkBillingFunctions, runClerkBillingWebhook, } from "./clerkBillingFunctions.js";
|
|
7
7
|
export { createClerkBillingNodeFunctions, createClerkBillingWebhookNodeAction, } from "./clerkBillingNodeFunctions.js";
|
package/dist/mcp/http.d.ts
CHANGED
|
@@ -61,10 +61,19 @@ export type McpHttpHandlerConfig<Principal, Ctx, Scope extends string = string>
|
|
|
61
61
|
log?: McpHttpLogger | false;
|
|
62
62
|
onAuthenticateError?: "throw" | "unauthorized";
|
|
63
63
|
requireUpstreamSecret?: boolean;
|
|
64
|
+
upstreamUser?: (args: UpstreamUserArgs<Ctx>) => Promise<Principal | null>;
|
|
65
|
+
};
|
|
66
|
+
export type UpstreamUserArgs<Ctx> = {
|
|
67
|
+
clerkUserId: string;
|
|
68
|
+
request: Request;
|
|
69
|
+
ctx: Ctx;
|
|
64
70
|
};
|
|
65
71
|
/**
|
|
66
72
|
* Build the `/mcp` handler: bearer check, `authenticate`, method check,
|
|
67
|
-
* body parsing, then `handleRpc`.
|
|
73
|
+
* body parsing, then `handleRpc`. With `upstreamUser`, a request that carries
|
|
74
|
+
* the upstream secret and a valid signed `X-Mcp-Upstream-User` header skips
|
|
75
|
+
* the bearer check and uses `upstreamUser({ clerkUserId, request, ctx })` as
|
|
76
|
+
* the principal; `null` returns 401.
|
|
68
77
|
*
|
|
69
78
|
* ```ts
|
|
70
79
|
* export const mcpHandler = httpAction(
|
package/dist/mcp/http.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { extractBearerToken } from "../convex/index.js";
|
|
2
2
|
import { timingSafeEqual } from "../crypto/timingSafeEqual.js";
|
|
3
3
|
import { resolveCors } from "./cors.js";
|
|
4
|
+
import { UPSTREAM_USER_HEADER, verifyUpstreamUser } from "./upstreamUser.js";
|
|
4
5
|
/** Default `WWW-Authenticate` resource metadata path. */
|
|
5
6
|
export const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource";
|
|
6
7
|
export const UPSTREAM_SECRET_HEADER = "X-Mcp-Upstream";
|
|
@@ -19,6 +20,15 @@ function hasUpstreamSecret(request) {
|
|
|
19
20
|
const received = request.headers.get(UPSTREAM_SECRET_HEADER);
|
|
20
21
|
return received !== null && timingSafeEqual(received, expected);
|
|
21
22
|
}
|
|
23
|
+
async function upstreamUserId(request) {
|
|
24
|
+
const secret = process.env[UPSTREAM_SECRET_ENV];
|
|
25
|
+
if (!secret)
|
|
26
|
+
return null;
|
|
27
|
+
const received = request.headers.get(UPSTREAM_SECRET_HEADER);
|
|
28
|
+
if (received === null || !timingSafeEqual(received, secret))
|
|
29
|
+
return null;
|
|
30
|
+
return verifyUpstreamUser(request.headers.get(UPSTREAM_USER_HEADER), { secret });
|
|
31
|
+
}
|
|
22
32
|
/**
|
|
23
33
|
* Logs with the app-a strings: "[MCP][mcpHandler] token verification failed"
|
|
24
34
|
* and "[MCP][mcpHandler] failed to parse JSON body:". app-c logs only the
|
|
@@ -40,7 +50,10 @@ export const consoleMcpLogger = (event) => {
|
|
|
40
50
|
};
|
|
41
51
|
/**
|
|
42
52
|
* Build the `/mcp` handler: bearer check, `authenticate`, method check,
|
|
43
|
-
* body parsing, then `handleRpc`.
|
|
53
|
+
* body parsing, then `handleRpc`. With `upstreamUser`, a request that carries
|
|
54
|
+
* the upstream secret and a valid signed `X-Mcp-Upstream-User` header skips
|
|
55
|
+
* the bearer check and uses `upstreamUser({ clerkUserId, request, ctx })` as
|
|
56
|
+
* the principal; `null` returns 401.
|
|
44
57
|
*
|
|
45
58
|
* ```ts
|
|
46
59
|
* export const mcpHandler = httpAction(
|
|
@@ -85,18 +98,24 @@ export function createMcpHttpHandler(config) {
|
|
|
85
98
|
if (config.requireUpstreamSecret && !hasUpstreamSecret(request)) {
|
|
86
99
|
return json({ error: messages.invalidUpstream }, 401);
|
|
87
100
|
}
|
|
88
|
-
const
|
|
89
|
-
if (!token)
|
|
90
|
-
return unauthorized(messages.missingToken);
|
|
101
|
+
const upstreamClerkUserId = config.upstreamUser ? await upstreamUserId(request) : null;
|
|
91
102
|
let principal;
|
|
92
|
-
|
|
93
|
-
principal = await config.
|
|
103
|
+
if (config.upstreamUser && upstreamClerkUserId !== null) {
|
|
104
|
+
principal = await config.upstreamUser({ clerkUserId: upstreamClerkUserId, request, ctx });
|
|
94
105
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
else {
|
|
107
|
+
const token = extractBearerToken(request.headers.get("Authorization"));
|
|
108
|
+
if (!token)
|
|
109
|
+
return unauthorized(messages.missingToken);
|
|
110
|
+
try {
|
|
111
|
+
principal = await config.authenticate({ token, request, ctx, scope });
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (onAuthenticateError === "throw")
|
|
115
|
+
throw error;
|
|
116
|
+
log?.({ type: "authenticate-threw", error });
|
|
117
|
+
principal = null;
|
|
118
|
+
}
|
|
100
119
|
}
|
|
101
120
|
if (principal === null || principal === undefined) {
|
|
102
121
|
log?.({ type: "auth-failed" });
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ export { mcpCors, type CorsOption, type HeaderMap } from "./cors.js";
|
|
|
2
2
|
export { createMcpDispatcher, parseRpcBody, type McpDispatcher, type McpDispatcherConfig, } from "./dispatcher.js";
|
|
3
3
|
export { readEnvUrl, type EnvFallbackMode, type EnvUrl } from "./env.js";
|
|
4
4
|
export { createExplorerTools, type ExplorerFilters, type ExplorerOperation, type ExplorerToolKey, type ExplorerToolsConfig, type FilterValue, type RunQueryArgs, type TableCatalog, type TableEntry, } from "./explorer.js";
|
|
5
|
-
export { consoleMcpLogger, createMcpHttpHandler, DEFAULT_MCP_HTTP_MESSAGES, PROTECTED_RESOURCE_METADATA_PATH, UPSTREAM_SECRET_HEADER, type AuthenticateArgs, type HandleRpcArgs, type HttpHandler, type McpHttpHandlerConfig, type McpHttpLogEvent, type McpHttpLogger, type McpHttpMessages, } from "./http.js";
|
|
5
|
+
export { consoleMcpLogger, createMcpHttpHandler, DEFAULT_MCP_HTTP_MESSAGES, PROTECTED_RESOURCE_METADATA_PATH, UPSTREAM_SECRET_HEADER, type AuthenticateArgs, type HandleRpcArgs, type HttpHandler, type McpHttpHandlerConfig, type McpHttpLogEvent, type McpHttpLogger, type McpHttpMessages, type UpstreamUserArgs, } from "./http.js";
|
|
6
6
|
export { errorMessage, isJsonObject, type JsonInput, type JsonObject, type JsonValue, type Thrown, } from "./json.js";
|
|
7
7
|
export { JSON_RPC_ERROR, mcpInternalError, negotiateProtocolVersion, rpcError, rpcResult, SDK_PROTOCOL_VERSIONS, type JsonRpcFailure, type JsonRpcId, type JsonRpcSuccess, type ProtocolVersionOptions, type RpcResult, } from "./jsonRpc.js";
|
|
8
8
|
export { createAuthorizationServerMetadataProxy, createHealthHandler, createOptionsHandler, createProtectedResourceMetadata, type AuthorizationServerMetadataProxyOptions, type HealthOptions, type OptionsHandlerOptions, type ProtectedResourceMetadataOptions, } from "./metadata.js";
|
|
9
9
|
export { registerMcpRoutes, type McpEndpointRoutes, type McpRouteMethod, type McpRouter, type McpRouteSpec, type McpRoutesConfig, } from "./routes.js";
|
|
10
10
|
export { runSdkMcpRequest, type RunSdkMcpRequestOptions, type SdkServerLike, type SdkTransportLike, } from "./sdk.js";
|
|
11
11
|
export { assertUniqueToolNames, createToolRegistry, defineTool, formatIssues, invalidArgumentsResult, runTool, toolErrorResult, toolJsonResult, toolsToList, toolTextResult, type JsonSchemaConverter, type JsonSchemaObject, type JsonSchemaToolDefinition, type McpTool, type ToolAnnotations, type ToolContent, type ToolContext, type ToolListEntry, type ToolRegistry, type ToolResult, type ToolsToListOptions, type ZodLikeSchema, type ZodToolDefinition, } from "./tools.js";
|
|
12
|
+
export { signUpstreamUser, UPSTREAM_USER_HEADER, verifyUpstreamUser, type UpstreamUserOptions, } from "./upstreamUser.js";
|
|
12
13
|
export { createZodJsonSchemaConverter, type ZodJsonSchemaOptions } from "./zodJsonSchema.js";
|
package/dist/mcp/index.js
CHANGED
|
@@ -9,4 +9,5 @@ export { createAuthorizationServerMetadataProxy, createHealthHandler, createOpti
|
|
|
9
9
|
export { registerMcpRoutes, } from "./routes.js";
|
|
10
10
|
export { runSdkMcpRequest, } from "./sdk.js";
|
|
11
11
|
export { assertUniqueToolNames, createToolRegistry, defineTool, formatIssues, invalidArgumentsResult, runTool, toolErrorResult, toolJsonResult, toolsToList, toolTextResult, } from "./tools.js";
|
|
12
|
+
export { signUpstreamUser, UPSTREAM_USER_HEADER, verifyUpstreamUser, } from "./upstreamUser.js";
|
|
12
13
|
export { createZodJsonSchemaConverter } from "./zodJsonSchema.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const UPSTREAM_USER_HEADER = "X-Mcp-Upstream-User";
|
|
2
|
+
export type UpstreamUserOptions = {
|
|
3
|
+
secret: string;
|
|
4
|
+
now?: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* The `X-Mcp-Upstream-User` value a first-party gateway sends upstream:
|
|
8
|
+
* `<clerkUserId>.<expiresAtMs>.<hmacHex>`, valid for 5 minutes. Only send it
|
|
9
|
+
* to first-party hosts, next to the raw `X-Mcp-Upstream` secret.
|
|
10
|
+
*/
|
|
11
|
+
export declare function signUpstreamUser(clerkUserId: string, options: UpstreamUserOptions): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* The Clerk user id in a signed `X-Mcp-Upstream-User` value, or `null` when
|
|
14
|
+
* the value is malformed, expired, too far in the future or badly signed, or
|
|
15
|
+
* when `secret` is empty. The signature compare is constant time.
|
|
16
|
+
*/
|
|
17
|
+
export declare function verifyUpstreamUser(value: string | null, options: UpstreamUserOptions): Promise<string | null>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { hmacSha256Hex } from "../crypto/hmac.js";
|
|
2
|
+
import { timingSafeEqual } from "../crypto/timingSafeEqual.js";
|
|
3
|
+
export const UPSTREAM_USER_HEADER = "X-Mcp-Upstream-User";
|
|
4
|
+
const TTL_MS = 5 * 60 * 1000;
|
|
5
|
+
const MAX_FUTURE_MS = 10 * 60 * 1000;
|
|
6
|
+
const VALUE_PATTERN = /^(user_[A-Za-z0-9]+)\.(\d{1,16})\.([0-9a-f]{64})$/;
|
|
7
|
+
const CLERK_USER_ID_PATTERN = /^user_[A-Za-z0-9]+$/;
|
|
8
|
+
function signedMessage(clerkUserId, expiresAtMs) {
|
|
9
|
+
return `mcp-upstream-user:${clerkUserId}:${expiresAtMs}`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The `X-Mcp-Upstream-User` value a first-party gateway sends upstream:
|
|
13
|
+
* `<clerkUserId>.<expiresAtMs>.<hmacHex>`, valid for 5 minutes. Only send it
|
|
14
|
+
* to first-party hosts, next to the raw `X-Mcp-Upstream` secret.
|
|
15
|
+
*/
|
|
16
|
+
export async function signUpstreamUser(clerkUserId, options) {
|
|
17
|
+
if (!options.secret)
|
|
18
|
+
throw new Error("signUpstreamUser needs a secret");
|
|
19
|
+
if (!CLERK_USER_ID_PATTERN.test(clerkUserId))
|
|
20
|
+
throw new Error("signUpstreamUser needs a Clerk user id");
|
|
21
|
+
const expiresAtMs = (options.now ?? Date.now()) + TTL_MS;
|
|
22
|
+
const signature = await hmacSha256Hex(options.secret, signedMessage(clerkUserId, expiresAtMs));
|
|
23
|
+
return `${clerkUserId}.${expiresAtMs}.${signature}`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The Clerk user id in a signed `X-Mcp-Upstream-User` value, or `null` when
|
|
27
|
+
* the value is malformed, expired, too far in the future or badly signed, or
|
|
28
|
+
* when `secret` is empty. The signature compare is constant time.
|
|
29
|
+
*/
|
|
30
|
+
export async function verifyUpstreamUser(value, options) {
|
|
31
|
+
if (!options.secret || value === null)
|
|
32
|
+
return null;
|
|
33
|
+
const match = VALUE_PATTERN.exec(value);
|
|
34
|
+
if (!match)
|
|
35
|
+
return null;
|
|
36
|
+
const [, clerkUserId = "", expiry = "", signature = ""] = match;
|
|
37
|
+
const expiresAtMs = Number(expiry);
|
|
38
|
+
const now = options.now ?? Date.now();
|
|
39
|
+
if (expiresAtMs <= now || expiresAtMs > now + MAX_FUTURE_MS)
|
|
40
|
+
return null;
|
|
41
|
+
const expected = await hmacSha256Hex(options.secret, signedMessage(clerkUserId, expiresAtMs));
|
|
42
|
+
return timingSafeEqual(expected, signature) ? clerkUserId : null;
|
|
43
|
+
}
|
package/docs/convex.md
CHANGED
|
@@ -62,6 +62,7 @@ expectMcpToolCount(toolNames, 2);
|
|
|
62
62
|
| `isConvexResourceLimitError`, `formatConvexQueryError` | Detect Convex read, write and time limit failures and add a remedy to the message. |
|
|
63
63
|
| `clerkAuthConfig(env?)` | `auth.config.ts` provider list. |
|
|
64
64
|
| `getClerkClient(factory, env?)` | Clerk backend client from env, with an injected factory. |
|
|
65
|
+
| `fetchClerkUserProfile(clerk, clerkUserId)` | `{ email, firstName, lastName, fullName }` from `clerk.users.getUser` (primary email). Throws when Clerk does. |
|
|
65
66
|
| `extractBearerToken(header)` | Token from an `Authorization` header, or `null`. |
|
|
66
67
|
| `requiredEnv(name, env?)`, `requiredEnvUrl(name, env?)` | Required env value, optionally stripping a trailing slash. |
|
|
67
68
|
| `mcpCorsHeaders`, `corsPreflight`, `jsonWithCors` | CORS for MCP HTTP handlers. Methods `GET,POST,DELETE,OPTIONS`; headers `Authorization,Content-Type`; credentials `false`. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared Convex backend helpers, MCP server scaffolding and Node-side MCP OAuth client helpers from one root import: query-limit errors, Clerk auth and token verification, an MCP bearer-token cache, Expo push token storage, batched send and receipts, Clerk-user lookups and ensure-user for Convex functions, V Pro plan checks and Clerk Billing webhook helpers, bearer tokens, env, CORS, JSON responses, MCP route registration, a bearer-auth MCP HTTP handler, OAuth metadata, a JSON-RPC dispatcher, explorer tools, WebCrypto primitives, Convex optimistic-update helpers, MCP OAuth client helpers (provider, sign-in, refresh, revocation, loopback redirect server) for desktop apps, a QuickJS code sandbox that bridges script tool calls to host handlers, and a pure artifacts core (Zod contract, state limits and ops, quiz and flashcards pages, a sandboxed document wrapper with CSP and a guest state bridge); and, from the `@vvedantb/server/ai` subpath, Vercel AI Gateway helpers (service tier provider options, cost from provider metadata, error classification).",
|
|
6
6
|
"type": "module",
|