@flowfuse/nr-launcher 2.33.3-d4a4590-202608060916.0 → 3.0.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,6 @@
1
+ #### 3.0.0: Release
2
+
3
+
1
4
  #### 2.33.2: Release
2
5
 
3
6
  - Bump brace-expansion (#597)
@@ -11,6 +11,12 @@ let httpNodeApp
11
11
  let client
12
12
  const httpTokenCache = {}
13
13
 
14
+ function deriveSessionSecret (credentialSecret) {
15
+ return credentialSecret
16
+ ? crypto.createHmac('sha256', credentialSecret).update('nr-launcher:httpAuth:session').digest('hex')
17
+ : crypto.randomBytes(20).toString('hex')
18
+ }
19
+
14
20
  module.exports = {
15
21
  init (_options) {
16
22
  options = _options
@@ -79,9 +85,7 @@ module.exports = {
79
85
 
80
86
  const crossSiteCookie = (options.baseURL || '').startsWith('https://')
81
87
  httpNodeApp.use(session({
82
- // As the session is only used across the life-span of an auth
83
- // hand-shake, we can use a instance specific random string
84
- secret: crypto.randomBytes(20).toString('hex'),
88
+ secret: deriveSessionSecret(options.credentialSecret),
85
89
  resave: false,
86
90
  saveUninitialized: false,
87
91
  store: new MemoryStore({
@@ -140,5 +144,7 @@ module.exports = {
140
144
  request: 500
141
145
  }
142
146
  })
143
- }
147
+ },
148
+
149
+ deriveSessionSecret
144
150
  }
@@ -53,7 +53,8 @@ function getSettingsFile (settings) {
53
53
  clientID: '${settings.clientID}',
54
54
  clientSecret: '${settings.clientSecret}',
55
55
  teamID: '${settings.teamID}',
56
- projectId: '${settings.projectID}'
56
+ projectId: '${settings.projectID}',
57
+ credentialSecret: '${settings.credentialSecret || ''}'
57
58
  })`
58
59
  projectSettings.httpNodeMiddleware = 'httpNodeMiddleware: flowforgeAuthMiddleware,'
59
60
  }