@vvedantb/server 0.4.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,17 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1
4
+
5
+ Docs and comments only; no runtime change.
6
+
7
+ - Shipped docs describe the Convex optimistic-update helpers and the MCP OAuth client helpers by what they do, and name no consuming app.
8
+ - `docs/mcp-client.md` is now `docs/mcp-oauth-client.md`. Internal folders `src/mcp-client` and `tests/mcp-client` are now `mcp-oauth-client`. Export names do not change.
9
+
3
10
  ## 0.4.0
4
11
 
5
- Additive: two packages fold in under the same export names. Nothing in 0.3.0 changes.
12
+ Additive: the Convex optimistic-update helpers and the MCP OAuth client helpers join the root. Nothing in 0.3.0 changes. (Historical: these came from the former `@vvedantb/convex-client` and `@vvedantb/mcp-client` 0.1.0 packages, under the same export names.)
6
13
 
7
14
  ### Added
8
15
 
9
- - From `@vvedantb/convex-client` 0.1.0, its non-React helpers: `mapLoadedQuery` (also `forEachLoadedQuery` and `updateAllCachedQueries`), `patchLoadedQuery`, `OptimisticStore`, `tempId(table?, { format? })`, `TempIdFormat`, `TempIdOptions` and `createMemoryOptimisticStore()`. See `docs/convex.md`. The package still never imports `convex` at runtime: the memory store carries a copy of `getFunctionName`, tested against Convex's.
10
- - From `@vvedantb/mcp-client` 0.1.0, every export: `createMcpOAuthStateSchema`, `hasMcpOAuthTokens`, `isAccessTokenExpiring`, `createMcpOAuthProvider`, `authorizeMcpServer`, `refreshMcpOAuth`, `revokeMcpOAuth`, `startLoopback`, `LOOPBACK_PATH`, `LOOPBACK_TIMEOUT_MS` and their types. See `docs/mcp-client.md`. Node only; nothing Node-only loads when the root is imported: `startLoopback` imports `node:http` when called, the SDK loads on first use, and `state()` uses WebCrypto instead of `node:crypto` (same format).
16
+ - Convex optimistic-update helpers (no React): `mapLoadedQuery` (also `forEachLoadedQuery` and `updateAllCachedQueries`), `patchLoadedQuery`, `OptimisticStore`, `tempId(table?, { format? })`, `TempIdFormat`, `TempIdOptions` and `createMemoryOptimisticStore()`. See `docs/convex.md`. The package still never imports `convex` at runtime: the memory store carries a copy of `getFunctionName`, tested against Convex's.
17
+ - MCP OAuth client helpers: `createMcpOAuthStateSchema`, `hasMcpOAuthTokens`, `isAccessTokenExpiring`, `createMcpOAuthProvider`, `authorizeMcpServer`, `refreshMcpOAuth`, `revokeMcpOAuth`, `startLoopback`, `LOOPBACK_PATH`, `LOOPBACK_TIMEOUT_MS` and their types. See `docs/mcp-oauth-client.md`. Node only; nothing Node-only loads when the root is imported: `startLoopback` imports `node:http` when called, the SDK loads on first use, and `state()` uses WebCrypto instead of `node:crypto` (same format).
11
18
  - New optional peers: `@modelcontextprotocol/sdk` `^1.29.0` (MCP client OAuth calls) and `convex` `^1.24.0` (types only). Neither is imported when the root loads.
12
- - Tests: the convex-client and mcp-client suites are ported. `tests-node/bundle.mjs` bundles a Convex function that imports the root with Convex's own esbuild and options, with and without the SDK installed, and asserts no `node:` import or built-in `require` in any output; it also runs an Electron-style Node bundle with no `node_modules`. `tests-node/esm-exports.mjs` imports the root with no peer installed.
19
+ - Tests: suites for both sets of helpers. `tests-node/bundle.mjs` bundles a Convex function that imports the root with Convex's own esbuild and options, with and without the SDK installed, and asserts no `node:` import or built-in `require` in any output; it also runs an Electron-style Node bundle with no `node_modules`. `tests-node/esm-exports.mjs` imports the root with no peer installed.
13
20
 
14
- ### Changed (from `@vvedantb/mcp-client` 0.1.0)
21
+ ### Changed (from the earlier MCP OAuth client package)
15
22
 
