@venizia/ignis-kernel 0.4.8-9 → 0.5.0-0

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 (171) hide show
  1. package/dist/esm/base/applications/artifact-index.d.ts +3 -3
  2. package/dist/esm/base/applications/artifact-index.js.map +1 -1
  3. package/dist/esm/base/applications/body-limit.js +1 -1
  4. package/dist/esm/base/applications/body-limit.js.map +1 -1
  5. package/dist/esm/base/applications/common/types/application.d.ts +2 -2
  6. package/dist/esm/base/applications/common/types/application.js.map +1 -1
  7. package/dist/esm/base/applications/common/types/middlewares.d.ts +2 -2
  8. package/dist/esm/base/applications/common/types/middlewares.js.map +1 -1
  9. package/dist/esm/base/applications/rest.d.ts +2 -2
  10. package/dist/esm/base/applications/rest.js +6 -1
  11. package/dist/esm/base/applications/rest.js.map +1 -1
  12. package/dist/esm/base/auth/authenticate/common/keys.d.ts +21 -7
  13. package/dist/esm/base/auth/authenticate/common/keys.js +34 -7
  14. package/dist/esm/base/auth/authenticate/common/keys.js.map +1 -1
  15. package/dist/esm/base/auth/authenticate/common/types/jwt.d.ts +9 -18
  16. package/dist/esm/base/auth/authenticate/common/types/jwt.js.map +1 -1
  17. package/dist/esm/base/auth/authenticate/common/types/rest.d.ts +3 -1
  18. package/dist/esm/base/auth/authenticate/common/types/rest.js.map +1 -1
  19. package/dist/esm/base/auth/authenticate/common/types/service.d.ts +3 -3
  20. package/dist/esm/base/auth/authenticate/common/types/service.js.map +1 -1
  21. package/dist/esm/base/auth/authenticate/common/types/strategy.d.ts +2 -3
  22. package/dist/esm/base/auth/authenticate/common/types/strategy.js.map +1 -1
  23. package/dist/esm/base/auth/authenticate/strategies/strategy-registry.d.ts +1 -1
  24. package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js +1 -1
  25. package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js.map +1 -1
  26. package/dist/esm/base/auth/authorize/common/constants/binding-keys.d.ts +6 -3
  27. package/dist/esm/base/auth/authorize/common/constants/binding-keys.js +8 -3
  28. package/dist/esm/base/auth/authorize/common/constants/binding-keys.js.map +1 -1
  29. package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
  30. package/dist/esm/base/auth/authorize/providers/request-domain.js +2 -1
  31. package/dist/esm/base/auth/authorize/providers/request-domain.js.map +1 -1
  32. package/dist/esm/base/auth/base/abstract-auth-registry.d.ts +2 -1
  33. package/dist/esm/base/auth/base/abstract-auth-registry.js +2 -2
  34. package/dist/esm/base/auth/base/abstract-auth-registry.js.map +1 -1
  35. package/dist/esm/base/components/base.d.ts +3 -3
  36. package/dist/esm/base/components/base.js +3 -3
  37. package/dist/esm/base/components/base.js.map +1 -1
  38. package/dist/esm/base/components/controller/rest/common/types.d.ts +2 -1
  39. package/dist/esm/base/components/controller/rest/common/types.js +3 -1
  40. package/dist/esm/base/components/controller/rest/common/types.js.map +1 -1
  41. package/dist/esm/base/components/controller/rest/rest.component.js.map +1 -1
  42. package/dist/esm/base/controllers/common/types/route.d.ts +13 -4
  43. package/dist/esm/base/controllers/common/types/route.js.map +1 -1
  44. package/dist/esm/base/controllers/factory/controller.d.ts +3 -4
  45. package/dist/esm/base/controllers/factory/controller.js +4 -2
  46. package/dist/esm/base/controllers/factory/controller.js.map +1 -1
  47. package/dist/esm/base/controllers/factory/crud/abstract.d.ts +3 -4
  48. package/dist/esm/base/controllers/factory/crud/abstract.js.map +1 -1
  49. package/dist/esm/base/controllers/factory/definition.d.ts +69 -49
  50. package/dist/esm/base/controllers/factory/definition.js +45 -31
  51. package/dist/esm/base/controllers/factory/definition.js.map +1 -1
  52. package/dist/esm/base/controllers/factory/index.d.ts +1 -0
  53. package/dist/esm/base/controllers/factory/index.js +1 -0
  54. package/dist/esm/base/controllers/factory/index.js.map +1 -1
  55. package/dist/esm/base/controllers/factory/injection.d.ts +38 -0
  56. package/dist/esm/base/controllers/factory/injection.js +54 -0
  57. package/dist/esm/base/controllers/factory/injection.js.map +1 -0
  58. package/dist/esm/base/controllers/rest/abstract.js +1 -1
  59. package/dist/esm/base/controllers/rest/abstract.js.map +1 -1
  60. package/dist/esm/base/controllers/rest/base.d.ts +3 -3
  61. package/dist/esm/base/controllers/rest/base.js.map +1 -1
  62. package/dist/esm/base/datasources/abstract.d.ts +4 -92
  63. package/dist/esm/base/datasources/abstract.js +3 -217
  64. package/dist/esm/base/datasources/abstract.js.map +1 -1
  65. package/dist/esm/base/datasources/common/types.d.ts +2 -2
  66. package/dist/esm/base/datasources/common/types.js.map +1 -1
  67. package/dist/esm/base/datasources/index.d.ts +1 -0
  68. package/dist/esm/base/datasources/index.js +1 -0
  69. package/dist/esm/base/datasources/index.js.map +1 -1
  70. package/dist/esm/base/datasources/root.d.ts +107 -0
  71. package/dist/esm/base/datasources/root.js +237 -0
  72. package/dist/esm/base/datasources/root.js.map +1 -0
  73. package/dist/esm/base/events/common/types.d.ts +2 -1
  74. package/dist/esm/base/events/common/types.js.map +1 -1
  75. package/dist/esm/base/events/event-bus.js.map +1 -1
  76. package/dist/esm/base/metadata/artifact-keys.d.ts +2 -1
  77. package/dist/esm/base/metadata/artifact-keys.js.map +1 -1
  78. package/dist/esm/base/metadata/index.d.ts +1 -1
  79. package/dist/esm/base/metadata/index.js +1 -1
  80. package/dist/esm/base/metadata/injectable.d.ts +2 -1
  81. package/dist/esm/base/metadata/injectable.js.map +1 -1
  82. package/dist/esm/base/metadata/injectors.d.ts +1 -1
  83. package/dist/esm/base/metadata/persistents/datasource.d.ts +21 -0
  84. package/dist/esm/base/metadata/persistents/datasource.js +46 -0
  85. package/dist/esm/base/metadata/persistents/datasource.js.map +1 -0
  86. package/dist/esm/base/metadata/persistents/index.d.ts +5 -0
  87. package/dist/esm/base/metadata/persistents/index.js +5 -0
  88. package/dist/esm/base/metadata/persistents/index.js.map +1 -0
  89. package/dist/esm/base/metadata/persistents/model.d.ts +18 -0
  90. package/dist/esm/base/metadata/persistents/model.js +64 -0
  91. package/dist/esm/base/metadata/persistents/model.js.map +1 -0
  92. package/dist/esm/base/metadata/persistents/repository/index.d.ts +19 -0
  93. package/dist/esm/base/metadata/persistents/repository/index.js +32 -0
  94. package/dist/esm/base/metadata/persistents/repository/index.js.map +1 -0
  95. package/dist/esm/base/metadata/persistents/repository/injection.d.ts +15 -0
  96. package/dist/esm/base/metadata/persistents/repository/injection.js +64 -0
  97. package/dist/esm/base/metadata/persistents/repository/injection.js.map +1 -0
  98. package/dist/esm/base/metadata/persistents/repository/resolve.d.ts +15 -0
  99. package/dist/esm/base/metadata/persistents/repository/resolve.js +76 -0
  100. package/dist/esm/base/metadata/persistents/repository/resolve.js.map +1 -0
  101. package/dist/esm/base/metadata/persistents/repository/validate.d.ts +15 -0
  102. package/dist/esm/base/metadata/persistents/repository/validate.js +50 -0
  103. package/dist/esm/base/metadata/persistents/repository/validate.js.map +1 -0
  104. package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.js +2 -1
  105. package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.js.map +1 -1
  106. package/dist/esm/base/models/common/schemas.d.ts +9 -9
  107. package/dist/esm/base/models/common/schemas.js +1 -1
  108. package/dist/esm/base/models/common/schemas.js.map +1 -1
  109. package/dist/esm/base/models/common/utilities.d.ts +1 -1
  110. package/dist/esm/base/repositories/common/response-reader.d.ts +40 -1
  111. package/dist/esm/base/repositories/common/response-reader.js +68 -1
  112. package/dist/esm/base/repositories/common/response-reader.js.map +1 -1
  113. package/dist/esm/base/repositories/common/types/contracts.d.ts +2 -2
  114. package/dist/esm/base/repositories/common/types/contracts.js.map +1 -1
  115. package/dist/esm/base/repositories/common/types/options.d.ts +2 -2
  116. package/dist/esm/base/repositories/common/types/options.js.map +1 -1
  117. package/dist/esm/base/repositories/common/types/query.d.ts +6 -15
  118. package/dist/esm/base/repositories/common/types/query.js.map +1 -1
  119. package/dist/esm/base/repositories/core/abstract.d.ts +6 -6
  120. package/dist/esm/base/repositories/core/abstract.js.map +1 -1
  121. package/dist/esm/base/repositories/query-schemas/index.js +7 -0
  122. package/dist/esm/base/repositories/query-schemas/index.js.map +1 -1
  123. package/dist/esm/common/bindings.d.ts +7 -7
  124. package/dist/esm/common/bindings.js +21 -7
  125. package/dist/esm/common/bindings.js.map +1 -1
  126. package/dist/esm/helpers/inversion/common/types/artifact.d.ts +2 -2
  127. package/dist/esm/helpers/inversion/common/types/artifact.js.map +1 -1
  128. package/dist/esm/helpers/inversion/common/types/model.d.ts +1 -1
  129. package/dist/esm/helpers/inversion/common/types/model.js.map +1 -1
  130. package/dist/esm/helpers/inversion/index.d.ts +1 -1
  131. package/dist/esm/helpers/inversion/index.js.map +1 -1
  132. package/dist/esm/helpers/inversion/mixins/artifact.mixin.d.ts +9 -8
  133. package/dist/esm/helpers/inversion/mixins/artifact.mixin.js +1 -0
  134. package/dist/esm/helpers/inversion/mixins/artifact.mixin.js.map +1 -1
  135. package/dist/esm/helpers/inversion/mixins/controllers/controller.d.ts +9 -8
  136. package/dist/esm/helpers/inversion/mixins/controllers/controller.js +1 -0
  137. package/dist/esm/helpers/inversion/mixins/controllers/controller.js.map +1 -1
  138. package/dist/esm/helpers/inversion/mixins/controllers/grpc.d.ts +9 -8
  139. package/dist/esm/helpers/inversion/mixins/controllers/grpc.js +1 -0
  140. package/dist/esm/helpers/inversion/mixins/controllers/grpc.js.map +1 -1
  141. package/dist/esm/helpers/inversion/mixins/controllers/rest.d.ts +9 -8
  142. package/dist/esm/helpers/inversion/mixins/controllers/rest.js +1 -0
  143. package/dist/esm/helpers/inversion/mixins/controllers/rest.js.map +1 -1
  144. package/dist/esm/helpers/inversion/mixins/datasource.mixin.d.ts +9 -8
  145. package/dist/esm/helpers/inversion/mixins/datasource.mixin.js +1 -0
  146. package/dist/esm/helpers/inversion/mixins/datasource.mixin.js.map +1 -1
  147. package/dist/esm/helpers/inversion/mixins/model.mixin.d.ts +9 -8
  148. package/dist/esm/helpers/inversion/mixins/model.mixin.js +1 -0
  149. package/dist/esm/helpers/inversion/mixins/model.mixin.js.map +1 -1
  150. package/dist/esm/helpers/inversion/mixins/repository.mixin.d.ts +14 -13
  151. package/dist/esm/helpers/inversion/mixins/repository.mixin.js +6 -6
  152. package/dist/esm/helpers/inversion/mixins/repository.mixin.js.map +1 -1
  153. package/dist/esm/helpers/inversion/registry.d.ts +61 -61
  154. package/dist/esm/helpers/inversion/registry.js.map +1 -1
  155. package/dist/esm/helpers/singleton-realm.js +5 -4
  156. package/dist/esm/helpers/singleton-realm.js.map +1 -1
  157. package/dist/esm/metadata.d.ts +1 -1
  158. package/dist/esm/metadata.js +1 -1
  159. package/dist/esm/repository.d.ts +1 -0
  160. package/dist/esm/repository.js +1 -0
  161. package/dist/esm/repository.js.map +1 -1
  162. package/dist/esm/utilities/index.d.ts +1 -0
  163. package/dist/esm/utilities/index.js +1 -0
  164. package/dist/esm/utilities/index.js.map +1 -1
  165. package/dist/esm/utilities/toggle.utility.d.ts +22 -0
  166. package/dist/esm/utilities/toggle.utility.js +16 -0
  167. package/dist/esm/utilities/toggle.utility.js.map +1 -0
  168. package/package.json +5 -5
  169. package/dist/esm/base/metadata/persistents.d.ts +0 -54
  170. package/dist/esm/base/metadata/persistents.js +0 -302
  171. package/dist/esm/base/metadata/persistents.js.map +0 -1
