c2-http 1.0.100 → 1.0.103

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.
@@ -28,7 +28,7 @@ class MiddlewareCheckTokenFlow {
28
28
  try {
29
29
  token = GetTokenFlowItem_1.default.get();
30
30
  const tokenDecoded = await ValidateTokenFlowItem_1.default.exec(token);
31
- AddInContextFlowItem_1.default.exec(tokenDecoded);
31
+ AddInContextFlowItem_1.default.exec(tokenDecoded, token);
32
32
  next();
33
33
  }
34
34
  catch (error) {
@@ -1,6 +1,6 @@
1
1
  import { IJWTPayload } from "../../../dto/IJWTPayload";
2
2
  declare class AddInContextFlowItem {
3
- exec(decode: IJWTPayload): void;
3
+ exec(decode: IJWTPayload, token: string): void;
4
4
  }
5
5
  declare const _default: AddInContextFlowItem;
6
6
  export default _default;
@@ -5,7 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const express_http_context_1 = __importDefault(require("express-http-context"));
7
7
  class AddInContextFlowItem {
8
- exec(decode) {
8
+ exec(decode, token) {
9
+ express_http_context_1.default.set("token", token);
9
10
  express_http_context_1.default.set("userId", decode.sub);
10
11
  express_http_context_1.default.set("accountId", decode.account);
11
12
  express_http_context_1.default.set("scopes", decode.scopes);
@@ -48,7 +48,7 @@ class ValidateTokenFlowItem {
48
48
  return res.data;
49
49
  }
50
50
  catch (error) {
51
- throw new Error(error.data?.message ?? error.message);
51
+ throw new Error(error.response?.data?.message ?? error.message);
52
52
  }
53
53
  }
54
54
  // otherwise, construct the URL to validate the token based on the request context
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-http",
3
- "version": "1.0.100",
3
+ "version": "1.0.103",
4
4
  "description": "Biblioteca Typescript para API NodeJS",
5
5
  "repository": "https://cabralsilva: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@github.com/cabralsilva/c2-http.git",
6
6
  "author": "Daniel Cabral <cabralconsultoriaemsoftware@gmail.com>",