@flowfuse/nr-launcher 3.2.1-d73caad-202610261159.0 → 3.3.0

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,3 +1,31 @@
1
+ #### 3.3.0: Release
2
+
3
+ - chore: bump @flowfuse/nr-mqtt-nodes to ^0.4.2 (#683)
4
+ - Bump hono from 4.13.13 to 4.13.18 (#675)
5
+ - Bump @flowfuse/nr-project-nodes from 0.7.9 to 1.0.0 (#679)
6
+ - Bump @flowfuse/nr-assistant from 0.21.0 to 0.22.0 (#681)
7
+ - Serialize instance settings values in settings.js (#677)
8
+ - Bump fast-xml-parser and @aws-sdk/xml-builder (#674)
9
+ - Bump globals from 17.13.0 to 17.14.0 in the dev-dependencies group (#671)
10
+ - Bump the dev-dependencies group across 1 directory with 4 updates (#667)
11
+ - Bump body-parser from 1.20.9 to 2.4.0 (#659)
12
+ - Bump express from 4.22.3 to 5.3.0 (#665)
13
+ - Bump sinon from 17.0.1 to 22.1.0 (#663)
14
+ - Bump oauth from 0.9.15 to 0.10.2 (#661)
15
+ - Bump passport from 0.6.0 to 0.7.0 (#660)
16
+ - Guard `request.body` for body-parser upgrade (#666)
17
+ - Bump globals from 16.5.0 to 17.13.0 (#658)
18
+ - Bump command-line-args from 5.2.1 to 6.0.2 (#656)
19
+ - Bump ws from 8.21.0 to 8.22.0 (#655)
20
+ - Bump express-session from 1.18.2 to 1.19.0 (#654)
21
+ - chore: Group dev dependabot (#647)
22
+ - Bump multer from 2.4.0 to 2.5.0 (#648)
23
+ - Bump body-parser (#652)
24
+ - Bump ip-address from 10.7.2 to 10.7.5 (#651)
25
+ - Bump serialize-javascript from 7.1.2 to 7.1.4 (#649)
26
+ - Bump fast-uri (#650)
27
+ - Bump hono from 4.13.7 to 4.13.13 (#644)
28
+
1
29
  #### 3.2.0: Release
2
30
 
3
31
  - chore: bump @flowfuse/nr-assistant to ^0.21.0 (#643)
package/lib/admin.js CHANGED
@@ -129,13 +129,14 @@ class AdminInterface {
129
129
  })
130
130
 
131
131
  app.post('/flowforge/command', async (request, response) => {
132
- if (request.body.cmd === 'stop') {
132
+ const body = request.body || {}
133
+ if (body.cmd === 'stop') {
133
134
  launcher.stop()
134
135
  response.send({})
135
136
  // } else {
136
137
  // response.status(409).send({err: "Not running"})
137
138
  // }
138
- } else if (request.body.cmd === 'restart') {
139
+ } else if (body.cmd === 'restart') {
139
140
  if (launcher.state === States.RUNNING ||
140
141
  launcher.state === States.CRASHED ||
141
142
  launcher.state === States.SAFE
@@ -145,7 +146,7 @@ class AdminInterface {
145
146
  // Update the settings
146
147
  try {
147
148
  await launcher.loadSettings()
148
- await launcher.start(request.body.safe ? States.SAFE : States.RUNNING)
149
+ await launcher.start(body.safe ? States.SAFE : States.RUNNING)
149
150
  } catch (error) {
150
151
  await launcher.logAuditEvent('start-failed', { error })
151
152
  return response.status(500).send({ error: error.message })
@@ -155,7 +156,7 @@ class AdminInterface {
155
156
  } else if (launcher.state === States.STOPPED) {
156
157
  try {
157
158
  await launcher.loadSettings()
158
- await launcher.start(request.body.safe ? States.SAFE : States.RUNNING)
159
+ await launcher.start(body.safe ? States.SAFE : States.RUNNING)
159
160
  } catch (error) {
160
161
  await launcher.logAuditEvent('start-failed', { error })
161
162
  return response.status(500).send({ error: error.message })
@@ -165,13 +166,13 @@ class AdminInterface {
165
166
  // Might need a different response
166
167
  response.send({})
167
168
  }
168
- } else if (request.body.cmd === 'start') {
169
+ } else if (body.cmd === 'start') {
169
170
  if (launcher.getState() === States.RUNNING) {
170
171
  response.status(409).send({ err: 'Already running' })
171
172
  } else {
172
173
  try {
173
174
  await launcher.loadSettings()
174
- await launcher.start(request.body.safe ? States.SAFE : States.RUNNING)
175
+ await launcher.start(body.safe ? States.SAFE : States.RUNNING)
175
176
  } catch (error) {
176
177
  // delay error audit entry to allow the start command to return and be logged first
177
178
  setTimeout(() => {
@@ -180,35 +181,35 @@ class AdminInterface {
180
181
  }
181
182
  response.send({})
182
183
  }
183
- } else if (request.body.cmd === 'logout') { // logout:nodered(step-4)
184
- await launcher.revokeUserToken(request.body.token) // logout:nodered(step-5)
184
+ } else if (body.cmd === 'logout') { // logout:nodered(step-4)
185
+ await launcher.revokeUserToken(body.token) // logout:nodered(step-5)
185
186
  response.send({})
186
- } else if (request.body.cmd === 'shutdown') {
187
+ } else if (body.cmd === 'shutdown') {
187
188
  await launcher.stop()
188
189
  response.send({})
189
190
  process.exit(0)
190
- } else if (request.body.cmd === 'mcp:get-features') {
191
+ } else if (body.cmd === 'mcp:get-features') {
191
192
  // MCP ROUTE: step 5 (hosted)
192
193
  // Called By: driver (localfs/k8s/docker)
193
194
  // Calls To : ./launcher.js helper functions
194
195
  try {
195
- const { endpoints } = request.body?.data || {}
196
+ const { endpoints } = body.data || {}
196
197
  const features = await launcher.getMCPFeatures(endpoints)
197
198
  response.send(features)
198
199
  } catch (error) {
199
200
  response.status(500).send({ err: error.message })
200
201
  }
201
- } else if (request.body.cmd === 'mcp:call-tool') {
202
+ } else if (body.cmd === 'mcp:call-tool') {
202
203
  try {
203
- const { endpoint, name, input } = request.body?.data || {}
204
+ const { endpoint, name, input } = body.data || {}
204
205
  const result = await launcher.callMCPTool(endpoint, name, input)
205
206
  response.send(result)
206
207
  } catch (error) {
207
208
  response.status(500).send({ err: error.message })
208
209
  }
209
- } else if (request.body.cmd === 'mcp:read-resource') {
210
+ } else if (body.cmd === 'mcp:read-resource') {
210
211
  try {
211
- const { endpoint, uri } = request.body?.data || {}
212
+ const { endpoint, uri } = body.data || {}
212
213
  const result = await launcher.readMCPResource(endpoint, uri)
213
214
  response.send(result)
214
215
  } catch (error) {
@@ -11,7 +11,7 @@ function getSettingsFile (settings) {
11
11
  page_title: 'FlowFuse',
12
12
  page_favicon: '',
13
13
  header_title: 'FlowFuse',
14
- header_url: `url: '${settings.forgeURL}/instance/${settings.projectID}'`,
14
+ header_url: `${settings.forgeURL}/instance/${settings.projectID}`,
15
15
  palette: {
16
16
  allowInstall: true,
17
17
  nodesExcludes: [],
@@ -62,12 +62,12 @@ function getSettingsFile (settings) {
62
62
  projectSettings.credentialSecret = `credentialSecret: '${settings.credentialSecret}',`
63
63
  }
64
64
  if (settings.settings.httpAdminRoot !== undefined) {
65
- projectSettings.httpAdminRoot = `httpAdminRoot: '${settings.settings.httpAdminRoot}',`
65
+ projectSettings.httpAdminRoot = `httpAdminRoot: ${JSON.stringify(settings.settings.httpAdminRoot)},`
66
66
  }
67
67
  if (settings.settings.dashboardUI !== undefined || authMiddlewareRequired) {
68
68
  const dashboardSettings = []
69
69
  if (settings.settings.dashboardUI !== undefined) {
70
- dashboardSettings.push(`path: '${settings.settings.dashboardUI}'`)
70
+ dashboardSettings.push(`path: ${JSON.stringify(settings.settings.dashboardUI)}`)
71
71
  }
72
72
  const middlewares = []
73
73
  if (authMiddlewareRequired) {
@@ -89,7 +89,7 @@ function getSettingsFile (settings) {
89
89
  projectSettings.dashboardUI = `ui: { ${dashboardSettings.join(', ')}},`
90
90
  }
91
91
  if (settings.settings.disableEditor !== undefined) {
92
- projectSettings.disableEditor = `disableEditor: ${settings.settings.disableEditor},`
92
+ projectSettings.disableEditor = `disableEditor: ${settings.settings.disableEditor === true},`
93
93
  }
94
94
  if (settings.settings.ha?.replicas >= 2) {
95
95
  projectSettings.disableEditor = 'disableEditor: true,'
@@ -109,7 +109,7 @@ function getSettingsFile (settings) {
109
109
  }
110
110
  projectSettings.page_favicon = 'favicon: "/theme/css/favicon.ico",' // TODO: get from theme
111
111
  if (settings.settings.page?.favicon) {
112
- projectSettings.page_favicon = `favicon: "${settings.settings.page.favicon}",`
112
+ projectSettings.page_favicon = `favicon: ${JSON.stringify(settings.settings.page.favicon)},`
113
113
  }
114
114
  if (settings.settings.header?.title) {
115
115
  projectSettings.header_title = settings.settings.header.title
@@ -148,10 +148,10 @@ function getSettingsFile (settings) {
148
148
  projectSettings.tours = false
149
149
  }
150
150
  if (settings.settings.apiMaxLength) {
151
- projectSettings.apiMaxLength = `apiMaxLength: "${settings.settings.apiMaxLength}",`
151
+ projectSettings.apiMaxLength = `apiMaxLength: ${JSON.stringify(settings.settings.apiMaxLength)},`
152
152
  }
153
- if (settings.settings.debugMaxLength) {
154
- projectSettings.debugMaxLength = `debugMaxLength: ${settings.settings.debugMaxLength},`
153
+ if (Number.isInteger(Number(settings.settings.debugMaxLength)) && settings.settings.debugMaxLength) {
154
+ projectSettings.debugMaxLength = `debugMaxLength: ${Number(settings.settings.debugMaxLength)},`
155
155
  }
156
156
 
157
157
  if (settings.settings.httpNodeCORS?.enabled) {
@@ -162,7 +162,7 @@ function getSettingsFile (settings) {
162
162
  methods.push(m)
163
163
  }
164
164
  })
165
- projectSettings.httpNodeCors = `httpNodeCors: { origin: "${settings.settings.httpNodeCORS.origin}", methods: "${methods.join(',')}"},`
165
+ projectSettings.httpNodeCors = `httpNodeCors: { origin: ${JSON.stringify(settings.settings.httpNodeCORS.origin)}, methods: ${JSON.stringify(methods.join(','))}},`
166
166
  }
167
167
  }
168
168
 
@@ -298,8 +298,8 @@ function getSettingsFile (settings) {
298
298
  activeTheme = 'forge-light'
299
299
  }
300
300
 
301
- projectSettings.themeSettings = `"${activeTheme}": ${JSON.stringify(ffSettings)},`
302
- projectSettings.theme = `theme: '${activeTheme}',`
301
+ projectSettings.themeSettings = `${JSON.stringify(activeTheme)}: ${JSON.stringify(ffSettings)},`
302
+ projectSettings.theme = `theme: ${JSON.stringify(activeTheme)},`
303
303
  }
304
304
 
305
305
  let nodesDir = ''
@@ -441,19 +441,19 @@ module.exports = {
441
441
  editorTheme: {
442
442
  ${projectSettings.theme}
443
443
  page: {
444
- title: '${projectSettings.page_title}',
444
+ title: ${JSON.stringify(projectSettings.page_title)},
445
445
  ${projectSettings.page_scripts || ''}
446
446
  ${projectSettings.page_favicon}
447
447
  },
448
448
  header: {
449
- title: '${projectSettings.header_title}',
450
- ${projectSettings.header_url}
449
+ title: ${JSON.stringify(projectSettings.header_title)},
450
+ url: ${JSON.stringify(projectSettings.header_url)},
451
451
  },
452
452
  logout: {
453
453
  redirect: '${settings.forgeURL}/instance/${settings.projectID}'
454
454
  },
455
455
  codeEditor: {
456
- lib: '${projectSettings.codeEditor}'
456
+ lib: ${JSON.stringify(projectSettings.codeEditor)}
457
457
  },
458
458
  ${projectSettings.libraries}
459
459
  tours: ${projectSettings.tours},
@@ -468,18 +468,18 @@ module.exports = {
468
468
  externalModules: {
469
469
  // autoInstall: true,
470
470
  palette: {
471
- allowInstall: ${projectSettings.palette.allowInstall},
471
+ allowInstall: ${projectSettings.palette.allowInstall === true},
472
472
  allowUpload: false,
473
473
  denyList: ${JSON.stringify(projectSettings.palette.denyList)},
474
474
  allowList: ${JSON.stringify(projectSettings.palette.allowList)}
475
475
  },
476
476
  modules: {
477
- allowInstall: ${projectSettings.modules.allowInstall},
477
+ allowInstall: ${projectSettings.modules.allowInstall === true},
478
478
  denyList: ${JSON.stringify(projectSettings.modules.denyList)},
479
479
  allowList: ${JSON.stringify(projectSettings.modules.allowList)}
480
480
  }
481
481
  },
482
- functionExternalModules: ${projectSettings.modules.allowInstall},
482
+ functionExternalModules: ${projectSettings.modules.allowInstall === true},
483
483
  flowforge: {
484
484
  forgeURL: '${settings.forgeURL}',
485
485
  teamID: '${settings.teamID}',