plac-micro-common 1.1.7 → 1.1.8

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.
@@ -42,6 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.JwtVerifierService = void 0;
43
43
  const common_1 = require("@nestjs/common");
44
44
  const jwt = __importStar(require("jsonwebtoken"));
45
+ const types_1 = require("../../types");
45
46
  let JwtVerifierService = class JwtVerifierService {
46
47
  verifyAccessToken(token) {
47
48
  try {
@@ -50,7 +51,20 @@ let JwtVerifierService = class JwtVerifierService {
50
51
  });
51
52
  return payload;
52
53
  }
53
- catch (e) {
54
+ catch (err) {
55
+ if (err instanceof jwt.TokenExpiredError) {
56
+ throw new common_1.UnauthorizedException({
57
+ code: types_1.ErrorCode.AccessTokenExpired,
58
+ message: "Authentication token expired",
59
+ action: "REFRESH_TOKEN",
60
+ });
61
+ }
62
+ if (err instanceof jwt.JsonWebTokenError) {
63
+ throw new common_1.UnauthorizedException({
64
+ code: types_1.ErrorCode.InvalidToken,
65
+ message: "Invalid authentication token",
66
+ });
67
+ }
54
68
  throw new common_1.UnauthorizedException("Invalid or expired token");
55
69
  }
56
70
  }
@@ -0,0 +1,4 @@
1
+ export declare enum ErrorCode {
2
+ AccessTokenExpired = "ACCESS_TOKEN_EXPIRED",
3
+ InvalidToken = "INVALID_TOKEN"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorCode = void 0;
4
+ var ErrorCode;
5
+ (function (ErrorCode) {
6
+ ErrorCode["AccessTokenExpired"] = "ACCESS_TOKEN_EXPIRED";
7
+ ErrorCode["InvalidToken"] = "INVALID_TOKEN";
8
+ })(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
@@ -3,6 +3,7 @@ export * from "./auth.type";
3
3
  export * from "./auth_info.type";
4
4
  export * from "./customer.type";
5
5
  export * from "./general.type";
6
+ export * from "./http.type";
6
7
  export * from "./permission.type";
7
8
  export * from "./product.type";
8
9
  export * from "./promotion.type";
@@ -19,6 +19,7 @@ __exportStar(require("./auth.type"), exports);
19
19
  __exportStar(require("./auth_info.type"), exports);
20
20
  __exportStar(require("./customer.type"), exports);
21
21
  __exportStar(require("./general.type"), exports);
22
+ __exportStar(require("./http.type"), exports);
22
23
  __exportStar(require("./permission.type"), exports);
23
24
  __exportStar(require("./product.type"), exports);
24
25
  __exportStar(require("./promotion.type"), exports);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PaymentModeCode = exports.DiscountType = exports.ProductCode = void 0;
4
+ // @critical
4
5
  var ProductCode;
5
6
  (function (ProductCode) {
6
7
  ProductCode["ExtraSure"] = "EXTRASURE";
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PromotionCode = void 0;
4
+ // @critical
4
5
  var PromotionCode;
5
6
  (function (PromotionCode) {
6
7
  PromotionCode["DB01"] = "DB000001";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plac-micro-common",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {