@skillstew/common 1.0.8 → 1.0.10
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.
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnauthorizedError = void 0;
|
|
4
|
+
const AppError_1 = require("./AppError");
|
|
5
|
+
class UnauthorizedError extends AppError_1.DomainError {
|
|
6
|
+
constructor() {
|
|
7
|
+
super("You are not authorized", "UNAUTHORIZED");
|
|
8
|
+
}
|
|
9
|
+
toJSON() {
|
|
10
|
+
return { error: this.name, message: this.message, code: this.code };
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.UnauthorizedError = UnauthorizedError;
|
package/build/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from "./errors/AppError";
|
|
2
2
|
export * from "./errors/JwtErrors";
|
|
3
3
|
export * from "./errors/UnauthenticatedError";
|
|
4
|
+
export * from "./errors/UnauthorizedError";
|
|
4
5
|
export * from "./errors/codes/JwtErrorCodes";
|
|
5
6
|
export * from "./jwt-utils/JwtHelper";
|
|
6
7
|
export * from "./middlewares/authMiddleware";
|
|
7
|
-
export * from "./types/UserRoles";
|
|
8
8
|
export * from "./middlewares/requireRole";
|
|
9
|
+
export * from "./types/UserRoles";
|
|
9
10
|
export * from "./constants/HttpStatus";
|
package/build/index.js
CHANGED
|
@@ -14,12 +14,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Errors
|
|
17
18
|
__exportStar(require("./errors/AppError"), exports);
|
|
18
19
|
__exportStar(require("./errors/JwtErrors"), exports);
|
|
19
20
|
__exportStar(require("./errors/UnauthenticatedError"), exports);
|
|
21
|
+
__exportStar(require("./errors/UnauthorizedError"), exports);
|
|
20
22
|
__exportStar(require("./errors/codes/JwtErrorCodes"), exports);
|
|
23
|
+
// Helpers
|
|
21
24
|
__exportStar(require("./jwt-utils/JwtHelper"), exports);
|
|
25
|
+
// Middlewares
|
|
22
26
|
__exportStar(require("./middlewares/authMiddleware"), exports);
|
|
23
|
-
__exportStar(require("./types/UserRoles"), exports);
|
|
24
27
|
__exportStar(require("./middlewares/requireRole"), exports);
|
|
28
|
+
// Types
|
|
29
|
+
__exportStar(require("./types/UserRoles"), exports);
|
|
30
|
+
// Constants
|
|
25
31
|
__exportStar(require("./constants/HttpStatus"), exports);
|
package/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DomainError } from "./AppError";
|
|
2
|
+
|
|
3
|
+
export class UnauthorizedError extends DomainError {
|
|
4
|
+
constructor() {
|
|
5
|
+
super("You are not authorized", "UNAUTHORIZED");
|
|
6
|
+
}
|
|
7
|
+
toJSON(): object {
|
|
8
|
+
return { error: this.name, message: this.message, code: this.code };
|
|
9
|
+
}
|
|
10
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
// Errors
|
|
1
2
|
export * from "./errors/AppError";
|
|
2
3
|
export * from "./errors/JwtErrors";
|
|
3
4
|
export * from "./errors/UnauthenticatedError";
|
|
5
|
+
export * from "./errors/UnauthorizedError";
|
|
4
6
|
export * from "./errors/codes/JwtErrorCodes";
|
|
5
7
|
|
|
8
|
+
// Helpers
|
|
6
9
|
export * from "./jwt-utils/JwtHelper";
|
|
10
|
+
|
|
11
|
+
// Middlewares
|
|
7
12
|
export * from "./middlewares/authMiddleware";
|
|
13
|
+
export * from "./middlewares/requireRole";
|
|
8
14
|
|
|
15
|
+
// Types
|
|
9
16
|
export * from "./types/UserRoles";
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
// Constants
|
|
13
19
|
export * from "./constants/HttpStatus";
|