16
23
  - A non-interactive provider's `redirectToAuthorization` returns a promise that rejects with the SDK's `UnauthorizedError`, instead of throwing it synchronously: the class is only reachable once the SDK is loaded. The SDK awaits the call, so its sign-in, refresh and connect flows are unchanged.
17
24
  - Without the SDK installed, `authorizeMcpServer` and `redirectToAuthorization` reject with "The MCP client OAuth helpers need the @modelcontextprotocol/sdk package", and `refreshMcpOAuth` and `revokeMcpOAuth` return `false`. Before, a missing SDK failed the package import.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @vvedantb/server
2
2
 
3
- Server-side helpers for Convex backends, Convex optimistic updates and Node-side MCP client OAuth, from one root import.
3
+ Server-side helpers for Convex backends, Convex optimistic updates and Node-side MCP OAuth client helpers, from one root import.
4
4
 
5
5
  ```sh
6
6
  npm install @vvedantb/server
@@ -17,8 +17,8 @@ There are no subpath exports (0.2.0 removed `/convex` and `/mcp`; see [CHANGELOG
17
17
  | Convex helpers | Query-limit errors, Clerk auth config and client, Clerk token verification, Clerk-user lookups and `ensureUser` (`createClerkUserAuth`), bearer tokens, env, MCP CORS, origin-allowlist CORS, `jsonResponse`, server info, test helpers. | [docs/convex.md](docs/convex.md) |
18
18
  | MCP scaffolding | For Convex `httpAction`s: bearer-auth handler, OAuth metadata, route registration, a pure JSON-RPC dispatcher, tool helpers and explorer tools. | [docs/mcp.md](docs/mcp.md) |
19
19
  | Crypto | WebCrypto-only base64/base64url/hex, SHA-256, random tokens, `timingSafeEqual`, AES-GCM. Convex default runtime and Node 20+. | [docs/crypto.md](docs/crypto.md) |
20
- | Optimistic updates | `mapLoadedQuery` (also `forEachLoadedQuery`, `updateAllCachedQueries`), `patchLoadedQuery`, `tempId`, `createMemoryOptimisticStore`. Client-side, no React. From `@vvedantb/convex-client`. | [docs/convex.md](docs/convex.md#optimistic-updates-client-side) |
21
- | MCP client OAuth | Node only (Electron main): OAuth provider over injected storage, sign-in, refresh, revocation, loopback redirect server. Node built-ins and the MCP SDK load on first use, so Convex V8 bundles of the root stay clean. From `@vvedantb/mcp-client`. | [docs/mcp-client.md](docs/mcp-client.md) |
20
+ | Optimistic updates | `mapLoadedQuery` (also `forEachLoadedQuery`, `updateAllCachedQueries`), `patchLoadedQuery`, `tempId`, `createMemoryOptimisticStore`. Client-side, no React. | [docs/convex.md](docs/convex.md#optimistic-updates-client-side) |
21
+ | MCP OAuth client | Node only (Electron main): OAuth provider over injected storage, sign-in, refresh, revocation, loopback redirect server. Node built-ins and the MCP SDK load on first use, so Convex V8 bundles of the root stay clean. | [docs/mcp-oauth-client.md](docs/mcp-oauth-client.md) |
22
22
 
23
23
  Migration steps per app: [docs/migration.md](docs/migration.md).
24
24
 
@@ -36,19 +36,19 @@ No React, no web dependencies. `"sideEffects": false`. Compiled ESM with types i
36
36
  ## Layout
37
37
 
38
38
  ```
