@authup/server-core 1.0.0-beta.45 → 1.0.0-beta.47

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 (448) hide show
  1. package/LICENSE +661 -201
  2. package/README.md +3 -1
  3. package/dist/adapters/database/data-source/index.d.ts +0 -1
  4. package/dist/adapters/database/data-source/index.d.ts.map +1 -1
  5. package/dist/adapters/database/data-source/index.mjs +1 -2
  6. package/dist/adapters/database/domains/client/subscriber.d.ts +3 -6
  7. package/dist/adapters/database/domains/client/subscriber.d.ts.map +1 -1
  8. package/dist/adapters/database/domains/client/subscriber.mjs +21 -39
  9. package/dist/adapters/database/domains/client/subscriber.mjs.map +1 -1
  10. package/dist/adapters/database/domains/client-permission/subscriber.d.ts +3 -6
  11. package/dist/adapters/database/domains/client-permission/subscriber.d.ts.map +1 -1
  12. package/dist/adapters/database/domains/client-permission/subscriber.mjs +24 -49
  13. package/dist/adapters/database/domains/client-permission/subscriber.mjs.map +1 -1
  14. package/dist/adapters/database/domains/client-role/subscriber.d.ts +3 -6
  15. package/dist/adapters/database/domains/client-role/subscriber.d.ts.map +1 -1
  16. package/dist/adapters/database/domains/client-role/subscriber.mjs +24 -49
  17. package/dist/adapters/database/domains/client-role/subscriber.mjs.map +1 -1
  18. package/dist/adapters/database/domains/client-scope/subscriber.d.ts +3 -6
  19. package/dist/adapters/database/domains/client-scope/subscriber.d.ts.map +1 -1
  20. package/dist/adapters/database/domains/client-scope/subscriber.mjs +21 -36
  21. package/dist/adapters/database/domains/client-scope/subscriber.mjs.map +1 -1
  22. package/dist/adapters/database/domains/identity-provider/subscriber.d.ts +3 -6
  23. package/dist/adapters/database/domains/identity-provider/subscriber.d.ts.map +1 -1
  24. package/dist/adapters/database/domains/identity-provider/subscriber.mjs +21 -39
  25. package/dist/adapters/database/domains/identity-provider/subscriber.mjs.map +1 -1
  26. package/dist/adapters/database/domains/identity-provider-account/subscriber.d.ts +3 -6
  27. package/dist/adapters/database/domains/identity-provider-account/subscriber.d.ts.map +1 -1
  28. package/dist/adapters/database/domains/identity-provider-account/subscriber.mjs +21 -36
  29. package/dist/adapters/database/domains/identity-provider-account/subscriber.mjs.map +1 -1
  30. package/dist/adapters/database/domains/identity-provider-attribute/subscriber.d.ts +3 -6
  31. package/dist/adapters/database/domains/identity-provider-attribute/subscriber.d.ts.map +1 -1
  32. package/dist/adapters/database/domains/identity-provider-attribute/subscriber.mjs +21 -36
  33. package/dist/adapters/database/domains/identity-provider-attribute/subscriber.mjs.map +1 -1
  34. package/dist/adapters/database/domains/identity-provider-role-mapping/subscriber.d.ts +3 -6
  35. package/dist/adapters/database/domains/identity-provider-role-mapping/subscriber.d.ts.map +1 -1
  36. package/dist/adapters/database/domains/identity-provider-role-mapping/subscriber.mjs +21 -45
  37. package/dist/adapters/database/domains/identity-provider-role-mapping/subscriber.mjs.map +1 -1
  38. package/dist/adapters/database/domains/permission/subscriber.d.ts +3 -6
  39. package/dist/adapters/database/domains/permission/subscriber.d.ts.map +1 -1
  40. package/dist/adapters/database/domains/permission/subscriber.mjs +28 -47
  41. package/dist/adapters/database/domains/permission/subscriber.mjs.map +1 -1
  42. package/dist/adapters/database/domains/policy/subscriber.d.ts +3 -6
  43. package/dist/adapters/database/domains/policy/subscriber.d.ts.map +1 -1
  44. package/dist/adapters/database/domains/policy/subscriber.mjs +21 -36
  45. package/dist/adapters/database/domains/policy/subscriber.mjs.map +1 -1
  46. package/dist/adapters/database/domains/policy-attribute/subscriber.d.ts +3 -6
  47. package/dist/adapters/database/domains/policy-attribute/subscriber.d.ts.map +1 -1
  48. package/dist/adapters/database/domains/policy-attribute/subscriber.mjs +24 -45
  49. package/dist/adapters/database/domains/policy-attribute/subscriber.mjs.map +1 -1
  50. package/dist/adapters/database/domains/realm/subscriber.d.ts +3 -6
  51. package/dist/adapters/database/domains/realm/subscriber.d.ts.map +1 -1
  52. package/dist/adapters/database/domains/realm/subscriber.mjs +21 -36
  53. package/dist/adapters/database/domains/realm/subscriber.mjs.map +1 -1
  54. package/dist/adapters/database/domains/robot/subscriber.d.ts +3 -6
  55. package/dist/adapters/database/domains/robot/subscriber.d.ts.map +1 -1
  56. package/dist/adapters/database/domains/robot/subscriber.mjs +21 -39
  57. package/dist/adapters/database/domains/robot/subscriber.mjs.map +1 -1
  58. package/dist/adapters/database/domains/robot-permission/subscriber.d.ts +3 -6
  59. package/dist/adapters/database/domains/robot-permission/subscriber.d.ts.map +1 -1
  60. package/dist/adapters/database/domains/robot-permission/subscriber.mjs +24 -49
  61. package/dist/adapters/database/domains/robot-permission/subscriber.mjs.map +1 -1
  62. package/dist/adapters/database/domains/robot-role/subscriber.d.ts +3 -6
  63. package/dist/adapters/database/domains/robot-role/subscriber.d.ts.map +1 -1
  64. package/dist/adapters/database/domains/robot-role/subscriber.mjs +24 -49
  65. package/dist/adapters/database/domains/robot-role/subscriber.mjs.map +1 -1
  66. package/dist/adapters/database/domains/role/subscriber.d.ts +3 -6
  67. package/dist/adapters/database/domains/role/subscriber.d.ts.map +1 -1
  68. package/dist/adapters/database/domains/role/subscriber.mjs +21 -41
  69. package/dist/adapters/database/domains/role/subscriber.mjs.map +1 -1
  70. package/dist/adapters/database/domains/role-attribute/subscriber.d.ts +3 -6
  71. package/dist/adapters/database/domains/role-attribute/subscriber.d.ts.map +1 -1
  72. package/dist/adapters/database/domains/role-attribute/subscriber.mjs +24 -45
  73. package/dist/adapters/database/domains/role-attribute/subscriber.mjs.map +1 -1
  74. package/dist/adapters/database/domains/role-permission/subscriber.d.ts +3 -6
  75. package/dist/adapters/database/domains/role-permission/subscriber.d.ts.map +1 -1
  76. package/dist/adapters/database/domains/role-permission/subscriber.mjs +24 -49
  77. package/dist/adapters/database/domains/role-permission/subscriber.mjs.map +1 -1
  78. package/dist/adapters/database/domains/scope/subscriber.d.ts +3 -6
  79. package/dist/adapters/database/domains/scope/subscriber.d.ts.map +1 -1
  80. package/dist/adapters/database/domains/scope/subscriber.mjs +17 -43
  81. package/dist/adapters/database/domains/scope/subscriber.mjs.map +1 -1
  82. package/dist/adapters/database/domains/user/subscriber.d.ts +3 -6
  83. package/dist/adapters/database/domains/user/subscriber.d.ts.map +1 -1
  84. package/dist/adapters/database/domains/user/subscriber.mjs +21 -39
  85. package/dist/adapters/database/domains/user/subscriber.mjs.map +1 -1
  86. package/dist/adapters/database/domains/user-attribute/subscriber.d.ts +3 -6
  87. package/dist/adapters/database/domains/user-attribute/subscriber.d.ts.map +1 -1
  88. package/dist/adapters/database/domains/user-attribute/subscriber.mjs +24 -43
  89. package/dist/adapters/database/domains/user-attribute/subscriber.mjs.map +1 -1
  90. package/dist/adapters/database/domains/user-permission/subscriber.d.ts +3 -6
  91. package/dist/adapters/database/domains/user-permission/subscriber.d.ts.map +1 -1
  92. package/dist/adapters/database/domains/user-permission/subscriber.mjs +24 -49
  93. package/dist/adapters/database/domains/user-permission/subscriber.mjs.map +1 -1
  94. package/dist/adapters/database/domains/user-role/subscriber.d.ts +3 -6
  95. package/dist/adapters/database/domains/user-role/subscriber.d.ts.map +1 -1
  96. package/dist/adapters/database/domains/user-role/subscriber.mjs +24 -49
  97. package/dist/adapters/database/domains/user-role/subscriber.mjs.map +1 -1
  98. package/dist/adapters/database/index.d.ts +1 -0
  99. package/dist/adapters/database/index.d.ts.map +1 -1
  100. package/dist/adapters/database/index.mjs +3 -2
  101. package/dist/adapters/database/subscriber/index.d.ts +3 -0
  102. package/dist/adapters/database/subscriber/index.d.ts.map +1 -0
  103. package/dist/adapters/database/subscriber/index.mjs +5 -0
  104. package/dist/adapters/database/subscriber/module.d.ts +19 -0
  105. package/dist/adapters/database/subscriber/module.d.ts.map +1 -0
  106. package/dist/adapters/database/subscriber/module.mjs +70 -0
  107. package/dist/adapters/database/subscriber/module.mjs.map +1 -0
  108. package/dist/adapters/database/subscriber/types.d.ts +15 -0
  109. package/dist/adapters/database/subscriber/types.d.ts.map +1 -0
  110. package/dist/adapters/http/controllers/entities/identity-provider/module.mjs +1 -1
  111. package/dist/adapters/http/controllers/workflows/activate/module.d.ts +8 -1
  112. package/dist/adapters/http/controllers/workflows/activate/module.d.ts.map +1 -1
  113. package/dist/adapters/http/controllers/workflows/activate/module.mjs +20 -1
  114. package/dist/adapters/http/controllers/workflows/activate/module.mjs.map +1 -1
  115. package/dist/adapters/http/controllers/workflows/authorize/module.d.ts.map +1 -1
  116. package/dist/adapters/http/controllers/workflows/authorize/module.mjs +16 -37
  117. package/dist/adapters/http/controllers/workflows/authorize/module.mjs.map +1 -1
  118. package/dist/adapters/http/controllers/workflows/authorize/types.d.ts +2 -0
  119. package/dist/adapters/http/controllers/workflows/authorize/types.d.ts.map +1 -1
  120. package/dist/adapters/http/controllers/workflows/password-forgot/module.d.ts +8 -1
  121. package/dist/adapters/http/controllers/workflows/password-forgot/module.d.ts.map +1 -1
  122. package/dist/adapters/http/controllers/workflows/password-forgot/module.mjs +23 -2
  123. package/dist/adapters/http/controllers/workflows/password-forgot/module.mjs.map +1 -1
  124. package/dist/adapters/http/controllers/workflows/password-reset/module.d.ts +8 -1
  125. package/dist/adapters/http/controllers/workflows/password-reset/module.d.ts.map +1 -1
  126. package/dist/adapters/http/controllers/workflows/password-reset/module.mjs +21 -1
  127. package/dist/adapters/http/controllers/workflows/password-reset/module.mjs.map +1 -1
  128. package/dist/adapters/http/controllers/workflows/register/module.d.ts +8 -1
  129. package/dist/adapters/http/controllers/workflows/register/module.d.ts.map +1 -1
  130. package/dist/adapters/http/controllers/workflows/register/module.mjs +23 -2
  131. package/dist/adapters/http/controllers/workflows/register/module.mjs.map +1 -1
  132. package/dist/adapters/http/controllers/workflows/status/module.d.ts +11 -4
  133. package/dist/adapters/http/controllers/workflows/status/module.d.ts.map +1 -1
  134. package/dist/adapters/http/controllers/workflows/status/module.mjs +17 -5
  135. package/dist/adapters/http/controllers/workflows/status/module.mjs.map +1 -1
  136. package/dist/adapters/http/index.mjs +4 -1
  137. package/dist/adapters/http/middleware/built-in/cors.d.ts.map +1 -1
  138. package/dist/adapters/http/middleware/built-in/cors.mjs.map +1 -1
  139. package/dist/adapters/http/middleware/built-in/error.d.ts +6 -1
  140. package/dist/adapters/http/middleware/built-in/error.d.ts.map +1 -1
  141. package/dist/adapters/http/middleware/built-in/error.mjs +2 -3
  142. package/dist/adapters/http/middleware/built-in/error.mjs.map +1 -1
  143. package/dist/adapters/http/middleware/built-in/index.d.ts +1 -0
  144. package/dist/adapters/http/middleware/built-in/index.d.ts.map +1 -1
  145. package/dist/adapters/http/middleware/built-in/index.mjs +2 -1
  146. package/dist/adapters/http/middleware/built-in/logger.d.ts +2 -0
  147. package/dist/adapters/http/middleware/built-in/logger.d.ts.map +1 -1
  148. package/dist/adapters/http/middleware/built-in/logger.mjs +1 -2
  149. package/dist/adapters/http/middleware/built-in/logger.mjs.map +1 -1
  150. package/dist/adapters/http/middleware/built-in/ui-http-client.d.ts +15 -0
  151. package/dist/adapters/http/middleware/built-in/ui-http-client.d.ts.map +1 -0
  152. package/dist/adapters/http/middleware/built-in/ui-http-client.mjs +25 -0
  153. package/dist/adapters/http/middleware/built-in/ui-http-client.mjs.map +1 -0
  154. package/dist/adapters/http/middleware/index.mjs +2 -1
  155. package/dist/adapters/http/request/helpers/index.d.ts +2 -0
  156. package/dist/adapters/http/request/helpers/index.d.ts.map +1 -1
  157. package/dist/adapters/http/request/helpers/index.mjs +3 -1
  158. package/dist/adapters/http/request/helpers/locale.d.ts +14 -0
  159. package/dist/adapters/http/request/helpers/locale.d.ts.map +1 -0
  160. package/dist/adapters/http/request/helpers/locale.mjs +32 -0
  161. package/dist/adapters/http/request/helpers/locale.mjs.map +1 -0
  162. package/dist/adapters/http/request/helpers/locations.mjs +1 -1
  163. package/dist/adapters/http/request/helpers/redirect.d.ts +14 -0
  164. package/dist/adapters/http/request/helpers/redirect.d.ts.map +1 -0
  165. package/dist/adapters/http/request/helpers/redirect.mjs +36 -0
  166. package/dist/adapters/http/request/helpers/redirect.mjs.map +1 -0
  167. package/dist/adapters/http/request/index.mjs +3 -1
  168. package/dist/adapters/http/ui/base-path.d.ts +9 -0
  169. package/dist/adapters/http/ui/base-path.d.ts.map +1 -0
  170. package/dist/adapters/http/ui/base-path.mjs +18 -0
  171. package/dist/adapters/http/ui/base-path.mjs.map +1 -0
  172. package/dist/adapters/http/ui/index.d.ts +5 -0
  173. package/dist/adapters/http/ui/index.d.ts.map +1 -0
  174. package/dist/adapters/http/ui/index.mjs +7 -0
  175. package/dist/adapters/http/ui/render.d.ts +4 -0
  176. package/dist/adapters/http/ui/render.d.ts.map +1 -0
  177. package/dist/adapters/http/ui/render.mjs +60 -0
  178. package/dist/adapters/http/ui/render.mjs.map +1 -0
  179. package/dist/adapters/http/ui/serve.d.ts +16 -0
  180. package/dist/adapters/http/ui/serve.d.ts.map +1 -0
  181. package/dist/adapters/http/ui/serve.mjs +32 -0
  182. package/dist/adapters/http/ui/serve.mjs.map +1 -0
  183. package/dist/adapters/http/ui/types.d.ts +8 -0
  184. package/dist/adapters/http/ui/types.d.ts.map +1 -0
  185. package/dist/adapters/http/ui/types.mjs +4 -0
  186. package/dist/app/index.d.ts +0 -2
  187. package/dist/app/index.d.ts.map +1 -1
  188. package/dist/app/index.mjs +3 -3
  189. package/dist/app/modules/config/constants.d.ts +1 -0
  190. package/dist/app/modules/config/constants.d.ts.map +1 -1
  191. package/dist/app/modules/config/constants.mjs +1 -0
  192. package/dist/app/modules/config/constants.mjs.map +1 -1
  193. package/dist/app/modules/config/index.d.ts +1 -0
  194. package/dist/app/modules/config/index.d.ts.map +1 -1
  195. package/dist/app/modules/config/index.mjs +2 -1
  196. package/dist/app/modules/config/normalize.d.ts.map +1 -1
  197. package/dist/app/modules/config/normalize.mjs +9 -2
  198. package/dist/app/modules/config/normalize.mjs.map +1 -1
  199. package/dist/app/modules/config/origins.d.ts +10 -0
  200. package/dist/app/modules/config/origins.d.ts.map +1 -0
  201. package/dist/app/modules/config/origins.mjs +21 -0
  202. package/dist/app/modules/config/origins.mjs.map +1 -0
  203. package/dist/app/modules/config/parse.d.ts.map +1 -1
  204. package/dist/app/modules/config/parse.mjs +1 -0
  205. package/dist/app/modules/config/parse.mjs.map +1 -1
  206. package/dist/app/modules/config/read/env.d.ts.map +1 -1
  207. package/dist/app/modules/config/read/env.mjs +2 -0
  208. package/dist/app/modules/config/read/env.mjs.map +1 -1
  209. package/dist/app/modules/config/types.d.ts +14 -0
  210. package/dist/app/modules/config/types.d.ts.map +1 -1
  211. package/dist/app/modules/database/constants.d.ts +2 -0
  212. package/dist/app/modules/database/constants.d.ts.map +1 -1
  213. package/dist/app/modules/database/constants.mjs +4 -1
  214. package/dist/app/modules/database/constants.mjs.map +1 -1
  215. package/dist/app/modules/database/module.d.ts +5 -1
  216. package/dist/app/modules/database/module.d.ts.map +1 -1
  217. package/dist/app/modules/database/module.mjs +26 -15
  218. package/dist/app/modules/database/module.mjs.map +1 -1
  219. package/dist/app/modules/http/constants.d.ts +11 -0
  220. package/dist/app/modules/http/constants.d.ts.map +1 -1
  221. package/dist/app/modules/http/constants.mjs +12 -1
  222. package/dist/app/modules/http/constants.mjs.map +1 -1
  223. package/dist/app/modules/http/modules/controller.d.ts +5 -1
  224. package/dist/app/modules/http/modules/controller.d.ts.map +1 -1
  225. package/dist/app/modules/http/modules/controller.mjs +75 -10
  226. package/dist/app/modules/http/modules/controller.mjs.map +1 -1
  227. package/dist/app/modules/http/modules/middleware.d.ts +2 -1
  228. package/dist/app/modules/http/modules/middleware.d.ts.map +1 -1
  229. package/dist/app/modules/http/modules/middleware.mjs +19 -4
  230. package/dist/app/modules/http/modules/middleware.mjs.map +1 -1
  231. package/dist/app/modules/identity/module.mjs +4 -4
  232. package/dist/app/modules/identity/module.mjs.map +1 -1
  233. package/dist/app/modules/identity/repositories/provider/account/module.d.ts +3 -1
  234. package/dist/app/modules/identity/repositories/provider/account/module.d.ts.map +1 -1
  235. package/dist/app/modules/identity/repositories/provider/account/module.mjs +6 -3
  236. package/dist/app/modules/identity/repositories/provider/account/module.mjs.map +1 -1
  237. package/dist/app/modules/identity/repositories/provider/mapper/attribute.d.ts +3 -0
  238. package/dist/app/modules/identity/repositories/provider/mapper/attribute.d.ts.map +1 -1
  239. package/dist/app/modules/identity/repositories/provider/mapper/attribute.mjs +5 -2
  240. package/dist/app/modules/identity/repositories/provider/mapper/attribute.mjs.map +1 -1
  241. package/dist/app/modules/identity/repositories/provider/mapper/permission.d.ts +3 -0
  242. package/dist/app/modules/identity/repositories/provider/mapper/permission.d.ts.map +1 -1
  243. package/dist/app/modules/identity/repositories/provider/mapper/permission.mjs +5 -2
  244. package/dist/app/modules/identity/repositories/provider/mapper/permission.mjs.map +1 -1
  245. package/dist/app/modules/identity/repositories/provider/mapper/role.d.ts +3 -0
  246. package/dist/app/modules/identity/repositories/provider/mapper/role.d.ts.map +1 -1
  247. package/dist/app/modules/identity/repositories/provider/mapper/role.mjs +5 -2
  248. package/dist/app/modules/identity/repositories/provider/mapper/role.mjs.map +1 -1
  249. package/dist/app/modules/index.mjs +3 -2
  250. package/dist/app/modules/logger/module.d.ts.map +1 -1
  251. package/dist/app/modules/logger/module.mjs +1 -5
  252. package/dist/app/modules/logger/module.mjs.map +1 -1
  253. package/dist/app/modules/mail/constants.d.ts +2 -1
  254. package/dist/app/modules/mail/constants.d.ts.map +1 -1
  255. package/dist/app/modules/mail/constants.mjs +2 -1
  256. package/dist/app/modules/mail/constants.mjs.map +1 -1
  257. package/dist/app/modules/mail/index.mjs +2 -2
  258. package/dist/app/modules/mail/module.d.ts.map +1 -1
  259. package/dist/app/modules/mail/module.mjs +4 -1
  260. package/dist/app/modules/mail/module.mjs.map +1 -1
  261. package/dist/app/modules/oauth2/module.d.ts.map +1 -1
  262. package/dist/app/modules/oauth2/module.mjs +3 -1
  263. package/dist/app/modules/oauth2/module.mjs.map +1 -1
  264. package/dist/app/modules/oauth2/repositories/key/repository.d.ts +3 -0
  265. package/dist/app/modules/oauth2/repositories/key/repository.d.ts.map +1 -1
  266. package/dist/app/modules/oauth2/repositories/key/repository.mjs +5 -2
  267. package/dist/app/modules/oauth2/repositories/key/repository.mjs.map +1 -1
  268. package/dist/app/modules/provisioning/module.d.ts.map +1 -1
  269. package/dist/app/modules/provisioning/module.mjs +12 -0
  270. package/dist/app/modules/provisioning/module.mjs.map +1 -1
  271. package/dist/app/modules/provisioning/sources/default/module.d.ts.map +1 -1
  272. package/dist/app/modules/provisioning/sources/default/module.mjs +2 -1
  273. package/dist/app/modules/provisioning/sources/default/module.mjs.map +1 -1
  274. package/dist/core/entities/client/index.d.ts +1 -0
  275. package/dist/core/entities/client/index.d.ts.map +1 -1
  276. package/dist/core/entities/client/index.mjs +2 -1
  277. package/dist/core/entities/client/service.d.ts.map +1 -1
  278. package/dist/core/entities/client/service.mjs +3 -2
  279. package/dist/core/entities/client/service.mjs.map +1 -1
  280. package/dist/core/entities/client/types.d.ts +11 -1
  281. package/dist/core/entities/client/types.d.ts.map +1 -1
  282. package/dist/core/entities/client/web-client.d.ts +34 -0
  283. package/dist/core/entities/client/web-client.d.ts.map +1 -0
  284. package/dist/core/entities/client/web-client.mjs +62 -0
  285. package/dist/core/entities/client/web-client.mjs.map +1 -0
  286. package/dist/core/entities/index.mjs +2 -1
  287. package/dist/core/entities/realm/service.d.ts +6 -1
  288. package/dist/core/entities/realm/service.d.ts.map +1 -1
  289. package/dist/core/entities/realm/service.mjs +9 -0
  290. package/dist/core/entities/realm/service.mjs.map +1 -1
  291. package/dist/core/identity/index.d.ts +1 -0
  292. package/dist/core/identity/index.d.ts.map +1 -1
  293. package/dist/core/identity/index.mjs +2 -1
  294. package/dist/core/identity/password-recovery/constants.d.ts +6 -0
  295. package/dist/core/identity/password-recovery/constants.d.ts.map +1 -0
  296. package/dist/core/identity/password-recovery/constants.mjs +12 -0
  297. package/dist/core/identity/password-recovery/constants.mjs.map +1 -0
  298. package/dist/core/identity/password-recovery/index.d.ts +1 -0
  299. package/dist/core/identity/password-recovery/index.d.ts.map +1 -1
  300. package/dist/core/identity/password-recovery/index.mjs +2 -1
  301. package/dist/core/identity/password-recovery/service.d.ts +4 -2
  302. package/dist/core/identity/password-recovery/service.d.ts.map +1 -1
  303. package/dist/core/identity/password-recovery/service.mjs +17 -6
  304. package/dist/core/identity/password-recovery/service.mjs.map +1 -1
  305. package/dist/core/identity/password-recovery/types.d.ts +5 -2
  306. package/dist/core/identity/password-recovery/types.d.ts.map +1 -1
  307. package/dist/core/identity/registration/service.d.ts +4 -2
  308. package/dist/core/identity/registration/service.d.ts.map +1 -1
  309. package/dist/core/identity/registration/service.mjs +15 -6
  310. package/dist/core/identity/registration/service.mjs.map +1 -1
  311. package/dist/core/identity/registration/types.d.ts +5 -2
  312. package/dist/core/identity/registration/types.d.ts.map +1 -1
  313. package/dist/core/identity/role/module.d.ts.map +1 -1
  314. package/dist/core/identity/role/module.mjs +1 -1
  315. package/dist/core/identity/role/module.mjs.map +1 -1
  316. package/dist/core/identity/types.d.ts +10 -0
  317. package/dist/core/identity/types.d.ts.map +1 -0
  318. package/dist/core/identity/types.mjs +4 -0
  319. package/dist/core/index.mjs +8 -1
  320. package/dist/core/mail/format/blocks.d.ts +12 -0
  321. package/dist/core/mail/format/blocks.d.ts.map +1 -0
  322. package/dist/core/mail/format/blocks.mjs +47 -0
  323. package/dist/core/mail/format/blocks.mjs.map +1 -0
  324. package/dist/core/mail/format/html.d.ts +9 -0
  325. package/dist/core/mail/format/html.d.ts.map +1 -0
  326. package/dist/core/mail/format/html.mjs +41 -0
  327. package/dist/core/mail/format/html.mjs.map +1 -0
  328. package/dist/core/mail/format/index.d.ts +5 -0
  329. package/dist/core/mail/format/index.d.ts.map +1 -0
  330. package/dist/core/mail/format/index.mjs +7 -0
  331. package/dist/core/mail/format/text.d.ts +3 -0
  332. package/dist/core/mail/format/text.d.ts.map +1 -0
  333. package/dist/core/mail/format/text.mjs +20 -0
  334. package/dist/core/mail/format/text.mjs.map +1 -0
  335. package/dist/core/mail/format/types.d.ts +30 -0
  336. package/dist/core/mail/format/types.d.ts.map +1 -0
  337. package/dist/core/mail/format/types.mjs +4 -0
  338. package/dist/core/mail/index.d.ts +3 -0
  339. package/dist/core/mail/index.d.ts.map +1 -1
  340. package/dist/core/mail/index.mjs +6 -1
  341. package/dist/core/mail/renderer.d.ts +10 -0
  342. package/dist/core/mail/renderer.d.ts.map +1 -0
  343. package/dist/core/mail/renderer.mjs +49 -0
  344. package/dist/core/mail/renderer.mjs.map +1 -0
  345. package/dist/core/mail/template/define.d.ts +7 -0
  346. package/dist/core/mail/template/define.d.ts.map +1 -0
  347. package/dist/core/mail/template/define.mjs +14 -0
  348. package/dist/core/mail/template/define.mjs.map +1 -0
  349. package/dist/core/mail/template/index.d.ts +4 -0
  350. package/dist/core/mail/template/index.d.ts.map +1 -0
  351. package/dist/core/mail/template/index.mjs +7 -0
  352. package/dist/core/mail/template/registry.d.ts +6 -0
  353. package/dist/core/mail/template/registry.d.ts.map +1 -0
  354. package/dist/core/mail/template/registry.mjs +15 -0
  355. package/dist/core/mail/template/registry.mjs.map +1 -0
  356. package/dist/core/mail/template/templates/password-reset.d.ts +3 -0
  357. package/dist/core/mail/template/templates/password-reset.d.ts.map +1 -0
  358. package/dist/core/mail/template/templates/password-reset.mjs +36 -0
  359. package/dist/core/mail/template/templates/password-reset.mjs.map +1 -0
  360. package/dist/core/mail/template/templates/registration-activation.d.ts +3 -0
  361. package/dist/core/mail/template/templates/registration-activation.d.ts.map +1 -0
  362. package/dist/core/mail/template/templates/registration-activation.mjs +34 -0
  363. package/dist/core/mail/template/templates/registration-activation.mjs.map +1 -0
  364. package/dist/core/mail/template/types.d.ts +39 -0
  365. package/dist/core/mail/template/types.d.ts.map +1 -0
  366. package/dist/core/mail/template/types.mjs +13 -0
  367. package/dist/core/mail/template/types.mjs.map +1 -0
  368. package/dist/core/mail/types.d.ts +21 -0
  369. package/dist/core/mail/types.d.ts.map +1 -1
  370. package/dist/index.mjs +7 -4
  371. package/dist/swagger.json +98 -3
  372. package/dist/ui/client/.vite/ssr-manifest.json +49086 -875
  373. package/dist/ui/client/assets/asap-latin-400-normal-Dc37g3Il.woff +0 -0
  374. package/dist/ui/client/assets/asap-latin-400-normal-DnZ1MOsG.woff2 +0 -0
  375. package/dist/ui/client/assets/asap-latin-700-normal-Dqcopq14.woff +0 -0
  376. package/dist/ui/client/assets/asap-latin-700-normal-l2Y8pi-F.woff2 +0 -0
  377. package/dist/ui/client/assets/asap-latin-ext-400-normal-C-fcRdtE.woff +0 -0
  378. package/dist/ui/client/assets/asap-latin-ext-400-normal-DwYtpHbV.woff2 +0 -0
  379. package/dist/ui/client/assets/asap-latin-ext-700-normal-D00OESsZ.woff +0 -0
  380. package/dist/ui/client/assets/asap-latin-ext-700-normal-y8bo5aW5.woff2 +0 -0
  381. package/dist/ui/client/assets/asap-vietnamese-400-normal-DGyJlJLT.woff2 +0 -0
  382. package/dist/ui/client/assets/asap-vietnamese-400-normal-lfLaoF2x.woff +0 -0
  383. package/dist/ui/client/assets/asap-vietnamese-700-normal-B-e19ug5.woff +0 -0
  384. package/dist/ui/client/assets/asap-vietnamese-700-normal-D-SxY94i.woff2 +0 -0
  385. package/dist/ui/client/assets/index-BeXJgvKE.css +2 -0
  386. package/dist/ui/client/assets/index-CgLTRwpP.js +95 -0
  387. package/dist/ui/client/assets/nunito-cyrillic-300-normal-BPQV259B.woff2 +0 -0
  388. package/dist/ui/client/assets/nunito-cyrillic-300-normal-g5qSsvc0.woff +0 -0
  389. package/dist/ui/client/assets/nunito-cyrillic-400-normal-D1j0u8EH.woff +0 -0
  390. package/dist/ui/client/assets/nunito-cyrillic-400-normal-xAOo5cBP.woff2 +0 -0
  391. package/dist/ui/client/assets/nunito-cyrillic-600-normal-BUjmtIuu.woff +0 -0
  392. package/dist/ui/client/assets/nunito-cyrillic-600-normal-DJGQ2h05.woff2 +0 -0
  393. package/dist/ui/client/assets/nunito-cyrillic-700-normal-DP36NgGt.woff2 +0 -0
  394. package/dist/ui/client/assets/nunito-cyrillic-700-normal-DfHRUDv-.woff +0 -0
  395. package/dist/ui/client/assets/nunito-cyrillic-ext-300-normal-BDHtqmCR.woff +0 -0
  396. package/dist/ui/client/assets/nunito-cyrillic-ext-300-normal-ChMQLIrm.woff2 +0 -0
  397. package/dist/ui/client/assets/nunito-cyrillic-ext-400-normal-CuPM9foi.woff2 +0 -0
  398. package/dist/ui/client/assets/nunito-cyrillic-ext-400-normal-xaE7D4Sw.woff +0 -0
  399. package/dist/ui/client/assets/nunito-cyrillic-ext-600-normal-CWPPjBOD.woff2 +0 -0
  400. package/dist/ui/client/assets/nunito-cyrillic-ext-600-normal-vnfu4DTE.woff +0 -0
  401. package/dist/ui/client/assets/nunito-cyrillic-ext-700-normal-BuR0mlCG.woff2 +0 -0
  402. package/dist/ui/client/assets/nunito-cyrillic-ext-700-normal-DfoqN4Gs.woff +0 -0
  403. package/dist/ui/client/assets/nunito-latin-300-normal-C3ZIKvzv.woff +0 -0
  404. package/dist/ui/client/assets/nunito-latin-300-normal-COoPE5VN.woff2 +0 -0
  405. package/dist/ui/client/assets/nunito-latin-400-normal-DKg4f3fz.woff +0 -0
  406. package/dist/ui/client/assets/nunito-latin-400-normal-r8SDr6Up.woff2 +0 -0
  407. package/dist/ui/client/assets/nunito-latin-600-normal-Br8yIETf.woff2 +0 -0
  408. package/dist/ui/client/assets/nunito-latin-600-normal-Cd0eNu1l.woff +0 -0
  409. package/dist/ui/client/assets/nunito-latin-700-normal-Dort48En.woff2 +0 -0
  410. package/dist/ui/client/assets/nunito-latin-700-normal-OcDqTBcA.woff +0 -0
  411. package/dist/ui/client/assets/nunito-latin-ext-300-normal-D1SyVuPt.woff2 +0 -0
  412. package/dist/ui/client/assets/nunito-latin-ext-300-normal-DfqbmdMl.woff +0 -0
  413. package/dist/ui/client/assets/nunito-latin-ext-400-normal-CjMJVfGn.woff +0 -0
  414. package/dist/ui/client/assets/nunito-latin-ext-400-normal-i-8OOpdj.woff2 +0 -0
  415. package/dist/ui/client/assets/nunito-latin-ext-600-normal-BKUpuB78.woff +0 -0
  416. package/dist/ui/client/assets/nunito-latin-ext-600-normal-Dd9Zuxh1.woff2 +0 -0
  417. package/dist/ui/client/assets/nunito-latin-ext-700-normal-BWeMsAzO.woff2 +0 -0
  418. package/dist/ui/client/assets/nunito-latin-ext-700-normal-D4woHhbd.woff +0 -0
  419. package/dist/ui/client/assets/nunito-vietnamese-300-normal-DATld5Vw.woff +0 -0
  420. package/dist/ui/client/assets/nunito-vietnamese-300-normal-mLneKULB.woff2 +0 -0
  421. package/dist/ui/client/assets/nunito-vietnamese-400-normal-BHkVbP3T.woff2 +0 -0
  422. package/dist/ui/client/assets/nunito-vietnamese-400-normal-DtOtW02z.woff +0 -0
  423. package/dist/ui/client/assets/nunito-vietnamese-600-normal-BY8O6Cug.woff2 +0 -0
  424. package/dist/ui/client/assets/nunito-vietnamese-600-normal-DO1RqFw5.woff +0 -0
  425. package/dist/ui/client/assets/nunito-vietnamese-700-normal-C9SQsXvj.woff +0 -0
  426. package/dist/ui/client/assets/nunito-vietnamese-700-normal-Ch8EUCfz.woff2 +0 -0
  427. package/dist/ui/client/index.html +2 -2
  428. package/dist/ui/server/server.js +20388 -18163
  429. package/package.json +20 -17
  430. package/dist/adapters/database/data-source/singleton.d.ts +0 -5
  431. package/dist/adapters/database/data-source/singleton.d.ts.map +0 -1
  432. package/dist/adapters/database/data-source/singleton.mjs +0 -19
  433. package/dist/adapters/database/data-source/singleton.mjs.map +0 -1
  434. package/dist/adapters/database/event-publisher/index.d.ts +0 -2
  435. package/dist/adapters/database/event-publisher/index.d.ts.map +0 -1
  436. package/dist/adapters/database/event-publisher/index.mjs +0 -5
  437. package/dist/adapters/database/event-publisher/module.d.ts +0 -6
  438. package/dist/adapters/database/event-publisher/module.d.ts.map +0 -1
  439. package/dist/adapters/database/event-publisher/module.mjs +0 -25
  440. package/dist/adapters/database/event-publisher/module.mjs.map +0 -1
  441. package/dist/app/module.d.ts +0 -2
  442. package/dist/app/module.d.ts.map +0 -1
  443. package/dist/app/module.mjs +0 -5
  444. package/dist/app/types.d.ts +0 -2
  445. package/dist/app/types.d.ts.map +0 -1
  446. package/dist/ui/client/assets/index-CjKS9a0I.css +0 -1
  447. package/dist/ui/client/assets/index-bGxpD1zZ.js +0 -95
  448. /package/dist/{app → adapters/database/subscriber}/types.mjs +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"module.mjs","names":["ClientEntity","ClientPermissionEntity","ClientRoleEntity","PermissionEntity","RealmEntity","RobotEntity","RobotPermissionEntity","RobotRoleEntity","RoleEntity","RolePermissionEntity","ScopeEntity","UserPermissionEntity","UserRoleEntity","SystemPolicyName","PermissionPolicyEntity","PolicyRepository","UserRepository","ClientProvisioningSynchronizer","GraphProvisioningSynchronizer","PermissionProvisioningSynchronizer","PolicyProvisioningSynchronizer","RealmProvisioningSynchronizer","RobotProvisioningSynchronizer","RoleProvisioningSynchronizer","ScopeProvisioningSynchronizer","UserProvisioningSynchronizer","ClientPermissionRepositoryAdapter","ClientRepositoryAdapter","ClientRoleRepositoryAdapter","PermissionPolicyRepositoryAdapter","PermissionRepositoryAdapter","PolicyRepositoryAdapter","RealmRepositoryAdapter","RobotPermissionRepositoryAdapter","RobotRepositoryAdapter","RobotRoleRepositoryAdapter","RolePermissionRepositoryAdapter","RoleRepositoryAdapter","ScopeRepositoryAdapter","UserPermissionRepositoryAdapter","UserRepositoryAdapter","UserRoleRepositoryAdapter","DatabaseInjectionKey","ModuleName","fs","path","ConfigInjectionKey","CompositeProvisioningSource","FileProvisioningSource","ProvisionerModule","name","dependencies","sources","PROVISIONING","CONFIG","DATABASE","setup","container","config","resolve","provisioningDir","join","writableDirectoryPath","existsSync","push","cwd","composite","data","load","dataSource","DataSource","realmRepository","permissionRepository","repository","policyRepository","permissionPolicyRepository","policySynchronizer","roleRepository","clientRepository","permissionSynchronizer","roleSynchronizer","rolePermissionRepository","clientSynchronizer","clientRoleRepository","clientPermissionRepository","userSynchronizer","userRepository","userRoleRepository","userPermissionRepository","robotSynchronizer","robotRepository","robotRoleRepository","robotPermissionRepository","scopeRepository","scopeSynchronizer","realmSynchronizer","rootSynchronizer","synchronize","permissionsDefaultPolicyAssignment","assignDefaultPolicy","defaultPolicy","findOneByName","DEFAULT","permissionRepo","getRepository","junctionRepo","permissions","find","permission","hasAnyPolicy","findOneBy","permission_id","id","save","create","permission_realm_id","realm_id","policy_id","policy_realm_id"],"sources":["../../../../src/app/modules/provisioning/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\nimport type {\n Client,\n ClientPermission,\n ClientRole,\n PermissionPolicy,\n Realm,\n Robot,\n RobotPermission,\n RobotRole,\n Role,\n RolePermission,\n Scope,\n UserPermission,\n UserRole,\n} from '@authup/core-kit';\nimport type { DataSource, Repository } from 'typeorm';\nimport {\n ClientEntity,\n ClientPermissionEntity,\n ClientRoleEntity,\n PermissionEntity,\n RealmEntity,\n RobotEntity,\n RobotPermissionEntity,\n RobotRoleEntity,\n RoleEntity,\n RolePermissionEntity,\n ScopeEntity,\n UserPermissionEntity,\n UserRoleEntity,\n} from '../../../adapters/database/index.ts';\nimport { SystemPolicyName } from '@authup/access';\nimport {\n PermissionPolicyEntity,\n PolicyRepository,\n UserRepository,\n} from '../../../adapters/database/domains/index.ts';\nimport type { IContainer } from 'eldin';\nimport {\n ClientProvisioningSynchronizer,\n GraphProvisioningSynchronizer,\n PermissionProvisioningSynchronizer,\n PolicyProvisioningSynchronizer,\n RealmProvisioningSynchronizer,\n RobotProvisioningSynchronizer,\n RoleProvisioningSynchronizer,\n ScopeProvisioningSynchronizer,\n UserProvisioningSynchronizer,\n} from '../../../core/provisioning/synchronizer/index.ts';\nimport type { IProvisioningSource } from '../../../core/provisioning/types.ts';\nimport {\n ClientPermissionRepositoryAdapter,\n ClientRepositoryAdapter,\n ClientRoleRepositoryAdapter,\n PermissionPolicyRepositoryAdapter,\n PermissionRepositoryAdapter,\n PolicyRepositoryAdapter,\n RealmRepositoryAdapter,\n RobotPermissionRepositoryAdapter,\n RobotRepositoryAdapter,\n RobotRoleRepositoryAdapter,\n RolePermissionRepositoryAdapter,\n RoleRepositoryAdapter,\n ScopeRepositoryAdapter,\n UserPermissionRepositoryAdapter,\n UserRepositoryAdapter,\n UserRoleRepositoryAdapter,\n} from '../database/repositories/index.ts';\nimport { DatabaseInjectionKey } from '../database/index.ts';\nimport type { IModule } from 'orkos';\nimport { ModuleName } from '../constants.ts';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { ConfigInjectionKey } from '../config/index.ts';\nimport { CompositeProvisioningSource, FileProvisioningSource } from './sources/index.ts';\n\nexport class ProvisionerModule implements IModule {\n readonly name: string;\n\n readonly dependencies: string[];\n\n protected sources: IProvisioningSource[];\n\n constructor(sources: IProvisioningSource[] = []) {\n this.name = ModuleName.PROVISIONING;\n this.dependencies = [ModuleName.CONFIG, ModuleName.DATABASE];\n this.sources = sources;\n }\n\n async setup(container: IContainer): Promise<void> {\n const sources = [...this.sources];\n\n const config = container.resolve(ConfigInjectionKey);\n const provisioningDir = path.join(config.writableDirectoryPath, 'provisioning');\n if (fs.existsSync(provisioningDir)) {\n sources.push(new FileProvisioningSource({ cwd: provisioningDir }));\n }\n\n const composite = new CompositeProvisioningSource(sources);\n const data = await composite.load(container);\n\n const dataSource = container.resolve(DatabaseInjectionKey.DataSource);\n const realmRepository = container.resolve<Repository<Realm>>(RealmEntity);\n\n const permissionRepository = new PermissionRepositoryAdapter({\n repository: container.resolve<Repository<PermissionEntity>>(PermissionEntity),\n realmRepository,\n });\n\n const policyRepository = new PolicyRepositoryAdapter({\n repository: new PolicyRepository(dataSource),\n realmRepository,\n });\n\n // ---------------------------------------------------------------\n // Synchronize all entities (policies → permissions → roles → ...)\n // ---------------------------------------------------------------\n\n const permissionPolicyRepository = new PermissionPolicyRepositoryAdapter(\n container.resolve<Repository<PermissionPolicy>>(PermissionPolicyEntity),\n );\n\n const policySynchronizer = new PolicyProvisioningSynchronizer({\n repository: policyRepository,\n permissionPolicyRepository,\n });\n\n const roleRepository = new RoleRepositoryAdapter({\n repository: container.resolve<Repository<Role>>(RoleEntity),\n realmRepository,\n });\n const clientRepository = new ClientRepositoryAdapter({\n repository: container.resolve<Repository<Client>>(ClientEntity),\n realmRepository,\n });\n\n const permissionSynchronizer = new PermissionProvisioningSynchronizer({\n repository: permissionRepository,\n policyRepository,\n permissionPolicyRepository,\n });\n\n const roleSynchronizer = new RoleProvisioningSynchronizer({\n repository: roleRepository,\n permissionRepository,\n policyRepository,\n rolePermissionRepository: new RolePermissionRepositoryAdapter(\n container.resolve<Repository<RolePermission>>(RolePermissionEntity),\n ),\n });\n\n const clientSynchronizer = new ClientProvisioningSynchronizer({\n clientRepository,\n clientRoleRepository: new ClientRoleRepositoryAdapter(\n container.resolve<Repository<ClientRole>>(ClientRoleEntity),\n ),\n clientPermissionRepository: new ClientPermissionRepositoryAdapter(\n container.resolve<Repository<ClientPermission>>(ClientPermissionEntity),\n ),\n\n roleRepository,\n permissionRepository,\n\n roleSynchronizer,\n permissionSynchronizer,\n });\n\n const userSynchronizer = new UserProvisioningSynchronizer({\n userRepository: new UserRepositoryAdapter({\n repository: new UserRepository(dataSource),\n realmRepository,\n }),\n userRoleRepository: new UserRoleRepositoryAdapter(\n container.resolve<Repository<UserRole>>(UserRoleEntity),\n ),\n userPermissionRepository: new UserPermissionRepositoryAdapter(\n container.resolve<Repository<UserPermission>>(UserPermissionEntity),\n ),\n\n clientRepository,\n roleRepository,\n permissionRepository,\n });\n\n const robotSynchronizer = new RobotProvisioningSynchronizer({\n robotRepository: new RobotRepositoryAdapter({\n repository: container.resolve<Repository<Robot>>(RobotEntity),\n realmRepository,\n }),\n robotRoleRepository: new RobotRoleRepositoryAdapter(\n container.resolve<Repository<RobotRole>>(RobotRoleEntity),\n ),\n robotPermissionRepository: new RobotPermissionRepositoryAdapter(\n container.resolve<Repository<RobotPermission>>(RobotPermissionEntity),\n ),\n\n roleRepository,\n permissionRepository,\n });\n\n const scopeRepository = new ScopeRepositoryAdapter({\n repository: container.resolve<Repository<Scope>>(ScopeEntity),\n realmRepository,\n });\n\n const scopeSynchronizer = new ScopeProvisioningSynchronizer({ repository: scopeRepository });\n\n const realmSynchronizer = new RealmProvisioningSynchronizer({\n repository: new RealmRepositoryAdapter(realmRepository),\n\n clientSynchronizer,\n roleSynchronizer,\n permissionSynchronizer,\n userSynchronizer,\n robotSynchronizer,\n scopeSynchronizer,\n });\n\n const rootSynchronizer = new GraphProvisioningSynchronizer({\n policySynchronizer,\n permissionSynchronizer,\n roleSynchronizer,\n realmSynchronizer,\n scopeSynchronizer,\n });\n\n await rootSynchronizer.synchronize(data);\n\n if (config.permissionsDefaultPolicyAssignment) {\n await this.assignDefaultPolicy(dataSource, policyRepository);\n }\n }\n\n protected async assignDefaultPolicy(\n dataSource: DataSource,\n policyRepository: PolicyRepositoryAdapter,\n ): Promise<void> {\n const defaultPolicy = await policyRepository.findOneByName(SystemPolicyName.DEFAULT);\n if (!defaultPolicy) {\n return;\n }\n\n const permissionRepo = dataSource.getRepository(PermissionEntity);\n const junctionRepo = dataSource.getRepository(PermissionPolicyEntity);\n\n const permissions = await permissionRepo.find();\n for (const permission of permissions) {\n const hasAnyPolicy = await junctionRepo.findOneBy({ permission_id: permission.id });\n\n if (!hasAnyPolicy) {\n await junctionRepo.save(junctionRepo.create({\n permission_id: permission.id,\n permission_realm_id: permission.realm_id,\n policy_id: defaultPolicy.id,\n policy_realm_id: defaultPolicy.realm_id,\n }));\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,IAAaiD,oBAAb,MAAaA;CACAC;CAEAC;CAECC;CAEV,YAAYA,UAAiC,CAAA,GAAI;EAC7C,KAAKF,OAAOP,WAAWU;EACvB,KAAKF,eAAe,CAACR,WAAWW,QAAQX,WAAWY,QAAAA;EACnD,KAAKH,UAAUA;CACnB;CAEA,MAAMI,MAAMC,WAAsC;EAC9C,MAAML,UAAU,CAA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nD;CAEA,MAAgByB,oBACZ9B,YACAK,kBACa;EACb,MAAM0B,gBAAgB,MAAM1B,iBAAiB2B,cAAcxF,iBAAiByF,OAAO;EACnF,IAAI,CAACF,eACD;EAGJ,MAAMG,iBAAiBlC,WAAWmC,cAAcrG,gBAAAA;EAChD,MAAMsG,eAAepC,WAAWmC,cAAc1F,sBAAAA;EAE9C,MAAM4F,cAAc,MAAMH,eAAeI,KAAI;EAC7C,KAAK,MAAMC,cAAcF,aAGrB,IAAI,CAACG,MAFsBJ,aAAaK,UAAU,EAAEC,eAAeH,WAAWI,GAAG,CAAA,GAG7E,MAAMP,aAAaQ,KAAKR,aAAaS,OAAO;GACxCH,eAAeH,WAAWI;GAC1BG,qBAAqBP,WAAWQ;GAChCC,WAAWjB,cAAcY;GACzBM,iBAAiBlB,cAAcgB;EACnC,CAAA,CAAA;CAGZ;AACJ"}