@@ -1,10 +1,24 @@
1
- /** Container binding keys under which the authenticate component stores each strategy's options and the service-certs controller path. */
1
+ import type { IJWKSIssuerOptions, IJWKSVerifierOptions, IJWSTokenServiceOptions, TJWTTokenServiceOptions } from './types/jwt.js';
2
+ import type { IServiceAuthOptions } from './types/service.js';
3
+ import type { TBasicTokenServiceOptions } from './types/basic.js';
4
+ import type { TAuthenticationRestOptions } from './types/rest.js';
5
+ /**
6
+ * Container binding keys under which the authenticate component stores each strategy's options and the service-certs
7
+ * controller path. Each key names ONE value type. `JWT_OPTIONS` is the one an application binds; the keys marked
8
+ * internal are bound by the component from it, and a service injects them.
9
+ */
2
10
  export declare class AuthenticateBindingKeys {
3
- static readonly REST_OPTIONS = "@app/authenticate/rest-options";
4
- static readonly JWT_OPTIONS = "@app/authenticate/jwt-options";
5
- static readonly JWKS_OPTIONS = "@app/authenticate/jwks-options";
6
- static readonly BASIC_OPTIONS = "@app/authenticate/basic-options";
7
- static readonly SERVICE_OPTIONS = "@app/authenticate/service-options";
8
- static readonly SERVICE_CERTS_PATH = "@app/authenticate/service-certs-path";
11
+ static readonly REST_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<TAuthenticationRestOptions>;
12
+ /** What an application binds for JWT or JWKS: the options with their `standard` (JWS or JWKS). */
13
+ static readonly JWT_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<TJWTTokenServiceOptions>;
14
+ /** Internal. The inner options of a JWS setup, bound by the component from `JWT_OPTIONS` and injected by `JWSTokenService`. */
15
+ static readonly JWS_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<IJWSTokenServiceOptions>;
16
+ /** Internal. The options of a JWKS issuer, bound by the component from `JWT_OPTIONS` and injected by `JWKSIssuerTokenService`. */
17
+ static readonly JWKS_ISSUER_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<IJWKSIssuerOptions>;
18
+ /** Internal. The options of a JWKS verifier, bound by the component from `JWT_OPTIONS` and injected by `JWKSVerifierTokenService`. */
19
+ static readonly JWKS_VERIFIER_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<IJWKSVerifierOptions>;
20
+ static readonly BASIC_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<TBasicTokenServiceOptions>;
21
+ static readonly SERVICE_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<IServiceAuthOptions<import("hono").Env>>;
22
+ static readonly SERVICE_CERTS_PATH: import("@venizia/ignis-inversion").TBindingKey<string>;
9
23
  }
10
24
  //# sourceMappingURL=keys.d.ts.map
@@ -1,10 +1,37 @@
1
- /** Container binding keys under which the authenticate component stores each strategy's options and the service-certs controller path. */
1
+ import { BindingKeys } from '../../../../helpers/inversion/index.js';
2
+ /**
3
+ * Container binding keys under which the authenticate component stores each strategy's options and the service-certs
4
+ * controller path. Each key names ONE value type. `JWT_OPTIONS` is the one an application binds; the keys marked
5
+ * internal are bound by the component from it, and a service injects them.
6
+ */
2
7
  export class AuthenticateBindingKeys {
3
- static { this.REST_OPTIONS = '@app/authenticate/rest-options'; }
4
- static { this.JWT_OPTIONS = '@app/authenticate/jwt-options'; }
5
- static { this.JWKS_OPTIONS = '@app/authenticate/jwks-options'; }
6
- static { this.BASIC_OPTIONS = '@app/authenticate/basic-options'; }
7
- static { this.SERVICE_OPTIONS = '@app/authenticate/service-options'; }
8
- static { this.SERVICE_CERTS_PATH = '@app/authenticate/service-certs-path'; }
8
+ static { this.REST_OPTIONS = BindingKeys.build({
9
+ key: '@app/authenticate/rest-options',
10
+ }); }
11
+ /** What an application binds for JWT or JWKS: the options with their `standard` (JWS or JWKS). */
12
+ static { this.JWT_OPTIONS = BindingKeys.build({
13
+ key: '@app/authenticate/jwt-options',
14
+ }); }
15
+ /** Internal. The inner options of a JWS setup, bound by the component from `JWT_OPTIONS` and injected by `JWSTokenService`. */
16
+ static { this.JWS_OPTIONS = BindingKeys.build({
17
+ key: '@app/authenticate/jws-options',
18
+ }); }
19
+ /** Internal. The options of a JWKS issuer, bound by the component from `JWT_OPTIONS` and injected by `JWKSIssuerTokenService`. */
20
+ static { this.JWKS_ISSUER_OPTIONS = BindingKeys.build({
21
+ key: '@app/authenticate/jwks-issuer-options',
22
+ }); }
23
+ /** Internal. The options of a JWKS verifier, bound by the component from `JWT_OPTIONS` and injected by `JWKSVerifierTokenService`. */
24
+ static { this.JWKS_VERIFIER_OPTIONS = BindingKeys.build({
25
+ key: '@app/authenticate/jwks-verifier-options',
26
+ }); }
27
+ static { this.BASIC_OPTIONS = BindingKeys.build({
28
+ key: '@app/authenticate/basic-options',
29
+ }); }
30
+ static { this.SERVICE_OPTIONS = BindingKeys.build({
31
+ key: '@app/authenticate/service-options',
32
+ }); }
33
+ static { this.SERVICE_CERTS_PATH = BindingKeys.build({
34
+ key: '@app/authenticate/service-certs-path',
35
+ }); }
9
36
  }
10
37
  //# sourceMappingURL=keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authenticate/common/keys.ts"],"names":[],"mappings":"AAAA,0IAA0I;AAC1I,MAAM,OAAO,uBAAuB;aAClB,iBAAY,GAAG,gCAAgC,CAAC;aAChD,gBAAW,GAAG,+BAA+B,CAAC;aAC9C,iBAAY,GAAG,gCAAgC,CAAC;aAChD,kBAAa,GAAG,iCAAiC,CAAC;aAClD,oBAAe,GAAG,mCAAmC,CAAC;aACtD,uBAAkB,GAAG,sCAAsC,CAAC","sourcesContent":["/** Container binding keys under which the authenticate component stores each strategy's options and the service-certs controller path. */\nexport class AuthenticateBindingKeys {\n static readonly REST_OPTIONS = '@app/authenticate/rest-options';\n static readonly JWT_OPTIONS = '@app/authenticate/jwt-options';\n static readonly JWKS_OPTIONS = '@app/authenticate/jwks-options';\n static readonly BASIC_OPTIONS = '@app/authenticate/basic-options';\n static readonly SERVICE_OPTIONS = '@app/authenticate/service-options';\n static readonly SERVICE_CERTS_PATH = '@app/authenticate/service-certs-path';\n}\n"]}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authenticate/common/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAWlD;;;;GAIG;AACH,MAAM,OAAO,uBAAuB;aAClB,iBAAY,GAAG,WAAW,CAAC,KAAK,CAA6B;QAC3E,GAAG,EAAE,gCAAgC;KACtC,CAAC,CAAC;IAEH,kGAAkG;aAClF,gBAAW,GAAG,WAAW,CAAC,KAAK,CAA0B;QACvE,GAAG,EAAE,+BAA+B;KACrC,CAAC,CAAC;IAEH,+HAA+H;aAC/G,gBAAW,GAAG,WAAW,CAAC,KAAK,CAA0B;QACvE,GAAG,EAAE,+BAA+B;KACrC,CAAC,CAAC;IAEH,kIAAkI;aAClH,wBAAmB,GAAG,WAAW,CAAC,KAAK,CAAqB;QAC1E,GAAG,EAAE,uCAAuC;KAC7C,CAAC,CAAC;IAEH,sIAAsI;aACtH,0BAAqB,GAAG,WAAW,CAAC,KAAK,CAAuB;QAC9E,GAAG,EAAE,yCAAyC;KAC/C,CAAC,CAAC;aAEa,kBAAa,GAAG,WAAW,CAAC,KAAK,CAA4B;QAC3E,GAAG,EAAE,iCAAiC;KACvC,CAAC,CAAC;aAEa,oBAAe,GAAG,WAAW,CAAC,KAAK,CAAsB;QACvE,GAAG,EAAE,mCAAmC;KACzC,CAAC,CAAC;aAEa,uBAAkB,GAAG,WAAW,CAAC,KAAK,CAAS;QAC7D,GAAG,EAAE,sCAAsC;KAC5C,CAAC,CAAC","sourcesContent":["import { BindingKeys } from '@/helpers/inversion';\nimport type {\n IJWKSIssuerOptions,\n IJWKSVerifierOptions,\n IJWSTokenServiceOptions,\n TJWTTokenServiceOptions,\n} from './types/jwt';\nimport type { IServiceAuthOptions } from './types/service';\nimport type { TBasicTokenServiceOptions } from './types/basic';\nimport type { TAuthenticationRestOptions } from './types/rest';\n\n/**\n * Container binding keys under which the authenticate component stores each strategy's options and the service-certs\n * controller path. Each key names ONE value type. `JWT_OPTIONS` is the one an application binds; the keys marked\n * internal are bound by the component from it, and a service injects them.\n */\nexport class AuthenticateBindingKeys {\n static readonly REST_OPTIONS = BindingKeys.build<TAuthenticationRestOptions>({\n key: '@app/authenticate/rest-options',\n });\n\n /** What an application binds for JWT or JWKS: the options with their `standard` (JWS or JWKS). */\n static readonly JWT_OPTIONS = BindingKeys.build<TJWTTokenServiceOptions>({\n key: '@app/authenticate/jwt-options',\n });\n\n /** Internal. The inner options of a JWS setup, bound by the component from `JWT_OPTIONS` and injected by `JWSTokenService`. */\n static readonly JWS_OPTIONS = BindingKeys.build<IJWSTokenServiceOptions>({\n key: '@app/authenticate/jws-options',\n });\n\n /** Internal. The options of a JWKS issuer, bound by the component from `JWT_OPTIONS` and injected by `JWKSIssuerTokenService`. */\n static readonly JWKS_ISSUER_OPTIONS = BindingKeys.build<IJWKSIssuerOptions>({\n key: '@app/authenticate/jwks-issuer-options',\n });\n\n /** Internal. The options of a JWKS verifier, bound by the component from `JWT_OPTIONS` and injected by `JWKSVerifierTokenService`. */\n static readonly JWKS_VERIFIER_OPTIONS = BindingKeys.build<IJWKSVerifierOptions>({\n key: '@app/authenticate/jwks-verifier-options',\n });\n\n static readonly BASIC_OPTIONS = BindingKeys.build<TBasicTokenServiceOptions>({\n key: '@app/authenticate/basic-options',\n });\n\n static readonly SERVICE_OPTIONS = BindingKeys.build<IServiceAuthOptions>({\n key: '@app/authenticate/service-options',\n });\n\n static readonly SERVICE_CERTS_PATH = BindingKeys.build<string>({\n key: '@app/authenticate/service-certs-path',\n });\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { IdType } from '../../../../models/common/index.js';
2
2
  import type { ValueOrPromise } from '@venizia/ignis-helpers/common';
3
- import type { AESAlgorithmType } from '@venizia/ignis-helpers/core';
3
+ import type { AESAlgorithmType, TTrustedOrigin } from '@venizia/ignis-helpers/core';
4
4
  import type { JWTPayload } from 'jose';
5
5
  import type { JOSEStandards, JWKSModes, TJWKSAlgorithm, TJWKSKeyDriver, TJWKSKeyFormat } from '../constants/index.js';
6
6
  import type { IAuthUser } from './strategy.js';
@@ -122,29 +122,20 @@ export interface IJWKSVerifierVerifyOptions extends IJWTVerifyOptions {
122
122
  /** The JWS `alg` values accepted, for example `['RS256']`. At least one. */
123
123
  algorithms: string[];
124
124
  }
125
- /**
126
- * Where a JWKS may be fetched over plain `http:`. A JWKS URL is `https:` unless its host is loopback (`localhost`,
127
- * `127.0.0.0/8`, `::1`) or is listed in `http`.
128
- */
129
- export interface IJWKSHosts {
130
- /**
131
- * Exact hosts that may serve a JWKS over `http:`: a name (`identity-service`), an IPv4 address (`10.0.0.5`) or an
132
- * IPv6 address in brackets (`[fd00::1]`), each with an optional `:port` (`10.0.0.5:8080`, `[fd00::1]:8443`). An entry
133
- * without a port covers every port of that host; an entry with one covers that port only. Never a wildcard, range or
134
- * CIDR. An entry is valid only when `new URL('http://' + entry)` gives the same host back, so `2130706433` and
135
- * `[::ffff:10.0.0.5]` refuse the boot, as do a scheme, a path, credentials or an empty label.
136
- */
137
- http?: string[];
138
- }
139
125
  /** Options of a JWKS verifier, which checks tokens against the key set served at `jwksUrl`. */
