c2-http 1.0.97 → 1.0.99
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IJWTPayload } from "../../dto/IJWTPayload";
|
|
2
2
|
declare class GenerateTokenFlow {
|
|
3
|
-
execute(jwtPayload: IJWTPayload): string;
|
|
3
|
+
execute(jwtPayload: IJWTPayload, timeToExpireInMinutes?: number): string;
|
|
4
4
|
}
|
|
5
5
|
declare const _default: GenerateTokenFlow;
|
|
6
6
|
export default _default;
|
|
@@ -25,13 +25,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const jwt = __importStar(require("jsonwebtoken"));
|
|
27
27
|
class GenerateTokenFlow {
|
|
28
|
-
execute(jwtPayload) {
|
|
28
|
+
execute(jwtPayload, timeToExpireInMinutes = 1080) {
|
|
29
29
|
if (!process.env.JWT_SECRET) {
|
|
30
30
|
throw new Error("key of token not found");
|
|
31
31
|
}
|
|
32
32
|
const now = new Date();
|
|
33
33
|
const exp = new Date(now);
|
|
34
|
-
exp.setMinutes(now.getMinutes() +
|
|
34
|
+
exp.setMinutes(now.getMinutes() + timeToExpireInMinutes);
|
|
35
35
|
const payload = {
|
|
36
36
|
iss: process.env.API_NAME,
|
|
37
37
|
iat: now.getTime(),
|
package/dist/index.d.ts
CHANGED
|
@@ -11,9 +11,10 @@ import { HttpError } from "./model/HttpError";
|
|
|
11
11
|
import { IControllerOptions } from "./model/IControllerOptions";
|
|
12
12
|
import { ICrudControllerOptions } from "./model/ICrudControllerOptions";
|
|
13
13
|
import { IServerConfig, Server } from "./model/Server";
|
|
14
|
+
import GetTokenFlowItem from "./middleware/jwt-middlware/item/GetTokenFlowItem";
|
|
14
15
|
export declare const convertErrorToHttpError: (error: any) => HttpError;
|
|
15
16
|
export declare const prepareRequestParams: (options?: any) => {
|
|
16
17
|
params: any;
|
|
17
18
|
paramsSerializer: (params: any) => string;
|
|
18
19
|
};
|
|
19
|
-
export { Controller, ControllerRoleMiddleware, ControllerRoute, CrudController, GenerateTokenFlow, getMessage, HttpDispatchDownload, HttpDispatchHandling, IControllerOptions, ICrudControllerOptions, IHealthcheck, IJWTPayload, initializei18n, IOpenApiPath, IServerConfig, MiddlewareCheckScopesFlow, OpenApi, Server };
|
|
20
|
+
export { Controller, ControllerRoleMiddleware, ControllerRoute, CrudController, GenerateTokenFlow, getMessage, HttpDispatchDownload, HttpDispatchHandling, IControllerOptions, ICrudControllerOptions, IHealthcheck, IJWTPayload, initializei18n, IOpenApiPath, IServerConfig, MiddlewareCheckScopesFlow, OpenApi, Server, GetTokenFlowItem };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Server = exports.OpenApi = exports.MiddlewareCheckScopesFlow = exports.initializei18n = exports.HttpDispatchHandling = exports.HttpDispatchDownload = exports.getMessage = exports.GenerateTokenFlow = exports.CrudController = exports.ControllerRoute = exports.ControllerRoleMiddleware = exports.Controller = exports.prepareRequestParams = exports.convertErrorToHttpError = void 0;
|
|
6
|
+
exports.GetTokenFlowItem = exports.Server = exports.OpenApi = exports.MiddlewareCheckScopesFlow = exports.initializei18n = exports.HttpDispatchHandling = exports.HttpDispatchDownload = exports.getMessage = exports.GenerateTokenFlow = exports.CrudController = exports.ControllerRoute = exports.ControllerRoleMiddleware = exports.Controller = exports.prepareRequestParams = exports.convertErrorToHttpError = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const express_http_context_1 = __importDefault(require("express-http-context"));
|
|
9
9
|
const http_status_1 = require("http-status");
|
|
@@ -31,6 +31,8 @@ Object.defineProperty(exports, "CrudController", { enumerable: true, get: functi
|
|
|
31
31
|
const HttpError_1 = require("./model/HttpError");
|
|
32
32
|
const Server_1 = require("./model/Server");
|
|
33
33
|
Object.defineProperty(exports, "Server", { enumerable: true, get: function () { return Server_1.Server; } });
|
|
34
|
+
const GetTokenFlowItem_1 = __importDefault(require("./middleware/jwt-middlware/item/GetTokenFlowItem"));
|
|
35
|
+
exports.GetTokenFlowItem = GetTokenFlowItem_1.default;
|
|
34
36
|
global.OPEN_API_DOC = {
|
|
35
37
|
"openapi": "3.1.0",
|
|
36
38
|
"info": {
|
|
@@ -29,7 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
30
30
|
const http_status_1 = require("http-status");
|
|
31
31
|
const jwt = __importStar(require("jsonwebtoken"));
|
|
32
|
-
const i18n_1 = require("../../../i18n");
|
|
33
32
|
const HttpError_1 = require("../../../model/HttpError");
|
|
34
33
|
const express_http_context_1 = __importDefault(require("express-http-context"));
|
|
35
34
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -58,7 +57,7 @@ class ValidateTokenFlowItem {
|
|
|
58
57
|
return res.data;
|
|
59
58
|
}
|
|
60
59
|
catch (error) {
|
|
61
|
-
throw new HttpError_1.HttpError(http_status_1.FORBIDDEN,
|
|
60
|
+
throw new HttpError_1.HttpError(http_status_1.FORBIDDEN, `error validating token: ${error.message}`);
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2-http",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.99",
|
|
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>",
|