@navservice/core 1.105.0 → 1.107.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/_token.d.ts +8 -0
- package/build/es/helpers/index.d.ts +8 -0
- package/build/es/helpers.js +23 -0
- package/build/es/index.js +1 -1
- package/build/es/types/_usuario.d.ts +10 -6
- package/build/es/types/index.d.ts +1 -0
- package/build/lib/helpers/_token.d.ts +8 -0
- package/build/lib/helpers/index.d.ts +8 -0
- package/build/lib/helpers.cjs +28 -0
- package/build/lib/index.cjs +1 -1
- package/build/lib/types/_usuario.d.ts +10 -6
- package/build/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -21,5 +21,13 @@ declare const _token: {
|
|
|
21
21
|
criar_token_micro_servico({ c }: {
|
|
22
22
|
c: t.Context;
|
|
23
23
|
}): Promise<string>;
|
|
24
|
+
criar_refresh_token({ env, usuario_id }: {
|
|
25
|
+
env: t.Env["Bindings"];
|
|
26
|
+
usuario_id: string;
|
|
27
|
+
}): Promise<string>;
|
|
28
|
+
verificar_refresh_token({ env, refresh_token }: {
|
|
29
|
+
env: t.Env["Bindings"];
|
|
30
|
+
refresh_token: string;
|
|
31
|
+
}): Promise<false | import("../types/_usuario").default.RefreshTokenPayload>;
|
|
24
32
|
};
|
|
25
33
|
export default _token;
|
|
@@ -218,6 +218,14 @@ declare const helpers: {
|
|
|
218
218
|
criar_token_micro_servico({ c }: {
|
|
219
219
|
c: import("..").TypesCore.Context;
|
|
220
220
|
}): Promise<string>;
|
|
221
|
+
criar_refresh_token({ env, usuario_id }: {
|
|
222
|
+
env: import("..").TypesCore.Env["Bindings"];
|
|
223
|
+
usuario_id: string;
|
|
224
|
+
}): Promise<string>;
|
|
225
|
+
verificar_refresh_token({ env, refresh_token }: {
|
|
226
|
+
env: import("..").TypesCore.Env["Bindings"];
|
|
227
|
+
refresh_token: string;
|
|
228
|
+
}): Promise<false | import("../types/_usuario").default.RefreshTokenPayload>;
|
|
221
229
|
};
|
|
222
230
|
secret: {
|
|
223
231
|
readonly SALT_LENGTH: 22;
|
package/build/es/helpers.js
CHANGED
|
@@ -396,6 +396,29 @@ const _token = new class {
|
|
|
396
396
|
}));
|
|
397
397
|
return token;
|
|
398
398
|
}
|
|
399
|
+
async criar_refresh_token({ env, usuario_id }) {
|
|
400
|
+
if (!env.JSON_WEB_REFRESH_TOKEN_AUTH_USER) return _set_response.error.WARNING({
|
|
401
|
+
message: "Erro ao gerar refresh token!!",
|
|
402
|
+
results: []
|
|
403
|
+
});
|
|
404
|
+
const token = await new SignJWT({
|
|
405
|
+
usuario_id: usuario_id
|
|
406
|
+
}).setProtectedHeader({
|
|
407
|
+
alg: "HS256"
|
|
408
|
+
}).setIssuedAt().setExpirationTime("2h").sign(new TextEncoder().encode(env.JSON_WEB_REFRESH_TOKEN_AUTH_USER)).catch((error)=>_set_response.error.WARNING({
|
|
409
|
+
message: "Erro ao gerar refresh token!"
|
|
410
|
+
}));
|
|
411
|
+
return token;
|
|
412
|
+
}
|
|
413
|
+
async verificar_refresh_token({ env, refresh_token }) {
|
|
414
|
+
try {
|
|
415
|
+
const secret_verify = new TextEncoder().encode(env.JSON_WEB_REFRESH_TOKEN_AUTH_USER);
|
|
416
|
+
const { payload } = await jwtVerify(refresh_token, secret_verify);
|
|
417
|
+
return payload;
|
|
418
|
+
} catch (error) {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
399
422
|
};
|
|
400
423
|
const helpers_token = _token;
|
|
401
424
|
const scryptAsync = promisify(scrypt);
|
package/build/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z4 from "zod/v4";
|
|
2
2
|
declare namespace TypeControllerUsuario {
|
|
3
|
-
export const PlanNameEnum: readonly ["FREE", "ESSENTIAL", "BUSINESS", "
|
|
3
|
+
export const PlanNameEnum: readonly ["FREE", "ESSENTIAL", "BUSINESS", "ENTERPRISE"];
|
|
4
4
|
export const AppEnum: readonly ["service-usuario", "service-pages", "service-assinatura", "service-bucket"];
|
|
5
5
|
export const AssinaturaStatusEnum: readonly ["active", "canceled", "incomplete", "incomplete_expired", "past_due", "paused", "trialing", "unpaid"];
|
|
6
6
|
export const UsuarioTipoEnum: readonly ["padrao"];
|
|
@@ -28,7 +28,7 @@ declare namespace TypeControllerUsuario {
|
|
|
28
28
|
FREE: "FREE";
|
|
29
29
|
ESSENTIAL: "ESSENTIAL";
|
|
30
30
|
BUSINESS: "BUSINESS";
|
|
31
|
-
|
|
31
|
+
ENTERPRISE: "ENTERPRISE";
|
|
32
32
|
}>;
|
|
33
33
|
type App = z4.infer<typeof AppEnumZod>;
|
|
34
34
|
type UsuarioTipo = z4.infer<typeof UsuarioTipoEnumZod>;
|
|
@@ -39,11 +39,12 @@ declare namespace TypeControllerUsuario {
|
|
|
39
39
|
usuario: {
|
|
40
40
|
_id: string;
|
|
41
41
|
email: string;
|
|
42
|
-
nome
|
|
42
|
+
nome: string;
|
|
43
43
|
imagem?: string;
|
|
44
|
-
token
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
token: string;
|
|
45
|
+
refresh_token: string;
|
|
46
|
+
data_criacao: number;
|
|
47
|
+
ativo: 0 | 1;
|
|
47
48
|
usuario_tipo: UsuarioTipo;
|
|
48
49
|
plano_name: PlanName;
|
|
49
50
|
plano_status: AssinaturaStatusEnum;
|
|
@@ -61,6 +62,9 @@ declare namespace TypeControllerUsuario {
|
|
|
61
62
|
plano_name: PlanName;
|
|
62
63
|
plano_status: AssinaturaStatusEnum;
|
|
63
64
|
}
|
|
65
|
+
export interface RefreshTokenPayload {
|
|
66
|
+
usuario_id: string;
|
|
67
|
+
}
|
|
64
68
|
export {};
|
|
65
69
|
}
|
|
66
70
|
export default TypeControllerUsuario;
|
|
@@ -21,5 +21,13 @@ declare const _token: {
|
|
|
21
21
|
criar_token_micro_servico({ c }: {
|
|
22
22
|
c: t.Context;
|
|
23
23
|
}): Promise<string>;
|
|
24
|
+
criar_refresh_token({ env, usuario_id }: {
|
|
25
|
+
env: t.Env["Bindings"];
|
|
26
|
+
usuario_id: string;
|
|
27
|
+
}): Promise<string>;
|
|
28
|
+
verificar_refresh_token({ env, refresh_token }: {
|
|
29
|
+
env: t.Env["Bindings"];
|
|
30
|
+
refresh_token: string;
|
|
31
|
+
}): Promise<false | import("../types/_usuario").default.RefreshTokenPayload>;
|
|
24
32
|
};
|
|
25
33
|
export default _token;
|
|
@@ -218,6 +218,14 @@ declare const helpers: {
|
|
|
218
218
|
criar_token_micro_servico({ c }: {
|
|
219
219
|
c: import("..").TypesCore.Context;
|
|
220
220
|
}): Promise<string>;
|
|
221
|
+
criar_refresh_token({ env, usuario_id }: {
|
|
222
|
+
env: import("..").TypesCore.Env["Bindings"];
|
|
223
|
+
usuario_id: string;
|
|
224
|
+
}): Promise<string>;
|
|
225
|
+
verificar_refresh_token({ env, refresh_token }: {
|
|
226
|
+
env: import("..").TypesCore.Env["Bindings"];
|
|
227
|
+
refresh_token: string;
|
|
228
|
+
}): Promise<false | import("../types/_usuario").default.RefreshTokenPayload>;
|
|
221
229
|
};
|
|
222
230
|
secret: {
|
|
223
231
|
readonly SALT_LENGTH: 22;
|
package/build/lib/helpers.cjs
CHANGED
|
@@ -473,6 +473,34 @@ const _token = new class _token {
|
|
|
473
473
|
});
|
|
474
474
|
return token;
|
|
475
475
|
}
|
|
476
|
+
async criar_refresh_token({ env, usuario_id }) {
|
|
477
|
+
if (!env.JSON_WEB_REFRESH_TOKEN_AUTH_USER) {
|
|
478
|
+
return _set_response.error.WARNING({
|
|
479
|
+
message: "Erro ao gerar refresh token!!",
|
|
480
|
+
results: []
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
const token = await new external_jose_namespaceObject.SignJWT({
|
|
484
|
+
usuario_id: usuario_id
|
|
485
|
+
}).setProtectedHeader({
|
|
486
|
+
alg: "HS256"
|
|
487
|
+
}).setIssuedAt().setExpirationTime("2h").sign(new TextEncoder().encode(env.JSON_WEB_REFRESH_TOKEN_AUTH_USER)).catch((error)=>{
|
|
488
|
+
return _set_response.error.WARNING({
|
|
489
|
+
message: "Erro ao gerar refresh token!"
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
return token;
|
|
493
|
+
}
|
|
494
|
+
async verificar_refresh_token({ env, refresh_token }) {
|
|
495
|
+
try {
|
|
496
|
+
if (!refresh_token) false;
|
|
497
|
+
const secret_verify = new TextEncoder().encode(env.JSON_WEB_REFRESH_TOKEN_AUTH_USER);
|
|
498
|
+
const { payload } = await external_jose_namespaceObject.jwtVerify(refresh_token, secret_verify);
|
|
499
|
+
return payload;
|
|
500
|
+
} catch (error) {
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
476
504
|
};
|
|
477
505
|
/* export default */ const helpers_token = (_token);
|
|
478
506
|
|
package/build/lib/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z4 from "zod/v4";
|
|
2
2
|
declare namespace TypeControllerUsuario {
|
|
3
|
-
export const PlanNameEnum: readonly ["FREE", "ESSENTIAL", "BUSINESS", "
|
|
3
|
+
export const PlanNameEnum: readonly ["FREE", "ESSENTIAL", "BUSINESS", "ENTERPRISE"];
|
|
4
4
|
export const AppEnum: readonly ["service-usuario", "service-pages", "service-assinatura", "service-bucket"];
|
|
5
5
|
export const AssinaturaStatusEnum: readonly ["active", "canceled", "incomplete", "incomplete_expired", "past_due", "paused", "trialing", "unpaid"];
|
|
6
6
|
export const UsuarioTipoEnum: readonly ["padrao"];
|
|
@@ -28,7 +28,7 @@ declare namespace TypeControllerUsuario {
|
|
|
28
28
|
FREE: "FREE";
|
|
29
29
|
ESSENTIAL: "ESSENTIAL";
|
|
30
30
|
BUSINESS: "BUSINESS";
|
|
31
|
-
|
|
31
|
+
ENTERPRISE: "ENTERPRISE";
|
|
32
32
|
}>;
|
|
33
33
|
type App = z4.infer<typeof AppEnumZod>;
|
|
34
34
|
type UsuarioTipo = z4.infer<typeof UsuarioTipoEnumZod>;
|
|
@@ -39,11 +39,12 @@ declare namespace TypeControllerUsuario {
|
|
|
39
39
|
usuario: {
|
|
40
40
|
_id: string;
|
|
41
41
|
email: string;
|
|
42
|
-
nome
|
|
42
|
+
nome: string;
|
|
43
43
|
imagem?: string;
|
|
44
|
-
token
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
token: string;
|
|
45
|
+
refresh_token: string;
|
|
46
|
+
data_criacao: number;
|
|
47
|
+
ativo: 0 | 1;
|
|
47
48
|
usuario_tipo: UsuarioTipo;
|
|
48
49
|
plano_name: PlanName;
|
|
49
50
|
plano_status: AssinaturaStatusEnum;
|
|
@@ -61,6 +62,9 @@ declare namespace TypeControllerUsuario {
|
|
|
61
62
|
plano_name: PlanName;
|
|
62
63
|
plano_status: AssinaturaStatusEnum;
|
|
63
64
|
}
|
|
65
|
+
export interface RefreshTokenPayload {
|
|
66
|
+
usuario_id: string;
|
|
67
|
+
}
|
|
64
68
|
export {};
|
|
65
69
|
}
|
|
66
70
|
export default TypeControllerUsuario;
|