switch to crypto lib

This commit is contained in:
Karl-Johan Alm
2024-11-19 21:39:35 +09:00
parent f25ea9f6d6
commit c2eaae3d42
3 changed files with 2 additions and 10 deletions

7
package-lock.json generated
View File

@@ -43,7 +43,6 @@
"ip-matching": "^2.1.2", "ip-matching": "^2.1.2",
"ipaddr.js": "^2.0.1", "ipaddr.js": "^2.0.1",
"jimp": "^0.22.10", "jimp": "^0.22.10",
"js-sha256": "^0.11.0",
"localforage": "^1.10.0", "localforage": "^1.10.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mime-types": "^2.1.35", "mime-types": "^2.1.35",
@@ -4883,12 +4882,6 @@
"integrity": "sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==", "integrity": "sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==",
"license": "BSD-3-Clause" "license": "BSD-3-Clause"
}, },
"node_modules/js-sha256": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.11.0.tgz",
"integrity": "sha512-6xNlKayMZvds9h1Y1VWc0fQHQ82BxTXizWPEtEeGvmOUYpBRy4gbWroHLpzowe6xiQhHpelCQiE7HEdznyBL9Q==",
"license": "MIT"
},
"node_modules/js-yaml": { "node_modules/js-yaml": {
"version": "4.1.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",

View File

@@ -33,7 +33,6 @@
"ip-matching": "^2.1.2", "ip-matching": "^2.1.2",
"ipaddr.js": "^2.0.1", "ipaddr.js": "^2.0.1",
"jimp": "^0.22.10", "jimp": "^0.22.10",
"js-sha256": "^0.11.0",
"localforage": "^1.10.0", "localforage": "^1.10.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mime-types": "^2.1.35", "mime-types": "^2.1.35",

View File

@@ -16,7 +16,7 @@ import {
} from '../../constants.js'; } from '../../constants.js';
import { forwardFetchResponse, trimV1, getConfigValue } from '../../util.js'; import { forwardFetchResponse, trimV1, getConfigValue } from '../../util.js';
import { setAdditionalHeaders } from '../../additional-headers.js'; import { setAdditionalHeaders } from '../../additional-headers.js';
import { sha256 } from 'js-sha256'; import { createHash } from 'crypto';
export const router = express.Router(); export const router = express.Router();
@@ -261,7 +261,7 @@ router.post('/chat_template', jsonParser, async function (request, response) {
/** @type {any} */ /** @type {any} */
const chatTemplate = await chatTemplateReply.json(); const chatTemplate = await chatTemplateReply.json();
chatTemplate['chat_template_hash'] = sha256.create().update(chatTemplate['chat_template']).hex(); chatTemplate['chat_template_hash'] = createHash('sha256').update(chatTemplate['chat_template']).digest('hex');
return response.send(chatTemplate); return response.send(chatTemplate);
} catch (error) { } catch (error) {
console.error(error); console.error(error);