Skip to content

Commit 48ffd5b

Browse files
committed
support external browser chrome extension distinct secret key
1 parent 3ecd7cf commit 48ffd5b

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

.env.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## API
22
APP_PORT=3004
33
JWT_SECRET=""
4+
BROWSER_EXTENSION_SECRET=""
45
JWT_TOKEN_EXPIRY_TIME="3h"
56

67
## Mistral AI

src/config/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface ConfigProps {
77
// App Server
88
port: string | number;
99
jwtToken: string;
10+
browserExtensionSecret: string;
1011
jwtTokenExpiryTime: string;
1112

1213
// Mistral AI
@@ -28,6 +29,7 @@ interface ConfigProps {
2829
const config: ConfigProps = {
2930
port: process.env.APP_PORT || 3000,
3031
jwtToken: process.env.JWT_SECRET || 'jwt-secret',
32+
browserExtensionSecret: process.env.BROWSER_EXTENSION_SECRET || 'browser-secret',
3133
jwtTokenExpiryTime: process.env.JWT_TOKEN_EXPIRY_TIME || '1h',
3234

3335
mistralAiApiEnabled: !!process.env.MISTRAL_AI_API_ENABLED,

src/middlewares/authMiddleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const authMiddleware = (req: Request, res: Response, next: NextFunction)
3030
}
3131

3232
try {
33-
if (sid !== config.jwtToken) {
33+
if ([config.jwtToken, config.browserExtensionSecret].includes(sid)) {
3434
throw new Error('Invalid token');
3535
}
3636

0 commit comments

Comments
 (0)