1
+ {"version":3,"file":"module.mjs","names":["ClientEntity","ClientPermissionEntity","ClientRoleEntity","PermissionEntity","RealmEntity","RobotEntity","RobotPermissionEntity","RobotRoleEntity","RoleEntity","RolePermissionEntity","ScopeEntity","UserPermissionEntity","UserRoleEntity","SystemPolicyName","PermissionPolicyEntity","PolicyRepository","UserRepository","ClientProvisioningSynchronizer","GraphProvisioningSynchronizer","PermissionProvisioningSynchronizer","PolicyProvisioningSynchronizer","RealmProvisioningSynchronizer","RobotProvisioningSynchronizer","RoleProvisioningSynchronizer","ScopeProvisioningSynchronizer","UserProvisioningSynchronizer","ClientPermissionRepositoryAdapter","ClientRepositoryAdapter","ClientRoleRepositoryAdapter","PermissionPolicyRepositoryAdapter","PermissionRepositoryAdapter","PolicyRepositoryAdapter","RealmRepositoryAdapter","RobotPermissionRepositoryAdapter","RobotRepositoryAdapter","RobotRoleRepositoryAdapter","RolePermissionRepositoryAdapter","RoleRepositoryAdapter","ScopeRepositoryAdapter","UserPermissionRepositoryAdapter","UserRepositoryAdapter","UserRoleRepositoryAdapter","DatabaseInjectionKey","ModuleName","fs","path","ConfigInjectionKey","getAppOrigins","LoggerInjectionKey","WebClientProvisioner","CompositeProvisioningSource","FileProvisioningSource","ProvisionerModule","name","dependencies","sources","PROVISIONING","CONFIG","DATABASE","setup","container","config","resolve","provisioningDir","join","writableDirectoryPath","existsSync","push","cwd","composite","data","load","dataSource","DataSource","realmRepository","permissionRepository","repository","policyRepository","permissionPolicyRepository","policySynchronizer","roleRepository","clientRepository","permissionSynchronizer","roleSynchronizer","rolePermissionRepository","clientSynchronizer","clientRoleRepository","clientPermissionRepository","userSynchronizer","userRepository","userRoleRepository","userPermissionRepository","robotSynchronizer","robotRepository","robotRoleRepository","robotPermissionRepository","scopeRepository","scopeSynchronizer","realmSynchronizer","rootSynchronizer","synchronize","webClientProvisioner","appOrigins","logger","realms","find","realm","ensureForRealm","permissionsDefaultPolicyAssignment","assignDefaultPolicy","defaultPolicy","findOneByName","DEFAULT","permissionRepo","getRepository","junctionRepo","permissions","permission","hasAnyPolicy","findOneBy","permission_id","id","save","create","permission_realm_id","realm_id","policy_id","policy_realm_id"],"sources":["../../../../src/app/modules/provisioning/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\nimport type {\n Client,\n ClientPermission,\n ClientRole,\n PermissionPolicy,\n Realm,\n Robot,\n RobotPermission,\n RobotRole,\n Role,\n RolePermission,\n Scope,\n UserPermission,\n UserRole,\n} from '@authup/core-kit';\nimport type { DataSource, Repository } from 'typeorm';\nimport {\n ClientEntity,\n ClientPermissionEntity,\n ClientRoleEntity,\n PermissionEntity,\n RealmEntity,\n RobotEntity,\n RobotPermissionEntity,\n RobotRoleEntity,\n RoleEntity,\n RolePermissionEntity,\n ScopeEntity,\n UserPermissionEntity,\n UserRoleEntity,\n} from '../../../adapters/database/index.ts';\nimport { SystemPolicyName } from '@authup/access';\nimport {\n PermissionPolicyEntity,\n PolicyRepository,\n UserRepository,\n} from '../../../adapters/database/domains/index.ts';\nimport type { IContainer } from 'eldin';\nimport {\n ClientProvisioningSynchronizer,\n GraphProvisioningSynchronizer,\n PermissionProvisioningSynchronizer,\n PolicyProvisioningSynchronizer,\n RealmProvisioningSynchronizer,\n RobotProvisioningSynchronizer,\n RoleProvisioningSynchronizer,\n ScopeProvisioningSynchronizer,\n UserProvisioningSynchronizer,\n} from '../../../core/provisioning/synchronizer/index.ts';\nimport type { IProvisioningSource } from '../../../core/provisioning/types.ts';\nimport {\n ClientPermissionRepositoryAdapter,\n ClientRepositoryAdapter,\n ClientRoleRepositoryAdapter,\n PermissionPolicyRepositoryAdapter,\n PermissionRepositoryAdapter,\n PolicyRepositoryAdapter,\n RealmRepositoryAdapter,\n RobotPermissionRepositoryAdapter,\n RobotRepositoryAdapter,\n RobotRoleRepositoryAdapter,\n RolePermissionRepositoryAdapter,\n RoleRepositoryAdapter,\n ScopeRepositoryAdapter,\n UserPermissionRepositoryAdapter,\n UserRepositoryAdapter,\n UserRoleRepositoryAdapter,\n} from '../database/repositories/index.ts';\nimport { DatabaseInjectionKey } from '../database/index.ts';\nimport type { IModule } from 'orkos';\nimport { ModuleName } from '../constants.ts';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { ConfigInjectionKey, getAppOrigins } from '../config/index.ts';\nimport { LoggerInjectionKey } from '../logger/index.ts';\nimport { WebClientProvisioner } from '../../../core/entities/client/index.ts';\nimport { CompositeProvisioningSource, FileProvisioningSource } from './sources/index.ts';\n\nexport class ProvisionerModule implements IModule {\n readonly name: string;\n\n readonly dependencies: string[];\n\n protected sources: IProvisioningSource[];\n\n constructor(sources: IProvisioningSource[] = []) {\n this.name = ModuleName.PROVISIONING;\n this.dependencies = [ModuleName.CONFIG, ModuleName.DATABASE];\n this.sources = sources;\n }\n\n async setup(container: IContainer): Promise<void> {\n const sources = [...this.sources];\n\n const config = container.resolve(ConfigInjectionKey);\n const provisioningDir = path.join(config.writableDirectoryPath, 'provisioning');\n if (fs.existsSync(provisioningDir)) {\n sources.push(new FileProvisioningSource({ cwd: provisioningDir }));\n }\n\n const composite = new CompositeProvisioningSource(sources);\n const data = await composite.load(container);\n\n const dataSource = container.resolve(DatabaseInjectionKey.DataSource);\n const realmRepository = container.resolve<Repository<Realm>>(RealmEntity);\n\n const permissionRepository = new PermissionRepositoryAdapter({\n repository: container.resolve<Repository<PermissionEntity>>(PermissionEntity),\n realmRepository,\n });\n\n const policyRepository = new PolicyRepositoryAdapter({\n repository: new PolicyRepository(dataSource),\n realmRepository,\n });\n\n // ---------------------------------------------------------------\n // Synchronize all entities (policies → permissions → roles → ...)\n // ---------------------------------------------------------------\n\n const permissionPolicyRepository = new PermissionPolicyRepositoryAdapter(\n container.resolve<Repository<PermissionPolicy>>(PermissionPolicyEntity),\n );\n\n const policySynchronizer = new PolicyProvisioningSynchronizer({\n repository: policyRepository,\n permissionPolicyRepository,\n });\n\n const roleRepository = new RoleRepositoryAdapter({\n repository: container.resolve<Repository<Role>>(RoleEntity),\n realmRepository,\n });\n const clientRepository = new ClientRepositoryAdapter({\n repository: container.resolve<Repository<Client>>(ClientEntity),\n realmRepository,\n });\n\n const permissionSynchronizer = new PermissionProvisioningSynchronizer({\n repository: permissionRepository,\n policyRepository,\n permissionPolicyRepository,\n });\n\n const roleSynchronizer = new RoleProvisioningSynchronizer({\n repository: roleRepository,\n permissionRepository,\n policyRepository,\n rolePermissionRepository: new RolePermissionRepositoryAdapter(\n container.resolve<Repository<RolePermission>>(RolePermissionEntity),\n ),\n });\n\n const clientSynchronizer = new ClientProvisioningSynchronizer({\n clientRepository,\n clientRoleRepository: new ClientRoleRepositoryAdapter(\n container.resolve<Repository<ClientRole>>(ClientRoleEntity),\n ),\n clientPermissionRepository: new ClientPermissionRepositoryAdapter(\n container.resolve<Repository<ClientPermission>>(ClientPermissionEntity),\n ),\n\n roleRepository,\n permissionRepository,\n\n roleSynchronizer,\n permissionSynchronizer,\n });\n\n const userSynchronizer = new UserProvisioningSynchronizer({\n userRepository: new UserRepositoryAdapter({\n repository: new UserRepository(dataSource),\n realmRepository,\n }),\n userRoleRepository: new UserRoleRepositoryAdapter(\n container.resolve<Repository<UserRole>>(UserRoleEntity),\n ),\n userPermissionRepository: new UserPermissionRepositoryAdapter(\n container.resolve<Repository<UserPermission>>(UserPermissionEntity),\n ),\n\n clientRepository,\n roleRepository,\n permissionRepository,\n });\n\n const robotSynchronizer = new RobotProvisioningSynchronizer({\n robotRepository: new RobotRepositoryAdapter({\n repository: container.resolve<Repository<Robot>>(RobotEntity),\n realmRepository,\n }),\n robotRoleRepository: new RobotRoleRepositoryAdapter(\n container.resolve<Repository<RobotRole>>(RobotRoleEntity),\n ),\n robotPermissionRepository: new RobotPermissionRepositoryAdapter(\n container.resolve<Repository<RobotPermission>>(RobotPermissionEntity),\n ),\n\n roleRepository,\n permissionRepository,\n });\n\n const scopeRepository = new ScopeRepositoryAdapter({\n repository: container.resolve<Repository<Scope>>(ScopeEntity),\n realmRepository,\n });\n\n const scopeSynchronizer = new ScopeProvisioningSynchronizer({ repository: scopeRepository });\n\n const realmSynchronizer = new RealmProvisioningSynchronizer({\n repository: new RealmRepositoryAdapter(realmRepository),\n\n clientSynchronizer,\n roleSynchronizer,\n permissionSynchronizer,\n userSynchronizer,\n robotSynchronizer,\n scopeSynchronizer,\n });\n\n const rootSynchronizer = new GraphProvisioningSynchronizer({\n policySynchronizer,\n permissionSynchronizer,\n roleSynchronizer,\n realmSynchronizer,\n scopeSynchronizer,\n });\n\n await rootSynchronizer.synchronize(data);\n\n // ---------------------------------------------------------------\n // Per-realm public `web` client. Single provisioning mechanism:\n // list every realm (incl. pre-existing) and upsert its web client.\n // Idempotent; guarded on built_in inside the provisioner.\n // ---------------------------------------------------------------\n const webClientProvisioner = new WebClientProvisioner({\n clientRepository,\n appOrigins: getAppOrigins(config),\n logger: container.resolve(LoggerInjectionKey),\n });\n\n const realms = await realmRepository.find();\n for (const realm of realms) {\n await webClientProvisioner.ensureForRealm(realm);\n }\n\n if (config.permissionsDefaultPolicyAssignment) {\n await this.assignDefaultPolicy(dataSource, policyRepository);\n }\n }\n\n protected async assignDefaultPolicy(\n dataSource: DataSource,\n policyRepository: PolicyRepositoryAdapter,\n ): Promise<void> {\n const defaultPolicy = await policyRepository.findOneByName(SystemPolicyName.DEFAULT);\n if (!defaultPolicy) {\n return;\n }\n\n const permissionRepo = dataSource.getRepository(PermissionEntity);\n const junctionRepo = dataSource.getRepository(PermissionPolicyEntity);\n\n const permissions = await permissionRepo.find();\n for (const permission of permissions) {\n const hasAnyPolicy = await junctionRepo.findOneBy({ permission_id: permission.id });\n\n if (!hasAnyPolicy) {\n await junctionRepo.save(junctionRepo.create({\n permission_id: permission.id,\n permission_realm_id: permission.realm_id,\n policy_id: defaultPolicy.id,\n policy_realm_id: defaultPolicy.realm_id,\n }));\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,IAAaoD,oBAAb,MAAaA;CACAC;CAEAC;CAECC;CAEV,YAAYA,UAAiC,CAAA,GAAI;EAC7C,KAAKF,OAAOV,WAAWa;EACvB,KAAKF,eAAe,CAACX,WAAWc,QAAQd,WAAWe,QAAAA;EACnD,KAAKH,UAAUA;CACnB;CAEA,MAAMI,MAAMC,WAAsC;EAC9C,MAAML,UAAU,CAAA,GAAI,KAAKA,OAAAA;EAEzB,MAAMM,SAASD,UAAUE,QAAQhB,kBAAAA;EACjC,MAAMiB,kBAAkBlB,KAAKmB,KAAKH,OAAOI,uBAAuB,cAAA;EAChE,IAAIrB,GAAGsB,WAAWH,eAAAA,GACdR,QAAQY,KAAK,IAAIhB,uBAAuB,EAAEiB,KAAKL,gBAAgB,CAAA,CAAA;EAInE,MAAMO,OAAO,MAAMD,IADGnB,4BAA4BK,OAC/Bc,CAAAA,CAAUE,KAAKX,SAAAA;EAElC,MAAMY,aAAaZ,UAAUE,QAAQpB,qBAAqB+B,UAAU;EACpE,MAAMC,kBAAkBd,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AM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IA8F/D,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAWrE"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../../src/app/modules/provisioning/sources/default/module.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAMxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,+DAA+D,CAAC;AAClH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC;AAC1G,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AACxG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yDAAyD,CAAC;AACtG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yDAAyD,CAAC;AACtG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AAGxG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAErF,qBAAa,yBAA0B,YAAW,mBAAmB;IACjE,aAAa,IAAI,wBAAwB,EAAE;IAuI3C,gBAAgB,IAAI,4BAA4B,EAAE;IA6BlD,WAAW,IAAI,uBAAuB,EAAE;IAcxC,UAAU,IAAI,sBAAsB,EAAE;IA4DhC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IA8F/D,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAWrE"}
@@ -10,7 +10,8 @@ import "../../../../../core/index.mjs";
10
10
  import { ConfigInjectionKey } from "../../../config/constants.mjs";
11
11
  import "../../../config/index.mjs";
12
12
  import { PermissionName, REALM_MASTER_NAME, ROLE_ADMIN_NAME, ROLE_REALM_ADMIN_NAME, ScopeName, buildUserFakeEmail } from "@authup/core-kit";
13
- import { BuiltInPolicyType, DecisionStrategy, SystemPolicyName } from "@authup/access";
13
+ import { DecisionStrategy } from "@authup/kit";
14
+ import { BuiltInPolicyType, SystemPolicyName } from "@authup/access";
14
15
  //#region src/app/modules/provisioning/sources/default/module.ts
15
16
  var DefaultProvisioningSource = class {
16
17
  buildPolicies() {
@@ -1 +1 @@
1
- {"version":3,"file":"module.mjs","names":["BuiltInPolicyType","DecisionStrategy","SystemPolicyName","PermissionName","REALM_MASTER_NAME","ROLE_ADMIN_NAME","ROLE_REALM_ADMIN_NAME","ScopeName","buildUserFakeEmail","ClientCredentialsService","RobotCredentialsService","UserCredentialsService","ConfigInjectionKey","ProvisioningEntityStrategyType","DefaultProvisioningSource","buildPolicies","attributes","name","DEFAULT","type","COMPOSITE","built_in","realm_id","extraAttributes","decision_strategy","UNANIMOUS","children","IDENTITY","PERMISSION_BINDING","REALM_MATCH","attribute_name","attribute_name_strict","identity_master_match_all","attribute_null_match_all","REALM_BOUND","REALM_OR_GLOBAL","CLIENT_NAMES_SELF_MANAGE","ATTRIBUTE_NAMES","invert","names","ROBOT_NAMES_SELF_MANAGE","USER_NAMES_SELF_MANAGE","buildPermissions","policiesByPermission","CLIENT_SELF_MANAGE","ROBOT_SELF_MANAGE","USER_SELF_MANAGE","Object","values","map","entity","strategy","MERGE","policies","relations","buildScopes","buildRoles","globalPermissions","globalPermissionsExclude","REALM_CREATE","REALM_UPDATE","REALM_DELETE","globalPermissionsPolicyName","globalPermissionsPolicyOverrides","CLIENT_CREATE","CLIENT_UPDATE","CLIENT_DELETE","IDENTITY_PROVIDER_CREATE","IDENTITY_PROVIDER_UPDATE","IDENTITY_PROVIDER_DELETE","PERMISSION_CREATE","PERMISSION_UPDATE","PERMISSION_DELETE","ROBOT_CREATE","ROBOT_UPDATE","ROBOT_DELETE","ROLE_CREATE","ROLE_UPDATE","ROLE_DELETE","SCOPE_CREATE","SCOPE_UPDATE","SCOPE_DELETE","USER_CREATE","USER_UPDATE","USER_DELETE","buildRealms","config","masterRealm","userCredentialsService","userStrategy","userAdminPasswordReset","users","password","protect","userAdminPassword","email","active","userAdminEnabled","globalRoles","clientCredentialsService","clientStrategy","clientSystemSecretReset","clients","is_confidential","secret","clientSystemSecret","secret_hashed","clientSystemEnabled","robotCredentialsService","robotStrategy","robotAdminSecretReset","robots","robotAdminSecret","robotAdminEnabled","load","container","resolve","permissions","scopes","roles","realms"],"sources":["../../../../../../src/app/modules/provisioning/sources/default/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BuiltInPolicyType, DecisionStrategy, SystemPolicyName } from '@authup/access';\nimport type {\n Client, \n Permission, \n Robot, \n Role, \n Scope, \n User,\n} from '@authup/core-kit';\nimport {\n PermissionName, \n REALM_MASTER_NAME, \n ROLE_ADMIN_NAME, \n ROLE_REALM_ADMIN_NAME, \n ScopeName, \n buildUserFakeEmail,\n} from '@authup/core-kit';\nimport type { IContainer } from 'eldin';\nimport {\n ClientCredentialsService,\n RobotCredentialsService,\n UserCredentialsService,\n} from '../../../../../core/index.ts';\nimport type { Config } from '../../../config/index.ts';\nimport { ConfigInjectionKey } from '../../../config/index.ts';\nimport type { PermissionProvisioningEntity } from '../../../../../core/provisioning/entities/permission/index.ts';\nimport type { PolicyProvisioningEntity } from '../../../../../core/provisioning/entities/policy/index.ts';\nimport type { RealmProvisioningEntity } from '../../../../../core/provisioning/entities/realm/index.ts';\nimport type { RoleProvisioningEntity } from '../../../../../core/provisioning/entities/role/index.ts';\nimport type { RootProvisioningEntity } from '../../../../../core/provisioning/entities/root/index.ts';\nimport type { ScopeProvisioningEntity } from '../../../../../core/provisioning/entities/scope/index.ts';\nimport type { ProvisioningEntityStrategy } from '../../../../../core/provisioning/strategy/index.ts';\nimport { ProvisioningEntityStrategyType } from '../../../../../core/provisioning/strategy/index.ts';\nimport type { IProvisioningSource } from '../../../../../core/provisioning/types.ts';\n\nexport class DefaultProvisioningSource implements IProvisioningSource {\n buildPolicies(): PolicyProvisioningEntity[] {\n return [\n {\n attributes: {\n name: SystemPolicyName.DEFAULT,\n type: BuiltInPolicyType.COMPOSITE,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: { decision_strategy: DecisionStrategy.UNANIMOUS },\n children: [\n {\n attributes: {\n name: SystemPolicyName.IDENTITY,\n type: BuiltInPolicyType.IDENTITY,\n built_in: true,\n realm_id: null,\n },\n },\n {\n attributes: {\n name: SystemPolicyName.PERMISSION_BINDING,\n type: BuiltInPolicyType.PERMISSION_BINDING,\n built_in: true,\n realm_id: null,\n },\n },\n {\n attributes: {\n name: SystemPolicyName.REALM_MATCH,\n type: BuiltInPolicyType.REALM_MATCH,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n attribute_name: ['realm_id'],\n attribute_name_strict: false,\n identity_master_match_all: false,\n attribute_null_match_all: true,\n },\n },\n ],\n },\n {\n attributes: {\n name: SystemPolicyName.REALM_BOUND,\n type: BuiltInPolicyType.REALM_MATCH,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n attribute_name: ['realm_id'],\n attribute_name_strict: false,\n attribute_null_match_all: false,\n identity_master_match_all: false,\n },\n },\n {\n attributes: {\n name: SystemPolicyName.REALM_OR_GLOBAL,\n type: BuiltInPolicyType.REALM_MATCH,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n attribute_name: ['realm_id'],\n attribute_name_strict: false,\n attribute_null_match_all: true,\n identity_master_match_all: false,\n },\n },\n // Self-manage policies use ATTRIBUTE_NAMES + invert: true (denylist).\n // Each `names` entry is what self-edit must REJECT; everything else\n // is permitted. New columns added to the entity are self-editable\n // by default — extend the denylist when adding admin-only state.\n {\n attributes: {\n name: SystemPolicyName.CLIENT_NAMES_SELF_MANAGE,\n type: BuiltInPolicyType.ATTRIBUTE_NAMES,\n invert: true,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n names: [\n // FK + lifecycle\n 'active',\n 'realm_id',\n // Security-critical: a self-edit must not change the\n // client's confidentiality (toggling this clears the\n // secret) or downgrade the secret-storage format\n // (which would persist the secret in plaintext).\n 'is_confidential',\n 'secret_hashed',\n 'secret_encrypted',\n ],\n },\n },\n {\n attributes: {\n name: SystemPolicyName.ROBOT_NAMES_SELF_MANAGE,\n type: BuiltInPolicyType.ATTRIBUTE_NAMES,\n invert: true,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n names: [\n 'active',\n 'realm_id',\n 'user_id',\n ],\n },\n },\n {\n attributes: {\n name: SystemPolicyName.USER_NAMES_SELF_MANAGE,\n type: BuiltInPolicyType.ATTRIBUTE_NAMES,\n invert: true,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n names: [\n 'active',\n 'name_locked',\n 'status',\n 'status_message',\n 'realm_id',\n ],\n },\n },\n ];\n }\n\n buildPermissions(): PermissionProvisioningEntity[] {\n const policiesByPermission: Partial<Record<string, string[]>> = {\n [PermissionName.CLIENT_SELF_MANAGE]: [SystemPolicyName.DEFAULT, SystemPolicyName.CLIENT_NAMES_SELF_MANAGE],\n [PermissionName.ROBOT_SELF_MANAGE]: [SystemPolicyName.DEFAULT, SystemPolicyName.ROBOT_NAMES_SELF_MANAGE],\n [PermissionName.USER_SELF_MANAGE]: [SystemPolicyName.DEFAULT, SystemPolicyName.USER_NAMES_SELF_MANAGE],\n };\n\n return Object.values(PermissionName)\n .map((name) => {\n const entity: PermissionProvisioningEntity = {\n strategy: {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in'] as (keyof Permission)[],\n },\n attributes: {\n name,\n built_in: true,\n },\n };\n\n const policies = policiesByPermission[name];\n if (policies) {\n entity.relations = { policies };\n }\n\n return entity;\n });\n }\n\n buildScopes(): ScopeProvisioningEntity[] {\n return Object.values(ScopeName)\n .map((name) => ({\n strategy: {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in'] as (keyof Scope)[],\n },\n attributes: {\n name,\n built_in: true,\n },\n }));\n }\n\n buildRoles(): RoleProvisioningEntity[] {\n return [\n {\n strategy: {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in'] as (keyof Role)[],\n },\n attributes: {\n name: ROLE_ADMIN_NAME,\n built_in: true,\n },\n relations: { globalPermissions: ['*'] },\n },\n {\n strategy: {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in'] as (keyof Role)[],\n },\n attributes: {\n name: ROLE_REALM_ADMIN_NAME,\n built_in: true,\n },\n relations: {\n globalPermissions: ['*'],\n globalPermissionsExclude: [\n PermissionName.REALM_CREATE,\n PermissionName.REALM_UPDATE,\n PermissionName.REALM_DELETE,\n ],\n globalPermissionsPolicyName: SystemPolicyName.REALM_OR_GLOBAL,\n globalPermissionsPolicyOverrides: {\n [SystemPolicyName.REALM_BOUND]: [\n PermissionName.CLIENT_CREATE,\n PermissionName.CLIENT_UPDATE,\n PermissionName.CLIENT_DELETE,\n PermissionName.IDENTITY_PROVIDER_CREATE,\n PermissionName.IDENTITY_PROVIDER_UPDATE,\n PermissionName.IDENTITY_PROVIDER_DELETE,\n PermissionName.PERMISSION_CREATE,\n PermissionName.PERMISSION_UPDATE,\n PermissionName.PERMISSION_DELETE,\n PermissionName.ROBOT_CREATE,\n PermissionName.ROBOT_UPDATE,\n PermissionName.ROBOT_DELETE,\n PermissionName.ROLE_CREATE,\n PermissionName.ROLE_UPDATE,\n PermissionName.ROLE_DELETE,\n PermissionName.SCOPE_CREATE,\n PermissionName.SCOPE_UPDATE,\n PermissionName.SCOPE_DELETE,\n PermissionName.USER_CREATE,\n PermissionName.USER_UPDATE,\n PermissionName.USER_DELETE,\n ],\n },\n },\n },\n ];\n }\n\n async buildRealms(config: Config): Promise<RealmProvisioningEntity[]> {\n const masterRealm : RealmProvisioningEntity = {\n strategy: {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in'],\n },\n attributes: {\n name: REALM_MASTER_NAME,\n built_in: true,\n },\n relations: {},\n };\n\n const userCredentialsService = new UserCredentialsService();\n\n let userStrategy : ProvisioningEntityStrategy<User> | undefined;\n if (config.userAdminPasswordReset) {\n userStrategy = {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['password'],\n };\n }\n\n masterRealm.relations = masterRealm.relations || {};\n masterRealm.relations.users = [\n {\n strategy: userStrategy,\n attributes: {\n name: 'admin',\n password: await userCredentialsService.protect(config.userAdminPassword),\n email: buildUserFakeEmail('admin'),\n active: config.userAdminEnabled,\n },\n relations: { globalRoles: [ROLE_ADMIN_NAME] },\n },\n ];\n\n const clientCredentialsService = new ClientCredentialsService();\n\n let clientStrategy : ProvisioningEntityStrategy<Client> | undefined;\n if (config.clientSystemSecretReset) {\n clientStrategy = {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in', 'is_confidential', 'secret', 'secret_hashed', 'secret_encrypted'],\n };\n } else {\n clientStrategy = {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in', 'is_confidential'],\n };\n }\n\n masterRealm.relations = masterRealm.relations || {};\n masterRealm.relations.clients = [\n {\n strategy: clientStrategy,\n attributes: {\n built_in: true,\n is_confidential: true,\n name: 'system',\n secret: await clientCredentialsService.protect(config.clientSystemSecret, { secret_hashed: false }),\n secret_hashed: false,\n active: config.clientSystemEnabled,\n },\n relations: { globalRoles: [ROLE_ADMIN_NAME] },\n },\n ];\n\n const robotCredentialsService = new RobotCredentialsService();\n\n let robotStrategy : ProvisioningEntityStrategy<Robot> | undefined;\n if (config.robotAdminSecretReset) {\n robotStrategy = {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['secret'],\n };\n }\n\n masterRealm.relations = masterRealm.relations || {};\n masterRealm.relations.robots = [\n {\n strategy: robotStrategy,\n attributes: {\n name: 'system',\n secret: await robotCredentialsService.protect(config.robotAdminSecret),\n active: config.robotAdminEnabled,\n },\n relations: { globalRoles: [ROLE_ADMIN_NAME] },\n },\n ];\n\n return [masterRealm];\n }\n\n async load(container: IContainer): Promise<RootProvisioningEntity> {\n const config = container.resolve(ConfigInjectionKey);\n\n return {\n policies: this.buildPolicies(),\n permissions: this.buildPermissions(),\n scopes: this.buildScopes(),\n roles: this.buildRoles(),\n realms: await this.buildRealms(config),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA0CA,IAAac,4BAAb,MAAaA;CACTC,gBAA4C;EACxC,OAAO;GACH;IACIC,YAAY;KACRC,MAAMf,iBAAiBgB;KACvBC,MAAMnB,kBAAkBoB;KACxBC,UAAU;KACVC,UAAU;IACd;IACAC,iBAAiB,EAAEC,mBAAmBvB,iBAAiBwB,UAAU;IACjEC,UAAU;KACN,EACIV,YAAY;MACRC,MAAMf,iBAAiByB;MACvBR,MAAMnB,kBAAkB2B;MACxBN,UAAU;MACVC,UAAU;KACd,EACJ;KACA,EACIN,YAAY;MACRC,MAAMf,iBAAiB0B;MACvBT,MAAMnB,kBAAkB4B;MACxBP,UAAU;MACVC,UAAU;KACd,EACJ;KACA;MACIN,YAAY;OACRC,MAAMf,iBAAiB2B;OACvBV,MAAMnB,kBAAkB6B;OACxBR,UAAU;OACVC,UAAU;MACd;MACAC,iBAAiB;OACbO,gBAAgB,CAAC,UAAA;OACjBC,uBAAuB;OACvBC,2BAA2B;OAC3BC,0BAA0B;MAC9B;KACJ;;GAER;GACA;IACIjB,YAAY;KACRC,MAAMf,iBAAiBgC;KACvBf,MAAMnB,kBAAkB6B;KACxBR,UAAU;KACVC,UAAU;IACd;IACAC,iBAAiB;KACbO,gBAAgB,CAAC,UAAA;KACjBC,uBAAuB;KACvBE,0BAA0B;KAC1BD,2BAA2B;IAC/B;GACJ;GACA;IACIhB,YAAY;KACRC,MAAMf,iBAAiBiC;KACvBhB,MAAMnB,kBAAkB6B;KACxBR,UAAU;KACVC,UAAU;IACd;IACAC,iBAAiB;KACbO,gBAAgB,CAAC,UAAA;KACjBC,uBAAuB;KACvBE,0BAA0B;KAC1BD,2BAA2B;I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wBf,QAAQP,OAAO0B,gBAAgB;IACrEhB,QAAQV,OAAO2B;GACnB;GACA3D,WAAW,EAAE4C,aAAa,CAAC7F,eAAAA,EAAiB;EAChD,CAAA;EAGJ,OAAO,CAACkF,WAAAA;CACZ;CAEA,MAAM2B,KAAKC,WAAwD;EAC/D,MAAM7B,SAAS6B,UAAUC,QAAQxG,kBAAAA;EAEjC,OAAO;GACHyC,UAAU,KAAKtC,cAAa;GAC5BsG,aAAa,KAAK3E,iBAAgB;GAClC4E,QAAQ,KAAK/D,YAAW;GACxBgE,OAAO,KAAK/D,WAAU;GACtBgE,QAAQ,MAAM,KAAKnC,YAAYC,MAAAA;EACnC;CACJ;AACJ"}
1
+ {"version":3,"file":"module.mjs","names":["BuiltInPolicyType","SystemPolicyName","DecisionStrategy","PermissionName","REALM_MASTER_NAME","ROLE_ADMIN_NAME","ROLE_REALM_ADMIN_NAME","ScopeName","buildUserFakeEmail","ClientCredentialsService","RobotCredentialsService","UserCredentialsService","ConfigInjectionKey","ProvisioningEntityStrategyType","DefaultProvisioningSource","buildPolicies","attributes","name","DEFAULT","type","COMPOSITE","built_in","realm_id","extraAttributes","decision_strategy","UNANIMOUS","children","IDENTITY","PERMISSION_BINDING","REALM_MATCH","attribute_name","attribute_name_strict","identity_master_match_all","attribute_null_match_all","REALM_BOUND","REALM_OR_GLOBAL","CLIENT_NAMES_SELF_MANAGE","ATTRIBUTE_NAMES","invert","names","ROBOT_NAMES_SELF_MANAGE","USER_NAMES_SELF_MANAGE","buildPermissions","policiesByPermission","CLIENT_SELF_MANAGE","ROBOT_SELF_MANAGE","USER_SELF_MANAGE","Object","values","map","entity","strategy","MERGE","policies","relations","buildScopes","buildRoles","globalPermissions","globalPermissionsExclude","REALM_CREATE","REALM_UPDATE","REALM_DELETE","globalPermissionsPolicyName","globalPermissionsPolicyOverrides","CLIENT_CREATE","CLIENT_UPDATE","CLIENT_DELETE","IDENTITY_PROVIDER_CREATE","IDENTITY_PROVIDER_UPDATE","IDENTITY_PROVIDER_DELETE","PERMISSION_CREATE","PERMISSION_UPDATE","PERMISSION_DELETE","ROBOT_CREATE","ROBOT_UPDATE","ROBOT_DELETE","ROLE_CREATE","ROLE_UPDATE","ROLE_DELETE","SCOPE_CREATE","SCOPE_UPDATE","SCOPE_DELETE","USER_CREATE","USER_UPDATE","USER_DELETE","buildRealms","config","masterRealm","userCredentialsService","userStrategy","userAdminPasswordReset","users","password","protect","userAdminPassword","email","active","userAdminEnabled","globalRoles","clientCredentialsService","clientStrategy","clientSystemSecretReset","clients","is_confidential","secret","clientSystemSecret","secret_hashed","clientSystemEnabled","robotCredentialsService","robotStrategy","robotAdminSecretReset","robots","robotAdminSecret","robotAdminEnabled","load","container","resolve","permissions","scopes","roles","realms"],"sources":["../../../../../../src/app/modules/provisioning/sources/default/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BuiltInPolicyType, SystemPolicyName } from '@authup/access';\nimport { DecisionStrategy } from '@authup/kit';\nimport type {\n Client, \n Permission, \n Robot, \n Role, \n Scope, \n User,\n} from '@authup/core-kit';\nimport {\n PermissionName, \n REALM_MASTER_NAME, \n ROLE_ADMIN_NAME, \n ROLE_REALM_ADMIN_NAME, \n ScopeName, \n buildUserFakeEmail,\n} from '@authup/core-kit';\nimport type { IContainer } from 'eldin';\nimport {\n ClientCredentialsService,\n RobotCredentialsService,\n UserCredentialsService,\n} from '../../../../../core/index.ts';\nimport type { Config } from '../../../config/index.ts';\nimport { ConfigInjectionKey } from '../../../config/index.ts';\nimport type { PermissionProvisioningEntity } from '../../../../../core/provisioning/entities/permission/index.ts';\nimport type { PolicyProvisioningEntity } from '../../../../../core/provisioning/entities/policy/index.ts';\nimport type { RealmProvisioningEntity } from '../../../../../core/provisioning/entities/realm/index.ts';\nimport type { RoleProvisioningEntity } from '../../../../../core/provisioning/entities/role/index.ts';\nimport type { RootProvisioningEntity } from '../../../../../core/provisioning/entities/root/index.ts';\nimport type { ScopeProvisioningEntity } from '../../../../../core/provisioning/entities/scope/index.ts';\nimport type { ProvisioningEntityStrategy } from '../../../../../core/provisioning/strategy/index.ts';\nimport { ProvisioningEntityStrategyType } from '../../../../../core/provisioning/strategy/index.ts';\nimport type { IProvisioningSource } from '../../../../../core/provisioning/types.ts';\n\nexport class DefaultProvisioningSource implements IProvisioningSource {\n buildPolicies(): PolicyProvisioningEntity[] {\n return [\n {\n attributes: {\n name: SystemPolicyName.DEFAULT,\n type: BuiltInPolicyType.COMPOSITE,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: { decision_strategy: DecisionStrategy.UNANIMOUS },\n children: [\n {\n attributes: {\n name: SystemPolicyName.IDENTITY,\n type: BuiltInPolicyType.IDENTITY,\n built_in: true,\n realm_id: null,\n },\n },\n {\n attributes: {\n name: SystemPolicyName.PERMISSION_BINDING,\n type: BuiltInPolicyType.PERMISSION_BINDING,\n built_in: true,\n realm_id: null,\n },\n },\n {\n attributes: {\n name: SystemPolicyName.REALM_MATCH,\n type: BuiltInPolicyType.REALM_MATCH,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n attribute_name: ['realm_id'],\n attribute_name_strict: false,\n identity_master_match_all: false,\n attribute_null_match_all: true,\n },\n },\n ],\n },\n {\n attributes: {\n name: SystemPolicyName.REALM_BOUND,\n type: BuiltInPolicyType.REALM_MATCH,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n attribute_name: ['realm_id'],\n attribute_name_strict: false,\n attribute_null_match_all: false,\n identity_master_match_all: false,\n },\n },\n {\n attributes: {\n name: SystemPolicyName.REALM_OR_GLOBAL,\n type: BuiltInPolicyType.REALM_MATCH,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n attribute_name: ['realm_id'],\n attribute_name_strict: false,\n attribute_null_match_all: true,\n identity_master_match_all: false,\n },\n },\n // Self-manage policies use ATTRIBUTE_NAMES + invert: true (denylist).\n // Each `names` entry is what self-edit must REJECT; everything else\n // is permitted. New columns added to the entity are self-editable\n // by default — extend the denylist when adding admin-only state.\n {\n attributes: {\n name: SystemPolicyName.CLIENT_NAMES_SELF_MANAGE,\n type: BuiltInPolicyType.ATTRIBUTE_NAMES,\n invert: true,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n names: [\n // FK + lifecycle\n 'active',\n 'realm_id',\n // Security-critical: a self-edit must not change the\n // client's confidentiality (toggling this clears the\n // secret) or downgrade the secret-storage format\n // (which would persist the secret in plaintext).\n 'is_confidential',\n 'secret_hashed',\n 'secret_encrypted',\n ],\n },\n },\n {\n attributes: {\n name: SystemPolicyName.ROBOT_NAMES_SELF_MANAGE,\n type: BuiltInPolicyType.ATTRIBUTE_NAMES,\n invert: true,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n names: [\n 'active',\n 'realm_id',\n 'user_id',\n ],\n },\n },\n {\n attributes: {\n name: SystemPolicyName.USER_NAMES_SELF_MANAGE,\n type: BuiltInPolicyType.ATTRIBUTE_NAMES,\n invert: true,\n built_in: true,\n realm_id: null,\n },\n extraAttributes: {\n names: [\n 'active',\n 'name_locked',\n 'status',\n 'status_message',\n 'realm_id',\n ],\n },\n },\n ];\n }\n\n buildPermissions(): PermissionProvisioningEntity[] {\n const policiesByPermission: Partial<Record<string, string[]>> = {\n [PermissionName.CLIENT_SELF_MANAGE]: [SystemPolicyName.DEFAULT, SystemPolicyName.CLIENT_NAMES_SELF_MANAGE],\n [PermissionName.ROBOT_SELF_MANAGE]: [SystemPolicyName.DEFAULT, SystemPolicyName.ROBOT_NAMES_SELF_MANAGE],\n [PermissionName.USER_SELF_MANAGE]: [SystemPolicyName.DEFAULT, SystemPolicyName.USER_NAMES_SELF_MANAGE],\n };\n\n return Object.values(PermissionName)\n .map((name) => {\n const entity: PermissionProvisioningEntity = {\n strategy: {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in'] as (keyof Permission)[],\n },\n attributes: {\n name,\n built_in: true,\n },\n };\n\n const policies = policiesByPermission[name];\n if (policies) {\n entity.relations = { policies };\n }\n\n return entity;\n });\n }\n\n buildScopes(): ScopeProvisioningEntity[] {\n return Object.values(ScopeName)\n .map((name) => ({\n strategy: {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in'] as (keyof Scope)[],\n },\n attributes: {\n name,\n built_in: true,\n },\n }));\n }\n\n buildRoles(): RoleProvisioningEntity[] {\n return [\n {\n strategy: {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in'] as (keyof Role)[],\n },\n attributes: {\n name: ROLE_ADMIN_NAME,\n built_in: true,\n },\n relations: { globalPermissions: ['*'] },\n },\n {\n strategy: {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in'] as (keyof Role)[],\n },\n attributes: {\n name: ROLE_REALM_ADMIN_NAME,\n built_in: true,\n },\n relations: {\n globalPermissions: ['*'],\n globalPermissionsExclude: [\n PermissionName.REALM_CREATE,\n PermissionName.REALM_UPDATE,\n PermissionName.REALM_DELETE,\n ],\n globalPermissionsPolicyName: SystemPolicyName.REALM_OR_GLOBAL,\n globalPermissionsPolicyOverrides: {\n [SystemPolicyName.REALM_BOUND]: [\n PermissionName.CLIENT_CREATE,\n PermissionName.CLIENT_UPDATE,\n PermissionName.CLIENT_DELETE,\n PermissionName.IDENTITY_PROVIDER_CREATE,\n PermissionName.IDENTITY_PROVIDER_UPDATE,\n PermissionName.IDENTITY_PROVIDER_DELETE,\n PermissionName.PERMISSION_CREATE,\n PermissionName.PERMISSION_UPDATE,\n PermissionName.PERMISSION_DELETE,\n PermissionName.ROBOT_CREATE,\n PermissionName.ROBOT_UPDATE,\n PermissionName.ROBOT_DELETE,\n PermissionName.ROLE_CREATE,\n PermissionName.ROLE_UPDATE,\n PermissionName.ROLE_DELETE,\n PermissionName.SCOPE_CREATE,\n PermissionName.SCOPE_UPDATE,\n PermissionName.SCOPE_DELETE,\n PermissionName.USER_CREATE,\n PermissionName.USER_UPDATE,\n PermissionName.USER_DELETE,\n ],\n },\n },\n },\n ];\n }\n\n async buildRealms(config: Config): Promise<RealmProvisioningEntity[]> {\n const masterRealm : RealmProvisioningEntity = {\n strategy: {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in'],\n },\n attributes: {\n name: REALM_MASTER_NAME,\n built_in: true,\n },\n relations: {},\n };\n\n const userCredentialsService = new UserCredentialsService();\n\n let userStrategy : ProvisioningEntityStrategy<User> | undefined;\n if (config.userAdminPasswordReset) {\n userStrategy = {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['password'],\n };\n }\n\n masterRealm.relations = masterRealm.relations || {};\n masterRealm.relations.users = [\n {\n strategy: userStrategy,\n attributes: {\n name: 'admin',\n password: await userCredentialsService.protect(config.userAdminPassword),\n email: buildUserFakeEmail('admin'),\n active: config.userAdminEnabled,\n },\n relations: { globalRoles: [ROLE_ADMIN_NAME] },\n },\n ];\n\n const clientCredentialsService = new ClientCredentialsService();\n\n let clientStrategy : ProvisioningEntityStrategy<Client> | undefined;\n if (config.clientSystemSecretReset) {\n clientStrategy = {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in', 'is_confidential', 'secret', 'secret_hashed', 'secret_encrypted'],\n };\n } else {\n clientStrategy = {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['built_in', 'is_confidential'],\n };\n }\n\n masterRealm.relations = masterRealm.relations || {};\n masterRealm.relations.clients = [\n {\n strategy: clientStrategy,\n attributes: {\n built_in: true,\n is_confidential: true,\n name: 'system',\n secret: await clientCredentialsService.protect(config.clientSystemSecret, { secret_hashed: false }),\n secret_hashed: false,\n active: config.clientSystemEnabled,\n },\n relations: { globalRoles: [ROLE_ADMIN_NAME] },\n },\n ];\n\n const robotCredentialsService = new RobotCredentialsService();\n\n let robotStrategy : ProvisioningEntityStrategy<Robot> | undefined;\n if (config.robotAdminSecretReset) {\n robotStrategy = {\n type: ProvisioningEntityStrategyType.MERGE,\n attributes: ['secret'],\n };\n }\n\n masterRealm.relations = masterRealm.relations || {};\n masterRealm.relations.robots = [\n {\n strategy: robotStrategy,\n attributes: {\n name: 'system',\n secret: await robotCredentialsService.protect(config.robotAdminSecret),\n active: config.robotAdminEnabled,\n },\n relations: { globalRoles: [ROLE_ADMIN_NAME] },\n },\n ];\n\n return [masterRealm];\n }\n\n async load(container: IContainer): Promise<RootProvisioningEntity> {\n const config = container.resolve(ConfigInjectionKey);\n\n return {\n policies: this.buildPolicies(),\n permissions: this.buildPermissions(),\n scopes: this.buildScopes(),\n roles: this.buildRoles(),\n realms: await this.buildRealms(config),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2CA,IAAac,4BAAb,MAAaA;CACTC,gBAA4C;EACxC,OAAO;GACH;IACIC,YAAY;KACRC,MAAMhB,iBAAiBiB;KACvBC,MAAMnB,kBAAkBoB;KACxBC,UAAU;KACVC,UAAU;IACd;IACAC,iBAAiB,EAAEC,mBAAmBtB,iBAAiBuB,UAAU;IACjEC,UAAU;KACN,EACIV,YAAY;MACRC,MAAMhB,iBAAiB0B;MACvBR,MAAMnB,kBAAkB2B;MACxBN,UAAU;MACVC,UAAU;KACd,EACJ;KACA,EACIN,YAAY;MACRC,MAAMhB,iBAAiB2B;MACvBT,MAAMnB,kBAAkB4B;MACxBP,UAAU;MACVC,UAAU;KACd,EACJ;KACA;MACIN,YAAY;OACRC,MAAMhB,iBAAiB4B;OACvBV,MAAMnB,kBAAkB6B;OACxBR,UAAU;OACVC,UAAU;MACd;MACAC,iBAAiB;OACbO,gBAAgB,CAAC,UAAA;OACjBC,uBAAuB;OACvBC,2BAA2B;OAC3BC,0BAA0B;MAC9B;KACJ;;GAER;GACA;IACIjB,YAAY;KACRC,MAAMhB,iBAAiBiC;KACvBf,MAAMnB,kBAAkB6B;KACxBR,UAAU;KACVC,UAAU;IACd;IACAC,iBAAiB;KACbO,gBAAgB,CAAC,UAAA;KACjBC,uBAAuB;KACvBE,0BAA0B;KAC1BD,2BAA2B;IAC/B;GACJ;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+BAA+BuC;GACrCpC,YAAY,CAAC,QAAA;EACjB;EAGJuE,YAAYjC,YAAYiC,YAAYjC,aAAa,CAAC;EAClDiC,YAAYjC,UAAUyD,SAAS,CAC3B;GACI5D,UAAU0D;GACV7F,YAAY;IACRC,MAAM;IACNuF,QAAQ,MAAMI,wBAAwBf,QAAQP,OAAO0B,gBAAgB;IACrEhB,QAAQV,OAAO2B;GACnB;GACA3D,WAAW,EAAE4C,aAAa,CAAC7F,eAAAA,EAAiB;EAChD,CAAA;EAGJ,OAAO,CAACkF,WAAAA;CACZ;CAEA,MAAM2B,KAAKC,WAAwD;EAC/D,MAAM7B,SAAS6B,UAAUC,QAAQxG,kBAAAA;EAEjC,OAAO;GACHyC,UAAU,KAAKtC,cAAa;GAC5BsG,aAAa,KAAK3E,iBAAgB;GAClC4E,QAAQ,KAAK/D,YAAW;GACxBgE,OAAO,KAAK/D,WAAU;GACtBgE,QAAQ,MAAM,KAAKnC,YAAYC,MAAAA;EACnC;CACJ;AACJ"}
@@ -1,3 +1,4 @@
1
1
  export * from './service.ts';
2
2
  export * from './types.ts';
3
+ export * from './web-client.ts';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/entities/client/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/entities/client/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
@@ -2,4 +2,5 @@ import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
4
  import { ClientService } from "./service.mjs";
5
- export { ClientService };
5
+ import { WebClientProvisioner, buildWebClientAttributes } from "./web-client.mjs";
6
+ export { ClientService, WebClientProvisioner, buildWebClientAttributes };
@@ -1 +1 @@
1
- {"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,GAAG,EAAE,oBAAoB;IAO/B,OAAO,CACT,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,KAAK,EAAE,YAAY,GACpB,OAAO,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;IAmD5C,MAAM,CACR,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,YAAY,EACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC;IA2CZ,MAAM,CACR,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,KAAK,EAAE,YAAY,GACpB,OAAO,CAAC,MAAM,CAAC;IAKZ,MAAM,CACR,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,KAAK,EAAE,YAAY,GACpB,OAAO,CAAC,MAAM,CAAC;IAKZ,IAAI,CACN,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAO,GACvC,OAAO,CAAC;QACP,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAA;KACnB,CAAC;IAuJI,MAAM,CACR,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,YAAY,GACpB,OAAO,CAAC,MAAM,CAAC;CAmBrB"}
@@ -2,11 +2,11 @@ import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
4
  import { ClientCredentialsService } from "../../authentication/credential/entities/client/module.mjs";
5
- import { ClientValidator, PermissionName } from "@authup/core-kit";
5
+ import { CLIENT_RESERVED_NAMES, ClientValidator, PermissionName } from "@authup/core-kit";
6
6
  import { AbstractEntityService } from "@authup/server-kit";
7
7
  import { ValidatorGroup, isUUID } from "@authup/kit";
8
8
  import { BuiltInPolicyType, PolicyData } from "@authup/access";
9
- import { EntityNotFoundError } from "@authup/errors";
9
+ import { BadRequestError, EntityNotFoundError } from "@authup/errors";
10
10
  //#region src/core/entities/client/service.ts
11
11
  var ClientService = class extends AbstractEntityService {
12
12
  repository;
@@ -109,6 +109,7 @@ var ClientService = class extends AbstractEntityService {
109
109
  group = ValidatorGroup.CREATE;
110
110
  }
111
111
  const validated = await this.validator.run(data, { group });
112
+ if (typeof validated.name === "string" && CLIENT_RESERVED_NAMES.includes(validated.name) && !(entity && entity.built_in && entity.name === validated.name)) throw new BadRequestError(`The client name '${validated.name}' is reserved.`);
112
113
  await this.repository.validateJoinColumns(validated);
113
114
  await this.repository.checkUniqueness(validated, entity || void 0);
114
115
  const credentialsService = new ClientCredentialsService();
@@ -1 +1 @@
1
- {"version":3,"file":"service.mjs","names":["BuiltInPolicyType","PolicyData","ValidatorGroup","isUUID","EntityNotFoundError","ClientValidator","PermissionName","AbstractEntityService","ClientCredentialsService","ClientService","repository","realmRepository","validator","ctx","getMany","query","actor","permissionEvaluator","preEvaluateOneOf","name","CLIENT_READ","CLIENT_UPDATE","CLIENT_DELETE","data","entities","meta","findMany","total","entity","secret","secret_encrypted","secret_hashed","evaluateOneOf","input","ATTRIBUTES","push","getOne","idOrName","realmId","permissionNames","isMe","identity","type","id","findOne","create","save","undefined","update","updateOnly","options","group","realm","realm_id","resolve","where","findOneWithSecret","isSelfEdit","preEvaluate","e","CLIENT_SELF_MANAGE","UPDATE","CLIENT_CREATE","CREATE","validated","run","validateJoinColumns","checkUniqueness","credentialsService","actorRealmId","getActorRealmId","evaluate","merge","is_confidential","generateSecret","protect","created","delete","findOneBy","entityId","remove"],"sources":["../../../../src/core/entities/client/service.ts"],"sourcesContent":["/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BuiltInPolicyType, PolicyData } from '@authup/access';\nimport { ValidatorGroup, isUUID } from '@authup/kit';\nimport { EntityNotFoundError } from '@authup/errors';\nimport {\n ClientValidator,\n PermissionName,\n} from '@authup/core-kit';\nimport type { Client } from '@authup/core-kit';\nimport type { ActorContext, EntityRepositoryFindManyResult } from '@authup/server-kit';\nimport type { IRealmRepository } from '../realm/types.ts';\nimport { AbstractEntityService } from '@authup/server-kit';\nimport { ClientCredentialsService } from '../../authentication/credential/entities/client/module.ts';\nimport type { IClientRepository, IClientService } from './types.ts';\n\nexport type ClientServiceContext = {\n repository: IClientRepository;\n realmRepository: IRealmRepository;\n};\n\nexport class ClientService extends AbstractEntityService implements IClientService {\n protected repository: IClientRepository;\n\n protected realmRepository: IRealmRepository;\n\n protected validator: ClientValidator;\n\n constructor(ctx: ClientServiceContext) {\n super();\n this.repository = ctx.repository;\n this.realmRepository = ctx.realmRepository;\n this.validator = new ClientValidator();\n }\n\n async getMany(\n query: Record<string, any>,\n actor: ActorContext,\n ): Promise<EntityRepositoryFindManyResult<Client>> {\n await actor.permissionEvaluator.preEvaluateOneOf({\n name: [\n PermissionName.CLIENT_READ,\n PermissionName.CLIENT_UPDATE,\n PermissionName.CLIENT_DELETE,\n ],\n });\n\n const {\n data: entities, \n meta, \n } = await this.repository.findMany(query);\n let { total } = meta;\n\n const data: Client[] = [];\n for (const entity of entities) {\n if (\n entity.secret &&\n !entity.secret_encrypted &&\n !entity.secret_hashed\n ) {\n try {\n await actor.permissionEvaluator.evaluateOneOf({\n name: [\n PermissionName.CLIENT_READ,\n PermissionName.CLIENT_UPDATE,\n PermissionName.CLIENT_DELETE,\n ],\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: entity }),\n });\n data.push(entity);\n } catch {\n total -= 1;\n }\n\n continue;\n }\n\n data.push(entity);\n }\n\n return {\n data,\n meta: {\n ...meta,\n total, \n }, \n };\n }\n\n async getOne(\n idOrName: string,\n actor: ActorContext,\n query?: Record<string, any>,\n realmId?: string,\n ): Promise<Client> {\n const permissionNames = [\n PermissionName.CLIENT_READ,\n PermissionName.CLIENT_UPDATE,\n PermissionName.CLIENT_DELETE,\n ];\n\n let isMe = !!actor.identity &&\n actor.identity.type === 'client' &&\n (\n actor.identity.data.id === idOrName ||\n actor.identity.data.name === idOrName\n );\n\n if (!isMe) {\n await actor.permissionEvaluator.preEvaluateOneOf({ name: permissionNames });\n }\n\n const entity = await this.repository.findOne(idOrName, query, realmId);\n if (!entity) {\n throw new EntityNotFoundError();\n }\n\n if (isMe && actor.identity!.data.id !== entity.id) {\n isMe = false;\n await actor.permissionEvaluator.preEvaluateOneOf({ name: permissionNames });\n }\n\n if (\n !isMe &&\n entity.secret &&\n !entity.secret_encrypted &&\n !entity.secret_hashed\n ) {\n await actor.permissionEvaluator.evaluateOneOf({\n name: permissionNames,\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: entity }),\n });\n }\n\n return entity;\n }\n\n async create(\n data: Record<string, any>,\n actor: ActorContext,\n ): Promise<Client> {\n const { entity } = await this.save(undefined, data, actor);\n return entity;\n }\n\n async update(\n idOrName: string,\n data: Record<string, any>,\n actor: ActorContext,\n ): Promise<Client> {\n const { entity } = await this.save(idOrName, data, actor, { updateOnly: true });\n return entity;\n }\n\n async save(\n idOrName: string | undefined,\n data: Record<string, any>,\n actor: ActorContext,\n options: { updateOnly?: boolean } = {},\n ): Promise<{\n entity: Client,\n created: boolean \n }> {\n let group: string;\n\n const realm = typeof data.realm_id === 'string' ?\n await this.realmRepository.resolve(data.realm_id) :\n undefined;\n\n let entity: Client | null | undefined;\n if (idOrName) {\n const where: Record<string, any> = {};\n if (isUUID(idOrName)) {\n where.id = idOrName;\n } else {\n where.name = idOrName;\n }\n\n if (realm) {\n where.realm_id = realm.id;\n }\n\n entity = await this.repository.findOneWithSecret(where);\n if (!entity && options.updateOnly) {\n throw new EntityNotFoundError();\n }\n } else if (options.updateOnly) {\n throw new EntityNotFoundError();\n }\n\n let isSelfEdit = false;\n if (entity) {\n try {\n await actor.permissionEvaluator.preEvaluate({ name: PermissionName.CLIENT_UPDATE });\n } catch (e) {\n if (\n !actor.identity ||\n actor.identity.type !== 'client' ||\n actor.identity.data.id !== entity.id\n ) {\n throw e;\n }\n isSelfEdit = true;\n await actor.permissionEvaluator.preEvaluate({ name: PermissionName.CLIENT_SELF_MANAGE });\n }\n group = ValidatorGroup.UPDATE;\n } else {\n await actor.permissionEvaluator.preEvaluate({ name: PermissionName.CLIENT_CREATE });\n group = ValidatorGroup.CREATE;\n }\n\n const validated = await this.validator.run(data, { group });\n\n await this.repository.validateJoinColumns(validated);\n await this.repository.checkUniqueness(validated, entity || undefined);\n\n const credentialsService = new ClientCredentialsService();\n\n if (entity) {\n if (\n !isSelfEdit &&\n !validated.realm_id &&\n !entity.realm_id\n ) {\n const actorRealmId = this.getActorRealmId(actor);\n if (actorRealmId) {\n validated.realm_id = actorRealmId;\n }\n }\n\n if (isSelfEdit) {\n await actor.permissionEvaluator.evaluate({\n name: PermissionName.CLIENT_SELF_MANAGE,\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: validated }),\n });\n }\n\n entity = this.repository.merge(entity, validated);\n\n if (!isSelfEdit) {\n await actor.permissionEvaluator.evaluate({\n name: PermissionName.CLIENT_UPDATE,\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: entity }),\n });\n }\n\n if (entity.is_confidential) {\n if (!validated.secret && !entity.secret) {\n validated.secret = credentialsService.generateSecret();\n }\n\n if (validated.secret) {\n entity.secret = await credentialsService.protect(validated.secret, entity);\n }\n } else {\n entity.secret = null;\n }\n\n await this.repository.save(entity);\n\n return {\n entity,\n created: false, \n };\n }\n\n if (!validated.realm_id) {\n const actorRealmId = this.getActorRealmId(actor);\n if (actorRealmId) {\n validated.realm_id = actorRealmId;\n }\n }\n\n await actor.permissionEvaluator.evaluate({\n name: PermissionName.CLIENT_CREATE,\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: validated }),\n });\n\n entity = this.repository.create(validated);\n\n if (entity.is_confidential) {\n if (!validated.secret) {\n validated.secret = credentialsService.generateSecret();\n }\n\n entity.secret = await credentialsService.protect(validated.secret, validated);\n } else {\n entity.secret = null;\n }\n\n await this.repository.save(entity);\n\n return {\n entity,\n created: true, \n };\n }\n\n async delete(\n id: string,\n actor: ActorContext,\n ): Promise<Client> {\n await actor.permissionEvaluator.preEvaluate({ name: PermissionName.CLIENT_DELETE });\n\n const entity = await this.repository.findOneBy({ id });\n if (!entity) {\n throw new EntityNotFoundError();\n }\n\n await actor.permissionEvaluator.evaluate({\n name: PermissionName.CLIENT_DELETE,\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: entity }),\n });\n\n const { id: entityId } = entity;\n await this.repository.remove(entity);\n entity.id = entityId;\n\n return entity;\n }\n}\n"],"mappings":";;;;;;;;;;AA0BA,IAAaS,gBAAb,cAAmCF,sBAAAA;CACrBG;CAEAC;CAEAC;CAEV,YAAYC,KAA2B;EACnC,MAAK;EACL,KAAKH,aAAaG,IAAIH;EACtB,KAAKC,kBAAkBE,IAAIF;EAC3B,KAAKC,YAAY,IAAIP,gBAAAA;CACzB;CAEA,MAAMS,QACFC,OACAC,OAC+C;EAC/C,MAAMA,MAAMC,oBAAoBC,iBAAiB,EAC7CC,MAAM;GACFb,eAAec;GACfd,eAAee;GACff,eAAegB;IAEvB,CAAA;EAEA,MAAM,EACFC,MAAMC,UACNC,SACA,MAAM,KAAKf,WAAWgB,SAASX,KAAAA;EACnC,IAAI,EAAEY,UAAUF;EAEhB,MAAMF,OAAiB,CAAA;EACvB,KAAK,MAAMK,UAAUJ,UAAU;GAC3B,IACII,OAAOC,UACP,CAACD,OAAOE,oBACR,CAACF,OAAOG,eACV;IACE,IAAI;KACA,MAAMf,MAAMC,oBAAoBe,cAAc;MAC1Cb,MAAM;OACFb,eAAec;OACfd,eAAee;OACff,eAAegB;;MAEnBW,OAAO,IAAIhC,WAAW,GAAGD,kBAAkBkC,aAAaN,OAAO,CAAA;KACnE,C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,KAAKlB,WAAWmC,OAAOmB,SAAAA;EAEhC,IAAIpC,OAAO6C,iBAAiB;GACxB,IAAI,CAACT,UAAUnC,QACXmC,UAAUnC,SAASuC,mBAAmBM,eAAc;GAGxD9C,OAAOC,SAAS,MAAMuC,mBAAmBO,QAAQX,UAAUnC,QAAQmC,SAAAA;EACvE,OACIpC,OAAOC,SAAS;EAGpB,MAAM,KAAKnB,WAAWoC,KAAKlB,MAAAA;EAE3B,OAAO;GACHA;GACAgD,SAAS;EACb;CACJ;CAEA,MAAMC,OACFlC,IACA3B,OACe;EACf,MAAMA,MAAMC,oBAAoByC,YAAY,EAAEvC,MAAMb,eAAegB,cAAc,CAAA;EAEjF,MAAMM,SAAS,MAAM,KAAKlB,WAAWoE,UAAU,EAAEnC,GAAG,CAAA;EACpD,IAAI,CAACf,QACD,MAAM,IAAIxB,oBAAAA;EAGd,MAAMY,MAAMC,oBAAoBsD,SAAS;GACrCpD,MAAMb,eAAegB;GACrBW,OAAO,IAAIhC,WAAW,GAAGD,kBAAkBkC,aAAaN,OAAO,CAAA;EACnE,CAAA;EAEA,MAAM,EAAEe,IAAIoC,aAAanD;EACzB,MAAM,KAAKlB,WAAWsE,OAAOpD,MAAAA;EAC7BA,OAAOe,KAAKoC;EAEZ,OAAOnD;CACX;AACJ"}
1
+ {"version":3,"file":"service.mjs","names":["BuiltInPolicyType","PolicyData","ValidatorGroup","isUUID","BadRequestError","EntityNotFoundError","CLIENT_RESERVED_NAMES","ClientValidator","PermissionName","AbstractEntityService","ClientCredentialsService","ClientService","repository","realmRepository","validator","ctx","getMany","query","actor","permissionEvaluator","preEvaluateOneOf","name","CLIENT_READ","CLIENT_UPDATE","CLIENT_DELETE","data","entities","meta","findMany","total","entity","secret","secret_encrypted","secret_hashed","evaluateOneOf","input","ATTRIBUTES","push","getOne","idOrName","realmId","permissionNames","isMe","identity","type","id","findOne","create","save","undefined","update","updateOnly","options","group","realm","realm_id","resolve","where","findOneWithSecret","isSelfEdit","preEvaluate","e","CLIENT_SELF_MANAGE","UPDATE","CLIENT_CREATE","CREATE","validated","run","includes","built_in","validateJoinColumns","checkUniqueness","credentialsService","actorRealmId","getActorRealmId","evaluate","merge","is_confidential","generateSecret","protect","created","delete","findOneBy","entityId","remove"],"sources":["../../../../src/core/entities/client/service.ts"],"sourcesContent":["/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BuiltInPolicyType, PolicyData } from '@authup/access';\nimport { ValidatorGroup, isUUID } from '@authup/kit';\nimport { BadRequestError, EntityNotFoundError } from '@authup/errors';\nimport {\n CLIENT_RESERVED_NAMES,\n ClientValidator,\n PermissionName,\n} from '@authup/core-kit';\nimport type { Client } from '@authup/core-kit';\nimport type { ActorContext, EntityRepositoryFindManyResult } from '@authup/server-kit';\nimport type { IRealmRepository } from '../realm/types.ts';\nimport { AbstractEntityService } from '@authup/server-kit';\nimport { ClientCredentialsService } from '../../authentication/credential/entities/client/module.ts';\nimport type { IClientRepository, IClientService } from './types.ts';\n\nexport type ClientServiceContext = {\n repository: IClientRepository;\n realmRepository: IRealmRepository;\n};\n\nexport class ClientService extends AbstractEntityService implements IClientService {\n protected repository: IClientRepository;\n\n protected realmRepository: IRealmRepository;\n\n protected validator: ClientValidator;\n\n constructor(ctx: ClientServiceContext) {\n super();\n this.repository = ctx.repository;\n this.realmRepository = ctx.realmRepository;\n this.validator = new ClientValidator();\n }\n\n async getMany(\n query: Record<string, any>,\n actor: ActorContext,\n ): Promise<EntityRepositoryFindManyResult<Client>> {\n await actor.permissionEvaluator.preEvaluateOneOf({\n name: [\n PermissionName.CLIENT_READ,\n PermissionName.CLIENT_UPDATE,\n PermissionName.CLIENT_DELETE,\n ],\n });\n\n const {\n data: entities, \n meta, \n } = await this.repository.findMany(query);\n let { total } = meta;\n\n const data: Client[] = [];\n for (const entity of entities) {\n if (\n entity.secret &&\n !entity.secret_encrypted &&\n !entity.secret_hashed\n ) {\n try {\n await actor.permissionEvaluator.evaluateOneOf({\n name: [\n PermissionName.CLIENT_READ,\n PermissionName.CLIENT_UPDATE,\n PermissionName.CLIENT_DELETE,\n ],\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: entity }),\n });\n data.push(entity);\n } catch {\n total -= 1;\n }\n\n continue;\n }\n\n data.push(entity);\n }\n\n return {\n data,\n meta: {\n ...meta,\n total, \n }, \n };\n }\n\n async getOne(\n idOrName: string,\n actor: ActorContext,\n query?: Record<string, any>,\n realmId?: string,\n ): Promise<Client> {\n const permissionNames = [\n PermissionName.CLIENT_READ,\n PermissionName.CLIENT_UPDATE,\n PermissionName.CLIENT_DELETE,\n ];\n\n let isMe = !!actor.identity &&\n actor.identity.type === 'client' &&\n (\n actor.identity.data.id === idOrName ||\n actor.identity.data.name === idOrName\n );\n\n if (!isMe) {\n await actor.permissionEvaluator.preEvaluateOneOf({ name: permissionNames });\n }\n\n const entity = await this.repository.findOne(idOrName, query, realmId);\n if (!entity) {\n throw new EntityNotFoundError();\n }\n\n if (isMe && actor.identity!.data.id !== entity.id) {\n isMe = false;\n await actor.permissionEvaluator.preEvaluateOneOf({ name: permissionNames });\n }\n\n if (\n !isMe &&\n entity.secret &&\n !entity.secret_encrypted &&\n !entity.secret_hashed\n ) {\n await actor.permissionEvaluator.evaluateOneOf({\n name: permissionNames,\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: entity }),\n });\n }\n\n return entity;\n }\n\n async create(\n data: Record<string, any>,\n actor: ActorContext,\n ): Promise<Client> {\n const { entity } = await this.save(undefined, data, actor);\n return entity;\n }\n\n async update(\n idOrName: string,\n data: Record<string, any>,\n actor: ActorContext,\n ): Promise<Client> {\n const { entity } = await this.save(idOrName, data, actor, { updateOnly: true });\n return entity;\n }\n\n async save(\n idOrName: string | undefined,\n data: Record<string, any>,\n actor: ActorContext,\n options: { updateOnly?: boolean } = {},\n ): Promise<{\n entity: Client,\n created: boolean \n }> {\n let group: string;\n\n const realm = typeof data.realm_id === 'string' ?\n await this.realmRepository.resolve(data.realm_id) :\n undefined;\n\n let entity: Client | null | undefined;\n if (idOrName) {\n const where: Record<string, any> = {};\n if (isUUID(idOrName)) {\n where.id = idOrName;\n } else {\n where.name = idOrName;\n }\n\n if (realm) {\n where.realm_id = realm.id;\n }\n\n entity = await this.repository.findOneWithSecret(where);\n if (!entity && options.updateOnly) {\n throw new EntityNotFoundError();\n }\n } else if (options.updateOnly) {\n throw new EntityNotFoundError();\n }\n\n let isSelfEdit = false;\n if (entity) {\n try {\n await actor.permissionEvaluator.preEvaluate({ name: PermissionName.CLIENT_UPDATE });\n } catch (e) {\n if (\n !actor.identity ||\n actor.identity.type !== 'client' ||\n actor.identity.data.id !== entity.id\n ) {\n throw e;\n }\n isSelfEdit = true;\n await actor.permissionEvaluator.preEvaluate({ name: PermissionName.CLIENT_SELF_MANAGE });\n }\n group = ValidatorGroup.UPDATE;\n } else {\n await actor.permissionEvaluator.preEvaluate({ name: PermissionName.CLIENT_CREATE });\n group = ValidatorGroup.CREATE;\n }\n\n const validated = await this.validator.run(data, { group });\n\n // Reserve the system-provisioned client names (`system`, `web`) so an\n // API caller can't create or rename a client onto them — that would\n // collide on unique(name, realm_id) or shadow the built_in client.\n // Provisioning and runtime hooks bypass this service, so they remain\n // free to manage the reserved clients. built_in clients are exempt\n // (they ARE the provisioned ones) but API callers can never produce a\n // built_in client since the validator strips the flag.\n if (\n typeof validated.name === 'string' &&\n CLIENT_RESERVED_NAMES.includes(validated.name) &&\n !(entity && entity.built_in && entity.name === validated.name)\n ) {\n throw new BadRequestError(`The client name '${validated.name}' is reserved.`);\n }\n\n await this.repository.validateJoinColumns(validated);\n await this.repository.checkUniqueness(validated, entity || undefined);\n\n const credentialsService = new ClientCredentialsService();\n\n if (entity) {\n if (\n !isSelfEdit &&\n !validated.realm_id &&\n !entity.realm_id\n ) {\n const actorRealmId = this.getActorRealmId(actor);\n if (actorRealmId) {\n validated.realm_id = actorRealmId;\n }\n }\n\n if (isSelfEdit) {\n await actor.permissionEvaluator.evaluate({\n name: PermissionName.CLIENT_SELF_MANAGE,\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: validated }),\n });\n }\n\n entity = this.repository.merge(entity, validated);\n\n if (!isSelfEdit) {\n await actor.permissionEvaluator.evaluate({\n name: PermissionName.CLIENT_UPDATE,\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: entity }),\n });\n }\n\n if (entity.is_confidential) {\n if (!validated.secret && !entity.secret) {\n validated.secret = credentialsService.generateSecret();\n }\n\n if (validated.secret) {\n entity.secret = await credentialsService.protect(validated.secret, entity);\n }\n } else {\n entity.secret = null;\n }\n\n await this.repository.save(entity);\n\n return {\n entity,\n created: false, \n };\n }\n\n if (!validated.realm_id) {\n const actorRealmId = this.getActorRealmId(actor);\n if (actorRealmId) {\n validated.realm_id = actorRealmId;\n }\n }\n\n await actor.permissionEvaluator.evaluate({\n name: PermissionName.CLIENT_CREATE,\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: validated }),\n });\n\n entity = this.repository.create(validated);\n\n if (entity.is_confidential) {\n if (!validated.secret) {\n validated.secret = credentialsService.generateSecret();\n }\n\n entity.secret = await credentialsService.protect(validated.secret, validated);\n } else {\n entity.secret = null;\n }\n\n await this.repository.save(entity);\n\n return {\n entity,\n created: true, \n };\n }\n\n async delete(\n id: string,\n actor: ActorContext,\n ): Promise<Client> {\n await actor.permissionEvaluator.preEvaluate({ name: PermissionName.CLIENT_DELETE });\n\n const entity = await this.repository.findOneBy({ id });\n if (!entity) {\n throw new EntityNotFoundError();\n }\n\n await actor.permissionEvaluator.evaluate({\n name: PermissionName.CLIENT_DELETE,\n input: new PolicyData({ [BuiltInPolicyType.ATTRIBUTES]: entity }),\n });\n\n const { id: entityId } = entity;\n await this.repository.remove(entity);\n entity.id = entityId;\n\n return entity;\n }\n}\n"],"mappings":";;;;;;;;;;AA2BA,IAAaW,gBAAb,cAAmCF,sBAAAA;CACrBG;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AMC,oBAAoByC,YAAY,EAAEvC,MAAMb,eAAegB,cAAc,CAAA;EAEjF,MAAMM,SAAS,MAAM,KAAKlB,WAAWsE,UAAU,EAAErC,GAAG,CAAA;EACpD,IAAI,CAACf,QACD,MAAM,IAAIzB,oBAAAA;EAGd,MAAMa,MAAMC,oBAAoBwD,SAAS;GACrCtD,MAAMb,eAAegB;GACrBW,OAAO,IAAIlC,WAAW,GAAGD,kBAAkBoC,aAAaN,OAAO,CAAA;EACnE,CAAA;EAEA,MAAM,EAAEe,IAAIsC,aAAarD;EACzB,MAAM,KAAKlB,WAAWwE,OAAOtD,MAAAA;EAC7BA,OAAOe,KAAKsC;EAEZ,OAAOrD;CACX;AACJ"}
@@ -1,6 +1,16 @@
1
- import type { Client, Role } from '@authup/core-kit';
1
+ import type { Client, Realm, Role } from '@authup/core-kit';
2
2
  import type { PermissionPolicyBinding } from '@authup/access';
3
3
  import type { ActorContext, EntityRepositoryFindManyResult, IEntityRepository } from '@authup/server-kit';
4
+ /**
5
+ * Ensures a realm has its system-provisioned public `web` client.
6
+ * Used by startup provisioning (every realm) and the runtime realm-create
7
+ * hook (a single realm). System-level — never gated on an actor.
8
+ */
9
+ export interface IWebClientProvisioner {
10
+ ensureForRealm(realm: Realm | {
11
+ id: string;
12
+ }): Promise<void>;
13
+ }
4
14
  export interface IClientRepository extends IEntityRepository<Client> {
5
15
  checkUniqueness(data: Partial<Client>, existing?: Client): Promise<void>;
6
16
  findOne(id: string, query?: Record<string, any>, realm?: string): Promise<Client | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/entities/client/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B,EAAE,iBAAiB,EAAG,MAAM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AC;QACP,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAA;KACnB,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5D"}
@@ -0,0 +1,34 @@
1
+ import type { Client, Realm } from '@authup/core-kit';
2
+ import type { Logger } from '@authup/server-kit';
3
+ import type { IClientRepository, IWebClientProvisioner } from './types.ts';
4
+ export type WebClientProvisionerContext = {
5
+ clientRepository: IClientRepository;
6
+ appOrigins: string[];
7
+ logger?: Logger;
8
+ };
9
+ /**
10
+ * Build the attribute set for a realm's public `web` client.
11
+ *
12
+ * Public (PKCE) client used by authup's own client-web and any downstream
13
+ * UI embedding client-web-kit. `built_in` makes it auto-consent in the
14
+ * /authorize flow and protects it from the API reserved-name guard. The
15
+ * `global` scope lets the issued token drive the management API (parity
16
+ * with the legacy password-grant admin login); `openid` for the id-token.
17
+ *
18
+ * `grant_types` is metadata only — the auth-code grant issues a refresh
19
+ * token regardless — but it documents the intended flow. `redirect_uri` is
20
+ * one `<origin>/**` wildcard per trusted origin (matched by isSimpleMatch).
21
+ */
22
+ export declare function buildWebClientAttributes(realm: Realm | {
23
+ id: string;
24
+ }, appOrigins: string[]): Partial<Client>;
25
+ export declare class WebClientProvisioner implements IWebClientProvisioner {
26
+ protected clientRepository: IClientRepository;
27
+ protected appOrigins: string[];
28
+ protected logger?: Logger;
29
+ constructor(ctx: WebClientProvisionerContext);
30
+ ensureForRealm(realm: Realm | {
31
+ id: string;
32
+ }): Promise<void>;
33
+ }
34
+ //# sourceMappingURL=web-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-client.d.ts","sourceRoot":"","sources":["../../../../src/core/entities/client/web-client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,MAAM,2BAA2B,GAAG;IACtC,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,KAAK,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC7B,UAAU,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED,qBAAa,oBAAqB,YAAW,qBAAqB;IAC9D,SAAS,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAE9C,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAE/B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEd,GAAG,EAAE,2BAA2B;IAMtC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAsCrE"}
@@ -0,0 +1,62 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { CLIENT_WEB_NAME, ScopeName } from "@authup/core-kit";
5
+ //#region src/core/entities/client/web-client.ts
6
+ /**
7
+ * Build the attribute set for a realm's public `web` client.
8
+ *
9
+ * Public (PKCE) client used by authup's own client-web and any downstream
10
+ * UI embedding client-web-kit. `built_in` makes it auto-consent in the
11
+ * /authorize flow and protects it from the API reserved-name guard. The
12
+ * `global` scope lets the issued token drive the management API (parity
13
+ * with the legacy password-grant admin login); `openid` for the id-token.
14
+ *
15
+ * `grant_types` is metadata only — the auth-code grant issues a refresh
16
+ * token regardless — but it documents the intended flow. `redirect_uri` is
17
+ * one `<origin>/**` wildcard per trusted origin (matched by isSimpleMatch).
18
+ */ function buildWebClientAttributes(realm, appOrigins) {
19
+ return {
20
+ name: CLIENT_WEB_NAME,
21
+ realm_id: realm.id,
22
+ is_confidential: false,
23
+ built_in: true,
24
+ active: true,
25
+ grant_types: "authorization_code refresh_token",
26
+ scope: `${ScopeName.GLOBAL} ${ScopeName.OPEN_ID}`,
27
+ redirect_uri: appOrigins.map((origin) => `${origin}/**`).join(",")
28
+ };
29
+ }
30
+ var WebClientProvisioner = class {
31
+ clientRepository;
32
+ appOrigins;
33
+ logger;
34
+ constructor(ctx) {
35
+ this.clientRepository = ctx.clientRepository;
36
+ this.appOrigins = ctx.appOrigins;
37
+ this.logger = ctx.logger;
38
+ }
39
+ async ensureForRealm(realm) {
40
+ const attributes = buildWebClientAttributes(realm, this.appOrigins);
41
+ const existing = await this.clientRepository.findOneBy({
42
+ name: CLIENT_WEB_NAME,
43
+ realm_id: realm.id
44
+ });
45
+ if (existing) {
46
+ if (!existing.built_in) {
47
+ if (this.logger) this.logger.warn(`Skipping web client provisioning for realm ${realm.id}: a non-built-in client named '${CLIENT_WEB_NAME}' already exists.`);
48
+ return;
49
+ }
50
+ if (!Object.keys(attributes).some((key) => existing[key] !== attributes[key])) return;
51
+ const merged = this.clientRepository.merge(existing, attributes);
52
+ await this.clientRepository.save(merged);
53
+ return;
54
+ }
55
+ const entity = this.clientRepository.create(attributes);
56
+ await this.clientRepository.save(entity);
57
+ }
58
+ };
59
+ //#endregion
60
+ export { WebClientProvisioner, buildWebClientAttributes };
61
+
62
+ //# sourceMappingURL=web-client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-client.mjs","names":["CLIENT_WEB_NAME","ScopeName","buildWebClientAttributes","realm","appOrigins","name","realm_id","id","is_confidential","built_in","active","grant_types","scope","GLOBAL","OPEN_ID","redirect_uri","map","origin","join","WebClientProvisioner","clientRepository","logger","ctx","ensureForRealm","attributes","existing","findOneBy","warn","isDirty","Object","keys","some","key","merged","merge","save","entity","create"],"sources":["../../../../src/core/entities/client/web-client.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { CLIENT_WEB_NAME, ScopeName } from '@authup/core-kit';\nimport type { Client, Realm } from '@authup/core-kit';\nimport type { Logger } from '@authup/server-kit';\nimport type { IClientRepository, IWebClientProvisioner } from './types.ts';\n\nexport type WebClientProvisionerContext = {\n clientRepository: IClientRepository;\n appOrigins: string[];\n logger?: Logger;\n};\n\n/**\n * Build the attribute set for a realm's public `web` client.\n *\n * Public (PKCE) client used by authup's own client-web and any downstream\n * UI embedding client-web-kit. `built_in` makes it auto-consent in the\n * /authorize flow and protects it from the API reserved-name guard. The\n * `global` scope lets the issued token drive the management API (parity\n * with the legacy password-grant admin login); `openid` for the id-token.\n *\n * `grant_types` is metadata only — the auth-code grant issues a refresh\n * token regardless — but it documents the intended flow. `redirect_uri` is\n * one `<origin>/**` wildcard per trusted origin (matched by isSimpleMatch).\n */\nexport function buildWebClientAttributes(\n realm: Realm | { id: string },\n appOrigins: string[],\n): Partial<Client> {\n return {\n name: CLIENT_WEB_NAME,\n realm_id: realm.id,\n is_confidential: false,\n built_in: true,\n active: true,\n grant_types: 'authorization_code refresh_token',\n scope: `${ScopeName.GLOBAL} ${ScopeName.OPEN_ID}`,\n redirect_uri: appOrigins.map((origin) => `${origin}/**`).join(','),\n };\n}\n\nexport class WebClientProvisioner implements IWebClientProvisioner {\n protected clientRepository: IClientRepository;\n\n protected appOrigins: string[];\n\n protected logger?: Logger;\n\n constructor(ctx: WebClientProvisionerContext) {\n this.clientRepository = ctx.clientRepository;\n this.appOrigins = ctx.appOrigins;\n this.logger = ctx.logger;\n }\n\n async ensureForRealm(realm: Realm | { id: string }): Promise<void> {\n const attributes = buildWebClientAttributes(realm, this.appOrigins);\n\n const existing = await this.clientRepository.findOneBy({\n name: CLIENT_WEB_NAME,\n realm_id: realm.id,\n });\n\n if (existing) {\n // Never overwrite a non-built_in client that happens to be named\n // `web` — that would be a user-owned client. Skip and warn.\n if (!existing.built_in) {\n if (this.logger) {\n this.logger.warn(\n `Skipping web client provisioning for realm ${realm.id}: a non-built-in client named '${CLIENT_WEB_NAME}' already exists.`,\n );\n }\n return;\n }\n\n // MERGE: refresh attributes (e.g. redirect_uri) when config\n // changes. Dirty-check first — the attributes are deterministic\n // from config, so a steady-state boot would otherwise issue one\n // redundant UPDATE (bumping updated_at) per realm.\n const isDirty = (Object.keys(attributes) as (keyof Client)[])\n .some((key) => existing[key] !== attributes[key]);\n if (!isDirty) {\n return;\n }\n\n const merged = this.clientRepository.merge(existing, attributes);\n await this.clientRepository.save(merged);\n return;\n }\n\n const entity = this.clientRepository.create(attributes);\n await this.clientRepository.save(entity);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;GA+BA,SAAgBE,yBACZC,OACAC,YAAoB;CAEpB,OAAO;EACHC,MAAML;EACNM,UAAUH,MAAMI;EAChBC,iBAAiB;EACjBC,UAAU;EACVC,QAAQ;EACRC,aAAa;EACbC,OAAO,GAAGX,UAAUY,OAAO,GAAGZ,UAAUa;EACxCC,cAAcX,WAAWY,KAAKC,WAAW,GAAGA,OAAO,IAAI,CAAA,CAAEC,KAAK,GAAA;CAClE;AACJ;AAEA,IAAaC,uBAAb,MAAaA;CACCC;CAEAhB;CAEAiB;CAEV,YAAYC,KAAkC;EAC1C,KAAKF,mBAAmBE,IAAIF;EAC5B,KAAKhB,aAAakB,IAAIlB;EACtB,KAAKiB,SAASC,IAAID;CACtB;CAEA,MAAME,eAAepB,OAA8C;EAC/D,MAAMqB,aAAatB,yBAAyBC,OAAO,KAAKC,UAAU;EAElE,MAAMqB,WAAW,MAAM,KAAKL,iBAAiBM,UAAU;GACnDrB,MAAML;GACNM,UAAUH,MAAMI;EACpB,CAAA;EAEA,IAAIkB,UAAU;GAGV,IAAI,CAACA,SAAShB,UAAU;IACpB,IAAI,KAAKY,QACL,KAAKA,OAAOM,KACR,8CAA8CxB,MAAMI,GAAG,iCAAiCP,gBAAgB,kBAAkB;IAGlI;GACJ;GAQA,IAAI,CAFY,OAAQ8B,KAAKN,UAAAA,CAAAA,CACxBO,MAAMC,QAAQP,SAASO,SAASR,WAAWQ,IAC3CJ,GACD;GAGJ,MAAMK,SAAS,KAAKb,iBAAiBc,MAAMT,UAAUD,UAAAA;GACrD,MAAM,KAAKJ,iBAAiBe,KAAKF,MAAAA;GACjC;EACJ;EAEA,MAAMG,SAAS,KAAKhB,iBAAiBiB,OAAOb,UAAAA;EAC5C,MAAM,KAAKJ,iBAAiBe,KAAKC,MAAAA;CACrC;AACJ"}
@@ -2,6 +2,7 @@ import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
4
  import { ClientService } from "./client/service.mjs";
5
+ import { WebClientProvisioner, buildWebClientAttributes } from "./client/web-client.mjs";
5
6
  import "./client/index.mjs";
6
7
  import { ClientPermissionService } from "./client-permission/service.mjs";
7
8
  import "./client-permission/index.mjs";
@@ -41,4 +42,4 @@ import { UserRoleService } from "./user-role/service.mjs";
41
42
  import "./user-role/index.mjs";
42
43
  import { IdentityProviderRoleMappingService } from "./identity-provider-role-mapping/service.mjs";
43
44
  import "./identity-provider-role-mapping/index.mjs";
44
- export { ClientPermissionService, ClientRoleService, ClientScopeService, ClientService, IdentityProviderRoleMappingService, PermissionPolicyService, PermissionService, PolicyService, RealmService, RobotPermissionService, RobotRoleService, RobotService, RoleAttributeService, RolePermissionService, RoleService, ScopeService, UserAttributeService, UserPermissionService, UserRoleService, UserService };
45
+ export { ClientPermissionService, ClientRoleService, ClientScopeService, ClientService, IdentityProviderRoleMappingService, PermissionPolicyService, PermissionService, PolicyService, RealmService, RobotPermissionService, RobotRoleService, RobotService, RoleAttributeService, RolePermissionService, RoleService, ScopeService, UserAttributeService, UserPermissionService, UserRoleService, UserService, WebClientProvisioner, buildWebClientAttributes };
@@ -1,14 +1,19 @@
1
1
  import { RealmValidator } from '@authup/core-kit';
2
2
  import type { Realm } from '@authup/core-kit';
3
- import type { ActorContext, EntityRepositoryFindManyResult } from '@authup/server-kit';
3
+ import type { ActorContext, EntityRepositoryFindManyResult, Logger } from '@authup/server-kit';
4
4
  import { AbstractEntityService } from '@authup/server-kit';
5
+ import type { IWebClientProvisioner } from '../client/types.ts';
5
6
  import type { IRealmRepository, IRealmService } from './types.ts';
6
7
  export type RealmServiceContext = {
7
8
  repository: IRealmRepository;
9
+ webClientProvisioner?: IWebClientProvisioner;
10
+ logger?: Logger;
8
11
  };
9
12
  export declare class RealmService extends AbstractEntityService implements IRealmService {
10
13
  protected repository: IRealmRepository;
11
14
  protected validator: RealmValidator;
15
+ protected webClientProvisioner?: IWebClientProvisioner;
16
+ protected logger?: Logger;
12
17
  constructor(ctx: RealmServiceContext);
13
18
  getMany(query: Record<string, any>): Promise<EntityRepositoryFindManyResult<Realm>>;
14
19
  getOne(idOrName: string): Promise<Realm>;
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/core/entities/realm/service.ts"],"names":[],"mappings":"AAUA,OAAO,EAGH,cAAc,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B,EAAG,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,MAAM,mBAAmB,GAAG;IAC9B,UAAU,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAEF,qBAAa,YAAa,SAAQ,qBAAsB,YAAW,aAAa;IAC5E,SAAS,CAAC,UAAU,EAAE,gBAAgB,CAAC;IAEvC,SAAS,CAAC,SAAS,EAAE,cAAc,CAAC;gBAExB,GAAG,EAAE,mBAAmB;IAM9B,OAAO,CACT,KAAK,EAAE,MAAM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C,KAAK,CAAC;CAuBpB"}
@@ -10,9 +10,13 @@ import { BadRequestError, EntityNotFoundError } from "@authup/errors";
10
10
  var RealmService = class extends AbstractEntityService {
11
11
  repository;
12
12
  validator;
13
+ webClientProvisioner;
14
+ logger;
13
15
  constructor(ctx) {
14
16
  super();
15
17
  this.repository = ctx.repository;
18
+ this.webClientProvisioner = ctx.webClientProvisioner;
19
+ this.logger = ctx.logger;
16
20
  this.validator = new RealmValidator();
17
21
  }
18
22
  async getMany(query) {
@@ -72,6 +76,11 @@ var RealmService = class extends AbstractEntityService {
72
76
  });
73
77
  entity = this.repository.create(validated);
74
78
  await this.repository.save(entity);
79
+ if (this.webClientProvisioner) try {
80
+ await this.webClientProvisioner.ensureForRealm(entity);
81
+ } catch (e) {
82
+ if (this.logger) this.logger.warn(`Failed to provision web client for realm ${entity.id}: ${e instanceof Error ? e.message : String(e)}`);
83
+ }
75
84
  return {
76
85
  entity,
77
86
  created: true