streamby-core 0.26.8 → 0.26.10

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.
@@ -4,6 +4,7 @@ exports.credentialRouter = credentialRouter;
4
4
  const express_1 = require("express");
5
5
  const manager_1 = require("../../models/manager");
6
6
  const auth_1 = require("../../utils/auth");
7
+ const sanitize_1 = require("../../utils/sanitize");
7
8
  const credential_1 = require("../../services/credential");
8
9
  function credentialRouter(config) {
9
10
  const router = (0, express_1.Router)();
@@ -25,7 +26,7 @@ function credentialRouter(config) {
25
26
  return res.status(403).json({ message: 'Unauthorized project access' });
26
27
  }
27
28
  const updatedProject = await (0, credential_1.addCredential)(config, projectId, { id, key, value });
28
- res.status(201).json({ message: 'Credential added successfully', project: updatedProject });
29
+ res.status(201).json({ message: 'Credential added successfully', project: (0, sanitize_1.sanitizeProject)(updatedProject) });
29
30
  }
30
31
  catch (err) {
31
32
  res.status(500).json({ message: 'Failed to add credential', details: err.message });
@@ -49,7 +50,7 @@ function credentialRouter(config) {
49
50
  return res.status(403).json({ message: 'Unauthorized project access' });
50
51
  }
51
52
  const updatedProject = await (0, credential_1.updateCredential)(config, projectId, credentialId, { key, value });
52
- res.status(200).json({ message: 'Credential updated successfully', project: updatedProject });
53
+ res.status(200).json({ message: 'Credential updated successfully', project: (0, sanitize_1.sanitizeProject)(updatedProject) });
53
54
  }
54
55
  catch (err) {
55
56
  res.status(500).json({ message: 'Failed to update credential', details: err.message });
@@ -69,7 +70,7 @@ function credentialRouter(config) {
69
70
  return res.status(403).json({ message: 'Unauthorized project access' });
70
71
  }
71
72
  const updatedProject = await (0, credential_1.deleteCredential)(config, projectId, credentialId);
72
- res.status(200).json({ message: 'Credential deleted successfully', project: updatedProject });
73
+ res.status(200).json({ message: 'Credential deleted successfully', project: (0, sanitize_1.sanitizeProject)(updatedProject) });
73
74
  }
74
75
  catch (err) {
75
76
  res.status(500).json({ message: 'Failed to delete credential', details: err.message });
@@ -6,6 +6,7 @@ const manager_1 = require("../../models/manager");
6
6
  const auth_1 = require("../../utils/auth");
7
7
  const connectionManager_1 = require("../../adapters/database/connectionManager");
8
8
  const sql_1 = require("../../adapters/database/sql");
9
+ const sanitize_1 = require("../../utils/sanitize");
9
10
  function projectRouter(config) {
10
11
  const router = (0, express_1.Router)();
11
12
  const Project = (0, manager_1.getModel)('projects');
@@ -136,7 +137,8 @@ function projectRouter(config) {
136
137
  useConnections: e.useConnections,
137
138
  useCredentials: e.useCredentials,
138
139
  }));
139
- res.json({ project: { ...project, id: project._id || project.id, _id: undefined, apiConnections: project.apiConnections || [], exports }, message: 'Project fetched successfully' });
140
+ const sanitized = (0, sanitize_1.sanitizeProject)({ ...project, id: project._id || project.id, _id: undefined, apiConnections: project.apiConnections || [], exports });
141
+ res.json({ project: sanitized, message: 'Project fetched successfully' });
140
142
  }
141
143
  catch (err) {
142
144
  res.status(500).json({ message: 'Failed to fetch project', details: err.message });
@@ -304,7 +306,7 @@ function projectRouter(config) {
304
306
  if (!updatedProject) {
305
307
  return res.status(404).json({ message: 'Project not found or not updated' });
306
308
  }
307
- res.status(200).json({ success: true, project: { ...updatedProject, id: updatedProject._id || updatedProject.id, _id: undefined }, message: 'Project image updated successfully' });
309
+ res.status(200).json({ success: true, project: (0, sanitize_1.sanitizeProject)({ ...updatedProject, id: updatedProject._id || updatedProject.id, _id: undefined }), message: 'Project image updated successfully' });
308
310
  }
309
311
  catch (err) {
310
312
  res.status(500).json({ message: 'Failed to update project image', details: err.message });
@@ -329,7 +331,7 @@ function projectRouter(config) {
329
331
  if (!updated) {
330
332
  return res.status(404).json({ message: 'Project not found or not updated' });
331
333
  }
332
- res.status(200).json({ success: true, project: updated, message: 'Project origins updated successfully' });
334
+ res.status(200).json({ success: true, project: (0, sanitize_1.sanitizeProject)(updated), message: 'Project origins updated successfully' });
333
335
  }
334
336
  catch (err) {
335
337
  res.status(500).json({ message: 'Failed to update project origins', details: err.message });
@@ -35,7 +35,9 @@ function initWsHub(wss, config) {
35
35
  connections.delete(userId);
36
36
  });
37
37
  try {
38
- ws.send(JSON.stringify({ type: 'connected', userId }));
38
+ const payload = JSON.stringify({ type: 'connected', userId });
39
+ console.log(`📤 WS sending to ${userId}:`, payload);
40
+ ws.send(payload, { binary: false });
39
41
  }
40
42
  catch (err) {
41
43
  console.error(`❌ WS send error for user ${userId}:`, err);
@@ -49,6 +51,6 @@ function emitToUser(userId, event) {
49
51
  const payload = JSON.stringify(event);
50
52
  for (const ws of userConnections) {
51
53
  if (ws.readyState === ws_1.WebSocket.OPEN)
52
- ws.send(payload);
54
+ ws.send(payload, { binary: false });
53
55
  }
54
56
  }
@@ -0,0 +1 @@
1
+ export declare function sanitizeProject(project: any): any;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sanitizeProject = sanitizeProject;
4
+ function sanitizeProject(project) {
5
+ if (!project)
6
+ return project;
7
+ return {
8
+ ...project,
9
+ credentials: project.credentials?.map(({ id, key }) => ({ id, key })) ?? [],
10
+ };
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamby-core",
3
- "version": "0.26.8",
3
+ "version": "0.26.10",
4
4
  "description": "StreamBy middleware framework for media storage management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",