chyz 2.0.0-rc.8 → 2.0.1-rc.1

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 (153) hide show
  1. package/BaseChyz.d.ts +73 -56
  2. package/BaseChyz.d.ts.map +1 -1
  3. package/BaseChyz.js +569 -404
  4. package/README.md +1 -1
  5. package/base/ActionFilter.d.ts +32 -32
  6. package/base/ActionFilter.d.ts.map +1 -1
  7. package/base/ActionFilter.js +82 -82
  8. package/base/BadRequestHttpException.d.ts +6 -0
  9. package/base/BadRequestHttpException.d.ts.map +1 -0
  10. package/base/BadRequestHttpException.js +17 -0
  11. package/base/BaseError.d.ts +43 -10
  12. package/base/BaseError.d.ts.map +1 -1
  13. package/base/BaseError.js +58 -26
  14. package/base/Behavior.d.ts +3 -3
  15. package/base/Behavior.js +7 -7
  16. package/base/CBaseObject.d.ts +4 -4
  17. package/base/CBaseObject.d.ts.map +1 -1
  18. package/base/CBaseObject.js +16 -16
  19. package/base/CEvents.d.ts +13 -0
  20. package/base/CEvents.d.ts.map +1 -0
  21. package/base/CEvents.js +24 -0
  22. package/base/CRequest.d.ts +1 -1
  23. package/base/CRequest.js +10 -10
  24. package/base/CWebController.d.ts +43 -43
  25. package/base/CWebController.d.ts.map +1 -1
  26. package/base/CWebController.js +81 -74
  27. package/base/Component.d.ts +20 -20
  28. package/base/Component.d.ts.map +1 -1
  29. package/base/Component.js +57 -57
  30. package/base/Configurable.d.ts +2 -2
  31. package/base/Configurable.js +8 -8
  32. package/base/DataErrorDbException.d.ts +5 -5
  33. package/base/DataErrorDbException.d.ts.map +1 -1
  34. package/base/DataErrorDbException.js +17 -17
  35. package/base/DbConnection.d.ts +12 -12
  36. package/base/DbConnection.js +53 -53
  37. package/base/ForbiddenHttpException.d.ts +4 -4
  38. package/base/ForbiddenHttpException.d.ts.map +1 -1
  39. package/base/ForbiddenHttpException.js +16 -16
  40. package/base/InvalidArgumentException.d.ts +5 -5
  41. package/base/InvalidArgumentException.d.ts.map +1 -1
  42. package/base/InvalidArgumentException.js +17 -17
  43. package/base/InvalidConfigException.d.ts +5 -5
  44. package/base/InvalidConfigException.d.ts.map +1 -1
  45. package/base/InvalidConfigException.js +17 -17
  46. package/base/Logs.d.ts +21 -21
  47. package/base/Logs.d.ts.map +1 -1
  48. package/base/Logs.js +57 -57
  49. package/base/Model.d.ts +301 -298
  50. package/base/Model.d.ts.map +1 -1
  51. package/base/Model.js +545 -507
  52. package/base/ModelManager.d.ts +1 -1
  53. package/base/ModelManager.js +19 -19
  54. package/base/NotFoundHttpException.d.ts +5 -5
  55. package/base/NotFoundHttpException.d.ts.map +1 -1
  56. package/base/NotFoundHttpException.js +17 -17
  57. package/base/RestClient.d.ts +6 -6
  58. package/base/RestClient.d.ts.map +1 -1
  59. package/base/RestClient.js +25 -25
  60. package/base/UnauthorizedHttpException.d.ts +5 -5
  61. package/base/UnauthorizedHttpException.d.ts.map +1 -1
  62. package/base/UnauthorizedHttpException.js +17 -17
  63. package/base/ValidationHttpException.d.ts +5 -5
  64. package/base/ValidationHttpException.d.ts.map +1 -1
  65. package/base/ValidationHttpException.js +17 -17
  66. package/base/db/Exception.d.ts +6 -6
  67. package/base/db/Exception.js +15 -15
  68. package/base/index.d.ts +19 -18
  69. package/base/index.d.ts.map +1 -1
  70. package/base/index.js +41 -39
  71. package/decorator/Middleware.d.ts +3 -3
  72. package/decorator/Middleware.js +11 -11
  73. package/decorator/controller.d.ts +2 -2
  74. package/decorator/controller.js +24 -24
  75. package/decorator/delete.d.ts +3 -0
  76. package/decorator/delete.d.ts.map +1 -0
  77. package/decorator/delete.js +36 -0
  78. package/decorator/enums/ControllerDecoratorParams.d.ts +5 -5
  79. package/decorator/enums/ControllerDecoratorParams.js +9 -9
  80. package/decorator/get.d.ts +2 -2
  81. package/decorator/get.js +36 -36
  82. package/decorator/index.d.ts +5 -3
  83. package/decorator/index.d.ts.map +1 -1
  84. package/decorator/index.js +13 -9
  85. package/decorator/post.d.ts +2 -2
  86. package/decorator/post.js +36 -36
  87. package/decorator/put.d.ts +3 -0
  88. package/decorator/put.d.ts.map +1 -0
  89. package/decorator/put.js +36 -0
  90. package/filters/AccessControl.d.ts +12 -12
  91. package/filters/AccessControl.d.ts.map +1 -1
  92. package/filters/AccessControl.js +83 -83
  93. package/filters/AccessRule.d.ts +82 -82
  94. package/filters/AccessRule.d.ts.map +1 -1
  95. package/filters/AccessRule.js +136 -137
  96. package/filters/auth/AuthInterface.d.ts +25 -25
  97. package/filters/auth/AuthInterface.js +2 -2
  98. package/filters/auth/AuthMethod.d.ts +37 -37
  99. package/filters/auth/AuthMethod.d.ts.map +1 -1
  100. package/filters/auth/AuthMethod.js +82 -82
  101. package/filters/auth/HttpBasicAuth.d.ts +23 -22
  102. package/filters/auth/HttpBasicAuth.d.ts.map +1 -1
  103. package/filters/auth/HttpBasicAuth.js +78 -72
  104. package/filters/auth/HttpBearerAuth.d.ts +17 -17
  105. package/filters/auth/HttpBearerAuth.d.ts.map +1 -1
  106. package/filters/auth/HttpBearerAuth.js +33 -32
  107. package/filters/auth/HttpHeaderAuth.d.ts +18 -14
  108. package/filters/auth/HttpHeaderAuth.d.ts.map +1 -1
  109. package/filters/auth/HttpHeaderAuth.js +64 -57
  110. package/filters/auth/JwtHttpBearerAuth.d.ts +20 -20
  111. package/filters/auth/JwtHttpBearerAuth.d.ts.map +1 -1
  112. package/filters/auth/JwtHttpBearerAuth.js +87 -81
  113. package/filters/auth/KeyCloakHttpBearerAuth.d.ts +22 -22
  114. package/filters/auth/KeyCloakHttpBearerAuth.js +116 -116
  115. package/filters/auth/index.d.ts +4 -4
  116. package/filters/auth/index.js +11 -11
  117. package/filters/index.d.ts +2 -2
  118. package/filters/index.js +7 -7
  119. package/index.d.ts +28 -21
  120. package/index.d.ts.map +1 -1
  121. package/index.js +71 -60
  122. package/model/RouteDefinition.d.ts +6 -6
  123. package/model/RouteDefinition.js +8 -8
  124. package/package.json +22 -24
  125. package/rbac/AuthAssignment.d.ts +18 -18
  126. package/rbac/AuthAssignment.js +44 -44
  127. package/rbac/AuthItem.d.ts +26 -26
  128. package/rbac/AuthItem.js +51 -51
  129. package/rbac/AuthItemChild.d.ts +18 -18
  130. package/rbac/AuthItemChild.js +43 -43
  131. package/rbac/AuthManager.d.ts +111 -111
  132. package/rbac/AuthManager.d.ts.map +1 -1
  133. package/rbac/AuthManager.js +356 -355
  134. package/rbac/index.d.ts +5 -0
  135. package/rbac/index.d.ts.map +1 -0
  136. package/rbac/index.js +28 -0
  137. package/requiments/Glob.d.ts +2 -2
  138. package/requiments/Glob.js +10 -10
  139. package/requiments/ReflectUtil.js +24 -24
  140. package/requiments/Utils.d.ts +1 -8
  141. package/requiments/Utils.d.ts.map +1 -1
  142. package/requiments/Utils.js +115 -112
  143. package/validators/BooleanValidator.js +1 -1
  144. package/validators/CompareValidator.js +1 -1
  145. package/validators/DateValidator.js +1 -1
  146. package/validators/EmailValidator.js +1 -1
  147. package/validators/Validator.d.ts +17 -17
  148. package/validators/Validator.js +27 -27
  149. package/web/IdentityInterface.d.ts +55 -54
  150. package/web/IdentityInterface.d.ts.map +1 -1
  151. package/web/IdentityInterface.js +8 -8
  152. package/web/WebUser.d.ts +71 -71
  153. package/web/WebUser.js +165 -165
