@vvedantb/server 0.19.0 → 0.20.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 +12 -0
- package/dist/ai/errors.d.ts +0 -2
- package/dist/ai/errors.js +0 -16
- package/dist/ai/serviceTier.d.ts +0 -4
- package/dist/ai/serviceTier.js +0 -4
- package/dist/artifacts/document.d.ts +0 -2
- package/dist/artifacts/document.js +0 -1
- package/dist/artifacts/protocol.d.ts +0 -5
- package/dist/artifacts/schemas.d.ts +0 -6
- package/dist/artifacts/storageShim.js +0 -2
- package/dist/convex/authFunctions.d.ts +0 -57
- package/dist/convex/clerkBilling.d.ts +2 -18
- package/dist/convex/clerkBilling.js +0 -9
- package/dist/convex/clerkBillingFunctions.d.ts +0 -35
- package/dist/convex/clerkBillingFunctions.js +0 -8
- package/dist/convex/clerkBillingNodeFunctions.d.ts +0 -29
- package/dist/convex/clerkBillingNodeFunctions.js +0 -1
- package/dist/convex/clerkUserAuth.d.ts +0 -18
- package/dist/convex/clerkUserAuth.js +0 -14
- package/dist/convex/clerkWebhook.d.ts +0 -2
- package/dist/convex/convexAdminClient.d.ts +0 -30
- package/dist/convex/convexAdminClient.js +0 -34
- package/dist/convex/convexQueryLimits.d.ts +0 -8
- package/dist/convex/convexQueryLimits.js +0 -8
- package/dist/convex/createMcpAuthActions.d.ts +0 -31
- package/dist/convex/expoPush.d.ts +0 -24
- package/dist/convex/expoPush.js +0 -4
- package/dist/convex/homepageRoutes.d.ts +0 -12
- package/dist/convex/mcpServerInfo.d.ts +0 -2
- package/dist/convex/mcpTokenCache.d.ts +0 -17
- package/dist/convex/mcpTokenCache.js +0 -2
- package/dist/convex/memoryStore.js +0 -6
- package/dist/convex/originAllowlistCors.d.ts +0 -8
- package/dist/convex/productEmails.d.ts +0 -4
- package/dist/convex/tempId.js +0 -2
- package/dist/convex/vPlan.d.ts +0 -4
- package/dist/convex/vProModule.d.ts +0 -27
- package/dist/convex/vProModule.js +0 -11
- package/dist/convex/verifyClerkAccessToken.d.ts +3 -13
- package/dist/convex/verifyClerkOAuthJwt.d.ts +0 -18
- package/dist/convex/verifyClerkOAuthJwt.js +0 -6
- package/dist/crypto/aesGcm.d.ts +0 -2
- package/dist/crypto/aesGcm.js +0 -2
- package/dist/crypto/encoding.d.ts +0 -8
- package/dist/crypto/encoding.js +0 -3
- package/dist/generative-ui/catalog.d.ts +0 -17
- package/dist/generative-ui/catalog.js +0 -18
- package/dist/generative-ui/spec.d.ts +0 -8
- package/dist/generative-ui/spec.js +0 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mcp/dispatcher.d.ts +0 -7
- package/dist/mcp/dispatcher.js +0 -1
- package/dist/mcp/explorer.d.ts +0 -21
- package/dist/mcp/http.d.ts +3 -30
- package/dist/mcp/http.js +14 -0
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/json.d.ts +0 -1
- package/dist/mcp/jsonRpc.d.ts +0 -2
- package/dist/mcp/metadata.d.ts +0 -15
- package/dist/mcp/routes.d.ts +2 -12
- package/dist/mcp/routes.js +6 -2
- package/dist/mcp/sdk.d.ts +0 -12
- package/dist/mcp/tools.d.ts +0 -18
- package/dist/mcp/tools.js +0 -1
- package/dist/mcp/zodJsonSchema.d.ts +0 -4
- package/dist/mcp/zodJsonSchema.js +0 -5
- package/dist/mcp-oauth-client/loopback.d.ts +0 -5
- package/dist/mcp-oauth-client/loopback.js +0 -6
- package/dist/mcp-oauth-client/oauth.d.ts +0 -14
- package/dist/mcp-oauth-client/oauth.js +0 -16
- package/dist/mcp-oauth-client/state.d.ts +0 -3
- package/dist/sandbox/runtime.d.ts +0 -15
- package/dist/sandbox/runtime.js +0 -25
- package/dist/skills/githubSkills.d.ts +51 -0
- package/dist/skills/githubSkills.js +172 -0
- package/dist/skills/index.d.ts +2 -0
- package/dist/skills/index.js +2 -0
- package/dist/skills/skillRef.d.ts +18 -0
- package/dist/skills/skillRef.js +168 -0
- package/package.json +1 -1
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A tiny client for a Convex deployment's admin HTTP API, used by each app's
|
|
3
|
-
* MCP "run query" tool. It takes the deployment's cloud URL and an admin (or
|
|
4
|
-
* deploy) key as arguments and reads no environment variables, so the app owns
|
|
5
|
-
* where those come from (its own `*_DEPLOY_KEY` env var, a bootstrap fetch, a
|
|
6
|
-
* cache). No `convex` or `zod` import: the responses are parsed at the boundary
|
|
7
|
-
* here, the same way `expoPush` and `clerkBilling` parse theirs.
|
|
8
|
-
*
|
|
9
|
-
* - `runTestFunction` POSTs a bundled query source to `/api/run_test_function`
|
|
10
|
-
* with the admin key in the body. This is how `run_query` MCP tools execute
|
|
11
|
-
* ad-hoc read-only queries against the deployment.
|
|
12
|
-
* - `listTables` reads `/api/shapes2` (inferred shapes) and the
|
|
13
|
-
* `_system/frontend/getSchemas` query (the declared schema) and merges them.
|
|
14
|
-
*
|
|
15
|
-
* `formatConvexQueryError` (in `convexQueryLimits`) turns a thrown resource
|
|
16
|
-
* limit message into user-facing MCP error text.
|
|
17
|
-
*/
|
|
18
1
|
function isRecord(value) {
|
|
19
2
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
3
|
}
|
|
@@ -71,12 +54,6 @@ export function createConvexAdminClient(config) {
|
|
|
71
54
|
}
|
|
72
55
|
return response.json();
|
|
73
56
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Run a bundled query source through `/api/run_test_function`. `source` is a
|
|
76
|
-
* complete Convex module whose default export is a query (the MCP tools wrap
|
|
77
|
-
* the user's code in such a module). Returns the query's value and log lines;
|
|
78
|
-
* throws `Error(errorMessage)` when the query errors.
|
|
79
|
-
*/
|
|
80
57
|
async function runTestFunction(source, options = {}) {
|
|
81
58
|
const json = await post(`${base}/api/run_test_function`, { "Content-Type": "application/json" }, {
|
|
82
59
|
adminKey: config.adminKey,
|
|
@@ -86,15 +63,10 @@ export function createConvexAdminClient(config) {
|
|
|
86
63
|
});
|
|
87
64
|
return parseConvexApiResponse(json);
|
|
88
65
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Run one deployment function through `/api/query` with the admin auth
|
|
91
|
-
* header. Used for `_system` queries like `getSchemas`; returns the value.
|
|
92
|
-
*/
|
|
93
66
|
async function runSystemQuery(path, args = {}) {
|
|
94
67
|
const json = await post(`${base}/api/query`, convexAuthHeaders(), { path, args, format: "json" });
|
|
95
68
|
return parseConvexApiResponse(json).value;
|
|
96
69
|
}
|
|
97
|
-
/** The inferred shapes map from `/api/shapes2`, keyed by table name. */
|
|
98
70
|
async function getShapes() {
|
|
99
71
|
const response = await doFetch(`${base}/api/shapes2`, { headers: convexAuthHeaders() });
|
|
100
72
|
if (!response.ok) {
|
|
@@ -129,12 +101,6 @@ export function createConvexAdminClient(config) {
|
|
|
129
101
|
}
|
|
130
102
|
return byTable;
|
|
131
103
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Merge the inferred shapes (`/api/shapes2`) and the declared schema
|
|
134
|
-
* (`_system/frontend/getSchemas`) into one sorted list of tables. Each table
|
|
135
|
-
* carries both, either of which may be `null`. Pass `hideTable` to drop
|
|
136
|
-
* tables (system tables, app internals).
|
|
137
|
-
*/
|
|
138
104
|
async function listTables(options = {}) {
|
|
139
105
|
const shapes = await getShapes();
|
|
140
106
|
const schemas = await runSystemQuery("_system/frontend/getSchemas");
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convex query resource-limit detection for MCP test queries.
|
|
3
|
-
*
|
|
4
|
-
* `run_test_function` failures like "Too many bytes read in a single function
|
|
5
|
-
* execution (limit: 16777216 bytes)" used to throw out of `runTestQuery` as
|
|
6
|
-
* an uncaught Server Error. Callers map the formatted message to an MCP
|
|
7
|
-
* `isError` result instead.
|
|
8
|
-
*/
|
|
9
1
|
export declare function isConvexResourceLimitError(message: string): boolean;
|
|
10
2
|
/** User-facing MCP error text for a failed test query. */
|
|
11
3
|
export declare function formatConvexQueryError(message: string): string;
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convex query resource-limit detection for MCP test queries.
|
|
3
|
-
*
|
|
4
|
-
* `run_test_function` failures like "Too many bytes read in a single function
|
|
5
|
-
* execution (limit: 16777216 bytes)" used to throw out of `runTestQuery` as
|
|
6
|
-
* an uncaught Server Error. Callers map the formatted message to an MCP
|
|
7
|
-
* `isError` result instead.
|
|
8
|
-
*/
|
|
9
1
|
const CONVEX_RESOURCE_LIMIT_HINT = "Use smaller limits, paginate, or query with a selective index range.";
|
|
10
2
|
const CONVEX_RESOURCE_LIMIT_MARKERS = [
|
|
11
3
|
"too many bytes read",
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `verifyAccessToken` internal action every Clerk-backed MCP app exposes:
|
|
3
|
-
* `verifyClerkAccessToken` plus the few things that differ per app (which
|
|
4
|
-
* Clerk instance, which token types, what to log, what to return).
|
|
5
|
-
*
|
|
6
|
-
* The package never imports `convex` at runtime, so the app passes in `v` and
|
|
7
|
-
* its `internalAction` builder.
|
|
8
|
-
*/
|
|
9
1
|
import type { RegisteredAction } from "convex/server";
|
|
10
2
|
import type { v as convexV, Validator } from "convex/values";
|
|
11
3
|
import { type ClerkAuthLike, type ClerkLike, type ClerkTokenType, type VerifiedClerkToken, type VerifyClerkAccessTokenOptions } from "./verifyClerkAccessToken.js";
|
|
@@ -41,49 +33,26 @@ export type McpAuthMapArgs<Ctx> = {
|
|
|
41
33
|
token: string;
|
|
42
34
|
ctx: Ctx;
|
|
43
35
|
userId: string;
|
|
44
|
-
/** The Clerk result; `null` when `tryBeforeClerk` accepted the token. */
|
|
45
36
|
verified: VerifiedClerkToken<ClerkAuthLike> | null;
|
|
46
37
|
};
|
|
47
38
|
type ClerkSource = {
|
|
48
|
-
/** One Clerk client, or a function that builds it. */
|
|
49
39
|
getClerk: McpAuthClerk;
|
|
50
40
|
getClerks?: undefined;
|
|
51
41
|
} | {
|
|
52
42
|
getClerk?: undefined;
|
|
53
|
-
/** Several Clerk instances, tried in order. The first success wins. */
|
|
54
43
|
getClerks: McpAuthClerk[];
|
|
55
44
|
};
|
|
56
45
|
type CommonConfig<Ctx> = {
|
|
57
46
|
v: ConvexV;
|
|
58
|
-
/** Forwarded to `verifyClerkAccessToken`. Default `["oauth_token", "session_token"]`. */
|
|
59
47
|
acceptsToken?: ClerkTokenType[];
|
|
60
|
-
/**
|
|
61
|
-
* `onReject` and `onError` for each Clerk attempt. Default: silent.
|
|
62
|
-
* `onError` also gets anything the two hooks throw, but only when
|
|
63
|
-
* `swallowHookErrors` is `true`.
|
|
64
|
-
*/
|
|
65
48
|
logger?: Pick<VerifyClerkAccessTokenOptions, "onReject" | "onError">;
|
|
66
|
-
/**
|
|
67
|
-
* Runs before Clerk. Return a user to skip Clerk, `null` to reject the
|
|
68
|
-
* token, or `undefined` to continue with Clerk.
|
|
69
|
-
*/
|
|
70
49
|
tryBeforeClerk?: (args: McpAuthEarlyArgs<Ctx>) => Promise<McpAuthEarlyUser | null | undefined>;
|
|
71
|
-
/**
|
|
72
|
-
* What to do when `tryBeforeClerk` or `mapPrincipal` throws. Default
|
|
73
|
-
* `false`: the error propagates, so the action fails and the caller can
|
|
74
|
-
* retry. A transient fault then does not look like a rejected token. Set
|
|
75
|
-
* `true` to call `logger.onError` and return `null` instead. Use `true` only
|
|
76
|
-
* when the handler this action replaces caught every throw and returned
|
|
77
|
-
* `null`. Clerk failures return `null` in both modes.
|
|
78
|
-
*/
|
|
79
50
|
swallowHookErrors?: boolean;
|
|
80
51
|
};
|
|
81
52
|
/** Default result: `{ clerkUserId }`. */
|
|
82
53
|
export type CreateMcpAuthActionsConfig<Ctx, Principal = McpAuthPrincipal> = CommonConfig<Ctx> & ClerkSource & {
|
|
83
54
|
internalAction: McpAuthActionBuilder<Ctx, Principal>;
|
|
84
|
-
/** After a user is accepted, build the result. Return `null` to reject. Default `{ clerkUserId: userId }`. */
|
|
85
55
|
mapPrincipal?: (args: McpAuthMapArgs<Ctx>) => Promise<Principal | null>;
|
|
86
|
-
/** Convex validator for the result. Default `v.union(v.object({ clerkUserId: v.string() }), v.null())`. */
|
|
87
56
|
returns?: Validator<Principal | null, "required", string>;
|
|
88
57
|
};
|
|
89
58
|
type CustomConfig<Ctx, Principal> = CommonConfig<Ctx> & ClerkSource & {
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Expo push notifications for Convex apps: a device-token table, `register`
|
|
3
|
-
* and `unregister` mutations, a batched send through the Expo Push API, and
|
|
4
|
-
* push receipts that drop dead tokens.
|
|
5
|
-
*
|
|
6
|
-
* The package cannot own a Convex table and never imports `convex` at
|
|
7
|
-
* runtime, so the app defines the table in its own schema and passes in `v`,
|
|
8
|
-
* its function builders and `requireCurrentUserId`. The HTTP side
|
|
9
|
-
* (`sendExpoPushMessages`, `fetchExpoPushReceipts` and the token-cleanup
|
|
10
|
-
* helpers) is plain TypeScript that runs in Node and tests with no Convex.
|
|
11
|
-
*/
|
|
12
1
|
import type { defineTable as convexDefineTable, FunctionReference, IndexRange, RegisteredAction, RegisteredMutation, RegisteredQuery } from "convex/server";
|
|
13
2
|
import type { v as convexV, GenericId, Validator } from "convex/values";
|
|
14
3
|
/** The default table name. */
|
|
@@ -111,9 +100,7 @@ export type ExpoPushReceiptRef = {
|
|
|
111
100
|
token: string;
|
|
112
101
|
};
|
|
113
102
|
export type ExpoPushHttpOptions = {
|
|
114
|
-
/** Default: the global `fetch`, read at call time. */
|
|
115
103
|
fetch?: typeof fetch;
|
|
116
|
-
/** Expo access token, when the project enforces enhanced push security. */
|
|
117
104
|
accessToken?: string;
|
|
118
105
|
};
|
|
119
106
|
export type SendExpoPushMessagesOptions = ExpoPushHttpOptions & {
|
|
@@ -286,30 +273,19 @@ type CheckReceiptsDef<Ctx> = {
|
|
|
286
273
|
};
|
|
287
274
|
export type ExpoPushFunctionsConfig<Table extends string, UserId, Id, Range, MutationCtx extends PushMutationCtx<Table, UserId, Id, Range>, ActionCtx extends ActionRunCtx<UserId>> = {
|
|
288
275
|
v: ConvexV;
|
|
289
|
-
/** The validator for user ids, for example `v.id("users")`. It sets `UserId`. */
|
|
290
276
|
userId: Req<UserId>;
|
|
291
|
-
/** The app's public `mutation`, narrowed to the two calls made here. */
|
|
292
277
|
mutation: ((def: RegisterDef<MutationCtx>) => RegisteredMutation<"public", RegisterArgs, Promise<null>>) & ((def: UnregisterDef<MutationCtx>) => RegisteredMutation<"public", UnregisterArgs, Promise<null>>);
|
|
293
278
|
internalQuery: (def: ListTokensDef<PushQueryCtx<NoInfer<Table>, UserId, Id, Range>, UserId>) => RegisteredQuery<"internal", ListTokensArgs<UserId>, Promise<string[]>>;
|
|
294
279
|
internalMutation: (def: RemoveTokensDef<PushMutationCtx<NoInfer<Table>, UserId, Id, Range>>) => RegisteredMutation<"internal", RemoveTokensArgs, Promise<null>>;
|
|
295
280
|
internalAction: ((def: SendDef<ActionCtx, UserId>) => RegisteredAction<"internal", PushSendParams<UserId>, Promise<null>>) & ((def: CheckReceiptsDef<ActionCtx>) => RegisteredAction<"internal", CheckReceiptsArgs, Promise<null>>);
|
|
296
|
-
/**
|
|
297
|
-
* The signed-in user's id, throwing when there is none. Annotate the ctx
|
|
298
|
-
* with your `MutationCtx`: `(ctx: MutationCtx) => userAuth.requireCurrentUserId(ctx)`.
|
|
299
|
-
*/
|
|
300
281
|
requireCurrentUserId: (ctx: MutationCtx) => Promise<UserId>;
|
|
301
|
-
/** `(): ExpoPushListTokensRef<Id<"users">> => internal.push.listTokensForUser`. */
|
|
302
282
|
listTokensRef: () => ExpoPushListTokensRef<UserId>;
|
|
303
283
|
removeTokensRef: () => ExpoPushRemoveTokensRef;
|
|
304
284
|
sendRef: () => ExpoPushSendRef<UserId>;
|
|
305
285
|
checkReceiptsRef: () => ExpoPushCheckReceiptsRef;
|
|
306
|
-
/** The tokens table. Default `"pushTokens"`; it needs both indexes. */
|
|
307
286
|
tableName?: Table;
|
|
308
|
-
/** Wait before receipts are checked. Default `EXPO_RECEIPT_DELAY_MS` (15 minutes). */
|
|
309
287
|
receiptDelayMs?: number;
|
|
310
|
-
/** For `fetch` in tests. Default: the global `fetch`. */
|
|
311
288
|
fetch?: typeof fetch;
|
|
312
|
-
/** Read at send time, so it can come from `process.env`. Sent as a bearer token. */
|
|
313
289
|
accessToken?: () => string | undefined;
|
|
314
290
|
};
|
|
315
291
|
/**
|
package/dist/convex/expoPush.js
CHANGED
|
@@ -141,7 +141,6 @@ export async function sendExpoPushMessages(options) {
|
|
|
141
141
|
const tickets = parseExpoTickets(await postJson(EXPO_PUSH_SEND_URL, messages, options), batch.length);
|
|
142
142
|
if (tickets === null)
|
|
143
143
|
continue;
|
|
144
|
-
// Tickets come back in request order.
|
|
145
144
|
tickets.forEach((ticket, index) => results.push({ token: batch[index], ticket }));
|
|
146
145
|
}
|
|
147
146
|
return results;
|
|
@@ -230,7 +229,6 @@ export async function schedulePush(ctx, params, options) {
|
|
|
230
229
|
*/
|
|
231
230
|
export function createExpoPushFunctions(config) {
|
|
232
231
|
const built = buildExpoPushFunctions(config);
|
|
233
|
-
// The builders only check `Table` here; `schedulePush` takes the app's real ctx, so type it with `Table`.
|
|
234
232
|
return {
|
|
235
233
|
...built,
|
|
236
234
|
schedulePush: built.schedulePush,
|
|
@@ -254,7 +252,6 @@ function buildExpoPushFunctions(config) {
|
|
|
254
252
|
.first();
|
|
255
253
|
const fields = { userId: currentUserId, platform: args.platform, updatedAt: Date.now() };
|
|
256
254
|
if (existing) {
|
|
257
|
-
// A token moves with the device, so a new sign-in takes it over.
|
|
258
255
|
await ctx.db.patch(existing._id, fields);
|
|
259
256
|
}
|
|
260
257
|
else {
|
|
@@ -320,7 +317,6 @@ function buildExpoPushFunctions(config) {
|
|
|
320
317
|
const dead = tokensToRemoveFromTickets(results);
|
|
321
318
|
if (dead.length > 0)
|
|
322
319
|
await ctx.runMutation(config.removeTokensRef(), { tokens: dead });
|
|
323
|
-
// Dead tokens are gone already; only check receipts for the rest.
|
|
324
320
|
const receipts = receiptRefsFromTickets(results).filter((ref) => !dead.includes(ref.token));
|
|
325
321
|
if (receipts.length > 0) {
|
|
326
322
|
await ctx.scheduler.runAfter(config.receiptDelayMs ?? EXPO_RECEIPT_DELAY_MS, config.checkReceiptsRef(), {
|
|
@@ -20,23 +20,11 @@ export type HomepageRoutesCtx = {
|
|
|
20
20
|
};
|
|
21
21
|
type Method = "GET" | "POST" | "OPTIONS";
|
|
22
22
|
export type HomepageRoutesConfig<Ctx extends HomepageRoutesCtx, Handler> = {
|
|
23
|
-
/** The app's generated `httpAction`. */
|
|
24
23
|
httpAction: (fn: (ctx: Ctx, request: Request) => Promise<Response>) => Handler;
|
|
25
|
-
/** Route prefix, for example `/api/hub`: routes are `<basePath>/homepage` and `<basePath>/query`. */
|
|
26
24
|
basePath: string;
|
|
27
|
-
/** Browser origins that may call the routes with credentials. */
|
|
28
25
|
allowedOrigins: readonly string[];
|
|
29
|
-
/** Cards for `GET <basePath>/homepage`. Runs only with an identity. */
|
|
30
26
|
homepage: (ctx: Ctx) => Promise<HomepageCard[]>;
|
|
31
|
-
/**
|
|
32
|
-
* Results for `POST <basePath>/query`. Runs only with an identity and a
|
|
33
|
-
* non-empty `query`. Return `null` to answer 401.
|
|
34
|
-
*/
|
|
35
27
|
query: (ctx: Ctx, query: string) => Promise<JsonInput[] | null>;
|
|
36
|
-
/**
|
|
37
|
-
* CORS headers and an `OPTIONS` preflight on the homepage route too.
|
|
38
|
-
* Default true. The query route always has both.
|
|
39
|
-
*/
|
|
40
28
|
homepageCors?: boolean;
|
|
41
29
|
};
|
|
42
30
|
/**
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/** An icon in MCP `serverInfo.icons` (MCP 2025-11-25 `Implementation.icons`). */
|
|
2
2
|
export type McpServerIcon = {
|
|
3
|
-
/** Icon URL, for example an absolute https URL to the app's public icon. */
|
|
4
3
|
src: string;
|
|
5
4
|
mimeType?: string;
|
|
6
|
-
/** For example `["48x48"]` or `["any"]`. */
|
|
7
5
|
sizes?: string[];
|
|
8
6
|
theme?: "light" | "dark";
|
|
9
7
|
};
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A cache of verified MCP bearer tokens, so most requests skip the verify
|
|
3
|
-
* step (for Clerk: a network call, often from a cold Node action). Rows hold
|
|
4
|
-
* the SHA-256 of the token, never the token. Only successful verifications
|
|
5
|
-
* are cached; a revoked token keeps working until its row expires (at most
|
|
6
|
-
* `MCP_TOKEN_CACHE_TTL_MS`).
|
|
7
|
-
*
|
|
8
|
-
* The package cannot own a Convex table and never imports `convex` at
|
|
9
|
-
* runtime, so the app defines the table in its own schema and passes in `v`
|
|
10
|
-
* and its function builders.
|
|
11
|
-
*/
|
|
12
1
|
import type { defineTable as convexDefineTable, FunctionReference, IndexRange, RegisteredMutation, RegisteredQuery } from "convex/server";
|
|
13
2
|
import type { v as convexV, GenericId, Validator } from "convex/values";
|
|
14
3
|
export declare const MCP_TOKEN_CACHE_TTL_MS: number;
|
|
@@ -70,13 +59,9 @@ export declare function mcpTokenCacheTable(defineTable: typeof convexDefineTable
|
|
|
70
59
|
}, {}, {}>;
|
|
71
60
|
export type AuthenticateWithTokenCacheOptions<Principal extends McpTokenCachePrincipal> = {
|
|
72
61
|
token: string;
|
|
73
|
-
/** For example `(tokenHash) => ctx.runQuery(internal.mcp.tokenCache.getInternal, { tokenHash })`. */
|
|
74
62
|
get: (tokenHash: string) => Promise<McpTokenCacheEntry | null>;
|
|
75
|
-
/** For example `(row) => ctx.runMutation(internal.mcp.tokenCache.putInternal, row)`. */
|
|
76
63
|
put: (row: McpTokenCacheRow) => Promise<unknown>;
|
|
77
|
-
/** The real verification, run on a miss. */
|
|
78
64
|
verify: (token: string) => Promise<Principal | null>;
|
|
79
|
-
/** Clock in ms. Default `Date.now`. */
|
|
80
65
|
now?: () => number;
|
|
81
66
|
};
|
|
82
67
|
/**
|
|
@@ -165,9 +150,7 @@ export type McpTokenCacheFunctionsConfig<Table extends string, Id = GenericId<Ta
|
|
|
165
150
|
v: ConvexV;
|
|
166
151
|
internalQuery: McpTokenCacheQueryBuilder<NoInfer<Table>, NoInfer<Id>, NoInfer<Range>>;
|
|
167
152
|
internalMutation: McpTokenCacheMutationBuilder<NoInfer<Table>, NoInfer<Id>, NoInfer<Range>>;
|
|
168
|
-
/** The cache table. Default `"mcpTokenCache"`. */
|
|
169
153
|
tableName?: Table;
|
|
170
|
-
/** This module's `purgeExpired`: `(): McpTokenCachePurgeRef => internal.mcp.tokenCache.purgeExpired`. */
|
|
171
154
|
purgeSelf: () => McpTokenCachePurgeRef;
|
|
172
155
|
};
|
|
173
156
|
/**
|
|
@@ -114,14 +114,12 @@ function logAuth(cached, authMs) {
|
|
|
114
114
|
export function createMcpTokenCacheFunctions(config) {
|
|
115
115
|
return buildMcpTokenCacheFunctions(config);
|
|
116
116
|
}
|
|
117
|
-
// Typed for any table name, so the default name needs no cast; `Table` only checks the app's builders.
|
|
118
117
|
function buildMcpTokenCacheFunctions(config) {
|
|
119
118
|
const { v, internalQuery, internalMutation, purgeSelf } = config;
|
|
120
119
|
const table = config.tableName ?? MCP_TOKEN_CACHE_TABLE;
|
|
121
120
|
const getInternal = internalQuery({
|
|
122
121
|
args: { tokenHash: v.string() },
|
|
123
122
|
returns: v.union(v.object({ clerkUserId: v.string(), expiresAt: v.number() }), v.null()),
|
|
124
|
-
// expiry is checked by the caller, so this query stays cacheable
|
|
125
123
|
handler: async (ctx, { tokenHash }) => {
|
|
126
124
|
const row = await ctx.db
|
|
127
125
|
.query(table)
|
|
@@ -33,11 +33,6 @@ export function createMemoryOptimisticStore() {
|
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
// `getFunctionName` from `convex/server` (as of 1.47), copied so this package
|
|
37
|
-
// never imports `convex` at runtime: the root is also loaded where `convex` is
|
|
38
|
-
// not installed. For the references Convex creates (`api`/`internal` refs,
|
|
39
|
-
// name strings, function handles, component refs) it returns the same name or
|
|
40
|
-
// throws the same message; tests compare it with Convex's.
|
|
41
36
|
const functionName = Symbol.for("functionName");
|
|
42
37
|
const toReferencePath = Symbol.for("toReferencePath");
|
|
43
38
|
function getFunctionName(reference) {
|
|
@@ -47,7 +42,6 @@ function getFunctionName(reference) {
|
|
|
47
42
|
}
|
|
48
43
|
return reference;
|
|
49
44
|
}
|
|
50
|
-
// Read, not `in`: `api` references are proxies that answer property reads only.
|
|
51
45
|
const symbols = reference;
|
|
52
46
|
const name = symbols[functionName];
|
|
53
47
|
if (name)
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
export type OriginAllowlistCors = {
|
|
2
|
-
/**
|
|
3
|
-
* Headers for a normal response. `Access-Control-Allow-Origin` is the
|
|
4
|
-
* origin when allowed and `""` otherwise.
|
|
5
|
-
*/
|
|
6
2
|
headers(origin: string): Record<string, string>;
|
|
7
|
-
/**
|
|
8
|
-
* Headers for an `OPTIONS` preflight: adds `Access-Control-Max-Age: 86400`
|
|
9
|
-
* and omits `Access-Control-Allow-Origin` unless the origin is allowed.
|
|
10
|
-
*/
|
|
11
3
|
preflightHeaders(origin: string): Record<string, string>;
|
|
12
4
|
};
|
|
13
5
|
/**
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
/** How a product signs its emails. */
|
|
2
2
|
export type ProductEmailBrand = {
|
|
3
|
-
/** Product name, as in "Welcome to Acme!". */
|
|
4
3
|
name: string;
|
|
5
|
-
/** Sender, for example `Acme <waitlist@example.com>`. */
|
|
6
4
|
from: string;
|
|
7
|
-
/** Closing name under "Best regards,". */
|
|
8
5
|
signOff: string;
|
|
9
|
-
/** HTML placed after the sign-off: links, contact line. */
|
|
10
6
|
footerHtml: string;
|
|
11
7
|
};
|
|
12
8
|
/** A ready-to-send email, in the shape Resend's `emails.send` takes. */
|
package/dist/convex/tempId.js
CHANGED
|
@@ -12,8 +12,6 @@ export function tempId(table, options = {}) {
|
|
|
12
12
|
}
|
|
13
13
|
return value;
|
|
14
14
|
}
|
|
15
|
-
// GenericId is a branded string with no constructor; this guard is the one
|
|
16
|
-
// place a placeholder string is accepted as one.
|
|
17
15
|
function isPlaceholderId(value) {
|
|
18
16
|
return value.length > 0;
|
|
19
17
|
}
|
package/dist/convex/vPlan.d.ts
CHANGED
|
@@ -17,13 +17,9 @@ export declare const V_PRO_PLAN_KEYS: readonly string[];
|
|
|
17
17
|
export declare function hasVPlan(claimsOrIdentity: unknown): boolean;
|
|
18
18
|
/** What `hasVPro` reads. Every field is optional. */
|
|
19
19
|
export type HasVProInput = {
|
|
20
|
-
/** A Convex `ctx.auth.getUserIdentity()` result or raw JWT claims, read by `hasVPlan`. */
|
|
21
20
|
identity?: unknown;
|
|
22
|
-
/** Plan slugs stored on the user row, for example from the Clerk Billing webhook. */
|
|
23
21
|
planSlugs?: readonly string[] | null;
|
|
24
|
-
/** Clerk user ids that get V Pro without a paid plan. See `parseVProCompUserIds`. */
|
|
25
22
|
compIds?: readonly string[] | null;
|
|
26
|
-
/** The Clerk user id to match against `compIds`. Default: `identity.subject`. */
|
|
27
23
|
clerkId?: string | null;
|
|
28
24
|
};
|
|
29
25
|
/**
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { type ClerkBillingChange, type ClerkWebhookEventLike } from "./clerkBilling.js";
|
|
2
2
|
import { type ClerkUserDataModelLike, type ClerkUserDbReader, type ClerkUserInsert } from "./clerkUserAuth.js";
|
|
3
|
-
/**
|
|
4
|
-
* V Pro helpers bound to one users table and its field names, so an app keeps
|
|
5
|
-
* its stored field (`planSlugs`, `billingPlanSlugs`, ...) with no data
|
|
6
|
-
* migration. Typed structurally like `createClerkUserAuth`: no `convex` import.
|
|
7
|
-
*/
|
|
8
3
|
/** Document fields that can hold a `string[]` (optional ones too). */
|
|
9
4
|
export type VProPlanSlugsFieldOf<Doc> = {
|
|
10
5
|
[K in keyof Doc & string]-?: string[] extends Doc[K] ? K : never;
|
|
@@ -31,13 +26,10 @@ export type VProCreateUser<Table extends string, Doc extends {
|
|
|
31
26
|
export type VProMissingUserConfig<Table extends string, Doc extends {
|
|
32
27
|
_id: string;
|
|
33
28
|
}> = {
|
|
34
|
-
/** Default `"noop"`: no write, `writeBillingChange` returns `false`. */
|
|
35
29
|
onMissingUser?: "noop";
|
|
36
30
|
createUser?: undefined;
|
|
37
31
|
} | {
|
|
38
|
-
/** `"create"` (implied by `createUser`): call `createUser`, then return `true`. */
|
|
39
32
|
onMissingUser?: "create";
|
|
40
|
-
/** Inserts the missing row with the given slugs. Required for `"create"`. */
|
|
41
33
|
createUser: VProCreateUser<Table, Doc>;
|
|
42
34
|
};
|
|
43
35
|
export type VProModuleConfig<Table extends string, Index extends string, ClerkIdField extends string, PlanSlugsField extends string, Doc extends {
|
|
@@ -45,29 +37,13 @@ export type VProModuleConfig<Table extends string, Index extends string, ClerkId
|
|
|
45
37
|
} = {
|
|
46
38
|
_id: string;
|
|
47
39
|
}> = VProMissingUserConfig<Table, Doc> & {
|
|
48
|
-
/** The users table, for example `"users"`. */
|
|
49
40
|
table: Table;
|
|
50
|
-
/** The index on the Clerk id field, for example `"by_clerk_id"`. */
|
|
51
41
|
index: Index;
|
|
52
|
-
/** The indexed field that holds the Clerk user id, for example `"clerkId"`. */
|
|
53
42
|
clerkIdField: ClerkIdField;
|
|
54
|
-
/** The `string[]` field that stores granting plan slugs, for example `"planSlugs"`. */
|
|
55
43
|
planSlugsField: PlanSlugsField;
|
|
56
|
-
/** How the index lookup ends. Default `"first"`; `"unique"` throws on duplicate rows. */
|
|
57
44
|
lookup?: "first" | "unique";
|
|
58
|
-
/**
|
|
59
|
-
* Item statuses that grant their plan, for `nextPlanSlugs`,
|
|
60
|
-
* `writeBillingChange` and `parseBillingEvent`. Default
|
|
61
|
-
* `GRANTING_ITEM_STATUSES` (`active`, `past_due`, `canceled`).
|
|
62
|
-
*/
|
|
63
45
|
grantingStatuses?: readonly string[];
|
|
64
|
-
/** Event type matching for `parseBillingEvent`. Default `"exact"`. See `ClerkBillingOptions`. */
|
|
65
46
|
eventMatch?: "exact" | "prefix";
|
|
66
|
-
/**
|
|
67
|
-
* Extra fields for the `writeBillingChange` patch of an existing row, for
|
|
68
|
-
* example `{ billingPlansUpdatedAt: Date.now() }`. The slugs field always
|
|
69
|
-
* wins. Not used by `planSlugsPatch` or `createUser`.
|
|
70
|
-
*/
|
|
71
47
|
extraPatch?: (planSlugs: string[]) => Partial<ClerkUserInsert<Doc>>;
|
|
72
48
|
};
|
|
73
49
|
/** `ctx.db` for `writeBillingChange`: one index lookup and a patch. A Convex `MutationCtx` fits. */
|
|
@@ -76,14 +52,11 @@ export type VProWriterCtx<Table extends string, Index extends string, ClerkIdFie
|
|
|
76
52
|
}, Range> = {
|
|
77
53
|
db: ClerkUserDbReader<Table, Index, ClerkIdField, Doc, Range> & {
|
|
78
54
|
patch(id: Doc["_id"], value: Partial<ClerkUserInsert<Doc>>): Promise<void>;
|
|
79
|
-
/** Needed only with `createUser`; a `MutationCtx` has it. */
|
|
80
55
|
insert?(table: Table, value: ClerkUserInsert<Doc>): Promise<Doc["_id"]>;
|
|
81
56
|
};
|
|
82
57
|
};
|
|
83
58
|
export type UserHasVProOptions = {
|
|
84
|
-
/** The caller's identity, for the session `pla` claim. */
|
|
85
59
|
identity?: unknown;
|
|
86
|
-
/** Clerk user ids that get V Pro without a paid plan. */
|
|
87
60
|
compIds?: readonly string[] | null;
|
|
88
61
|
};
|
|
89
62
|
/**
|
|
@@ -30,25 +30,20 @@ export function createVProModule() {
|
|
|
30
30
|
field: config.clerkIdField,
|
|
31
31
|
lookup: config.lookup,
|
|
32
32
|
});
|
|
33
|
-
/** The stored slugs; `[]` for no user, a missing field or a non-array value. */
|
|
34
33
|
function planSlugsOf(user) {
|
|
35
34
|
const value = user?.[config.planSlugsField];
|
|
36
35
|
return Array.isArray(value) ? value.filter((slug) => typeof slug === "string") : [];
|
|
37
36
|
}
|
|
38
|
-
/** The slugs to store after `change`. */
|
|
39
37
|
function nextPlanSlugs(user, change) {
|
|
40
38
|
return applyBillingChange(planSlugsOf(user), change, billingOptions);
|
|
41
39
|
}
|
|
42
|
-
/** `parseClerkBillingEvent` with this module's `grantingStatuses` and `eventMatch`. */
|
|
43
40
|
function parseBillingEvent(event) {
|
|
44
41
|
return parseClerkBillingEvent(event, billingOptions);
|
|
45
42
|
}
|
|
46
|
-
/** `{ [planSlugsField]: planSlugs }`, for `ctx.db.patch`. */
|
|
47
43
|
function planSlugsPatch(planSlugs) {
|
|
48
44
|
const patch = { [config.planSlugsField]: [...planSlugs] };
|
|
49
45
|
return patch;
|
|
50
46
|
}
|
|
51
|
-
/** `hasVPro` over the row's stored slugs and Clerk id, plus the given identity and comp ids. */
|
|
52
47
|
function userHasVPro(user, options = {}) {
|
|
53
48
|
const clerkId = user?.[config.clerkIdField];
|
|
54
49
|
return hasVPro({
|
|
@@ -58,12 +53,6 @@ export function createVProModule() {
|
|
|
58
53
|
clerkId: typeof clerkId === "string" ? clerkId : undefined,
|
|
59
54
|
});
|
|
60
55
|
}
|
|
61
|
-
/**
|
|
62
|
-
* The webhook writer's body: find the row by `change.clerkId` and patch
|
|
63
|
-
* the new slugs (plus `extraPatch`). With no row: returns `false` with no
|
|
64
|
-
* write (the next event or a backfill fills it in), or, with
|
|
65
|
-
* `createUser`, calls it with the slugs and returns `true`.
|
|
66
|
-
*/
|
|
67
56
|
async function writeBillingChange(ctx, change) {
|
|
68
57
|
const user = await userAuth.getUserByClerkId(ctx, change.clerkId);
|
|
69
58
|
if (!user) {
|
|
@@ -26,34 +26,24 @@ export type ClerkLike<Auth extends ClerkAuthLike> = {
|
|
|
26
26
|
}): Promise<ClerkRequestStateLike<Auth>>;
|
|
27
27
|
};
|
|
28
28
|
/** Why a token was rejected without throwing. */
|
|
29
|
-
export type ClerkVerifyRejection =
|
|
30
|
-
/** `authenticateRequest` returned an unauthenticated state. */
|
|
31
|
-
{
|
|
29
|
+
export type ClerkVerifyRejection = {
|
|
32
30
|
kind: "unauthenticated";
|
|
33
31
|
reason: string | null;
|
|
34
32
|
message: string | null;
|
|
35
|
-
}
|
|
36
|
-
/** `toAuth()` was not authenticated, or its token type is not accepted. */
|
|
37
|
-
| {
|
|
33
|
+
} | {
|
|
38
34
|
kind: "wrong-token";
|
|
39
35
|
tokenType: string | null;
|
|
40
|
-
}
|
|
41
|
-
/** `toAuth().userId` is not a non-empty string. */
|
|
42
|
-
| {
|
|
36
|
+
} | {
|
|
43
37
|
kind: "no-user";
|
|
44
38
|
};
|
|
45
39
|
export type VerifyClerkAccessTokenOptions = {
|
|
46
|
-
/** Default `["oauth_token", "session_token"]`. Also the allowed `toAuth().tokenType` values. */
|
|
47
40
|
acceptsToken?: ClerkTokenType[];
|
|
48
|
-
/** Called once before returning `null` for a rejected token. Default: silent. */
|
|
49
41
|
onReject?: (rejection: ClerkVerifyRejection) => void;
|
|
50
|
-
/** Called with anything thrown (client factory, `Request`, Clerk) before returning `null`. Default: silent. */
|
|
51
42
|
onError?: (error: Thrown) => void;
|
|
52
43
|
};
|
|
53
44
|
export type VerifiedClerkToken<Auth extends ClerkAuthLike> = {
|
|
54
45
|
userId: string;
|
|
55
46
|
tokenType: ClerkTokenType;
|
|
56
|
-
/** `state.toAuth()`, for app-specific claims. */
|
|
57
47
|
auth: Auth;
|
|
58
48
|
};
|
|
59
49
|
/**
|
|
@@ -26,23 +26,16 @@ export type ClerkOAuthJwtRejection = {
|
|
|
26
26
|
export type VerifyClerkOAuthJwtOptions = {
|
|
27
27
|
/** Clerk Frontend API URL, e.g. `https://clerk.example.com`. Must equal the token's `iss` (trailing slash ignored). */
|
|
28
28
|
issuer: string;
|
|
29
|
-
/** Default `${issuer}/.well-known/jwks.json`. */
|
|
30
29
|
jwksUrl?: string;
|
|
31
|
-
/** Default global `fetch`. */
|
|
32
30
|
fetch?: typeof fetch;
|
|
33
|
-
/** Default `Date.now`. */
|
|
34
31
|
now?: () => number;
|
|
35
|
-
/** Allowed clock difference for `exp` and `nbf`. Default 5000. */
|
|
36
32
|
clockSkewMs?: number;
|
|
37
|
-
/** Called once before returning `null` for a rejected token. Default: silent. */
|
|
38
33
|
onReject?: (rejection: ClerkOAuthJwtRejection) => void;
|
|
39
|
-
/** Called with anything thrown (JWKS fetch, WebCrypto) before returning `null`. Default: silent. */
|
|
40
34
|
onError?: (error: Thrown) => void;
|
|
41
35
|
};
|
|
42
36
|
/** The verified token. `clerkUserId` is the `sub` claim. */
|
|
43
37
|
export type VerifiedClerkOAuthJwt = {
|
|
44
38
|
clerkUserId: string;
|
|
45
|
-
/** All payload claims, for app-specific use (e.g. `scope`, `client_id`). */
|
|
46
39
|
claims: Record<string, unknown>;
|
|
47
40
|
};
|
|
48
41
|
/** How long a fetched JWKS is used before the next fetch. */
|
|
@@ -68,25 +61,14 @@ type FallbackResult = {
|
|
|
68
61
|
} | null | undefined;
|
|
69
62
|
type VerifyFallback = (token: string) => Promise<FallbackResult>;
|
|
70
63
|
type AuthenticateClerkBearerBaseOptions = Omit<VerifyClerkOAuthJwtOptions, "onReject"> & {
|
|
71
|
-
/** The bearer token, without the `Bearer ` prefix. */
|
|
72
64
|
token: string;
|
|
73
|
-
/** Called for a rejected OAuth access token JWT. Default: silent. */
|
|
74
65
|
onReject?: (rejection: ClerkOAuthJwtRejection) => void;
|
|
75
66
|
};
|
|
76
67
|
export type AuthenticateClerkBearerOptions = AuthenticateClerkBearerBaseOptions & ({
|
|
77
|
-
/**
|
|
78
|
-
* Verifies every token that is not an OAuth access token JWT (header `typ`
|
|
79
|
-
* `at+jwt` or `application/at+jwt`): opaque OAuth tokens issued before the
|
|
80
|
-
* switch to JWTs, and other JWTs such as Clerk session tokens. Usually
|
|
81
|
-
* `ctx.runAction(internal.mcp.nodeActions.verifyAccessToken, { token })`.
|
|
82
|
-
* Returns `{ clerkUserId }`, or `{ userId }` as `verifyClerkAccessToken` does, or `null`.
|
|
83
|
-
*/
|
|
84
68
|
verifyFallback: VerifyFallback;
|
|
85
|
-
/** @deprecated Use `verifyFallback`. Ignored when `verifyFallback` is set. */
|
|
86
69
|
verifyOpaque?: VerifyFallback;
|
|
87
70
|
} | {
|
|
88
71
|
verifyFallback?: VerifyFallback;
|
|
89
|
-
/** @deprecated Use `verifyFallback`. Alias kept so 0.8.0 callers compile. */
|
|
90
72
|
verifyOpaque: VerifyFallback;
|
|
91
73
|
});
|
|
92
74
|
/** True when the token is a JWT whose header `typ` is `at+jwt` or `application/at+jwt`. */
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* V8-safe verification of Clerk OAuth access tokens issued as JWTs (RFC 9068).
|
|
3
|
-
* WebCrypto and `fetch` only: no Node built-ins, no `@clerk/backend`, so it
|
|
4
|
-
* runs in a Convex `httpAction` on the default runtime without a Node action.
|
|
5
|
-
*/
|
|
6
1
|
import { base64UrlToBytes } from "../crypto/encoding.js";
|
|
7
2
|
/** How long a fetched JWKS is used before the next fetch. */
|
|
8
3
|
export const CLERK_JWKS_TTL_MS = 60 * 60 * 1000;
|
|
9
4
|
/** A key id missing from the cached JWKS triggers a refetch, at most this often. */
|
|
10
5
|
export const CLERK_JWKS_REFETCH_MIN_MS = 60 * 1000;
|
|
11
|
-
// Module scope: shared by every request in the same isolate.
|
|
12
6
|
const jwksCache = new Map();
|
|
13
7
|
const keyCache = new Map();
|
|
14
8
|
/** Forget cached JWKS and imported keys (tests, or a forced key refresh). */
|
package/dist/crypto/aesGcm.d.ts
CHANGED
|
@@ -8,9 +8,7 @@ export type AesGcmSealed = {
|
|
|
8
8
|
ciphertext: Uint8Array<ArrayBuffer>;
|
|
9
9
|
};
|
|
10
10
|
export type AesGcmEncryptOptions = {
|
|
11
|
-
/** Default 12 random bytes. Pass a fixed IV only in tests. */
|
|
12
11
|
iv?: Uint8Array;
|
|
13
|
-
/** Additional authenticated data. Omitted and empty are the same in GCM. */
|
|
14
12
|
aad?: BytesOrText;
|
|
15
13
|
};
|
|
16
14
|
export type AesGcmDecryptOptions = {
|
package/dist/crypto/aesGcm.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
export type Base64DecodeOptions = {
|
|
2
|
-
/**
|
|
3
|
-
* Only accept canonical padded RFC 4648 text: the exact string
|
|
4
|
-
* `bytesToBase64` would produce (no whitespace, padding required, zero pad
|
|
5
|
-
* bits), like `@scure/base`'s `base64.decode`. Throws `Error("Invalid base64")`
|
|
6
|
-
* otherwise. Default `false`: `atob`'s forgiving decode (whitespace ignored,
|
|
7
|
-
* padding optional, `DOMException` on bad characters).
|
|
8
|
-
*/
|
|
9
2
|
strict?: boolean;
|
|
10
3
|
};
|
|
11
4
|
export type Base64UrlEncodeOptions = {
|
|
12
|
-
/** Keep `=` padding, like `@scure/base`'s `base64url`. Default `false` (RFC 7515, `Buffer`'s `"base64url"`). */
|
|
13
5
|
padding?: boolean;
|
|
14
6
|
};
|
|
15
7
|
/** Standard padded base64. */
|