39
- src/index.ts the only export: re-exports the four folders
40
- src/convex/ Convex helpers and optimistic updates
41
- src/mcp/ MCP scaffolding (imports ../convex by relative path)
42
- src/mcp-client/ MCP client OAuth (Node only; lazy node:http and SDK imports)
43
- src/crypto/ WebCrypto primitives
44
- tests/convex/ vitest
45
- tests/mcp/ vitest, with fixtures/ (SDK captures, app references)
46
- tests/mcp-client/ vitest, against fake MCP and authorization servers
47
- tests/crypto/ vitest, with published vectors and app format parity
48
- tests-node/ plain Node checks of the built package: exports map and peers (esm-exports.mjs),
49
- Convex V8 and Electron main bundles with esbuild (bundle.mjs)
50
- docs/ convex.md, mcp.md, mcp-client.md, crypto.md, migration.md, migrated/<app>/
51
- scripts/ capture-sdk-fixtures.mjs
39
+ src/index.ts the only export: re-exports the four folders
40
+ src/convex/ Convex helpers and optimistic updates
41
+ src/mcp/ MCP scaffolding (imports ../convex by relative path)
42
+ src/mcp-oauth-client/ MCP OAuth client helpers (Node only; lazy node:http and SDK imports)
43
+ src/crypto/ WebCrypto primitives
44
+ tests/convex/ vitest
45
+ tests/mcp/ vitest, with fixtures/ (SDK captures, app references)
46
+ tests/mcp-oauth-client/ vitest, against fake MCP and authorization servers
47
+ tests/crypto/ vitest, with published vectors and app format parity
48
+ tests-node/ plain Node checks of the built package: exports map and peers (esm-exports.mjs),
49
+ Convex V8 and Electron main bundles with esbuild (bundle.mjs)
50
+ docs/ convex.md, mcp.md, mcp-oauth-client.md, crypto.md, migration.md, migrated/<app>/
51
+ scripts/ capture-sdk-fixtures.mjs
52
52
  ```
53
53
 
54
54
  ## Develop
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from "./convex/index.js";
2
2
  export * from "./crypto/index.js";
3
3
  export * from "./mcp/index.js";
4
- export * from "./mcp-client/index.js";
4
+ export * from "./mcp-oauth-client/index.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from "./convex/index.js";
2
2
  export * from "./crypto/index.js";
3
3
  export * from "./mcp/index.js";
4
- export * from "./mcp-client/index.js";
4
+ export * from "./mcp-oauth-client/index.js";
package/docs/convex.md CHANGED
@@ -234,7 +234,7 @@ Stays in the apps: legacy email lookups, migration-table lookups, API-key actors
234
234
 
235
235
  ## Optimistic updates (client side)
236
236
 
237
- Moved from `@vvedantb/convex-client` 0.1.0 with the same names and behaviour. They live here, not in `@vvedantb/ui`, because they have no React: a backend package's client folder, its tests and a React Native app import them, and none of those can load the `@vvedantb/ui` root.
237
+ Client-side helpers for Convex optimistic updates. They live here, not in `@vvedantb/ui`, because they have no React: a backend package's client folder, its tests and a React Native app import them, and none of those can load the `@vvedantb/ui` root.
238
238
 
239
239
  ```ts
240
240
  import { mapLoadedQuery, patchLoadedQuery, tempId } from "@vvedantb/server";
package/docs/crypto.md CHANGED
@@ -53,7 +53,7 @@ The two app copies are the same: encode both strings as UTF-8, return `false` at
53
53
  | app-a | `convex/lib/base64.ts` | `@scure/base` `base64`, `base64url` (padded) | `bytesToBase64`, `base64ToBytes(v, { strict: true })`, `bytesToBase64Url(b, { padding: true })` |
54
54
  | app-a | `convex/apiKeys.ts` | `<prefix>_sk_<base64url of 24 bytes>`; hash `hex(sha256(key))` | `randomToken(24, "base64url")` (24 bytes never pads), `sha256Hex` |
55
55
  | app-e | `convex/crypto.ts` | `enc:<version>:<iv>:<ct>` (master key, versioned env), `enc2:<iv>:<ct>` (per-user data key), wrapped key `{ wrapped, iv, masterVersion, dekVersion }`; AAD labels on all; btoa/atob | `aesGcmEncrypt(key, text, { aad })` + `bytesToBase64`/`base64ToBytes`; `randomBytes(32)` for a data key; `sha256Hex`; `randomToken(24, "hex")` |
56
- | app-b | `convex/vhubCredentials/seal.ts` | `{ ciphertext, nonce }` base64, no AAD; key 64 hex chars or 32 raw UTF-8 bytes | `hexToBytes` for the hex form, `aesGcmEncrypt` + `bytesToBase64` |
56
+ | app-b | `convex/<app>Credentials/seal.ts` | `{ ciphertext, nonce }` base64, no AAD; key 64 hex chars or 32 raw UTF-8 bytes | `hexToBytes` for the hex form, `aesGcmEncrypt` + `bytesToBase64` |
57
57
  | app-b | `convex/routines/triggerEvents.ts` | trigger secret base64url (unpadded) of 32 bytes; event boundary hex of 12; `sha256Hex`; `timingSafeEqual` | `randomToken(32, "base64url")`, `randomToken(12, "hex")`, `sha256Hex`, `timingSafeEqual` |
