@navservice/core 1.97.0 → 1.99.0
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/build/es/helpers/_data.d.ts +4 -3
- package/build/es/helpers/_secret.d.ts +6 -5
- package/build/es/helpers/_set_response.d.ts +0 -3
- package/build/es/helpers/_token.d.ts +0 -1
- package/build/es/helpers/index.d.ts +13 -8
- package/build/es/helpers.js +34 -34
- package/build/es/index.js +44 -40
- package/build/es/utils/_data.d.ts +0 -1
- package/build/es/utils/_environment.d.ts +2 -3
- package/build/es/utils/_form.d.ts +10 -9
- package/build/es/utils/_geral.d.ts +0 -1
- package/build/es/utils/_local_storage.d.ts +0 -1
- package/build/es/utils/_session_storage.d.ts +1 -1
- package/build/es/utils/_update_context.d.ts +0 -1
- package/build/es/utils/index.d.ts +11 -8
- package/build/lib/helpers/_data.d.ts +4 -3
- package/build/lib/helpers/_secret.d.ts +6 -5
- package/build/lib/helpers/_set_response.d.ts +0 -3
- package/build/lib/helpers/_token.d.ts +0 -1
- package/build/lib/helpers/index.d.ts +13 -8
- package/build/lib/helpers.cjs +34 -34
- package/build/lib/index.cjs +44 -41
- package/build/lib/utils/_data.d.ts +0 -1
- package/build/lib/utils/_environment.d.ts +2 -3
- package/build/lib/utils/_form.d.ts +10 -9
- package/build/lib/utils/_geral.d.ts +0 -1
- package/build/lib/utils/_local_storage.d.ts +0 -1
- package/build/lib/utils/_session_storage.d.ts +1 -1
- package/build/lib/utils/_update_context.d.ts +0 -1
- package/build/lib/utils/index.d.ts +11 -8
- package/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
declare class _form {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
regex_cpf_cnpj(value: string): string;
|
|
3
|
+
formatar_cpf(value: string): string;
|
|
4
|
+
formatar_cnpj(value: string): string;
|
|
5
|
+
formatar_cep(value: string): string;
|
|
6
|
+
formatar_telefone_fixo(value: string): string;
|
|
7
|
+
formatar_celular(value: string): string;
|
|
8
|
+
formatar_nome(name: string): string;
|
|
9
|
+
formatar_reais_br(value: string): string;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
declare const _default: _form;
|
|
12
|
+
export default _default;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
declare const _session_storage: {
|
|
2
|
-
new (): {};
|
|
3
2
|
adicionar_item_session_storage({ chave, novoItem }: {
|
|
4
3
|
chave: string;
|
|
5
4
|
novoItem: any;
|
|
@@ -10,5 +9,6 @@ declare const _session_storage: {
|
|
|
10
9
|
}): void;
|
|
11
10
|
get_item_session_storage(chave: string): any;
|
|
12
11
|
remover_item_session_storage(chave: string): void;
|
|
12
|
+
get usuario_auth(): import("../types/_usuario").default.Auth;
|
|
13
13
|
};
|
|
14
14
|
export default _session_storage;
|
|
@@ -9,7 +9,6 @@ type RemoveArrayItems = {
|
|
|
9
9
|
key?: string | "_id" | "id";
|
|
10
10
|
};
|
|
11
11
|
declare const _update_context: {
|
|
12
|
-
new (): {};
|
|
13
12
|
set_new_item_end: ({ oldArray, newItem, key }: ParamsPadrao) => any;
|
|
14
13
|
update_array_itens: ({ oldArray, newItem, key }: ParamsPadrao) => any;
|
|
15
14
|
remove_array_items: ({ oldArray, itemsToRemove, key }: RemoveArrayItems) => any[];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _form from "./_form";
|
|
2
1
|
declare const utils: {
|
|
3
2
|
api: {
|
|
4
3
|
new (): {};
|
|
@@ -61,7 +60,6 @@ declare const utils: {
|
|
|
61
60
|
};
|
|
62
61
|
};
|
|
63
62
|
data: {
|
|
64
|
-
new (): {};
|
|
65
63
|
YYYY_MM_DD_00_00_00(newData: string): string;
|
|
66
64
|
DD_MM_YYYY_00_00_00(newData: string): string;
|
|
67
65
|
DD_MM_YYYY_00_00(newData: string): string;
|
|
@@ -71,9 +69,17 @@ declare const utils: {
|
|
|
71
69
|
DIFERENCA_DIAS(data: string): number;
|
|
72
70
|
SET_SECONDS_TO_DD_MM_YYYY_HH_MM(timestamp: number | string): string;
|
|
73
71
|
};
|
|
74
|
-
form:
|
|
72
|
+
form: {
|
|
73
|
+
regex_cpf_cnpj(value: string): string;
|
|
74
|
+
formatar_cpf(value: string): string;
|
|
75
|
+
formatar_cnpj(value: string): string;
|
|
76
|
+
formatar_cep(value: string): string;
|
|
77
|
+
formatar_telefone_fixo(value: string): string;
|
|
78
|
+
formatar_celular(value: string): string;
|
|
79
|
+
formatar_nome(name: string): string;
|
|
80
|
+
formatar_reais_br(value: string): string;
|
|
81
|
+
};
|
|
75
82
|
geral: {
|
|
76
|
-
new (): {};
|
|
77
83
|
slice_file_name(filename: string, maxLength?: number): string;
|
|
78
84
|
extrair_id(array_enviado: Array<{
|
|
79
85
|
_id?: string;
|
|
@@ -81,14 +87,12 @@ declare const utils: {
|
|
|
81
87
|
gerar_id: (length?: number) => string;
|
|
82
88
|
};
|
|
83
89
|
local_storage: {
|
|
84
|
-
new (): {};
|
|
85
90
|
adicionar_item_local_storage(chave: string, novoItem: any): void;
|
|
86
91
|
set_local_storage_sem_incremento(chave: string, novoItem: any): void;
|
|
87
92
|
get_item_local_storage(chave: string): any;
|
|
88
93
|
remover_item_local_storage(chave: string): void;
|
|
89
94
|
};
|
|
90
95
|
update_context: {
|
|
91
|
-
new (): {};
|
|
92
96
|
set_new_item_end: ({ oldArray, newItem, key }: {
|
|
93
97
|
oldArray: any[];
|
|
94
98
|
newItem: any;
|
|
@@ -110,7 +114,6 @@ declare const utils: {
|
|
|
110
114
|
}): any[];
|
|
111
115
|
};
|
|
112
116
|
session_sorage: {
|
|
113
|
-
new (): {};
|
|
114
117
|
adicionar_item_session_storage({ chave, novoItem }: {
|
|
115
118
|
chave: string;
|
|
116
119
|
novoItem: any;
|
|
@@ -121,6 +124,7 @@ declare const utils: {
|
|
|
121
124
|
}): void;
|
|
122
125
|
get_item_session_storage(chave: string): any;
|
|
123
126
|
remover_item_session_storage(chave: string): void;
|
|
127
|
+
get usuario_auth(): import("../types/_usuario").default.Auth;
|
|
124
128
|
};
|
|
125
129
|
sistema: {
|
|
126
130
|
empresa: {
|
|
@@ -175,7 +179,6 @@ declare const utils: {
|
|
|
175
179
|
use_dark_mode(): void;
|
|
176
180
|
};
|
|
177
181
|
environment: {
|
|
178
|
-
new (): {};
|
|
179
182
|
set(key: import("..").TypesCore.Geral.BaseUrl, props: string): void;
|
|
180
183
|
get(key: import("..").TypesCore.Geral.BaseUrl): import("..").TypesCore.Geral.BaseUrl;
|
|
181
184
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare class _data {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
get get_now_format_number(): number;
|
|
3
|
+
verificar_data(value: number): number;
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
declare const _default: _data;
|
|
6
|
+
export default _default;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
declare class _secret {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
readonly SALT_LENGTH = 22;
|
|
3
|
+
readonly KEY_LENGTH = 35;
|
|
4
|
+
gerar_hash_senha(password: string): Promise<string>;
|
|
5
|
+
verify({ password, dashed_senha }: {
|
|
6
6
|
password: string;
|
|
7
7
|
dashed_senha: string;
|
|
8
8
|
}): Promise<boolean>;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
declare const _default: _secret;
|
|
11
|
+
export default _default;
|
|
@@ -3,9 +3,7 @@ type ResponseCOmmit = Omit<t.Geral.Response.C.Input, "type" | "code" | "status">
|
|
|
3
3
|
type ResponseErrorOmmit = Omit<t.Geral.Response.Error.Input, "type" | "code" | "status">;
|
|
4
4
|
export type ResponseCPayload<T = unknown> = Omit<t.Geral.Response.C.Input<T>, "c">;
|
|
5
5
|
declare const set_response: {
|
|
6
|
-
new (): {};
|
|
7
6
|
c: {
|
|
8
|
-
new (): {};
|
|
9
7
|
SUCCESS<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
10
8
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
11
9
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
@@ -134,7 +132,6 @@ declare const set_response: {
|
|
|
134
132
|
}, 200, "json">)>;
|
|
135
133
|
};
|
|
136
134
|
error: {
|
|
137
|
-
new (): {};
|
|
138
135
|
ACTION_REQUIRED({ message, results }: ResponseErrorOmmit): void;
|
|
139
136
|
WARNING({ message, results }: ResponseErrorOmmit): void;
|
|
140
137
|
AUTHORIZATION_ERROR({ message, results }: ResponseErrorOmmit): void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Next } from 'hono';
|
|
2
2
|
import t from '../types';
|
|
3
3
|
declare const _token: {
|
|
4
|
-
new (): {};
|
|
5
4
|
verificar_token(c: t.Context, next: Next): Promise<void | (Response & import("hono").TypedResponse<{
|
|
6
5
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
7
6
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import _secret from "./_secret";
|
|
2
|
-
import _data from "./_data";
|
|
3
1
|
declare const helpers: {
|
|
4
2
|
set_response: {
|
|
5
|
-
new (): {};
|
|
6
3
|
c: {
|
|
7
|
-
new (): {};
|
|
8
4
|
SUCCESS<T>({ message, results, c }: {
|
|
9
5
|
message?: string | undefined;
|
|
10
6
|
results: any;
|
|
@@ -165,7 +161,6 @@ declare const helpers: {
|
|
|
165
161
|
}, 200, "json">)>;
|
|
166
162
|
};
|
|
167
163
|
error: {
|
|
168
|
-
new (): {};
|
|
169
164
|
ACTION_REQUIRED({ message, results }: {
|
|
170
165
|
message?: string | undefined;
|
|
171
166
|
results?: unknown;
|
|
@@ -203,7 +198,6 @@ declare const helpers: {
|
|
|
203
198
|
};
|
|
204
199
|
};
|
|
205
200
|
token: {
|
|
206
|
-
new (): {};
|
|
207
201
|
verificar_token(c: import("..").TypesCore.Context, next: import("hono").Next): Promise<void | (Response & import("hono").TypedResponse<{
|
|
208
202
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
209
203
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
@@ -225,7 +219,18 @@ declare const helpers: {
|
|
|
225
219
|
c: import("..").TypesCore.Context;
|
|
226
220
|
}): Promise<string>;
|
|
227
221
|
};
|
|
228
|
-
secret:
|
|
229
|
-
|
|
222
|
+
secret: {
|
|
223
|
+
readonly SALT_LENGTH: 22;
|
|
224
|
+
readonly KEY_LENGTH: 35;
|
|
225
|
+
gerar_hash_senha(password: string): Promise<string>;
|
|
226
|
+
verify({ password, dashed_senha }: {
|
|
227
|
+
password: string;
|
|
228
|
+
dashed_senha: string;
|
|
229
|
+
}): Promise<boolean>;
|
|
230
|
+
};
|
|
231
|
+
data: {
|
|
232
|
+
get get_now_format_number(): number;
|
|
233
|
+
verificar_data(value: number): number;
|
|
234
|
+
};
|
|
230
235
|
};
|
|
231
236
|
export default helpers;
|
package/build/lib/helpers.cjs
CHANGED
|
@@ -60,9 +60,9 @@ var v4_default = /*#__PURE__*/__webpack_require__.n(v4_namespaceObject);
|
|
|
60
60
|
;// CONCATENATED MODULE: ./src/helpers/_set_response.ts
|
|
61
61
|
// TYPES
|
|
62
62
|
|
|
63
|
-
const set_response = class set_response {
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const set_response = new class set_response {
|
|
64
|
+
c = new class c {
|
|
65
|
+
SUCCESS({ message, results, c }) {
|
|
66
66
|
const payload = {
|
|
67
67
|
status: 200,
|
|
68
68
|
code: "SUCCESS",
|
|
@@ -74,7 +74,7 @@ const set_response = class set_response {
|
|
|
74
74
|
status: 200
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
ACTION_REQUIRED({ message, results, c }) {
|
|
78
78
|
const payload = {
|
|
79
79
|
status: 428,
|
|
80
80
|
code: "ACTION_REQUIRED",
|
|
@@ -86,7 +86,7 @@ const set_response = class set_response {
|
|
|
86
86
|
status: 428
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
CREATED({ message, results, c }) {
|
|
90
90
|
const payload = {
|
|
91
91
|
status: 201,
|
|
92
92
|
code: "CREATED",
|
|
@@ -98,7 +98,7 @@ const set_response = class set_response {
|
|
|
98
98
|
status: 201
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
WARNING({ message, results, c }) {
|
|
102
102
|
const payload = {
|
|
103
103
|
status: 400,
|
|
104
104
|
code: "WARNING",
|
|
@@ -110,7 +110,7 @@ const set_response = class set_response {
|
|
|
110
110
|
status: 400
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
AUTHORIZATION_ERROR({ message, results, c }) {
|
|
114
114
|
const payload = {
|
|
115
115
|
status: 405,
|
|
116
116
|
code: "WARNING",
|
|
@@ -122,7 +122,7 @@ const set_response = class set_response {
|
|
|
122
122
|
status: 405
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
SERVER_ERROR({ error, c }) {
|
|
126
126
|
if (error instanceof (v4_default()).ZodError) {
|
|
127
127
|
const payload = {
|
|
128
128
|
status: 500,
|
|
@@ -146,7 +146,7 @@ const set_response = class set_response {
|
|
|
146
146
|
status: error?.status || error?.status || 500
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
UNAUTHORIZED({ message, c }) {
|
|
150
150
|
const payload = {
|
|
151
151
|
status: 401,
|
|
152
152
|
code: "UNAUTHORIZED",
|
|
@@ -158,7 +158,7 @@ const set_response = class set_response {
|
|
|
158
158
|
status: 401
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
INVALID_TOKEN({ message, c }) {
|
|
162
162
|
const payload = {
|
|
163
163
|
status: 409,
|
|
164
164
|
code: "INVALID_TOKEN",
|
|
@@ -170,7 +170,7 @@ const set_response = class set_response {
|
|
|
170
170
|
status: 409
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
-
|
|
173
|
+
NOT_FOUND({ message, c }) {
|
|
174
174
|
const payload = {
|
|
175
175
|
status: 404,
|
|
176
176
|
code: "NOT_FOUND",
|
|
@@ -182,7 +182,7 @@ const set_response = class set_response {
|
|
|
182
182
|
status: 404
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
async SUCCESS_FILE({ message, file_buffer, content_type, filename, c }) {
|
|
186
186
|
if (c && content_type) {
|
|
187
187
|
const headers = {
|
|
188
188
|
"Content-Type": content_type,
|
|
@@ -205,8 +205,8 @@ const set_response = class set_response {
|
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
error = new class error {
|
|
209
|
+
ACTION_REQUIRED({ message, results }) {
|
|
210
210
|
const payload = {
|
|
211
211
|
status: 428,
|
|
212
212
|
code: "ACTION_REQUIRED",
|
|
@@ -216,7 +216,7 @@ const set_response = class set_response {
|
|
|
216
216
|
};
|
|
217
217
|
throw payload;
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
WARNING({ message, results }) {
|
|
220
220
|
const payload = {
|
|
221
221
|
status: 400,
|
|
222
222
|
code: "WARNING",
|
|
@@ -226,7 +226,7 @@ const set_response = class set_response {
|
|
|
226
226
|
};
|
|
227
227
|
throw payload;
|
|
228
228
|
}
|
|
229
|
-
|
|
229
|
+
AUTHORIZATION_ERROR({ message, results }) {
|
|
230
230
|
const payload = {
|
|
231
231
|
status: 400,
|
|
232
232
|
code: "WARNING",
|
|
@@ -236,7 +236,7 @@ const set_response = class set_response {
|
|
|
236
236
|
};
|
|
237
237
|
throw payload;
|
|
238
238
|
}
|
|
239
|
-
|
|
239
|
+
DATABASE_ERROR({ message, results, erro }) {
|
|
240
240
|
const errorCode = erro?.cause?.code || erro?.cause?.cause?.code || erro?.code || "";
|
|
241
241
|
const map = {
|
|
242
242
|
"SQLITE_CONSTRAINT_UNIQUE": {
|
|
@@ -281,7 +281,7 @@ const set_response = class set_response {
|
|
|
281
281
|
};
|
|
282
282
|
throw payload;
|
|
283
283
|
}
|
|
284
|
-
|
|
284
|
+
SCHEMA_VALIDATION({ results }) {
|
|
285
285
|
const payload = {
|
|
286
286
|
status: 500,
|
|
287
287
|
code: "SCHEMA_VALIDATION",
|
|
@@ -291,7 +291,7 @@ const set_response = class set_response {
|
|
|
291
291
|
};
|
|
292
292
|
throw payload;
|
|
293
293
|
}
|
|
294
|
-
|
|
294
|
+
UNAUTHORIZED({ message }) {
|
|
295
295
|
const payload = {
|
|
296
296
|
status: 401,
|
|
297
297
|
code: "UNAUTHORIZED",
|
|
@@ -300,7 +300,7 @@ const set_response = class set_response {
|
|
|
300
300
|
};
|
|
301
301
|
throw payload;
|
|
302
302
|
}
|
|
303
|
-
|
|
303
|
+
INVALID_TOKEN({ message }) {
|
|
304
304
|
const payload = {
|
|
305
305
|
status: 401,
|
|
306
306
|
code: "INVALID_TOKEN",
|
|
@@ -310,7 +310,7 @@ const set_response = class set_response {
|
|
|
310
310
|
};
|
|
311
311
|
throw payload;
|
|
312
312
|
}
|
|
313
|
-
|
|
313
|
+
NOT_FOUND({ message }) {
|
|
314
314
|
const payload = {
|
|
315
315
|
status: 404,
|
|
316
316
|
code: "NOT_FOUND",
|
|
@@ -329,8 +329,8 @@ const external_jose_namespaceObject = require("jose");
|
|
|
329
329
|
|
|
330
330
|
// Tem que importar assim para evitar dependencia circular
|
|
331
331
|
|
|
332
|
-
const _token = class _token {
|
|
333
|
-
|
|
332
|
+
const _token = new class _token {
|
|
333
|
+
async verificar_token(c, next) {
|
|
334
334
|
try {
|
|
335
335
|
const authHeader = c.req.header("Authorization");
|
|
336
336
|
if (!authHeader) return _set_response.c.INVALID_TOKEN({
|
|
@@ -372,7 +372,7 @@ const _token = class _token {
|
|
|
372
372
|
});
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
|
|
375
|
+
async criar_token_login_usuario({ _id, email, app, usuario_tipo, ativo, data_criacao, nome, c }) {
|
|
376
376
|
if (!c.env.JSON_WEB_TOKEN_AUTH_USER) {
|
|
377
377
|
return _set_response.error.WARNING({
|
|
378
378
|
message: "Erro ao gerar token!!",
|
|
@@ -398,7 +398,7 @@ const _token = class _token {
|
|
|
398
398
|
});
|
|
399
399
|
return token;
|
|
400
400
|
}
|
|
401
|
-
|
|
401
|
+
async verificar_token_micro_servico(c, next) {
|
|
402
402
|
try {
|
|
403
403
|
const authHeader = c.req.header("Authorization");
|
|
404
404
|
if (!authHeader) return _set_response.c.INVALID_TOKEN({
|
|
@@ -440,7 +440,7 @@ const _token = class _token {
|
|
|
440
440
|
});
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
-
|
|
443
|
+
async criar_token_micro_servico({ c }) {
|
|
444
444
|
if (!c.env.JSON_WEB_TOKEN_AUTH_MICRO_SERVICO) {
|
|
445
445
|
return _set_response.error.WARNING({
|
|
446
446
|
message: "Erro ao gerar token!!",
|
|
@@ -478,14 +478,14 @@ const external_node_util_namespaceObject = require("node:util");
|
|
|
478
478
|
|
|
479
479
|
const scryptAsync = (0,external_node_util_namespaceObject.promisify)(external_node_crypto_namespaceObject.scrypt);
|
|
480
480
|
class _secret {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
481
|
+
SALT_LENGTH = 22;
|
|
482
|
+
KEY_LENGTH = 35;
|
|
483
|
+
async gerar_hash_senha(password) {
|
|
484
484
|
const salt = (0,external_node_crypto_namespaceObject.randomBytes)(this.SALT_LENGTH);
|
|
485
485
|
const derivedKey = await scryptAsync(password, salt, this.KEY_LENGTH);
|
|
486
486
|
return salt.toString('base64') + '.' + derivedKey.toString('base64');
|
|
487
487
|
}
|
|
488
|
-
|
|
488
|
+
async verify({ password, dashed_senha }) {
|
|
489
489
|
try {
|
|
490
490
|
const [saltBase64, hashBase64] = dashed_senha.split('.');
|
|
491
491
|
if (!saltBase64 || !hashBase64) return false;
|
|
@@ -498,14 +498,14 @@ class _secret {
|
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
|
-
/* export default */ const helpers_secret = (_secret);
|
|
501
|
+
/* export default */ const helpers_secret = (new _secret);
|
|
502
502
|
|
|
503
503
|
;// CONCATENATED MODULE: ./src/helpers/_data.ts
|
|
504
504
|
class _data {
|
|
505
|
-
|
|
505
|
+
get get_now_format_number() {
|
|
506
506
|
return Math.floor(Date.now() / 1000);
|
|
507
507
|
}
|
|
508
|
-
|
|
508
|
+
verificar_data(value) {
|
|
509
509
|
const data = new Date(value * 1000);
|
|
510
510
|
if (isNaN(data.getTime())) {
|
|
511
511
|
throw new Error("Timestamp está inválido.");
|
|
@@ -513,7 +513,7 @@ class _data {
|
|
|
513
513
|
return value; // válido
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
|
-
/* export default */ const helpers_data = (_data);
|
|
516
|
+
/* export default */ const helpers_data = (new _data);
|
|
517
517
|
|
|
518
518
|
;// CONCATENATED MODULE: ./src/helpers/index.ts
|
|
519
519
|
//_HELPERS
|