@rabstack/rab-api 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/index.cjs.js +2 -2
- package/index.esm.d.ts +1 -0
- package/index.esm.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
package/index.cjs.js
CHANGED
|
@@ -577,7 +577,7 @@ const authHandler = (isProtected, config)=>(req, res, next)=>{
|
|
|
577
577
|
const token = extractTokenFromHeader(req);
|
|
578
578
|
if (!token) {
|
|
579
579
|
console.log('authHandler:UnauthorizedException:Token Not Found');
|
|
580
|
-
throw new UnauthorizedException();
|
|
580
|
+
throw new UnauthorizedException('Unauthorized', config.errorCode);
|
|
581
581
|
}
|
|
582
582
|
try {
|
|
583
583
|
const payload = jwt.verify(token, config.jwt.secret_key);
|
|
@@ -585,7 +585,7 @@ const authHandler = (isProtected, config)=>(req, res, next)=>{
|
|
|
585
585
|
return next();
|
|
586
586
|
} catch (err) {
|
|
587
587
|
console.error('authHandler:JWT Error:', err.message);
|
|
588
|
-
throw new UnauthorizedException();
|
|
588
|
+
throw new UnauthorizedException('Unauthorized', config.errorCode);
|
|
589
589
|
}
|
|
590
590
|
};
|
|
591
591
|
|
package/index.esm.d.ts
CHANGED
|
@@ -121,6 +121,7 @@ export declare function AtomRoute(method: HttpMethod, path: string, options?: Co
|
|
|
121
121
|
export declare const authHandler: (isProtected: boolean, config: AuthHandlerOptions) => (req: any, res: Response_2, next: NextFunction) => void;
|
|
122
122
|
|
|
123
123
|
export declare type AuthHandlerOptions = {
|
|
124
|
+
errorCode?: string;
|
|
124
125
|
jwt: {
|
|
125
126
|
secret_key: string;
|
|
126
127
|
algorithms: any;
|
package/index.esm.js
CHANGED
|
@@ -575,7 +575,7 @@ const authHandler = (isProtected, config)=>(req, res, next)=>{
|
|
|
575
575
|
const token = extractTokenFromHeader(req);
|
|
576
576
|
if (!token) {
|
|
577
577
|
console.log('authHandler:UnauthorizedException:Token Not Found');
|
|
578
|
-
throw new UnauthorizedException();
|
|
578
|
+
throw new UnauthorizedException('Unauthorized', config.errorCode);
|
|
579
579
|
}
|
|
580
580
|
try {
|
|
581
581
|
const payload = jwt.verify(token, config.jwt.secret_key);
|
|
@@ -583,7 +583,7 @@ const authHandler = (isProtected, config)=>(req, res, next)=>{
|
|
|
583
583
|
return next();
|
|
584
584
|
} catch (err) {
|
|
585
585
|
console.error('authHandler:JWT Error:', err.message);
|
|
586
|
-
throw new UnauthorizedException();
|
|
586
|
+
throw new UnauthorizedException('Unauthorized', config.errorCode);
|
|
587
587
|
}
|
|
588
588
|
};
|
|
589
589
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rabstack/rab-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A TypeScript REST API framework built on Express.js with decorator-based routing, dependency injection, and built-in validation",
|
|
5
5
|
"author": "Softin",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"joi": "^17.0.0",
|
|
24
24
|
"jsonwebtoken": "^9.0.0",
|
|
25
25
|
"compose-middleware": "^5.0.0",
|
|
26
|
-
"reflect-metadata": "^0.
|
|
26
|
+
"reflect-metadata": "^0.2.2"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {},
|
|
29
29
|
"typings": "./index.esm.d.ts",
|