@@ -1,137 +1,136 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AccessRule = void 0;
13
- const Component_1 = require("../base/Component");
14
- const InvalidConfigException_1 = require("../base/InvalidConfigException");
15
- const Utils_1 = require("../requiments/Utils");
16
- var _ = require('lodash');
17
- class AccessRule extends Component_1.Component {
18
- constructor() {
19
- super(...arguments);
20
- /**
21
- * @var array|Closure parameters to pass to the [[User::can()]] function for evaluating
22
- * user permissions in [[$roles]].
23
- *
24
- * If this is an array, it will be passed directly to [[User::can()]]. For example for passing an
25
- * ID from the current request, you may use the following:
26
- *
27
- * ```php
28
- * ['postId' => Yii::$app->request->get('id')]
29
- * ```
30
- *
31
- * You may also specify a closure that returns an array. This can be used to
32
- * evaluate the array values only if they are needed, for example when a model needs to be
33
- * loaded like in the following code:
34
- *
35
- * ```php
36
- * 'rules' => [
37
- * [
38
- * 'allow' => true,
39
- * 'actions' => ['update'],
40
- * 'roles' => ['updatePost'],
41
- * 'roleParams' => function($rule) {
42
- * return ['post' => Post::findOne(Yii::$app->request->get('id'))];
43
- * },
44
- * ],
45
- * ],
46
- * ```
47
- *
48
- * A reference to the [[AccessRule]] instance will be passed to the closure as the first parameter.
49
- *
50
- * @see roles
51
- * @since 2.0.12
52
- */
53
- this.roleParams = [];
54
- }
55
- allows(action, user, request) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- if (this.matchAction(action)
58
- && (yield this.matchRole(user))) {
59
- return this.allow;
60
- }
61
- // if (this.matchAction($action)
62
- // && this.matchRole($user)
63
- // && this.matchIP($request->getUserIP())
64
- // && this.matchVerb($request->getMethod())
65
- // && this.matchController($action->controller)
66
- // && this.matchCustom($action)
67
- // ) {
68
- // return $this->allow ? true : false;
69
- // }
70
- return null;
71
- });
72
- }
73
- /**
74
- * @param Action $action the action
75
- * @return bool whether the rule applies to the action
76
- */
77
- matchAction(action) {
78
- return _.isEmpty(this.actions) || this.actions.includes(action.id);
79
- }
80
- /**
81
- * @param Controller $controller the controller
82
- * @return bool whether the rule applies to the controller
83
- */
84
- matchController(controller) {
85
- // if (empty($this->controllers)) {
86
- // return true;
87
- // }
88
- //
89
- // $id = $controller->getUniqueId();
90
- // foreach ($this->controllers as $pattern) {
91
- // if (StringHelper::matchWildcard($pattern, $id)) {
92
- // return true;
93
- // }
94
- // }
95
- return false;
96
- }
97
- matchRole(user) {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- let items = Utils_1.Utils.isEmpty(this.roles) ? [] : this.roles;
100
- if (!Utils_1.Utils.isEmpty(this.permissions)) {
101
- items = Utils_1.Utils.merge(items, this.permissions);
102
- }
103
- if (Utils_1.Utils.isEmpty(items)) {
104
- return true;
105
- }
106
- if (!user) {
107
- throw new InvalidConfigException_1.InvalidConfigException('The user application component must be available to specify roles in AccessRule.');
108
- }
109
- // @ts-ignore
110
- let roleParams = [];
111
- for (const itemsKey in items) {
112
- let item = items[itemsKey];
113
- if (item === '?') {
114
- if (user.getIsGuest()) {
115
- return true;
116
- }
117
- }
118
- else if (item === '@') {
119
- if (!user.getIsGuest()) {
120
- return true;
121
- }
122
- }
123
- else {
124
- //roleparams
125
- if (!Utils_1.Utils.isEmpty(this.roleParams)) {
126
- roleParams = !Utils_1.Utils.isArray(this.roleParams) ? this.roleParams.apply(this) : this.roleParams;
127
- }
128
- if (yield user.can(item, this.roleParams)) {
129
- return true;
130
- }
131
- }
132
- }
133
- return false;
134
- });
135
- }
136
- }
137
- exports.AccessRule = AccessRule;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AccessRule = void 0;
13
+ const base_1 = require("../base");
14
+ const base_2 = require("../base");
15
+ const Utils_1 = require("../requiments/Utils");
16
+ class AccessRule extends base_1.Component {
17
+ constructor() {
18
+ super(...arguments);
19
+ /**
20
+ * @var array|Closure parameters to pass to the [[User::can()]] function for evaluating
21
+ * user permissions in [[$roles]].
22
+ *
23
+ * If this is an array, it will be passed directly to [[User::can()]]. For example for passing an
24
+ * ID from the current request, you may use the following:
25
+ *
26
+ * ```php
27
+ * ['postId' => Yii::$app->request->get('id')]
28
+ * ```
29
+ *
30
+ * You may also specify a closure that returns an array. This can be used to
31
+ * evaluate the array values only if they are needed, for example when a model needs to be
32
+ * loaded like in the following code:
33
+ *
34
+ * ```php
35
+ * 'rules' => [
36
+ * [
37
+ * 'allow' => true,
38
+ * 'actions' => ['update'],
39
+ * 'roles' => ['updatePost'],
40
+ * 'roleParams' => function($rule) {
41
+ * return ['post' => Post::findOne(Yii::$app->request->get('id'))];
42
+ * },
43
+ * ],
44
+ * ],
45
+ * ```
46
+ *
47
+ * A reference to the [[AccessRule]] instance will be passed to the closure as the first parameter.
48
+ *
49
+ * @see roles
50
+ * @since 2.0.12
51
+ */
52
+ this.roleParams = [];
53
+ }
54
+ allows(action, user, request) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ if (this.matchAction(action)
57
+ && (yield this.matchRole(user))) {
58
+ return this.allow;
59
+ }
60
+ // if (this.matchAction($action)
61
+ // && this.matchRole($user)
62
+ // && this.matchIP($request->getUserIP())
63
+ // && this.matchVerb($request->getMethod())
64
+ // && this.matchController($action->controller)
65
+ // && this.matchCustom($action)
66
+ // ) {
67
+ // return $this->allow ? true : false;
68
+ // }
69
+ return null;
70
+ });
71
+ }
72
+ /**
73
+ * @param action $action the action
74
+ * @return bool whether the rule applies to the action
75
+ */
76
+ matchAction(action) {
77
+ return Utils_1.Utils.isEmpty(this.actions) || this.actions.includes(action.id);
78
+ }
79
+ /**
80
+ * @param controller $controller the controller
81
+ * @return bool whether the rule applies to the controller
82
+ */
83
+ matchController(controller) {
84
+ // if (empty($this->controllers)) {
85
+ // return true;
86
+ // }
87
+ //
88
+ // $id = $controller->getUniqueId();
89
+ // foreach ($this->controllers as $pattern) {
90
+ // if (StringHelper::matchWildcard($pattern, $id)) {
91
+ // return true;
92
+ // }
93
+ // }
94
+ return false;
95
+ }
96
+ matchRole(user) {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ let items = Utils_1.Utils.isEmpty(this.roles) ? [] : this.roles;
99
+ if (!Utils_1.Utils.isEmpty(this.permissions)) {
100
+ items = Utils_1.Utils.merge(items, this.permissions);
101
+ }
102
+ if (Utils_1.Utils.isEmpty(items)) {
103
+ return true;
104
+ }
105
+ if (!user) {
106
+ throw new base_2.InvalidConfigException('The user application component must be available to specify roles in AccessRule.');
107
+ }
108
+ // @ts-ignore
109
+ let roleParams = [];
110
+ for (const itemsKey in items) {
111
+ let item = items[itemsKey];
112
+ if (item === '?') {
113
+ if (user.getIsGuest()) {
114
+ return true;
115
+ }
116
+ }
117
+ else if (item === '@') {
118
+ if (!user.getIsGuest()) {
119
+ return true;
120
+ }
121
+ }
122
+ else {
123
+ //role-params
124
+ if (!Utils_1.Utils.isEmpty(this.roleParams)) {
125
+ roleParams = !Utils_1.Utils.isArray(this.roleParams) ? this.roleParams.apply(this) : this.roleParams;
126
+ }
127
+ if (yield user.can(item, this.roleParams)) {
128
+ return true;
129
+ }
130
+ }
131
+ }
132
+ return false;
133
+ });
134
+ }
135
+ }
136
+ exports.AccessRule = AccessRule;
@@ -1,26 +1,26 @@
1
- import { Request, Response } from "express";
2
- export interface AuthInterface {
3
- /**
4
- * Authenticates the current user.
5
- * @param User $user
6
- * @param Request $request
7
- * @param Response $response
8
- * @return IdentityInterface the authenticated user identity. If authentication information is not provided, null will be returned.
9
- * @throws UnauthorizedHttpException if authentication information is provided but is invalid.
10
- */
11
- authenticate(user: any, request: Request, response: Response): any;
12
- /**
13
- * Generates challenges upon authentication failure.
14
- * For example, some appropriate HTTP headers may be generated.
15
- * @param Response $response
16
- */
17
- challenge(response: Response): Response;
18
- /**
19
- * Handles authentication failure.
20
- * The implementation should normally throw UnauthorizedHttpException to indicate authentication failure.
21
- * @param Response $response
22
- * @throws UnauthorizedHttpException
23
- */
24
- handleFailure(response: Response): Response;
25
- }
1
+ import { Request, Response } from "express";
2
+ export interface AuthInterface {
3
+ /**
4
+ * Authenticates the current user.
5
+ * @param User $user
6
+ * @param Request $request
7
+ * @param Response $response
8
+ * @return IdentityInterface the authenticated user identity. If authentication information is not provided, null will be returned.
9
+ * @throws UnauthorizedHttpException if authentication information is provided but is invalid.
10
+ */
11
+ authenticate(user: any, request: Request, response: Response): any;
12
+ /**
13
+ * Generates challenges upon authentication failure.
14
+ * For example, some appropriate HTTP headers may be generated.
15
+ * @param Response $response
16
+ */
17
+ challenge(response: Response): Response;
18
+ /**
19
+ * Handles authentication failure.
20
+ * The implementation should normally throw UnauthorizedHttpException to indicate authentication failure.
21
+ * @param Response $response
22
+ * @throws UnauthorizedHttpException
23
+ */
24
+ handleFailure(response: Response): Response;
25
+ }
26
26
  //# sourceMappingURL=AuthInterface.d.ts.map
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,38 +1,38 @@
1
- import { ActionFilter } from "../../base/ActionFilter";
2
- import { AuthInterface } from "./AuthInterface";
3
- import { WebUser } from "../../web/WebUser";
4
- import { Request, Response } from "express";
5
- export declare abstract class AuthMethod extends ActionFilter implements AuthInterface {
6
- /**
7
- * @var User the user object representing the user authentication status. If not set, the `user` application component will be used.
8
- */
9
- user: WebUser | undefined;
10
- /**
11
- * @var Request the current request. If not set, the `request` application component will be used.
12
- */
13
- request: Request | undefined;
14
- /**
15
- * @var Response the response to be sent. If not set, the `response` application component will be used.
16
- */
17
- response: Response | undefined;
18
- optional: never[];
19
- /**
20
- *
21
- * @param action
22
- * @param request
23
- * @param response
24
- */
25
- beforeAction(action: any, request: Request, response: Response): Promise<boolean>;
26
- /**
27
- *
28
- * @param user
29
- * @param request
30
- * @param response
31
- */
32
- authenticate(user: WebUser, request: Request, response: Response): void;
33
- challenge(response: Response): void;
34
- handleFailure(response: Response): void;
35
- getHeaderByKey(headers: any, findKey: any): any;
36
- patternCheck(headerText: any, pattern: RegExp): any;
37
- }
1
+ import { ActionFilter } from "../../base";
2
+ import { AuthInterface } from "./AuthInterface";
3
+ import { WebUser } from "../../web/WebUser";
4
+ import { Request, Response } from "express";
5
+ export declare abstract class AuthMethod extends ActionFilter implements AuthInterface {
6
+ /**
7
+ * @var user the user object representing the user authentication status. If not set, the `user` application component will be used.
8
+ */
9
+ user: WebUser | undefined;
10
+ /**
11
+ * @var Request the current request. If not set, the `request` application component will be used.
12
+ */
13
+ request: Request | undefined;
14
+ /**
15
+ * @var Response the response to be sent. If not set, the `response` application component will be used.
16
+ */
17
+ response: Response | undefined;
18
+ optional: never[];
19
+ /**
20
+ *
21
+ * @param action
22
+ * @param request
23
+ * @param response
24
+ */
25
+ beforeAction(action: any, request: Request, response: Response): Promise<boolean>;
26
+ /**
27
+ *
28
+ * @param user
29
+ * @param request
30
+ * @param response
31
+ */
32
+ authenticate(user: WebUser, request: Request, response: Response): void;
33
+ challenge(response: Response): Response;
34
+ handleFailure(response: Response): Response;
35
+ getHeaderByKey(headers: any, findKey: any): any;
36
+ patternCheck(headerText: any, pattern: RegExp): any;
37
+ }
38
38
  //# sourceMappingURL=AuthMethod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuthMethod.d.ts","sourceRoot":"","sources":["../../../src/filters/auth/AuthMethod.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAE1C,8BAAsB,UAAW,SAAQ,YAAa,YAAW,aAAa;IAE1E;;OAEG;IACI,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAEjC;;OAEG;IACI,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAEpC;;OAEG;IACI,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;IAG/B,QAAQ,UAAM;IAErB;;;;;OAKG;IACU,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ;IAoB3E;;;;;OAKG;IACH,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ;IAKhE,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAKnC,aAAa,CAAC,QAAQ,EAAE,QAAQ;IAIhC,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;IASzC,YAAY,CAAC,UAAU,EAAC,GAAG,EAAE,OAAO,EAAC,MAAM;CAY9C"}