58
58
  | app-c | `convex/http.ts` | `timingSafeEqual` for a bootstrap header | `timingSafeEqual` |
59
59
 
@@ -1,8 +1,8 @@
1
- # MCP client OAuth (`@vvedantb/server`)
1
+ # MCP OAuth client helpers (`@vvedantb/server`)
2
2
 
3
- Node-side MCP client OAuth for desktop apps. It covers OAuth 2.1 with PKCE and dynamic client registration against a remote MCP server. Pieces: an `OAuthClientProvider` over storage you supply, sign-in, refresh, best-effort revocation, and a one-shot loopback redirect server on `127.0.0.1`. It has no Electron imports: the app supplies the storage, the redirect and the browser. Node 20 or later (Electron main process).
3
+ Node-side MCP OAuth client helpers for desktop apps. It covers OAuth 2.1 with PKCE and dynamic client registration against a remote MCP server. Pieces: an `OAuthClientProvider` over storage you supply, sign-in, refresh, best-effort revocation, and a one-shot loopback redirect server on `127.0.0.1`. It has no Electron imports: the app supplies the storage, the redirect and the browser. Node 20 or later (Electron main process).
4
4
 
5
- Moved from `@vvedantb/mcp-client` 0.1.0 with the same export names. One behaviour differs: a non-interactive provider's `redirectToAuthorization` rejects instead of throwing (see [Provider](#provider)). Import everything from the package root, `@vvedantb/server`.
5
+ Import everything from the package root, `@vvedantb/server`.
6
6
 
7
7
  ## Install
8
8
 
