qyani-web 1.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/README.md +14 -0
- package/index.js +4 -0
- package/keys/cert.pem +19 -0
- package/keys/key.pem +27 -0
- package/package.json +25 -0
- package/src/config/type.ts +44 -0
- package/src/controllers/index.ts +93 -0
- package/src/index.ts +20 -0
- package/src/lib/GroupRoute.ts +153 -0
- package/src/lib/app.ts +232 -0
- package/src/lib/middleware/body-parser.ts +175 -0
- package/src/lib/middleware/cors.ts +64 -0
- package/src/lib/middleware/logger.ts +95 -0
- package/src/lib/middleware/static-resources.ts +94 -0
- package/src/lib/middleware/validate.ts +169 -0
- package/src/public/html/index.html +11 -0
- package/src/public/test.mp4 +0 -0
- package/src/routes/index.ts +51 -0
- package/src/utils/certs.ts +11 -0
- package/src/utils/tsl.ts +44 -0
- package/tsconfig.json +15 -0
package/src/utils/tsl.ts
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
// const forge = import('node-forge');
|
2
|
+
// const fs = import('fs');
|
3
|
+
//
|
4
|
+
// // 生成密钥对
|
5
|
+
// const keys = forge.pki.rsa.generateKeyPair(2048);
|
6
|
+
//
|
7
|
+
// // 创建证书
|
8
|
+
// const cert = forge.pki.createCertificate();
|
9
|
+
// cert.publicKey = keys.publicKey;
|
10
|
+
// cert.serialNumber = '01';
|
11
|
+
// cert.validity.notBefore = new Date();
|
12
|
+
// cert.validity.notAfter = new Date();
|
13
|
+
// cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 1);
|
14
|
+
//
|
15
|
+
// // 设置主题和颁发者信息
|
16
|
+
// const attrs = [{
|
17
|
+
// name: 'commonName',
|
18
|
+
// value: 'localhost'
|
19
|
+
// }, {
|
20
|
+
// name: 'countryName',
|
21
|
+
// value: 'CN'
|
22
|
+
// }, {
|
23
|
+
// name: 'organizationName',
|
24
|
+
// value: 'Qianrenni'
|
25
|
+
// }, {
|
26
|
+
// name: 'organizationalUnitName',
|
27
|
+
// value: 'Development'
|
28
|
+
// }];
|
29
|
+
//
|
30
|
+
// cert.setSubject(attrs);
|
31
|
+
// cert.setIssuer(attrs); // 通常自签名证书 issuer == subject
|
32
|
+
// cert.sign(keys.privateKey, forge.md.sha256.create()); // ✅ 正确的方法
|
33
|
+
//
|
34
|
+
// // 转换为 PEM 格式
|
35
|
+
// const pem = {
|
36
|
+
// key: forge.pki.privateKeyToPem(keys.privateKey),
|
37
|
+
// cert: forge.pki.certificateToPem(cert)
|
38
|
+
// };
|
39
|
+
//
|
40
|
+
// // 写入文件
|
41
|
+
// fs.writeFileSync('key.pem', pem.key);
|
42
|
+
// fs.writeFileSync('cert.pem', pem.cert);
|
43
|
+
//
|
44
|
+
// console.log('✅ 私钥和证书已生成:key.pem 和 cert.pem');
|
package/tsconfig.json
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "ES2020",
|
4
|
+
"module": "ESNext",
|
5
|
+
"esModuleInterop": true,
|
6
|
+
"strict": true,
|
7
|
+
"outDir": "./dist",
|
8
|
+
"rootDir": "./src",
|
9
|
+
"moduleResolution": "node",
|
10
|
+
"resolveJsonModule": true,
|
11
|
+
"skipLibCheck": false,
|
12
|
+
"allowJs": true,
|
13
|
+
},
|
14
|
+
"include": ["src/**/*"]
|
15
|
+
}
|