1
+ {"version":3,"file":"AuthMethod.d.ts","sourceRoot":"","sources":["../../../src/filters/auth/AuthMethod.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAE1C,8BAAsB,UAAW,SAAQ,YAAa,YAAW,aAAa;IAE1E;;OAEG;IACI,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAEjC;;OAEG;IACI,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAEpC;;OAEG;IACI,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;IAG/B,QAAQ,UAAM;IAErB;;;;;OAKG;IACU,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ;IAmB3E;;;;;OAKG;IACH,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ;IAKhE,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ;IAKvC,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ;IAI3C,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;IASzC,YAAY,CAAC,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM;CAYhD"}
@@ -1,82 +1,82 @@
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
- return new (P || (P = Promise))(function (resolve, reject) {
11
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
- step((generator = generator.apply(thisArg, _arguments || [])).next());
15
- });
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.AuthMethod = void 0;
19
- const ActionFilter_1 = require("../../base/ActionFilter");
20
- const UnauthorizedHttpException_1 = require("../../base/UnauthorizedHttpException");
21
- const WebUser_1 = require("../../web/WebUser");
22
- class AuthMethod extends ActionFilter_1.ActionFilter {
23
- constructor() {
24
- super(...arguments);
25
- this.optional = [];
26
- }
27
- /**
28
- *
29
- * @param action
30
- * @param request
31
- * @param response
32
- */
33
- beforeAction(action, request, response) {
34
- var _a;
35
- return __awaiter(this, void 0, void 0, function* () {
36
- let identity = yield this.authenticate((_a = this.user) !== null && _a !== void 0 ? _a : new WebUser_1.WebUser(), request, response);
37
- // @ts-ignore
38
- request.identity = identity;
39
- if (identity !== null) {
40
- return true;
41
- }
42
- this.challenge(response);
43
- this.handleFailure(response);
44
- return false;
45
- });
46
- }
47
- /**
48
- *
49
- * @param user
50
- * @param request
51
- * @param response
52
- */
53
- authenticate(user, request, response) {
54
- }
55
- // @ts-ignore
56
- challenge(response) {
57
- }
58
- // @ts-ignore
59
- handleFailure(response) {
60
- throw new UnauthorizedHttpException_1.UnauthorizedHttpException('Your request was made with invalid credentials.');
61
- }
62
- getHeaderByKey(headers, findKey) {
63
- let key = Object.keys(headers).find(key => key.toLowerCase() === findKey.toLowerCase());
64
- if (key) {
65
- return headers[key];
66
- }
67
- return null;
68
- }
69
- patternCheck(headerText, pattern) {
70
- if (pattern) {
71
- let matches = headerText.match(pattern);
72
- if (matches && matches.length > 0) {
73
- return matches;
74
- }
75
- else {
76
- return null;
77
- }
78
- }
79
- return null;
80
- }
81
- }
82
- exports.AuthMethod = AuthMethod;
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.AuthMethod = void 0;
19
+ const base_1 = require("../../base");
20
+ const base_2 = require("../../base");
21
+ const WebUser_1 = require("../../web/WebUser");
22
+ class AuthMethod extends base_1.ActionFilter {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.optional = [];
26
+ }
27
+ /**
28
+ *
29
+ * @param action
30
+ * @param request
31
+ * @param response
32
+ */
33
+ beforeAction(action, request, response) {
34
+ var _a;
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ let identity = yield this.authenticate((_a = this.user) !== null && _a !== void 0 ? _a : new WebUser_1.WebUser(), request, response);
37
+ // @ts-ignore
38
+ request.identity = identity;
39
+ if (identity !== null) {
40
+ return true;
41
+ }
42
+ this.challenge(response);
43
+ this.handleFailure(response);
44
+ return false;
45
+ });
46
+ }
47
+ /**
48
+ *
49
+ * @param user
50
+ * @param request
51
+ * @param response
52
+ */
53
+ authenticate(user, request, response) {
54
+ }
55
+ // @ts-ignore
56
+ challenge(response) {
57
+ }
58
+ // @ts-ignore
59
+ handleFailure(response) {
60
+ throw new base_2.UnauthorizedHttpException('Your request was made with invalid credentials.');
61
+ }
62
+ getHeaderByKey(headers, findKey) {
63
+ let key = Object.keys(headers).find(key => key.toLowerCase() === findKey.toLowerCase());
64
+ if (key) {
65
+ return headers[key];
66
+ }
67
+ return null;
68
+ }
69
+ patternCheck(headerText, pattern) {
70
+ if (pattern) {
71
+ let matches = headerText.match(pattern);
72
+ if (matches && matches.length > 0) {
73
+ return matches;
74
+ }
75
+ else {
76
+ return null;
77
+ }
78
+ }
79
+ return null;
80
+ }
81
+ }
82
+ exports.AuthMethod = AuthMethod;
@@ -1,23 +1,24 @@
1
- import { Request, Response } from "express";
2
- import { WebUser } from "../../web/WebUser";
3
- import { AuthMethod } from "./AuthMethod";
4
- export declare class HttpBasicAuth extends AuthMethod {
5
- /**
6
- * @var string the HTTP header name
7
- */
8
- header: string;
9
- /**
10
- * @var string a pattern to use to extract the HTTP authentication value
11
- */
12
- pattern: RegExp;
13
- /**
14
- * @throws InvalidConfigException
15
- */
16
- init(): void;
17
- authenticate(user: WebUser, request: Request, response: Response): Promise<any>;
18
- /**
19
- * @throws UnauthorizedHttpException
20
- */
21
- fail(response: Response): void;
22
- }
1
+ import { Request, Response } from "express";
2
+ import { WebUser } from "../../web/WebUser";
3
+ import { AuthMethod } from "./AuthMethod";
4
+ export declare class HttpBasicAuth extends AuthMethod {
5
+ /**
6
+ * @var string the HTTP header name
7
+ */
8
+ header: string;
9
+ /**
10
+ * @var string a pattern to use to extract the HTTP authentication value
11
+ */
12
+ pattern: RegExp;
13
+ auth: any;
14
+ /**
15
+ * @throws InvalidConfigException
16
+ */
17
+ init(): void;
18
+ authenticate(user: WebUser, request: Request, response: Response): Promise<any>;
19
+ /**
20
+ * @throws UnauthorizedHttpException
21
+ */
22
+ fail(response: Response): void;
23
+ }
23
24
  //# sourceMappingURL=HttpBasicAuth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpBasicAuth.d.ts","sourceRoot":"","sources":["../../../src/filters/auth/HttpBasicAuth.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAIxC,qBAAa,aAAc,SAAQ,UAAU;IAEzC;;OAEG;IACI,MAAM,SAAmB;IAGhC;;OAEG;IAEI,OAAO,SAAqB;IAGnC;;OAEG;IACI,IAAI,IAAI,IAAI;IAWb,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,QAAQ;IAuBpE;;OAEG;IACI,IAAI,CAAC,QAAQ,EAAC,QAAQ,GAAG,IAAI;CAIvC"}
1
+ {"version":3,"file":"HttpBasicAuth.d.ts","sourceRoot":"","sources":["../../../src/filters/auth/HttpBasicAuth.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAIxC,qBAAa,aAAc,SAAQ,UAAU;IAEzC;;OAEG;IACI,MAAM,SAAmB;IAGhC;;OAEG;IAEI,OAAO,SAAqB;IAG5B,IAAI,EAAE,GAAG,CAAQ;IAExB;;OAEG;IACI,IAAI,IAAI,IAAI;IAWb,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ;IA2BtE;;OAEG;IACI,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAIxC"}