chyz 2.0.1-rc.36 → 2.0.1-rc.37

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.
Files changed (231) hide show
  1. package/dist/BaseChyz.d.ts +74 -0
  2. package/dist/BaseChyz.d.ts.map +1 -0
  3. package/dist/BaseChyz.js +586 -0
  4. package/dist/base/ActionFilter.d.ts +32 -0
  5. package/dist/base/ActionFilter.d.ts.map +1 -0
  6. package/dist/base/ActionFilter.js +90 -0
  7. package/dist/base/BadRequestHttpException.d.ts +6 -0
  8. package/dist/base/BadRequestHttpException.d.ts.map +1 -0
  9. package/dist/base/BadRequestHttpException.js +17 -0
  10. package/dist/base/BaseError.d.ts +44 -0
  11. package/dist/base/BaseError.d.ts.map +1 -0
  12. package/{base/BaseError.ts → dist/base/BaseError.js} +18 -26
  13. package/dist/base/Behavior.d.ts +4 -0
  14. package/dist/base/Behavior.d.ts.map +1 -0
  15. package/dist/base/Behavior.js +7 -0
  16. package/dist/base/CBaseObject.d.ts +5 -0
  17. package/dist/base/CBaseObject.d.ts.map +1 -0
  18. package/dist/base/CBaseObject.js +16 -0
  19. package/dist/base/CEvents.d.ts +13 -0
  20. package/dist/base/CEvents.d.ts.map +1 -0
  21. package/dist/base/CEvents.js +24 -0
  22. package/dist/base/CRequest.d.ts +2 -0
  23. package/dist/base/CRequest.d.ts.map +1 -0
  24. package/{base/CRequest.ts → dist/base/CRequest.js} +2 -6
  25. package/dist/base/CWebController.d.ts +44 -0
  26. package/dist/base/CWebController.d.ts.map +1 -0
  27. package/dist/base/CWebController.js +81 -0
  28. package/dist/base/Component.d.ts +21 -0
  29. package/dist/base/Component.d.ts.map +1 -0
  30. package/dist/base/Component.js +57 -0
  31. package/dist/base/Configurable.d.ts +3 -0
  32. package/dist/base/Configurable.d.ts.map +1 -0
  33. package/{requiments/Glob.ts → dist/base/Configurable.js} +2 -3
  34. package/dist/base/DataErrorDbException.d.ts +6 -0
  35. package/dist/base/DataErrorDbException.d.ts.map +1 -0
  36. package/dist/base/DataErrorDbException.js +17 -0
  37. package/dist/base/DbConnection.d.ts +13 -0
  38. package/dist/base/DbConnection.d.ts.map +1 -0
  39. package/dist/base/DbConnection.js +53 -0
  40. package/dist/base/ForbiddenHttpException.d.ts +5 -0
  41. package/dist/base/ForbiddenHttpException.d.ts.map +1 -0
  42. package/dist/base/ForbiddenHttpException.js +16 -0
  43. package/dist/base/InvalidArgumentException.d.ts +6 -0
  44. package/dist/base/InvalidArgumentException.d.ts.map +1 -0
  45. package/dist/base/InvalidArgumentException.js +17 -0
  46. package/dist/base/InvalidConfigException.d.ts +6 -0
  47. package/dist/base/InvalidConfigException.d.ts.map +1 -0
  48. package/dist/base/InvalidConfigException.js +17 -0
  49. package/dist/base/Logs.d.ts +22 -0
  50. package/dist/base/Logs.d.ts.map +1 -0
  51. package/{base/Logs.ts → dist/base/Logs.js} +24 -41
  52. package/dist/base/Model.d.ts +302 -0
  53. package/dist/base/Model.d.ts.map +1 -0
  54. package/{base/Model.ts → dist/base/Model.js} +158 -225
  55. package/dist/base/ModelManager.d.ts +2 -0
  56. package/dist/base/ModelManager.d.ts.map +1 -0
  57. package/{base/ModelManager.ts → dist/base/ModelManager.js} +7 -7
  58. package/dist/base/NotFoundHttpException.d.ts +6 -0
  59. package/dist/base/NotFoundHttpException.d.ts.map +1 -0
  60. package/dist/base/NotFoundHttpException.js +17 -0
  61. package/dist/base/RestClient.d.ts +7 -0
  62. package/dist/base/RestClient.d.ts.map +1 -0
  63. package/dist/base/RestClient.js +25 -0
  64. package/dist/base/UnauthorizedHttpException.d.ts +6 -0
  65. package/dist/base/UnauthorizedHttpException.d.ts.map +1 -0
  66. package/dist/base/UnauthorizedHttpException.js +17 -0
  67. package/dist/base/ValidationHttpException.d.ts +6 -0
  68. package/dist/base/ValidationHttpException.d.ts.map +1 -0
  69. package/dist/base/ValidationHttpException.js +17 -0
  70. package/dist/base/db/Exception.d.ts +7 -0
  71. package/dist/base/db/Exception.d.ts.map +1 -0
  72. package/dist/base/db/Exception.js +15 -0
  73. package/dist/base/index.d.ts +20 -0
  74. package/dist/base/index.d.ts.map +1 -0
  75. package/dist/base/index.js +41 -0
  76. package/dist/decorator/Middleware.d.ts +4 -0
  77. package/dist/decorator/Middleware.d.ts.map +1 -0
  78. package/dist/decorator/Middleware.js +10 -0
  79. package/dist/decorator/controller.d.ts +3 -0
  80. package/dist/decorator/controller.d.ts.map +1 -0
  81. package/{decorator/controller.ts → dist/decorator/controller.js} +9 -7
  82. package/dist/decorator/delete.d.ts +3 -0
  83. package/dist/decorator/delete.d.ts.map +1 -0
  84. package/{decorator/delete.ts → dist/decorator/delete.js} +9 -9
  85. package/dist/decorator/enums/ControllerDecoratorParams.d.ts +6 -0
  86. package/dist/decorator/enums/ControllerDecoratorParams.d.ts.map +1 -0
  87. package/dist/decorator/enums/ControllerDecoratorParams.js +9 -0
  88. package/dist/decorator/get.d.ts +3 -0
  89. package/dist/decorator/get.d.ts.map +1 -0
  90. package/{decorator/get.ts → dist/decorator/get.js} +10 -11
  91. package/dist/decorator/index.d.ts +6 -0
  92. package/dist/decorator/index.d.ts.map +1 -0
  93. package/dist/decorator/index.js +13 -0
  94. package/dist/decorator/post.d.ts +3 -0
  95. package/dist/decorator/post.d.ts.map +1 -0
  96. package/{decorator/post.ts → dist/decorator/post.js} +10 -10
  97. package/dist/decorator/put.d.ts +3 -0
  98. package/dist/decorator/put.d.ts.map +1 -0
  99. package/{decorator/put.ts → dist/decorator/put.js} +9 -9
  100. package/dist/filters/AccessControl.d.ts +12 -0
  101. package/dist/filters/AccessControl.d.ts.map +1 -0
  102. package/dist/filters/AccessControl.js +83 -0
  103. package/dist/filters/AccessRule.d.ts +83 -0
  104. package/dist/filters/AccessRule.d.ts.map +1 -0
  105. package/dist/filters/AccessRule.js +136 -0
  106. package/{filters/auth/AuthInterface.ts → dist/filters/auth/AuthInterface.d.ts} +7 -15
  107. package/dist/filters/auth/AuthInterface.d.ts.map +1 -0
  108. package/dist/filters/auth/AuthInterface.js +2 -0
  109. package/dist/filters/auth/AuthMethod.d.ts +38 -0
  110. package/dist/filters/auth/AuthMethod.d.ts.map +1 -0
  111. package/dist/filters/auth/AuthMethod.js +82 -0
  112. package/dist/filters/auth/HttpBasicAuth.d.ts +24 -0
  113. package/dist/filters/auth/HttpBasicAuth.d.ts.map +1 -0
  114. package/dist/filters/auth/HttpBasicAuth.js +79 -0
  115. package/dist/filters/auth/HttpBearerAuth.d.ts +18 -0
  116. package/dist/filters/auth/HttpBearerAuth.d.ts.map +1 -0
  117. package/dist/filters/auth/HttpBearerAuth.js +33 -0
  118. package/dist/filters/auth/HttpHeaderAuth.d.ts +19 -0
  119. package/dist/filters/auth/HttpHeaderAuth.d.ts.map +1 -0
  120. package/dist/filters/auth/HttpHeaderAuth.js +64 -0
  121. package/dist/filters/auth/JwtHttpBearerAuth.d.ts +21 -0
  122. package/dist/filters/auth/JwtHttpBearerAuth.d.ts.map +1 -0
  123. package/dist/filters/auth/JwtHttpBearerAuth.js +88 -0
  124. package/dist/filters/auth/KeyCloakHttpBearerAuth.d.ts +23 -0
  125. package/dist/filters/auth/KeyCloakHttpBearerAuth.d.ts.map +1 -0
  126. package/dist/filters/auth/KeyCloakHttpBearerAuth.js +116 -0
  127. package/dist/filters/auth/index.d.ts +5 -0
  128. package/dist/filters/auth/index.d.ts.map +1 -0
  129. package/dist/filters/auth/index.js +11 -0
  130. package/dist/filters/index.d.ts +3 -0
  131. package/dist/filters/index.d.ts.map +1 -0
  132. package/dist/filters/index.js +7 -0
  133. package/dist/index.d.ts +26 -0
  134. package/dist/index.d.ts.map +1 -0
  135. package/dist/index.js +73 -0
  136. package/dist/log/log/config/log4js.json +55 -0
  137. package/dist/model/RouteDefinition.d.ts +7 -0
  138. package/dist/model/RouteDefinition.d.ts.map +1 -0
  139. package/{base/Configurable.ts → dist/model/RouteDefinition.js} +2 -4
  140. package/dist/package.json +63 -0
  141. package/dist/rbac/AuthAssignment.d.ts +19 -0
  142. package/dist/rbac/AuthAssignment.d.ts.map +1 -0
  143. package/dist/rbac/AuthAssignment.js +44 -0
  144. package/dist/rbac/AuthItem.d.ts +27 -0
  145. package/dist/rbac/AuthItem.d.ts.map +1 -0
  146. package/{rbac/AuthItem.ts → dist/rbac/AuthItem.js} +16 -22
  147. package/dist/rbac/AuthItemChild.d.ts +19 -0
  148. package/dist/rbac/AuthItemChild.d.ts.map +1 -0
  149. package/{rbac/AuthItemChild.ts → dist/rbac/AuthItemChild.js} +14 -21
  150. package/dist/rbac/AuthManager.d.ts +112 -0
  151. package/dist/rbac/AuthManager.d.ts.map +1 -0
  152. package/dist/rbac/AuthManager.js +356 -0
  153. package/dist/rbac/index.d.ts +5 -0
  154. package/dist/rbac/index.d.ts.map +1 -0
  155. package/dist/rbac/index.js +28 -0
  156. package/dist/requiments/Glob.d.ts +3 -0
  157. package/dist/requiments/Glob.d.ts.map +1 -0
  158. package/dist/requiments/Glob.js +10 -0
  159. package/dist/requiments/ReflectUtil.d.ts +1 -0
  160. package/dist/requiments/ReflectUtil.d.ts.map +1 -0
  161. package/{requiments/ReflectUtil.ts → dist/requiments/ReflectUtil.js} +4 -6
  162. package/dist/requiments/Utils.d.ts +2 -0
  163. package/dist/requiments/Utils.d.ts.map +1 -0
  164. package/{requiments/Utils.ts → dist/requiments/Utils.js} +34 -40
  165. package/dist/validators/BooleanValidator.d.ts +1 -0
  166. package/dist/validators/BooleanValidator.d.ts.map +1 -0
  167. package/dist/validators/BooleanValidator.js +1 -0
  168. package/dist/validators/CompareValidator.d.ts +1 -0
  169. package/dist/validators/CompareValidator.d.ts.map +1 -0
  170. package/dist/validators/CompareValidator.js +1 -0
  171. package/dist/validators/DateValidator.d.ts +1 -0
  172. package/dist/validators/DateValidator.d.ts.map +1 -0
  173. package/dist/validators/DateValidator.js +1 -0
  174. package/dist/validators/EmailValidator.d.ts +1 -0
  175. package/dist/validators/EmailValidator.d.ts.map +1 -0
  176. package/dist/validators/EmailValidator.js +1 -0
  177. package/dist/validators/Validator.d.ts +18 -0
  178. package/dist/validators/Validator.d.ts.map +1 -0
  179. package/dist/validators/Validator.js +27 -0
  180. package/{web/IdentityInterface.ts → dist/web/IdentityInterface.d.ts} +2 -15
  181. package/dist/web/IdentityInterface.d.ts.map +1 -0
  182. package/dist/web/IdentityInterface.js +8 -0
  183. package/dist/web/WebUser.d.ts +72 -0
  184. package/dist/web/WebUser.d.ts.map +1 -0
  185. package/dist/web/WebUser.js +165 -0
  186. package/package.json +16 -56
  187. package/BaseChyz.ts +0 -623
  188. package/base/ActionFilter.ts +0 -88
  189. package/base/BadRequestHttpException.ts +0 -14
  190. package/base/Behavior.ts +0 -6
  191. package/base/CBaseObject.ts +0 -17
  192. package/base/CEvents.ts +0 -24
  193. package/base/CWebController.ts +0 -90
  194. package/base/Component.ts +0 -66
  195. package/base/DataErrorDbException.ts +0 -16
  196. package/base/DbConnection.ts +0 -55
  197. package/base/ForbiddenHttpException.ts +0 -15
  198. package/base/InvalidArgumentException.ts +0 -16
  199. package/base/InvalidConfigException.ts +0 -16
  200. package/base/NotFoundHttpException.ts +0 -14
  201. package/base/RestClient.ts +0 -26
  202. package/base/UnauthorizedHttpException.ts +0 -17
  203. package/base/ValidationHttpException.ts +0 -14
  204. package/base/db/Exception.ts +0 -14
  205. package/base/index.ts +0 -19
  206. package/decorator/Middleware.ts +0 -9
  207. package/decorator/enums/ControllerDecoratorParams.ts +0 -5
  208. package/decorator/index.ts +0 -5
  209. package/filters/AccessControl.ts +0 -74
  210. package/filters/AccessRule.ts +0 -182
  211. package/filters/auth/AuthMethod.ts +0 -100
  212. package/filters/auth/HttpBasicAuth.ts +0 -79
  213. package/filters/auth/HttpBearerAuth.ts +0 -34
  214. package/filters/auth/HttpHeaderAuth.ts +0 -61
  215. package/filters/auth/JwtHttpBearerAuth.ts +0 -83
  216. package/filters/auth/KeyCloakHttpBearerAuth.ts +0 -114
  217. package/filters/auth/index.ts +0 -4
  218. package/filters/index.ts +0 -2
  219. package/index.ts +0 -80
  220. package/model/RouteDefinition.ts +0 -18
  221. package/rbac/AuthAssignment.ts +0 -50
  222. package/rbac/AuthManager.ts +0 -399
  223. package/rbac/index.ts +0 -12
  224. package/validators/BooleanValidator.ts +0 -0
  225. package/validators/CompareValidator.ts +0 -0
  226. package/validators/DateValidator.ts +0 -0
  227. package/validators/EmailValidator.ts +0 -0
  228. package/validators/Validator.ts +0 -27
  229. package/web/WebUser.ts +0 -187
  230. /package/{README.md → dist/README.md} +0 -0
  231. /package/{log → dist/log}/config/log4js.json +0 -0
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2021. Chy Bilgisayar Bilisim
4
+ * Author: Cihan Ozturk
5
+ * E-mail: cihan@chy.com.tr
6
+ * Github:https://github.com/cihan53/
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const Glob = require("glob");
10
+ exports.default = Glob;
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=ReflectUtil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReflectUtil.d.ts","sourceRoot":"","sources":["../../src/requiments/ReflectUtil.ts"],"names":[],"mappings":""}
@@ -1,10 +1,10 @@
1
+ "use strict";
1
2
  /*
2
3
  * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
4
  * Author: Cihan Ozturk
4
5
  * E-mail: cihan@chy.com.tr
5
6
  * Github:https://github.com/cihan53/
6
7
  */