140
126
  export interface IJWKSVerifierOptions {
141
127
  mode: typeof JWKSModes.VERIFIER;
142
128
  jwksUrl: string;
143
129
  /** The `iss` and `aud` required on every verified token. */
144
130
  claims: IJWTClaimsOptions;
145
- /** Where the key set may be fetched from over `http:`. Unset means `https:` or loopback only. */
131
+ /**
132
+ * Where the key set may be fetched from. `trusted` lists the exact `http:` origins that may serve it, written as the
133
+ * URL parser writes an origin (`http://identity-service`, `http://10.0.0.5:8080`, `http://[fd00::1]:8443`); each port
134
+ * is its own entry. A JWKS URL is `https:` unless its host is loopback (`localhost`, `127.0.0.0/8`, `::1`) or its
135
+ * origin is listed. An entry that is not exactly an origin refuses the boot. Unset means `https:` or loopback only.
136
+ */
146
137
  jwks?: {
147
- hosts?: IJWKSHosts;
138
+ trusted?: TTrustedOrigin[];
148
139
  };
149
140
  /**
150
141
  * How long the fetched key set stays cached, in ms (12 hours).
@@ -196,7 +187,7 @@ export interface IJWTTokenPayload extends JWTPayload, IAuthUser {
196
187
  provider?: string;
197
188
  email?: string;
198
189
  name?: string;
199
- [extra: string | symbol]: any;
190
+ [extra: string | symbol]: unknown;
200
191
  }
201
192
  /** Converts one payload field, found under `key`, to a string and back around the AES envelope. */
202
193
  export interface IPayloadFieldCodec<T = unknown> {
@@ -1 +1 @@
1
- {"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/types/jwt.ts"],"names":[],"mappings":"","sourcesContent":["import type { IdType } from '@/base/models/common';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { AESAlgorithmType } from '@venizia/ignis-helpers/core';\nimport type { JWTPayload } from 'jose';\nimport type {\n JOSEStandards,\n JWKSModes,\n TJWKSAlgorithm,\n TJWKSKeyDriver,\n TJWKSKeyFormat,\n} from '../constants';\nimport type { IAuthUser } from './strategy';\n\n/**\n * The `iss` and, optionally, the `aud` of a service: stamped on every token it signs and REQUIRED on every token it\n * verifies. `issuer` is required, `audience` is optional, and no other key is accepted.\n *\n * Without them a token signed with the same key for another purpose (a password-reset or an invite\n * token that carries a user id) would authenticate a request, and in a fleet where every verifier\n * points at the same issuer JWKS a token minted for one service would be accepted by every other.\n * `audience` is what makes \"this token was meant for me\" a cryptographic statement rather than a\n * convention.\n */\nexport interface IJWTClaimsOptions {\n /** The `iss` stamped on every issued token and required on every verified one. */\n issuer: string;\n\n /**\n * The `aud` stamped on every issued token and required on every verified one. Optional: without it no `aud` is\n * stamped and none is checked, so a token with or without one verifies. Set, it must be a non-empty string or a\n * non-empty list of them. Matching is jose's OVERLAP semantics, not equality: a token carrying `['a','b']`\n * satisfies `audience: 'a'`. Enforce single-valued audiences at issue time if that matters.\n */\n audience?: string | string[];\n}\n\n/**\n * The other claim checks applied when VERIFYING a JWT. Field names and types mirror jose's\n * `JWTVerifyOptions`, so this is a pass-through with no translation layer. `issuer` and `audience`\n * are not here: they are the required {@link IJWTClaimsOptions}.\n *\n * Every field is optional and unset by default: nothing is checked beyond the signature, the time\n * claims, the `claims` and the algorithm pin.\n */\nexport interface IJWTVerifyOptions {\n /** Expected `sub`. Setting it makes the claim required. */\n subject?: string;\n\n /** Clock skew tolerance: seconds, or a jose duration string such as `'30 seconds'`. */\n clockTolerance?: string | number;\n\n /** Accepted JWS `alg` header values. Unset pins the one algorithm the service signs with: `headerAlgorithm` (`HS256` by default) of the JWS service, `algorithm` of a JWKS issuer. A JWKS verifier cannot know it, so it requires this ({@link IJWKSVerifierVerifyOptions}). */\n algorithms?: string[];\n\n /** Caps elapsed time since `iat`. The real replay window for a short-lived assertion, independent of whatever `exp` the caller chose to stamp. */\n maxTokenAge?: string | number;\n\n /** Expected JWS `typ` header. The standard defence against cross-token-type confusion when one JWKS serves more than one kind of token. */\n typ?: string;\n\n /** Claims that must be present, beyond those implied by the checks above. */\n requiredClaims?: string[];\n}\n\n/**\n * Per-token registered claims, passed to `generate()`.\n *\n * This is the supported way to vary `aud` or `sub` per token. Putting them on the payload used to\n * work by accident - `iss`, `aud`, `sub` and `jti` ride through the AES envelope in the clear\n * because they are standard JWT fields - but a claim the payload can set is a claim any caller who\n * shapes the payload can forge. These win over the configured {@link IJWTClaimsOptions}; the payload never does.\n */\nexport interface IJWTIssueClaims {\n issuer?: string;\n audience?: string | string[];\n subject?: string;\n jwtId?: string;\n}\n\n/**\n * Options of the JWS token service, which signs with the shared `jwtSecret`.\n *\n * `getTokenExpiresFn` is required. AES payload encryption is active only when `applicationSecret` is set.\n */\nexport interface IJWSTokenServiceOptions {\n /**\n * The JWS `alg` header.\n *\n * @default 'HS256'\n */\n headerAlgorithm?: string;\n jwtSecret: string;\n getTokenExpiresFn: TGetTokenExpiresFn;\n\n /** The `iss` and `aud` stamped on every issued token and required on every verified one. A configured value WINS over one supplied in the payload. */\n claims: IJWTClaimsOptions;\n\n /**\n * The AES algorithm of payload encryption, used when `applicationSecret` is set.\n *\n * @default 'aes-256-cbc'\n */\n aesAlgorithm?: AESAlgorithmType;\n applicationSecret?: string;\n fieldCodecs?: IPayloadFieldCodec[];\n\n /** Further checks applied on verify, beside `claims` and the algorithm pin. */\n verify?: IJWTVerifyOptions;\n}\n\n/** Options of a JWKS issuer, which signs tokens with its own key pair. `keys.private` and `keys.public` hold content or a file path according to `keys.driver`. `rest.path` sets where the public key set is served. */\nexport interface IJWKSIssuerOptions {\n mode: typeof JWKSModes.ISSUER;\n algorithm: TJWKSAlgorithm;\n rest?: {\n /** @default '/certs' */\n path: string;\n };\n keys: {\n driver: TJWKSKeyDriver;\n format: TJWKSKeyFormat;\n private: string; // Key content (text) or file path (file) — PEM or JWK based on format\n public: string; // Key content (text) or file path (file) — PEM or JWK based on format\n };\n kid: string;\n getTokenExpiresFn: TGetTokenExpiresFn;\n\n /** The `iss` and `aud` stamped on every issued token and required on every verified one. A configured value WINS over one supplied in the payload. */\n claims: IJWTClaimsOptions;\n\n /**\n * The AES algorithm of payload encryption, used when `applicationSecret` is set.\n *\n * @default 'aes-256-cbc'\n */\n aesAlgorithm?: AESAlgorithmType;\n applicationSecret?: string;\n fieldCodecs?: IPayloadFieldCodec[];\n\n /** Further checks applied on verify, beside `claims` and the algorithm pin. */\n verify?: IJWTVerifyOptions;\n}\n\n/** The verify checks of a JWKS verifier: `algorithms` is required, because the verifier cannot know what the issuer signs with. */\nexport interface IJWKSVerifierVerifyOptions extends IJWTVerifyOptions {\n /** The JWS `alg` values accepted, for example `['RS256']`. At least one. */\n algorithms: string[];\n}\n\n/**\n * Where a JWKS may be fetched over plain `http:`. A JWKS URL is `https:` unless its host is loopback (`localhost`,\n * `127.0.0.0/8`, `::1`) or is listed in `http`.\n */\nexport interface IJWKSHosts {\n /**\n * Exact hosts that may serve a JWKS over `http:`: a name (`identity-service`), an IPv4 address (`10.0.0.5`) or an\n * IPv6 address in brackets (`[fd00::1]`), each with an optional `:port` (`10.0.0.5:8080`, `[fd00::1]:8443`). An entry\n * without a port covers every port of that host; an entry with one covers that port only. Never a wildcard, range or\n * CIDR. An entry is valid only when `new URL('http://' + entry)` gives the same host back, so `2130706433` and\n * `[::ffff:10.0.0.5]` refuse the boot, as do a scheme, a path, credentials or an empty label.\n */\n http?: string[];\n}\n\n/** Options of a JWKS verifier, which checks tokens against the key set served at `jwksUrl`. */\nexport interface IJWKSVerifierOptions {\n mode: typeof JWKSModes.VERIFIER;\n jwksUrl: string;\n\n /** The `iss` and `aud` required on every verified token. */\n claims: IJWTClaimsOptions;\n\n /** Where the key set may be fetched from over `http:`. Unset means `https:` or loopback only. */\n jwks?: { hosts?: IJWKSHosts };\n\n /**\n * How long the fetched key set stays cached, in ms (12 hours).\n *\n * @default 43_200_000\n */\n cacheTtlMs?: number;\n\n /**\n * Minimum wait between refetches of the key set, in ms (30 seconds).\n *\n * @default 30_000\n */\n cooldownMs?: number;\n\n /**\n * The AES algorithm of payload encryption, used when `applicationSecret` is set.\n *\n * @default 'aes-256-cbc'\n */\n aesAlgorithm?: AESAlgorithmType;\n applicationSecret?: string;\n fieldCodecs?: IPayloadFieldCodec[];\n\n /** Further checks applied on verify, beside `claims`. `algorithms` is required. */\n verify: IJWKSVerifierVerifyOptions;\n}\n\n/** Options of the JWKS token service, selected by `mode`. */\nexport type TJWKSTokenServiceOptions = IJWKSIssuerOptions | IJWKSVerifierOptions;\n\n/** Options of the JWT token service, selected by `standard` (`JWS` or `JWKS`). */\nexport type TJWTTokenServiceOptions =\n | { standard: typeof JOSEStandards.JWS; options: IJWSTokenServiceOptions }\n | { standard: typeof JOSEStandards.JWKS; options: TJWKSTokenServiceOptions };\n\n/** One role as a token carries it. */\nexport type TJWTTokenRole = { id: IdType; identifier: string; priority: number };\n\n/**\n * What a token carries. `roles` may be absent: `generate` signs a payload without it as is, `verify`\n * returns it without `roles`, and authorization reads its roles as none. Check it before you read it.\n */\nexport interface IJWTTokenPayload extends JWTPayload, IAuthUser {\n userId: IdType;\n roles?: TJWTTokenRole[];\n\n clientId?: string;\n provider?: string;\n email?: string;\n name?: string;\n\n [extra: string | symbol]: any;\n}\n\n/** Converts one payload field, found under `key`, to a string and back around the AES envelope. */\nexport interface IPayloadFieldCodec<T = unknown> {\n key: string;\n serialize(opts: { value: T }): string;\n deserialize(opts: { raw: string }): T;\n}\n\n/** Returns the lifetime of a token to issue, in seconds from now. */\nexport type TGetTokenExpiresFn = () => ValueOrPromise<number>;\n"]}
1
+ {"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/types/jwt.ts"],"names":[],"mappings":"","sourcesContent":["import type { IdType } from '@/base/models/common';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { AESAlgorithmType, TTrustedOrigin } from '@venizia/ignis-helpers/core';\nimport type { JWTPayload } from 'jose';\nimport type {\n JOSEStandards,\n JWKSModes,\n TJWKSAlgorithm,\n TJWKSKeyDriver,\n TJWKSKeyFormat,\n} from '../constants';\nimport type { IAuthUser } from './strategy';\n\n/**\n * The `iss` and, optionally, the `aud` of a service: stamped on every token it signs and REQUIRED on every token it\n * verifies. `issuer` is required, `audience` is optional, and no other key is accepted.\n *\n * Without them a token signed with the same key for another purpose (a password-reset or an invite\n * token that carries a user id) would authenticate a request, and in a fleet where every verifier\n * points at the same issuer JWKS a token minted for one service would be accepted by every other.\n * `audience` is what makes \"this token was meant for me\" a cryptographic statement rather than a\n * convention.\n */\nexport interface IJWTClaimsOptions {\n /** The `iss` stamped on every issued token and required on every verified one. */\n issuer: string;\n\n /**\n * The `aud` stamped on every issued token and required on every verified one. Optional: without it no `aud` is\n * stamped and none is checked, so a token with or without one verifies. Set, it must be a non-empty string or a\n * non-empty list of them. Matching is jose's OVERLAP semantics, not equality: a token carrying `['a','b']`\n * satisfies `audience: 'a'`. Enforce single-valued audiences at issue time if that matters.\n */\n audience?: string | string[];\n}\n\n/**\n * The other claim checks applied when VERIFYING a JWT. Field names and types mirror jose's\n * `JWTVerifyOptions`, so this is a pass-through with no translation layer. `issuer` and `audience`\n * are not here: they are the required {@link IJWTClaimsOptions}.\n *\n * Every field is optional and unset by default: nothing is checked beyond the signature, the time\n * claims, the `claims` and the algorithm pin.\n */\nexport interface IJWTVerifyOptions {\n /** Expected `sub`. Setting it makes the claim required. */\n subject?: string;\n\n /** Clock skew tolerance: seconds, or a jose duration string such as `'30 seconds'`. */\n clockTolerance?: string | number;\n\n /** Accepted JWS `alg` header values. Unset pins the one algorithm the service signs with: `headerAlgorithm` (`HS256` by default) of the JWS service, `algorithm` of a JWKS issuer. A JWKS verifier cannot know it, so it requires this ({@link IJWKSVerifierVerifyOptions}). */\n algorithms?: string[];\n\n /** Caps elapsed time since `iat`. The real replay window for a short-lived assertion, independent of whatever `exp` the caller chose to stamp. */\n maxTokenAge?: string | number;\n\n /** Expected JWS `typ` header. The standard defence against cross-token-type confusion when one JWKS serves more than one kind of token. */\n typ?: string;\n\n /** Claims that must be present, beyond those implied by the checks above. */\n requiredClaims?: string[];\n}\n\n/**\n * Per-token registered claims, passed to `generate()`.\n *\n * This is the supported way to vary `aud` or `sub` per token. Putting them on the payload used to\n * work by accident - `iss`, `aud`, `sub` and `jti` ride through the AES envelope in the clear\n * because they are standard JWT fields - but a claim the payload can set is a claim any caller who\n * shapes the payload can forge. These win over the configured {@link IJWTClaimsOptions}; the payload never does.\n */\nexport interface IJWTIssueClaims {\n issuer?: string;\n audience?: string | string[];\n subject?: string;\n jwtId?: string;\n}\n\n/**\n * Options of the JWS token service, which signs with the shared `jwtSecret`.\n *\n * `getTokenExpiresFn` is required. AES payload encryption is active only when `applicationSecret` is set.\n */\nexport interface IJWSTokenServiceOptions {\n /**\n * The JWS `alg` header.\n *\n * @default 'HS256'\n */\n headerAlgorithm?: string;\n jwtSecret: string;\n getTokenExpiresFn: TGetTokenExpiresFn;\n\n /** The `iss` and `aud` stamped on every issued token and required on every verified one. A configured value WINS over one supplied in the payload. */\n claims: IJWTClaimsOptions;\n\n /**\n * The AES algorithm of payload encryption, used when `applicationSecret` is set.\n *\n * @default 'aes-256-cbc'\n */\n aesAlgorithm?: AESAlgorithmType;\n applicationSecret?: string;\n fieldCodecs?: IPayloadFieldCodec[];\n\n /** Further checks applied on verify, beside `claims` and the algorithm pin. */\n verify?: IJWTVerifyOptions;\n}\n\n/** Options of a JWKS issuer, which signs tokens with its own key pair. `keys.private` and `keys.public` hold content or a file path according to `keys.driver`. `rest.path` sets where the public key set is served. */\nexport interface IJWKSIssuerOptions {\n mode: typeof JWKSModes.ISSUER;\n algorithm: TJWKSAlgorithm;\n rest?: {\n /** @default '/certs' */\n path: string;\n };\n keys: {\n driver: TJWKSKeyDriver;\n format: TJWKSKeyFormat;\n private: string; // Key content (text) or file path (file) — PEM or JWK based on format\n public: string; // Key content (text) or file path (file) — PEM or JWK based on format\n };\n kid: string;\n getTokenExpiresFn: TGetTokenExpiresFn;\n\n /** The `iss` and `aud` stamped on every issued token and required on every verified one. A configured value WINS over one supplied in the payload. */\n claims: IJWTClaimsOptions;\n\n /**\n * The AES algorithm of payload encryption, used when `applicationSecret` is set.\n *\n * @default 'aes-256-cbc'\n */\n aesAlgorithm?: AESAlgorithmType;\n applicationSecret?: string;\n fieldCodecs?: IPayloadFieldCodec[];\n\n /** Further checks applied on verify, beside `claims` and the algorithm pin. */\n verify?: IJWTVerifyOptions;\n}\n\n/** The verify checks of a JWKS verifier: `algorithms` is required, because the verifier cannot know what the issuer signs with. */\nexport interface IJWKSVerifierVerifyOptions extends IJWTVerifyOptions {\n /** The JWS `alg` values accepted, for example `['RS256']`. At least one. */\n algorithms: string[];\n}\n\n/** Options of a JWKS verifier, which checks tokens against the key set served at `jwksUrl`. */\nexport interface IJWKSVerifierOptions {\n mode: typeof JWKSModes.VERIFIER;\n jwksUrl: string;\n\n /** The `iss` and `aud` required on every verified token. */\n claims: IJWTClaimsOptions;\n\n /**\n * Where the key set may be fetched from. `trusted` lists the exact `http:` origins that may serve it, written as the\n * URL parser writes an origin (`http://identity-service`, `http://10.0.0.5:8080`, `http://[fd00::1]:8443`); each port\n * is its own entry. A JWKS URL is `https:` unless its host is loopback (`localhost`, `127.0.0.0/8`, `::1`) or its\n * origin is listed. An entry that is not exactly an origin refuses the boot. Unset means `https:` or loopback only.\n */\n jwks?: { trusted?: TTrustedOrigin[] };\n\n /**\n * How long the fetched key set stays cached, in ms (12 hours).\n *\n * @default 43_200_000\n */\n cacheTtlMs?: number;\n\n /**\n * Minimum wait between refetches of the key set, in ms (30 seconds).\n *\n * @default 30_000\n */\n cooldownMs?: number;\n\n /**\n * The AES algorithm of payload encryption, used when `applicationSecret` is set.\n *\n * @default 'aes-256-cbc'\n */\n aesAlgorithm?: AESAlgorithmType;\n applicationSecret?: string;\n fieldCodecs?: IPayloadFieldCodec[];\n\n /** Further checks applied on verify, beside `claims`. `algorithms` is required. */\n verify: IJWKSVerifierVerifyOptions;\n}\n\n/** Options of the JWKS token service, selected by `mode`. */\nexport type TJWKSTokenServiceOptions = IJWKSIssuerOptions | IJWKSVerifierOptions;\n\n/** Options of the JWT token service, selected by `standard` (`JWS` or `JWKS`). */\nexport type TJWTTokenServiceOptions =\n | { standard: typeof JOSEStandards.JWS; options: IJWSTokenServiceOptions }\n | { standard: typeof JOSEStandards.JWKS; options: TJWKSTokenServiceOptions };\n\n/** One role as a token carries it. */\nexport type TJWTTokenRole = { id: IdType; identifier: string; priority: number };\n\n/**\n * What a token carries. `roles` may be absent: `generate` signs a payload without it as is, `verify`\n * returns it without `roles`, and authorization reads its roles as none. Check it before you read it.\n */\nexport interface IJWTTokenPayload extends JWTPayload, IAuthUser {\n userId: IdType;\n roles?: TJWTTokenRole[];\n\n clientId?: string;\n provider?: string;\n email?: string;\n name?: string;\n\n [extra: string | symbol]: unknown;\n}\n\n/** Converts one payload field, found under `key`, to a string and back around the AES envelope. */\nexport interface IPayloadFieldCodec<T = unknown> {\n key: string;\n serialize(opts: { value: T }): string;\n deserialize(opts: { raw: string }): T;\n}\n\n/** Returns the lifetime of a token to issue, in seconds from now. */\nexport type TGetTokenExpiresFn = () => ValueOrPromise<number>;\n"]}
@@ -1,8 +1,10 @@
1
+ import type { TBindingKey } from '../../../../../helpers/inversion/index.js';
2
+ import type { IAuthService } from './strategy.js';
1
3
  import type { TAnyObjectSchema } from '../../../../controllers/common/schema-builders.js';
