@navservice/core 1.103.0 → 1.106.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 +9 -1
- package/build/es/helpers/index.d.ts +9 -1
- package/build/es/helpers.js +44 -13
- package/build/es/index.js +18 -0
- package/build/es/types/_usuario.d.ts +33 -4
- package/build/es/types/index.d.ts +1 -0
- package/build/lib/helpers/_token.d.ts +9 -1
- package/build/lib/helpers/index.d.ts +9 -1
- package/build/lib/helpers.cjs +50 -15
- package/build/lib/index.cjs +18 -0
- package/build/lib/types/_usuario.d.ts +33 -4
- package/build/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ declare const _token: {
|
|
|
8
8
|
message?: string | undefined;
|
|
9
9
|
results: any;
|
|
10
10
|
}, 409, "json">)>;
|
|
11
|
-
criar_token_login_usuario(
|
|
11
|
+
criar_token_login_usuario(props: t.Controller.Usuario.TokenPayload & {
|
|
12
12
|
c: t.Context;
|
|
13
13
|
}): Promise<string>;
|
|
14
14
|
verificar_token_micro_servico(c: t.Context, next: Next): Promise<void | (Response & import("hono").TypedResponse<{
|
|
@@ -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;
|
|
@@ -205,7 +205,7 @@ declare const helpers: {
|
|
|
205
205
|
message?: string | undefined;
|
|
206
206
|
results: any;
|
|
207
207
|
}, 409, "json">)>;
|
|
208
|
-
criar_token_login_usuario(
|
|
208
|
+
criar_token_login_usuario(props: import("../types/_usuario").default.TokenPayload & {
|
|
209
209
|
c: import("..").TypesCore.Context;
|
|
210
210
|
}): Promise<string>;
|
|
211
211
|
verificar_token_micro_servico(c: import("..").TypesCore.Context, next: import("hono").Next): Promise<void | (Response & import("hono").TypedResponse<{
|
|
@@ -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
|
@@ -293,7 +293,9 @@ const _token = new class {
|
|
|
293
293
|
data_criacao: payload.data_criacao,
|
|
294
294
|
nome: payload.nome,
|
|
295
295
|
app: payload.app,
|
|
296
|
-
usuario_tipo: payload.usuario_tipo
|
|
296
|
+
usuario_tipo: payload.usuario_tipo,
|
|
297
|
+
plano_name: payload?.plano_name,
|
|
298
|
+
plano_status: payload?.plano_status
|
|
297
299
|
};
|
|
298
300
|
c.set("usuario_auth", setar_token);
|
|
299
301
|
return await next();
|
|
@@ -305,22 +307,24 @@ const _token = new class {
|
|
|
305
307
|
});
|
|
306
308
|
}
|
|
307
309
|
}
|
|
308
|
-
async criar_token_login_usuario(
|
|
309
|
-
if (!c.env.JSON_WEB_TOKEN_AUTH_USER)
|
|
310
|
+
async criar_token_login_usuario(props) {
|
|
311
|
+
if (!props?.c.env.JSON_WEB_TOKEN_AUTH_USER) _set_response.error.WARNING({
|
|
310
312
|
message: "Erro ao gerar token!!",
|
|
311
313
|
results: []
|
|
312
314
|
});
|
|
313
315
|
const token = await new SignJWT({
|
|
314
|
-
_id: _id,
|
|
315
|
-
email: email,
|
|
316
|
-
app: app,
|
|
317
|
-
usuario_tipo: usuario_tipo,
|
|
318
|
-
ativo: ativo,
|
|
319
|
-
data_criacao: data_criacao,
|
|
320
|
-
nome: nome
|
|
316
|
+
_id: props?._id,
|
|
317
|
+
email: props?.email,
|
|
318
|
+
app: props?.app,
|
|
319
|
+
usuario_tipo: props?.usuario_tipo,
|
|
320
|
+
ativo: props?.ativo,
|
|
321
|
+
data_criacao: props?.data_criacao,
|
|
322
|
+
nome: props?.nome,
|
|
323
|
+
plano_name: props?.plano_name,
|
|
324
|
+
plano_status: props?.plano_status
|
|
321
325
|
}).setProtectedHeader({
|
|
322
326
|
alg: "HS256"
|
|
323
|
-
}).setIssuedAt().sign(new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_USER)).catch((error)=>_set_response.error.WARNING({
|
|
327
|
+
}).setIssuedAt().setExpirationTime("1h").sign(new TextEncoder().encode(props?.c.env.JSON_WEB_TOKEN_AUTH_USER)).catch((error)=>_set_response.error.WARNING({
|
|
324
328
|
message: "Erro ao gerar token!",
|
|
325
329
|
results: error?.message
|
|
326
330
|
}));
|
|
@@ -354,7 +358,9 @@ const _token = new class {
|
|
|
354
358
|
data_criacao: payload.data_criacao,
|
|
355
359
|
nome: payload.nome,
|
|
356
360
|
app: payload.app,
|
|
357
|
-
usuario_tipo: payload.usuario_tipo
|
|
361
|
+
usuario_tipo: payload.usuario_tipo,
|
|
362
|
+
plano_name: payload?.plano_name,
|
|
363
|
+
plano_status: payload?.plano_status
|
|
358
364
|
};
|
|
359
365
|
c.set("usuario_auth", setar_token);
|
|
360
366
|
return await next();
|
|
@@ -379,7 +385,9 @@ const _token = new class {
|
|
|
379
385
|
usuario_tipo: usuario_auth?.usuario_tipo,
|
|
380
386
|
ativo: usuario_auth?.ativo,
|
|
381
387
|
data_criacao: usuario_auth?.data_criacao,
|
|
382
|
-
nome: usuario_auth?.nome
|
|
388
|
+
nome: usuario_auth?.nome,
|
|
389
|
+
plano_name: usuario_auth?.plano_name,
|
|
390
|
+
plano_status: usuario_auth?.plano_status
|
|
383
391
|
}).setProtectedHeader({
|
|
384
392
|
alg: "HS256"
|
|
385
393
|
}).setIssuedAt().setExpirationTime("30s").sign(new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_MICRO_SERVICO)).catch((error)=>_set_response.error.WARNING({
|
|
@@ -388,6 +396,29 @@ const _token = new class {
|
|
|
388
396
|
}));
|
|
389
397
|
return token;
|
|
390
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
|
+
}
|
|
391
422
|
};
|
|
392
423
|
const helpers_token = _token;
|
|
393
424
|
const scryptAsync = promisify(scrypt);
|
package/build/es/index.js
CHANGED
|
@@ -2,12 +2,28 @@ import v4 from "zod/v4";
|
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import { useLayoutEffect, useState } from "react";
|
|
4
4
|
(function(TypeControllerUsuario) {
|
|
5
|
+
TypeControllerUsuario.PlanNameEnum = [
|
|
6
|
+
"FREE",
|
|
7
|
+
"ESSENTIAL",
|
|
8
|
+
"BUSINESS",
|
|
9
|
+
"ULTIMATE"
|
|
10
|
+
];
|
|
5
11
|
TypeControllerUsuario.AppEnum = [
|
|
6
12
|
"service-usuario",
|
|
7
13
|
"service-pages",
|
|
8
14
|
"service-assinatura",
|
|
9
15
|
"service-bucket"
|
|
10
16
|
];
|
|
17
|
+
TypeControllerUsuario.AssinaturaStatusEnum = [
|
|
18
|
+
"active",
|
|
19
|
+
"canceled",
|
|
20
|
+
"incomplete",
|
|
21
|
+
"incomplete_expired",
|
|
22
|
+
"past_due",
|
|
23
|
+
"paused",
|
|
24
|
+
"trialing",
|
|
25
|
+
"unpaid"
|
|
26
|
+
];
|
|
11
27
|
TypeControllerUsuario.UsuarioTipoEnum = [
|
|
12
28
|
"padrao"
|
|
13
29
|
];
|
|
@@ -27,6 +43,8 @@ import { useLayoutEffect, useState } from "react";
|
|
|
27
43
|
};
|
|
28
44
|
v4["enum"](TypeControllerUsuario.AppEnum);
|
|
29
45
|
v4["enum"](TypeControllerUsuario.UsuarioTipoEnum);
|
|
46
|
+
v4["enum"](TypeControllerUsuario.AssinaturaStatusEnum);
|
|
47
|
+
v4["enum"](TypeControllerUsuario.PlanNameEnum);
|
|
30
48
|
})(_usuario_TypeControllerUsuario || (_usuario_TypeControllerUsuario = {}));
|
|
31
49
|
const _usuario = _usuario_TypeControllerUsuario;
|
|
32
50
|
var _usuario_TypeControllerUsuario;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import z4 from "zod/v4";
|
|
2
2
|
declare namespace TypeControllerUsuario {
|
|
3
|
+
export const PlanNameEnum: readonly ["FREE", "ESSENTIAL", "BUSINESS", "ULTIMATE"];
|
|
3
4
|
export const AppEnum: readonly ["service-usuario", "service-pages", "service-assinatura", "service-bucket"];
|
|
5
|
+
export const AssinaturaStatusEnum: readonly ["active", "canceled", "incomplete", "incomplete_expired", "past_due", "paused", "trialing", "unpaid"];
|
|
4
6
|
export const UsuarioTipoEnum: readonly ["padrao"];
|
|
5
7
|
export const apps_permitidos_e_tipos_de_usuarios_de_cada_app: Record<App, UsuarioTipo[]>;
|
|
6
8
|
const AppEnumZod: z4.ZodEnum<{
|
|
@@ -12,18 +14,40 @@ declare namespace TypeControllerUsuario {
|
|
|
12
14
|
const UsuarioTipoEnumZod: z4.ZodEnum<{
|
|
13
15
|
padrao: "padrao";
|
|
14
16
|
}>;
|
|
17
|
+
const AssinaturaStatusEnumZod: z4.ZodEnum<{
|
|
18
|
+
active: "active";
|
|
19
|
+
canceled: "canceled";
|
|
20
|
+
incomplete: "incomplete";
|
|
21
|
+
incomplete_expired: "incomplete_expired";
|
|
22
|
+
past_due: "past_due";
|
|
23
|
+
paused: "paused";
|
|
24
|
+
trialing: "trialing";
|
|
25
|
+
unpaid: "unpaid";
|
|
26
|
+
}>;
|
|
27
|
+
const PlanNameEnumZod: z4.ZodEnum<{
|
|
28
|
+
FREE: "FREE";
|
|
29
|
+
ESSENTIAL: "ESSENTIAL";
|
|
30
|
+
BUSINESS: "BUSINESS";
|
|
31
|
+
ULTIMATE: "ULTIMATE";
|
|
32
|
+
}>;
|
|
15
33
|
type App = z4.infer<typeof AppEnumZod>;
|
|
16
34
|
type UsuarioTipo = z4.infer<typeof UsuarioTipoEnumZod>;
|
|
35
|
+
type AssinaturaStatusEnum = z4.infer<typeof AssinaturaStatusEnumZod>;
|
|
36
|
+
type PlanName = z4.infer<typeof PlanNameEnumZod>;
|
|
17
37
|
export interface Auth {
|
|
18
38
|
data: {
|
|
19
39
|
usuario: {
|
|
20
40
|
_id: string;
|
|
21
41
|
email: string;
|
|
22
|
-
nome
|
|
42
|
+
nome: string;
|
|
23
43
|
imagem?: string;
|
|
24
|
-
token
|
|
25
|
-
|
|
26
|
-
|
|
44
|
+
token: string;
|
|
45
|
+
refresh_token: string;
|
|
46
|
+
data_criacao: number;
|
|
47
|
+
ativo: 0 | 1;
|
|
48
|
+
usuario_tipo: UsuarioTipo;
|
|
49
|
+
plano_name: PlanName;
|
|
50
|
+
plano_status: AssinaturaStatusEnum;
|
|
27
51
|
};
|
|
28
52
|
};
|
|
29
53
|
}
|
|
@@ -35,6 +59,11 @@ declare namespace TypeControllerUsuario {
|
|
|
35
59
|
ativo: 1 | 0;
|
|
36
60
|
app: App;
|
|
37
61
|
usuario_tipo: UsuarioTipo;
|
|
62
|
+
plano_name: PlanName;
|
|
63
|
+
plano_status: AssinaturaStatusEnum;
|
|
64
|
+
}
|
|
65
|
+
export interface RefreshTokenPayload {
|
|
66
|
+
usuario_id: string;
|
|
38
67
|
}
|
|
39
68
|
export {};
|
|
40
69
|
}
|
|
@@ -8,7 +8,7 @@ declare const _token: {
|
|
|
8
8
|
message?: string | undefined;
|
|
9
9
|
results: any;
|
|
10
10
|
}, 409, "json">)>;
|
|
11
|
-
criar_token_login_usuario(
|
|
11
|
+
criar_token_login_usuario(props: t.Controller.Usuario.TokenPayload & {
|
|
12
12
|
c: t.Context;
|
|
13
13
|
}): Promise<string>;
|
|
14
14
|
verificar_token_micro_servico(c: t.Context, next: Next): Promise<void | (Response & import("hono").TypedResponse<{
|
|
@@ -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;
|
|
@@ -205,7 +205,7 @@ declare const helpers: {
|
|
|
205
205
|
message?: string | undefined;
|
|
206
206
|
results: any;
|
|
207
207
|
}, 409, "json">)>;
|
|
208
|
-
criar_token_login_usuario(
|
|
208
|
+
criar_token_login_usuario(props: import("../types/_usuario").default.TokenPayload & {
|
|
209
209
|
c: import("..").TypesCore.Context;
|
|
210
210
|
}): Promise<string>;
|
|
211
211
|
verificar_token_micro_servico(c: import("..").TypesCore.Context, next: import("hono").Next): Promise<void | (Response & import("hono").TypedResponse<{
|
|
@@ -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
|
@@ -360,7 +360,9 @@ const _token = new class _token {
|
|
|
360
360
|
data_criacao: payload.data_criacao,
|
|
361
361
|
nome: payload.nome,
|
|
362
362
|
app: payload.app,
|
|
363
|
-
usuario_tipo: payload.usuario_tipo
|
|
363
|
+
usuario_tipo: payload.usuario_tipo,
|
|
364
|
+
plano_name: payload?.plano_name,
|
|
365
|
+
plano_status: payload?.plano_status
|
|
364
366
|
};
|
|
365
367
|
c.set("usuario_auth", setar_token);
|
|
366
368
|
return await next();
|
|
@@ -372,25 +374,26 @@ const _token = new class _token {
|
|
|
372
374
|
});
|
|
373
375
|
}
|
|
374
376
|
}
|
|
375
|
-
async criar_token_login_usuario(
|
|
376
|
-
if (!c.env.JSON_WEB_TOKEN_AUTH_USER) {
|
|
377
|
-
|
|
377
|
+
async criar_token_login_usuario(props) {
|
|
378
|
+
if (!props?.c.env.JSON_WEB_TOKEN_AUTH_USER) {
|
|
379
|
+
_set_response.error.WARNING({
|
|
378
380
|
message: "Erro ao gerar token!!",
|
|
379
381
|
results: []
|
|
380
382
|
});
|
|
381
383
|
}
|
|
382
384
|
const token = await new external_jose_namespaceObject.SignJWT({
|
|
383
|
-
_id: _id,
|
|
384
|
-
email: email,
|
|
385
|
-
app: app,
|
|
386
|
-
usuario_tipo: usuario_tipo,
|
|
387
|
-
ativo: ativo,
|
|
388
|
-
data_criacao: data_criacao,
|
|
389
|
-
nome: nome
|
|
385
|
+
_id: props?._id,
|
|
386
|
+
email: props?.email,
|
|
387
|
+
app: props?.app,
|
|
388
|
+
usuario_tipo: props?.usuario_tipo,
|
|
389
|
+
ativo: props?.ativo,
|
|
390
|
+
data_criacao: props?.data_criacao,
|
|
391
|
+
nome: props?.nome,
|
|
392
|
+
plano_name: props?.plano_name,
|
|
393
|
+
plano_status: props?.plano_status
|
|
390
394
|
}).setProtectedHeader({
|
|
391
395
|
alg: "HS256"
|
|
392
|
-
}).setIssuedAt()
|
|
393
|
-
.sign(new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_USER)).catch((error)=>{
|
|
396
|
+
}).setIssuedAt().setExpirationTime("1h").sign(new TextEncoder().encode(props?.c.env.JSON_WEB_TOKEN_AUTH_USER)).catch((error)=>{
|
|
394
397
|
return _set_response.error.WARNING({
|
|
395
398
|
message: "Erro ao gerar token!",
|
|
396
399
|
results: error?.message
|
|
@@ -428,7 +431,9 @@ const _token = new class _token {
|
|
|
428
431
|
data_criacao: payload.data_criacao,
|
|
429
432
|
nome: payload.nome,
|
|
430
433
|
app: payload.app,
|
|
431
|
-
usuario_tipo: payload.usuario_tipo
|
|
434
|
+
usuario_tipo: payload.usuario_tipo,
|
|
435
|
+
plano_name: payload?.plano_name,
|
|
436
|
+
plano_status: payload?.plano_status
|
|
432
437
|
};
|
|
433
438
|
c.set("usuario_auth", setar_token);
|
|
434
439
|
return await next();
|
|
@@ -455,7 +460,9 @@ const _token = new class _token {
|
|
|
455
460
|
usuario_tipo: usuario_auth?.usuario_tipo,
|
|
456
461
|
ativo: usuario_auth?.ativo,
|
|
457
462
|
data_criacao: usuario_auth?.data_criacao,
|
|
458
|
-
nome: usuario_auth?.nome
|
|
463
|
+
nome: usuario_auth?.nome,
|
|
464
|
+
plano_name: usuario_auth?.plano_name,
|
|
465
|
+
plano_status: usuario_auth?.plano_status
|
|
459
466
|
}).setProtectedHeader({
|
|
460
467
|
alg: "HS256"
|
|
461
468
|
}).setIssuedAt().setExpirationTime("30s").sign(new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_MICRO_SERVICO)).catch((error)=>{
|
|
@@ -466,6 +473,34 @@ const _token = new class _token {
|
|
|
466
473
|
});
|
|
467
474
|
return token;
|
|
468
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
|
+
}
|
|
469
504
|
};
|
|
470
505
|
/* export default */ const helpers_token = (_token);
|
|
471
506
|
|
package/build/lib/index.cjs
CHANGED
|
@@ -61,12 +61,28 @@ var v4_default = /*#__PURE__*/__webpack_require__.n(v4_namespaceObject);
|
|
|
61
61
|
;// CONCATENATED MODULE: ./src/types/_usuario.ts
|
|
62
62
|
|
|
63
63
|
(function(TypeControllerUsuario) {
|
|
64
|
+
TypeControllerUsuario.PlanNameEnum = [
|
|
65
|
+
"FREE",
|
|
66
|
+
"ESSENTIAL",
|
|
67
|
+
"BUSINESS",
|
|
68
|
+
"ULTIMATE"
|
|
69
|
+
];
|
|
64
70
|
TypeControllerUsuario.AppEnum = [
|
|
65
71
|
"service-usuario",
|
|
66
72
|
"service-pages",
|
|
67
73
|
"service-assinatura",
|
|
68
74
|
"service-bucket"
|
|
69
75
|
];
|
|
76
|
+
TypeControllerUsuario.AssinaturaStatusEnum = [
|
|
77
|
+
"active",
|
|
78
|
+
"canceled",
|
|
79
|
+
"incomplete",
|
|
80
|
+
"incomplete_expired",
|
|
81
|
+
"past_due",
|
|
82
|
+
"paused",
|
|
83
|
+
"trialing",
|
|
84
|
+
"unpaid"
|
|
85
|
+
];
|
|
70
86
|
TypeControllerUsuario.UsuarioTipoEnum = [
|
|
71
87
|
"padrao"
|
|
72
88
|
];
|
|
@@ -86,6 +102,8 @@ var v4_default = /*#__PURE__*/__webpack_require__.n(v4_namespaceObject);
|
|
|
86
102
|
};
|
|
87
103
|
const AppEnumZod = v4_default()["enum"](TypeControllerUsuario.AppEnum);
|
|
88
104
|
const UsuarioTipoEnumZod = v4_default()["enum"](TypeControllerUsuario.UsuarioTipoEnum);
|
|
105
|
+
const AssinaturaStatusEnumZod = v4_default()["enum"](TypeControllerUsuario.AssinaturaStatusEnum);
|
|
106
|
+
const PlanNameEnumZod = v4_default()["enum"](TypeControllerUsuario.PlanNameEnum);
|
|
89
107
|
})(_usuario_TypeControllerUsuario || (_usuario_TypeControllerUsuario = {}));
|
|
90
108
|
/* export default */ const _usuario = (_usuario_TypeControllerUsuario);
|
|
91
109
|
var _usuario_TypeControllerUsuario;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import z4 from "zod/v4";
|
|
2
2
|
declare namespace TypeControllerUsuario {
|
|
3
|
+
export const PlanNameEnum: readonly ["FREE", "ESSENTIAL", "BUSINESS", "ULTIMATE"];
|
|
3
4
|
export const AppEnum: readonly ["service-usuario", "service-pages", "service-assinatura", "service-bucket"];
|
|
5
|
+
export const AssinaturaStatusEnum: readonly ["active", "canceled", "incomplete", "incomplete_expired", "past_due", "paused", "trialing", "unpaid"];
|
|
4
6
|
export const UsuarioTipoEnum: readonly ["padrao"];
|
|
5
7
|
export const apps_permitidos_e_tipos_de_usuarios_de_cada_app: Record<App, UsuarioTipo[]>;
|
|
6
8
|
const AppEnumZod: z4.ZodEnum<{
|
|
@@ -12,18 +14,40 @@ declare namespace TypeControllerUsuario {
|
|
|
12
14
|
const UsuarioTipoEnumZod: z4.ZodEnum<{
|
|
13
15
|
padrao: "padrao";
|
|
14
16
|
}>;
|
|
17
|
+
const AssinaturaStatusEnumZod: z4.ZodEnum<{
|
|
18
|
+
active: "active";
|
|
19
|
+
canceled: "canceled";
|
|
20
|
+
incomplete: "incomplete";
|
|
21
|
+
incomplete_expired: "incomplete_expired";
|
|
22
|
+
past_due: "past_due";
|
|
23
|
+
paused: "paused";
|
|
24
|
+
trialing: "trialing";
|
|
25
|
+
unpaid: "unpaid";
|
|
26
|
+
}>;
|
|
27
|
+
const PlanNameEnumZod: z4.ZodEnum<{
|
|
28
|
+
FREE: "FREE";
|
|
29
|
+
ESSENTIAL: "ESSENTIAL";
|
|
30
|
+
BUSINESS: "BUSINESS";
|
|
31
|
+
ULTIMATE: "ULTIMATE";
|
|
32
|
+
}>;
|
|
15
33
|
type App = z4.infer<typeof AppEnumZod>;
|
|
16
34
|
type UsuarioTipo = z4.infer<typeof UsuarioTipoEnumZod>;
|
|
35
|
+
type AssinaturaStatusEnum = z4.infer<typeof AssinaturaStatusEnumZod>;
|
|
36
|
+
type PlanName = z4.infer<typeof PlanNameEnumZod>;
|
|
17
37
|
export interface Auth {
|
|
18
38
|
data: {
|
|
19
39
|
usuario: {
|
|
20
40
|
_id: string;
|
|
21
41
|
email: string;
|
|
22
|
-
nome
|
|
42
|
+
nome: string;
|
|
23
43
|
imagem?: string;
|
|
24
|
-
token
|
|
25
|
-
|
|
26
|
-
|
|
44
|
+
token: string;
|
|
45
|
+
refresh_token: string;
|
|
46
|
+
data_criacao: number;
|
|
47
|
+
ativo: 0 | 1;
|
|
48
|
+
usuario_tipo: UsuarioTipo;
|
|
49
|
+
plano_name: PlanName;
|
|
50
|
+
plano_status: AssinaturaStatusEnum;
|
|
27
51
|
};
|
|
28
52
|
};
|
|
29
53
|
}
|
|
@@ -35,6 +59,11 @@ declare namespace TypeControllerUsuario {
|
|
|
35
59
|
ativo: 1 | 0;
|
|
36
60
|
app: App;
|
|
37
61
|
usuario_tipo: UsuarioTipo;
|
|
62
|
+
plano_name: PlanName;
|
|
63
|
+
plano_status: AssinaturaStatusEnum;
|
|
64
|
+
}
|
|
65
|
+
export interface RefreshTokenPayload {
|
|
66
|
+
usuario_id: string;
|
|
38
67
|
}
|
|
39
68
|
export {};
|
|
40
69
|
}
|