@elizaos/server 1.6.4 → 1.6.5-alpha.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/dist/index.js CHANGED
@@ -27030,6 +27030,15 @@ function transformMessageAttachments(message) {
27030
27030
  return message;
27031
27031
  }
27032
27032
 
27033
+ // src/utils/rls-validation.ts
27034
+ function validateServerIdForRls(server_id, serverInstance) {
27035
+ const rlsEnabled = process.env.ENABLE_RLS_ISOLATION === "true";
27036
+ if (!rlsEnabled) {
27037
+ return true;
27038
+ }
27039
+ return server_id === serverInstance.serverId;
27040
+ }
27041
+
27033
27042
  // src/api/messaging/core.ts
27034
27043
  function createMessagingCoreRouter(serverInstance) {
27035
27044
  const router = express10.Router();
@@ -27044,13 +27053,18 @@ function createMessagingCoreRouter(serverInstance) {
27044
27053
  raw_message,
27045
27054
  metadata
27046
27055
  } = req.body;
27047
- const isValidServerId = server_id === serverInstance.serverId;
27048
- if (!validateUuid9(channel_id) || !validateUuid9(author_id) || !content || !isValidServerId || !source_type || !raw_message) {
27056
+ if (!validateUuid9(channel_id) || !validateUuid9(server_id) || !validateUuid9(author_id) || !content || !source_type || !raw_message) {
27049
27057
  return res.status(400).json({
27050
27058
  success: false,
27051
27059
  error: "Missing required fields: channel_id, server_id, author_id, content, source_type, raw_message"
27052
27060
  });
27053
27061
  }
27062
+ if (!validateServerIdForRls(server_id, serverInstance)) {
27063
+ return res.status(403).json({
27064
+ success: false,
27065
+ error: "Forbidden: server_id does not match current server"
27066
+ });
27067
+ }
27054
27068
  if (in_reply_to_message_id && !validateUuid9(in_reply_to_message_id)) {
27055
27069
  return res.status(400).json({
27056
27070
  success: false,
@@ -27102,13 +27116,18 @@ function createMessagingCoreRouter(serverInstance) {
27102
27116
  raw_message,
27103
27117
  metadata
27104
27118
  } = req.body;
27105
- const isValidServerId = server_id === serverInstance.serverId;
27106
- if (!validateUuid9(channel_id) || !validateUuid9(author_id) || !content || !isValidServerId || !source_type || !raw_message) {
27119
+ if (!validateUuid9(channel_id) || !validateUuid9(server_id) || !validateUuid9(author_id) || !content || !source_type || !raw_message) {
27107
27120
  return res.status(400).json({
27108
27121
  success: false,
27109
27122
  error: "Missing required fields: channel_id, server_id, author_id, content, source_type, raw_message"
27110
27123
  });
27111
27124
  }
27125
+ if (!validateServerIdForRls(server_id, serverInstance)) {
27126
+ return res.status(403).json({
27127
+ success: false,
27128
+ error: "Forbidden: server_id does not match current server"
27129
+ });
27130
+ }
27112
27131
  if (in_reply_to_message_id && !validateUuid9(in_reply_to_message_id)) {
27113
27132
  return res.status(400).json({ success: false, error: "Invalid in_reply_to_message_id format" });
27114
27133
  }
@@ -27171,8 +27190,14 @@ function createMessagingCoreRouter(serverInstance) {
27171
27190
  if (author_id && !validateUuid9(author_id)) {
27172
27191
  return res.status(400).json({ success: false, error: "Invalid author_id format" });
27173
27192
  }
27174
- if (server_id && server_id !== serverInstance.serverId) {
27175
- return res.status(403).json({ success: false, error: "Forbidden: server_id does not match current server" });
27193
+ if (server_id && !validateUuid9(server_id)) {
27194
+ return res.status(400).json({ success: false, error: "Invalid server_id format" });
27195
+ }
27196
+ if (server_id && !validateServerIdForRls(server_id, serverInstance)) {
27197
+ return res.status(403).json({
27198
+ success: false,
27199
+ error: "Forbidden: server_id does not match current server"
27200
+ });
27176
27201
  }
27177
27202
  try {
27178
27203
  const updated = await serverInstance.updateMessage(id, {
@@ -27695,14 +27720,13 @@ function createChannelsRouter(elizaOS, serverInstance) {
27695
27720
  metadata,
27696
27721
  source_type
27697
27722
  } = req.body;
27698
- const isValidServerId = server_id === serverInstance.serverId;
27699
27723
  if (!channelIdParam || !validateUuid13(author_id) || !content || !validateUuid13(server_id)) {
27700
27724
  return res.status(400).json({
27701
27725
  success: false,
27702
27726
  error: "Missing required fields: channelId, server_id, author_id, content"
27703
27727
  });
27704
27728
  }
27705
- if (!isValidServerId) {
27729
+ if (!validateServerIdForRls(server_id, serverInstance)) {
27706
27730
  return res.status(403).json({
27707
27731
  success: false,
27708
27732
  error: "Forbidden: server_id does not match current server"
@@ -27958,14 +27982,13 @@ function createChannelsRouter(elizaOS, serverInstance) {
27958
27982
  error: "Invalid server_id format"
27959
27983
  });
27960
27984
  }
27961
- const isValidServerId = server_id === serverInstance.serverId;
27962
27985
  if (!name || !Array.isArray(participantCentralUserIds) || participantCentralUserIds.some((id) => !validateUuid13(id))) {
27963
27986
  return res.status(400).json({
27964
27987
  success: false,
27965
27988
  error: 'Invalid payload. Required: name, server_id (UUID or "0"), participantCentralUserIds (array of UUIDs). Optional: type, metadata.'
27966
27989
  });
27967
27990
  }
27968
- if (!isValidServerId) {
27991
+ if (!validateServerIdForRls(server_id, serverInstance)) {
27969
27992
  return res.status(403).json({
27970
27993
  success: false,
27971
27994
  error: "Forbidden: server_id does not match current server"
@@ -30689,7 +30712,7 @@ import express31 from "express";
30689
30712
  // package.json
30690
30713
  var package_default = {
30691
30714
  name: "@elizaos/server",
30692
- version: "1.6.4",
30715
+ version: "1.6.5-alpha.1",
30693
30716
  description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
30694
30717
  publishConfig: {
30695
30718
  access: "public",
@@ -0,0 +1,28 @@
1
+ import type { UUID } from '@elizaos/core';
2
+ import type { AgentServer } from '../index';
3
+ /**
4
+ * Validates server_id for RLS (Row Level Security) isolation
5
+ *
6
+ * When ENABLE_RLS_ISOLATION is enabled, only allows access to data
7
+ * belonging to the current server instance.
8
+ *
9
+ * When ENABLE_RLS_ISOLATION is disabled, allows access to all data
10
+ * (backward compatibility mode).
11
+ *
12
+ * @param server_id - The server ID from the request
13
+ * @param serverInstance - The current AgentServer instance
14
+ * @returns true if the server_id is valid for this request, false otherwise
15
+ *
16
+ * @example
17
+ * const isValid = validateServerIdForRls(req.body.server_id, serverInstance);
18
+ * if (!isValid) {
19
+ * return res.status(403).json({ error: 'Forbidden: server_id does not match' });
20
+ * }
21
+ */
22
+ export declare function validateServerIdForRls(server_id: UUID | string | undefined, serverInstance: AgentServer): boolean;
23
+ /**
24
+ * Checks if RLS (Row Level Security) isolation is enabled
25
+ *
26
+ * @returns true if ENABLE_RLS_ISOLATION=true, false otherwise
27
+ */
28
+ export declare function isRlsEnabled(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/server",
3
- "version": "1.6.4",
3
+ "version": "1.6.5-alpha.1",
4
4
  "description": "ElizaOS Server - Core server infrastructure for ElizaOS agents",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -44,7 +44,7 @@
44
44
  "dev": "bun run build.ts --watch"
45
45
  },
46
46
  "devDependencies": {
47
- "@elizaos/client": "1.6.4",
47
+ "@elizaos/client": "1.6.5-alpha.1",
48
48
  "@types/node": "^24.0.1",
49
49
  "prettier": "3.6.2",
50
50
  "tsx": "4.20.6",
@@ -52,10 +52,10 @@
52
52
  "which": "^5.0.0",
53
53
  "ws": "^8.18.0"
54
54
  },
55
- "gitHead": "a8aada56c37ac69c7382753a907bedf092533c6c",
55
+ "gitHead": "56b7ca950c4461f16eb2f835786474c8db6a6c23",
56
56
  "dependencies": {
57
- "@elizaos/core": "1.6.4",
58
- "@elizaos/plugin-sql": "1.6.4",
57
+ "@elizaos/core": "1.6.5-alpha.1",
58
+ "@elizaos/plugin-sql": "1.6.5-alpha.1",
59
59
  "@sentry/node": "^10.16.0",
60
60
  "@types/express": "^5.0.2",
61
61
  "@types/helmet": "^4.0.0",