@minimaltech/node-infra 0.5.10-20 → 0.5.10-22

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 (193) hide show
  1. package/dist/components/authenticate/common/types.d.ts +33 -0
  2. package/dist/components/authenticate/common/types.d.ts.map +1 -1
  3. package/dist/components/authenticate/common/types.js +5 -0
  4. package/dist/components/authenticate/common/types.js.map +1 -1
  5. package/dist/components/authenticate/controllers/oauth2.controller.d.ts +41 -0
  6. package/dist/components/authenticate/controllers/oauth2.controller.d.ts.map +1 -1
  7. package/dist/components/authenticate/controllers/oauth2.controller.js +25 -3
  8. package/dist/components/authenticate/controllers/oauth2.controller.js.map +1 -1
  9. package/dist/components/authenticate/models/oauth2-scope.model.d.ts +6 -2
  10. package/dist/components/authenticate/models/oauth2-scope.model.d.ts.map +1 -1
  11. package/dist/components/authenticate/models/oauth2-scope.model.js +47 -0
  12. package/dist/components/authenticate/models/oauth2-scope.model.js.map +1 -1
  13. package/dist/components/authenticate/oauth2-handlers/authorization-code.handler.d.ts.map +1 -1
  14. package/dist/components/authenticate/oauth2-handlers/authorization-code.handler.js +20 -13
  15. package/dist/components/authenticate/oauth2-handlers/authorization-code.handler.js.map +1 -1
  16. package/dist/components/authenticate/oauth2-handlers/base.d.ts +22 -5
  17. package/dist/components/authenticate/oauth2-handlers/base.d.ts.map +1 -1
  18. package/dist/components/authenticate/oauth2-handlers/base.js +103 -28
  19. package/dist/components/authenticate/oauth2-handlers/base.js.map +1 -1
  20. package/dist/components/authenticate/oauth2-handlers/config/index.d.ts +2 -0
  21. package/dist/components/authenticate/oauth2-handlers/config/index.d.ts.map +1 -0
  22. package/dist/components/authenticate/oauth2-handlers/config/index.js +18 -0
  23. package/dist/components/authenticate/oauth2-handlers/config/index.js.map +1 -0
  24. package/dist/components/authenticate/oauth2-handlers/config/scope-config-validator.d.ts +46 -0
  25. package/dist/components/authenticate/oauth2-handlers/config/scope-config-validator.d.ts.map +1 -0
  26. package/dist/components/authenticate/oauth2-handlers/config/scope-config-validator.js +199 -0
  27. package/dist/components/authenticate/oauth2-handlers/config/scope-config-validator.js.map +1 -0
  28. package/dist/components/authenticate/oauth2-handlers/constants/index.d.ts +2 -0
  29. package/dist/components/authenticate/oauth2-handlers/constants/index.d.ts.map +1 -0
  30. package/dist/components/authenticate/oauth2-handlers/constants/index.js +18 -0
  31. package/dist/components/authenticate/oauth2-handlers/constants/index.js.map +1 -0
  32. package/dist/components/authenticate/oauth2-handlers/constants/scope-constants.d.ts +79 -0
  33. package/dist/components/authenticate/oauth2-handlers/constants/scope-constants.d.ts.map +1 -0
  34. package/dist/components/authenticate/oauth2-handlers/constants/scope-constants.js +117 -0
  35. package/dist/components/authenticate/oauth2-handlers/constants/scope-constants.js.map +1 -0
  36. package/dist/components/authenticate/oauth2-handlers/data/index.d.ts +2 -0
  37. package/dist/components/authenticate/oauth2-handlers/data/index.d.ts.map +1 -0
  38. package/dist/components/authenticate/oauth2-handlers/data/index.js +18 -0
  39. package/dist/components/authenticate/oauth2-handlers/data/index.js.map +1 -0
  40. package/dist/components/authenticate/oauth2-handlers/data/user-data-fetcher.d.ts +99 -0
  41. package/dist/components/authenticate/oauth2-handlers/data/user-data-fetcher.d.ts.map +1 -0
  42. package/dist/components/authenticate/oauth2-handlers/data/user-data-fetcher.js +371 -0
  43. package/dist/components/authenticate/oauth2-handlers/data/user-data-fetcher.js.map +1 -0
  44. package/dist/components/authenticate/oauth2-handlers/index.d.ts +4 -0
  45. package/dist/components/authenticate/oauth2-handlers/index.d.ts.map +1 -1
  46. package/dist/components/authenticate/oauth2-handlers/index.js +4 -0
  47. package/dist/components/authenticate/oauth2-handlers/index.js.map +1 -1
  48. package/dist/components/authenticate/oauth2-handlers/scope/index.d.ts +4 -0
  49. package/dist/components/authenticate/oauth2-handlers/scope/index.d.ts.map +1 -0
  50. package/dist/components/authenticate/oauth2-handlers/scope/index.js +20 -0
  51. package/dist/components/authenticate/oauth2-handlers/scope/index.js.map +1 -0
  52. package/dist/components/authenticate/oauth2-handlers/scope/scope-manager.d.ts +64 -0
  53. package/dist/components/authenticate/oauth2-handlers/scope/scope-manager.d.ts.map +1 -0
  54. package/dist/components/authenticate/oauth2-handlers/scope/scope-manager.js +100 -0
  55. package/dist/components/authenticate/oauth2-handlers/scope/scope-manager.js.map +1 -0
  56. package/dist/components/authenticate/oauth2-handlers/scope/scope-parser.d.ts +49 -0
  57. package/dist/components/authenticate/oauth2-handlers/scope/scope-parser.d.ts.map +1 -0
  58. package/dist/components/authenticate/oauth2-handlers/scope/scope-parser.js +89 -0
  59. package/dist/components/authenticate/oauth2-handlers/scope/scope-parser.js.map +1 -0
  60. package/dist/components/authenticate/oauth2-handlers/scope/scope-validator.d.ts +58 -0
  61. package/dist/components/authenticate/oauth2-handlers/scope/scope-validator.d.ts.map +1 -0
  62. package/dist/components/authenticate/oauth2-handlers/scope/scope-validator.js +165 -0
  63. package/dist/components/authenticate/oauth2-handlers/scope/scope-validator.js.map +1 -0
  64. package/dist/components/authenticate/services/index.d.ts +1 -0
  65. package/dist/components/authenticate/services/index.d.ts.map +1 -1
  66. package/dist/components/authenticate/services/index.js +1 -0
  67. package/dist/components/authenticate/services/index.js.map +1 -1
  68. package/dist/components/authenticate/services/oauth2-scope.service.d.ts +22 -0
  69. package/dist/components/authenticate/services/oauth2-scope.service.d.ts.map +1 -0
  70. package/dist/components/authenticate/services/oauth2-scope.service.js +63 -0
  71. package/dist/components/authenticate/services/oauth2-scope.service.js.map +1 -0
  72. package/dist/components/authenticate/services/oauth2.service.d.ts +2 -0
  73. package/dist/components/authenticate/services/oauth2.service.d.ts.map +1 -1
  74. package/dist/components/authenticate/services/oauth2.service.js +8 -3
  75. package/dist/components/authenticate/services/oauth2.service.js.map +1 -1
  76. package/dist/components/authenticate/views/pages/auth.ejs +6 -2
  77. package/dist/components/index.d.ts +1 -0
  78. package/dist/components/index.d.ts.map +1 -1
  79. package/dist/components/index.js +1 -0
  80. package/dist/components/index.js.map +1 -1
  81. package/dist/components/mail/common/constants.d.ts +26 -0
  82. package/dist/components/mail/common/constants.d.ts.map +1 -0
  83. package/dist/components/mail/common/constants.js +37 -0
  84. package/dist/components/mail/common/constants.js.map +1 -0
  85. package/dist/components/mail/common/index.d.ts +4 -0
  86. package/dist/components/mail/common/index.d.ts.map +1 -0
  87. package/dist/components/mail/common/index.js +20 -0
  88. package/dist/components/mail/common/index.js.map +1 -0
  89. package/dist/components/mail/common/keys.d.ts +17 -0
  90. package/dist/components/mail/common/keys.d.ts.map +1 -0
  91. package/dist/components/mail/common/keys.js +24 -0
  92. package/dist/components/mail/common/keys.js.map +1 -0
  93. package/dist/components/mail/common/types.d.ts +168 -0
  94. package/dist/components/mail/common/types.d.ts.map +1 -0
  95. package/dist/components/mail/common/types.js +10 -0
  96. package/dist/components/mail/common/types.js.map +1 -0
  97. package/dist/components/mail/component.d.ts +12 -0
  98. package/dist/components/mail/component.d.ts.map +1 -0
  99. package/dist/components/mail/component.js +90 -0
  100. package/dist/components/mail/component.js.map +1 -0
  101. package/dist/components/mail/controllers/index.d.ts +2 -0
  102. package/dist/components/mail/controllers/index.d.ts.map +1 -0
  103. package/dist/components/mail/controllers/index.js +18 -0
  104. package/dist/components/mail/controllers/index.js.map +1 -0
  105. package/dist/components/mail/controllers/mail.controller.d.ts +24 -0
  106. package/dist/components/mail/controllers/mail.controller.d.ts.map +1 -0
  107. package/dist/components/mail/controllers/mail.controller.js +330 -0
  108. package/dist/components/mail/controllers/mail.controller.js.map +1 -0
  109. package/dist/components/mail/helpers/executors/bullmq-executor.helper.d.ts +48 -0
  110. package/dist/components/mail/helpers/executors/bullmq-executor.helper.d.ts.map +1 -0
  111. package/dist/components/mail/helpers/executors/bullmq-executor.helper.js +159 -0
  112. package/dist/components/mail/helpers/executors/bullmq-executor.helper.js.map +1 -0
  113. package/dist/components/mail/helpers/executors/direct-executor.helper.d.ts +14 -0
  114. package/dist/components/mail/helpers/executors/direct-executor.helper.d.ts.map +1 -0
  115. package/dist/components/mail/helpers/executors/direct-executor.helper.js +27 -0
  116. package/dist/components/mail/helpers/executors/direct-executor.helper.js.map +1 -0
  117. package/dist/components/mail/helpers/executors/index.d.ts +4 -0
  118. package/dist/components/mail/helpers/executors/index.d.ts.map +1 -0
  119. package/dist/components/mail/helpers/executors/index.js +20 -0
  120. package/dist/components/mail/helpers/executors/index.js.map +1 -0
  121. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.d.ts +22 -0
  122. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.d.ts.map +1 -0
  123. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.js +103 -0
  124. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -0
  125. package/dist/components/mail/helpers/index.d.ts +3 -0
  126. package/dist/components/mail/helpers/index.d.ts.map +1 -0
  127. package/dist/components/mail/helpers/index.js +19 -0
  128. package/dist/components/mail/helpers/index.js.map +1 -0
  129. package/dist/components/mail/helpers/transports/index.d.ts +3 -0
  130. package/dist/components/mail/helpers/transports/index.d.ts.map +1 -0
  131. package/dist/components/mail/helpers/transports/index.js +19 -0
  132. package/dist/components/mail/helpers/transports/index.js.map +1 -0
  133. package/dist/components/mail/helpers/transports/mailgun-transport.helper.d.ts +11 -0
  134. package/dist/components/mail/helpers/transports/mailgun-transport.helper.d.ts.map +1 -0
  135. package/dist/components/mail/helpers/transports/mailgun-transport.helper.js +88 -0
  136. package/dist/components/mail/helpers/transports/mailgun-transport.helper.js.map +1 -0
  137. package/dist/components/mail/helpers/transports/nodemailer-transport.helper.d.ts +11 -0
  138. package/dist/components/mail/helpers/transports/nodemailer-transport.helper.d.ts.map +1 -0
  139. package/dist/components/mail/helpers/transports/nodemailer-transport.helper.js +67 -0
  140. package/dist/components/mail/helpers/transports/nodemailer-transport.helper.js.map +1 -0
  141. package/dist/components/mail/index.d.ts +8 -0
  142. package/dist/components/mail/index.d.ts.map +1 -0
  143. package/dist/components/mail/index.js +24 -0
  144. package/dist/components/mail/index.js.map +1 -0
  145. package/dist/components/mail/providers/index.d.ts +3 -0
  146. package/dist/components/mail/providers/index.d.ts.map +1 -0
  147. package/dist/components/mail/providers/index.js +19 -0
  148. package/dist/components/mail/providers/index.js.map +1 -0
  149. package/dist/components/mail/providers/mail-queue-executor.provider.d.ts +9 -0
  150. package/dist/components/mail/providers/mail-queue-executor.provider.d.ts.map +1 -0
  151. package/dist/components/mail/providers/mail-queue-executor.provider.js +41 -0
  152. package/dist/components/mail/providers/mail-queue-executor.provider.js.map +1 -0
  153. package/dist/components/mail/providers/mail-transport.provider.d.ts +15 -0
  154. package/dist/components/mail/providers/mail-transport.provider.d.ts.map +1 -0
  155. package/dist/components/mail/providers/mail-transport.provider.js +93 -0
  156. package/dist/components/mail/providers/mail-transport.provider.js.map +1 -0
  157. package/dist/components/mail/services/generator.service.d.ts +14 -0
  158. package/dist/components/mail/services/generator.service.d.ts.map +1 -0
  159. package/dist/components/mail/services/generator.service.js +70 -0
  160. package/dist/components/mail/services/generator.service.js.map +1 -0
  161. package/dist/components/mail/services/index.d.ts +4 -0
  162. package/dist/components/mail/services/index.d.ts.map +1 -0
  163. package/dist/components/mail/services/index.js +20 -0
  164. package/dist/components/mail/services/index.js.map +1 -0
  165. package/dist/components/mail/services/mail.service.d.ts +23 -0
  166. package/dist/components/mail/services/mail.service.d.ts.map +1 -0
  167. package/dist/components/mail/services/mail.service.js +178 -0
  168. package/dist/components/mail/services/mail.service.js.map +1 -0
  169. package/dist/components/mail/services/template-engine.service.d.ts +36 -0
  170. package/dist/components/mail/services/template-engine.service.d.ts.map +1 -0
  171. package/dist/components/mail/services/template-engine.service.js +126 -0
  172. package/dist/components/mail/services/template-engine.service.js.map +1 -0
  173. package/dist/components/mail/utilities/index.d.ts +3 -0
  174. package/dist/components/mail/utilities/index.d.ts.map +1 -0
  175. package/dist/components/mail/utilities/index.js +19 -0
  176. package/dist/components/mail/utilities/index.js.map +1 -0
  177. package/dist/components/mail/utilities/type.utility.d.ts +5 -0
  178. package/dist/components/mail/utilities/type.utility.d.ts.map +1 -0
  179. package/dist/components/mail/utilities/type.utility.js +34 -0
  180. package/dist/components/mail/utilities/type.utility.js.map +1 -0
  181. package/dist/components/mail/utilities/verification.utility.d.ts +3 -0
  182. package/dist/components/mail/utilities/verification.utility.d.ts.map +1 -0
  183. package/dist/components/mail/utilities/verification.utility.js +11 -0
  184. package/dist/components/mail/utilities/verification.utility.js.map +1 -0
  185. package/dist/utilities/index.d.ts +1 -0
  186. package/dist/utilities/index.d.ts.map +1 -1
  187. package/dist/utilities/index.js +1 -0
  188. package/dist/utilities/index.js.map +1 -1
  189. package/dist/utilities/module.utility.d.ts +5 -0
  190. package/dist/utilities/module.utility.d.ts.map +1 -0
  191. package/dist/utilities/module.utility.js +21 -0
  192. package/dist/utilities/module.utility.js.map +1 -0
  193. package/package.json +14 -1
