Skip to content

Commit 1ad9832

Browse files
authored
fix(runtime): function source leakage caused by type hint interface (#1454)
1 parent e2be923 commit 1ad9832

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

runtimes/nodejs/src/handler/typings.ts

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import path = require('path')
1111
import { logger } from '../support/logger'
1212
import { IRequest } from '../support/types'
1313
import { FunctionCache } from '../support/function-engine/cache'
14+
import { parseToken } from '../support/token'
1415

1516
const nodeModulesRoot = path.resolve(__dirname, '../../node_modules')
1617

@@ -20,6 +21,16 @@ const nodeModulesRoot = path.resolve(__dirname, '../../node_modules')
2021
export async function handlePackageTypings(req: IRequest, res: Response) {
2122
const requestId = req['requestId']
2223

24+
// verify the debug token
25+
const token = req.get('x-laf-develop-token')
26+
if (!token) {
27+
return res.status(400).send('x-laf-develop-token is required')
28+
}
29+
const auth = parseToken(token) || null
30+
if (auth?.type !== 'develop') {
31+
return res.status(403).send('permission denied: invalid develop token')
32+
}
33+
2334
const packageName = req.query.packageName as string
2435
if (!packageName) {
2536
return res.status(422).send('invalid package name')

0 commit comments

Comments
 (0)