@taleswords/common 1.0.26 → 1.0.27
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/build/constants/globals.d.ts +8 -3
- package/build/constants/globals.d.ts.map +1 -1
- package/build/constants/globals.js +1 -1
- package/build/constants/globals.js.map +1 -1
- package/build/constants/project/project.interfaces.d.ts +9 -0
- package/build/constants/project/project.interfaces.d.ts.map +1 -0
- package/build/constants/project/project.interfaces.js +9 -0
- package/build/constants/project/project.interfaces.js.map +1 -0
- package/build/errors/bad-request-error.d.ts +10 -7
- package/build/errors/bad-request-error.d.ts.map +1 -1
- package/build/errors/bad-request-error.js +8 -3
- package/build/errors/bad-request-error.js.map +1 -1
- package/build/errors/custom-error.d.ts +13 -5
- package/build/errors/custom-error.d.ts.map +1 -1
- package/build/errors/custom-error.js.map +1 -1
- package/build/errors/database-connection-error.d.ts +10 -6
- package/build/errors/database-connection-error.d.ts.map +1 -1
- package/build/errors/database-connection-error.js +11 -4
- package/build/errors/database-connection-error.js.map +1 -1
- package/build/errors/not-authorized-error.d.ts +10 -6
- package/build/errors/not-authorized-error.d.ts.map +1 -1
- package/build/errors/not-authorized-error.js +11 -4
- package/build/errors/not-authorized-error.js.map +1 -1
- package/build/errors/not-found-error.d.ts +10 -6
- package/build/errors/not-found-error.d.ts.map +1 -1
- package/build/errors/not-found-error.js +11 -4
- package/build/errors/not-found-error.js.map +1 -1
- package/build/errors/request-validation-error.d.ts +11 -7
- package/build/errors/request-validation-error.d.ts.map +1 -1
- package/build/errors/request-validation-error.js +11 -4
- package/build/errors/request-validation-error.js.map +1 -1
- package/build/index.d.ts +4 -9
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -9
- package/build/index.js.map +1 -1
- package/build/middlewares/current-project.d.ts +3 -0
- package/build/middlewares/current-project.d.ts.map +1 -0
- package/build/middlewares/current-project.js +21 -0
- package/build/middlewares/current-project.js.map +1 -0
- package/build/middlewares/error-handler.d.ts.map +1 -1
- package/build/middlewares/error-handler.js +8 -0
- package/build/middlewares/error-handler.js.map +1 -1
- package/build/middlewares/require-project.d.ts +3 -0
- package/build/middlewares/require-project.d.ts.map +1 -0
- package/build/middlewares/require-project.js +8 -0
- package/build/middlewares/require-project.js.map +1 -0
- package/build/services/token.service.d.ts +15 -0
- package/build/services/token.service.d.ts.map +1 -0
- package/build/services/token.service.js +18 -0
- package/build/services/token.service.js.map +1 -0
- package/build/types/express.d.ts +8 -7
- package/build/types/express.d.ts.map +1 -1
- package/build/types/express.js +7 -0
- package/build/types/express.js.map +1 -1
- package/package.json +3 -4
- package/build/constants/auth/user.interfaces.d.ts +0 -8
- package/build/constants/auth/user.interfaces.d.ts.map +0 -1
- package/build/constants/auth/user.interfaces.js +0 -2
- package/build/constants/auth/user.interfaces.js.map +0 -1
- package/build/constants/buyer/cart-product.interfaces.d.ts +0 -11
- package/build/constants/buyer/cart-product.interfaces.d.ts.map +0 -1
- package/build/constants/buyer/cart-product.interfaces.js +0 -2
- package/build/constants/buyer/cart-product.interfaces.js.map +0 -1
- package/build/constants/buyer/cart.interfaces.d.ts +0 -11
- package/build/constants/buyer/cart.interfaces.d.ts.map +0 -1
- package/build/constants/buyer/cart.interfaces.js +0 -2
- package/build/constants/buyer/cart.interfaces.js.map +0 -1
- package/build/constants/seller/product.interfaces.d.ts +0 -13
- package/build/constants/seller/product.interfaces.d.ts.map +0 -1
- package/build/constants/seller/product.interfaces.js +0 -2
- package/build/constants/seller/product.interfaces.js.map +0 -1
- package/build/middlewares/current-user.d.ts +0 -3
- package/build/middlewares/current-user.d.ts.map +0 -1
- package/build/middlewares/current-user.js +0 -17
- package/build/middlewares/current-user.js.map +0 -1
- package/build/middlewares/require-auth.d.ts +0 -3
- package/build/middlewares/require-auth.d.ts.map +0 -1
- package/build/middlewares/require-auth.js +0 -8
- package/build/middlewares/require-auth.js.map +0 -1
- package/build/middlewares/uploader.d.ts +0 -15
- package/build/middlewares/uploader.d.ts.map +0 -1
- package/build/middlewares/uploader.js +0 -42
- package/build/middlewares/uploader.js.map +0 -1
- package/build/middlewares/validation-request.d.ts +0 -3
- package/build/middlewares/validation-request.d.ts.map +0 -1
- package/build/middlewares/validation-request.js +0 -10
- package/build/middlewares/validation-request.js.map +0 -1
- package/build/services/authentication.service.d.ts +0 -8
- package/build/services/authentication.service.d.ts.map +0 -1
- package/build/services/authentication.service.js +0 -25
- package/build/services/authentication.service.js.map +0 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
1
8
|
export interface JWTPayload {
|
|
2
|
-
|
|
3
|
-
userId: string;
|
|
9
|
+
projectId: string;
|
|
4
10
|
}
|
|
5
|
-
export declare const UPLOAD_DIR = "upload/";
|
|
6
11
|
//# sourceMappingURL=globals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../src/constants/globals.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,
|
|
1
|
+
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../src/constants/globals.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACvB,SAAS,EAAE,MAAM,CAAA;CACpB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=globals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.js","sourceRoot":"","sources":["../../src/constants/globals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"globals.js","sourceRoot":"","sources":["../../src/constants/globals.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.interfaces.d.ts","sourceRoot":"","sources":["../../../src/constants/project/project.interfaces.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.interfaces.js","sourceRoot":"","sources":["../../../src/constants/project/project.interfaces.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
8
|
+
import { CustomError, type GeneratedError } from './custom-error.js';
|
|
2
9
|
export declare class BadRequestError extends CustomError {
|
|
3
|
-
message: string;
|
|
4
|
-
statusCode: number;
|
|
5
10
|
constructor(message: string);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
field?: string;
|
|
9
|
-
}[];
|
|
11
|
+
statusCode: number;
|
|
12
|
+
generateErrors(): Array<GeneratedError>;
|
|
10
13
|
}
|
|
11
14
|
//# sourceMappingURL=bad-request-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bad-request-error.d.ts","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"bad-request-error.d.ts","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEpE,qBAAa,eAAgB,SAAQ,WAAW;gBACzB,OAAO,EAAE,MAAM;IAI3B,UAAU,SAAM;IAEhB,cAAc,IAAI,KAAK,CAAC,cAAc,CAAC;CAGjD"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
1
8
|
import { CustomError } from './custom-error.js';
|
|
2
9
|
export class BadRequestError extends CustomError {
|
|
3
|
-
message;
|
|
4
|
-
statusCode = 400;
|
|
5
10
|
constructor(message) {
|
|
6
11
|
super(message);
|
|
7
|
-
this.message = message;
|
|
8
12
|
}
|
|
13
|
+
statusCode = 400;
|
|
9
14
|
generateErrors() {
|
|
10
15
|
return [{ message: this.message }];
|
|
11
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bad-request-error.js","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"bad-request-error.js","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAuB,MAAM,mBAAmB,CAAA;AAEpE,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC5C,YAAmB,OAAe;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;IAEM,UAAU,GAAG,GAAG,CAAA;IAEhB,cAAc;QACjB,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACtC,CAAC;CACJ"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
8
|
+
export interface GeneratedError {
|
|
9
|
+
message: string;
|
|
10
|
+
field?: string;
|
|
11
|
+
}
|
|
1
12
|
export declare abstract class CustomError extends Error {
|
|
2
|
-
abstract statusCode: number;
|
|
3
13
|
constructor(message: string);
|
|
4
|
-
abstract
|
|
5
|
-
|
|
6
|
-
field?: string;
|
|
7
|
-
}[];
|
|
14
|
+
abstract statusCode: number;
|
|
15
|
+
abstract generateErrors(): Array<GeneratedError>;
|
|
8
16
|
}
|
|
9
17
|
//# sourceMappingURL=custom-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-error.d.ts","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"custom-error.d.ts","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB;AACD,8BAAsB,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAG,MAAM;IAInC,SAAgB,UAAU,EAAE,MAAM,CAAA;aAElB,cAAc,IAAI,KAAK,CAAC,cAAc,CAAC;CAC1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-error.js","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"custom-error.js","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":"AAWA,MAAM,OAAgB,WAAY,SAAQ,KAAK;IAC3C,YAAmB,OAAgB;QAC/B,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;CAKJ"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
8
|
+
import { CustomError, type GeneratedError } from './custom-error.js';
|
|
2
9
|
export declare class DatabaseConnectionError extends CustomError {
|
|
10
|
+
constructor(message?: string);
|
|
3
11
|
statusCode: number;
|
|
4
|
-
|
|
5
|
-
generateErrors(): {
|
|
6
|
-
message: string;
|
|
7
|
-
field?: string;
|
|
8
|
-
}[];
|
|
12
|
+
generateErrors(): Array<GeneratedError>;
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=database-connection-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-connection-error.d.ts","sourceRoot":"","sources":["../../src/errors/database-connection-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"database-connection-error.d.ts","sourceRoot":"","sources":["../../src/errors/database-connection-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEpE,qBAAa,uBAAwB,SAAQ,WAAW;gBACjC,OAAO,GAAG,MAAoC;IAI1D,UAAU,SAAM;IAEhB,cAAc,IAAI,KAAK,CAAC,cAAc,CAAC;CAGjD"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
1
8
|
import { CustomError } from './custom-error.js';
|
|
2
9
|
export class DatabaseConnectionError extends CustomError {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
super('database connection error');
|
|
10
|
+
constructor(message = 'database connection error') {
|
|
11
|
+
super(message);
|
|
6
12
|
}
|
|
13
|
+
statusCode = 500;
|
|
7
14
|
generateErrors() {
|
|
8
|
-
return [{ message:
|
|
15
|
+
return [{ message: this.message }];
|
|
9
16
|
}
|
|
10
17
|
}
|
|
11
18
|
//# sourceMappingURL=database-connection-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-connection-error.js","sourceRoot":"","sources":["../../src/errors/database-connection-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"database-connection-error.js","sourceRoot":"","sources":["../../src/errors/database-connection-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAuB,MAAM,mBAAmB,CAAA;AAEpE,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IACpD,YAAmB,UAAmB,2BAA2B;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;IAEM,UAAU,GAAG,GAAG,CAAA;IAEhB,cAAc;QACjB,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACtC,CAAC;CACJ"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
8
|
+
import { CustomError, type GeneratedError } from './custom-error.js';
|
|
2
9
|
export declare class NotAuthorizedError extends CustomError {
|
|
10
|
+
constructor(message?: string);
|
|
3
11
|
statusCode: number;
|
|
4
|
-
|
|
5
|
-
generateErrors(): {
|
|
6
|
-
message: string;
|
|
7
|
-
field?: string;
|
|
8
|
-
}[];
|
|
12
|
+
generateErrors(): Array<GeneratedError>;
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=not-authorized-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-authorized-error.d.ts","sourceRoot":"","sources":["../../src/errors/not-authorized-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"not-authorized-error.d.ts","sourceRoot":"","sources":["../../src/errors/not-authorized-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEpE,qBAAa,kBAAmB,SAAQ,WAAW;gBAC5B,OAAO,GAAE,MAAyB;IAI9C,UAAU,SAAM;IAEhB,cAAc,IAAI,KAAK,CAAC,cAAc,CAAC;CAGjD"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
1
8
|
import { CustomError } from './custom-error.js';
|
|
2
9
|
export class NotAuthorizedError extends CustomError {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
super('not authorized');
|
|
10
|
+
constructor(message = 'not authorized') {
|
|
11
|
+
super(message);
|
|
6
12
|
}
|
|
13
|
+
statusCode = 401;
|
|
7
14
|
generateErrors() {
|
|
8
|
-
return [{ message:
|
|
15
|
+
return [{ message: this.message }];
|
|
9
16
|
}
|
|
10
17
|
}
|
|
11
18
|
//# sourceMappingURL=not-authorized-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-authorized-error.js","sourceRoot":"","sources":["../../src/errors/not-authorized-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"not-authorized-error.js","sourceRoot":"","sources":["../../src/errors/not-authorized-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAuB,MAAM,mBAAmB,CAAA;AAEpE,MAAM,OAAO,kBAAmB,SAAQ,WAAW;IAC/C,YAAmB,UAAkB,gBAAgB;QACjD,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;IAEM,UAAU,GAAG,GAAG,CAAA;IAEhB,cAAc;QACjB,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACtC,CAAC;CACJ"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
8
|
+
import { CustomError, type GeneratedError } from './custom-error.js';
|
|
2
9
|
export declare class NotFoundError extends CustomError {
|
|
10
|
+
constructor(message?: string);
|
|
3
11
|
statusCode: number;
|
|
4
|
-
|
|
5
|
-
generateErrors(): {
|
|
6
|
-
message: string;
|
|
7
|
-
field?: string;
|
|
8
|
-
}[];
|
|
12
|
+
generateErrors(): Array<GeneratedError>;
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=not-found-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found-error.d.ts","sourceRoot":"","sources":["../../src/errors/not-found-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"not-found-error.d.ts","sourceRoot":"","sources":["../../src/errors/not-found-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEpE,qBAAa,aAAc,SAAQ,WAAW;gBACvB,OAAO,SAAc;IAIjC,UAAU,SAAM;IAEhB,cAAc,IAAI,KAAK,CAAC,cAAc,CAAC;CAGjD"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
1
8
|
import { CustomError } from './custom-error.js';
|
|
2
9
|
export class NotFoundError extends CustomError {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
super('not found');
|
|
10
|
+
constructor(message = 'not found') {
|
|
11
|
+
super(message);
|
|
6
12
|
}
|
|
13
|
+
statusCode = 404;
|
|
7
14
|
generateErrors() {
|
|
8
|
-
return [{ message:
|
|
15
|
+
return [{ message: this.message }];
|
|
9
16
|
}
|
|
10
17
|
}
|
|
11
18
|
//# sourceMappingURL=not-found-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found-error.js","sourceRoot":"","sources":["../../src/errors/not-found-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"not-found-error.js","sourceRoot":"","sources":["../../src/errors/not-found-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAuB,MAAM,mBAAmB,CAAA;AAEpE,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC1C,YAAmB,OAAO,GAAG,WAAW;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;IAEM,UAAU,GAAG,GAAG,CAAA;IAEhB,cAAc;QACjB,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACtC,CAAC;CACJ"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
8
|
+
import { CustomError, type GeneratedError } from './custom-error.js';
|
|
2
9
|
import type { ValidationError } from 'express-validator';
|
|
3
10
|
export declare class RequestValidationError extends CustomError {
|
|
4
|
-
errors: ValidationError
|
|
11
|
+
errors: Array<ValidationError>;
|
|
12
|
+
constructor(errors: Array<ValidationError>, message?: string);
|
|
5
13
|
statusCode: number;
|
|
6
|
-
|
|
7
|
-
generateErrors(): {
|
|
8
|
-
message: string;
|
|
9
|
-
field?: string;
|
|
10
|
-
}[];
|
|
14
|
+
generateErrors(): Array<GeneratedError>;
|
|
11
15
|
}
|
|
12
16
|
//# sourceMappingURL=request-validation-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-validation-error.d.ts","sourceRoot":"","sources":["../../src/errors/request-validation-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"request-validation-error.d.ts","sourceRoot":"","sources":["../../src/errors/request-validation-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,qBAAa,sBAAuB,SAAQ,WAAW;IAExC,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC;gBAA9B,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC,EACrC,OAAO,GAAE,MAA0B;IAKhC,UAAU,SAAM;IAEhB,cAAc,IAAI,KAAK,CAAC,cAAc,CAAC;CAQjD"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
1
8
|
import { CustomError } from './custom-error.js';
|
|
2
9
|
export class RequestValidationError extends CustomError {
|
|
3
10
|
errors;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
super('invalid request');
|
|
11
|
+
constructor(errors, message = 'invalid request') {
|
|
12
|
+
super(message);
|
|
7
13
|
this.errors = errors;
|
|
8
14
|
}
|
|
15
|
+
statusCode = 400;
|
|
9
16
|
generateErrors() {
|
|
10
|
-
return this.errors.map(error => {
|
|
17
|
+
return this.errors.map((error) => {
|
|
11
18
|
return {
|
|
12
19
|
message: error.msg,
|
|
13
20
|
field: error.type === 'field' ? error.path : ''
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-validation-error.js","sourceRoot":"","sources":["../../src/errors/request-validation-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"request-validation-error.js","sourceRoot":"","sources":["../../src/errors/request-validation-error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAuB,MAAM,mBAAmB,CAAA;AAGpE,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IAExC;IADX,YACW,MAA8B,EACrC,UAAkB,iBAAiB;QAEnC,KAAK,CAAC,OAAO,CAAC,CAAA;QAHP,WAAM,GAAN,MAAM,CAAwB;IAIzC,CAAC;IAEM,UAAU,GAAG,GAAG,CAAA;IAEhB,cAAc;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAsB,EAAE,EAAE;YAC9C,OAAO;gBACH,OAAO,EAAE,KAAK,CAAC,GAAG;gBAClB,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;aAClD,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import './types/express.js';
|
|
2
2
|
export * from './constants/globals.js';
|
|
3
|
-
export * from './constants/
|
|
4
|
-
export * from './constants/buyer/cart-product.interfaces.js';
|
|
5
|
-
export * from './constants/buyer/cart.interfaces.js';
|
|
6
|
-
export * from './constants/seller/product.interfaces.js';
|
|
3
|
+
export * from './constants/project/project.interfaces.js';
|
|
7
4
|
export * from './errors/bad-request-error.js';
|
|
8
5
|
export * from './errors/custom-error.js';
|
|
9
6
|
export * from './errors/database-connection-error.js';
|
|
10
7
|
export * from './errors/not-authorized-error.js';
|
|
11
8
|
export * from './errors/not-found-error.js';
|
|
12
9
|
export * from './errors/request-validation-error.js';
|
|
13
|
-
export * from './middlewares/current-
|
|
10
|
+
export * from './middlewares/current-project.js';
|
|
14
11
|
export * from './middlewares/error-handler.js';
|
|
15
|
-
export * from './middlewares/require-
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './middlewares/validation-request.js';
|
|
18
|
-
export * from './services/authentication.service.js';
|
|
12
|
+
export * from './middlewares/require-project.js';
|
|
13
|
+
export * from './services/token.service.js';
|
|
19
14
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAE3B,cAAc,wBAAwB,CAAA;AACtC,cAAc,2CAA2C,CAAA;AAEzD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,0BAA0B,CAAA;AACxC,cAAc,uCAAuC,CAAA;AACrD,cAAc,kCAAkC,CAAA;AAChD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sCAAsC,CAAA;AAEpD,cAAc,kCAAkC,CAAA;AAChD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,kCAAkC,CAAA;AAEhD,cAAc,6BAA6B,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import './types/express.js';
|
|
2
2
|
export * from './constants/globals.js';
|
|
3
|
-
export * from './constants/
|
|
4
|
-
export * from './constants/buyer/cart-product.interfaces.js';
|
|
5
|
-
export * from './constants/buyer/cart.interfaces.js';
|
|
6
|
-
export * from './constants/seller/product.interfaces.js';
|
|
3
|
+
export * from './constants/project/project.interfaces.js';
|
|
7
4
|
export * from './errors/bad-request-error.js';
|
|
8
5
|
export * from './errors/custom-error.js';
|
|
9
6
|
export * from './errors/database-connection-error.js';
|
|
10
7
|
export * from './errors/not-authorized-error.js';
|
|
11
8
|
export * from './errors/not-found-error.js';
|
|
12
9
|
export * from './errors/request-validation-error.js';
|
|
13
|
-
export * from './middlewares/current-
|
|
10
|
+
export * from './middlewares/current-project.js';
|
|
14
11
|
export * from './middlewares/error-handler.js';
|
|
15
|
-
export * from './middlewares/require-
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './middlewares/validation-request.js';
|
|
18
|
-
export * from './services/authentication.service.js';
|
|
12
|
+
export * from './middlewares/require-project.js';
|
|
13
|
+
export * from './services/token.service.js';
|
|
19
14
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAE3B,cAAc,wBAAwB,CAAA;AACtC,cAAc,2CAA2C,CAAA;AAEzD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,0BAA0B,CAAA;AACxC,cAAc,uCAAuC,CAAA;AACrD,cAAc,kCAAkC,CAAA;AAChD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sCAAsC,CAAA;AAEpD,cAAc,kCAAkC,CAAA;AAChD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,kCAAkC,CAAA;AAEhD,cAAc,6BAA6B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-project.d.ts","sourceRoot":"","sources":["../../src/middlewares/current-project.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG9D,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,MACpC,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAe1D,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
8
|
+
import { tokenService } from '../services/token.service.js';
|
|
9
|
+
export const currentProject = (jwtSecret) => {
|
|
10
|
+
return (req, res, next) => {
|
|
11
|
+
const authHeader = req.headers.authorization;
|
|
12
|
+
if (!authHeader?.startsWith('Bearer ')) {
|
|
13
|
+
return next();
|
|
14
|
+
}
|
|
15
|
+
const token = authHeader.slice(7);
|
|
16
|
+
const payload = tokenService.verifyJwt(token, jwtSecret);
|
|
17
|
+
req.projectId = payload.projectId;
|
|
18
|
+
next();
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=current-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-project.js","sourceRoot":"","sources":["../../src/middlewares/current-project.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAI3D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAiB,EAAE,EAAE;IAChD,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;QACvD,MAAM,UAAU,GAAkB,GAAG,CAAC,OAAO,CAAC,aAAa,CAAA;QAE3D,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACrC,OAAO,IAAI,EAAE,CAAA;QACjB,CAAC;QAED,MAAM,KAAK,GAAW,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAEzC,MAAM,OAAO,GAAe,YAAY,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QAEpE,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QAEjC,IAAI,EAAE,CAAA;IACV,CAAC,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/middlewares/error-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/middlewares/error-handler.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE9D,eAAO,MAAM,YAAY,GAAI,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,mDAQvF,CAAA"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
1
8
|
import { CustomError } from '../errors/custom-error.js';
|
|
2
9
|
export const errorHandler = (err, req, res, next) => {
|
|
3
10
|
if (err instanceof CustomError) {
|
|
4
11
|
return res.status(err.statusCode).json({ errors: err.generateErrors() });
|
|
5
12
|
}
|
|
13
|
+
console.error('untyped error', err);
|
|
6
14
|
res.status(500).json({ errors: [{ message: 'something went wrong ' }] });
|
|
7
15
|
};
|
|
8
16
|
//# sourceMappingURL=error-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/middlewares/error-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/middlewares/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAGvD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAU,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IACxF,IAAI,GAAG,YAAY,WAAW,EAAE,CAAC;QAC7B,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;IAC5E,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,GAAG,CAAC,CAAA;IAEnC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAC,CAAC,EAAC,CAAC,CAAA;AAC1E,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-project.d.ts","sourceRoot":"","sources":["../../src/middlewares/require-project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG9D,eAAO,MAAM,cAAc,GAAU,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,kBAKnF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-project.js","sourceRoot":"","sources":["../../src/middlewares/require-project.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IACpF,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAA;IACzC,CAAC;IACD,IAAI,EAAE,CAAA;AACV,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
8
|
+
import { type SignOptions } from 'jsonwebtoken';
|
|
9
|
+
import type { JWTPayload } from '../constants/globals.js';
|
|
10
|
+
export declare class TokenService {
|
|
11
|
+
generateJwt(payload: JWTPayload, JWT_SECRET: string, options?: SignOptions): string;
|
|
12
|
+
verifyJwt(token: string, JWT_SECRET: string): JWTPayload;
|
|
13
|
+
}
|
|
14
|
+
export declare const tokenService: TokenService;
|
|
15
|
+
//# sourceMappingURL=token.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.service.d.ts","sourceRoot":"","sources":["../../src/services/token.service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAY,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEzD,qBAAa,YAAY;IACd,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM;IAInF,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU;CAGlE;AAED,eAAO,MAAM,YAAY,cAAqB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
8
|
+
import jwt, {} from 'jsonwebtoken';
|
|
9
|
+
export class TokenService {
|
|
10
|
+
generateJwt(payload, JWT_SECRET, options) {
|
|
11
|
+
return jwt.sign(payload, JWT_SECRET, options);
|
|
12
|
+
}
|
|
13
|
+
verifyJwt(token, JWT_SECRET) {
|
|
14
|
+
return jwt.verify(token, JWT_SECRET);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export const tokenService = new TokenService();
|
|
18
|
+
//# sourceMappingURL=token.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.service.js","sourceRoot":"","sources":["../../src/services/token.service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,GAAG,EAAE,EAAoB,MAAM,cAAc,CAAA;AAGpD,MAAM,OAAO,YAAY;IACd,WAAW,CAAC,OAAmB,EAAE,UAAkB,EAAE,OAAqB;QAC7E,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;IAEM,SAAS,CAAC,KAAa,EAAE,UAAkB;QAC9C,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAe,CAAA;IACtD,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA"}
|
package/build/types/express.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Taleswords
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Proprietary and confidential.
|
|
6
|
+
* Unauthorized copying, modification, or distribution is prohibited.
|
|
7
|
+
*/
|
|
1
8
|
import 'express';
|
|
2
|
-
import type { JWTPayload } from '../constants/globals.js';
|
|
3
9
|
declare global {
|
|
4
10
|
namespace Express {
|
|
5
11
|
interface Request {
|
|
6
|
-
|
|
7
|
-
jwt?: string;
|
|
8
|
-
cartId: string;
|
|
9
|
-
};
|
|
10
|
-
currentUser?: JWTPayload;
|
|
11
|
-
uploaderError?: Error;
|
|
12
|
+
projectId?: string;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/types/express.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/types/express.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,SAAS,CAAA;AAEhB,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,OAAO,CAAC;QACd,UAAU,OAAO;YACb,SAAS,CAAC,EAAE,MAAM,CAAA;SACrB;KACJ;CACJ"}
|
package/build/types/express.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/types/express.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/types/express.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,SAAS,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taleswords/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -25,14 +25,13 @@
|
|
|
25
25
|
"@types/express": "^5.0.6",
|
|
26
26
|
"@types/express-validator": "^2.20.33",
|
|
27
27
|
"@types/jsonwebtoken": "^9.0.10",
|
|
28
|
+
"@types/node": "^25.1.0",
|
|
28
29
|
"del-cli": "^7.0.0"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@types/multer": "^2.0.0",
|
|
32
32
|
"express": "^5.2.1",
|
|
33
33
|
"express-validator": "^7.3.1",
|
|
34
34
|
"jsonwebtoken": "^9.0.3",
|
|
35
|
-
"mongoose": "^9.1.5"
|
|
36
|
-
"multer": "^2.0.2"
|
|
35
|
+
"mongoose": "^9.1.5"
|
|
37
36
|
}
|
|
38
37
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.interfaces.d.ts","sourceRoot":"","sources":["../../../src/constants/auth/user.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,MAAM,WAAW,OAAQ,SAAQ,QAAQ,CAAC,QAAQ;IAC9C,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,SAAU,SAAQ,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.interfaces.js","sourceRoot":"","sources":["../../../src/constants/auth/user.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
import type { CartDoc } from './cart.interfaces.js';
|
|
3
|
-
import type { ProductDoc } from '../seller/product.interfaces.js';
|
|
4
|
-
export interface CartProductDoc extends mongoose.Document {
|
|
5
|
-
cart: CartDoc | string;
|
|
6
|
-
product: ProductDoc;
|
|
7
|
-
quantity: number;
|
|
8
|
-
}
|
|
9
|
-
export interface CartProductModel extends mongoose.Model<CartProductDoc> {
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=cart-product.interfaces.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cart-product.interfaces.d.ts","sourceRoot":"","sources":["../../../src/constants/buyer/cart-product.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,WAAW,cAAe,SAAQ,QAAQ,CAAC,QAAQ;IACrD,IAAI,EAAE,OAAO,GAAG,MAAM,CAAA;IACtB,OAAO,EAAE,UAAU,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,gBAAiB,SAAQ,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cart-product.interfaces.js","sourceRoot":"","sources":["../../../src/constants/buyer/cart-product.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
import type { UserDoc } from '../auth/user.interfaces.js';
|
|
3
|
-
import type { CartProductDoc } from './cart-product.interfaces.js';
|
|
4
|
-
export interface CartDoc extends mongoose.Document {
|
|
5
|
-
user: UserDoc | string;
|
|
6
|
-
products: Array<CartProductDoc | string>;
|
|
7
|
-
totalPrice: number;
|
|
8
|
-
}
|
|
9
|
-
export interface CartModel extends mongoose.Model<CartDoc> {
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=cart.interfaces.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cart.interfaces.d.ts","sourceRoot":"","sources":["../../../src/constants/buyer/cart.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAElE,MAAM,WAAW,OAAQ,SAAQ,QAAQ,CAAC,QAAQ;IAC9C,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,CAAA;IACxC,UAAU,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,SAAU,SAAQ,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cart.interfaces.js","sourceRoot":"","sources":["../../../src/constants/buyer/cart.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
import type { UserDoc } from '../auth/user.interfaces.js';
|
|
3
|
-
export interface ProductDoc extends mongoose.Document {
|
|
4
|
-
user: UserDoc | string;
|
|
5
|
-
title: string;
|
|
6
|
-
price: number;
|
|
7
|
-
images: {
|
|
8
|
-
src: string;
|
|
9
|
-
}[];
|
|
10
|
-
}
|
|
11
|
-
export interface ProductModel extends mongoose.Model<ProductDoc> {
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=product.interfaces.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"product.interfaces.d.ts","sourceRoot":"","sources":["../../../src/constants/seller/product.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEzD,MAAM,WAAW,UAAW,SAAQ,QAAQ,CAAC,QAAQ;IACjD,IAAI,EAAE,OAAO,GAAG,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAC5B;AAED,MAAM,WAAW,YAAa,SAAQ,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"product.interfaces.js","sourceRoot":"","sources":["../../../src/constants/seller/product.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"current-user.d.ts","sourceRoot":"","sources":["../../src/middlewares/current-user.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG9D,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,MAC/B,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAa1D,CAAA"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import jwt from 'jsonwebtoken';
|
|
2
|
-
export const currentUser = (JWT_KEY) => {
|
|
3
|
-
return (req, res, next) => {
|
|
4
|
-
const token = req.session?.jwt;
|
|
5
|
-
if (!token)
|
|
6
|
-
return next();
|
|
7
|
-
try {
|
|
8
|
-
const payload = (jwt.verify(token, JWT_KEY));
|
|
9
|
-
req.currentUser = payload;
|
|
10
|
-
next();
|
|
11
|
-
}
|
|
12
|
-
catch (err) {
|
|
13
|
-
return next();
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=current-user.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"current-user.js","sourceRoot":"","sources":["../../src/middlewares/current-user.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAA;AAI9B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,EAAE;IAC3C,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;QACvD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,CAAA;QAC9B,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,EAAE,CAAA;QAEzB,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAe,CAAA;YAE1D,GAAG,CAAC,WAAW,GAAG,OAAO,CAAA;YACzB,IAAI,EAAE,CAAA;QACV,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,IAAI,EAAE,CAAA;QACjB,CAAC;IACL,CAAC,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"require-auth.d.ts","sourceRoot":"","sources":["../../src/middlewares/require-auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG9D,eAAO,MAAM,WAAW,GAAU,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,kBAKhF,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"require-auth.js","sourceRoot":"","sources":["../../src/middlewares/require-auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IACjF,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAA;IACzC,CAAC;IACD,IAAI,EAAE,CAAA;AACV,CAAC,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import multer, { type FileFilterCallback } from 'multer';
|
|
2
|
-
import type { Request } from 'express';
|
|
3
|
-
export interface UploaderMiddlewareOptions {
|
|
4
|
-
types?: string[];
|
|
5
|
-
fieldName: string;
|
|
6
|
-
}
|
|
7
|
-
export declare class Uploader {
|
|
8
|
-
uploadDir: string;
|
|
9
|
-
constructor(uploadDir?: string);
|
|
10
|
-
fileFilter: (types?: Array<string>) => (req: Request, file: Express.Multer.File, cb: FileFilterCallback) => void;
|
|
11
|
-
storage: multer.StorageEngine;
|
|
12
|
-
uploadMultipleFiles(options?: UploaderMiddlewareOptions): import("express").RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
13
|
-
uploadSingleFile(options?: UploaderMiddlewareOptions): import("express").RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=uploader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/middlewares/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,KAAK,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AACxD,OAAO,KAAK,EAAE,OAAO,EAA0B,MAAM,SAAS,CAAA;AAG9D,MAAM,WAAW,yBAAyB;IACtC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CACpB;AAED,qBAAa,QAAQ;IAEE,SAAS,EAAE,MAAM;gBAAjB,SAAS,GAAE,MAAoB;IAE3C,UAAU,GAAI,QAAQ,KAAK,CAAC,MAAM,CAAC,MAC9B,KAAK,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,kBAAkB,UAa1E;IAEM,OAAO,uBAOZ;IAEF,mBAAmB,CAAC,OAAO,CAAC,EAAE,yBAAyB;IAOvD,gBAAgB,CAAC,OAAO,CAAC,EAAE,yBAAyB;CAMvD"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import multer, {} from 'multer';
|
|
2
|
-
import { UPLOAD_DIR } from '../constants/globals.js';
|
|
3
|
-
export class Uploader {
|
|
4
|
-
uploadDir;
|
|
5
|
-
constructor(uploadDir = UPLOAD_DIR) {
|
|
6
|
-
this.uploadDir = uploadDir;
|
|
7
|
-
}
|
|
8
|
-
fileFilter = (types) => {
|
|
9
|
-
return (req, file, cb) => {
|
|
10
|
-
const type = file.mimetype;
|
|
11
|
-
if (!types || types.length === 0) {
|
|
12
|
-
return cb(null, true);
|
|
13
|
-
}
|
|
14
|
-
if (types.some((accepted) => type === accepted)) {
|
|
15
|
-
return cb(null, true);
|
|
16
|
-
}
|
|
17
|
-
req.uploaderError = new Error(`we only accept these types ${types}`);
|
|
18
|
-
return cb(null, false);
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
storage = multer.diskStorage({
|
|
22
|
-
destination: (req, file, cb) => {
|
|
23
|
-
cb(null, this.uploadDir);
|
|
24
|
-
},
|
|
25
|
-
filename: (req, file, cb) => {
|
|
26
|
-
cb(null, file.fieldname + Date.now());
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
uploadMultipleFiles(options) {
|
|
30
|
-
return multer({
|
|
31
|
-
storage: this.storage,
|
|
32
|
-
fileFilter: this.fileFilter(options?.types)
|
|
33
|
-
}).array(options?.fieldName || 'file');
|
|
34
|
-
}
|
|
35
|
-
uploadSingleFile(options) {
|
|
36
|
-
return multer({
|
|
37
|
-
storage: this.storage,
|
|
38
|
-
fileFilter: this.fileFilter(options?.types)
|
|
39
|
-
}).single(options?.fieldName || 'file');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=uploader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../src/middlewares/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAA2B,MAAM,QAAQ,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAOpD,MAAM,OAAO,QAAQ;IAEE;IAAnB,YAAmB,YAAqB,UAAU;QAA/B,cAAS,GAAT,SAAS,CAAsB;IAAG,CAAC;IAE/C,UAAU,GAAG,CAAC,KAAqB,EAAE,EAAE;QAC1C,OAAO,CAAC,GAAY,EAAE,IAAyB,EAAE,EAAsB,EAAE,EAAE;YACvE,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAA;YAE1B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YACzB,CAAC;YAED,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,QAAgB,EAAE,EAAE,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;gBACtD,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YACzB,CAAC;YACD,GAAG,CAAC,aAAa,GAAG,IAAI,KAAK,CAAC,8BAA8B,KAAK,EAAE,CAAC,CAAA;YACpE,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QAC1B,CAAC,CAAA;IACL,CAAC,CAAA;IAEM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC;QAChC,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;YAC3B,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QAC5B,CAAC;QACD,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;YACxB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;QACzC,CAAC;KACJ,CAAC,CAAA;IAEF,mBAAmB,CAAC,OAAmC;QACnD,OAAO,MAAM,CAAC;YACV,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC;SAC9C,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,IAAI,MAAM,CAAC,CAAA;IAC1C,CAAC;IAED,gBAAgB,CAAC,OAAmC;QAChD,OAAO,MAAM,CAAC;YACV,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC;SAC9C,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,IAAI,MAAM,CAAC,CAAA;IAC3C,CAAC;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation-request.d.ts","sourceRoot":"","sources":["../../src/middlewares/validation-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAI9D,eAAO,MAAM,iBAAiB,GAAU,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,kBAOlG,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { validationResult } from 'express-validator';
|
|
2
|
-
import { RequestValidationError } from '../index.js';
|
|
3
|
-
export const validationRequest = async (err, req, res, next) => {
|
|
4
|
-
const errors = validationResult(req);
|
|
5
|
-
if (!errors.isEmpty()) {
|
|
6
|
-
return next(new RequestValidationError(errors.array()));
|
|
7
|
-
}
|
|
8
|
-
next();
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=validation-request.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation-request.js","sourceRoot":"","sources":["../../src/middlewares/validation-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,GAAU,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IACnG,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;IACpC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IAC3D,CAAC;IAED,IAAI,EAAE,CAAA;AACV,CAAC,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { JWTPayload } from '../constants/globals.js';
|
|
2
|
-
export declare class AuthenticationService {
|
|
3
|
-
generateJWT(payload: JWTPayload, JWT_KEY: string): string;
|
|
4
|
-
pwdToHash(password: string): Promise<string>;
|
|
5
|
-
pwdCompare(storedPassword: string, suppliedPassword: string): Promise<Boolean>;
|
|
6
|
-
verifyJWT(jwtToken: string, JWT_KEY: string): JWTPayload;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=authentication.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.service.d.ts","sourceRoot":"","sources":["../../src/services/authentication.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAKzD,qBAAa,qBAAqB;IACvB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM;IAI1C,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO5C,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASpF,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU;CAGlE"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import jwt from 'jsonwebtoken';
|
|
2
|
-
import { scrypt, randomBytes } from 'crypto';
|
|
3
|
-
import { promisify } from 'util';
|
|
4
|
-
const scryptAsync = promisify(scrypt);
|
|
5
|
-
export class AuthenticationService {
|
|
6
|
-
generateJWT(payload, JWT_KEY) {
|
|
7
|
-
return jwt.sign(payload, JWT_KEY, { expiresIn: '10h' });
|
|
8
|
-
}
|
|
9
|
-
async pwdToHash(password) {
|
|
10
|
-
const salt = randomBytes(8).toString('hex');
|
|
11
|
-
const buf = (await scryptAsync(password, salt, 64));
|
|
12
|
-
return `${buf.toString('hex')}.${salt}`;
|
|
13
|
-
}
|
|
14
|
-
async pwdCompare(storedPassword, suppliedPassword) {
|
|
15
|
-
const [hashedPassword, salt] = storedPassword.split('.');
|
|
16
|
-
if (!salt)
|
|
17
|
-
return false;
|
|
18
|
-
const buf = (await scryptAsync(suppliedPassword, salt, 64));
|
|
19
|
-
return buf.toString('hex') === hashedPassword;
|
|
20
|
-
}
|
|
21
|
-
verifyJWT(jwtToken, JWT_KEY) {
|
|
22
|
-
return jwt.verify(jwtToken, JWT_KEY);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=authentication.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../src/services/authentication.service.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAEhC,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;AAErC,MAAM,OAAO,qBAAqB;IACvB,WAAW,CAAC,OAAmB,EAAE,OAAe;QACnD,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;IAC3D,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,QAAgB;QACnC,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC3C,MAAM,GAAG,GAAG,CAAC,MAAM,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAW,CAAA;QAE7D,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAA;IAC3C,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,cAAsB,EAAE,gBAAwB;QACpE,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACxD,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAA;QAEvB,MAAM,GAAG,GAAG,CAAC,MAAM,WAAW,CAAC,gBAAgB,EAAE,IAAI,EAAE,EAAE,CAAC,CAAW,CAAA;QAErE,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,cAAc,CAAA;IACjD,CAAC;IAEM,SAAS,CAAC,QAAgB,EAAE,OAAe;QAC9C,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAe,CAAA;IACtD,CAAC;CACJ"}
|