Compare commits
3 Commits
0be7627bd1
...
ab0ba939d4
| Author | SHA1 | Date | |
|---|---|---|---|
| ab0ba939d4 | |||
| e51cacd7a2 | |||
| 6bf8d86c10 |
34
pnpm-lock.yaml
generated
34
pnpm-lock.yaml
generated
@@ -161,14 +161,14 @@ importers:
|
|||||||
specifier: ^0.0.4
|
specifier: ^0.0.4
|
||||||
version: 0.0.4
|
version: 0.0.4
|
||||||
'@kevisual/query':
|
'@kevisual/query':
|
||||||
specifier: ^0.0.38
|
specifier: ^0.0.39
|
||||||
version: 0.0.38
|
version: 0.0.39
|
||||||
'@kevisual/router':
|
'@kevisual/router':
|
||||||
specifier: 0.0.60
|
specifier: 0.0.70
|
||||||
version: 0.0.60
|
version: 0.0.70
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^25.0.10
|
specifier: ^25.2.1
|
||||||
version: 25.0.10
|
version: 25.2.1
|
||||||
crypto-js:
|
crypto-js:
|
||||||
specifier: ^4.2.0
|
specifier: ^4.2.0
|
||||||
version: 4.2.0
|
version: 4.2.0
|
||||||
@@ -697,9 +697,6 @@ packages:
|
|||||||
'@kevisual/query@0.0.39':
|
'@kevisual/query@0.0.39':
|
||||||
resolution: {integrity: sha512-3UEPBIvtdykNkrby3hvrgrHdgd17Uq+Pnr4zs+JBzATkU2eKaOqtTUJqdyIEwuySCwzGTxrnlUzWP4tziDQDLQ==}
|
resolution: {integrity: sha512-3UEPBIvtdykNkrby3hvrgrHdgd17Uq+Pnr4zs+JBzATkU2eKaOqtTUJqdyIEwuySCwzGTxrnlUzWP4tziDQDLQ==}
|
||||||
|
|
||||||
'@kevisual/router@0.0.60':
|
|
||||||
resolution: {integrity: sha512-2v/ZzUstsaq+Uqo+tZX9ys5E+/2erPggCtljv9jTb3NA88ZdHsYUAsd5wUFvLtf9QucpJCzyWEt+InDV/98FKw==}
|
|
||||||
|
|
||||||
'@kevisual/router@0.0.70':
|
'@kevisual/router@0.0.70':
|
||||||
resolution: {integrity: sha512-vXlIj9jRufhcIfeuPWemjSI+dxdzSmIBq5eRxQzqEfAJ7k+mBPhoI4KxH8vHnwyL30bqm8EdODL/p6Wg8uBw3g==}
|
resolution: {integrity: sha512-vXlIj9jRufhcIfeuPWemjSI+dxdzSmIBq5eRxQzqEfAJ7k+mBPhoI4KxH8vHnwyL30bqm8EdODL/p6Wg8uBw3g==}
|
||||||
|
|
||||||
@@ -1005,9 +1002,6 @@ packages:
|
|||||||
'@types/ms@0.7.34':
|
'@types/ms@0.7.34':
|
||||||
resolution: {integrity: sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==}
|
resolution: {integrity: sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==}
|
||||||
|
|
||||||
'@types/node@25.0.10':
|
|
||||||
resolution: {integrity: sha512-zWW5KPngR/yvakJgGOmZ5vTBemDoSqF3AcV/LrO5u5wTWyEAVVh+IT39G4gtyAkh3CtTZs8aX/yRM82OfzHJRg==}
|
|
||||||
|
|
||||||
'@types/node@25.2.1':
|
'@types/node@25.2.1':
|
||||||
resolution: {integrity: sha512-CPrnr8voK8vC6eEtyRzvMpgp3VyVRhgclonE7qYi6P9sXwYb59ucfrnmFBTaP0yUi8Gk4yZg/LlTJULGxvTNsg==}
|
resolution: {integrity: sha512-CPrnr8voK8vC6eEtyRzvMpgp3VyVRhgclonE7qYi6P9sXwYb59ucfrnmFBTaP0yUi8Gk4yZg/LlTJULGxvTNsg==}
|
||||||
|
|
||||||
@@ -1588,10 +1582,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}
|
resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
hono@4.11.5:
|
|
||||||
resolution: {integrity: sha512-WemPi9/WfyMwZs+ZUXdiwcCh9Y+m7L+8vki9MzDw3jJ+W9Lc+12HGsd368Qc1vZi1xwW8BWMMsnK5efYKPdt4g==}
|
|
||||||
engines: {node: '>=16.9.0'}
|
|
||||||
|
|
||||||
http-errors@2.0.1:
|
http-errors@2.0.1:
|
||||||
resolution: {integrity: sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==}
|
resolution: {integrity: sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==}
|
||||||
engines: {node: '>= 0.8'}
|
engines: {node: '>= 0.8'}
|
||||||
@@ -2998,10 +2988,6 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
tslib: 2.8.1
|
tslib: 2.8.1
|
||||||
|
|
||||||
'@kevisual/router@0.0.60':
|
|
||||||
dependencies:
|
|
||||||
hono: 4.11.5
|
|
||||||
|
|
||||||
'@kevisual/router@0.0.70':
|
'@kevisual/router@0.0.70':
|
||||||
dependencies:
|
dependencies:
|
||||||
es-toolkit: 1.44.0
|
es-toolkit: 1.44.0
|
||||||
@@ -3449,10 +3435,6 @@ snapshots:
|
|||||||
|
|
||||||
'@types/ms@0.7.34': {}
|
'@types/ms@0.7.34': {}
|
||||||
|
|
||||||
'@types/node@25.0.10':
|
|
||||||
dependencies:
|
|
||||||
undici-types: 7.16.0
|
|
||||||
|
|
||||||
'@types/node@25.2.1':
|
'@types/node@25.2.1':
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 7.16.0
|
undici-types: 7.16.0
|
||||||
@@ -3479,7 +3461,7 @@ snapshots:
|
|||||||
|
|
||||||
'@types/xml2js@0.4.14':
|
'@types/xml2js@0.4.14':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 25.0.10
|
'@types/node': 25.2.1
|
||||||
|
|
||||||
abort-controller@3.0.0:
|
abort-controller@3.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -3973,8 +3955,6 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
function-bind: 1.1.2
|
function-bind: 1.1.2
|
||||||
|
|
||||||
hono@4.11.5: {}
|
|
||||||
|
|
||||||
http-errors@2.0.1:
|
http-errors@2.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
depd: 2.0.0
|
depd: 2.0.0
|
||||||
|
|||||||
@@ -1,19 +1,12 @@
|
|||||||
import { useConfig } from '@kevisual/use-config';
|
import { useConfig } from '@kevisual/use-config';
|
||||||
import { useFileStore } from '@kevisual/use-config';
|
import { useFileStore } from '@kevisual/use-config';
|
||||||
import { minioResources } from './s3.ts';
|
import { minioResources } from './s3.ts';
|
||||||
|
import { proxyDomain } from './domain.ts';
|
||||||
|
|
||||||
export const config = useConfig() as any;
|
export const config = useConfig() as any;
|
||||||
export const port = config.PORT ? Number(config.PORT) : 4005;
|
export const port = config.PORT ? Number(config.PORT) : 4005;
|
||||||
export const fileStore = useFileStore('pages');
|
export const fileStore = useFileStore('pages');
|
||||||
type ConfigType = {
|
type ConfigType = {
|
||||||
api: {
|
|
||||||
/**
|
|
||||||
* API host address
|
|
||||||
*/
|
|
||||||
host: string;
|
|
||||||
path?: string;
|
|
||||||
port?: number;
|
|
||||||
};
|
|
||||||
apiList: {
|
apiList: {
|
||||||
path: string;
|
path: string;
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +22,11 @@ type ConfigType = {
|
|||||||
/**
|
/**
|
||||||
* self domain kevisual.xiongxiao.me
|
* self domain kevisual.xiongxiao.me
|
||||||
*/
|
*/
|
||||||
domain: string;
|
domain?: string;
|
||||||
|
/**
|
||||||
|
* self ip
|
||||||
|
*/
|
||||||
|
ip?: string;
|
||||||
/**
|
/**
|
||||||
* resources path
|
* resources path
|
||||||
* https://minio.xiongxiao.me/resources
|
* https://minio.xiongxiao.me/resources
|
||||||
@@ -41,24 +38,8 @@ type ConfigType = {
|
|||||||
*/
|
*/
|
||||||
allowedOrigin: string[];
|
allowedOrigin: string[];
|
||||||
};
|
};
|
||||||
stat: {
|
|
||||||
/**
|
|
||||||
* 统计网站ID
|
|
||||||
*/
|
|
||||||
websiteId: string;
|
|
||||||
};
|
|
||||||
redis?: {
|
|
||||||
host: string;
|
|
||||||
port: number;
|
|
||||||
password?: string;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
export const myConfig: ConfigType = {
|
export const myConfig: ConfigType = {
|
||||||
api: {
|
|
||||||
host: config.API_HOST,
|
|
||||||
path: config.API_PATH,
|
|
||||||
port: config.PROXY_PORT,
|
|
||||||
},
|
|
||||||
apiList: [
|
apiList: [
|
||||||
// {
|
// {
|
||||||
// path: '/api',
|
// path: '/api',
|
||||||
@@ -66,20 +47,12 @@ export const myConfig: ConfigType = {
|
|||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
path: '/client',
|
path: '/client',
|
||||||
target: config.API_CLIENT_HOST || 'http://localhost:51015',
|
target: config.API_CLIENT_HOST || 'http://localhost:51515',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
proxy: {
|
proxy: {
|
||||||
domain: config.PROXY_DOMAIN,
|
domain: proxyDomain as string,
|
||||||
resources: minioResources,
|
resources: minioResources,
|
||||||
allowedOrigin: (config.PROXY_ALLOWED_ORIGINS as string)?.split(',') || [],
|
allowedOrigin: (config.PROXY_ALLOWED_ORIGINS as string)?.split(',') || [],
|
||||||
},
|
}
|
||||||
redis: {
|
|
||||||
host: config.REDIS_HOST,
|
|
||||||
port: config.REDIS_PORT,
|
|
||||||
password: config.REDIS_PASSWORD,
|
|
||||||
},
|
|
||||||
stat: {
|
|
||||||
websiteId: config.DATA_WEBSITE_ID,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
|
import { useKey } from "@kevisual/use-config";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用来放cookie的域名
|
* 用来放cookie的域名
|
||||||
*/
|
*/
|
||||||
export const domain = process.env.DOMAIN || ''; // 请在这里填写你的域名
|
export const proxyDomain = useKey('PROXY_DOMAIN') || ''; // 请在这里填写你的域名
|
||||||
|
|||||||
31
src/modules/jwks/index.ts
Normal file
31
src/modules/jwks/index.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { generate } from '@kevisual/auth'
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
|
export const getPath = async (dir: string) => {
|
||||||
|
const JWKS_PATH = path.join(dir, 'jwks.json');
|
||||||
|
const PRIVATE_JWK_PATH = path.join(dir, 'privateKey.json');
|
||||||
|
const PRIVATE_KEY_PATH = path.join(dir, 'privateKey.txt');
|
||||||
|
const PUBLIC_KEY_PATH = path.join(dir, 'publicKey.txt');
|
||||||
|
return {
|
||||||
|
JWKS_PATH,
|
||||||
|
PRIVATE_JWK_PATH,
|
||||||
|
PRIVATE_KEY_PATH,
|
||||||
|
PUBLIC_KEY_PATH,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const jwksGenerate = async (opts: { dir: string }) => {
|
||||||
|
const dir = path.isAbsolute(opts.dir) ? opts.dir : path.join(process.cwd(), opts.dir);
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
|
}
|
||||||
|
const { JWKS_PATH, PRIVATE_JWK_PATH, PRIVATE_KEY_PATH, PUBLIC_KEY_PATH } = await getPath(dir);
|
||||||
|
const { jwks, privateJWK, privatePEM, publicPEM } = await generate();
|
||||||
|
fs.writeFileSync(PUBLIC_KEY_PATH, publicPEM);
|
||||||
|
fs.writeFileSync(PRIVATE_KEY_PATH, privatePEM);
|
||||||
|
fs.writeFileSync(PRIVATE_JWK_PATH, JSON.stringify(privateJWK, null, 2));
|
||||||
|
fs.writeFileSync(JWKS_PATH, JSON.stringify(jwks, null, 2));
|
||||||
|
console.log(`Keys have been saved to directory: ${dir}`);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { app } from '@/app.ts';
|
import { app } from '@/app.ts';
|
||||||
import { Org } from '@/models/org.ts';
|
import { Org } from '@/models/org.ts';
|
||||||
import { User } from '@/models/user.ts';
|
import { User } from '@/models/user.ts';
|
||||||
import { domain } from '@/modules/domain.ts';
|
import { proxyDomain as domain } from '@/modules/domain.ts';
|
||||||
/**
|
/**
|
||||||
* 当配置了domain后,创建cookie,当get请求地址的时候,会自动带上cookie
|
* 当配置了domain后,创建cookie,当get请求地址的时候,会自动带上cookie
|
||||||
* @param token
|
* @param token
|
||||||
|
|||||||
@@ -23,13 +23,13 @@
|
|||||||
],
|
],
|
||||||
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"packageManager": "pnpm@10.28.1",
|
"packageManager": "pnpm@10.28.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kevisual/context": "^0.0.4",
|
"@kevisual/context": "^0.0.4",
|
||||||
"@kevisual/query": "^0.0.38",
|
"@kevisual/query": "^0.0.39",
|
||||||
"@kevisual/router": "0.0.60",
|
"@kevisual/router": "0.0.70",
|
||||||
"@types/node": "^25.0.10",
|
"@types/node": "^25.2.1",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"xml2js": "^0.6.2"
|
"xml2js": "^0.6.2"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user