7
-
8
8
  /**
9
9
  * @param strClass:
10
10
  * class name
@@ -12,15 +12,13 @@
12
12
  * constructor arguments
13
13
  */
14
14
  // @ts-ignore
15
- Reflect.newInstance = function (strClass: string) {
15
+ Reflect.newInstance = function (strClass) {
16
16
  const args = Array.prototype.slice.call(arguments, 1);
17
17
  const clsClass = eval(strClass);
18
-
19
18
  const F = () => {
20
19
  return clsClass.apply(this, args);
21
- }
22
-
20
+ };
23
21
  F.prototype = clsClass.prototype;
24
22
  // @ts-ignore
25
23
  return new F();
26
- };
24
+ };
@@ -0,0 +1,2 @@
1
+ export declare const Utils: any;
2
+ //# sourceMappingURL=Utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/requiments/Utils.ts"],"names":[],"mappings":"AA+GA,eAAO,MAAM,KAAK,KAQjB,CAAA"}
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /*
2
3
  * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
4
  * Author: Cihan Ozturk
@@ -5,7 +6,8 @@
5
6
  * Github:https://github.com/cihan53/
6
7
  */
7
8
  // import _ from "lodash";
8
-
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Utils = void 0;
9
11
  const _ = require('lodash');
10
12
  /**
11
13
  *
@@ -13,17 +15,20 @@ const _ = require('lodash');
13
15
  * @param val
14
16
  * @param top
15
17
  */
