asv-hlps 1.2.79 → 1.2.80

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.
@@ -0,0 +1,16 @@
1
+ import { User } from "./models/entities/users/User";
2
+ import { UserNotarial } from "./models/entities/users/UserNotatial";
3
+ interface AuthParam {
4
+ tag?: string;
5
+ roles?: string[];
6
+ grps?: string[];
7
+ client?: {
8
+ roles?: string[];
9
+ steGrps?: string[];
10
+ };
11
+ steGrps?: string[];
12
+ steNames?: string[];
13
+ url?: string;
14
+ }
15
+ declare const getAuth: (authUser: User | UserNotarial, authSte: string[], param?: AuthParam) => boolean;
16
+ export { AuthParam, getAuth };
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAuth = void 0;
4
+ const user_1 = require("./user");
5
+ const getAuth = (authUser, authSte, param) => {
6
+ var _a, _b, _c, _d, _e;
7
+ // let auth: boolean = false;
8
+ if ((param === null || param === void 0 ? void 0 : param.tag) && (authUser === null || authUser === void 0 ? void 0 : authUser.tags)) {
9
+ const tags = [];
10
+ for (const tag of authUser.tags) {
11
+ tags.push(tag.code.toLowerCase());
12
+ }
13
+ const authIn = tags.includes(param.tag.toLowerCase());
14
+ if (authIn) {
15
+ return true;
16
+ }
17
+ }
18
+ /* if (param?.roles?.length) {
19
+ if (isStaffSte(authSte, authUser)) {
20
+ // return param?.roles?.length ? ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase()) : false;
21
+ // ------ multi roles ------
22
+ // return param?.roles?.length ? this.checkRoles(["sadm", ...param.roles]) : false;
23
+ }
24
+ } */
25
+ if ((_a = param === null || param === void 0 ? void 0 : param.roles) === null || _a === void 0 ? void 0 : _a.length) {
26
+ return (0, user_1.isStaffSte)(authSte, authUser) && ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase());
27
+ // ------ multi roles ------
28
+ // return param?.roles?.length ? this.checkRoles(["sadm", ...param.roles]) : false;
29
+ // }
30
+ }
31
+ if ((_b = param === null || param === void 0 ? void 0 : param.steGrps) === null || _b === void 0 ? void 0 : _b.length) {
32
+ return param.steGrps.includes(authUser.ste.grp.code.toLowerCase());
33
+ }
34
+ if ((_c = param === null || param === void 0 ? void 0 : param.grps) === null || _c === void 0 ? void 0 : _c.length) {
35
+ return param.grps.includes(authUser.grp.code.toLowerCase());
36
+ }
37
+ /* if (param?.client) {
38
+ if (!isStaffSte(authSte, authUser)) {
39
+ if (param.client.roles && !param.client.steGrps) {
40
+ return param.client.roles.length ? ["ceo", ...param?.client.roles].includes(authUser.role.code.toLowerCase()) : false;
41
+ }
42
+
43
+ if (!param.client.roles && param.client.steGrps) {
44
+ return param.client.steGrps.length ? param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase()) : false;
45
+ }
46
+ return param?.client.roles?.length && param?.client.steGrps.length
47
+ ? ["ceo", ...param?.client.roles].includes(authUser.role.code.toLowerCase()) &&
48
+ (param?.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())
49
+ : false;
50
+ }
51
+ const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
52
+ if(authIn) { return true}
53
+ } */
54
+ if (param === null || param === void 0 ? void 0 : param.client) {
55
+ if (!(0, user_1.isStaffSte)(authSte, authUser)) {
56
+ if (param.client.roles && !param.client.steGrps) {
57
+ return param.client.roles.length && ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase());
58
+ }
59
+ if (!param.client.roles && param.client.steGrps) {
60
+ return param.client.steGrps.length && param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase());
61
+ }
62
+ return (((_d = param === null || param === void 0 ? void 0 : param.client.roles) === null || _d === void 0 ? void 0 : _d.length) &&
63
+ (param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
64
+ ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
65
+ (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase()));
66
+ }
67
+ /* const authIn = param.steGrps.includes(this.authUser.ste.grp.code.toLowerCase());
68
+ if (authIn) {
69
+ return true;
70
+ } */
71
+ }
72
+ if ((_e = param === null || param === void 0 ? void 0 : param.steNames) === null || _e === void 0 ? void 0 : _e.length) {
73
+ return param.steNames.includes(authUser.ste.name.toLowerCase());
74
+ /* const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
75
+ if(authIn) { return true} */
76
+ }
77
+ /* if (param?.url) {
78
+ return this.router.url === param.url;
79
+ } */
80
+ // return false;
81
+ // return auth;
82
+ /* if(param?.steGrps?.length) {
83
+ auth = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
84
+ } */
85
+ };
86
+ exports.getAuth = getAuth;
package/lib/cjs/auth.js CHANGED
@@ -15,42 +15,54 @@ const getAuth = (authUser, authSte, param) => {
15
15
  return true;
16
16
  }