2
4
  /** Options for defining the auth controller. `serviceKey` is the container key of the `IAuthService` it calls; each `payload` entry overrides the request or response schema of one route. */
3
5
  export type TDefineAuthControllerOpts = {
4
6
  restPath?: string;
5
- serviceKey: string;
7
+ serviceKey: TBindingKey<IAuthService>;
6
8
  requireAuthenticatedSignUp?: boolean;
7
9
  payload?: {
8
10
  signIn?: {
@@ -1 +1 @@
1
- {"version":3,"file":"rest.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/types/rest.ts"],"names":[],"mappings":"","sourcesContent":["import type { TAnyObjectSchema } from '@/base/controllers/common/schema-builders';\n\n/** Options for defining the auth controller. `serviceKey` is the container key of the `IAuthService` it calls; each `payload` entry overrides the request or response schema of one route. */\nexport type TDefineAuthControllerOpts = {\n restPath?: string;\n serviceKey: string;\n requireAuthenticatedSignUp?: boolean;\n payload?: {\n signIn?: {\n request: { schema: TAnyObjectSchema };\n response: { schema: TAnyObjectSchema };\n };\n signUp?: {\n request: { schema: TAnyObjectSchema };\n response: { schema: TAnyObjectSchema };\n };\n changePassword?: {\n request: { schema?: TAnyObjectSchema };\n response: { schema: TAnyObjectSchema };\n };\n refreshToken?: {\n response: { schema: TAnyObjectSchema };\n };\n getUserInformation?: {\n response: { schema: TAnyObjectSchema };\n };\n };\n};\n\n/** REST options of the authenticate component: `controllerOpts` is required when `useAuthController` is `true`. */\nexport type TAuthenticationRestOptions = {} & (\n | { useAuthController?: false | undefined }\n | {\n useAuthController: true;\n controllerOpts: TDefineAuthControllerOpts;\n }\n);\n"]}
1
+ {"version":3,"file":"rest.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/types/rest.ts"],"names":[],"mappings":"","sourcesContent":["import type { TBindingKey } from '@/helpers/inversion';\nimport type { IAuthService } from './strategy';\nimport type { TAnyObjectSchema } from '@/base/controllers/common/schema-builders';\n\n/** Options for defining the auth controller. `serviceKey` is the container key of the `IAuthService` it calls; each `payload` entry overrides the request or response schema of one route. */\nexport type TDefineAuthControllerOpts = {\n restPath?: string;\n serviceKey: TBindingKey<IAuthService>;\n requireAuthenticatedSignUp?: boolean;\n payload?: {\n signIn?: {\n request: { schema: TAnyObjectSchema };\n response: { schema: TAnyObjectSchema };\n };\n signUp?: {\n request: { schema: TAnyObjectSchema };\n response: { schema: TAnyObjectSchema };\n };\n changePassword?: {\n request: { schema?: TAnyObjectSchema };\n response: { schema: TAnyObjectSchema };\n };\n refreshToken?: {\n response: { schema: TAnyObjectSchema };\n };\n getUserInformation?: {\n response: { schema: TAnyObjectSchema };\n };\n };\n};\n\n/** REST options of the authenticate component: `controllerOpts` is required when `useAuthController` is `true`. */\nexport type TAuthenticationRestOptions = {} & (\n | { useAuthController?: false | undefined }\n | {\n useAuthController: true;\n controllerOpts: TDefineAuthControllerOpts;\n }\n);\n"]}
@@ -1,9 +1,9 @@
1
1
  import type { TContext } from '../../../../controllers/common/types/index.js';
2
2
  import type { TNullable, ValueOrPromise } from '@venizia/ignis-helpers/common';
3
+ import type { TTrustedOrigin } from '@venizia/ignis-helpers/core';
3
4
  import type { Env } from 'hono';
4
5
  import type { JWTPayload } from 'jose';
5
6
  import type { TJWKSKeyDriver, TJWKSKeyFormat } from '../constants/index.js';
6
- import type { IJWKSHosts } from './jwt.js';
7
7
  import type { IAuthUser } from './strategy.js';
8
8
  /**
9
9
  * The request binding, following RFC 9449's `htm`/`htu`. A captured assertion cannot be replayed
@@ -91,8 +91,8 @@ export interface IServiceAuthOptions<E extends Env = Env> {
91
91
  cacheMaxAgeMs?: number;
92
92
  /** @default 30_000 */
93
93
  cooldownMs?: number;
94
- /** Exact hosts (name, IP or bracketed IPv6, each with an optional `:port`) that may serve a caller's key set over `http:`. Unset means `https:` or loopback only. */
95
- hosts?: IJWKSHosts;
94
+ /** Exact origins (`http://identity-service`, `http://10.0.0.5:8080`) that may serve a caller's key set over `http:`. Unset means `https:` or loopback only. */
95
+ trusted?: TTrustedOrigin[];
96
96
  };
