@ajayjbtickets/common 1.0.13 → 1.0.14
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/dist/index.cjs +23 -8
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +22 -8
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -58,6 +58,7 @@ __export(index_exports, {
|
|
|
58
58
|
ValidationSource: () => ValidationSource,
|
|
59
59
|
asyncHandler: () => asyncHandler,
|
|
60
60
|
logger: () => logger,
|
|
61
|
+
sanitizeObject: () => sanitizeObject,
|
|
61
62
|
schemaValidator: () => schemaValidator,
|
|
62
63
|
verifyToken: () => verifyToken
|
|
63
64
|
});
|
|
@@ -129,16 +130,16 @@ var ApiResponse = class {
|
|
|
129
130
|
this.prepare(res, this, headers);
|
|
130
131
|
}
|
|
131
132
|
sanitize(response) {
|
|
132
|
-
const
|
|
133
|
-
Object.assign(
|
|
134
|
-
delete
|
|
135
|
-
for (const key in
|
|
133
|
+
const clone2 = {};
|
|
134
|
+
Object.assign(clone2, response);
|
|
135
|
+
delete clone2["statusCode"];
|
|
136
|
+
for (const key in clone2) {
|
|
136
137
|
const typedKey = key;
|
|
137
|
-
if (
|
|
138
|
-
delete
|
|
138
|
+
if (clone2[typedKey] === void 0) {
|
|
139
|
+
delete clone2[typedKey];
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
|
-
return
|
|
142
|
+
return clone2;
|
|
142
143
|
}
|
|
143
144
|
};
|
|
144
145
|
var SuccessResponse = class extends ApiResponse {
|
|
@@ -411,7 +412,7 @@ var JwtService = class {
|
|
|
411
412
|
);
|
|
412
413
|
return token;
|
|
413
414
|
}
|
|
414
|
-
static verify(token, verifyOptions) {
|
|
415
|
+
static verify(token, verifyOptions = {}) {
|
|
415
416
|
const decoded = import_jsonwebtoken.default.verify(
|
|
416
417
|
token,
|
|
417
418
|
sanitizedConfig.JWT_KEY,
|
|
@@ -490,6 +491,19 @@ var asyncHandler = (execution) => async (req, res, next) => {
|
|
|
490
491
|
next(err);
|
|
491
492
|
}
|
|
492
493
|
};
|
|
494
|
+
|
|
495
|
+
// src/utils/sanitizeObject.ts
|
|
496
|
+
var import_lodash = require("lodash");
|
|
497
|
+
var sanitizeObject = (value) => {
|
|
498
|
+
const newObject = (0, import_lodash.clone)(value);
|
|
499
|
+
for (const key in newObject) {
|
|
500
|
+
const typedKey = key;
|
|
501
|
+
if (newObject[key] === void 0) {
|
|
502
|
+
delete newObject[key];
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return newObject;
|
|
506
|
+
};
|
|
493
507
|
// Annotate the CommonJS export names for ESM import in node:
|
|
494
508
|
0 && (module.exports = {
|
|
495
509
|
AccessTokenError,
|
|
@@ -520,6 +534,7 @@ var asyncHandler = (execution) => async (req, res, next) => {
|
|
|
520
534
|
ValidationSource,
|
|
521
535
|
asyncHandler,
|
|
522
536
|
logger,
|
|
537
|
+
sanitizeObject,
|
|
523
538
|
schemaValidator,
|
|
524
539
|
verifyToken
|
|
525
540
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -176,4 +176,6 @@ declare class Password {
|
|
|
176
176
|
type AsyncFunction = (req: Request, res: Response, next: NextFunction) => Promise<any>;
|
|
177
177
|
declare const asyncHandler: (execution: AsyncFunction) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
declare const sanitizeObject: <T>(value: T) => T;
|
|
180
|
+
|
|
181
|
+
export { AccessTokenError, AccessTokenErrorResponse, ApiError, ApiResponse, AuthFailureError, BadRequestError, BadRequestResponse, BadTokenError, BadTokenResponse, ENVIRONMENTS, type ErrorDetailType, ErrorType, ForbiddenError, ForbiddenResponse, InternalError, InternalErrorResponse, type JwtPayload, JwtService, NoDataError, NoEntryError, NoFoundResponse, NotFoundError, Password, ResponseStatusCode, StatusCode, SuccessResponse, TokenExpiredError, ValidationSource, asyncHandler, logger, sanitizeObject, schemaValidator, verifyToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -176,4 +176,6 @@ declare class Password {
|
|
|
176
176
|
type AsyncFunction = (req: Request, res: Response, next: NextFunction) => Promise<any>;
|
|
177
177
|
declare const asyncHandler: (execution: AsyncFunction) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
declare const sanitizeObject: <T>(value: T) => T;
|
|
180
|
+
|
|
181
|
+
export { AccessTokenError, AccessTokenErrorResponse, ApiError, ApiResponse, AuthFailureError, BadRequestError, BadRequestResponse, BadTokenError, BadTokenResponse, ENVIRONMENTS, type ErrorDetailType, ErrorType, ForbiddenError, ForbiddenResponse, InternalError, InternalErrorResponse, type JwtPayload, JwtService, NoDataError, NoEntryError, NoFoundResponse, NotFoundError, Password, ResponseStatusCode, StatusCode, SuccessResponse, TokenExpiredError, ValidationSource, asyncHandler, logger, sanitizeObject, schemaValidator, verifyToken };
|
package/dist/index.js
CHANGED
|
@@ -64,16 +64,16 @@ var ApiResponse = class {
|
|
|
64
64
|
this.prepare(res, this, headers);
|
|
65
65
|
}
|
|
66
66
|
sanitize(response) {
|
|
67
|
-
const
|
|
68
|
-
Object.assign(
|
|
69
|
-
delete
|
|
70
|
-
for (const key in
|
|
67
|
+
const clone2 = {};
|
|
68
|
+
Object.assign(clone2, response);
|
|
69
|
+
delete clone2["statusCode"];
|
|
70
|
+
for (const key in clone2) {
|
|
71
71
|
const typedKey = key;
|
|
72
|
-
if (
|
|
73
|
-
delete
|
|
72
|
+
if (clone2[typedKey] === void 0) {
|
|
73
|
+
delete clone2[typedKey];
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
return
|
|
76
|
+
return clone2;
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
var SuccessResponse = class extends ApiResponse {
|
|
@@ -346,7 +346,7 @@ var JwtService = class {
|
|
|
346
346
|
);
|
|
347
347
|
return token;
|
|
348
348
|
}
|
|
349
|
-
static verify(token, verifyOptions) {
|
|
349
|
+
static verify(token, verifyOptions = {}) {
|
|
350
350
|
const decoded = jsonwebtoken.verify(
|
|
351
351
|
token,
|
|
352
352
|
sanitizedConfig.JWT_KEY,
|
|
@@ -425,6 +425,19 @@ var asyncHandler = (execution) => async (req, res, next) => {
|
|
|
425
425
|
next(err);
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
|
+
|
|
429
|
+
// src/utils/sanitizeObject.ts
|
|
430
|
+
import { clone } from "lodash";
|
|
431
|
+
var sanitizeObject = (value) => {
|
|
432
|
+
const newObject = clone(value);
|
|
433
|
+
for (const key in newObject) {
|
|
434
|
+
const typedKey = key;
|
|
435
|
+
if (newObject[key] === void 0) {
|
|
436
|
+
delete newObject[key];
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return newObject;
|
|
440
|
+
};
|
|
428
441
|
export {
|
|
429
442
|
AccessTokenError,
|
|
430
443
|
AccessTokenErrorResponse,
|
|
@@ -454,6 +467,7 @@ export {
|
|
|
454
467
|
ValidationSource,
|
|
455
468
|
asyncHandler,
|
|
456
469
|
logger,
|
|
470
|
+
sanitizeObject,
|
|
457
471
|
schemaValidator,
|
|
458
472
|
verifyToken
|
|
459
473
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ajayjbtickets/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"dotenv": "^16.5.0",
|
|
37
37
|
"express": "^5.1.0",
|
|
38
38
|
"jsonwebtoken": "^9.0.2",
|
|
39
|
+
"lodash": "^4.17.21",
|
|
39
40
|
"winston": "^3.17.0",
|
|
40
41
|
"winston-daily-rotate-file": "^5.0.0",
|
|
41
42
|
"zod": "^3.24.4"
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
"@types/cookie-session": "^2.0.49",
|
|
46
47
|
"@types/express": "^5.0.1",
|
|
47
48
|
"@types/jsonwebtoken": "^9.0.9",
|
|
49
|
+
"@types/lodash": "^4.17.17",
|
|
48
50
|
"del-cli": "^6.0.0",
|
|
49
51
|
"tsup": "^8.4.0",
|
|
50
52
|
"tsx": "^4.19.4",
|