mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
center: support node18 crypto
This commit is contained in:
1 parent
e32f285876
commit
067eb2c348
2 files changed
+11
-7
No files matched your search
@@ -1,15 +1,15 @@
|
||||
import assert from 'assert';
|
||||
import crypto from 'crypto';
|
||||
import crypto from 'crypto-js';
|
||||
import {
|
||||
db, definePlugin, ForbiddenError, Handler, post, Types, yaml,
|
||||
} from 'hydrooj';
|
||||
|
||||
function decrypt(encrypted: string) {
|
||||
if (!encrypted) throw new Error();
|
||||
const decipher = crypto.createDecipheriv('des-ecb', 'hydro-oj', '');
|
||||
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
|
||||
decrypted += decipher.final('utf8');
|
||||
return decrypted;
|
||||
return crypto.DES.decrypt(
|
||||
{ ciphertext: crypto.enc.Hex.parse(encrypted) },
|
||||
crypto.enc.Utf8.parse('hydro-oj'),
|
||||
{ mode: crypto.mode.ECB },
|
||||
).toString(crypto.enc.Utf8);
|
||||
}
|
||||
|
||||
declare module 'hydrooj' {
|
||||
@@ -38,6 +38,7 @@ class DataReportHandler extends Handler {
|
||||
try {
|
||||
assert(typeof payload.url === 'string');
|
||||
} catch (e) {
|
||||
console.log(payload);
|
||||
throw new ForbiddenError();
|
||||
}
|
||||
const old = await coll.findOne({ _id: installId });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/center",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"main": "index.ts",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
@@ -8,5 +8,8 @@
|
||||
"preferUnplugged": true,
|
||||
"peerDependencies": {
|
||||
"hydrooj": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"crypto-js": "^4.1.1"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user