@twin.org/node-core 0.0.1-next.6 → 0.0.1-next.7

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.
@@ -308,10 +308,10 @@ async function bootstrapNodeUser(engineCore, context, envVars, features) {
308
308
  const authUserEntityStorage = entityStorageModels.EntityStorageConnectorFactory.get(core.StringHelper.kebabCase("AuthenticationUser"));
309
309
  const email = envVars.username ?? DEFAULT_NODE_USERNAME;
310
310
  let nodeAdminUser = await authUserEntityStorage.get(email);
311
- const generatedPassword = envVars.password ?? crypto.PasswordGenerator.generate(16);
312
- const passwordBytes = core.Converter.utf8ToBytes(generatedPassword);
313
311
  if (core.Is.empty(nodeAdminUser)) {
314
312
  engineCore.logInfo(core.I18n.formatMessage("node.creatingNodeUser"));
313
+ const generatedPassword = envVars.password ?? crypto.PasswordGenerator.generate(16);
314
+ const passwordBytes = core.Converter.utf8ToBytes(generatedPassword);
315
315
  const saltBytes = core.RandomHelper.generate(16);
316
316
  const hashedPassword = await apiAuthEntityStorageService.PasswordHelper.hashPassword(passwordBytes, saltBytes);
317
317
  nodeAdminUser = {
@@ -327,12 +327,21 @@ async function bootstrapNodeUser(engineCore, context, envVars, features) {
327
327
  else {
328
328
  engineCore.logInfo(core.I18n.formatMessage("node.existingNodeUser"));
329
329
  // The user already exists, so double check the other details match
330
- const saltBytes = core.Converter.base64ToBytes(nodeAdminUser.salt);
331
- const hashedPassword = await apiAuthEntityStorageService.PasswordHelper.hashPassword(passwordBytes, saltBytes);
332
- if (nodeAdminUser.identity !== context.state.nodeIdentity ||
333
- nodeAdminUser.password !== hashedPassword) {
334
- nodeAdminUser.password = hashedPassword;
330
+ let needsUpdate = false;
331
+ if (nodeAdminUser.identity !== context.state.nodeIdentity) {
335
332
  nodeAdminUser.identity = context.state.nodeIdentity;
333
+ needsUpdate = true;
334
+ }
335
+ if (core.Is.stringValue(envVars.password)) {
336
+ const passwordBytes = core.Converter.utf8ToBytes(envVars.password);
337
+ const saltBytes = core.Converter.base64ToBytes(nodeAdminUser.salt);
338
+ const hashedPassword = await apiAuthEntityStorageService.PasswordHelper.hashPassword(passwordBytes, saltBytes);
339
+ if (nodeAdminUser.password !== hashedPassword) {
340
+ nodeAdminUser.password = hashedPassword;
341
+ needsUpdate = true;
342
+ }
343
+ }
344
+ if (needsUpdate) {
336
345
  await authUserEntityStorage.set(nodeAdminUser);
337
346
  }
338
347
  }
@@ -559,7 +568,7 @@ async function run(options) {
559
568
  try {
560
569
  const serverInfo = {
561
570
  name: options?.serverName ?? "TWIN Node Server",
562
- version: options?.serverVersion ?? "0.0.1-next.6" // x-release-please-version
571
+ version: options?.serverVersion ?? "0.0.1-next.7" // x-release-please-version
563
572
  };
564
573
  console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
565
574
  const executionDirectory = options?.executionDirectory ?? getExecutionDirectory();
@@ -287,10 +287,10 @@ async function bootstrapNodeUser(engineCore, context, envVars, features) {
287
287
  const authUserEntityStorage = EntityStorageConnectorFactory.get(StringHelper.kebabCase("AuthenticationUser"));
288
288
  const email = envVars.username ?? DEFAULT_NODE_USERNAME;
289
289
  let nodeAdminUser = await authUserEntityStorage.get(email);
290
- const generatedPassword = envVars.password ?? PasswordGenerator.generate(16);
291
- const passwordBytes = Converter.utf8ToBytes(generatedPassword);
292
290
  if (Is.empty(nodeAdminUser)) {
293
291
  engineCore.logInfo(I18n.formatMessage("node.creatingNodeUser"));
292
+ const generatedPassword = envVars.password ?? PasswordGenerator.generate(16);
293
+ const passwordBytes = Converter.utf8ToBytes(generatedPassword);
294
294
  const saltBytes = RandomHelper.generate(16);
295
295
  const hashedPassword = await PasswordHelper.hashPassword(passwordBytes, saltBytes);
296
296
  nodeAdminUser = {
@@ -306,12 +306,21 @@ async function bootstrapNodeUser(engineCore, context, envVars, features) {
306
306
  else {
307
307
  engineCore.logInfo(I18n.formatMessage("node.existingNodeUser"));
308
308
  // The user already exists, so double check the other details match
309
- const saltBytes = Converter.base64ToBytes(nodeAdminUser.salt);
310
- const hashedPassword = await PasswordHelper.hashPassword(passwordBytes, saltBytes);
311
- if (nodeAdminUser.identity !== context.state.nodeIdentity ||
312
- nodeAdminUser.password !== hashedPassword) {
313
- nodeAdminUser.password = hashedPassword;
309
+ let needsUpdate = false;
310
+ if (nodeAdminUser.identity !== context.state.nodeIdentity) {
314
311
  nodeAdminUser.identity = context.state.nodeIdentity;
312
+ needsUpdate = true;
313
+ }
314
+ if (Is.stringValue(envVars.password)) {
315
+ const passwordBytes = Converter.utf8ToBytes(envVars.password);
316
+ const saltBytes = Converter.base64ToBytes(nodeAdminUser.salt);
317
+ const hashedPassword = await PasswordHelper.hashPassword(passwordBytes, saltBytes);
318
+ if (nodeAdminUser.password !== hashedPassword) {
319
+ nodeAdminUser.password = hashedPassword;
320
+ needsUpdate = true;
321
+ }
322
+ }
323
+ if (needsUpdate) {
315
324
  await authUserEntityStorage.set(nodeAdminUser);
316
325
  }
317
326
  }
@@ -538,7 +547,7 @@ async function run(options) {
538
547
  try {
539
548
  const serverInfo = {
540
549
  name: options?.serverName ?? "TWIN Node Server",
541
- version: options?.serverVersion ?? "0.0.1-next.6" // x-release-please-version
550
+ version: options?.serverVersion ?? "0.0.1-next.7" // x-release-please-version
542
551
  };
543
552
  console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
544
553
  const executionDirectory = options?.executionDirectory ?? getExecutionDirectory();
package/docs/changelog.md CHANGED
@@ -1,22 +1,29 @@
1
1
  # @twin.org/node-core - Changelog
2
2
 
3
- ## [0.0.1-next.6](https://github.com/twinfoundation/node/compare/node-core-v0.0.1-next.5...node-core-v0.0.1-next.6) (2025-06-12)
3
+ ## [0.0.1-next.7](https://github.com/twinfoundation/node/compare/node-core-v0.0.1-next.6...node-core-v0.0.1-next.7) (2025-06-17)
4
4
 
5
5
 
6
- ### Features
6
+ ### Bug Fixes
7
7
 
8
- * add extend engine and server methods ([ec09c7e](https://github.com/twinfoundation/node/commit/ec09c7eb882d9f5797f2fd372e96cad1a3716f59))
9
- * add extend engine and server methods ([0136a6f](https://github.com/twinfoundation/node/commit/0136a6f3f4e1a82b1427ee9618b8a17c79bc7fda))
10
- * additional run options ([c35e5bb](https://github.com/twinfoundation/node/commit/c35e5bbb8a80fe6a36628d41f64585b3723d9ad7))
11
- * improve error reporting ([fcd39a1](https://github.com/twinfoundation/node/commit/fcd39a18da2a6ce33965a99ca5f2f36f4aba712f))
12
- * initial commit ([522f1e5](https://github.com/twinfoundation/node/commit/522f1e515348f9b1dd1eeb3170b1249e2b0b5371))
13
- * node app use JavaScript ([14fe08c](https://github.com/twinfoundation/node/commit/14fe08cb760dd885a5dac9056a4d5dbc3d61df64))
14
- * update dependencies ([9d25f16](https://github.com/twinfoundation/node/commit/9d25f16f1d554cd38f3bec28fdf7f8fff892ceaf))
8
+ * adding a condition to verify if the password exists when bootstrapping ([6030a42](https://github.com/twinfoundation/node/commit/6030a42bdaf581678d96932fd0b809396bf7b8b0))
9
+ * adding a condition to verify if the password exists when bootstrapping ([c66f396](https://github.com/twinfoundation/node/commit/c66f396717394161a7647d1f08b3d87729d96e96))
10
+ * pr comments [#1](https://github.com/twinfoundation/node/issues/1) ([66e795b](https://github.com/twinfoundation/node/commit/66e795b16c372ab131ec1de30085aee90e4dbbd0))
15
11
 
12
+ ## [0.0.1-next.6](https://github.com/twinfoundation/node/compare/node-core-v0.0.1-next.5...node-core-v0.0.1-next.6) (2025-06-12)
13
+
14
+ ### Features
15
+
16
+ - add extend engine and server methods ([ec09c7e](https://github.com/twinfoundation/node/commit/ec09c7eb882d9f5797f2fd372e96cad1a3716f59))
17
+ - add extend engine and server methods ([0136a6f](https://github.com/twinfoundation/node/commit/0136a6f3f4e1a82b1427ee9618b8a17c79bc7fda))
18
+ - additional run options ([c35e5bb](https://github.com/twinfoundation/node/commit/c35e5bbb8a80fe6a36628d41f64585b3723d9ad7))
19
+ - improve error reporting ([fcd39a1](https://github.com/twinfoundation/node/commit/fcd39a18da2a6ce33965a99ca5f2f36f4aba712f))
20
+ - initial commit ([522f1e5](https://github.com/twinfoundation/node/commit/522f1e515348f9b1dd1eeb3170b1249e2b0b5371))
21
+ - node app use JavaScript ([14fe08c](https://github.com/twinfoundation/node/commit/14fe08cb760dd885a5dac9056a4d5dbc3d61df64))
22
+ - update dependencies ([9d25f16](https://github.com/twinfoundation/node/commit/9d25f16f1d554cd38f3bec28fdf7f8fff892ceaf))
16
23
 
17
24
  ### Bug Fixes
18
25
 
19
- * broken docs ([61479fd](https://github.com/twinfoundation/node/commit/61479fd618f766d22c5aafec5277e1a89e22b453))
26
+ - broken docs ([61479fd](https://github.com/twinfoundation/node/commit/61479fd618f766d22c5aafec5277e1a89e22b453))
20
27
 
21
28
  ## [0.0.1-next.5](https://github.com/twinfoundation/node/compare/node-core-v0.0.1-next.4...node-core-v0.0.1-next.5) (2025-06-12)
22
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/node-core",
3
- "version": "0.0.1-next.6",
3
+ "version": "0.0.1-next.7",
4
4
  "description": "TWIN Node Core for serving APIs using the specified configuration",
5
5
  "repository": {
6
6
  "type": "git",