@protobase/server 0.131.0 → 0.131.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.
@@ -17,12 +17,12 @@ const grants = {
17
17
  keptWhileOthers: false
18
18
  };
19
19
  /**
20
- * The role the built-in assistant's read-only queries run as, `<database>_query`, which reads only the resources'
21
- * tables (`queryInput`), and `query.run_read_only`, the runner every query goes through as that role.
20
+ * The role read-only queries run as, `<database>_query`, of the built-in assistant and the MCP endpoint's `sql`, which
21
+ * reads only the resources' tables (`queryInput`), and `query.run_read_only`, the runner every query goes through as that role.
22
22
  */
23
23
  const queryModule = {
24
- label: "the query role of the assistant's read-only queries",
25
- title: "The role the assistant's read-only queries run as, which reads only the resources' tables",
24
+ label: "the query role of read-only queries",
25
+ title: "The role read-only queries run as, which reads only the resources' tables",
26
26
  steps: [{
27
27
  step: 1,
28
28
  name: "role",
@@ -11,7 +11,7 @@ export type GuardedTables = {
11
11
  schemas: readonly string[];
12
12
  };
13
13
  /**
14
- * Refuses to go on while the runner of the assistant's read-only queries, which the record of migrations says is there,
14
+ * Refuses to go on while the runner of read-only queries, which the record of migrations says is there,
15
15
  * does not run as a role weaker than the app's: it is no security definer, or runs as the app's role itself or one it
16
16
  * is a member of, a superuser, a login role, or one that can read an auth table, or while that role may call a
17
17
  * security-definer function that runs as a role able to read one. A migration cannot promise these: they are the live
@@ -5,7 +5,7 @@ import { sql } from "kysely";
5
5
  const rowsOf = async (db, query) => (await query.execute(db)).rows;
6
6
  const guardedRelations = ({ tables, schemas }) => sql`select c.oid, c.relnamespace from pg_class c join pg_namespace n on n.oid = c.relnamespace
7
7
  where c.oid in (select to_regclass(t.name) from unnest(${tables.map(regclassText)}::text[]) as t(name)) or n.nspname = any(${[...schemas]}::text[])`;
8
- const refusal = (state) => /* @__PURE__ */ new Error(`The query role of the assistant's read-only queries ${state}. Take back by hand what it was given, then start again.`);
8
+ const refusal = (state) => /* @__PURE__ */ new Error(`The query role of read-only queries ${state}. Take back by hand what it was given, then start again.`);
9
9
  const leakingFunctions = (db, authTables) => rowsOf(db, sql`with runner as (select proowner as role from pg_proc where oid = to_regprocedure(${queryRunnerSignature}))
10
10
  select format('%I.%I(%s)', n.nspname, p.proname, pg_get_function_identity_arguments(p.oid)) as name
11
11
  from pg_proc p join pg_namespace n on n.oid = p.pronamespace, runner
@@ -15,7 +15,7 @@ const leakingFunctions = (db, authTables) => rowsOf(db, sql`with runner as (sele
15
15
  where has_schema_privilege(p.proowner, c.relnamespace, 'USAGE') and has_any_column_privilege(p.proowner, c.oid, 'SELECT'))
16
16
  order by 1`);
17
17
  /**
18
- * Refuses to go on while the runner of the assistant's read-only queries, which the record of migrations says is there,
18
+ * Refuses to go on while the runner of read-only queries, which the record of migrations says is there,
19
19
  * does not run as a role weaker than the app's: it is no security definer, or runs as the app's role itself or one it
20
20
  * is a member of, a superuser, a login role, or one that can read an auth table, or while that role may call a
21
21
  * security-definer function that runs as a role able to read one. A migration cannot promise these: they are the live
@@ -35,7 +35,7 @@ const checkQueryRoleSafety = async (db, authTables) => {
35
35
  if (runner.reads_auth) throw refusal("can read the auth schema");
36
36
  const leaking = await leakingFunctions(db, authTables);
37
37
  if (leaking.length === 0) return;
38
- throw new Error(`The query role of the assistant's read-only queries can read the auth schema through the security-definer functions ${leaking.map((found) => found.name).join(", ")}. Revoke execute on them from PUBLIC, or move them to a schema without a resource, then start again.`);
38
+ throw new Error(`The query role of read-only queries can read the auth schema through the security-definer functions ${leaking.map((found) => found.name).join(", ")}. Revoke execute on them from PUBLIC, or move them to a schema without a resource, then start again.`);
39
39
  };
40
40
  //#endregion
41
41
  export { checkQueryRoleSafety };
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.131.0";
2
+ var version = "0.131.1";
3
3
  //#endregion
4
4
  export { version };
@@ -35,6 +35,6 @@ export declare const commentsSchemaSql: () => string;
35
35
  export declare const mailFeedbackSchemaSql: () => string;
36
36
  /** The table of who unsubscribed from which topic of the bulk mail. */
37
37
  export declare const unsubscribesSchemaSql: () => string;
38
- /** The role of the built-in assistant's read-only queries and its runner, with select on the tables of `models` but those of `auth`'s store. */
38
+ /** The role of read-only queries and its runner, with select on the tables of `models` but those of `auth`'s store. */
39
39
  export declare const querySchemaSql: (models: readonly ResourceModel[], auth?: StoreNamesSource) => string;
40
40
  //#endregion
@@ -45,7 +45,7 @@ const commentsSchemaSql = () => modulesSql({ comments: noInput });
45
45
  const mailFeedbackSchemaSql = () => modulesSql({ mail_feedback: noInput });
46
46
  /** The table of who unsubscribed from which topic of the bulk mail. */
47
47
  const unsubscribesSchemaSql = () => modulesSql({ unsubscribes: noInput });
48
- /** The role of the built-in assistant's read-only queries and its runner, with select on the tables of `models` but those of `auth`'s store. */
48
+ /** The role of read-only queries and its runner, with select on the tables of `models` but those of `auth`'s store. */
49
49
  const querySchemaSql = (models, auth) => modulesSql({ query: queryInput(models, auth && storeNames(auth)) });
50
50
  //#endregion
51
51
  export { callsSchemaSql, channelSendsSchemaSql, commentsSchemaSql, computedSchemaSql, derivedSchemaSql, mailFeedbackSchemaSql, notificationsSchemaSql, querySchemaSql, realtimeRelaySchemaSql, relaySchemaSql, statusSchemaSql, unsubscribesSchemaSql, userTablesSchemaSql, webhooksSchemaSql, workflowsSchemaSql };
@@ -30,7 +30,7 @@ export type ModuleApp = {
30
30
  events?: EventsOptions;
31
31
  /** Whether the tables users add serve (`userTables`). */
32
32
  userTables?: boolean;
33
- /** Whether the built-in assistant's read-only queries run, as a role of their own that must not read the auth store. */
33
+ /** Whether read-only queries run, of the built-in assistant or the MCP endpoint's `sql`, as a role of their own that must not read the auth store. */
34
34
  readOnlyQueries?: boolean;
35
35
  };
36
36
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.131.0",
3
+ "version": "0.131.1",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -44,11 +44,11 @@
44
44
  "@better-auth/sso": "^1.7.12",
45
45
  "@livekit/protocol": "1.53.1",
46
46
  "@modelcontextprotocol/server": "^2.3.1",
47
- "@protobase/layout": "0.131.0",
48
- "@protobase/query": "0.131.0",
49
- "@protobase/schema": "0.131.0",
50
- "@protobase/workflow-plugins": "0.131.0",
51
- "@protobase/workflows": "0.131.0",
47
+ "@protobase/layout": "0.131.1",
48
+ "@protobase/query": "0.131.1",
49
+ "@protobase/schema": "0.131.1",
50
+ "@protobase/workflow-plugins": "0.131.1",
51
+ "@protobase/workflows": "0.131.1",
52
52
  "@react-email/render": "^2.1.0",
53
53
  "@react-pdf/primitives": "^4.4.0",
54
54
  "@react-pdf/renderer": "^4.9.1",