17
17
  }
18
- /* if (param?.roles?.length) {
19
- if (isStaffSte(authSte, authUser)) {
20
- // return param?.roles?.length ? ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase()) : false;
21
- // ------ multi roles ------
22
- // return param?.roles?.length ? this.checkRoles(["sadm", ...param.roles]) : false;
23
- }
24
- } */
25
18
  if ((_a = param === null || param === void 0 ? void 0 : param.roles) === null || _a === void 0 ? void 0 : _a.length) {
26
- // if (isStaffSte(authSte, authUser)) {
27
19
  return (0, user_1.isStaffSte)(authSte, authUser) && ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase());
28
20
  // ------ multi roles ------
29
21
  // return param?.roles?.length ? this.checkRoles(["sadm", ...param.roles]) : false;
30
22
  // }
31
23
  }
32
- if ((_b = param === null || param === void 0 ? void 0 : param.steGrps) === null || _b === void 0 ? void 0 : _b.length) {
33
- return param.steGrps.includes(authUser.ste.grp.code.toLowerCase());
34
- }
35
- if ((_c = param === null || param === void 0 ? void 0 : param.grps) === null || _c === void 0 ? void 0 : _c.length) {
36
- return param.grps.includes(authUser.grp.code.toLowerCase());
37
- }
24
+ // ------ client ------
38
25
  if (param === null || param === void 0 ? void 0 : param.client) {
39
26
  if (!(0, user_1.isStaffSte)(authSte, authUser)) {
40
27
  if (param.client.roles && !param.client.steGrps) {
41
- return param.client.roles.length ? ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) : false;
28
+ return param.client.roles.length && ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase());
42
29
  }
43
30
  if (!param.client.roles && param.client.steGrps) {
44
- return param.client.steGrps.length ? param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase()) : false;
31
+ return param.client.steGrps.length && param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase());
45
32
  }
46
- return ((_d = param === null || param === void 0 ? void 0 : param.client.roles) === null || _d === void 0 ? void 0 : _d.length) && (param === null || param === void 0 ? void 0 : param.client.steGrps.length)
47
- ? ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
48
- (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())
49
- : false;
33
+ return (((_b = param === null || param === void 0 ? void 0 : param.client.roles) === null || _b === void 0 ? void 0 : _b.length) &&
34
+ (param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
35
+ ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
36
+ (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase()));
50
37
  }
51
- /* const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
52
- if(authIn) { return true} */
38
+ /* const authIn = param.steGrps.includes(this.authUser.ste.grp.code.toLowerCase());
39
+ if (authIn) {
40
+ return true;
41
+ } */
42
+ }
43
+ if ((_c = param === null || param === void 0 ? void 0 : param.steGrps) === null || _c === void 0 ? void 0 : _c.length) {
44
+ return param.steGrps.includes(authUser.ste.grp.code.toLowerCase());
45
+ }
46
+ if ((_d = param === null || param === void 0 ? void 0 : param.grps) === null || _d === void 0 ? void 0 : _d.length) {
47
+ return param.grps.includes(authUser.grp.code.toLowerCase());
53
48
  }
