alpha release

update v0.8.0
This commit is contained in:
2026-03-17 22:49:38 -04:00
commit 63a91931da
157 changed files with 10951 additions and 0 deletions

32
dist/src/middlewares/authCheckJWT.js vendored Normal file
View File

@@ -0,0 +1,32 @@
import Debug from 'debug';
import jwt from 'jsonwebtoken';
const debug = Debug('twtkpr:authCheckJWT');
/**
* Checks for a valid JWT, and returns a boolean indicating the result
*
* @param req
* @returns
*/
export default async function authCheckJWT(req, config) {
debug('beginning');
const token = req.header('Authorization')?.split(' ')[1];
if (!token) {
debug('no token');
return false;
}
debug('token present');
try {
const decoded = jwt.verify(token, config.accessSecret);
debug({ decoded });
if (!decoded.id)
return false;
req.username = decoded.id;
}
catch {
debug('invalid token');
return false;
}
debug('token good');
return true;
}
//# sourceMappingURL=authCheckJWT.js.map