Skip to content

Commit

Permalink
feat(wip): 支持 JWT
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Oct 30, 2024
1 parent 2320ab3 commit aba6264
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.407",
"version": "2.14.408",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
8 changes: 3 additions & 5 deletions backend/src/restful/miscs.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ export default function register($app) {
try {
const { payload, options } = req.body;
const jwt = eval(`require("jsonwebtoken")`);
const token = jwt.sign(
payload,
eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH'),
options,
);
const secret = eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH');
const token = jwt.sign(payload, secret, options);
res.set('Content-Type', 'application/json;charset=utf-8').send({
token,
secret,
});
} catch (e) {
return failed(
Expand Down
6 changes: 2 additions & 4 deletions backend/src/utils/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ try {
meta.plugin = $Plugin;
}
if (isNode) {
if (
eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH') &&
eval('process.env.SUB_STORE_FRONTEND_PATH')
) {
const secret = eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH');
if (secret && eval('process.env.SUB_STORE_FRONTEND_PATH')) {
feature.share = true;
}
meta.node = {
Expand Down

0 comments on commit aba6264

Please sign in to comment.