@innvoid/getmarket-sdk 0.2.7 → 0.2.9
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/chunk-HNOUEVHW.js +410 -0
- package/dist/chunk-HNOUEVHW.js.map +1 -0
- package/dist/express.d.cts +1 -1
- package/dist/express.d.ts +1 -1
- package/dist/index.cjs +282 -342
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -24
- package/dist/index.d.ts +11 -24
- package/dist/index.js +196 -15
- package/dist/index.js.map +1 -1
- package/dist/middlewares/index.cjs +88 -204
- package/dist/middlewares/index.cjs.map +1 -1
- package/dist/middlewares/index.d.cts +34 -40
- package/dist/middlewares/index.d.ts +34 -40
- package/dist/middlewares/index.js +1 -1
- package/dist/{types-CRECQuHp.d.cts → types-Cc_McZgD.d.cts} +12 -10
- package/dist/{types-CRECQuHp.d.ts → types-Cc_McZgD.d.ts} +12 -10
- package/package.json +2 -2
- package/dist/chunk-WM2QICZQ.js +0 -666
- package/dist/chunk-WM2QICZQ.js.map +0 -1
|
@@ -15,73 +15,67 @@ declare function internalAuth(req: Request, res: Response, next: NextFunction):
|
|
|
15
15
|
declare function sendOk<T>(_req: Request, res: Response, data: T, statusCode?: number): Response<any, Record<string, any>>;
|
|
16
16
|
declare function sendError(_req: Request, res: Response, statusCode: number, code: string, message: string, details?: any): Response<any, Record<string, any>>;
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* 401 si no existe req.auth (contexto auth).
|
|
20
|
-
* Útil para proteger rutas donde SIEMPRE debe existir auth.
|
|
21
|
-
*/
|
|
22
18
|
declare function requireAuthContext(): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
|
|
23
|
-
/**
|
|
24
|
-
* Requiere TODOS los permisos indicados.
|
|
25
|
-
* Regla: denied_permissions siempre gana sobre permissions.
|
|
26
|
-
*
|
|
27
|
-
* options:
|
|
28
|
-
* - sysAdminBypass: default true
|
|
29
|
-
* - sysAdminRole: default "SYS_ADMIN"
|
|
30
|
-
*/
|
|
31
19
|
declare function requirePermissions(perms: string[], options?: {
|
|
32
20
|
sysAdminBypass?: boolean;
|
|
33
21
|
sysAdminRole?: string;
|
|
34
22
|
}): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
|
|
35
|
-
/**
|
|
36
|
-
* Requiere AL MENOS 1 permiso de la lista (ANY/OR).
|
|
37
|
-
* Regla: denied_permissions siempre gana.
|
|
38
|
-
*/
|
|
39
23
|
declare function requireAnyPermission(perms: string[], options?: {
|
|
40
24
|
sysAdminBypass?: boolean;
|
|
41
25
|
sysAdminRole?: string;
|
|
42
26
|
}): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
|
|
43
|
-
/**
|
|
44
|
-
* Requiere al menos 1 rol (ANY/OR).
|
|
45
|
-
* options:
|
|
46
|
-
* - sysAdminBypass: default true
|
|
47
|
-
* - sysAdminRole: default "SYS_ADMIN"
|
|
48
|
-
*/
|
|
49
27
|
declare function requireRoles(roles: string[], options?: {
|
|
50
28
|
sysAdminBypass?: boolean;
|
|
51
29
|
sysAdminRole?: string;
|
|
52
30
|
}): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
|
|
53
|
-
/**
|
|
54
|
-
* Requiere (roles ANY) OR (permissions ANY).
|
|
55
|
-
* deny_permissions siempre gana sobre permissions.
|
|
56
|
-
*/
|
|
57
31
|
declare function requireRolesOrAnyPermission(roles: string[], perms: string[], options?: {
|
|
58
32
|
sysAdminBypass?: boolean;
|
|
59
33
|
sysAdminRole?: string;
|
|
60
34
|
}): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
|
|
61
35
|
|
|
36
|
+
type GuardOptions = {
|
|
37
|
+
/**
|
|
38
|
+
* Middleware(s) de autenticación del microservicio.
|
|
39
|
+
* Ej:
|
|
40
|
+
* allowSysAdminOrAnyPermission(["sale.read"], { auth: authEmployeeRequired })
|
|
41
|
+
*/
|
|
42
|
+
auth?: RequestHandler | RequestHandler[];
|
|
43
|
+
/**
|
|
44
|
+
* Si true, agrega parseHeaders automáticamente.
|
|
45
|
+
* Default: true
|
|
46
|
+
*/
|
|
47
|
+
includeParseHeaders?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Rol que representa SysAdmin.
|
|
50
|
+
* Default: SYS_ADMIN
|
|
51
|
+
*/
|
|
52
|
+
sysAdminRole?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Si false, desactiva bypass por SysAdmin.
|
|
55
|
+
* Default: true
|
|
56
|
+
*/
|
|
57
|
+
sysAdminBypass?: boolean;
|
|
58
|
+
};
|
|
62
59
|
/**
|
|
63
|
-
*
|
|
64
|
-
* - Si tiene alguno de los permisos => OK
|
|
65
|
-
* - denied_permissions gana siempre
|
|
60
|
+
* SYS_ADMIN bypass OR ANY permission
|
|
66
61
|
*/
|
|
67
|
-
declare function allowSysAdminOrAnyPermission(
|
|
62
|
+
declare function allowSysAdminOrAnyPermission(perms: string[] | string, options?: GuardOptions): RequestHandler[];
|
|
68
63
|
/**
|
|
69
|
-
*
|
|
64
|
+
* SYS_ADMIN bypass OR ALL permissions
|
|
70
65
|
*/
|
|
71
|
-
declare function allowSysAdminOrPermissionsAll(
|
|
66
|
+
declare function allowSysAdminOrPermissionsAll(perms: string[] | string, options?: GuardOptions): RequestHandler[];
|
|
72
67
|
/**
|
|
73
|
-
*
|
|
68
|
+
* SYS_ADMIN bypass OR ANY role
|
|
74
69
|
*/
|
|
75
|
-
declare function allowSysAdminOrRoles(
|
|
70
|
+
declare function allowSysAdminOrRoles(roles: string[] | string, options?: GuardOptions): RequestHandler[];
|
|
76
71
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
72
|
+
* SYS_ADMIN bypass OR (roles ANY) OR (permissions ANY)
|
|
73
|
+
* denied_permissions siempre gana
|
|
79
74
|
*/
|
|
80
|
-
declare function allowSysAdminOrRolesOrAnyPermission(roles: string | string[], permissions: string | string[]): RequestHandler[];
|
|
75
|
+
declare function allowSysAdminOrRolesOrAnyPermission(roles: string | string[], permissions: string | string[], options?: GuardOptions): RequestHandler[];
|
|
81
76
|
/**
|
|
82
|
-
*
|
|
83
|
-
* Rol AUTH_ADMIN o permiso fino (y SYS_ADMIN bypass)
|
|
77
|
+
* Helper típico para AUTH backoffice
|
|
84
78
|
*/
|
|
85
|
-
declare function allowAuthAdminOrPerm(permission: string): RequestHandler[];
|
|
79
|
+
declare function allowAuthAdminOrPerm(permission: string, options?: GuardOptions): RequestHandler[];
|
|
86
80
|
|
|
87
81
|
export { allowAuthAdminOrPerm, allowSysAdminOrAnyPermission, allowSysAdminOrPermissionsAll, allowSysAdminOrRoles, allowSysAdminOrRolesOrAnyPermission, internalAuth, parseHeaders, requestId, requireAnyPermission, requireAuthContext, requirePermissions, requireRoles, requireRolesOrAnyPermission, sendError, sendOk };
|
|
@@ -15,73 +15,67 @@ declare function internalAuth(req: Request, res: Response, next: NextFunction):
|
|
|
15
15
|
declare function sendOk<T>(_req: Request, res: Response, data: T, statusCode?: number): Response<any, Record<string, any>>;
|
|
16
16
|
declare function sendError(_req: Request, res: Response, statusCode: number, code: string, message: string, details?: any): Response<any, Record<string, any>>;
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* 401 si no existe req.auth (contexto auth).
|
|
20
|
-
* Útil para proteger rutas donde SIEMPRE debe existir auth.
|
|
21
|
-
*/
|
|
22
18
|
declare function requireAuthContext(): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
|
|
23
|
-
/**
|
|
24
|
-
* Requiere TODOS los permisos indicados.
|
|
25
|
-
* Regla: denied_permissions siempre gana sobre permissions.
|
|
26
|
-
*
|
|
27
|
-
* options:
|
|
28
|
-
* - sysAdminBypass: default true
|
|
29
|
-
* - sysAdminRole: default "SYS_ADMIN"
|
|
30
|
-
*/
|
|
31
19
|
declare function requirePermissions(perms: string[], options?: {
|
|
32
20
|
sysAdminBypass?: boolean;
|
|
33
21
|
sysAdminRole?: string;
|
|
34
22
|
}): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
|
|
35
|
-
/**
|
|
36
|
-
* Requiere AL MENOS 1 permiso de la lista (ANY/OR).
|
|
37
|
-
* Regla: denied_permissions siempre gana.
|
|
38
|
-
*/
|
|
39
23
|
declare function requireAnyPermission(perms: string[], options?: {
|
|
40
24
|
sysAdminBypass?: boolean;
|
|
41
25
|
sysAdminRole?: string;
|
|
42
26
|
}): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
|
|
43
|
-
/**
|
|
44
|
-
* Requiere al menos 1 rol (ANY/OR).
|
|
45
|
-
* options:
|
|
46
|
-
* - sysAdminBypass: default true
|
|
47
|
-
* - sysAdminRole: default "SYS_ADMIN"
|
|
48
|
-
*/
|
|
49
27
|
declare function requireRoles(roles: string[], options?: {
|
|
50
28
|
sysAdminBypass?: boolean;
|
|
51
29
|
sysAdminRole?: string;
|
|
52
30
|
}): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
|
|
53
|
-
/**
|
|
54
|
-
* Requiere (roles ANY) OR (permissions ANY).
|
|
55
|
-
* deny_permissions siempre gana sobre permissions.
|
|
56
|
-
*/
|
|
57
31
|
declare function requireRolesOrAnyPermission(roles: string[], perms: string[], options?: {
|
|
58
32
|
sysAdminBypass?: boolean;
|
|
59
33
|
sysAdminRole?: string;
|
|
60
34
|
}): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
|
|
61
35
|
|
|
36
|
+
type GuardOptions = {
|
|
37
|
+
/**
|
|
38
|
+
* Middleware(s) de autenticación del microservicio.
|
|
39
|
+
* Ej:
|
|
40
|
+
* allowSysAdminOrAnyPermission(["sale.read"], { auth: authEmployeeRequired })
|
|
41
|
+
*/
|
|
42
|
+
auth?: RequestHandler | RequestHandler[];
|
|
43
|
+
/**
|
|
44
|
+
* Si true, agrega parseHeaders automáticamente.
|
|
45
|
+
* Default: true
|
|
46
|
+
*/
|
|
47
|
+
includeParseHeaders?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Rol que representa SysAdmin.
|
|
50
|
+
* Default: SYS_ADMIN
|
|
51
|
+
*/
|
|
52
|
+
sysAdminRole?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Si false, desactiva bypass por SysAdmin.
|
|
55
|
+
* Default: true
|
|
56
|
+
*/
|
|
57
|
+
sysAdminBypass?: boolean;
|
|
58
|
+
};
|
|
62
59
|
/**
|
|
63
|
-
*
|
|
64
|
-
* - Si tiene alguno de los permisos => OK
|
|
65
|
-
* - denied_permissions gana siempre
|
|
60
|
+
* SYS_ADMIN bypass OR ANY permission
|
|
66
61
|
*/
|
|
67
|
-
declare function allowSysAdminOrAnyPermission(
|
|
62
|
+
declare function allowSysAdminOrAnyPermission(perms: string[] | string, options?: GuardOptions): RequestHandler[];
|
|
68
63
|
/**
|
|
69
|
-
*
|
|
64
|
+
* SYS_ADMIN bypass OR ALL permissions
|
|
70
65
|
*/
|
|
71
|
-
declare function allowSysAdminOrPermissionsAll(
|
|
66
|
+
declare function allowSysAdminOrPermissionsAll(perms: string[] | string, options?: GuardOptions): RequestHandler[];
|
|
72
67
|
/**
|
|
73
|
-
*
|
|
68
|
+
* SYS_ADMIN bypass OR ANY role
|
|
74
69
|
*/
|
|
75
|
-
declare function allowSysAdminOrRoles(
|
|
70
|
+
declare function allowSysAdminOrRoles(roles: string[] | string, options?: GuardOptions): RequestHandler[];
|
|
76
71
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
72
|
+
* SYS_ADMIN bypass OR (roles ANY) OR (permissions ANY)
|
|
73
|
+
* denied_permissions siempre gana
|
|
79
74
|
*/
|
|
80
|
-
declare function allowSysAdminOrRolesOrAnyPermission(roles: string | string[], permissions: string | string[]): RequestHandler[];
|
|
75
|
+
declare function allowSysAdminOrRolesOrAnyPermission(roles: string | string[], permissions: string | string[], options?: GuardOptions): RequestHandler[];
|
|
81
76
|
/**
|
|
82
|
-
*
|
|
83
|
-
* Rol AUTH_ADMIN o permiso fino (y SYS_ADMIN bypass)
|
|
77
|
+
* Helper típico para AUTH backoffice
|
|
84
78
|
*/
|
|
85
|
-
declare function allowAuthAdminOrPerm(permission: string): RequestHandler[];
|
|
79
|
+
declare function allowAuthAdminOrPerm(permission: string, options?: GuardOptions): RequestHandler[];
|
|
86
80
|
|
|
87
81
|
export { allowAuthAdminOrPerm, allowSysAdminOrAnyPermission, allowSysAdminOrPermissionsAll, allowSysAdminOrRoles, allowSysAdminOrRolesOrAnyPermission, internalAuth, parseHeaders, requestId, requireAnyPermission, requireAuthContext, requirePermissions, requireRoles, requireRolesOrAnyPermission, sendError, sendOk };
|
|
@@ -10,16 +10,18 @@ type AuthSession = {
|
|
|
10
10
|
type AuthContext = {
|
|
11
11
|
tokenType: TokenType;
|
|
12
12
|
subject: AuthSubject;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
employee_uid?: string;
|
|
14
|
+
customer_uid?: string;
|
|
15
15
|
company_uid?: string;
|
|
16
16
|
branch_uid?: string;
|
|
17
|
+
employee?: any;
|
|
18
|
+
customer?: any;
|
|
17
19
|
companies?: any[];
|
|
18
20
|
company?: any;
|
|
19
21
|
branch?: any;
|
|
20
|
-
roles?:
|
|
21
|
-
permissions?:
|
|
22
|
-
denied_permissions?:
|
|
22
|
+
roles?: any[];
|
|
23
|
+
permissions?: any[];
|
|
24
|
+
denied_permissions?: any[];
|
|
23
25
|
session?: AuthSession;
|
|
24
26
|
firebase?: any;
|
|
25
27
|
};
|
|
@@ -30,23 +32,23 @@ type HydrateInput = {
|
|
|
30
32
|
company_uid: string | null;
|
|
31
33
|
branch_uid: string | null;
|
|
32
34
|
};
|
|
33
|
-
type HydrateResult = Partial<Pick<AuthContext, "employee" | "customer" | "companies" | "company" | "branch" | "roles" | "permissions" | "denied_permissions">>;
|
|
35
|
+
type HydrateResult = Partial<Pick<AuthContext, "employee_uid" | "customer_uid" | "employee" | "customer" | "companies" | "company" | "branch" | "roles" | "permissions" | "denied_permissions">>;
|
|
34
36
|
type Hydrator = (input: HydrateInput) => Promise<HydrateResult> | HydrateResult;
|
|
35
37
|
type AuthMiddlewareOptions = {
|
|
36
38
|
subject: AuthSubject;
|
|
37
39
|
/**
|
|
38
|
-
*
|
|
40
|
+
* Si true, exige que el sujeto exista luego del hydrate.
|
|
39
41
|
* Default: true
|
|
40
42
|
*/
|
|
41
43
|
requireSubject?: boolean;
|
|
42
44
|
/**
|
|
43
|
-
* Si true, permite fallback a Firebase
|
|
45
|
+
* Si true, permite fallback a Firebase ID token.
|
|
44
46
|
* Default: false
|
|
45
47
|
*/
|
|
46
48
|
allowFirebaseIdToken?: boolean;
|
|
47
49
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
+
* Hidrata contexto de dominio del micro.
|
|
51
|
+
* Obligatorio en el middleware estándar.
|
|
50
52
|
*/
|
|
51
53
|
hydrate: Hydrator;
|
|
52
54
|
};
|
|
@@ -10,16 +10,18 @@ type AuthSession = {
|
|
|
10
10
|
type AuthContext = {
|
|
11
11
|
tokenType: TokenType;
|
|
12
12
|
subject: AuthSubject;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
employee_uid?: string;
|
|
14
|
+
customer_uid?: string;
|
|
15
15
|
company_uid?: string;
|
|
16
16
|
branch_uid?: string;
|
|
17
|
+
employee?: any;
|
|
18
|
+
customer?: any;
|
|
17
19
|
companies?: any[];
|
|
18
20
|
company?: any;
|
|
19
21
|
branch?: any;
|
|
20
|
-
roles?:
|
|
21
|
-
permissions?:
|
|
22
|
-
denied_permissions?:
|
|
22
|
+
roles?: any[];
|
|
23
|
+
permissions?: any[];
|
|
24
|
+
denied_permissions?: any[];
|
|
23
25
|
session?: AuthSession;
|
|
24
26
|
firebase?: any;
|
|
25
27
|
};
|
|
@@ -30,23 +32,23 @@ type HydrateInput = {
|
|
|
30
32
|
company_uid: string | null;
|
|
31
33
|
branch_uid: string | null;
|
|
32
34
|
};
|
|
33
|
-
type HydrateResult = Partial<Pick<AuthContext, "employee" | "customer" | "companies" | "company" | "branch" | "roles" | "permissions" | "denied_permissions">>;
|
|
35
|
+
type HydrateResult = Partial<Pick<AuthContext, "employee_uid" | "customer_uid" | "employee" | "customer" | "companies" | "company" | "branch" | "roles" | "permissions" | "denied_permissions">>;
|
|
34
36
|
type Hydrator = (input: HydrateInput) => Promise<HydrateResult> | HydrateResult;
|
|
35
37
|
type AuthMiddlewareOptions = {
|
|
36
38
|
subject: AuthSubject;
|
|
37
39
|
/**
|
|
38
|
-
*
|
|
40
|
+
* Si true, exige que el sujeto exista luego del hydrate.
|
|
39
41
|
* Default: true
|
|
40
42
|
*/
|
|
41
43
|
requireSubject?: boolean;
|
|
42
44
|
/**
|
|
43
|
-
* Si true, permite fallback a Firebase
|
|
45
|
+
* Si true, permite fallback a Firebase ID token.
|
|
44
46
|
* Default: false
|
|
45
47
|
*/
|
|
46
48
|
allowFirebaseIdToken?: boolean;
|
|
47
49
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
+
* Hidrata contexto de dominio del micro.
|
|
51
|
+
* Obligatorio en el middleware estándar.
|
|
50
52
|
*/
|
|
51
53
|
hydrate: Hydrator;
|
|
52
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innvoid/getmarket-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@innvoid/getmarket-contracts": "^0.1.
|
|
91
|
+
"@innvoid/getmarket-contracts": "^0.1.17",
|
|
92
92
|
"axios": "^1.13.5",
|
|
93
93
|
"firebase-admin": "^13.6.1",
|
|
94
94
|
"jsonwebtoken": "^9.0.2",
|