@@ -19,4 +19,8 @@ __exportStar(require("./oauth2"), exports);
19
19
  __exportStar(require("./authorization-code.handler"), exports);
20
20
  __exportStar(require("./client-credential.handler"), exports);
21
21
  __exportStar(require("./password.handler"), exports);
22
+ __exportStar(require("./config"), exports);
23
+ __exportStar(require("./constants"), exports);
24
+ __exportStar(require("./data"), exports);
25
+ __exportStar(require("./scope"), exports);
22
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/authenticate/oauth2-handlers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AAEzB,+DAA6C;AAC7C,8DAA4C;AAC5C,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/authenticate/oauth2-handlers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AAEzB,+DAA6C;AAC7C,8DAA4C;AAC5C,qDAAmC;AAEnC,2CAAyB;AACzB,8CAA4B;AAC5B,yCAAuB;AACvB,0CAAwB"}
@@ -0,0 +1,4 @@
1
+ export * from './scope-parser';
2
+ export * from './scope-validator';
3
+ export * from './scope-manager';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/authenticate/oauth2-handlers/scope/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./scope-parser"), exports);
18
+ __exportStar(require("./scope-validator"), exports);
19
+ __exportStar(require("./scope-manager"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/authenticate/oauth2-handlers/scope/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,oDAAkC;AAClC,kDAAgC"}
@@ -0,0 +1,64 @@
1
+ import { IScopeDefinition, IScopeValidationResult } from '../../common';
2
+ import { ScopeParser } from './scope-parser';
3
+ import { ScopeValidator } from './scope-validator';
4
+ /**
5
+ * ScopeManager orchestrates scope parsing and validation
6
+ * This is the main entry point for scope-related operations
7
+ */
8
+ export declare class ScopeManager {
9
+ private logger;
10
+ private parser;
11
+ private validator;
12
+ constructor(opts: {
13
+ availableScopes: IScopeDefinition[];
14
+ defaultScopes: string[];
15
+ scope?: string;
16
+ });
17
+ /**
18
+ * Normalize scope input to array format
19
+ * @param scopes - String, array, or undefined
20
+ * @returns Array of scope strings
21
+ */
22
+ normalizeScopes(scopes?: string | string[]): string[];
23
+ /**
24
+ * Validate scopes with normalization
25
+ * @param scopes - Scopes in any format
26
+ * @returns Validation result
27
+ */
28
+ validateScopes(scopes?: string | string[]): Promise<IScopeValidationResult>;
29
+ /**
30
+ * Parse scopes
31
+ * @param scopes - Scopes in any format
32
+ * @returns Array of parsed scopes
33
+ */
34
+ parseScopes(scopes?: string | string[]): import("../../common").IParsedScope[];
35
+ /**
36
+ * Check if a field is allowed
37
+ * Returns actual field names (handles aliases)
38
+ * @param relation - Relation name or '_base'
39
+ * @param field - Field name (can be an alias)
40
+ * @returns Array of resolved field names
41
+ */
42
+ isFieldAllowed(relation: string, field: string): string[];
43
+ /**
44
+ * Get default scopes
45
+ * @returns Array of default scope strings
46
+ */
47
+ getDefaultScopes(): string[];
48
+ /**
49
+ * Get available scope definitions
50
+ * @returns Array of scope definitions
51
+ */
52
+ getAvailableScopes(): IScopeDefinition[];
53
+ /**
54
+ * Get parser instance
55
+ * @returns ScopeParser instance
56
+ */
57
+ getParser(): ScopeParser;
58
+ /**
59
+ * Get validator instance
60
+ * @returns ScopeValidator instance
61
+ */
62
+ getValidator(): ScopeValidator;
63
+ }
64
+ //# sourceMappingURL=scope-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-manager.d.ts","sourceRoot":"","sources":["../../../../../src/components/authenticate/oauth2-handlers/scope/scope-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAA0B,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE3E;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,SAAS,CAAiB;gBAEtB,IAAI,EAAE;QAChB,eAAe,EAAE,gBAAgB,EAAE,CAAC;QACpC,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB;IAsBD;;;;OAIG;IACH,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE;IAgBrD;;;;OAIG;IACG,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAKjF;;;;OAIG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAKtC;;;;;;OAMG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAIzD;;;OAGG;IACH,gBAAgB,IAAI,MAAM,EAAE;IAI5B;;;OAGG;IACH,kBAAkB,IAAI,gBAAgB,EAAE;IAIxC;;;OAGG;IACH,SAAS,IAAI,WAAW;IAIxB;;;OAGG;IACH,YAAY,IAAI,cAAc;CAG/B"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScopeManager = void 0;
4
+ const helpers_1 = require("../../../../helpers");
5
+ const scope_parser_1 = require("./scope-parser");
6
+ const scope_validator_1 = require("./scope-validator");
7
+ /**
8
+ * ScopeManager orchestrates scope parsing and validation
9
+ * This is the main entry point for scope-related operations
10
+ */
11
+ class ScopeManager {
12
+ constructor(opts) {
13
+ const { availableScopes, defaultScopes, scope } = opts;
14
+ this.logger = helpers_1.LoggerFactory.getLogger([scope ?? ScopeManager.name]);
15
+ this.parser = new scope_parser_1.ScopeParser({ scope });
16
+ const validatorOptions = {
17
+ availableScopes,
18
+ defaultScopes,
19
+ supportedResources: ['user'],
20
+ supportedActions: ['read'],
21
+ };
22
+ this.validator = new scope_validator_1.ScopeValidator({ options: validatorOptions, scope });
23
+ this.logger.info('[constructor] Initialized | Available scopes: %d | Default scopes: %s', availableScopes.length, defaultScopes.join(', '));
24
+ }
25
+ /**
26
+ * Normalize scope input to array format
27
+ * @param scopes - String, array, or undefined
28
+ * @returns Array of scope strings
29
+ */
30
+ normalizeScopes(scopes) {
31
+ if (!scopes) {
32
+ return [];
33
+ }
34
+ if (Array.isArray(scopes)) {
35
+ return scopes.filter(Boolean);
36
+ }
37
+ if (typeof scopes === 'string') {
38
+ return scopes.split(' ').filter(Boolean);
39
+ }
40
+ return [];
41
+ }
42
+ /**
43
+ * Validate scopes with normalization
44
+ * @param scopes - Scopes in any format
45
+ * @returns Validation result
46
+ */
47
+ async validateScopes(scopes) {
48
+ const normalized = this.normalizeScopes(scopes);
49
+ return this.validator.validate(normalized);
50
+ }
51
+ /**
52
+ * Parse scopes
53
+ * @param scopes - Scopes in any format
54
+ * @returns Array of parsed scopes
55
+ */
56
+ parseScopes(scopes) {
57
+ const normalized = this.normalizeScopes(scopes);
58
+ return this.parser.parseMultiple(normalized);
59
+ }
60
+ /**
61
+ * Check if a field is allowed
62
+ * Returns actual field names (handles aliases)
63
+ * @param relation - Relation name or '_base'
64
+ * @param field - Field name (can be an alias)
65
+ * @returns Array of resolved field names
66
+ */
67
+ isFieldAllowed(relation, field) {
68
+ return this.validator.isFieldAllowed(relation, field);
69
+ }
70
+ /**
71
+ * Get default scopes
72
+ * @returns Array of default scope strings
73
+ */
74
+ getDefaultScopes() {
75
+ return this.validator.getDefaultScopes();
76
+ }
77
+ /**
78
+ * Get available scope definitions
79
+ * @returns Array of scope definitions
80
+ */
81
+ getAvailableScopes() {
82
+ return this.validator.getAvailableScopes();
83
+ }
84
+ /**
85
+ * Get parser instance
86
+ * @returns ScopeParser instance
87
+ */
88
+ getParser() {
89
+ return this.parser;
90
+ }
91
+ /**
92
+ * Get validator instance
93
+ * @returns ScopeValidator instance
94
+ */
95
+ getValidator() {
96
+ return this.validator;
97
+ }
98
+ }
99
+ exports.ScopeManager = ScopeManager;
100
+ //# sourceMappingURL=scope-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-manager.js","sourceRoot":"","sources":["../../../../../src/components/authenticate/oauth2-handlers/scope/scope-manager.ts"],"names":[],"mappings":";;;AAAA,uCAA6D;AAE7D,iDAA6C;AAC7C,uDAA2E;AAE3E;;;GAGG;AACH,MAAa,YAAY;IAKvB,YAAY,IAIX;QACC,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAEvD,IAAI,CAAC,MAAM,GAAG,uBAAa,CAAC,SAAS,CAAC,CAAC,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QACpE,IAAI,CAAC,MAAM,GAAG,IAAI,0BAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAEzC,MAAM,gBAAgB,GAA2B;YAC/C,eAAe;YACf,aAAa;YACb,kBAAkB,EAAE,CAAC,MAAM,CAAC;YAC5B,gBAAgB,EAAE,CAAC,MAAM,CAAC;SAC3B,CAAC;QAEF,IAAI,CAAC,SAAS,GAAG,IAAI,gCAAc,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC;QAE1E,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,uEAAuE,EACvE,eAAe,CAAC,MAAM,EACtB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CACzB,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,MAA0B;QACxC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,C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 *
5
+ * Scope Format: resource:action:path[:subpath...]
6
+ * Examples:
7
+ * - "user:read:basic" -> { resource: 'user', action: 'read', path: ['basic'] }
8
+ * - "user:read:profile:firstName" -> { resource: 'user', action: 'read', path: ['profile', 'firstName'] }
9
+ * - "user:read:id" -> { resource: 'user', action: 'read', path: ['id'] }
10
+ */
11
+ export declare class ScopeParser {
12
+ private logger;
13
+ private readonly MINIMUM_PARTS;
14
+ private readonly SEPARATOR;
15
+ constructor(opts: {
16
+ scope?: string;
17
+ });
18
+ /**
19
+ * Parse a single scope string into structured format
20
+ * @param scopeString - The scope string to parse (e.g., "user:read:basic")
21
+ * @returns Parsed scope object or null if invalid
22
+ */
23
+ parse(scopeString: string): IParsedScope | null;
24
+ /**
25
+ * Parse multiple scope strings
26
+ * @param scopeStrings - Array of scope strings or space-separated string
27
+ * @returns Array of parsed scopes (invalid scopes are filtered out)
28
+ */
29
+ parseMultiple(scopeStrings: string[] | string): IParsedScope[];
30
+ /**
31
+ * Check if a scope string is valid without fully parsing
32
+ * @param scopeString - The scope string to validate
33
+ * @returns true if the scope format is valid
34
+ */
35
+ isValidFormat(scopeString: string): boolean;
36
+ /**
37
+ * Extract resource from scope string without full parsing
38
+ * @param scopeString - The scope string
39
+ * @returns Resource name or null
40
+ */
41
+ extractResource(scopeString: string): string | null;
42
+ /**
43
+ * Extract action from scope string without full parsing
44
+ * @param scopeString - The scope string
45
+ * @returns Action name or null
46
+ */
47
+ extractAction(scopeString: string): string | null;
48
+ }
49
+ //# sourceMappingURL=scope-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-parser.d.ts","sourceRoot":"","sources":["../../../../../src/components/authenticate/oauth2-handlers/scope/scope-parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;;GAQG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAK;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAO;gBAErB,IAAI,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAMpC;;;;OAIG;IACH,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IA+B/C;;;;OAIG;IACH,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,YAAY,EAAE;IAU9D;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAI3C;;;;OAIG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAKnD;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAIlD"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScopeParser = void 0;
4
+ const helpers_1 = require("../../../../helpers");
5
+ /**
6
+ * ScopeParser handles parsing of hierarchical OAuth2 scopes
7
+ *
8
+ * Scope Format: resource:action:path[:subpath...]
9
+ * Examples:
10
+ * - "user:read:basic" -> { resource: 'user', action: 'read', path: ['basic'] }
11
+ * - "user:read:profile:firstName" -> { resource: 'user', action: 'read', path: ['profile', 'firstName'] }
12
+ * - "user:read:id" -> { resource: 'user', action: 'read', path: ['id'] }
13
+ */
14
+ class ScopeParser {
15
+ constructor(opts) {
16
+ this.MINIMUM_PARTS = 3;
17
+ this.SEPARATOR = ':';
18
+ const { scope } = opts;
19
+ this.logger = helpers_1.LoggerFactory.getLogger([scope ?? ScopeParser.name]);
20
+ }
21
+ /**
22
+ * Parse a single scope string into structured format
23
+ * @param scopeString - The scope string to parse (e.g., "user:read:basic")
24
+ * @returns Parsed scope object or null if invalid
25
+ */
26
+ parse(scopeString) {
27
+ if (!scopeString || typeof scopeString !== 'string') {
28
+ this.logger.warn('[parse] Invalid scope string: %s', scopeString);
29
+ return null;
30
+ }
31
+ const parts = scopeString.trim().split(this.SEPARATOR);
32
+ if (parts.length < this.MINIMUM_PARTS) {
33
+ this.logger.warn('[parse] Invalid scope format: %s (expected resource:action:path)', scopeString);
34
+ return null;
35
+ }
36
+ const [resource, action, ...path] = parts;
37
+ if (!resource || !action || path.length === 0) {
38
+ this.logger.warn('[parse] Scope has empty parts: %s', scopeString);
39
+ return null;
40
+ }
41
+ return {
42
+ original: scopeString,
43
+ resource: resource.toLowerCase(),
44
+ action: action.toLowerCase(),
45
+ path: path.map(p => p.trim()).filter(Boolean),
46
+ };
47
+ }
48
+ /**
49
+ * Parse multiple scope strings
50
+ * @param scopeStrings - Array of scope strings or space-separated string
51
+ * @returns Array of parsed scopes (invalid scopes are filtered out)
52
+ */
53
+ parseMultiple(scopeStrings) {
54
+ const scopes = Array.isArray(scopeStrings)
55
+ ? scopeStrings
56
+ : scopeStrings.split(' ').filter(Boolean);
57
+ return scopes
58
+ .map(scope => this.parse(scope))
59
+ .filter((parsed) => parsed !== null);
60
+ }
61
+ /**
62
+ * Check if a scope string is valid without fully parsing
63
+ * @param scopeString - The scope string to validate
64
+ * @returns true if the scope format is valid
65
+ */
66
+ isValidFormat(scopeString) {
67
+ return this.parse(scopeString) !== null;
68
+ }
69
+ /**
70
+ * Extract resource from scope string without full parsing
71
+ * @param scopeString - The scope string
72
+ * @returns Resource name or null
73
+ */
74
+ extractResource(scopeString) {
75
+ const parts = scopeString.split(this.SEPARATOR);
76
+ return parts.length >= this.MINIMUM_PARTS ? parts[0].toLowerCase() : null;
77
+ }
78
+ /**
79
+ * Extract action from scope string without full parsing
80
+ * @param scopeString - The scope string
81
+ * @returns Action name or null
82
+ */
83
+ extractAction(scopeString) {
84
+ const parts = scopeString.split(this.SEPARATOR);
85
+ return parts.length >= this.MINIMUM_PARTS ? parts[1].toLowerCase() : null;
86
+ }
87
+ }
88
+ exports.ScopeParser = ScopeParser;
89
+ //# sourceMappingURL=scope-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-parser.js","sourceRoot":"","sources":["../../../../../src/components/authenticate/oauth2-handlers/scope/scope-parser.ts"],"names":[],"mappings":";;;AAAA,uCAA6D;AAG7D;;;;;;;;GAQG;AACH,MAAa,WAAW;IAKtB,YAAY,IAAwB;QAHnB,kBAAa,GAAG,CAAC,CAAC;QAClB,cAAS,GAAG,GAAG,CAAC;QAG/B,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAEvB,IAAI,CAAC,MAAM,GAAG,uBAAa,CAAC,SAAS,CAAC,CAAC,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAmB;QACvB,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,WAAW,CAAC,CAAC;YAClE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEvD,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,kEAAkE,EAClE,WAAW,CACZ,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;QAE1C,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE,WAAW,CAAC,CAAC;YACnE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO;YACL,QAAQ,EAAE,WAAW;YACrB,QAAQ,EAAE,QAAQ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AC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5E,CAAC;CACF;AA1FD,kCA0FC"}
@@ -0,0 +1,58 @@
1
+ import { IScopeDefinition, IScopeValidationResult } from '../../common';
2
+ export declare const BASE_FIELDS_SCOPE = "_base";
3
+ export interface IScopeValidatorOptions {
4
+ availableScopes: IScopeDefinition[];
5
+ defaultScopes: string[];
6
+ supportedResources?: string[];
7
+ supportedActions?: string[];
8
+ }
9
+ /**
10
+ * ScopeValidator validates OAuth2 scopes against configuration
11
+ * Ensures that requested scopes are allowed and properly formatted
12
+ */
13
+ export declare class ScopeValidator {
14
+ private logger;
15
+ private parser;
16
+ private options;
17
+ constructor(opts: {
18
+ options: IScopeValidatorOptions;
19
+ scope?: string;
20
+ });
21
+ /**
22
+ * Validate requested scopes against available scopes configuration
23
+ * @param requestedScopes - Array of scope strings requested by client
24
+ * @returns Validation result with granted and invalid scopes
25
+ */
26
+ validate(requestedScopes: string[]): Promise<IScopeValidationResult>;
27
+ /**
28
+ * Validate a single parsed scope
29
+ * @param parsed - Parsed scope object
30
+ * @returns Error message if invalid, null if valid
31
+ */
32
+ private validateParsedScope;
33
+ /**
34
+ * Check if a scope path is valid based on configuration
35
+ * @param path - Scope path (e.g., ['basic'], ['profile', 'firstName'])
36
+ * @returns true if valid, false otherwise
37
+ */
38
+ private isPathValid;
39
+ /**
40
+ * Check if a specific field is allowed in a relation
41
+ * Supports field aliases mapping (e.g., 'name' -> ['firstName', 'lastName'])
42
+ * @param relation - Relation name or '_base' for base fields
43
+ * @param field - Field name (can be an alias)
44
+ * @returns Array of actual fields allowed, or empty array if not allowed
45
+ */
46
+ isFieldAllowed(relation: string, field: string): string[];
47
+ /**
48
+ * Get default scopes
49
+ * @returns Array of default scope strings
50
+ */
51
+ getDefaultScopes(): string[];
52
+ /**
53
+ * Get available scope definitions
54
+ * @returns Array of scope definitions
55
+ */
56
+ getAvailableScopes(): IScopeDefinition[];
57
+ }
58
+ //# sourceMappingURL=scope-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-validator.d.ts","sourceRoot":"","sources":["../../../../../src/components/authenticate/oauth2-handlers/scope/scope-validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAKtF,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAEzC,MAAM,WAAW,sBAAsB;IACrC,eAAe,EAAE,gBAAgB,EAAE,CAAC;IACpC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,OAAO,CAAyB;gBAE5B,IAAI,EAAE;QAAE,OAAO,EAAE,sBAAsB,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAWrE;;;;OAIG;IACG,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA2D1E;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAmB3B;;;;OAIG;IACH,OAAO,CAAC,WAAW;IA4BnB;;;;;;OAMG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAgCzD;;;OAGG;IACH,gBAAgB,IAAI,MAAM,EAAE;IAI5B;;;OAGG;IACH,kBAAkB,IAAI,gBAAgB,EAAE;CAGzC"}
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScopeValidator = exports.BASE_FIELDS_SCOPE = void 0;
4
+ const helpers_1 = require("../../../../helpers");
5
+ const scope_parser_1 = require("./scope-parser");
6
+ const constants_1 = require("../constants");
7
+ // Constant for base fields scope identifier
8
+ exports.BASE_FIELDS_SCOPE = '_base';
9
+ /**
10
+ * ScopeValidator validates OAuth2 scopes against configuration
11
+ * Ensures that requested scopes are allowed and properly formatted
12
+ */
13
+ class ScopeValidator {
14
+ constructor(opts) {
15
+ const { options, scope } = opts;
16
+ this.logger = helpers_1.LoggerFactory.getLogger([scope ?? ScopeValidator.name]);
17
+ this.parser = new scope_parser_1.ScopeParser({ scope });
18
+ this.options = {
19
+ supportedResources: [constants_1.OAuth2Resources.USER],
20
+ supportedActions: [constants_1.OAuth2Actions.READ],
21
+ ...options,
22
+ };
23
+ }
24
+ /**
25
+ * Validate requested scopes against available scopes configuration
26
+ * @param requestedScopes - Array of scope strings requested by client
27
+ * @returns Validation result with granted and invalid scopes
28
+ */
29
+ async validate(requestedScopes) {
30
+ // If no scopes requested, use default scopes
31
+ if (!requestedScopes || requestedScopes.length === 0) {
32
+ this.logger.debug('[validate] No scopes requested, using defaults');
33
+ return {
34
+ valid: true,
35
+ grantedScopes: this.options.defaultScopes,
36
+ };
37
+ }
38
+ // If no available scopes configured, grant all (backward compatibility mode)
39
+ if (this.options.availableScopes.length === 0) {
40
+ this.logger.warn('[validate] No available scopes configured, granting all requested scopes (backward compatibility)');
41
+ return {
42
+ valid: true,
43
+ grantedScopes: requestedScopes,
44
+ };
45
+ }
46
+ const grantedScopes = [];
47
+ const invalidScopes = [];
48
+ for (const scopeString of requestedScopes) {
49
+ const parsed = this.parser.parse(scopeString);
50
+ if (!parsed) {
51
+ invalidScopes.push(scopeString);
52
+ continue;
53
+ }
54
+ const validationError = this.validateParsedScope(parsed);
55
+ if (validationError) {
56
+ this.logger.warn('[validate] Invalid scope: %s | Reason: %s', scopeString, validationError);
57
+ invalidScopes.push(scopeString);
58
+ }
59
+ else {
60
+ grantedScopes.push(scopeString);
61
+ }
62
+ }
63
+ const isValid = invalidScopes.length === 0;
64
+ this.logger.info('[validate] Validation result | Valid: %s | Requested: %s | Granted: %s | Invalid: %s', isValid, requestedScopes.join(', '), grantedScopes.join(', '), invalidScopes.join(', ') || 'none');
65
+ return {
66
+ valid: isValid,
67
+ grantedScopes,
68
+ invalidScopes: invalidScopes.length > 0 ? invalidScopes : undefined,
69
+ };
70
+ }
71
+ /**
72
+ * Validate a single parsed scope
73
+ * @param parsed - Parsed scope object
74
+ * @returns Error message if invalid, null if valid
75
+ */
76
+ validateParsedScope(parsed) {
77
+ // Check if resource is supported
78
+ if (!this.options.supportedResources?.includes(parsed.resource)) {
79
+ return `Unsupported resource: ${parsed.resource}`;
80
+ }
81
+ // Check if action is supported
82
+ if (!this.options.supportedActions?.includes(parsed.action)) {
83
+ return `Unsupported action: ${parsed.action}`;
84
+ }
85
+ // Validate path against available scopes
86
+ if (!this.isPathValid(parsed.path)) {
87
+ return `Invalid path: ${parsed.path.join(':')}`;
88
+ }
89
+ return null;
90
+ }
91
+ /**
92
+ * Check if a scope path is valid based on configuration
93
+ * @param path - Scope path (e.g., ['basic'], ['profile', 'firstName'])
94
+ * @returns true if valid, false otherwise
95
+ */
96
+ isPathValid(path) {
97
+ if (path.length === 0) {
98
+ return false;
99
+ }
100
+ const [firstPart] = path;
101
+ // Check if it's a scope group identifier
102
+ const isScopeGroup = this.options.availableScopes.some(s => s.identifier === firstPart);
103
+ if (isScopeGroup) {
104
+ return true;
105
+ }
106
+ // For single-level paths, allow as direct field access
107
+ if (path.length === 1) {
108
+ return true;
109
+ }
110
+ // For nested paths, check if relation exists in any scope group
111
+ const [relation] = path;
112
+ const hasRelation = this.options.availableScopes.some(s => s.relations?.some(r => r.relation === relation));
113
+ return hasRelation;
114
+ }
115
+ /**
116
+ * Check if a specific field is allowed in a relation
117
+ * Supports field aliases mapping (e.g., 'name' -> ['firstName', 'lastName'])
118
+ * @param relation - Relation name or '_base' for base fields
119
+ * @param field - Field name (can be an alias)
120
+ * @returns Array of actual fields allowed, or empty array if not allowed
121
+ */
122
+ isFieldAllowed(relation, field) {
123
+ const allowedFields = [];
124
+ for (const scopeConfig of this.options.availableScopes) {
125
+ // Check base fields
126
+ if (relation === exports.BASE_FIELDS_SCOPE && scopeConfig.fields) {
127
+ if (scopeConfig.fields.includes(field)) {
128
+ allowedFields.push(field);
129
+ }
130
+ }
131
+ // Check relation fields and aliases
132
+ if (scopeConfig.relations) {
133
+ for (const rel of scopeConfig.relations) {
134
+ if (rel.relation === relation) {
135
+ // Check if field is a direct field
136
+ if (rel.fields?.includes(field)) {
137
+ allowedFields.push(field);
138
+ }
139
+ // Check if field is an alias
140
+ if (rel.fieldAliases?.[field]) {
141
+ allowedFields.push(...rel.fieldAliases[field]);
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+ return allowedFields;
148
+ }
149
+ /**
150
+ * Get default scopes
151
+ * @returns Array of default scope strings
152
+ */
153
+ getDefaultScopes() {
154
+ return this.options.defaultScopes;
155
+ }
156
+ /**
157
+ * Get available scope definitions
158
+ * @returns Array of scope definitions
159
+ */
160
+ getAvailableScopes() {
161
+ return this.options.availableScopes;
162
+ }
163
+ }
164
+ exports.ScopeValidator = ScopeValidator;
165
+ //# sourceMappingURL=scope-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-validator.js","sourceRoot":"","sources":["../../../../../src/components/authenticate/oauth2-handlers/scope/scope-validator.ts"],"names":[],"mappings":";;;AAAA,uCAA6D;AAE7D,iDAA6C;AAC7C,4CAA8D;AAE9D,4CAA4C;AAC/B,QAAA,iBAAiB,GAAG,OAAO,CAAC;AASzC;;;GAGG;AACH,MAAa,cAAc;IAKzB,YAAY,IAAyD;QACnE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,uBAAa,CAAC,SAAS,CAAC,CAAC,KAAK,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,GAAG,IAAI,0BAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,G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AAW,CAAC,SAAS,EAAE,CAAC;oBACxC,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;wBAC9B,mCAAmC;wBACnC,IAAI,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;4BAChC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;wBAC5B,CAAC;wBAED,6BAA6B;wBAC7B,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;4BAC9B,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;wBACjD,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;IACtC,CAAC;CACF;AA/LD,wCA+LC"}
@@ -4,4 +4,5 @@ export * from './jwt.strategy';
4
4
  export * from './jwt-token.service';
5
5
  export * from './oauth2.strategy';
6
6
  export * from './oauth2.service';
7
+ export * from './oauth2-scope.service';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/authenticate/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/authenticate/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
@@ -20,4 +20,5 @@ __exportStar(require("./jwt.strategy"), exports);
20
20
  __exportStar(require("./jwt-token.service"), exports);
21
21
  __exportStar(require("./oauth2.strategy"), exports);
22
22
  __exportStar(require("./oauth2.service"), exports);
23
+ __exportStar(require("./oauth2-scope.service"), exports);
23
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/authenticate/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,wDAAsC;AAEtC,iDAA+B;AAC/B,sDAAoC;AAEpC,oDAAkC;AAClC,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/authenticate/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,wDAAsC;AAEtC,iDAA+B;AAC/B,sDAAoC;AAEpC,oDAAkC;AAClC,mDAAiC;AACjC,yDAAuC"}