49
+ /* if (param?.client) {
50
+ if (!isStaffSte(authSte, authUser)) {
51
+ if (param.client.roles && !param.client.steGrps) {
52
+ return param.client.roles.length ? ["ceo", ...param?.client.roles].includes(authUser.role.code.toLowerCase()) : false;
53
+ }
54
+
55
+ if (!param.client.roles && param.client.steGrps) {
56
+ return param.client.steGrps.length ? param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase()) : false;
57
+ }
58
+ return param?.client.roles?.length && param?.client.steGrps.length
59
+ ? ["ceo", ...param?.client.roles].includes(authUser.role.code.toLowerCase()) &&
60
+ (param?.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())
61
+ : false;
62
+ }
63
+ const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
64
+ if(authIn) { return true}
65
+ } */
54
66
  if ((_e = param === null || param === void 0 ? void 0 : param.steNames) === null || _e === void 0 ? void 0 : _e.length) {
55
67
  return param.steNames.includes(authUser.ste.name.toLowerCase());
56
68
  /* const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
@@ -0,0 +1,16 @@
1
+ import { User } from "./models/entities/users/User";
2
+ import { UserNotarial } from "./models/entities/users/UserNotatial";
3
+ interface AuthParam {
4
+ tag?: string;
5
+ roles?: string[];
6
+ grps?: string[];
7
+ client?: {
8
+ roles?: string[];
9
+ steGrps?: string[];
10
+ };
11
+ steGrps?: string[];
12
+ steNames?: string[];
13
+ url?: string;
14
+ }
15
+ declare const getAuth: (authUser: User | UserNotarial, authSte: string[], param?: AuthParam) => boolean;
16
+ export { AuthParam, getAuth };
@@ -0,0 +1,83 @@
1
+ import { isStaffSte } from "./user";
2
+ const getAuth = (authUser, authSte, param) => {
3
+ var _a, _b, _c, _d, _e;
4
+ // let auth: boolean = false;
5
+ if ((param === null || param === void 0 ? void 0 : param.tag) && (authUser === null || authUser === void 0 ? void 0 : authUser.tags)) {
6
+ const tags = [];
7
+ for (const tag of authUser.tags) {
8
+ tags.push(tag.code.toLowerCase());
9
+ }
10
+ const authIn = tags.includes(param.tag.toLowerCase());
11
+ if (authIn) {
12
+ return true;
13
+ }
14
+ }
15
+ /* if (param?.roles?.length) {
16
+ if (isStaffSte(authSte, authUser)) {
17
+ // return param?.roles?.length ? ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase()) : false;
18
+ // ------ multi roles ------
19
+ // return param?.roles?.length ? this.checkRoles(["sadm", ...param.roles]) : false;
20
+ }
21
+ } */
22
+ if ((_a = param === null || param === void 0 ? void 0 : param.roles) === null || _a === void 0 ? void 0 : _a.length) {
23
+ return isStaffSte(authSte, authUser) && ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase());
24
+ // ------ multi roles ------
25
+ // return param?.roles?.length ? this.checkRoles(["sadm", ...param.roles]) : false;
26
+ // }
27
+ }
28
+ if ((_b = param === null || param === void 0 ? void 0 : param.steGrps) === null || _b === void 0 ? void 0 : _b.length) {
29
+ return param.steGrps.includes(authUser.ste.grp.code.toLowerCase());
30
+ }
31
+ if ((_c = param === null || param === void 0 ? void 0 : param.grps) === null || _c === void 0 ? void 0 : _c.length) {
32
+ return param.grps.includes(authUser.grp.code.toLowerCase());
33
+ }
34
+ /* if (param?.client) {
35
+ if (!isStaffSte(authSte, authUser)) {
36
+ if (param.client.roles && !param.client.steGrps) {
37
+ return param.client.roles.length ? ["ceo", ...param?.client.roles].includes(authUser.role.code.toLowerCase()) : false;
38
+ }
39
+
40
+ if (!param.client.roles && param.client.steGrps) {
41
+ return param.client.steGrps.length ? param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase()) : false;
42
+ }
43
+ return param?.client.roles?.length && param?.client.steGrps.length
44
+ ? ["ceo", ...param?.client.roles].includes(authUser.role.code.toLowerCase()) &&
45
+ (param?.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())
46
+ : false;
47
+ }
48
+ const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
49
+ if(authIn) { return true}
50
+ } */
51
+ if (param === null || param === void 0 ? void 0 : param.client) {
52
+ if (!isStaffSte(authSte, authUser)) {
53
+ if (param.client.roles && !param.client.steGrps) {
54
+ return param.client.roles.length && ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase());
55
+ }
56
+ if (!param.client.roles && param.client.steGrps) {
57
+ return param.client.steGrps.length && param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase());
58
+ }
59
+ return (((_d = param === null || param === void 0 ? void 0 : param.client.roles) === null || _d === void 0 ? void 0 : _d.length) &&
60
+ (param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
61
+ ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
62
+ (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase()));
63
+ }
64
+ /* const authIn = param.steGrps.includes(this.authUser.ste.grp.code.toLowerCase());
65
+ if (authIn) {
66
+ return true;
67
+ } */
68
+ }
69
+ if ((_e = param === null || param === void 0 ? void 0 : param.steNames) === null || _e === void 0 ? void 0 : _e.length) {
70
+ return param.steNames.includes(authUser.ste.name.toLowerCase());
71
+ /* const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
72
+ if(authIn) { return true} */
73
+ }
74
+ /* if (param?.url) {
75
+ return this.router.url === param.url;
76
+ } */
77
+ // return false;
78
+ // return auth;
79
+ /* if(param?.steGrps?.length) {
80
+ auth = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
81
+ } */
82
+ };
83
+ export { getAuth };
package/lib/esm/auth.js CHANGED
@@ -12,42 +12,54 @@ const getAuth = (authUser, authSte, param) => {
12
12
  return true;
13
13
  }