@@ -68,7 +68,7 @@ const provider = createMcpOAuthProvider({
68
68
  | `storage` | (required) | `McpOAuthStorage`. |
69
69
  | `clientName` | (required) | `client_name` for dynamic registration. |
70
70
  | `scope` | none | Added to the client metadata. `authorizeMcpServer` without `connectAs` also sends it with the authorization request. |
71
- | `redirectUrl`, `redirectToAuthorization` | none | Set both for the interactive sign-in. Without them the provider only uses and refreshes what is stored. It never opens a browser: `redirectToAuthorization` returns a promise that rejects with the SDK's `UnauthorizedError(signInRequiredMessage)` (0.1.0 of `@vvedantb/mcp-client` threw it synchronously; the SDK awaits the call, so its flows see the same error). |
71
+ | `redirectUrl`, `redirectToAuthorization` | none | Set both for the interactive sign-in. Without them the provider only uses and refreshes what is stored. It never opens a browser: `redirectToAuthorization` returns a promise that rejects with the SDK's `UnauthorizedError(signInRequiredMessage)` (the SDK awaits the call, so its flows see the same error as a synchronous throw). |
72
72
  | `signInRequiredMessage` | `"Sign-in required"` | The message of that error. Tell the user where to sign in. |
73
73
  | `clientRegistration` | `"interactive"` | `"interactive"`: `saveClientInformation` exists only on an interactive provider, so a non-interactive 401 stops before any registration request. `"always"`: every provider can save a client, so the SDK never throws for want of somewhere to keep it. |
74
74
  | `stampObtainedAt` | `true` | Stamp `obtained_at` on saved tokens, for `isAccessTokenExpiring`. |
@@ -128,6 +128,6 @@ Each page is `<!doctype html><meta charset="utf-8"><title>{title}</title><body s
128
128
 
129
129
  ```sh
130
130
  pnpm --filter @vvedantb/server build
131
- pnpm --filter @vvedantb/server test # vitest from source (tests/mcp-client), then node --test on the built package
131
+ pnpm --filter @vvedantb/server test # vitest from source (tests/mcp-oauth-client), then node --test on the built package
132
132
  pnpm --filter @vvedantb/server typecheck
133
133
  ```
package/docs/migration.md CHANGED
@@ -17,7 +17,7 @@ Add the dependency in each app's `packages/backend/package.json` (after `@vvedan
17
17
 
18
18
  ## Upgrading to 0.4.0
19
19
 
20
- Additive: the optimistic-update helpers from `@vvedantb/convex-client` and every export of `@vvedantb/mcp-client` join the root under the same names. Bump to `"@vvedantb/server": "^0.4.0"`; backends that used neither package change nothing else. Steps for the apps that used them: the repository `MIGRATION.md`, section "Folded packages".
20
+ Additive: the Convex optimistic-update helpers and the MCP OAuth client helpers join the root. Bump to `"@vvedantb/server": "^0.4.0"`; backends that use neither change nothing else. See [convex.md](convex.md#optimistic-updates-client-side) and [mcp-oauth-client.md](mcp-oauth-client.md).
21
21
 
22
22
  ## Upgrading to 0.2.0
23
23
 
@@ -35,7 +35,7 @@ Additive: the optimistic-update helpers from `@vvedantb/convex-client` and every
35
35
  | app-c, app-d | `jsonResponse`, `createOriginAllowlistCors` | the local `jsonResponse`, `getCorsHeaders`, `getPreflightHeaders` in `convex/http.ts` | `const cors = createOriginAllowlistCors(ALLOWED_ORIGINS)`; `cors.headers(origin)`, `cors.preflightHeaders(origin)`. |
36
36
  | app-c | `timingSafeEqual` | the local copy in `convex/http.ts` | Same semantics. |
37
37
  | app-b | `timingSafeEqual`, `sha256Hex`, `randomToken`, `bytesToBase64Url`, `bytesToHex` | the local helpers in `convex/routines/triggerEvents.ts` | `generateTriggerSecret = () => randomToken(32, "base64url")`; `generateEventBoundary = () => randomToken(12, "hex")`. `githubSignature` keeps its HMAC call and uses `bytesToHex`. |
38
- | app-b | `aesGcmEncrypt`, `aesGcmDecrypt`, `bytesToBase64`, `base64ToBytes`, `hexToBytes` | the body of `convex/vhubCredentials/seal.ts` | Keep `secretBytes` (env name, trim, hex-or-raw rule) and the `{ ciphertext, nonce }` shape. |
38
+ | app-b | `aesGcmEncrypt`, `aesGcmDecrypt`, `bytesToBase64`, `base64ToBytes`, `hexToBytes` | the body of `convex/<app>Credentials/seal.ts` | Keep `secretBytes` (env name, trim, hex-or-raw rule) and the `{ ciphertext, nonce }` shape. |
39
39
  | app-a | `aesGcmEncrypt`, `aesGcmDecrypt`, `bytesToBase64`, `base64ToBytes(v, { strict: true })`, `bytesToBase64Url(b, { padding: true })`, `sha256Hex`, `randomToken` | `convex/lib/crypto.ts`, `convex/lib/base64.ts`, `generateApiKey`/`hashApiKey` in `convex/apiKeys.ts` | `strict` and `padding` keep `@scure/base` behaviour; then `@scure/base` can go if nothing else uses it. Keep the `v1:` format and `ENCRYPTION_KEY`. |
40
40
  | app-e | `aesGcmEncrypt`, `aesGcmDecrypt`, `bytesToBase64`, `base64ToBytes`, `randomBytes`, `randomToken`, `sha256Hex` | the WebCrypto calls and encoders in `convex/crypto.ts` | Keep `enc:`/`enc2:`, the AAD label functions, key versions, `masterKeyBytes` checks and `WrappedDek`. |
41
41
 
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@vvedantb/server",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "license": "MIT",
5
- "description": "Shared Convex backend helpers, MCP server scaffolding and Node-side MCP client OAuth from one root import: query-limit errors, Clerk auth and token verification, Clerk-user lookups and ensure-user for Convex functions, 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, and an MCP client OAuth provider with a loopback redirect server for desktop apps.",
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, Clerk-user lookups and ensure-user for Convex functions, 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, and MCP OAuth client helpers (provider, sign-in, refresh, revocation, loopback redirect server) for desktop apps.",
6
6
  "type": "module",
7
7
  "publishConfig": {
8
8
  "access": "public"
@@ -24,7 +24,7 @@
24
24
  "docs/convex.md",
25
25
  "docs/crypto.md",
26
26
  "docs/mcp.md",
27
- "docs/mcp-client.md",
27
+ "docs/mcp-oauth-client.md",
28
28
  "docs/migration.md",
29
29
  "CHANGELOG.md",
30
30
  "LICENSE"
File without changes
File without changes
File without changes