97
97
  /**
98
98
  * WHO a verified assertion acts as. The framework has already proven the caller; this only maps a
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/types/service.ts"],"names":[],"mappings":"","sourcesContent":["import type { TContext } from '@/base/controllers/common/types';\nimport type { TNullable, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { Env } from 'hono';\nimport type { JWTPayload } from 'jose';\nimport type { TJWKSKeyDriver, TJWKSKeyFormat } from '../constants';\nimport type { IJWKSHosts } from './jwt';\nimport type { IAuthUser } from './strategy';\n\n/**\n * The request binding, following RFC 9449's `htm`/`htu`. A captured assertion cannot be replayed\n * against a different method or path.\n *\n * `htu` is the percent-ENCODED pathname on both ends. Compare it against\n * `new URL(context.req.url).pathname`, never `context.req.path` - Hono hands that one back DECODED,\n * so any route carrying a space or a non-ASCII slug would never match what the caller signed.\n */\nexport interface IServiceAssertionClaims extends JWTPayload {\n htm: string;\n htu: string;\n}\n\n/**\n * One entry in the caller allowlist: the JWKS url, or that url plus settings for this caller alone.\n */\nexport type TServiceCallerEntry =\n | string\n | {\n jwksUrl: string;\n /** Widens the accepted age for THIS caller only. Falls back to the service-wide setting. */\n acceptMaxAgeSeconds?: number;\n };\n\n/** Service-to-service authentication: an Ed25519 assertion per request, verified against the caller's JWKS. */\nexport interface IServiceAuthOptions<E extends Env = Env> {\n /** What this service calls itself: the `iss` it stamps, and the `aud` it demands. */\n name: string;\n\n /**\n * Present only on a service that CALLS OUT. Absent means verify-only, and no certs route is\n * mounted - which is the common case, since most services are called and never call.\n */\n keys?: {\n driver: TJWKSKeyDriver;\n format: TJWKSKeyFormat;\n /** PEM or JWK by `format`; content for the `text` driver, a path for `file`. */\n private: string;\n public: string;\n kid?: string;\n };\n\n /**\n * Caller name to its JWKS url. THIS IS ALSO THE ALLOWLIST - a name absent from the map cannot\n * call, and an empty map correctly allows nobody.\n *\n * The bare-string form is the common case. The object form exists to widen the accepted age for\n * ONE caller: a nightly batch may legitimately need more slack than an interactive service, and\n * granting it per caller keeps the concession named and visible in config.\n */\n callers?: Record<string, TServiceCallerEntry>;\n\n /** Where the certs route is mounted. */\n rest?: {\n /** @default '/svc-certs' */\n path: string;\n };\n\n /**\n * How long the assertions this service MINTS stay valid. Only meaningful where `keys` is set.\n *\n * @default 60\n */\n signLifetimeSeconds?: number;\n\n /**\n * The oldest assertion this service ACCEPTS, measured from `iat`.\n *\n * Deliberately separate from `signLifetimeSeconds`, and deliberately not requestable by the\n * caller. The caller already controls `exp` - it signs the token - so this is the only bound that\n * survives a compromised caller. A per-caller override belongs in {@link callers}, never in the\n * assertion.\n *\n * Composes with `clockToleranceSeconds`: the real acceptance window is the sum of the two.\n *\n * @default 60\n */\n acceptMaxAgeSeconds?: number;\n\n /**\n * Clock skew allowance. A SECURITY knob, not an operational one.\n *\n * Its job is the future case: two machines never agree to the second, and without it a caller one\n * second ahead is refused outright. But it also widens the REPLAY window second for second - a\n * callee accepting an `iat` 5s in its own future keeps accepting that token for the rest of the\n * window too. Measured at the defaults: 65s accepted on our clock, 70s of wall-clock life for a\n * capture minted by a caller running the full tolerance fast.\n *\n * @default 5\n */\n clockToleranceSeconds?: number;\n\n jwks?: {\n /** @default 600_000 */\n cacheMaxAgeMs?: number;\n\n /** @default 30_000 */\n cooldownMs?: number;\n\n /** Exact hosts (name, IP or bracketed IPv6, each with an optional `:port`) that may serve a caller's key set over `http:`. Unset means `https:` or loopback only. */\n hosts?: IJWKSHosts;\n };\n\n /**\n * WHO a verified assertion acts as. The framework has already proven the caller; this only maps a\n * caller name onto an application principal. Return `null` to refuse a caller the allowlist\n * admits but the application does not recognise.\n */\n resolvePrincipal: (opts: {\n issuer: string;\n context: TContext<E, string>;\n }) => ValueOrPromise<TNullable<IAuthUser>>;\n}\n"]}
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/types/service.ts"],"names":[],"mappings":"","sourcesContent":["import type { TContext } from '@/base/controllers/common/types';\nimport type { TNullable, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { TTrustedOrigin } from '@venizia/ignis-helpers/core';\nimport type { Env } from 'hono';\nimport type { JWTPayload } from 'jose';\nimport type { TJWKSKeyDriver, TJWKSKeyFormat } from '../constants';\nimport type { IAuthUser } from './strategy';\n\n/**\n * The request binding, following RFC 9449's `htm`/`htu`. A captured assertion cannot be replayed\n * against a different method or path.\n *\n * `htu` is the percent-ENCODED pathname on both ends. Compare it against\n * `new URL(context.req.url).pathname`, never `context.req.path` - Hono hands that one back DECODED,\n * so any route carrying a space or a non-ASCII slug would never match what the caller signed.\n */\nexport interface IServiceAssertionClaims extends JWTPayload {\n htm: string;\n htu: string;\n}\n\n/**\n * One entry in the caller allowlist: the JWKS url, or that url plus settings for this caller alone.\n */\nexport type TServiceCallerEntry =\n | string\n | {\n jwksUrl: string;\n /** Widens the accepted age for THIS caller only. Falls back to the service-wide setting. */\n acceptMaxAgeSeconds?: number;\n };\n\n/** Service-to-service authentication: an Ed25519 assertion per request, verified against the caller's JWKS. */\nexport interface IServiceAuthOptions<E extends Env = Env> {\n /** What this service calls itself: the `iss` it stamps, and the `aud` it demands. */\n name: string;\n\n /**\n * Present only on a service that CALLS OUT. Absent means verify-only, and no certs route is\n * mounted - which is the common case, since most services are called and never call.\n */\n keys?: {\n driver: TJWKSKeyDriver;\n format: TJWKSKeyFormat;\n /** PEM or JWK by `format`; content for the `text` driver, a path for `file`. */\n private: string;\n public: string;\n kid?: string;\n };\n\n /**\n * Caller name to its JWKS url. THIS IS ALSO THE ALLOWLIST - a name absent from the map cannot\n * call, and an empty map correctly allows nobody.\n *\n * The bare-string form is the common case. The object form exists to widen the accepted age for\n * ONE caller: a nightly batch may legitimately need more slack than an interactive service, and\n * granting it per caller keeps the concession named and visible in config.\n */\n callers?: Record<string, TServiceCallerEntry>;\n\n /** Where the certs route is mounted. */\n rest?: {\n /** @default '/svc-certs' */\n path: string;\n };\n\n /**\n * How long the assertions this service MINTS stay valid. Only meaningful where `keys` is set.\n *\n * @default 60\n */\n signLifetimeSeconds?: number;\n\n /**\n * The oldest assertion this service ACCEPTS, measured from `iat`.\n *\n * Deliberately separate from `signLifetimeSeconds`, and deliberately not requestable by the\n * caller. The caller already controls `exp` - it signs the token - so this is the only bound that\n * survives a compromised caller. A per-caller override belongs in {@link callers}, never in the\n * assertion.\n *\n * Composes with `clockToleranceSeconds`: the real acceptance window is the sum of the two.\n *\n * @default 60\n */\n acceptMaxAgeSeconds?: number;\n\n /**\n * Clock skew allowance. A SECURITY knob, not an operational one.\n *\n * Its job is the future case: two machines never agree to the second, and without it a caller one\n * second ahead is refused outright. But it also widens the REPLAY window second for second - a\n * callee accepting an `iat` 5s in its own future keeps accepting that token for the rest of the\n * window too. Measured at the defaults: 65s accepted on our clock, 70s of wall-clock life for a\n * capture minted by a caller running the full tolerance fast.\n *\n * @default 5\n */\n clockToleranceSeconds?: number;\n\n jwks?: {\n /** @default 600_000 */\n cacheMaxAgeMs?: number;\n\n /** @default 30_000 */\n cooldownMs?: number;\n\n /** Exact origins (`http://identity-service`, `http://10.0.0.5:8080`) that may serve a caller's key set over `http:`. Unset means `https:` or loopback only. */\n trusted?: TTrustedOrigin[];\n };\n\n /**\n * WHO a verified assertion acts as. The framework has already proven the caller; this only maps a\n * caller name onto an application principal. Return `null` to refuse a caller the allowlist\n * admits but the application does not recognise.\n */\n resolvePrincipal: (opts: {\n issuer: string;\n context: TContext<E, string>;\n }) => ValueOrPromise<TNullable<IAuthUser>>;\n}\n"]}
@@ -1,13 +1,12 @@
1
1
  import type { TContext } from '../../../../controllers/common/types/index.js';
2
2
  import type { IdType } from '../../../../models/common/index.js';
3
- import type { AnyObject } from '@venizia/ignis-helpers/common';
4
3
  import type { Env, MiddlewareHandler } from 'hono';
5
4
  import type { TChangePasswordRequest, TSignInRequest, TSignUpRequest } from '../../../models/requests/index.js';
6
5
  import type { TAuthMode } from '../constants/index.js';
7
6
  /** The authenticated identity a strategy returns and the request context stores. Carries at least `userId`. */
8
7
  export interface IAuthUser {
9
8
  userId: IdType;
10
- [extra: string | symbol]: any;
9
+ [extra: string | symbol]: unknown;
11
10
  }
12
11
  /** A strategy that authenticates a request. `name` is the name it is registered under; `authenticate` returns the user or throws. */
13
12
  export interface IAuthenticationStrategy<E extends Env = Env> {
@@ -21,7 +20,7 @@ export type TAuthenticateFn<RouteEnv extends Env = Env> = (opts: {
21
20
  mode?: TAuthMode;
22
21
  }) => MiddlewareHandler<RouteEnv>;
23
22
  /** The service behind the auth controller routes. `getUserInformation` and `refreshToken` are optional. The type parameters set each route's request and response types. */
24
- export interface IAuthService<E extends Env = Env, SIRQ extends TSignInRequest = TSignInRequest, SIRS = AnyObject, SURQ extends TSignUpRequest = TSignUpRequest, SURS = AnyObject, CPRQ extends TChangePasswordRequest = TChangePasswordRequest, CPRS = AnyObject, UIRQ = AnyObject, UIRS = AnyObject, RTRS = AnyObject> {
23
+ export interface IAuthService<E extends Env = Env, SIRQ extends TSignInRequest = TSignInRequest, SIRS = Record<string, unknown>, SURQ extends TSignUpRequest = TSignUpRequest, SURS = Record<string, unknown>, CPRQ extends TChangePasswordRequest = TChangePasswordRequest, CPRS = Record<string, unknown>, UIRQ = Record<string, unknown>, UIRS = Record<string, unknown>, RTRS = Record<string, unknown>> {
25
24
  signIn(context: TContext<E>, opts: SIRQ): Promise<SIRS>;
26
25
  signUp(context: TContext<E>, opts: SURQ): Promise<SURS>;
27
26
  changePassword(context: TContext<E>, opts: CPRQ): Promise<CPRS>;
@@ -1 +1 @@
1
- {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/types/strategy.ts"],"names":[],"mappings":"","sourcesContent":["import type { TContext } from '@/base/controllers/common/types';\nimport type { IdType } from '@/base/models/common';\nimport type { AnyObject } from '@venizia/ignis-helpers/common';\nimport type { Env, MiddlewareHandler } from 'hono';\nimport type {\n TChangePasswordRequest,\n TSignInRequest,\n TSignUpRequest,\n} from '../../../models/requests';\nimport type { TAuthMode } from '../constants';\n\n/** The authenticated identity a strategy returns and the request context stores. Carries at least `userId`. */\nexport interface IAuthUser {\n userId: IdType;\n [extra: string | symbol]: any;\n}\n\n/** A strategy that authenticates a request. `name` is the name it is registered under; `authenticate` returns the user or throws. */\nexport interface IAuthenticationStrategy<E extends Env = Env> {\n name: string;\n authenticate(context: TContext<E, string>): Promise<IAuthUser>;\n}\n\n/** Builds the authentication middleware for the listed strategy names. */\nexport type TAuthenticateFn<RouteEnv extends Env = Env> = (opts: {\n strategies: string[];\n\n /** @default 'any' */\n mode?: TAuthMode;\n}) => MiddlewareHandler<RouteEnv>;\n\n/** The service behind the auth controller routes. `getUserInformation` and `refreshToken` are optional. The type parameters set each route's request and response types. */\nexport interface IAuthService<\n E extends Env = Env,\n // SignIn types\n SIRQ extends TSignInRequest = TSignInRequest,\n SIRS = AnyObject,\n // SignUp types\n SURQ extends TSignUpRequest = TSignUpRequest,\n SURS = AnyObject,\n // ChangePassword types\n CPRQ extends TChangePasswordRequest = TChangePasswordRequest,\n CPRS = AnyObject,\n // UserInformation types\n UIRQ = AnyObject,\n UIRS = AnyObject,\n // RefreshToken types\n RTRS = AnyObject,\n> {\n signIn(context: TContext<E>, opts: SIRQ): Promise<SIRS>;\n signUp(context: TContext<E>, opts: SURQ): Promise<SURS>;\n changePassword(context: TContext<E>, opts: CPRQ): Promise<CPRS>;\n getUserInformation?(context: TContext<E>, opts: UIRQ): Promise<UIRS>;\n refreshToken?(context: TContext<E>): Promise<RTRS>;\n}\n"]}
1
+ {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/types/strategy.ts"],"names":[],"mappings":"","sourcesContent":["import type { TContext } from '@/base/controllers/common/types';\nimport type { IdType } from '@/base/models/common';\nimport type { Env, MiddlewareHandler } from 'hono';\nimport type {\n TChangePasswordRequest,\n TSignInRequest,\n TSignUpRequest,\n} from '../../../models/requests';\nimport type { TAuthMode } from '../constants';\n\n/** The authenticated identity a strategy returns and the request context stores. Carries at least `userId`. */\nexport interface IAuthUser {\n userId: IdType;\n [extra: string | symbol]: unknown;\n}\n\n/** A strategy that authenticates a request. `name` is the name it is registered under; `authenticate` returns the user or throws. */\nexport interface IAuthenticationStrategy<E extends Env = Env> {\n name: string;\n authenticate(context: TContext<E, string>): Promise<IAuthUser>;\n}\n\n/** Builds the authentication middleware for the listed strategy names. */\nexport type TAuthenticateFn<RouteEnv extends Env = Env> = (opts: {\n strategies: string[];\n\n /** @default 'any' */\n mode?: TAuthMode;\n}) => MiddlewareHandler<RouteEnv>;\n\n/** The service behind the auth controller routes. `getUserInformation` and `refreshToken` are optional. The type parameters set each route's request and response types. */\nexport interface IAuthService<\n E extends Env = Env,\n // SignIn types\n SIRQ extends TSignInRequest = TSignInRequest,\n SIRS = Record<string, unknown>,\n // SignUp types\n SURQ extends TSignUpRequest = TSignUpRequest,\n SURS = Record<string, unknown>,\n // ChangePassword types\n CPRQ extends TChangePasswordRequest = TChangePasswordRequest,\n CPRS = Record<string, unknown>,\n // UserInformation types\n UIRQ = Record<string, unknown>,\n UIRS = Record<string, unknown>,\n // RefreshToken types\n RTRS = Record<string, unknown>,\n> {\n signIn(context: TContext<E>, opts: SIRQ): Promise<SIRS>;\n signUp(context: TContext<E>, opts: SURQ): Promise<SURS>;\n changePassword(context: TContext<E>, opts: CPRQ): Promise<CPRS>;\n getUserInformation?(context: TContext<E>, opts: UIRQ): Promise<UIRS>;\n refreshToken?(context: TContext<E>): Promise<RTRS>;\n}\n"]}
@@ -37,7 +37,7 @@ export declare class AuthenticationStrategyRegistry extends AbstractAuthRegistry
37
37
  *
38
38
  * The framework does NOT call this - it reports instead. A hard failure cannot be the default
39
39
  * here: a route listing several strategies in ANY mode tolerates one that does not resolve, and
40
- * `AuthControllerFactory.define` hard-codes `'jwt'` on four of its routes, so an application that
40
+ * `AuthControllerFactory.build` hard-codes `'jwt'` on four of its routes, so an application that
41
41
  * registers its JWT strategy under a different name works today and would stop booting.
42
42
  */
43
43
  assertRegistered(opts: {
@@ -50,7 +50,7 @@ export class AuthenticationStrategyRegistry extends AbstractAuthRegistry {
50
50
  *
51
51
  * The framework does NOT call this - it reports instead. A hard failure cannot be the default
52
52
  * here: a route listing several strategies in ANY mode tolerates one that does not resolve, and
53
- * `AuthControllerFactory.define` hard-codes `'jwt'` on four of its routes, so an application that
53
+ * `AuthControllerFactory.build` hard-codes `'jwt'` on four of its routes, so an application that
54
54
  * registers its JWT strategy under a different name works today and would stop booting.
55
55
  */
56
56
  assertRegistered(opts) {
@@ -1 +1 @@
1
- {"version":3,"file":"strategy-registry.js","sourceRoot":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AAC","sourcesContent":["import type { Container } from '@/helpers/inversion/container';\nimport { SingletonRealm } from '@/helpers/singleton-realm';\nimport type { TClass } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { AbstractAuthRegistry } from '../../base';\nimport type { IAuthenticationStrategy } from '../common';\nimport { Authentication } from '../common';\n\n/** Registry of authentication strategies by name. Use `getInstance()` for the shared one; register application strategies before controllers are bound. */\nexport class AuthenticationStrategyRegistry extends AbstractAuthRegistry<IAuthenticationStrategy> {\n static readonly SINGLETON_REAL_KEY = 'authentication-strategy-registry';\n\n constructor() {\n super({ scope: AuthenticationStrategyRegistry.name });\n }\n\n static getInstance() {\n return SingletonRealm.resolve({\n key: AuthenticationStrategyRegistry.SINGLETON_REAL_KEY,\n create: () => new AuthenticationStrategyRegistry(),\n });\n }\n\n protected getBindingPrefix(): string {\n return Authentication.AUTHENTICATION_STRATEGY;\n }\n\n register(opts: {\n container: Container;\n strategies: { strategy: TClass<IAuthenticationStrategy>; name: string }[];\n }) {\n const { container, strategies } = opts;\n\n for (const { strategy, name } of strategies) {\n this.registerDescriptor({ container, target: strategy, name });\n }\n\n return this;\n }\n\n resolveStrategy(opts: { name: string }): IAuthenticationStrategy {\n return this.resolveDescriptor(opts);\n }\n\n /**\n * The names on this list that no registered strategy answers to.\n *\n * An EMPTY list yields nothing - it is the framework's own encoding of\n * `authenticate: { skip: true }`, so treating it as a problem would flag every public route.\n *\n * Nothing is reported while the registry is empty. Route configs are built during\n * `registerControllers()`, after `preConfigure()` and `registerComponents()`, so a real\n * application has registered by then; an empty registry means this is running outside that\n * lifecycle - a unit test on a controller - where no name could resolve either way.\n */\n findUnregistered(opts: { names: string[] }): string[] {\n const { names } = opts;\n\n if (names.length === 0 || this.descriptors.size === 0) {\n return [];\n }\n\n return names.filter((name) => !this.has({ name }));\n }\n\n /**\n * Refuses to continue past an unregistered name. For an APPLICATION's own startup check.\n *\n * The framework does NOT call this - it reports instead. A hard failure cannot be the default\n * here: a route listing several strategies in ANY mode tolerates one that does not resolve, and\n * `AuthControllerFactory.define` hard-codes `'jwt'` on four of its routes, so an application that\n * registers its JWT strategy under a different name works today and would stop booting.\n */\n assertRegistered(opts: { names: string[]; scope?: string }): void {\n const { names, scope = 'route' } = opts;\n\n const unregistered = this.findUnregistered({ names });\n\n if (unregistered.length === 0) {\n return;\n }\n\n throw getError({\n message: `[${scope}] Unknown authentication strategy | unregistered: ${unregistered.join(', ')} | registered: ${this.getNames().join(', ')} | register it with AuthenticationStrategyRegistry.register() before controllers are bound`,\n });\n }\n\n /**\n * Names an unregistered strategy at boot, at a level someone sees. Never throws.\n *\n * This is what replaces the guard the open `TAuthStrategy` gave up: `resolveStrategy` throws at\n * request time, the provider's ANY mode swallows it at DEBUG, and the route 401s with nothing to\n * explain why.\n */\n reportUnregistered(opts: { names: string[]; scope?: string }): void {\n const { names, scope = 'route' } = opts;\n\n const unregistered = this.findUnregistered({ names });\n\n if (unregistered.length === 0) {\n return;\n }\n\n this.logger\n .for(this.reportUnregistered.name)\n .error(\n '[%s] Unknown authentication strategy - requests relying on it cannot authenticate | unregistered: %s | registered: %s',\n scope,\n unregistered.join(', '),\n this.getNames().join(', '),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"strategy-registry.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authenticate/strategies/strategy-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,2JAA2J;AAC3J,MAAM,OAAO,8BAA+B,SAAQ,oBAA6C;aAC/E,uBAAkB,GAAG,kCAAkC,CAAC;IAExE;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,8BAA8B,CAAC,IAAI,EAAE,CAAC,CAAC;IACx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QAEtD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,IAAI,KAAK,qDAAqD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,4FAA4F;SACvO,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,kBAAkB,CAAC,IAAyC;QAC1D,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;QAExC,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAEtD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAI,CAAC,MAAM;aACR,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;aACjC,KAAK,CACJ,uHAAuH,EACvH,KAAK,EACL,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EACvB,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAC3B,CAAC;IACN,CAAC","sourcesContent":["import type { Container } from '@/helpers/inversion/container';\nimport { SingletonRealm } from '@/helpers/singleton-realm';\nimport type { TClass } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { AbstractAuthRegistry } from '../../base';\nimport type { IAuthenticationStrategy } from '../common';\nimport { Authentication } from '../common';\n\n/** Registry of authentication strategies by name. Use `getInstance()` for the shared one; register application strategies before controllers are bound. */\nexport class AuthenticationStrategyRegistry extends AbstractAuthRegistry<IAuthenticationStrategy> {\n static readonly SINGLETON_REAL_KEY = 'authentication-strategy-registry';\n\n constructor() {\n super({ scope: AuthenticationStrategyRegistry.name });\n }\n\n static getInstance() {\n return SingletonRealm.resolve({\n key: AuthenticationStrategyRegistry.SINGLETON_REAL_KEY,\n create: () => new AuthenticationStrategyRegistry(),\n });\n }\n\n protected getBindingPrefix(): string {\n return Authentication.AUTHENTICATION_STRATEGY;\n }\n\n register(opts: {\n container: Container;\n strategies: { strategy: TClass<IAuthenticationStrategy>; name: string }[];\n }) {\n const { container, strategies } = opts;\n\n for (const { strategy, name } of strategies) {\n this.registerDescriptor({ container, target: strategy, name });\n }\n\n return this;\n }\n\n resolveStrategy(opts: { name: string }): IAuthenticationStrategy {\n return this.resolveDescriptor(opts);\n }\n\n /**\n * The names on this list that no registered strategy answers to.\n *\n * An EMPTY list yields nothing - it is the framework's own encoding of\n * `authenticate: { skip: true }`, so treating it as a problem would flag every public route.\n *\n * Nothing is reported while the registry is empty. Route configs are built during\n * `registerControllers()`, after `preConfigure()` and `registerComponents()`, so a real\n * application has registered by then; an empty registry means this is running outside that\n * lifecycle - a unit test on a controller - where no name could resolve either way.\n */\n findUnregistered(opts: { names: string[] }): string[] {\n const { names } = opts;\n\n if (names.length === 0 || this.descriptors.size === 0) {\n return [];\n }\n\n return names.filter((name) => !this.has({ name }));\n }\n\n /**\n * Refuses to continue past an unregistered name. For an APPLICATION's own startup check.\n *\n * The framework does NOT call this - it reports instead. A hard failure cannot be the default\n * here: a route listing several strategies in ANY mode tolerates one that does not resolve, and\n * `AuthControllerFactory.build` hard-codes `'jwt'` on four of its routes, so an application that\n * registers its JWT strategy under a different name works today and would stop booting.\n */\n assertRegistered(opts: { names: string[]; scope?: string }): void {\n const { names, scope = 'route' } = opts;\n\n const unregistered = this.findUnregistered({ names });\n\n if (unregistered.length === 0) {\n return;\n }\n\n throw getError({\n message: `[${scope}] Unknown authentication strategy | unregistered: ${unregistered.join(', ')} | registered: ${this.getNames().join(', ')} | register it with AuthenticationStrategyRegistry.register() before controllers are bound`,\n });\n }\n\n /**\n * Names an unregistered strategy at boot, at a level someone sees. Never throws.\n *\n * This is what replaces the guard the open `TAuthStrategy` gave up: `resolveStrategy` throws at\n * request time, the provider's ANY mode swallows it at DEBUG, and the route 401s with nothing to\n * explain why.\n */\n reportUnregistered(opts: { names: string[]; scope?: string }): void {\n const { names, scope = 'route' } = opts;\n\n const unregistered = this.findUnregistered({ names });\n\n if (unregistered.length === 0) {\n return;\n }\n\n this.logger\n .for(this.reportUnregistered.name)\n .error(\n '[%s] Unknown authentication strategy - requests relying on it cannot authenticate | unregistered: %s | registered: %s',\n scope,\n unregistered.join(', '),\n this.getNames().join(', '),\n );\n }\n}\n"]}
@@ -1,7 +1,10 @@
1
+ import { type TBindingKey } from '../../../../../helpers/inversion/index.js';
2
+ import type { IAuthorizeOptions } from '../types/index.js';
1
3
  /** Container binding keys for the authorize options, the always-allow roles, and (through `enforcerOptions`) the options of one named enforcer. */
2
4
  export declare class AuthorizeBindingKeys {
3
- static readonly OPTIONS = "@app/authorize/options";
4
- static readonly ALWAYS_ALLOW_ROLES = "@app/authorize/always-allow-roles";
5
- static enforcerOptions(name: string): string;
5
+ static readonly OPTIONS: TBindingKey<IAuthorizeOptions>;
6
+ static readonly ALWAYS_ALLOW_ROLES: TBindingKey<string[]>;
7
+ /** The options of the enforcer named `name`; their type is the enforcer's, so the caller names it: `enforcerOptions<ICasbinOptions>(name)`. */
8
+ static enforcerOptions<T = unknown>(name: string): TBindingKey<T>;
6
9
  }
7
10
  //# sourceMappingURL=binding-keys.d.ts.map
@@ -1,9 +1,14 @@
1
+ import { BindingKeys } from '../../../../../helpers/inversion/index.js';
1
2
  /** Container binding keys for the authorize options, the always-allow roles, and (through `enforcerOptions`) the options of one named enforcer. */
2
3
  export class AuthorizeBindingKeys {
3
- static { this.OPTIONS = '@app/authorize/options'; }
4
- static { this.ALWAYS_ALLOW_ROLES = '@app/authorize/always-allow-roles'; }
4
+ static { this.OPTIONS = BindingKeys.build({ key: '@app/authorize/options' }); }
5
+ static { this.ALWAYS_ALLOW_ROLES = BindingKeys.build({
6
+ key: '@app/authorize/always-allow-roles',
7
+ }); }
8
+ /** The options of the enforcer named `name`; their type is the enforcer's, so the caller names it: `enforcerOptions<ICasbinOptions>(name)`. */
5
9
  static enforcerOptions(name) {
6
- return `@app/authorize/enforcers/${name}/options`;
10
+ // A key built for `unknown` is the key of any `T`: the brand is bivariant.
11
+ return BindingKeys.build({ key: `@app/authorize/enforcers/${name}/options` });
7
12
  }
8
13
  }
9
14
  //# sourceMappingURL=binding-keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding-keys.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authorize/common/constants/binding-keys.ts"],"names":[],"mappings":"AAAA,mJAAmJ;AACnJ,MAAM,OAAO,oBAAoB;aACf,YAAO,GAAG,wBAAwB,CAAC;aACnC,uBAAkB,GAAG,mCAAmC,CAAC;IAEzE,MAAM,CAAC,eAAe,CAAC,IAAY;QACjC,OAAO,4BAA4B,IAAI,UAAU,CAAC;IACpD,CAAC","sourcesContent":["/** Container binding keys for the authorize options, the always-allow roles, and (through `enforcerOptions`) the options of one named enforcer. */\nexport class AuthorizeBindingKeys {\n static readonly OPTIONS = '@app/authorize/options';\n static readonly ALWAYS_ALLOW_ROLES = '@app/authorize/always-allow-roles';\n\n static enforcerOptions(name: string): string {\n return `@app/authorize/enforcers/${name}/options`;\n }\n}\n"]}
1
+ {"version":3,"file":"binding-keys.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authorize/common/constants/binding-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoB,MAAM,qBAAqB,CAAC;AAGpE,mJAAmJ;AACnJ,MAAM,OAAO,oBAAoB;aACf,YAAO,GAAG,WAAW,CAAC,KAAK,CAAoB,EAAE,GAAG,EAAE,wBAAwB,EAAE,CAAC,CAAC;aAClF,uBAAkB,GAAG,WAAW,CAAC,KAAK,CAAW;QAC/D,GAAG,EAAE,mCAAmC;KACzC,CAAC,CAAC;IAEH,+IAA+I;IAC/I,MAAM,CAAC,eAAe,CAAc,IAAY;QAC9C,2EAA2E;QAC3E,OAAO,WAAW,CAAC,KAAK,CAAU,EAAE,GAAG,EAAE,4BAA4B,IAAI,UAAU,EAAE,CAAC,CAAC;IACzF,CAAC","sourcesContent":["import { BindingKeys, type TBindingKey } from '@/helpers/inversion';\nimport type { IAuthorizeOptions } from '../types';\n\n/** Container binding keys for the authorize options, the always-allow roles, and (through `enforcerOptions`) the options of one named enforcer. */\nexport class AuthorizeBindingKeys {\n static readonly OPTIONS = BindingKeys.build<IAuthorizeOptions>({ key: '@app/authorize/options' });\n static readonly ALWAYS_ALLOW_ROLES = BindingKeys.build<string[]>({\n key: '@app/authorize/always-allow-roles',\n });\n\n /** The options of the enforcer named `name`; their type is the enforcer's, so the caller names it: `enforcerOptions<ICasbinOptions>(name)`. */\n static enforcerOptions<T = unknown>(name: string): TBindingKey<T> {\n // A key built for `unknown` is the key of any `T`: the brand is bivariant.\n return BindingKeys.build<unknown>({ key: `@app/authorize/enforcers/${name}/options` });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"enforcer-registry.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authorize/enforcers/enforcer-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAQlD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEhE,qKAAqK;AACrK,MAAM,OAAO,6BAA8B,SAAQ,oBAA4C;aAC7E,uBAAkB,GAAG,iCAAiC,AAApC,CAAqC;IAWvE;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,6BAA6B,CAAC,IAAI,EAAE,CAAC,CAAC;QALvD;iHACyG;QACjG,uBAAkB,GAAiC,IAAI,CAAC;QAI9D,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,qBAAqB,GAAG,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CAAC;IAED,qEAAqE;IACrE,UAAU,CAAC,IAAoC;QAC7C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC;IACzC,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,kBAAkB,CAAC;QACjC,CAAC;QAED,KAAK,MAAM,CAAC,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAC5C,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;YAC/B,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAoB;gBAC/C,GAAG,EAAE,oBAAoB,CAAC,OAAO;gBACjC,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;YAEH,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC","sourcesContent":["import { SingletonRealm } from '@/helpers/singleton-realm';\nimport type { Container } from '@/helpers/inversion/container';\nimport type { TClass, TNullable } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { IAuthUser } from '../../authenticate/common/types';\nimport { AbstractAuthRegistry } from '../../base';\nimport type {\n AuthorizationEnforcerTypes,\n IAuthorizationEnforcer,\n IAuthorizationUser,\n IAuthorizeOptions,\n ICasbinEnforcerOptions,\n} from '../common';\nimport { Authorization, AuthorizeBindingKeys } from '../common';\n\n/** Singleton registry of named authorization enforcers. An enforcer is configured once, on first resolve; concurrent first resolves share one `configure()` call. */\nexport class AuthorizationEnforcerRegistry extends AbstractAuthRegistry<IAuthorizationEnforcer> {\n static readonly SINGLETON_REAL_KEY = 'authorization-enforcer-registry';\n\n private configuredEnforcers: Set<string>;\n\n /** In-flight `configure()` calls, so concurrent first requests share one warmup instead of racing. */\n private pendingConfigurations: Map<string, Promise<void>>;\n\n /** Set by AuthorizeComponent from the application container. Held here because the descriptor scan\n * below sees only registered enforcers, and `defaultDecision` has to be readable when there are none. */\n private applicationOptions: TNullable<IAuthorizeOptions> = null;\n\n constructor() {\n super({ scope: AuthorizationEnforcerRegistry.name });\n this.configuredEnforcers = new Set();\n this.pendingConfigurations = new Map();\n }\n\n static getInstance() {\n return SingletonRealm.resolve({\n key: AuthorizationEnforcerRegistry.SINGLETON_REAL_KEY,\n create: () => new AuthorizationEnforcerRegistry(),\n });\n }\n\n override reset(): void {\n super.reset();\n this.configuredEnforcers.clear();\n this.pendingConfigurations.clear();\n this.applicationOptions = null;\n }\n\n protected getBindingPrefix(): string {\n return Authorization.ENFORCER;\n }\n\n register(opts: {\n container: Container;\n enforcers: Array<\n | {\n enforcer: TClass<IAuthorizationEnforcer>;\n name: string;\n type: typeof AuthorizationEnforcerTypes.CASBIN;\n options?: ICasbinEnforcerOptions;\n }\n | {\n enforcer: TClass<IAuthorizationEnforcer>;\n name: string;\n type: typeof AuthorizationEnforcerTypes.CUSTOM;\n options?: unknown;\n }\n >;\n }) {\n const { container, enforcers } = opts;\n\n const names = enforcers.map((e) => e.name);\n const duplicateNames = names.filter((n, i) => names.indexOf(n) !== i);\n\n if (duplicateNames.length) {\n throw getError({\n message: `[AuthorizationEnforcerRegistry] Duplicate enforcer name(s): ${[...new Set(duplicateNames)].join(', ')}`,\n });\n }\n\n for (const { enforcer, name, options } of enforcers) {\n if (this.descriptors.has(name)) {\n throw getError({\n message: `[AuthorizationEnforcerRegistry] Enforcer already registered: ${name}`,\n });\n }\n\n this.registerDescriptor({ container, target: enforcer, name });\n\n if (options) {\n container.bind({ key: AuthorizeBindingKeys.enforcerOptions(name) }).toValue(options);\n }\n }\n\n return this;\n }\n\n hasEnforcers(): boolean {\n return this.descriptors.size > 0;\n }\n\n getDefaultEnforcerName(): string {\n return this.getDefaultName();\n }\n\n /**\n * The PROMISE is memoised, not just the completed flag.\n *\n * `configure()` yields (it dynamic-imports casbin), and the flag was only set after the await -\n * so a burst of first requests each saw an unconfigured enforcer and each built a full pool.\n * Measured: 40 concurrent first requests produced 40 configure() calls and 640 enforcers.\n * The entry is dropped on rejection so a failed warmup does not poison every later request.\n */\n async resolveEnforcer(opts: { name: string }): Promise<IAuthorizationEnforcer> {\n const enforcer = this.resolveDescriptor(opts);\n\n if (this.configuredEnforcers.has(opts.name)) {\n return enforcer;\n }\n\n const inFlight = this.pendingConfigurations.get(opts.name);\n\n if (inFlight) {\n await inFlight;\n\n return enforcer;\n }\n\n // `Promise.resolve` because `configure()` is declared `ValueOrPromise<void>` - a synchronous\n // implementation returns plain `void`, which has no `.then`.\n const pending = Promise.resolve(enforcer.configure())\n .then(() => {\n this.configuredEnforcers.add(opts.name);\n })\n .finally(() => {\n this.pendingConfigurations.delete(opts.name);\n });\n\n this.pendingConfigurations.set(opts.name, pending);\n\n await pending;\n\n return enforcer;\n }\n\n /** Drop a user's cached policies on the resolved enforcer. Lazy - next request rebuilds. */\n async invalidateUserCache(opts: {\n user: IAuthorizationUser;\n enforcerName?: string;\n }): Promise<{ invalidatedKeys: number }> {\n const name = opts.enforcerName ?? this.getDefaultEnforcerName();\n const enforcer = await this.resolveEnforcer({ name });\n\n // Cache management is an optional IAuthorizationEnforcer capability - feature-detect it.\n if (typeof enforcer.invalidateUserCache !== 'function') {\n throw getError({\n message: `[AuthorizationEnforcerRegistry] Enforcer \"${name}\" does not support cache invalidation`,\n });\n }\n\n return enforcer.invalidateUserCache({ user: opts.user });\n }\n\n /** Drop then immediately rebuild + re-cache a user's policies on the resolved enforcer. */\n async rebuildUserCache(opts: {\n user: { principalType: string } & IAuthUser;\n enforcerName?: string;\n }): Promise<{ cacheKey: string; lineCount: number }> {\n const name = opts.enforcerName ?? this.getDefaultEnforcerName();\n const enforcer = await this.resolveEnforcer({ name });\n\n if (typeof enforcer.rebuildUserCache !== 'function') {\n throw getError({\n message: `[AuthorizationEnforcerRegistry] Enforcer \"${name}\" does not support cache invalidation`,\n });\n }\n\n return enforcer.rebuildUserCache({ user: opts.user });\n }\n\n /** Options bound on the application, independent of any enforcer. */\n setOptions(opts: { options: IAuthorizeOptions }): void {\n this.applicationOptions = opts.options;\n }\n\n resolveOptions(): IAuthorizeOptions | undefined {\n if (this.applicationOptions) {\n return this.applicationOptions;\n }\n\n for (const [, metadata] of this.descriptors) {\n const { container } = metadata;\n const options = container.get<IAuthorizeOptions>({\n key: AuthorizeBindingKeys.OPTIONS,\n isOptional: true,\n });\n\n if (options) {\n return options;\n }\n }\n\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"enforcer-registry.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authorize/enforcers/enforcer-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAQlD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEhE,qKAAqK;AACrK,MAAM,OAAO,6BAA8B,SAAQ,oBAA4C;aAC7E,uBAAkB,GAAG,iCAAiC,AAApC,CAAqC;IAWvE;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,6BAA6B,CAAC,IAAI,EAAE,CAAC,CAAC;QALvD;iHACyG;QACjG,uBAAkB,GAAiC,IAAI,CAAC;QAI9D,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,OAAO,cAAc,CAAC,OAAO,CAAC;YAC5B,GAAG,EAAE,6BAA6B,CAAC,kBAAkB;YACrD,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,6BAA6B,EAAE;SAClD,CAAC,CAAC;IACL,CAAC;IAEQ,KAAK;QACZ,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAA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,EAAE,CAAC;YAC5C,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;YAC/B,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC;gBAC5B,GAAG,EAAE,oBAAoB,CAAC,OAAO;gBACjC,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;YAEH,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC","sourcesContent":["import { SingletonRealm } from '@/helpers/singleton-realm';\nimport type { Container } from '@/helpers/inversion/container';\nimport type { TClass, TNullable } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { IAuthUser } from '../../authenticate/common/types';\nimport { AbstractAuthRegistry } from '../../base';\nimport type {\n AuthorizationEnforcerTypes,\n IAuthorizationEnforcer,\n IAuthorizationUser,\n IAuthorizeOptions,\n ICasbinEnforcerOptions,\n} from '../common';\nimport { Authorization, AuthorizeBindingKeys } from '../common';\n\n/** Singleton registry of named authorization enforcers. An enforcer is configured once, on first resolve; concurrent first resolves share one `configure()` call. */\nexport class AuthorizationEnforcerRegistry extends AbstractAuthRegistry<IAuthorizationEnforcer> {\n static readonly SINGLETON_REAL_KEY = 'authorization-enforcer-registry';\n\n private configuredEnforcers: Set<string>;\n\n /** In-flight `configure()` calls, so concurrent first requests share one warmup instead of racing. */\n private pendingConfigurations: Map<string, Promise<void>>;\n\n /** Set by AuthorizeComponent from the application container. Held here because the descriptor scan\n * below sees only registered enforcers, and `defaultDecision` has to be readable when there are none. */\n private applicationOptions: TNullable<IAuthorizeOptions> = null;\n\n constructor() {\n super({ scope: AuthorizationEnforcerRegistry.name });\n this.configuredEnforcers = new Set();\n this.pendingConfigurations = new Map();\n }\n\n static getInstance() {\n return SingletonRealm.resolve({\n key: AuthorizationEnforcerRegistry.SINGLETON_REAL_KEY,\n create: () => new AuthorizationEnforcerRegistry(),\n });\n }\n\n override reset(): void {\n super.reset();\n this.configuredEnforcers.clear();\n this.pendingConfigurations.clear();\n this.applicationOptions = null;\n }\n\n protected getBindingPrefix(): string {\n return Authorization.ENFORCER;\n }\n\n register(opts: {\n container: Container;\n enforcers: Array<\n | {\n enforcer: TClass<IAuthorizationEnforcer>;\n name: string;\n type: typeof AuthorizationEnforcerTypes.CASBIN;\n options?: ICasbinEnforcerOptions;\n }\n | {\n enforcer: TClass<IAuthorizationEnforcer>;\n name: string;\n type: typeof AuthorizationEnforcerTypes.CUSTOM;\n options?: unknown;\n }\n >;\n }) {\n const { container, enforcers } = opts;\n\n const names = enforcers.map((e) => e.name);\n const duplicateNames = names.filter((n, i) => names.indexOf(n) !== i);\n\n if (duplicateNames.length) {\n throw getError({\n message: `[AuthorizationEnforcerRegistry] Duplicate enforcer name(s): ${[...new Set(duplicateNames)].join(', ')}`,\n });\n }\n\n for (const { enforcer, name, options } of enforcers) {\n if (this.descriptors.has(name)) {\n throw getError({\n message: `[AuthorizationEnforcerRegistry] Enforcer already registered: ${name}`,\n });\n }\n\n this.registerDescriptor({ container, target: enforcer, name });\n\n if (options) {\n container.bind({ key: AuthorizeBindingKeys.enforcerOptions(name) }).toValue(options);\n }\n }\n\n return this;\n }\n\n hasEnforcers(): boolean {\n return this.descriptors.size > 0;\n }\n\n getDefaultEnforcerName(): string {\n return this.getDefaultName();\n }\n\n /**\n * The PROMISE is memoised, not just the completed flag.\n *\n * `configure()` yields (it dynamic-imports casbin), and the flag was only set after the await -\n * so a burst of first requests each saw an unconfigured enforcer and each built a full pool.\n * Measured: 40 concurrent first requests produced 40 configure() calls and 640 enforcers.\n * The entry is dropped on rejection so a failed warmup does not poison every later request.\n */\n async resolveEnforcer(opts: { name: string }): Promise<IAuthorizationEnforcer> {\n const enforcer = this.resolveDescriptor(opts);\n\n if (this.configuredEnforcers.has(opts.name)) {\n return enforcer;\n }\n\n const inFlight = this.pendingConfigurations.get(opts.name);\n\n if (inFlight) {\n await inFlight;\n\n return enforcer;\n }\n\n // `Promise.resolve` because `configure()` is declared `ValueOrPromise<void>` - a synchronous\n // implementation returns plain `void`, which has no `.then`.\n const pending = Promise.resolve(enforcer.configure())\n .then(() => {\n this.configuredEnforcers.add(opts.name);\n })\n .finally(() => {\n this.pendingConfigurations.delete(opts.name);\n });\n\n this.pendingConfigurations.set(opts.name, pending);\n\n await pending;\n\n return enforcer;\n }\n\n /** Drop a user's cached policies on the resolved enforcer. Lazy - next request rebuilds. */\n async invalidateUserCache(opts: {\n user: IAuthorizationUser;\n enforcerName?: string;\n }): Promise<{ invalidatedKeys: number }> {\n const name = opts.enforcerName ?? this.getDefaultEnforcerName();\n const enforcer = await this.resolveEnforcer({ name });\n\n // Cache management is an optional IAuthorizationEnforcer capability - feature-detect it.\n if (typeof enforcer.invalidateUserCache !== 'function') {\n throw getError({\n message: `[AuthorizationEnforcerRegistry] Enforcer \"${name}\" does not support cache invalidation`,\n });\n }\n\n return enforcer.invalidateUserCache({ user: opts.user });\n }\n\n /** Drop then immediately rebuild + re-cache a user's policies on the resolved enforcer. */\n async rebuildUserCache(opts: {\n user: { principalType: string } & IAuthUser;\n enforcerName?: string;\n }): Promise<{ cacheKey: string; lineCount: number }> {\n const name = opts.enforcerName ?? this.getDefaultEnforcerName();\n const enforcer = await this.resolveEnforcer({ name });\n\n if (typeof enforcer.rebuildUserCache !== 'function') {\n throw getError({\n message: `[AuthorizationEnforcerRegistry] Enforcer \"${name}\" does not support cache invalidation`,\n });\n }\n\n return enforcer.rebuildUserCache({ user: opts.user });\n }\n\n /** Options bound on the application, independent of any enforcer. */\n setOptions(opts: { options: IAuthorizeOptions }): void {\n this.applicationOptions = opts.options;\n }\n\n resolveOptions(): IAuthorizeOptions | undefined {\n if (this.applicationOptions) {\n return this.applicationOptions;\n }\n\n for (const [, metadata] of this.descriptors) {\n const { container } = metadata;\n const options = container.get({\n key: AuthorizeBindingKeys.OPTIONS,\n isOptional: true,\n });\n\n if (options) {\n return options;\n }\n }\n\n return undefined;\n }\n}\n"]}
@@ -15,7 +15,8 @@ export class RequestDomainResolver {
15
15
  return context.req.query(source.key) ?? null;
16
16
  }
17
17
  case AuthorizationDomainSources.CONTEXT: {
18
- const value = context.get(source.key);
18
+ // A declarative key is a string read off the request, so it cannot satisfy `get`'s `keyof Variables` parameter.
19
+ const value = Reflect.apply(context.get, context, [source.key]);
19
20
  return value == null ? null : String(value);
20
21
  }
21
22
  default: {
@@ -1 +1 @@
1
- {"version":3,"file":"request-domain.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authorize/providers/request-domain.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAO5F,kEAAkE;AAClE,MAAM,OAAO,qBAAqB;IAChC,yEAAyE;IACzE,MAAM,CAAC,eAAe,CAAC,IAGtB;QACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEjC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC;gBACtC,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;YAC/C,CAAC;YACD,KAAK,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvC,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;YAChD,CAAC;YACD,KAAK,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC;gBACtC,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;YAC/C,CAAC;YACD,KAAK,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;gBACxC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAU,CAAC,CAAC;gBAE7C,OAAO,KAA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,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBACxC,CAAC,CAAC,yBAAyB,CAAC,WAAW,CAAC;QAC5C,CAAC;QAED,OAAO,yBAAyB,CAAC,WAAW,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import type { TContext } from '@/base/controllers/common/types';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport type { Env } from 'hono';\nimport { AuthorizationDomainScopes, AuthorizationDomainSources } from '../common/constants';\nimport type {\n IAuthorizationDomainSource,\n IAuthorizationSpec,\n IAuthorizeOptions,\n} from '../common/types';\n\n/** Reads the domain of an authorization check off the request. */\nexport class RequestDomainResolver {\n /** Read a domain value from a declarative source on the Hono context. */\n static readDeclarative(opts: {\n source: IAuthorizationDomainSource;\n context: TContext<Env, string>;\n }): TNullable<string> {\n const { source, context } = opts;\n\n switch (source.from) {\n case AuthorizationDomainSources.PARAM: {\n return context.req.param(source.key) ?? null;\n }\n case AuthorizationDomainSources.HEADER: {\n return context.req.header(source.key) ?? null;\n }\n case AuthorizationDomainSources.QUERY: {\n return context.req.query(source.key) ?? null;\n }\n case AuthorizationDomainSources.CONTEXT: {\n const value = context.get(source.key as any);\n\n return value == null ? null : String(value);\n }\n default: {\n return null;\n }\n }\n }\n\n /** Resolve the request domain, precedence spec.domain (method | declarative) -> options.domainResolver -> SYSTEM_WIDE, as a casbin domain string (\"<type>_<id>\") or the SYSTEM_WIDE sentinel. */\n static async resolveRequestDomain(opts: {\n spec: IAuthorizationSpec;\n context: TContext<Env, string>;\n options: TNullable<IAuthorizeOptions>;\n }): Promise<string> {\n const { spec, context, options } = opts;\n\n if (typeof spec.domain === 'function') {\n const resolved = await spec.domain({ context });\n\n return resolved\n ? [resolved.type, resolved.id].join('_')\n : AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n\n if (spec.domain) {\n const id = RequestDomainResolver.readDeclarative({ source: spec.domain, context });\n\n return id ? [spec.domain.type, id].join('_') : AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n\n const globalResolver = options?.domainResolver ?? null;\n\n if (globalResolver) {\n const resolved = await globalResolver({ context });\n\n return resolved\n ? [resolved.type, resolved.id].join('_')\n : AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n\n return AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n}\n"]}
1
+ {"version":3,"file":"request-domain.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authorize/providers/request-domain.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAO5F,kEAAkE;AAClE,MAAM,OAAO,qBAAqB;IAChC,yEAAyE;IACzE,MAAM,CAAC,eAAe,CAAC,IAGtB;QACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEjC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC;gBACtC,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;YAC/C,CAAC;YACD,KAAK,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvC,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;YAChD,CAAC;YACD,KAAK,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC;gBACtC,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;YAC/C,CAAC;YACD,KAAK,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;gBACxC,gHAAgH;gBAChH,MAAM,KAAK,GAAY,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAEzE,OAAO,KAAK,IAAI,IAAI,CA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C,IAAI,CAAC,GAAG,CAAC;gBACxC,CAAC,CAAC,yBAAyB,CAAC,WAAW,CAAC;QAC5C,CAAC;QAED,OAAO,yBAAyB,CAAC,WAAW,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import type { TContext } from '@/base/controllers/common/types';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport type { Env } from 'hono';\nimport { AuthorizationDomainScopes, AuthorizationDomainSources } from '../common/constants';\nimport type {\n IAuthorizationDomainSource,\n IAuthorizationSpec,\n IAuthorizeOptions,\n} from '../common/types';\n\n/** Reads the domain of an authorization check off the request. */\nexport class RequestDomainResolver {\n /** Read a domain value from a declarative source on the Hono context. */\n static readDeclarative(opts: {\n source: IAuthorizationDomainSource;\n context: TContext<Env, string>;\n }): TNullable<string> {\n const { source, context } = opts;\n\n switch (source.from) {\n case AuthorizationDomainSources.PARAM: {\n return context.req.param(source.key) ?? null;\n }\n case AuthorizationDomainSources.HEADER: {\n return context.req.header(source.key) ?? null;\n }\n case AuthorizationDomainSources.QUERY: {\n return context.req.query(source.key) ?? null;\n }\n case AuthorizationDomainSources.CONTEXT: {\n // A declarative key is a string read off the request, so it cannot satisfy `get`'s `keyof Variables` parameter.\n const value: unknown = Reflect.apply(context.get, context, [source.key]);\n\n return value == null ? null : String(value);\n }\n default: {\n return null;\n }\n }\n }\n\n /** Resolve the request domain, precedence spec.domain (method | declarative) -> options.domainResolver -> SYSTEM_WIDE, as a casbin domain string (\"<type>_<id>\") or the SYSTEM_WIDE sentinel. */\n static async resolveRequestDomain(opts: {\n spec: IAuthorizationSpec;\n context: TContext<Env, string>;\n options: TNullable<IAuthorizeOptions>;\n }): Promise<string> {\n const { spec, context, options } = opts;\n\n if (typeof spec.domain === 'function') {\n const resolved = await spec.domain({ context });\n\n return resolved\n ? [resolved.type, resolved.id].join('_')\n : AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n\n if (spec.domain) {\n const id = RequestDomainResolver.readDeclarative({ source: spec.domain, context });\n\n return id ? [spec.domain.type, id].join('_') : AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n\n const globalResolver = options?.domainResolver ?? null;\n\n if (globalResolver) {\n const resolved = await globalResolver({ context });\n\n return resolved\n ? [resolved.type, resolved.id].join('_')\n : AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n\n return AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { type TBindingKey } from '@venizia/ignis-inversion';
1
2
  import type { Container } from '../../../helpers/inversion/container.js';
2
3
  import type { TClass } from '@venizia/ignis-helpers/common';
3
4
  import { BaseHelper } from '@venizia/ignis-helpers/core';
@@ -15,7 +16,7 @@ export declare abstract class AbstractAuthRegistry<TItem> extends BaseHelper {
15
16
  protected abstract getBindingPrefix(): string;
16
17
  getKey(opts: {
17
18
  name: string;
18
- }): string;
19
+ }): TBindingKey;
19
20
  /**
20
21
  * Whether a name resolves. The registry is the only source of truth for that: the strategy type is
21
22
  * open (`TAuthStrategy` accepts any string), so nothing upstream can tell a registered name from a
@@ -1,5 +1,5 @@
1
1
  import { ObjectUtility } from '@venizia/ignis-helpers/common';
2
- import { BindingScopes } from '@venizia/ignis-inversion';
2
+ import { BindingKeys, BindingScopes } from '@venizia/ignis-inversion';
3
3
  import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
4
4
  /** Base of the auth registries. Registers classes under a name as singletons in a container and resolves them by name. Subclasses supply the binding key prefix. */
5
5
  export class AbstractAuthRegistry extends BaseHelper {
@@ -11,7 +11,7 @@ export class AbstractAuthRegistry extends BaseHelper {
11
11
  if (!opts?.name || ObjectUtility.isEmpty({ value: opts.name })) {
12
12
  throw getError({ message: `[getKey] Invalid name | name: ${opts.name}` });
13
13
  }
14
- return [this.getBindingPrefix(), opts.name].join('.');
14
+ return BindingKeys.build({ namespace: this.getBindingPrefix(), key: opts.name });
15
15
  }
16
16
  /**
17
17
  * Whether a name resolves. The registry is the only source of truth for that: the strategy type is
@@ -1 +1 @@
1
- {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EAAE;aACjE,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { ObjectUtility } from '@venizia/ignis-helpers/common';\nimport { BindingScopes } from '@venizia/ignis-inversion';\nimport type { Container } from '@/helpers/inversion/container';\nimport type { TClass } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\n/** A registered item: its class and the container that resolves it. */\nexport type TRegistryDescriptor<TItem> = {\n container: Container;\n targetClass: TClass<TItem>;\n};\n\n/** Base of the auth registries. Registers classes under a name as singletons in a container and resolves them by name. Subclasses supply the binding key prefix. */\nexport abstract class AbstractAuthRegistry<TItem> extends BaseHelper {\n protected descriptors: Map<string, TRegistryDescriptor<TItem>>;\n\n constructor(opts: { scope: string }) {\n super(opts);\n this.descriptors = new Map();\n }\n\n protected abstract getBindingPrefix(): string;\n\n getKey(opts: { name: string }): string {\n if (!opts?.name || ObjectUtility.isEmpty({ value: opts.name })) {\n throw getError({ message: `[getKey] Invalid name | name: ${opts.name}` });\n }\n\n return [this.getBindingPrefix(), opts.name].join('.');\n }\n\n /**\n * Whether a name resolves. The registry is the only source of truth for that: the strategy type is\n * open (`TAuthStrategy` accepts any string), so nothing upstream can tell a registered name from a\n * typo. `AuthenticateStrategy.isValid` knows the two built-ins only and must not be used here.\n */\n has(opts: { name: string }): boolean {\n return this.descriptors.has(opts.name);\n }\n\n /** Every registered name, for a caller building its own startup check or an error message. */\n getNames(): string[] {\n return [...this.descriptors.keys()];\n }\n\n getDefaultName(): string {\n const firstName = this.descriptors.keys().next().value;\n\n if (!firstName) {\n throw getError({\n message: `[${this.constructor.name}] No items registered`,\n });\n }\n\n return firstName;\n }\n\n protected registerDescriptor(opts: {\n container: Container;\n target: TClass<TItem>;\n name: string;\n }): void {\n const { container, target, name } = opts;\n\n this.descriptors.set(name, { container, targetClass: target });\n container\n .bind({ key: this.getKey({ name }) })\n .toClass(target)\n .setScope(BindingScopes.SINGLETON);\n }\n\n reset(): void {\n this.descriptors.clear();\n }\n\n protected resolveDescriptor(opts: { name: string }): TItem {\n const { name } = opts;\n const metadata = this.descriptors.get(name);\n\n if (!metadata) {\n throw getError({\n message: `[${this.constructor.name}] Descriptor not found: ${name}`,\n });\n }\n\n const { container } = metadata;\n const instance = container.get<TItem>({\n key: this.getKey({ name }),\n });\n\n if (!instance) {\n throw getError({\n message: `[${this.constructor.name}] Failed to resolve: ${name}`,\n });\n }\n\n return instance;\n }\n}\n"]}
1
+ {"version":3,"file":"abstract-auth-registry.js","sourceRoot":"","sources":["../../../../../src/base/auth/base/abstract-auth-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAoB,MAAM,0BAA0B,CAAC;AAGxF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAQnE,oKAAoK;AACpK,MAAM,OAAgB,oBAA4B,SAAQ,UAAU;IAGlE,YAAY,IAAuB;QACjC,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;IAC/B,CAAC;IAID,MAAM,CAAC,IAAsB;QAC3B,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAC/D,MAAM,QAAQ,CAAC,EAAE,OAAO,EAAE,iCAAiC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,WAAW,CAAC,KAAK,CAAU,EAAE,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAsB;QACxB,OAAO,IAAI,CA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IAAI,EAAE;aACpE,CAAC,CAAC;QACL,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;QAC/B,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAQ;YACpC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;SAC3B,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,wBAAwB,IAAI,EAAE;aACjE,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { ObjectUtility } from '@venizia/ignis-helpers/common';\nimport { BindingKeys, BindingScopes, type TBindingKey } from '@venizia/ignis-inversion';\nimport type { Container } from '@/helpers/inversion/container';\nimport type { TClass } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\n/** A registered item: its class and the container that resolves it. */\nexport type TRegistryDescriptor<TItem> = {\n container: Container;\n targetClass: TClass<TItem>;\n};\n\n/** Base of the auth registries. Registers classes under a name as singletons in a container and resolves them by name. Subclasses supply the binding key prefix. */\nexport abstract class AbstractAuthRegistry<TItem> extends BaseHelper {\n protected descriptors: Map<string, TRegistryDescriptor<TItem>>;\n\n constructor(opts: { scope: string }) {\n super(opts);\n this.descriptors = new Map();\n }\n\n protected abstract getBindingPrefix(): string;\n\n getKey(opts: { name: string }): TBindingKey {\n if (!opts?.name || ObjectUtility.isEmpty({ value: opts.name })) {\n throw getError({ message: `[getKey] Invalid name | name: ${opts.name}` });\n }\n\n return BindingKeys.build<unknown>({ namespace: this.getBindingPrefix(), key: opts.name });\n }\n\n /**\n * Whether a name resolves. The registry is the only source of truth for that: the strategy type is\n * open (`TAuthStrategy` accepts any string), so nothing upstream can tell a registered name from a\n * typo. `AuthenticateStrategy.isValid` knows the two built-ins only and must not be used here.\n */\n has(opts: { name: string }): boolean {\n return this.descriptors.has(opts.name);\n }\n\n /** Every registered name, for a caller building its own startup check or an error message. */\n getNames(): string[] {\n return [...this.descriptors.keys()];\n }\n\n getDefaultName(): string {\n const firstName = this.descriptors.keys().next().value;\n\n if (!firstName) {\n throw getError({\n message: `[${this.constructor.name}] No items registered`,\n });\n }\n\n return firstName;\n }\n\n protected registerDescriptor(opts: {\n container: Container;\n target: TClass<TItem>;\n name: string;\n }): void {\n const { container, target, name } = opts;\n\n this.descriptors.set(name, { container, targetClass: target });\n container\n .bind({ key: this.getKey({ name }) })\n .toClass(target)\n .setScope(BindingScopes.SINGLETON);\n }\n\n reset(): void {\n this.descriptors.clear();\n }\n\n protected resolveDescriptor(opts: { name: string }): TItem {\n const { name } = opts;\n const metadata = this.descriptors.get(name);\n\n if (!metadata) {\n throw getError({\n message: `[${this.constructor.name}] Descriptor not found: ${name}`,\n });\n }\n\n const { container } = metadata;\n const instance = container.get<TItem>({\n key: this.getKey({ name }),\n });\n\n if (!instance) {\n throw getError({\n message: `[${this.constructor.name}] Failed to resolve: ${name}`,\n });\n }\n\n return instance;\n }\n}\n"]}