14
14
  }
15
- /* if (param?.roles?.length) {
16
- if (isStaffSte(authSte, authUser)) {
17
- // return param?.roles?.length ? ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase()) : false;
18
- // ------ multi roles ------
19
- // return param?.roles?.length ? this.checkRoles(["sadm", ...param.roles]) : false;
20
- }
21
- } */
22
15
  if ((_a = param === null || param === void 0 ? void 0 : param.roles) === null || _a === void 0 ? void 0 : _a.length) {
23
- // if (isStaffSte(authSte, authUser)) {
24
16
  return isStaffSte(authSte, authUser) && ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase());
25
17
  // ------ multi roles ------
26
18
  // return param?.roles?.length ? this.checkRoles(["sadm", ...param.roles]) : false;
27
19
  // }
28
20
  }
29
- if ((_b = param === null || param === void 0 ? void 0 : param.steGrps) === null || _b === void 0 ? void 0 : _b.length) {
30
- return param.steGrps.includes(authUser.ste.grp.code.toLowerCase());
31
- }
32
- if ((_c = param === null || param === void 0 ? void 0 : param.grps) === null || _c === void 0 ? void 0 : _c.length) {
33
- return param.grps.includes(authUser.grp.code.toLowerCase());
34
- }
21
+ // ------ client ------
35
22
  if (param === null || param === void 0 ? void 0 : param.client) {
36
23
  if (!isStaffSte(authSte, authUser)) {
37
24
  if (param.client.roles && !param.client.steGrps) {
38
- return param.client.roles.length ? ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) : false;
25
+ return param.client.roles.length && ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase());
39
26
  }
40
27
  if (!param.client.roles && param.client.steGrps) {
41
- return param.client.steGrps.length ? param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase()) : false;
28
+ return param.client.steGrps.length && param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase());
42
29
  }
43
- return ((_d = param === null || param === void 0 ? void 0 : param.client.roles) === null || _d === void 0 ? void 0 : _d.length) && (param === null || param === void 0 ? void 0 : param.client.steGrps.length)
44
- ? ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
45
- (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())
46
- : false;
30
+ return (((_b = param === null || param === void 0 ? void 0 : param.client.roles) === null || _b === void 0 ? void 0 : _b.length) &&
31
+ (param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
32
+ ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
33
+ (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase()));
47
34
  }
48
- /* const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
49
- if(authIn) { return true} */
35
+ /* const authIn = param.steGrps.includes(this.authUser.ste.grp.code.toLowerCase());
36
+ if (authIn) {
37
+ return true;
38
+ } */
39
+ }
40
+ if ((_c = param === null || param === void 0 ? void 0 : param.steGrps) === null || _c === void 0 ? void 0 : _c.length) {
41
+ return param.steGrps.includes(authUser.ste.grp.code.toLowerCase());
42
+ }
43
+ if ((_d = param === null || param === void 0 ? void 0 : param.grps) === null || _d === void 0 ? void 0 : _d.length) {
44
+ return param.grps.includes(authUser.grp.code.toLowerCase());
50
45
  }
46
+ /* if (param?.client) {
47
+ if (!isStaffSte(authSte, authUser)) {
48
+ if (param.client.roles && !param.client.steGrps) {
49
+ return param.client.roles.length ? ["ceo", ...param?.client.roles].includes(authUser.role.code.toLowerCase()) : false;
50
+ }
51
+
52
+ if (!param.client.roles && param.client.steGrps) {
53
+ return param.client.steGrps.length ? param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase()) : false;
54
+ }
55
+ return param?.client.roles?.length && param?.client.steGrps.length
56
+ ? ["ceo", ...param?.client.roles].includes(authUser.role.code.toLowerCase()) &&
57
+ (param?.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())
58
+ : false;
59
+ }
60
+ const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
61
+ if(authIn) { return true}
62
+ } */
51
63
  if ((_e = param === null || param === void 0 ? void 0 : param.steNames) === null || _e === void 0 ? void 0 : _e.length) {
52
64
  return param.steNames.includes(authUser.ste.name.toLowerCase());
53
65
  /* const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.2.79",
3
+ "version": "1.2.80",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",