16
- const buildParams = function (prefix: string, val: any, top?: boolean) {
17
- if (_.isUndefined(top)) top = true;
18
+ const buildParams = function (prefix, val, top) {
19
+ if (_.isUndefined(top))
20
+ top = true;
18
21
  if (_.isArray(val)) {
19
- return _.map(val, function (value: any, key: string) {
22
+ return _.map(val, function (value, key) {
20
23
  return buildParams(top ? key : prefix + '[]', value, false);
21
24
  }).join('&');
22
- } else if (_.isObject(val)) {
23
- return _.map(val, function (value: any, key: string) {
25
+ }
26
+ else if (_.isObject(val)) {
27
+ return _.map(val, function (value, key) {
24
28
  return buildParams(top ? key : prefix + '[' + key + ']', value, false);
25
29
  }).join('&');
26
- } else {
30
+ }
31
+ else {
27
32
  return encodeURIComponent(prefix) + '=' + encodeURIComponent(val);
28
33
  }
29
34
  };
@@ -31,41 +36,38 @@ const buildParams = function (prefix: string, val: any, top?: boolean) {
31
36
  *Creates a query string from a hash
32
37
  * @param obj
33
38
  */
34
- const toQuery = function (obj: any) {
39
+ const toQuery = function (obj) {
35
40
  return buildParams('', obj);
36
- }
37
-
41
+ };
38
42
  /**
39
43
  *
40
44
  * @param object
41
45
  * @param params
42
46
  */
43
- const createObject = (object: any, params: any) => {
44
- let newParams: any = {}
47
+ const createObject = (object, params) => {
48
+ let newParams = {};
45
49
  Object.keys(params).forEach((param) => {
46
- newParams[param] = {}
50
+ newParams[param] = {};
47
51
  Object.assign(newParams[param], {
48
52
  writable: true,
49
53
  configurable: true,
50
54
  value: params[param]
51
55
  });
52
- })
56
+ });
53
57
  return Object.create(object, newParams);
54
- }
58
+ };
55
59
  /**
56
60
  *
57
61
  * @param object
58
62
  * @param findKey
59
63
  */
60
- const findKeyValue = (object: any, findKey: string) => {
61
- let key = Object.keys(object).find(key => key.toLowerCase() === findKey.toLowerCase())
64
+ const findKeyValue = (object, findKey) => {
65
+ let key = Object.keys(object).find(key => key.toLowerCase() === findKey.toLowerCase());
62
66
  if (key) {
63
67
  return object[key];
64
68
  }
65
-
66
- return null
67
- }
68
-
69
+ return null;
70
+ };
69
71
  /**
70
72
  *
71
73
  * @param seconds
@@ -74,48 +76,40 @@ const sleep = (seconds = 1) => {
74
76
  const waitTill = new Date(new Date().getTime() + seconds * 1000);
75
77
  while (waitTill > new Date()) {
76
78
  }
77
- }
78
-
79
+ };
79
80
  /**
80
81
  *
81
82
  * @param wildcard
82
83
  * @param str
83
84
  */
84
- function wildTest(wildcard: string, str: string) {
85
+ function wildTest(wildcard, str) {
85
86
  let w = wildcard.replace(/[.+^${}()|[\]\\]/g, '\\$&'); // regexp escape
86
- const re = new RegExp(`^${w.replace(/\*/g,'.*').replace(/\?/g,'.')}$`, 'i');
87
+ const re = new RegExp(`^${w.replace(/\*/g, '.*').replace(/\?/g, '.')}$`, 'i');
87
88
  return re.test(str); // remove last 'i' above to have case sensitive
88
89
  }
89
-
90
90
  /**
91
91
  *
92
92
  * @param pattern
93
93
  * @param string
94
94
  * @param options
95
95
  */
96
- const matchWildcard = (pattern: string, string: string, options: any = {}) => {
97
- return wildTest(pattern, string)
98
- }
99
-
100
-
96
+ const matchWildcard = (pattern, string, options = {}) => {
97
+ return wildTest(pattern, string);
98
+ };
101
99
  /**
102
100
  * random string genrate
103
101
  * @param length
104
102
  * @param randomString
105
103
  */
106
- const generateRandomString = function (length: number, randomString = ""): string {
104
+ const generateRandomString = function (length, randomString = "") {
107
105
  randomString += Math.random().toString(20).substring(2, length);
108
- if (randomString.length > length) return randomString.slice(0, length);
106
+ if (randomString.length > length)
107
+ return randomString.slice(0, length);
109
108
  return generateRandomString(length, randomString);
110
109
  };
111
-
112
- export const Utils = {
113
- findKeyValue,
110
+ exports.Utils = Object.assign({ findKeyValue,
114
111
  createObject,
115
112
  sleep,
116
113
  matchWildcard,
117
114
  toQuery,
118
- generateRandomString,
119
- ..._
120
- }
121
-
115
+ generateRandomString }, _);
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=BooleanValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BooleanValidator.d.ts","sourceRoot":"","sources":["../../src/validators/BooleanValidator.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=CompareValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompareValidator.d.ts","sourceRoot":"","sources":["../../src/validators/CompareValidator.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=DateValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateValidator.d.ts","sourceRoot":"","sources":["../../src/validators/DateValidator.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=EmailValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailValidator.d.ts","sourceRoot":"","sources":["../../src/validators/EmailValidator.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,18 @@
1
+ import { Component } from "../base";
2
+ export declare class Validator extends Component {
3
+ static builtInValidators: {
4
+ boolean: string;
5
+ email: string;
6
+ };
7
+ /**
8
+ * @var array|string attributes to be validated by this validator. For multiple attributes,
9
+ * please specify them as an array; for single attribute, you may use either a string or an array.
10
+ */
11
+ attributes: never[];
12
+ message: string;
13
+ except: never[];
14
+ isEmpty: never[];
15
+ init(): void;
16
+ static createValidator(type: any, model: any, attributes: any, params?: never[]): void;
17
+ }
18
+ //# sourceMappingURL=Validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../src/validators/Validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAElC,qBAAa,SAAU,SAAQ,SAAS;IACpC,OAAc,iBAAiB;;;MAG9B;IAGD;;;OAGG;IACI,UAAU,UAAM;IAChB,OAAO,EAAE,MAAM,CAAM;IAErB,MAAM,UAAM;IACZ,OAAO,UAAM;IAEb,IAAI;WAIG,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,UAAK;CAGpF"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Validator = void 0;
4
+ const base_1 = require("../base");
5
+ class Validator extends base_1.Component {
6
+ constructor() {
7
+ super(...arguments);
8
+ /**
9
+ * @var array|string attributes to be validated by this validator. For multiple attributes,
10
+ * please specify them as an array; for single attribute, you may use either a string or an array.
11
+ */
12
+ this.attributes = [];
13
+ this.message = "";
14
+ this.except = [];
15
+ this.isEmpty = [];
16
+ }
17
+ init() {
18
+ super.init();
19
+ }
20
+ static createValidator(type, model, attributes, params = []) {
21
+ }
22
+ }
23
+ exports.Validator = Validator;
24
+ Validator.builtInValidators = {
25
+ 'boolean': '',
26
+ 'email': '',
27
+ };
@@ -1,10 +1,3 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
1
  export interface IdentityInterface {
9
2
  /**
10
3
  * Finds an identity by the given ID.
@@ -13,8 +6,7 @@ export interface IdentityInterface {
13
6
  * Null should be returned if such an identity cannot be found
14
7
  * or the identity is not in an active state (disabled, deleted, etc.)
15
8
  */
16
- findIdentity(id: number): any
17
-
9
+ findIdentity(id: number): any;
18
10
  /**
19
11
  * Finds an identity by the given token.
20
12
  * For example, [[\yii\filters\auth\HttpBearerAuth]] will set this parameter to be `yii\filters\auth\HttpBearerAuth`.
@@ -26,13 +18,11 @@ export interface IdentityInterface {
26
18
  * @param any
27
19
  */
28
20
  findIdentityByAccessToken(token: any, type: string): any;
29
-
30
21
  /**
31
22
  * Returns an ID that can uniquely identify a user identity.
32
23
  * @return string|int an ID that uniquely identifies a user identity.
33
24
  */
34
25
  getId(): number;
35
-
36
26
  /**
37
27
  * Returns a key that can be used to check the validity of a given identity ID.
38
28
  *
@@ -50,7 +40,6 @@ export interface IdentityInterface {
50
40
  * @see validateAuthKey()
51
41
  */
52
42
  getAuthKey(): string;
53
-
54
43
  /**
55
44
  * Validates the given auth key.
56
45
  *
@@ -59,11 +48,9 @@ export interface IdentityInterface {
59
48
  * @see getAuthKey()
60
49
  */
61
50
  validateAuthKey(authKey: string): (boolean | null);
62
-
63
-
64
51
  /**
65
52
  *
66
53
  */
67
54
  can(permissionName: string, params: any[], allowCaching: boolean): Promise<(boolean | null)>;
68
-
69
55
  }
56
+ //# sourceMappingURL=IdentityInterface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IdentityInterface.d.ts","sourceRoot":"","sources":["../../src/web/IdentityInterface.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAC9B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAA;IAE7B;;;;;;;;;OASG;IACH,yBAAyB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;IAEzD;;;OAGG;IACH,KAAK,IAAI,MAAM,CAAC;IAEhB;;;;;;;;;;;;;;;OAeG;IACH,UAAU,IAAI,MAAM,CAAC;IAErB;;;;;;OAMG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAGnD;;OAEG;IACH,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;CAEhG"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2021. Chy Bilgisayar Bilisim
4
+ * Author: Cihan Ozturk
5
+ * E-mail: cihan@chy.com.tr
6
+ * Github:https://github.com/cihan53/
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,72 @@
1
+ import { Component } from "../base/Component";
2
+ import { IdentityInterface } from "./IdentityInterface";
3
+ import { AuthManager } from "../rbac/AuthManager";
4
+ export declare class WebUser extends Component {
5
+ /**
6
+ * @var string the class name of the [[identity]] object.
7
+ */
8
+ identityClass: any;
9
+ private _identity;
10
+ /**
11
+ * @var CheckAccessInterface|string|array The access checker object to use for checking access or the application
12
+ * component ID of the access checker.
13
+ * If not set the application auth manager will be used.
14
+ * @since 2.0.9
15
+ */
16
+ accessChecker: any;
17
+ get identity(): any;
18
+ set identity(value: any);
19
+ init(): void;
20
+ getIsGuest(): boolean;
21
+ getIdentity(autoRenew?: boolean): any;
22
+ loginRequired(): void;
23
+ /**
24
+ * Regenerates CSRF token
25
+ *
26
+ * @since 2.0.14.2
27
+ */
28
+ protected regenerateCsrfToken(): void;
29
+ /**
30
+ * Logs in a user by the given access token.
31
+ * @param token
32
+ * @param type
33
+ */
34
+ loginByAccessToken(token: any, type?: any): Promise<any>;
35
+ login(identity: IdentityInterface, duration?: number): boolean;
36
+ beforeLogin(identity: any, cookieBased: boolean, duration: number): boolean;
37
+ afterLogin(): void;
38
+ getId(): any;
39
+ /**
40
+ * Checks if the user can perform the operation as specified by the given permission.
41
+ *
42
+ * Note that you must configure "authManager" application component in order to use this method.
43
+ * Otherwise it will always return false.
44
+ *
45
+ * @param string $permissionName the name of the permission (e.g. "edit post") that needs access check.
46
+ * @param array $params name-value pairs that would be passed to the rules associated
47
+ * with the roles and permissions assigned to the user.
48
+ * @param bool $allowCaching whether to allow caching the result of access check.
49
+ * When this parameter is true (default), if the access check of an operation was performed
50
+ * before, its result will be directly returned when calling this method to check the same
51
+ * operation. If this parameter is false, this method will always call
52
+ * [[\yii\rbac\CheckAccessInterface::checkAccess()]] to obtain the up-to-date access result. Note that this
53
+ * caching is effective only within the same request and only works when `$params = []`.
54
+ * @return bool whether the user can perform the operation as specified by the given permission.
55
+ */
56
+ can(permissionName: string, params?: never[], allowCaching?: boolean): Promise<boolean>;
57
+ /**
58
+ * Returns auth manager associated with the user component.
59
+ *
60
+ * By default this is the `authManager` application component.
61
+ * You may override this method to return a different auth manager instance if needed.
62
+ * @return \yii\rbac\ManagerInterface
63
+ * @since 2.0.6
64
+ */
65
+ protected getAuthManager(): AuthManager;
66
+ /**
67
+ * Returns the access checker used for checking access.
68
+ * @return CheckAccessInterface
69
+ */
70
+ protected getAccessChecker(): AuthManager;
71
+ }
72
+ //# sourceMappingURL=WebUser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebUser.d.ts","sourceRoot":"","sources":["../../src/web/WebUser.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAEhD,qBAAa,OAAQ,SAAQ,SAAS;IAElC;;OAEG;IACI,aAAa,EAAE,GAAG,CAAC;IAC1B,OAAO,CAAC,SAAS,CAAM;IACvB;;;;;OAKG;IACI,aAAa,EAAE,GAAG,CAAQ;IAGjC,IAAI,QAAQ,QAEX;IAED,IAAI,QAAQ,CAAC,KAAK,KAAA,EAEjB;IAEM,IAAI;IAYJ,UAAU;IAIV,WAAW,CAAC,SAAS,UAAO;IAI5B,aAAa;IAMpB;;;;OAIG;IACH,SAAS,CAAC,mBAAmB;IAI7B;;;;OAIG;IACU,kBAAkB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,GAAE,GAAU;IAcrD,KAAK,CAAC,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,SAAI,GAAG,OAAO;IAQzD,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM;IAKjE,UAAU;IAIV,KAAK;IAKZ;;;;;;;;;;;;;;;;OAgBG;IAiBU,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,UAAK,EAAE,YAAY,UAAO;IAkBzE;;;;;;;OAOG;IACH,SAAS,CAAC,cAAc,IAAI,WAAW;IAIvC;;;OAGG;IACH,SAAS,CAAC,gBAAgB,IAAG,WAAW;CAK3C"}
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.WebUser = void 0;
16
+ /*
17
+ * Copyright (c) 2021. Chy Bilgisayar Bilisim
18
+ * Author: Cihan Ozturk
19
+ * E-mail: cihan@chy.com.tr
20
+ * Github:https://github.com/cihan53/
21
+ */
22
+ const BaseChyz_1 = __importDefault(require("../BaseChyz"));
23
+ const Component_1 = require("../base/Component");
24
+ const ForbiddenHttpException_1 = require("../base/ForbiddenHttpException");
25
+ const InvalidConfigException_1 = require("../base/InvalidConfigException");
26
+ const Utils_1 = require("../requiments/Utils");
27
+ class WebUser extends Component_1.Component {
28
+ constructor() {
29
+ super(...arguments);
30
+ /**
31
+ * @var CheckAccessInterface|string|array The access checker object to use for checking access or the application
32
+ * component ID of the access checker.
33
+ * If not set the application auth manager will be used.
34
+ * @since 2.0.9
35
+ */
36
+ this.accessChecker = null;
37
+ }
38
+ get identity() {
39
+ return this._identity;
40
+ }
41
+ set identity(value) {
42
+ this._identity = value;
43
+ }
44
+ init() {
45
+ super.init();
46
+ if (this.identityClass === null) {
47
+ throw new InvalidConfigException_1.InvalidConfigException('User::identityClass must be set.');
48
+ }
49
+ this.identityClass = new this.identityClass();
50
+ }
51
+ getIsGuest() {
52
+ return this.getIdentity() === null;
53
+ }
54
+ getIdentity(autoRenew = true) {
55
+ return this._identity;
56
+ }
57
+ loginRequired() {
58
+ throw new ForbiddenHttpException_1.ForbiddenHttpException(BaseChyz_1.default.t('Login Required'));
59
+ }
60
+ /**
61
+ * Regenerates CSRF token
62
+ *
63
+ * @since 2.0.14.2
64
+ */
65
+ regenerateCsrfToken() {
66
+ }
67
+ /**
68
+ * Logs in a user by the given access token.
69
+ * @param token
70
+ * @param type
71
+ */
72
+ loginByAccessToken(token_1) {
73
+ return __awaiter(this, arguments, void 0, function* (token, type = null) {
74
+ let $class = this.identityClass;
75
+ if ($class.findIdentityByAccessToken) {
76
+ this.identity = yield $class.findIdentityByAccessToken(token, type);
77
+ if (this.identity && this.login(this.identity)) {
78
+ return this.identity;
79
+ }
80
+ }
81
+ else {
82
+ BaseChyz_1.default.error("WebUser::findIdentityByAccessToken undefined");
83
+ }
84
+ return null;
85
+ });
86
+ }
87
+ login(identity, duration = 0) {
88
+ if (this.beforeLogin(identity, false, duration)) {
89
+ }
90
+ return !this.getIsGuest();
91
+ }
92
+ beforeLogin(identity, cookieBased, duration) {
93
+ return true;
94
+ }
95
+ afterLogin() {
96
+ }
97
+ getId() {
98
+ let identity = this.getIdentity();
99
+ return identity !== null ? identity.id : null;
100
+ }
101
+ /**
102
+ * Checks if the user can perform the operation as specified by the given permission.
103
+ *
104
+ * Note that you must configure "authManager" application component in order to use this method.
105
+ * Otherwise it will always return false.
106
+ *
107
+ * @param string $permissionName the name of the permission (e.g. "edit post") that needs access check.
108
+ * @param array $params name-value pairs that would be passed to the rules associated
109
+ * with the roles and permissions assigned to the user.
110
+ * @param bool $allowCaching whether to allow caching the result of access check.
111
+ * When this parameter is true (default), if the access check of an operation was performed
112
+ * before, its result will be directly returned when calling this method to check the same
113
+ * operation. If this parameter is false, this method will always call
114
+ * [[\yii\rbac\CheckAccessInterface::checkAccess()]] to obtain the up-to-date access result. Note that this
115
+ * caching is effective only within the same request and only works when `$params = []`.
116
+ * @return bool whether the user can perform the operation as specified by the given permission.
117
+ */
118
+ // public function can($permissionName, $params = [], $allowCaching = true)
119
+ // {
120
+ // if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) {
121
+ // return $this->_access[$permissionName];
122
+ // }
123
+ // if (($accessChecker = $this->getAccessChecker()) === null) {
124
+ // return false;
125
+ // }
126
+ // $access = $accessChecker->checkAccess($this->getId(), $permissionName, $params);
127
+ // if ($allowCaching && empty($params)) {
128
+ // $this->_access[$permissionName] = $access;
129
+ // }
130
+ //
131
+ // return $access;
132
+ // }
133
+ can(permissionName_1) {
134
+ return __awaiter(this, arguments, void 0, function* (permissionName, params = [], allowCaching = true) {
135
+ let access;
136
+ let accessChecker;
137
+ if ((accessChecker = this.getAccessChecker()) == null)
138
+ return false;
139
+ access = yield accessChecker.checkAccess(this.getId(), permissionName, params);
140
+ if (allowCaching && Utils_1.Utils.isEmpty(params)) {
141
+ // this._access[$permissionName] = $access;
142
+ }
143
+ return access;
144
+ });
145
+ }
146
+ /**
147
+ * Returns auth manager associated with the user component.
148
+ *
149
+ * By default this is the `authManager` application component.
150
+ * You may override this method to return a different auth manager instance if needed.
151
+ * @return \yii\rbac\ManagerInterface
152
+ * @since 2.0.6
153
+ */
154
+ getAuthManager() {
155
+ return BaseChyz_1.default.getComponent('authManager');
156
+ }
157
+ /**
158
+ * Returns the access checker used for checking access.
159
+ * @return CheckAccessInterface
160
+ */
161
+ getAccessChecker() {
162
+ return this.accessChecker !== null ? this.accessChecker : this.getAuthManager();
163
+ }
164
+ }
165
+ exports.WebUser = WebUser;