ismx-nexo-node-app 0.4.156 → 0.4.159
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/js/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.PostgresUtils = exports.RestUtils = exports.QueryUtils = exports.RepositoryRestFormalTemplate = exports.RepositoryRestFormal = exports.RepositoryRest = exports.RepositoryDatabasePostgres = exports.RepositoryDatabase = exports.Repository = exports.PromiseUtils = exports.ArrayUtils = exports.StringUtils = exports.ObjectUtils = exports.NumberUtils = exports.CryptoUtils = exports.DateUtils = exports.BusinessLogger = exports.FormalError = exports.BusinessErrors = exports.BusinessThreadState = exports.BusinessThread = exports.BusinessServer = exports.FormalLoopbackBusiness = exports.FormalProxyBusiness = exports.ProxyBusiness = exports.BusinessState = exports.Business = exports.ColorUtils = exports.ServiceRestFormalTemplate = exports.ServiceRestFormal = exports.ServiceRest = exports.HttpResponse = exports.Service = void 0;
|
|
29
|
+
exports.PostgresUtils = exports.JwtUtils = exports.RestUtils = exports.QueryUtils = exports.RepositoryRestFormalTemplate = exports.RepositoryRestFormal = exports.RepositoryRest = exports.RepositoryDatabasePostgres = exports.RepositoryDatabase = exports.Repository = exports.PromiseUtils = exports.ArrayUtils = exports.StringUtils = exports.ObjectUtils = exports.NumberUtils = exports.CryptoUtils = exports.DateUtils = exports.BusinessLogger = exports.FormalError = exports.BusinessErrors = exports.BusinessThreadState = exports.BusinessThread = exports.BusinessServer = exports.FormalLoopbackBusiness = exports.FormalProxyBusiness = exports.ProxyBusiness = exports.BusinessState = exports.Business = exports.ColorUtils = exports.ServiceRestFormalTemplate = exports.ServiceRestFormal = exports.ServiceRest = exports.HttpResponse = exports.Service = void 0;
|
|
30
30
|
const Service_1 = __importStar(require("./api/Service"));
|
|
31
31
|
class Service extends Service_1.default {
|
|
32
32
|
}
|
|
@@ -155,6 +155,10 @@ const RestUtils_1 = __importDefault(require("./repository/utils/RestUtils"));
|
|
|
155
155
|
class RestUtils extends RestUtils_1.default {
|
|
156
156
|
}
|
|
157
157
|
exports.RestUtils = RestUtils;
|
|
158
|
+
const JwtUtils_1 = __importDefault(require("./repository/utils/JwtUtils"));
|
|
159
|
+
class JwtUtils extends JwtUtils_1.default {
|
|
160
|
+
}
|
|
161
|
+
exports.JwtUtils = JwtUtils;
|
|
158
162
|
const PostgresUtils_1 = __importDefault(require("./repository/utils/PostgresUtils"));
|
|
159
163
|
class PostgresUtils extends PostgresUtils_1.default {
|
|
160
164
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const buffer_1 = require("buffer");
|
|
4
|
+
class JwtUtils {
|
|
5
|
+
static decodeBase64Url(base64Url) {
|
|
6
|
+
// Reemplaza caracteres de base64url
|
|
7
|
+
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
8
|
+
// Decodifica en UTF-8
|
|
9
|
+
return decodeURIComponent(buffer_1.Buffer.from(base64, 'base64').toString("utf-8")
|
|
10
|
+
.split("")
|
|
11
|
+
.map(c => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2))
|
|
12
|
+
.join(""));
|
|
13
|
+
}
|
|
14
|
+
static decode(jwt) {
|
|
15
|
+
const [headerB64, payloadB64, signature] = jwt.split(".");
|
|
16
|
+
const header = JSON.parse(JwtUtils.decodeBase64Url(headerB64));
|
|
17
|
+
const payload = JSON.parse(JwtUtils.decodeBase64Url(payloadB64));
|
|
18
|
+
// Si tiene campos de tiempo, conviértelos a fecha legible
|
|
19
|
+
if (payload.iat)
|
|
20
|
+
payload.iat_date = new Date(payload.iat * 1000).toISOString();
|
|
21
|
+
if (payload.exp)
|
|
22
|
+
payload.exp_date = new Date(payload.exp * 1000).toISOString();
|
|
23
|
+
return { header, payload, signature };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = JwtUtils;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -106,6 +106,9 @@ export declare abstract class QueryUtils extends _QueryUtils {
|
|
|
106
106
|
import _RestUtils from "./repository/utils/RestUtils";
|
|
107
107
|
export declare abstract class RestUtils extends _RestUtils {
|
|
108
108
|
}
|
|
109
|
+
import _JwtUtils from "./repository/utils/JwtUtils";
|
|
110
|
+
export declare abstract class JwtUtils extends _JwtUtils {
|
|
111
|
+
}
|
|
109
112
|
import _PostgresUtils from "./repository/utils/PostgresUtils";
|
|
110
113
|
export declare abstract class PostgresUtils extends _PostgresUtils {
|
|
111
114
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default class JwtUtils {
|
|
2
|
+
private static decodeBase64Url;
|
|
3
|
+
static decode(jwt: string): Jwt;
|
|
4
|
+
}
|
|
5
|
+
export interface JwtHeader {
|
|
6
|
+
alg: string;
|
|
7
|
+
typ: string;
|
|
8
|
+
kid?: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface JwtPayload {
|
|
12
|
+
exp?: number;
|
|
13
|
+
iat?: number;
|
|
14
|
+
nbf?: number;
|
|
15
|
+
iss?: string;
|
|
16
|
+
aud?: string | string[];
|
|
17
|
+
sub?: string;
|
|
18
|
+
jti?: string;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
export interface Jwt {
|
|
22
|
+
header: JwtHeader;
|
|
23
|
+
payload: JwtPayload;
|
|
24
|
+
signature: string;
|
|
25
|
+
}
|
package/package.json
CHANGED
package/src/main/node/index.ts
CHANGED
|
@@ -101,5 +101,8 @@ export abstract class QueryUtils extends _QueryUtils {}
|
|
|
101
101
|
import _RestUtils from "./repository/utils/RestUtils";
|
|
102
102
|
export abstract class RestUtils extends _RestUtils {}
|
|
103
103
|
|
|
104
|
+
import _JwtUtils from "./repository/utils/JwtUtils";
|
|
105
|
+
export abstract class JwtUtils extends _JwtUtils {}
|
|
106
|
+
|
|
104
107
|
import _PostgresUtils from "./repository/utils/PostgresUtils";
|
|
105
108
|
export abstract class PostgresUtils extends _PostgresUtils {}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
|
|
3
|
+
export default class JwtUtils
|
|
4
|
+
{
|
|
5
|
+
private static decodeBase64Url(base64Url: string) {
|
|
6
|
+
// Reemplaza caracteres de base64url
|
|
7
|
+
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
8
|
+
// Decodifica en UTF-8
|
|
9
|
+
return decodeURIComponent(
|
|
10
|
+
Buffer.from(base64, 'base64').toString("utf-8")
|
|
11
|
+
.split("")
|
|
12
|
+
.map(c => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2))
|
|
13
|
+
.join("")
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static decode(jwt: string): Jwt {
|
|
18
|
+
const [headerB64, payloadB64, signature] = jwt.split(".");
|
|
19
|
+
const header: JwtHeader = JSON.parse(JwtUtils.decodeBase64Url(headerB64));
|
|
20
|
+
const payload: JwtPayload = JSON.parse(JwtUtils.decodeBase64Url(payloadB64));
|
|
21
|
+
|
|
22
|
+
// Si tiene campos de tiempo, conviértelos a fecha legible
|
|
23
|
+
if (payload.iat) payload.iat_date = new Date(payload.iat * 1000).toISOString();
|
|
24
|
+
if (payload.exp) payload.exp_date = new Date(payload.exp * 1000).toISOString();
|
|
25
|
+
|
|
26
|
+
return { header, payload, signature };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface JwtHeader {
|
|
31
|
+
alg: string; // Algorithm (e.g., "RS256")
|
|
32
|
+
typ: string; // Token type (usually "JWT")
|
|
33
|
+
kid?: string; // Key ID (optional)
|
|
34
|
+
[key: string]: any; // Allow other custom header fields
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface JwtPayload {
|
|
38
|
+
exp?: number; // Expiration time (Unix timestamp)
|
|
39
|
+
iat?: number; // Issued at
|
|
40
|
+
nbf?: number; // Not before
|
|
41
|
+
iss?: string; // Issuer
|
|
42
|
+
aud?: string | string[]; // Audience
|
|
43
|
+
sub?: string; // Subject (usually user ID)
|
|
44
|
+
jti?: string; // JWT ID
|
|
45
|
+
[key: string]: any; // Allow extra claims
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface Jwt {
|
|
49
|
+
header: JwtHeader;
|
|
50
|
+
payload: JwtPayload;
|
|
51
|
+
signature: string;
|
|
52
|
+
}
|