We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c482cef + 79887d1 commit a8f0520Copy full SHA for a8f0520
src/services/session_secret.ts
@@ -1,24 +1,18 @@
1
"use strict";
2
3
import fs from "fs";
4
-import crypto from "crypto";
5
import dataDir from "./data_dir.js";
6
import log from "./log.js";
+import utils from "./utils.js"
7
8
const sessionSecretPath = `${dataDir.TRILIUM_DATA_DIR}/session_secret.txt`;
9
10
let sessionSecret: string;
11
12
const ENCODING = "ascii";
13
14
-function randomValueHex(len: number) {
15
- return crypto.randomBytes(Math.ceil(len / 2))
16
- .toString('hex') // convert to hexadecimal format
17
- .slice(0, len).toUpperCase(); // return required number of characters
18
-}
19
-
20
if (!fs.existsSync(sessionSecretPath)) {
21
- sessionSecret = randomValueHex(64);
+ sessionSecret = utils.randomSecureToken(64).slice(0, 64);
22
23
log.info("Generated session secret");
24
0 commit comments