@authup/server-core 1.0.0-beta.54 → 1.0.0-beta.55

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 (328) hide show
  1. package/dist/adapters/database/data-source/options/module.mjs.map +1 -1
  2. package/dist/adapters/database/domains/client/entity.mjs +2 -2
  3. package/dist/adapters/database/domains/client/entity.mjs.map +1 -1
  4. package/dist/adapters/database/domains/client/subscriber.mjs +2 -2
  5. package/dist/adapters/database/domains/client/subscriber.mjs.map +1 -1
  6. package/dist/adapters/database/domains/client-permission/entity.mjs +2 -2
  7. package/dist/adapters/database/domains/client-permission/entity.mjs.map +1 -1
  8. package/dist/adapters/database/domains/client-permission/subscriber.mjs +2 -2
  9. package/dist/adapters/database/domains/client-permission/subscriber.mjs.map +1 -1
  10. package/dist/adapters/database/domains/client-role/entity.mjs +2 -2
  11. package/dist/adapters/database/domains/client-role/entity.mjs.map +1 -1
  12. package/dist/adapters/database/domains/client-role/subscriber.mjs +2 -2
  13. package/dist/adapters/database/domains/client-role/subscriber.mjs.map +1 -1
  14. package/dist/adapters/database/domains/client-scope/entity.mjs +2 -2
  15. package/dist/adapters/database/domains/client-scope/entity.mjs.map +1 -1
  16. package/dist/adapters/database/domains/client-scope/subscriber.mjs +2 -2
  17. package/dist/adapters/database/domains/client-scope/subscriber.mjs.map +1 -1
  18. package/dist/adapters/database/domains/consent/entity.mjs +2 -2
  19. package/dist/adapters/database/domains/consent/entity.mjs.map +1 -1
  20. package/dist/adapters/database/domains/consent/subscriber.mjs +2 -2
  21. package/dist/adapters/database/domains/consent/subscriber.mjs.map +1 -1
  22. package/dist/adapters/database/domains/constants.mjs.map +1 -1
  23. package/dist/adapters/database/domains/event/entity.mjs +2 -2
  24. package/dist/adapters/database/domains/event/entity.mjs.map +1 -1
  25. package/dist/adapters/database/domains/identity-provider/entity.mjs +2 -2
  26. package/dist/adapters/database/domains/identity-provider/entity.mjs.map +1 -1
  27. package/dist/adapters/database/domains/identity-provider/subscriber.mjs +2 -2
  28. package/dist/adapters/database/domains/identity-provider/subscriber.mjs.map +1 -1
  29. package/dist/adapters/database/domains/identity-provider-account/entity.mjs +2 -2
  30. package/dist/adapters/database/domains/identity-provider-account/entity.mjs.map +1 -1
  31. package/dist/adapters/database/domains/identity-provider-account/subscriber.mjs +2 -2
  32. package/dist/adapters/database/domains/identity-provider-account/subscriber.mjs.map +1 -1
  33. package/dist/adapters/database/domains/identity-provider-attribute/entity.mjs +2 -2
  34. package/dist/adapters/database/domains/identity-provider-attribute/entity.mjs.map +1 -1
  35. package/dist/adapters/database/domains/identity-provider-attribute/subscriber.mjs +2 -2
  36. package/dist/adapters/database/domains/identity-provider-attribute/subscriber.mjs.map +1 -1
  37. package/dist/adapters/database/domains/identity-provider-attribute-mapping/entity.mjs +2 -2
  38. package/dist/adapters/database/domains/identity-provider-attribute-mapping/entity.mjs.map +1 -1
  39. package/dist/adapters/database/domains/identity-provider-permission-mapping/entity.mjs +2 -2
  40. package/dist/adapters/database/domains/identity-provider-permission-mapping/entity.mjs.map +1 -1
  41. package/dist/adapters/database/domains/identity-provider-role-mapping/entity.mjs +2 -2
  42. package/dist/adapters/database/domains/identity-provider-role-mapping/entity.mjs.map +1 -1
  43. package/dist/adapters/database/domains/identity-provider-role-mapping/subscriber.mjs +2 -2
  44. package/dist/adapters/database/domains/identity-provider-role-mapping/subscriber.mjs.map +1 -1
  45. package/dist/adapters/database/domains/key/entity.mjs +2 -2
  46. package/dist/adapters/database/domains/key/entity.mjs.map +1 -1
  47. package/dist/adapters/database/domains/permission/entity.mjs +2 -2
  48. package/dist/adapters/database/domains/permission/entity.mjs.map +1 -1
  49. package/dist/adapters/database/domains/permission/subscriber.mjs +2 -2
  50. package/dist/adapters/database/domains/permission/subscriber.mjs.map +1 -1
  51. package/dist/adapters/database/domains/permission-policy/entity.mjs +2 -2
  52. package/dist/adapters/database/domains/permission-policy/entity.mjs.map +1 -1
  53. package/dist/adapters/database/domains/policy/entity.mjs +2 -2
  54. package/dist/adapters/database/domains/policy/entity.mjs.map +1 -1
  55. package/dist/adapters/database/domains/policy/subscriber.mjs +2 -2
  56. package/dist/adapters/database/domains/policy/subscriber.mjs.map +1 -1
  57. package/dist/adapters/database/domains/policy-attribute/entity.mjs +2 -2
  58. package/dist/adapters/database/domains/policy-attribute/entity.mjs.map +1 -1
  59. package/dist/adapters/database/domains/policy-attribute/subscriber.mjs +2 -2
  60. package/dist/adapters/database/domains/policy-attribute/subscriber.mjs.map +1 -1
  61. package/dist/adapters/database/domains/realm/entity.mjs +2 -2
  62. package/dist/adapters/database/domains/realm/entity.mjs.map +1 -1
  63. package/dist/adapters/database/domains/realm/subscriber.mjs +2 -2
  64. package/dist/adapters/database/domains/realm/subscriber.mjs.map +1 -1
  65. package/dist/adapters/database/domains/role/entity.mjs +2 -2
  66. package/dist/adapters/database/domains/role/entity.mjs.map +1 -1
  67. package/dist/adapters/database/domains/role/subscriber.mjs +2 -2
  68. package/dist/adapters/database/domains/role/subscriber.mjs.map +1 -1
  69. package/dist/adapters/database/domains/role-attribute/entity.mjs +2 -2
  70. package/dist/adapters/database/domains/role-attribute/entity.mjs.map +1 -1
  71. package/dist/adapters/database/domains/role-attribute/subscriber.mjs +2 -2
  72. package/dist/adapters/database/domains/role-attribute/subscriber.mjs.map +1 -1
  73. package/dist/adapters/database/domains/role-permission/entity.mjs +2 -2
  74. package/dist/adapters/database/domains/role-permission/entity.mjs.map +1 -1
  75. package/dist/adapters/database/domains/role-permission/subscriber.mjs +2 -2
  76. package/dist/adapters/database/domains/role-permission/subscriber.mjs.map +1 -1
  77. package/dist/adapters/database/domains/scope/entity.mjs +2 -2
  78. package/dist/adapters/database/domains/scope/entity.mjs.map +1 -1
  79. package/dist/adapters/database/domains/scope/subscriber.mjs +2 -2
  80. package/dist/adapters/database/domains/scope/subscriber.mjs.map +1 -1
  81. package/dist/adapters/database/domains/session/entity.mjs +2 -2
  82. package/dist/adapters/database/domains/session/entity.mjs.map +1 -1
  83. package/dist/adapters/database/domains/session-token/entity.mjs +2 -2
  84. package/dist/adapters/database/domains/session-token/entity.mjs.map +1 -1
  85. package/dist/adapters/database/domains/trust-anchor/entity.mjs +2 -2
  86. package/dist/adapters/database/domains/trust-anchor/entity.mjs.map +1 -1
  87. package/dist/adapters/database/domains/user/entity.mjs +2 -2
  88. package/dist/adapters/database/domains/user/entity.mjs.map +1 -1
  89. package/dist/adapters/database/domains/user/subscriber.mjs +2 -2
  90. package/dist/adapters/database/domains/user/subscriber.mjs.map +1 -1
  91. package/dist/adapters/database/domains/user-attribute/entity.mjs +2 -2
  92. package/dist/adapters/database/domains/user-attribute/entity.mjs.map +1 -1
  93. package/dist/adapters/database/domains/user-attribute/subscriber.mjs +2 -2
  94. package/dist/adapters/database/domains/user-attribute/subscriber.mjs.map +1 -1
  95. package/dist/adapters/database/domains/user-authenticator/entity.mjs +2 -2
  96. package/dist/adapters/database/domains/user-authenticator/entity.mjs.map +1 -1
  97. package/dist/adapters/database/domains/user-permission/entity.mjs +2 -2
  98. package/dist/adapters/database/domains/user-permission/entity.mjs.map +1 -1
  99. package/dist/adapters/database/domains/user-permission/subscriber.mjs +2 -2
  100. package/dist/adapters/database/domains/user-permission/subscriber.mjs.map +1 -1
  101. package/dist/adapters/database/domains/user-role/entity.mjs +2 -2
  102. package/dist/adapters/database/domains/user-role/entity.mjs.map +1 -1
  103. package/dist/adapters/database/domains/user-role/subscriber.mjs +2 -2
  104. package/dist/adapters/database/domains/user-role/subscriber.mjs.map +1 -1
  105. package/dist/adapters/database/errors/driver.mjs.map +1 -1
  106. package/dist/adapters/database/extra-attribute-repository/adapter.mjs.map +1 -1
  107. package/dist/adapters/database/extra-attribute-repository/tree/adapter.mjs.map +1 -1
  108. package/dist/adapters/database/extra-attribute-repository/tree/repository.mjs.map +1 -1
  109. package/dist/adapters/database/migrations/mysql/1779267068441-Default.mjs.map +1 -1
  110. package/dist/adapters/database/migrations/mysql/1779300000000-Default.mjs.map +1 -1
  111. package/dist/adapters/database/migrations/mysql/1784289540000-CamelCaseAttributes.mjs.map +1 -1
  112. package/dist/adapters/database/migrations/postgres/1779267068441-Default.mjs.map +1 -1
  113. package/dist/adapters/database/migrations/postgres/1779300000000-Default.mjs.map +1 -1
  114. package/dist/adapters/database/migrations/postgres/1784289540000-CamelCaseAttributes.mjs.map +1 -1
  115. package/dist/adapters/database/subscriber/module.mjs.map +1 -1
  116. package/dist/adapters/http/adapters/oauth2/authorization/module.mjs.map +1 -1
  117. package/dist/adapters/http/adapters/oauth2/grant-types/utils/realm.mjs.map +1 -1
  118. package/dist/adapters/http/controllers/entities/client/module.mjs +2 -2
  119. package/dist/adapters/http/controllers/entities/client/module.mjs.map +1 -1
  120. package/dist/adapters/http/controllers/entities/client-permission/module.mjs +2 -2
  121. package/dist/adapters/http/controllers/entities/client-permission/module.mjs.map +1 -1
  122. package/dist/adapters/http/controllers/entities/client-role/module.mjs +2 -2
  123. package/dist/adapters/http/controllers/entities/client-role/module.mjs.map +1 -1
  124. package/dist/adapters/http/controllers/entities/client-scope/module.mjs +2 -2
  125. package/dist/adapters/http/controllers/entities/client-scope/module.mjs.map +1 -1
  126. package/dist/adapters/http/controllers/entities/consent/module.mjs +2 -2
  127. package/dist/adapters/http/controllers/entities/consent/module.mjs.map +1 -1
  128. package/dist/adapters/http/controllers/entities/event/module.mjs +2 -2
  129. package/dist/adapters/http/controllers/entities/event/module.mjs.map +1 -1
  130. package/dist/adapters/http/controllers/entities/identity-provide-role/module.mjs +2 -2
  131. package/dist/adapters/http/controllers/entities/identity-provide-role/module.mjs.map +1 -1
  132. package/dist/adapters/http/controllers/entities/identity-provider/module.mjs +2 -2
  133. package/dist/adapters/http/controllers/entities/identity-provider/module.mjs.map +1 -1
  134. package/dist/adapters/http/controllers/entities/key/module.mjs +2 -2
  135. package/dist/adapters/http/controllers/entities/key/module.mjs.map +1 -1
  136. package/dist/adapters/http/controllers/entities/permission/module.mjs +2 -2
  137. package/dist/adapters/http/controllers/entities/permission/module.mjs.map +1 -1
  138. package/dist/adapters/http/controllers/entities/permission-policy/module.mjs +2 -2
  139. package/dist/adapters/http/controllers/entities/permission-policy/module.mjs.map +1 -1
  140. package/dist/adapters/http/controllers/entities/policy/module.mjs +2 -2
  141. package/dist/adapters/http/controllers/entities/policy/module.mjs.map +1 -1
  142. package/dist/adapters/http/controllers/entities/realm/module.mjs +2 -2
  143. package/dist/adapters/http/controllers/entities/realm/module.mjs.map +1 -1
  144. package/dist/adapters/http/controllers/entities/role/module.mjs +2 -2
  145. package/dist/adapters/http/controllers/entities/role/module.mjs.map +1 -1
  146. package/dist/adapters/http/controllers/entities/role-attribute/module.mjs +2 -2
  147. package/dist/adapters/http/controllers/entities/role-attribute/module.mjs.map +1 -1
  148. package/dist/adapters/http/controllers/entities/role-permission/module.mjs +2 -2
  149. package/dist/adapters/http/controllers/entities/role-permission/module.mjs.map +1 -1
  150. package/dist/adapters/http/controllers/entities/scope/module.mjs +2 -2
  151. package/dist/adapters/http/controllers/entities/scope/module.mjs.map +1 -1
  152. package/dist/adapters/http/controllers/entities/session/module.mjs +2 -2
  153. package/dist/adapters/http/controllers/entities/session/module.mjs.map +1 -1
  154. package/dist/adapters/http/controllers/entities/trust-anchor/module.mjs +2 -2
  155. package/dist/adapters/http/controllers/entities/trust-anchor/module.mjs.map +1 -1
  156. package/dist/adapters/http/controllers/entities/user/module.mjs +2 -2
  157. package/dist/adapters/http/controllers/entities/user/module.mjs.map +1 -1
  158. package/dist/adapters/http/controllers/entities/user-attribute/module.mjs +2 -2
  159. package/dist/adapters/http/controllers/entities/user-attribute/module.mjs.map +1 -1
  160. package/dist/adapters/http/controllers/entities/user-authenticator/module.mjs +2 -2
  161. package/dist/adapters/http/controllers/entities/user-authenticator/module.mjs.map +1 -1
  162. package/dist/adapters/http/controllers/entities/user-permission/module.mjs +2 -2
  163. package/dist/adapters/http/controllers/entities/user-permission/module.mjs.map +1 -1
  164. package/dist/adapters/http/controllers/entities/user-role/module.mjs +2 -2
  165. package/dist/adapters/http/controllers/entities/user-role/module.mjs.map +1 -1
  166. package/dist/adapters/http/controllers/workflows/activate/module.mjs +2 -2
  167. package/dist/adapters/http/controllers/workflows/authenticator-challenge/module.mjs +2 -2
  168. package/dist/adapters/http/controllers/workflows/authorize/module.mjs +2 -2
  169. package/dist/adapters/http/controllers/workflows/authorize/module.mjs.map +1 -1
  170. package/dist/adapters/http/controllers/workflows/jwks/handlers/read.mjs.map +1 -1
  171. package/dist/adapters/http/controllers/workflows/jwks/module.mjs +2 -2
  172. package/dist/adapters/http/controllers/workflows/jwks/module.mjs.map +1 -1
  173. package/dist/adapters/http/controllers/workflows/logout/module.mjs +2 -2
  174. package/dist/adapters/http/controllers/workflows/logout/module.mjs.map +1 -1
  175. package/dist/adapters/http/controllers/workflows/openid/module.mjs +2 -2
  176. package/dist/adapters/http/controllers/workflows/password-forgot/module.mjs +2 -2
  177. package/dist/adapters/http/controllers/workflows/password-reset/module.mjs +2 -2
  178. package/dist/adapters/http/controllers/workflows/register/module.mjs +2 -2
  179. package/dist/adapters/http/controllers/workflows/status/module.mjs +2 -2
  180. package/dist/adapters/http/controllers/workflows/token/module.mjs +2 -2
  181. package/dist/adapters/http/controllers/workflows/token/utils/extract.mjs.map +1 -1
  182. package/dist/adapters/http/middleware/built-in/authorization/module.mjs.map +1 -1
  183. package/dist/adapters/http/middleware/built-in/cors.mjs.map +1 -1
  184. package/dist/adapters/http/middleware/built-in/logger.mjs.map +1 -1
  185. package/dist/adapters/http/request/constants.mjs.map +1 -1
  186. package/dist/adapters/http/request/helpers/param-id.mjs.map +1 -1
  187. package/dist/adapters/http/request/helpers/redirect.mjs.map +1 -1
  188. package/dist/app/factory.mjs.map +1 -1
  189. package/dist/app/modules/authentication/module.mjs.map +1 -1
  190. package/dist/app/modules/authentication/repositories/constants.mjs.map +1 -1
  191. package/dist/app/modules/authentication/repositories/session.mjs.map +1 -1
  192. package/dist/app/modules/cache/module.mjs.map +1 -1
  193. package/dist/app/modules/components/module.mjs.map +1 -1
  194. package/dist/app/modules/config/constants.mjs.map +1 -1
  195. package/dist/app/modules/config/origins.mjs.map +1 -1
  196. package/dist/app/modules/config/read/env.mjs.map +1 -1
  197. package/dist/app/modules/config/read/fs.mjs.map +1 -1
  198. package/dist/app/modules/config/validator.mjs.map +1 -1
  199. package/dist/app/modules/database/module.mjs.map +1 -1
  200. package/dist/app/modules/database/repositories/bindings.mjs.map +1 -1
  201. package/dist/app/modules/database/repositories/client/repository.mjs.map +1 -1
  202. package/dist/app/modules/database/repositories/event/repository.mjs.map +1 -1
  203. package/dist/app/modules/database/repositories/helpers.mjs.map +1 -1
  204. package/dist/app/modules/database/repositories/permission-provider/module.mjs.map +1 -1
  205. package/dist/app/modules/database/repositories/user/repository.mjs.map +1 -1
  206. package/dist/app/modules/database/repositories/user-attribute/repository.mjs.map +1 -1
  207. package/dist/app/modules/database/repositories/user-authenticator/repository.mjs.map +1 -1
  208. package/dist/app/modules/http/module.mjs.map +1 -1
  209. package/dist/app/modules/http/modules/controller.mjs.map +1 -1
  210. package/dist/app/modules/identity/module.mjs.map +1 -1
  211. package/dist/app/modules/logger/module.mjs.map +1 -1
  212. package/dist/app/modules/mail/module.mjs.map +1 -1
  213. package/dist/app/modules/metrics/prom.mjs.map +1 -1
  214. package/dist/app/modules/oauth2/module.mjs.map +1 -1
  215. package/dist/app/modules/oauth2/repositories/consent/repository.mjs.map +1 -1
  216. package/dist/app/modules/oauth2/repositories/constants.mjs.map +1 -1
  217. package/dist/app/modules/provisioning/module.mjs.map +1 -1
  218. package/dist/app/modules/provisioning/sources/composite/module.mjs.map +1 -1
  219. package/dist/app/modules/provisioning/sources/default/module.mjs.map +1 -1
  220. package/dist/app/modules/provisioning/sources/file/module.mjs.map +1 -1
  221. package/dist/app/modules/runtime/module.mjs.map +1 -1
  222. package/dist/cli/commands/migration.mjs.map +1 -1
  223. package/dist/components/database/unique-entries/module.mjs.map +1 -1
  224. package/dist/core/authentication/entities/client/module.mjs.map +1 -1
  225. package/dist/core/authentication/session/module.mjs.map +1 -1
  226. package/dist/core/authentication/session/types.mjs.map +1 -1
  227. package/dist/core/client-certificate/module.mjs.map +1 -1
  228. package/dist/core/entities/client/schema.mjs.map +1 -1
  229. package/dist/core/entities/client/service.mjs.map +1 -1
  230. package/dist/core/entities/client-permission/schema.mjs.map +1 -1
  231. package/dist/core/entities/client-permission/service.mjs.map +1 -1
  232. package/dist/core/entities/client-role/schema.mjs.map +1 -1
  233. package/dist/core/entities/client-role/service.mjs.map +1 -1
  234. package/dist/core/entities/client-scope/schema.mjs.map +1 -1
  235. package/dist/core/entities/client-scope/service.mjs.map +1 -1
  236. package/dist/core/entities/consent/schema.mjs.map +1 -1
  237. package/dist/core/entities/consent/types.mjs.map +1 -1
  238. package/dist/core/entities/event/diff.mjs.map +1 -1
  239. package/dist/core/entities/event/sanitize.mjs.map +1 -1
  240. package/dist/core/entities/event/schema.mjs.map +1 -1
  241. package/dist/core/entities/event/service.mjs.map +1 -1
  242. package/dist/core/entities/identity-provider/schema.mjs.map +1 -1
  243. package/dist/core/entities/identity-provider-role-mapping/schema.mjs.map +1 -1
  244. package/dist/core/entities/identity-provider-role-mapping/service.mjs.map +1 -1
  245. package/dist/core/entities/key/schema.mjs.map +1 -1
  246. package/dist/core/entities/key/service.mjs.map +1 -1
  247. package/dist/core/entities/permission/schema.d.ts.map +1 -1
  248. package/dist/core/entities/permission/schema.mjs +12 -0
  249. package/dist/core/entities/permission/schema.mjs.map +1 -1
  250. package/dist/core/entities/permission/service.mjs.map +1 -1
  251. package/dist/core/entities/permission-policy/schema.mjs.map +1 -1
  252. package/dist/core/entities/permission-policy/service.mjs.map +1 -1
  253. package/dist/core/entities/policy/schema.mjs.map +1 -1
  254. package/dist/core/entities/policy/service.mjs.map +1 -1
  255. package/dist/core/entities/realm/schema.mjs.map +1 -1
  256. package/dist/core/entities/role/schema.mjs.map +1 -1
  257. package/dist/core/entities/role/service.mjs.map +1 -1
  258. package/dist/core/entities/role-attribute/schema.mjs.map +1 -1
  259. package/dist/core/entities/role-attribute/service.mjs.map +1 -1
  260. package/dist/core/entities/role-permission/schema.mjs.map +1 -1
  261. package/dist/core/entities/role-permission/service.mjs.map +1 -1
  262. package/dist/core/entities/scope/schema.mjs.map +1 -1
  263. package/dist/core/entities/scope/service.mjs.map +1 -1
  264. package/dist/core/entities/session/schema.mjs.map +1 -1
  265. package/dist/core/entities/session/service.mjs.map +1 -1
  266. package/dist/core/entities/trust-anchor/schema.mjs.map +1 -1
  267. package/dist/core/entities/trust-anchor/service.mjs.map +1 -1
  268. package/dist/core/entities/user/schema.mjs.map +1 -1
  269. package/dist/core/entities/user/service.mjs.map +1 -1
  270. package/dist/core/entities/user-attribute/schema.mjs.map +1 -1
  271. package/dist/core/entities/user-attribute/service.mjs.map +1 -1
  272. package/dist/core/entities/user-authenticator/schema.mjs.map +1 -1
  273. package/dist/core/entities/user-authenticator/service.mjs.map +1 -1
  274. package/dist/core/entities/user-authenticator/types.mjs.map +1 -1
  275. package/dist/core/entities/user-permission/schema.mjs.map +1 -1
  276. package/dist/core/entities/user-permission/service.mjs.map +1 -1
  277. package/dist/core/entities/user-role/schema.mjs.map +1 -1
  278. package/dist/core/entities/user-role/service.mjs.map +1 -1
  279. package/dist/core/identity/permission/junction-grant.mjs.map +1 -1
  280. package/dist/core/identity/permission/module.mjs.map +1 -1
  281. package/dist/core/identity/provider/authentication/presets/facebook.mjs.map +1 -1
  282. package/dist/core/identity/provider/authentication/presets/github.mjs.map +1 -1
  283. package/dist/core/identity/provider/authentication/presets/google.mjs.map +1 -1
  284. package/dist/core/identity/provider/authentication/presets/instagram.mjs.map +1 -1
  285. package/dist/core/identity/provider/authentication/presets/paypal.mjs.map +1 -1
  286. package/dist/core/identity/provider/authentication/protocols/ldap/module.mjs.map +1 -1
  287. package/dist/core/identity/provider/authentication/protocols/oauth2/module.mjs.map +1 -1
  288. package/dist/core/identity/provider/authentication/protocols/open-id/module.mjs.map +1 -1
  289. package/dist/core/identity/provider/constants.mjs.map +1 -1
  290. package/dist/core/identity/provider/mapper/base.mjs.map +1 -1
  291. package/dist/core/identity/provider/mapper/constants.mjs.map +1 -1
  292. package/dist/core/identity/registration/service.mjs.map +1 -1
  293. package/dist/core/key/provisioner.mjs.map +1 -1
  294. package/dist/core/key/realm-cipher.mjs.map +1 -1
  295. package/dist/core/mail/template/templates/mfa-email-otp.mjs.map +1 -1
  296. package/dist/core/mail/template/templates/password-reset.mjs.map +1 -1
  297. package/dist/core/mail/template/templates/registration-activation.mjs.map +1 -1
  298. package/dist/core/mail/template/types.mjs.map +1 -1
  299. package/dist/core/oauth2/authorization/code/verifier/module.mjs.map +1 -1
  300. package/dist/core/oauth2/authorization/code-request/verifier/module.mjs.map +1 -1
  301. package/dist/core/oauth2/authorization/module.mjs.map +1 -1
  302. package/dist/core/oauth2/end-session/service.mjs.map +1 -1
  303. package/dist/core/oauth2/grant-types/refresh-token.mjs.map +1 -1
  304. package/dist/core/oauth2/mfa-login/module.mjs.map +1 -1
  305. package/dist/core/oauth2/openid/claims.mjs.map +1 -1
  306. package/dist/core/oauth2/scope/resolver.mjs.map +1 -1
  307. package/dist/core/oauth2/token/issuer/access/module.mjs.map +1 -1
  308. package/dist/core/oauth2/token/issuer/mfa/module.mjs.map +1 -1
  309. package/dist/core/oauth2/token/issuer/open-id/module.mjs.map +1 -1
  310. package/dist/core/oauth2/token/issuer/refresh/module.mjs.map +1 -1
  311. package/dist/core/oauth2/token/verifier/module.mjs.map +1 -1
  312. package/dist/core/provisioning/entities/policy/validator.mjs.map +1 -1
  313. package/dist/core/provisioning/entities/utils.mjs.map +1 -1
  314. package/dist/core/provisioning/strategy/constants.mjs.map +1 -1
  315. package/dist/core/provisioning/strategy/validator.mjs.map +1 -1
  316. package/dist/core/provisioning/synchronizer/client/module.mjs.map +1 -1
  317. package/dist/core/provisioning/synchronizer/role/module.mjs.map +1 -1
  318. package/dist/core/provisioning/synchronizer/user/module.mjs.map +1 -1
  319. package/dist/core/query/module.mjs.map +1 -1
  320. package/dist/core/query/relations.mjs.map +1 -1
  321. package/dist/core/security/policy/evaluator.mjs.map +1 -1
  322. package/dist/ui/client/.vite/ssr-manifest.json +218 -218
  323. package/dist/ui/client/assets/index-CiHrf73J.css +2 -0
  324. package/dist/ui/client/assets/{index-BmJ2X468.js → index-mtJngmng.js} +1 -1
  325. package/dist/ui/client/index.html +2 -2
  326. package/dist/ui/server/server.js +534 -79
  327. package/package.json +26 -26
  328. package/dist/ui/client/assets/index-DiOvW76Q.css +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":["ValidatorGroup","buildZodIssuesForError","isValidupError","createProvisioningEntitiesValidator","validator","ctx","i","value","length","run","group","PROVISIONING","e","issues","push","map","issue","path"],"sources":["../../../../src/core/provisioning/entities/utils.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 { ValidatorGroup } from '@authup/kit';\nimport { buildZodIssuesForError } from '@validup/zod';\nimport type { ParsePayload } from 'zod/v4/core';\nimport type { Container } from 'validup';\nimport { isValidupError } from 'validup';\n\n/**\n * Run a provisioning entity validator over every array element with the\n * PROVISIONING group (zod check closures do not inherit the validup run\n * group) and write the validated output back, so validator transforms\n * (canonicalization, stripping) reach the synchronizers.\n */\nexport function createProvisioningEntitiesValidator(\n validator: Container<any>,\n): (ctx: ParsePayload<any[]>) => Promise<void> {\n return async (ctx) => {\n for (let i = 0; i < ctx.value.length; i++) {\n try {\n ctx.value[i] = await validator.run(ctx.value[i], { group: ValidatorGroup.PROVISIONING });\n } catch (e) {\n if (!isValidupError(e)) {\n throw e;\n }\n\n ctx.issues.push(...buildZodIssuesForError(e).map((issue) => ({\n ...issue,\n path: [i, ...(issue.path ?? [])],\n })));\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;GAmBA,SAAgBG,oCACZC,WAAyB;CAEzB,OAAO,OAAOC,QAAAA;EACV,KAAK,IAAIC,IAAI,GAAGA,IAAID,IAAIE,MAAMC,QAAQF,KAClC,IAAI;GACAD,IAAIE,MAAMD,KAAK,MAAMF,UAAUK,IAAIJ,IAAIE,MAAMD,IAAI,EAAEI,OAAOV,eAAeW,aAAa,CAAA;EAC1F,SAASC,GAAG;GACR,IAAI,CAACV,eAAeU,CAAAA,GAChB,MAAMA;GAGVP,IAAIQ,OAAOC,KAAI,GAAIb,uBAAuBW,CAAAA,CAAAA,CAAGG,KAAKC,WAAW;IACzD,GAAGA;IACHC,MAAM,CAACX,GAAAA,GAAOU,MAAMC,QAAQ,CAAA,CAAA;GAChC,EAAA,CAAA;EACJ;CAER;AACJ"}
1
+ {"version":3,"file":"utils.mjs","names":["ValidatorGroup","buildZodIssuesForError","isValidupError","createProvisioningEntitiesValidator","validator","ctx","i","value","length","run","group","PROVISIONING","e","issues","push","map","issue","path"],"sources":["../../../../src/core/provisioning/entities/utils.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 { ValidatorGroup } from '@authup/kit';\nimport { buildZodIssuesForError } from '@validup/zod';\nimport type { ParsePayload } from 'zod/v4/core';\nimport type { Container } from 'validup';\nimport { isValidupError } from 'validup';\n\n/**\n * Run a provisioning entity validator over every array element with the\n * PROVISIONING group (zod check closures do not inherit the validup run\n * group) and write the validated output back, so validator transforms\n * (canonicalization, stripping) reach the synchronizers.\n */\nexport function createProvisioningEntitiesValidator(\n validator: Container<any>,\n): (ctx: ParsePayload<any[]>) => Promise<void> {\n return async (ctx) => {\n for (let i = 0; i < ctx.value.length; i++) {\n try {\n ctx.value[i] = await validator.run(ctx.value[i], { group: ValidatorGroup.PROVISIONING });\n } catch (e) {\n if (!isValidupError(e)) {\n throw e;\n }\n\n ctx.issues.push(...buildZodIssuesForError(e).map((issue) => ({\n ...issue,\n path: [i, ...(issue.path ?? [])],\n })));\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;GAmBA,SAAgBG,oCACZC,WAAyB;CAEzB,OAAO,OAAOC,QAAAA;EACV,KAAK,IAAIC,IAAI,GAAGA,IAAID,IAAIE,MAAMC,QAAQF,KAClC,IAAI;GACAD,IAAIE,MAAMD,KAAK,MAAMF,UAAUK,IAAIJ,IAAIE,MAAMD,IAAI,EAAEI,OAAOV,eAAeW,aAAa,CAAA;EAC1F,SAASC,GAAG;GACR,IAAI,CAACV,eAAeU,CAAAA,GAChB,MAAMA;GAGVP,IAAIQ,OAAOC,KAAI,GAAIb,uBAAuBW,CAAAA,CAAAA,CAAGG,KAAKC,WAAW;IACzD,GAAGA;IACHC,MAAM,CAACX,GAAOU,GAAAA,MAAMC,QAAQ,CAAA,CAAI;GACpC,EAAA,CAAA;EACJ;CAER;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","names":["ProvisioningEntityStrategyType"],"sources":["../../../../src/core/provisioning/strategy/constants.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\nexport enum ProvisioningEntityStrategyType {\n REPLACE = 'replace',\n MERGE = 'merge',\n CREATE_ONLY = 'createOnly',\n ABSENT = 'absent',\n}\n"],"mappings":";;;;AAOA,IAAO,iCAAKA,uBAAAA,gCAAAA;;;;;QAAAA"}
1
+ {"version":3,"file":"constants.mjs","names":["ProvisioningEntityStrategyType"],"sources":["../../../../src/core/provisioning/strategy/constants.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\nexport enum ProvisioningEntityStrategyType {\n REPLACE = 'replace',\n MERGE = 'merge',\n CREATE_ONLY = 'createOnly',\n ABSENT = 'absent',\n}\n"],"mappings":";;;;AAOA,IAAO,iCAAKA,uBAAAA,gCAAAA;;;;;CAAAA,OAAAA;AAKX,EAAA,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"validator.mjs","names":["createValidator","Container","z","ProvisioningStrategyValidator","options","oneOf","initialize","mergeContainer","mount","enum","array","string","optional","altContainer"],"sources":["../../../../src/core/provisioning/strategy/validator.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 { createValidator } from '@validup/zod';\nimport type { ContainerOptions } from 'validup';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { ProvisioningEntityMergeStrategy, ProvisioningEntityReplaceStrategy, ProvisioningEntityStrategy } from './types.ts';\n\nexport class ProvisioningStrategyValidator extends Container<ProvisioningEntityStrategy> {\n constructor(options: ContainerOptions<ProvisioningEntityStrategy> = {}) {\n super({\n ...options,\n oneOf: true,\n });\n }\n\n protected initialize() {\n super.initialize();\n\n const mergeContainer = new Container<ProvisioningEntityMergeStrategy>();\n mergeContainer.mount('type', createValidator(\n z\n .enum(['merge']),\n ));\n mergeContainer.mount('attributes', createValidator(\n z\n .array(z.string())\n .optional(),\n ));\n this.mount(mergeContainer);\n\n const altContainer = new Container<ProvisioningEntityReplaceStrategy>();\n altContainer.mount('type', createValidator(\n z\n .enum(['replace', 'createOnly', 'absent']),\n ));\n this.mount(altContainer);\n }\n}\n"],"mappings":";;;;;;;AAaA,IAAaG,gCAAb,cAAmDF,UAAAA;CAC/C,YAAYG,UAAwD,CAAC,GAAG;EACpE,MAAM;GACF,GAAGA;GACHC,OAAO;EACX,CAAA;CACJ;CAEUC,aAAa;EACnB,MAAMA,WAAAA;EAEN,MAAMC,iBAAiB,IAAIN,UAAAA;EAC3BM,eAAeC,MAAM,QAAQR,gBACzBE,EACKO,KAAK,CAAC,OAAA,CAAQ,CAAA,CAAA;EAEvBF,eAAeC,MAAM,cAAcR,gBAC/BE,EACKQ,MAAMR,EAAES,OAAM,CAAA,CAAA,CACdC,SAAQ,CAAA,CAAA;EAEjB,KAAKJ,MAAMD,cAAAA;EAEX,MAAMM,eAAe,IAAIZ,UAAAA;EACzBY,aAAaL,MAAM,QAAQR,gBACvBE,EACKO,KAAK;GAAC;GAAW;GAAc;GAAS,CAAA,CAAA;EAEjD,KAAKD,MAAMK,YAAAA;CACf;AACJ"}
1
+ {"version":3,"file":"validator.mjs","names":["createValidator","Container","z","ProvisioningStrategyValidator","options","oneOf","initialize","mergeContainer","mount","enum","array","string","optional","altContainer"],"sources":["../../../../src/core/provisioning/strategy/validator.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 { createValidator } from '@validup/zod';\nimport type { ContainerOptions } from 'validup';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { ProvisioningEntityMergeStrategy, ProvisioningEntityReplaceStrategy, ProvisioningEntityStrategy } from './types.ts';\n\nexport class ProvisioningStrategyValidator extends Container<ProvisioningEntityStrategy> {\n constructor(options: ContainerOptions<ProvisioningEntityStrategy> = {}) {\n super({\n ...options,\n oneOf: true,\n });\n }\n\n protected initialize() {\n super.initialize();\n\n const mergeContainer = new Container<ProvisioningEntityMergeStrategy>();\n mergeContainer.mount('type', createValidator(\n z\n .enum(['merge']),\n ));\n mergeContainer.mount('attributes', createValidator(\n z\n .array(z.string())\n .optional(),\n ));\n this.mount(mergeContainer);\n\n const altContainer = new Container<ProvisioningEntityReplaceStrategy>();\n altContainer.mount('type', createValidator(\n z\n .enum(['replace', 'createOnly', 'absent']),\n ));\n this.mount(altContainer);\n }\n}\n"],"mappings":";;;;;;;AAaA,IAAaG,gCAAb,cAAmDF,UAAAA;CAC/C,YAAYG,UAAwD,CAAC,GAAG;EACpE,MAAM;GACF,GAAGA;GACHC,OAAO;EACX,CAAA;CACJ;CAEUC,aAAa;EACnB,MAAMA,WAAAA;EAEN,MAAMC,iBAAiB,IAAIN,UAAAA;EAC3BM,eAAeC,MAAM,QAAQR,gBACzBE,EACKO,KAAK,CAAC,OAAQ,CAAA,CAAA,CAAA;EAEvBF,eAAeC,MAAM,cAAcR,gBAC/BE,EACKQ,MAAMR,EAAES,OAAM,CAAA,CAAA,CACdC,SAAQ,CAAA,CAAA;EAEjB,KAAKJ,MAAMD,cAAAA;EAEX,MAAMM,eAAe,IAAIZ,UAAAA;EACzBY,aAAaL,MAAM,QAAQR,gBACvBE,EACKO,KAAK;GAAC;GAAW;GAAc;EAAS,CAAA,CAAA,CAAA;EAEjD,KAAKD,MAAMK,YAAAA;CACf;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"module.mjs","names":["pickRecord","ProvisioningEntityStrategyType","normalizeEntityProvisioningStrategy","BaseProvisioningSynchronizer","ProvisioningEntityResolver","ProvisioningJunctionSynchronizer","ClientProvisioningSynchronizer","clientRepository","permissionResolver","roleResolver","permissionJunction","roleJunction","permissionSynchronizer","roleSynchronizer","ctx","permissionRepository","roleRepository","repository","clientPermissionRepository","ownerKey","ownerRealmKey","clientRoleRepository","synchronize","input","canonicalizeName","attributes","strategy","findOneBy","name","realmId","type","ABSENT","remove","MERGE","merge","save","REPLACE","id","create","permissions","resolveGlobal","relations","globalPermissions","resolveRealm","realmPermissions","length","roles","globalRoles","realmRoles","children","map","child","clientId","client","synchronizeMany"],"sources":["../../../../../src/core/provisioning/synchronizer/client/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026-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 type {\n ClientPermission, \n ClientRole, \n Permission, \n Role,\n} from '@authup/core-kit';\nimport { pickRecord } from '@authup/kit';\nimport type { IClientRepository } from '../../../entities/index.ts';\nimport type { ClientProvisioningEntity } from '../../entities/client';\nimport type { PermissionProvisioningEntity } from '../../entities/permission';\nimport type { RoleProvisioningEntity } from '../../entities/role';\nimport { ProvisioningEntityStrategyType, normalizeEntityProvisioningStrategy } from '../../strategy/index.ts';\nimport type { IProvisioningSynchronizer } from '../../types.ts';\nimport { BaseProvisioningSynchronizer } from '../base.ts';\nimport { ProvisioningEntityResolver } from '../entity-resolver.ts';\nimport { ProvisioningJunctionSynchronizer } from '../junction-synchronizer.ts';\nimport type { ClientProvisioningSynchronizerContext } from './types.ts';\n\nexport class ClientProvisioningSynchronizer extends BaseProvisioningSynchronizer<ClientProvisioningEntity> {\n protected clientRepository: IClientRepository;\n\n protected permissionResolver: ProvisioningEntityResolver<Permission>;\n\n protected roleResolver: ProvisioningEntityResolver<Role>;\n\n protected permissionJunction: ProvisioningJunctionSynchronizer<ClientPermission>;\n\n protected roleJunction: ProvisioningJunctionSynchronizer<ClientRole>;\n\n protected permissionSynchronizer: IProvisioningSynchronizer<PermissionProvisioningEntity>;\n\n protected roleSynchronizer: IProvisioningSynchronizer<RoleProvisioningEntity>;\n\n constructor(ctx: ClientProvisioningSynchronizerContext) {\n super();\n\n this.clientRepository = ctx.clientRepository;\n\n this.permissionResolver = new ProvisioningEntityResolver(ctx.permissionRepository);\n this.roleResolver = new ProvisioningEntityResolver(ctx.roleRepository);\n\n this.permissionJunction = new ProvisioningJunctionSynchronizer({\n repository: ctx.clientPermissionRepository,\n ownerKey: 'clientId',\n ownerRealmKey: 'clientRealmId',\n });\n this.roleJunction = new ProvisioningJunctionSynchronizer({\n repository: ctx.clientRoleRepository,\n ownerKey: 'clientId',\n ownerRealmKey: 'clientRealmId',\n });\n\n this.permissionSynchronizer = ctx.permissionSynchronizer;\n this.roleSynchronizer = ctx.roleSynchronizer;\n }\n\n async synchronize(input: ClientProvisioningEntity): Promise<ClientProvisioningEntity> {\n this.canonicalizeName(input.attributes);\n\n const strategy = normalizeEntityProvisioningStrategy(input.strategy);\n\n let attributes = await this.clientRepository.findOneBy({\n name: input.attributes.name,\n realmId: input.attributes.realmId || null,\n });\n\n if (strategy.type === ProvisioningEntityStrategyType.ABSENT) {\n if (attributes) {\n await this.clientRepository.remove(attributes);\n }\n return {\n ...input,\n attributes: attributes || input.attributes, \n };\n }\n\n if (attributes) {\n switch (strategy.type) {\n case ProvisioningEntityStrategyType.MERGE:\n attributes = this.clientRepository.merge(\n attributes,\n strategy.attributes ?\n pickRecord(input.attributes, strategy.attributes) :\n input.attributes,\n );\n attributes = await this.clientRepository.save(attributes);\n break;\n case ProvisioningEntityStrategyType.REPLACE:\n input.attributes.id = attributes.id;\n attributes = await this.clientRepository.save(this.clientRepository.create(input.attributes));\n break;\n }\n } else {\n attributes = await this.clientRepository.save(this.clientRepository.create(input.attributes));\n }\n\n // Permissions (Global + Realm)\n const permissions = [\n ...await this.permissionResolver.resolveGlobal(\n input.relations && input.relations.globalPermissions,\n ),\n ...(attributes.realmId ?\n await this.permissionResolver.resolveRealm(\n input.relations && input.relations.realmPermissions,\n attributes.realmId,\n ) :\n []),\n ];\n\n if (permissions.length > 0) {\n await this.permissionJunction.synchronize(\n attributes,\n permissions,\n 'permissionId',\n 'permissionRealmId',\n );\n }\n\n // Roles (Global + Realm)\n const roles = [\n ...await this.roleResolver.resolveGlobal(\n input.relations && input.relations.globalRoles,\n ),\n ...(attributes.realmId ?\n await this.roleResolver.resolveRealm(\n input.relations && input.relations.realmRoles,\n attributes.realmId,\n ) :\n []),\n ];\n\n if (roles.length > 0) {\n await this.roleJunction.synchronize(\n attributes,\n roles,\n 'roleId',\n 'roleRealmId',\n );\n }\n\n // Containers\n\n if (input.relations && input.relations.permissions) {\n const children = input.relations.permissions.map((child) => {\n child.attributes.clientId = attributes.id;\n child.attributes.client = attributes;\n return child;\n });\n\n await this.permissionSynchronizer.synchronizeMany(children);\n }\n\n if (input.relations && input.relations.roles) {\n const children = input.relations.roles.map((child) => {\n child.attributes.clientId = attributes.id;\n child.attributes.client = attributes;\n return child;\n });\n\n await this.roleSynchronizer.synchronizeMany(children);\n }\n\n return {\n ...input,\n attributes,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAyBA,IAAaM,iCAAb,cAAoDH,6BAAAA;CACtCI;CAEAC;CAEAC;CAEAC;CAEAC;CA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AAiByC,gBAAgBL,QAAAA;EAChD;EAEA,OAAO;GACH,GAAG1B;GACHE;EACJ;CACJ;AACJ"}
1
+ {"version":3,"file":"module.mjs","names":["pickRecord","ProvisioningEntityStrategyType","normalizeEntityProvisioningStrategy","BaseProvisioningSynchronizer","ProvisioningEntityResolver","ProvisioningJunctionSynchronizer","ClientProvisioningSynchronizer","clientRepository","permissionResolver","roleResolver","permissionJunction","roleJunction","permissionSynchronizer","roleSynchronizer","ctx","permissionRepository","roleRepository","repository","clientPermissionRepository","ownerKey","ownerRealmKey","clientRoleRepository","synchronize","input","canonicalizeName","attributes","strategy","findOneBy","name","realmId","type","ABSENT","remove","MERGE","merge","save","REPLACE","id","create","permissions","resolveGlobal","relations","globalPermissions","resolveRealm","realmPermissions","length","roles","globalRoles","realmRoles","children","map","child","clientId","client","synchronizeMany"],"sources":["../../../../../src/core/provisioning/synchronizer/client/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026-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 type {\n ClientPermission, \n ClientRole, \n Permission, \n Role,\n} from '@authup/core-kit';\nimport { pickRecord } from '@authup/kit';\nimport type { IClientRepository } from '../../../entities/index.ts';\nimport type { ClientProvisioningEntity } from '../../entities/client';\nimport type { PermissionProvisioningEntity } from '../../entities/permission';\nimport type { RoleProvisioningEntity } from '../../entities/role';\nimport { ProvisioningEntityStrategyType, normalizeEntityProvisioningStrategy } from '../../strategy/index.ts';\nimport type { IProvisioningSynchronizer } from '../../types.ts';\nimport { BaseProvisioningSynchronizer } from '../base.ts';\nimport { ProvisioningEntityResolver } from '../entity-resolver.ts';\nimport { ProvisioningJunctionSynchronizer } from '../junction-synchronizer.ts';\nimport type { ClientProvisioningSynchronizerContext } from './types.ts';\n\nexport class ClientProvisioningSynchronizer extends BaseProvisioningSynchronizer<ClientProvisioningEntity> {\n protected clientRepository: IClientRepository;\n\n protected permissionResolver: ProvisioningEntityResolver<Permission>;\n\n protected roleResolver: ProvisioningEntityResolver<Role>;\n\n protected permissionJunction: ProvisioningJunctionSynchronizer<ClientPermission>;\n\n protected roleJunction: ProvisioningJunctionSynchronizer<ClientRole>;\n\n protected permissionSynchronizer: IProvisioningSynchronizer<PermissionProvisioningEntity>;\n\n protected roleSynchronizer: IProvisioningSynchronizer<RoleProvisioningEntity>;\n\n constructor(ctx: ClientProvisioningSynchronizerContext) {\n super();\n\n this.clientRepository = ctx.clientRepository;\n\n this.permissionResolver = new ProvisioningEntityResolver(ctx.permissionRepository);\n this.roleResolver = new ProvisioningEntityResolver(ctx.roleRepository);\n\n this.permissionJunction = new ProvisioningJunctionSynchronizer({\n repository: ctx.clientPermissionRepository,\n ownerKey: 'clientId',\n ownerRealmKey: 'clientRealmId',\n });\n this.roleJunction = new ProvisioningJunctionSynchronizer({\n repository: ctx.clientRoleRepository,\n ownerKey: 'clientId',\n ownerRealmKey: 'clientRealmId',\n });\n\n this.permissionSynchronizer = ctx.permissionSynchronizer;\n this.roleSynchronizer = ctx.roleSynchronizer;\n }\n\n async synchronize(input: ClientProvisioningEntity): Promise<ClientProvisioningEntity> {\n this.canonicalizeName(input.attributes);\n\n const strategy = normalizeEntityProvisioningStrategy(input.strategy);\n\n let attributes = await this.clientRepository.findOneBy({\n name: input.attributes.name,\n realmId: input.attributes.realmId || null,\n });\n\n if (strategy.type === ProvisioningEntityStrategyType.ABSENT) {\n if (attributes) {\n await this.clientRepository.remove(attributes);\n }\n return {\n ...input,\n attributes: attributes || input.attributes, \n };\n }\n\n if (attributes) {\n switch (strategy.type) {\n case ProvisioningEntityStrategyType.MERGE:\n attributes = this.clientRepository.merge(\n attributes,\n strategy.attributes ?\n pickRecord(input.attributes, strategy.attributes) :\n input.attributes,\n );\n attributes = await this.clientRepository.save(attributes);\n break;\n case ProvisioningEntityStrategyType.REPLACE:\n input.attributes.id = attributes.id;\n attributes = await this.clientRepository.save(this.clientRepository.create(input.attributes));\n break;\n }\n } else {\n attributes = await this.clientRepository.save(this.clientRepository.create(input.attributes));\n }\n\n // Permissions (Global + Realm)\n const permissions = [\n ...await this.permissionResolver.resolveGlobal(\n input.relations && input.relations.globalPermissions,\n ),\n ...(attributes.realmId ?\n await this.permissionResolver.resolveRealm(\n input.relations && input.relations.realmPermissions,\n attributes.realmId,\n ) :\n []),\n ];\n\n if (permissions.length > 0) {\n await this.permissionJunction.synchronize(\n attributes,\n permissions,\n 'permissionId',\n 'permissionRealmId',\n );\n }\n\n // Roles (Global + Realm)\n const roles = [\n ...await this.roleResolver.resolveGlobal(\n input.relations && input.relations.globalRoles,\n ),\n ...(attributes.realmId ?\n await this.roleResolver.resolveRealm(\n input.relations && input.relations.realmRoles,\n attributes.realmId,\n ) :\n []),\n ];\n\n if (roles.length > 0) {\n await this.roleJunction.synchronize(\n attributes,\n roles,\n 'roleId',\n 'roleRealmId',\n );\n }\n\n // Containers\n\n if (input.relations && input.relations.permissions) {\n const children = input.relations.permissions.map((child) => {\n child.attributes.clientId = attributes.id;\n child.attributes.client = attributes;\n return child;\n });\n\n await this.permissionSynchronizer.synchronizeMany(children);\n }\n\n if (input.relations && input.relations.roles) {\n const children = input.relations.roles.map((child) => {\n child.attributes.clientId = attributes.id;\n child.attributes.client = attributes;\n return child;\n });\n\n await this.roleSynchronizer.synchronizeMany(children);\n }\n\n return {\n ...input,\n attributes,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAyBA,IAAaM,iCAAb,cAAoDH,6BAAAA;CACtCI;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEV,YAAYC,KAA4C;EACpD,MAAK;EAEL,KAAKP,mBAAmBO,IAAIP;EAE5B,KAAKC,qBAAqB,IAAIJ,2BAA2BU,IAAIC,oBAAoB;EACjF,KAAKN,eAAe,IAAIL,2BAA2BU,IAAIE,cAAc;EAErE,KAAKN,qBAAqB,IAAIL,iCAAiC;GAC3DY,YAAYH,IAAII;GAChBC,UAAU;GACVC,eAAe;EACnB,CAAA;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AMkB,UAAUG,kBACnCnB,WAAWI,OAAO,IAEtB,CAAA,CACP;EAED,IAAIU,YAAYM,SAAS,GACrB,MAAM,KAAKnC,mBAAmBY,YAC1BG,YACAc,aACA,gBACA,mBAAA;EAKR,MAAMO,QAAQ,CACP,GAAA,MAAM,KAAKrC,aAAa+B,cACvBjB,MAAMkB,aAAalB,MAAMkB,UAAUM,WAAW,GAE9CtB,GAAAA,WAAWI,UACX,MAAM,KAAKpB,aAAakC,aACpBpB,MAAMkB,aAAalB,MAAMkB,UAAUO,YACnCvB,WAAWI,OAAO,IAEtB,CAAA,CACP;EAED,IAAIiB,MAAMD,SAAS,GACf,MAAM,KAAKlC,aAAaW,YACpBG,YACAqB,OACA,UACA,aAAA;EAMR,IAAIvB,MAAMkB,aAAalB,MAAMkB,UAAUF,aAAa;GAChD,MAAMU,WAAW1B,MAAMkB,UAAUF,YAAYW,KAAKC,UAAAA;IAC9CA,MAAM1B,WAAW2B,WAAW3B,WAAWY;IACvCc,MAAM1B,WAAW4B,SAAS5B;IAC1B,OAAO0B;GACX,CAAA;GAEA,MAAM,KAAKvC,uBAAuB0C,gBAAgBL,QAAAA;EACtD;EAEA,IAAI1B,MAAMkB,aAAalB,MAAMkB,UAAUK,OAAO;GAC1C,MAAMG,WAAW1B,MAAMkB,UAAUK,MAAMI,KAAKC,UAAAA;IACxCA,MAAM1B,WAAW2B,WAAW3B,WAAWY;IACvCc,MAAM1B,WAAW4B,SAAS5B;IAC1B,OAAO0B;GACX,CAAA;GAEA,MAAM,KAAKtC,iBAAiByC,gBAAgBL,QAAAA;EAChD;EAEA,OAAO;GACH,GAAG1B;GACHE;EACJ;CACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"module.mjs","names":["pickRecord","ProvisioningEntityStrategyType","normalizeEntityProvisioningStrategy","BaseProvisioningSynchronizer","ProvisioningEntityResolver","ProvisioningJunctionSynchronizer","RoleProvisioningSynchronizer","repository","permissionResolver","permissionJunction","ctx","permissionRepository","rolePermissionRepository","ownerKey","ownerRealmKey","synchronize","input","canonicalizeName","attributes","strategy","findOneBy","name","realmId","clientId","type","ABSENT","remove","MERGE","merge","save","REPLACE","id","create","relations","globalPermissions","resolveGlobal","globalPermissionsExclude","length","excludeSet","Set","filter","p","has","realmPermissions","resolveRealm","permissions","defaultScope","globalPermissionsRealmScope","overrides","buildRealmScopeOverrides","permission","realmScope","get","Map","globalPermissionsRealmScopeOverrides","permissionNames","Object","entries","permName","set"],"sources":["../../../../../src/core/provisioning/synchronizer/role/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026-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 { pickRecord } from '@authup/kit';\nimport type { Permission, RolePermission } from '@authup/core-kit';\nimport type { IRoleRepository } from '../../../entities/index.ts';\nimport type { RoleProvisioningEntity } from '../../entities/role/index.ts';\nimport { ProvisioningEntityStrategyType, normalizeEntityProvisioningStrategy } from '../../strategy/index.ts';\nimport { BaseProvisioningSynchronizer } from '../base.ts';\nimport { ProvisioningEntityResolver } from '../entity-resolver.ts';\nimport { ProvisioningJunctionSynchronizer } from '../junction-synchronizer.ts';\nimport type { RoleProvisioningSynchronizerContext } from './types.ts';\n\nexport class RoleProvisioningSynchronizer extends BaseProvisioningSynchronizer<RoleProvisioningEntity> {\n protected repository : IRoleRepository;\n\n protected permissionResolver : ProvisioningEntityResolver<Permission>;\n\n protected permissionJunction: ProvisioningJunctionSynchronizer<RolePermission>;\n\n constructor(ctx: RoleProvisioningSynchronizerContext) {\n super();\n\n this.repository = ctx.repository;\n this.permissionResolver = new ProvisioningEntityResolver(ctx.permissionRepository);\n this.permissionJunction = new ProvisioningJunctionSynchronizer({\n repository: ctx.rolePermissionRepository,\n ownerKey: 'roleId',\n ownerRealmKey: 'roleRealmId',\n });\n }\n\n async synchronize(input: RoleProvisioningEntity): Promise<RoleProvisioningEntity> {\n this.canonicalizeName(input.attributes);\n\n const strategy = normalizeEntityProvisioningStrategy(input.strategy);\n let attributes = await this.repository.findOneBy({\n name: input.attributes.name,\n realmId: input.attributes.realmId || null,\n clientId: input.attributes.clientId || null,\n });\n\n if (strategy.type === ProvisioningEntityStrategyType.ABSENT) {\n if (attributes) {\n await this.repository.remove(attributes);\n }\n return {\n ...input,\n attributes: attributes || input.attributes,\n };\n }\n\n if (attributes) {\n switch (strategy.type) {\n case ProvisioningEntityStrategyType.MERGE:\n attributes = this.repository.merge(\n attributes,\n strategy.attributes ?\n pickRecord(input.attributes, strategy.attributes) :\n input.attributes,\n );\n\n attributes = await this.repository.save(attributes);\n break;\n case ProvisioningEntityStrategyType.REPLACE:\n input.attributes.id = attributes.id;\n attributes = await this.repository.save(this.repository.create(input.attributes));\n break;\n }\n } else {\n attributes = await this.repository.save(this.repository.create(input.attributes));\n }\n\n if (!input.relations) {\n return {\n ...input,\n attributes,\n };\n }\n\n let globalPermissions = await this.permissionResolver.resolveGlobal(input.relations.globalPermissions);\n\n if (input.relations.globalPermissionsExclude && input.relations.globalPermissionsExclude.length > 0) {\n const excludeSet = new Set(input.relations.globalPermissionsExclude);\n globalPermissions = globalPermissions.filter((p) => !excludeSet.has(p.name));\n }\n\n const realmPermissions = attributes.realmId ?\n await this.permissionResolver.resolveRealm(input.relations.realmPermissions, attributes.realmId) :\n [];\n\n const permissions = [\n ...globalPermissions,\n ...realmPermissions,\n ];\n\n if (permissions.length > 0) {\n const defaultScope = input.relations.globalPermissionsRealmScope;\n\n if (defaultScope) {\n const overrides = this.buildRealmScopeOverrides(input);\n for (const permission of permissions) {\n const realmScope = overrides.get(permission.name) ?? defaultScope;\n await this.permissionJunction.synchronize(\n attributes,\n [permission],\n 'permissionId',\n 'permissionRealmId',\n { realmScope },\n );\n }\n } else {\n await this.permissionJunction.synchronize(\n attributes,\n permissions,\n 'permissionId',\n 'permissionRealmId',\n );\n }\n }\n\n return {\n ...input,\n attributes,\n };\n }\n\n private buildRealmScopeOverrides(input: RoleProvisioningEntity): Map<string, string> {\n const overrides = new Map<string, string>();\n if (input.relations?.globalPermissionsRealmScopeOverrides) {\n for (const [realmScope, permissionNames] of Object.entries(input.relations.globalPermissionsRealmScopeOverrides)) {\n if (!permissionNames) {\n continue;\n }\n for (const permName of permissionNames) {\n overrides.set(permName, realmScope);\n }\n }\n }\n return overrides;\n }\n}\n"],"mappings":";;;;;;;;;;;AAiBA,IAAaM,+BAAb,cAAkDH,6BAAAA;CACpCI;CAEAC;CAEAC;CAEV,YAAYC,KAA0C;EAClD,MAAK;EAEL,KAAKH,aAAaG,IAAIH;EACtB,KAAKC,qBAAqB,IAAIJ,2BAA2BM,IAAIC,oBAAoB;EACjF,KAAKF,qBAAqB,IAAIJ,iCAAiC;GAC3DE,YAAYG,IAAIE;GAChBC,UAAU;GACVC,eAAe;EACnB,CAAA;CACJ;CAEA,MAAMC,YAAYC,OAAgE;EAC9E,KAAKC,iBAAiBD,MAAME,UAAU;EAEtC,MAAMC,WAAWjB,oCAAoCc,MAAMG,QAAQ;EACnE,IAAID,aAAa,MAAM,KAAKX,WAAWa,UAAU;GAC7CC,MAAML,MAAME,WAAWG;GACvBC,SAASN,MAAME,WAAWI,WAAW;GACrCC,UAAUP,MAAME,WAAWK,YAAY;EAC3C,CAAA;EAEA,IAAIJ,SAASK,SAASvB,+BAA+BwB,QAAQ;GACzD,IAAIP,YACA,MAAM,KAAKX,WAAWmB,OAAOR,UAAAA;GAEjC,OAAO;IACH,GAAGF;IACHE,YAAYA,cAAcF,MAAME;GACpC;EACJ;EAEA,IAAIA,YACA,QAAQC,SAASK,MAAjB;GACI,KAAKvB,+BAA+B0B;IAChCT,aAAa,KAAKX,WAAWqB,MACzBV,YACAC,SAASD,aACLlB,WAAWgB,MAAME,YAAYC,SAASD,UAAU,IAChDF,MAAME,UAAU;IAGxBA,aAAa,MAAM,KAAKX,WAAWsB,KAAKX,UAAAA;IACxC;GACJ,KAAKjB,+BAA+B6B;IAChCd,MAAME,WAAWa,KAAKb,WAAWa;IACjCb,aAA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AIrC,MAAMiB,WAAWqB,sCACjB,KAAK,MAAM,CAACH,YAAYI,oBAAoBC,OAAOC,QAAQzC,MAAMiB,UAAUqB,oCAAoC,GAAG;GAC9G,IAAI,CAACC,iBACD;GAEJ,KAAK,MAAMG,YAAYH,iBACnBP,UAAUW,IAAID,UAAUP,UAAAA;EAEhC;EAEJ,OAAOH;CACX;AACJ"}
1
+ {"version":3,"file":"module.mjs","names":["pickRecord","ProvisioningEntityStrategyType","normalizeEntityProvisioningStrategy","BaseProvisioningSynchronizer","ProvisioningEntityResolver","ProvisioningJunctionSynchronizer","RoleProvisioningSynchronizer","repository","permissionResolver","permissionJunction","ctx","permissionRepository","rolePermissionRepository","ownerKey","ownerRealmKey","synchronize","input","canonicalizeName","attributes","strategy","findOneBy","name","realmId","clientId","type","ABSENT","remove","MERGE","merge","save","REPLACE","id","create","relations","globalPermissions","resolveGlobal","globalPermissionsExclude","length","excludeSet","Set","filter","p","has","realmPermissions","resolveRealm","permissions","defaultScope","globalPermissionsRealmScope","overrides","buildRealmScopeOverrides","permission","realmScope","get","Map","globalPermissionsRealmScopeOverrides","permissionNames","Object","entries","permName","set"],"sources":["../../../../../src/core/provisioning/synchronizer/role/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026-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 { pickRecord } from '@authup/kit';\nimport type { Permission, RolePermission } from '@authup/core-kit';\nimport type { IRoleRepository } from '../../../entities/index.ts';\nimport type { RoleProvisioningEntity } from '../../entities/role/index.ts';\nimport { ProvisioningEntityStrategyType, normalizeEntityProvisioningStrategy } from '../../strategy/index.ts';\nimport { BaseProvisioningSynchronizer } from '../base.ts';\nimport { ProvisioningEntityResolver } from '../entity-resolver.ts';\nimport { ProvisioningJunctionSynchronizer } from '../junction-synchronizer.ts';\nimport type { RoleProvisioningSynchronizerContext } from './types.ts';\n\nexport class RoleProvisioningSynchronizer extends BaseProvisioningSynchronizer<RoleProvisioningEntity> {\n protected repository : IRoleRepository;\n\n protected permissionResolver : ProvisioningEntityResolver<Permission>;\n\n protected permissionJunction: ProvisioningJunctionSynchronizer<RolePermission>;\n\n constructor(ctx: RoleProvisioningSynchronizerContext) {\n super();\n\n this.repository = ctx.repository;\n this.permissionResolver = new ProvisioningEntityResolver(ctx.permissionRepository);\n this.permissionJunction = new ProvisioningJunctionSynchronizer({\n repository: ctx.rolePermissionRepository,\n ownerKey: 'roleId',\n ownerRealmKey: 'roleRealmId',\n });\n }\n\n async synchronize(input: RoleProvisioningEntity): Promise<RoleProvisioningEntity> {\n this.canonicalizeName(input.attributes);\n\n const strategy = normalizeEntityProvisioningStrategy(input.strategy);\n let attributes = await this.repository.findOneBy({\n name: input.attributes.name,\n realmId: input.attributes.realmId || null,\n clientId: input.attributes.clientId || null,\n });\n\n if (strategy.type === ProvisioningEntityStrategyType.ABSENT) {\n if (attributes) {\n await this.repository.remove(attributes);\n }\n return {\n ...input,\n attributes: attributes || input.attributes,\n };\n }\n\n if (attributes) {\n switch (strategy.type) {\n case ProvisioningEntityStrategyType.MERGE:\n attributes = this.repository.merge(\n attributes,\n strategy.attributes ?\n pickRecord(input.attributes, strategy.attributes) :\n input.attributes,\n );\n\n attributes = await this.repository.save(attributes);\n break;\n case ProvisioningEntityStrategyType.REPLACE:\n input.attributes.id = attributes.id;\n attributes = await this.repository.save(this.repository.create(input.attributes));\n break;\n }\n } else {\n attributes = await this.repository.save(this.repository.create(input.attributes));\n }\n\n if (!input.relations) {\n return {\n ...input,\n attributes,\n };\n }\n\n let globalPermissions = await this.permissionResolver.resolveGlobal(input.relations.globalPermissions);\n\n if (input.relations.globalPermissionsExclude && input.relations.globalPermissionsExclude.length > 0) {\n const excludeSet = new Set(input.relations.globalPermissionsExclude);\n globalPermissions = globalPermissions.filter((p) => !excludeSet.has(p.name));\n }\n\n const realmPermissions = attributes.realmId ?\n await this.permissionResolver.resolveRealm(input.relations.realmPermissions, attributes.realmId) :\n [];\n\n const permissions = [\n ...globalPermissions,\n ...realmPermissions,\n ];\n\n if (permissions.length > 0) {\n const defaultScope = input.relations.globalPermissionsRealmScope;\n\n if (defaultScope) {\n const overrides = this.buildRealmScopeOverrides(input);\n for (const permission of permissions) {\n const realmScope = overrides.get(permission.name) ?? defaultScope;\n await this.permissionJunction.synchronize(\n attributes,\n [permission],\n 'permissionId',\n 'permissionRealmId',\n { realmScope },\n );\n }\n } else {\n await this.permissionJunction.synchronize(\n attributes,\n permissions,\n 'permissionId',\n 'permissionRealmId',\n );\n }\n }\n\n return {\n ...input,\n attributes,\n };\n }\n\n private buildRealmScopeOverrides(input: RoleProvisioningEntity): Map<string, string> {\n const overrides = new Map<string, string>();\n if (input.relations?.globalPermissionsRealmScopeOverrides) {\n for (const [realmScope, permissionNames] of Object.entries(input.relations.globalPermissionsRealmScopeOverrides)) {\n if (!permissionNames) {\n continue;\n }\n for (const permName of permissionNames) {\n overrides.set(permName, realmScope);\n }\n }\n }\n return overrides;\n }\n}\n"],"mappings":";;;;;;;;;;;AAiBA,IAAaM,+BAAb,cAAkDH,6BAAAA;CACpCI;CAEAC;CAEAC;CAEV,YAAYC,KAA0C;EAClD,MAAK;EAEL,KAAKH,aAAaG,IAAIH;EACtB,KAAKC,qBAAqB,IAAIJ,2BAA2BM,IAAIC,oBAAoB;EACjF,KAAKF,qBAAqB,IAAIJ,iCAAiC;GAC3DE,YAAYG,IAAIE;GAChBC,UAAU;GACVC,eAAe;EACnB,CAAA;CACJ;CAEA,MAAMC,YAAYC,OAAgE;EAC9E,KAAKC,iBAAiBD,MAAME,UAAU;EAEtC,MAAMC,WAAWjB,oCAAoCc,MAAMG,QAAQ;EACnE,IAAID,aAAa,MAAM,KAAKX,WAAWa,UAAU;GAC7CC,MAAML,MAAME,WAAWG;GACvBC,SAASN,MAAME,WAAWI,WAAW;GACrCC,UAAUP,MAAME,WAAWK,YAAY;EAC3C,CAAA;EAEA,IAAIJ,SAASK,SAASvB,+BAA+BwB,QAA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AME,YAAY,KAAKC,yBAAyBjC,KAAAA;IAChD,KAAK,MAAMkC,cAAcL,aAAa;KAClC,MAAMM,aAAaH,UAAUI,IAAIF,WAAW7B,IAAI,KAAKyB;KACrD,MAAM,KAAKrC,mBAAmBM,YAC1BG,YACA,CAACgC,UAAW,GACZ,gBACA,qBACA,EAAEC,WAAW,CAAA;IAErB;GACJ,OACI,MAAM,KAAK1C,mBAAmBM,YAC1BG,YACA2B,aACA,gBACA,mBAAA;EAGZ;EAEA,OAAO;GACH,GAAG7B;GACHE;EACJ;CACJ;CAEQ+B,yBAAyBjC,OAAoD;EACjF,MAAMgC,4BAAY,IAAIK,IAAAA;EACtB,IAAIrC,MAAMiB,WAAWqB,sCACjB,KAAK,MAAM,CAACH,YAAYI,oBAAoBC,OAAOC,QAAQzC,MAAMiB,UAAUqB,oCAAoC,GAAG;GAC9G,IAAI,CAACC,iBACD;GAEJ,KAAK,MAAMG,YAAYH,iBACnBP,UAAUW,IAAID,UAAUP,UAAAA;EAEhC;EAEJ,OAAOH;CACX;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"module.mjs","names":["buildUserFakeEmail","pickRecord","ProvisioningEntityStrategyType","normalizeEntityProvisioningStrategy","BaseProvisioningSynchronizer","ProvisioningEntityResolver","ProvisioningJunctionSynchronizer","UserProvisioningSynchronizer","userRepository","clientRepository","permissionResolver","roleResolver","permissionJunction","roleJunction","ctx","permissionRepository","roleRepository","repository","userPermissionRepository","ownerKey","ownerRealmKey","userRoleRepository","synchronize","input","canonicalizeName","attributes","strategy","findOneBy","name","realmId","type","ABSENT","remove","MERGE","includes","email","merge","save","REPLACE","undefined","id","create","permissions","resolveGlobal","relations","globalPermissions","resolveRealm","realmPermissions","clientPermissions","clientKeys","Object","keys","clientKey","client","entities","resolveClient","push","length","roles","globalRoles","realmRoles","clientRoles"],"sources":["../../../../../src/core/provisioning/synchronizer/user/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026-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 type {\n Permission, \n Role, \n UserPermission, \n UserRole,\n} from '@authup/core-kit';\nimport { buildUserFakeEmail } from '@authup/core-kit';\nimport { pickRecord } from '@authup/kit';\nimport type {\n IClientRepository,\n IUserRepository,\n} from '../../../entities/index.ts';\nimport type { UserProvisioningEntity } from '../../entities/user/index.ts';\nimport { ProvisioningEntityStrategyType, normalizeEntityProvisioningStrategy } from '../../strategy/index.ts';\nimport { BaseProvisioningSynchronizer } from '../base.ts';\nimport { ProvisioningEntityResolver } from '../entity-resolver.ts';\nimport { ProvisioningJunctionSynchronizer } from '../junction-synchronizer.ts';\nimport type { UserProvisioningSynchronizerContext } from './types.ts';\n\nexport class UserProvisioningSynchronizer extends BaseProvisioningSynchronizer<UserProvisioningEntity> {\n protected userRepository: IUserRepository;\n\n protected clientRepository: IClientRepository;\n\n protected permissionResolver: ProvisioningEntityResolver<Permission>;\n\n protected roleResolver: ProvisioningEntityResolver<Role>;\n\n protected permissionJunction: ProvisioningJunctionSynchronizer<UserPermission>;\n\n protected roleJunction: ProvisioningJunctionSynchronizer<UserRole>;\n\n constructor(ctx: UserProvisioningSynchronizerContext) {\n super();\n\n this.userRepository = ctx.userRepository;\n this.clientRepository = ctx.clientRepository;\n\n this.permissionResolver = new ProvisioningEntityResolver(ctx.permissionRepository);\n this.roleResolver = new ProvisioningEntityResolver(ctx.roleRepository);\n\n this.permissionJunction = new ProvisioningJunctionSynchronizer({\n repository: ctx.userPermissionRepository,\n ownerKey: 'userId',\n ownerRealmKey: 'userRealmId',\n });\n this.roleJunction = new ProvisioningJunctionSynchronizer({\n repository: ctx.userRoleRepository,\n ownerKey: 'userId',\n ownerRealmKey: 'userRealmId',\n });\n }\n\n async synchronize(input: UserProvisioningEntity): Promise<UserProvisioningEntity> {\n this.canonicalizeName(input.attributes);\n\n const strategy = normalizeEntityProvisioningStrategy(input.strategy);\n\n let attributes = await this.userRepository.findOneBy({\n name: input.attributes.name,\n realmId: input.attributes.realmId || null,\n });\n\n if (strategy.type === ProvisioningEntityStrategyType.ABSENT) {\n if (attributes) {\n await this.userRepository.remove(attributes);\n }\n return {\n ...input,\n attributes: attributes || input.attributes, \n };\n }\n\n if (attributes) {\n switch (strategy.type) {\n case ProvisioningEntityStrategyType.MERGE:\n if (\n strategy.attributes &&\n strategy.attributes.includes('email')\n ) {\n input.attributes.email = input.attributes.email ||\n attributes.email ||\n buildUserFakeEmail(input.attributes.name || attributes.name);\n }\n\n attributes = this.userRepository.merge(\n attributes,\n strategy.attributes ?\n pickRecord(input.attributes, strategy.attributes) :\n input.attributes,\n );\n\n attributes = await this.userRepository.save(attributes);\n break;\n case ProvisioningEntityStrategyType.REPLACE:\n input.attributes.email = input.attributes.email ||\n attributes.email ||\n (input.attributes.name ? buildUserFakeEmail(input.attributes.name) : undefined);\n\n input.attributes.id = attributes.id;\n attributes = await this.userRepository.save(this.userRepository.create(input.attributes));\n break;\n }\n } else {\n if (!input.attributes.email && input.attributes.name) {\n input.attributes.email = buildUserFakeEmail(input.attributes.name);\n }\n\n attributes = await this.userRepository.save(this.userRepository.create(input.attributes));\n }\n\n // Permissions (Global, Realm & Client)\n const permissions : Permission[] = [\n ...await this.permissionResolver.resolveGlobal(\n input.relations && input.relations.globalPermissions,\n ),\n ...(attributes.realmId ?\n await this.permissionResolver.resolveRealm(\n input.relations && input.relations.realmPermissions,\n attributes.realmId,\n ) :\n []),\n ];\n\n if (input.relations && input.relations.clientPermissions) {\n const clientKeys = Object.keys(input.relations.clientPermissions);\n for (const clientKey of clientKeys) {\n const client = await this.clientRepository.findOneBy({\n name: clientKey,\n realmId: attributes.realmId,\n });\n\n if (client) {\n const entities = await this.permissionResolver.resolveClient(\n input.relations.clientPermissions[clientKey],\n attributes.realmId,\n client.id,\n );\n permissions.push(...entities);\n }\n }\n }\n\n if (permissions.length > 0) {\n await this.permissionJunction.synchronize(\n attributes,\n permissions,\n 'permissionId',\n 'permissionRealmId',\n );\n }\n\n // Roles (Global, Realm & Client)\n const roles : Role[] = [\n ...await this.roleResolver.resolveGlobal(\n input.relations && input.relations.globalRoles,\n ),\n ...(attributes.realmId ?\n await this.roleResolver.resolveRealm(\n input.relations && input.relations.realmRoles,\n attributes.realmId,\n ) :\n []),\n ];\n\n if (input.relations && input.relations.clientRoles) {\n const clientKeys = Object.keys(input.relations.clientRoles);\n for (const clientKey of clientKeys) {\n const client = await this.clientRepository.findOneBy({\n name: clientKey,\n realmId: attributes.realmId,\n });\n\n if (client) {\n const entities = await this.roleResolver.resolveClient(\n input.relations.clientRoles[clientKey],\n attributes.realmId,\n client.id,\n );\n roles.push(...entities);\n }\n }\n }\n\n if (roles.length > 0) {\n await this.roleJunction.synchronize(\n attributes,\n roles,\n 'roleId',\n 'roleRealmId',\n );\n }\n\n return {\n ...input,\n attributes,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,IAAaO,+BAAb,cAAkDH,6BAAAA;CACpCI;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEV,YAAYC,KAA0C;EAClD,MAAK;EAEL,KAAKN,iBAAiBM,IAAIN;EAC1B,KAAKC,mBAAmBK,IAAIL;EAE5B,KAAKC,qBAAqB,IAAIL,2BAA2BS,IAAIC,oBAAoB;EACjF,KAAKJ,eAAe,IAAIN,2BAA2BS,IAAIE,cAAc;EAErE,KAAKJ,qBAAqB,IAAIN,iCAAiC;GAC3DW,YAAYH,IAAII;GAChBC,UAAU;GACVC,eAAe;EACnB,CAAA;EACA,KAAKP,eAAe,IAAIP,iCAAiC;GACrDW,YAAYH,IAAIO;GAChBF,UAAU;GACVC,eAAe;EACnB,CAAA;CACJ;CAEA,MAAME,YAAYC,OAAgE;EAC9E,KAAKC,iBAAiBD,MAAME,UAAU;EAEtC,MAAMC,WAAWvB,oCAAoCoB,MAAMG,QAAQ;EAEnE,IAAID,aAAa,MAAM,KAAKjB,eAAemB,UAAU;GACjDC,MAAML,MAAME,WAAWG;GACvBC,SAASN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E;KAEbkB,MAAMF,KAAI,GAAIF,QAAAA;IAClB;GACJ;EACJ;EAEA,IAAII,MAAMD,SAAS,GACf,MAAM,KAAK5C,aAAaS,YACpBG,YACAiC,OACA,UACA,aAAA;EAIR,OAAO;GACH,GAAGnC;GACHE;EACJ;CACJ;AACJ"}
1
+ {"version":3,"file":"module.mjs","names":["buildUserFakeEmail","pickRecord","ProvisioningEntityStrategyType","normalizeEntityProvisioningStrategy","BaseProvisioningSynchronizer","ProvisioningEntityResolver","ProvisioningJunctionSynchronizer","UserProvisioningSynchronizer","userRepository","clientRepository","permissionResolver","roleResolver","permissionJunction","roleJunction","ctx","permissionRepository","roleRepository","repository","userPermissionRepository","ownerKey","ownerRealmKey","userRoleRepository","synchronize","input","canonicalizeName","attributes","strategy","findOneBy","name","realmId","type","ABSENT","remove","MERGE","includes","email","merge","save","REPLACE","undefined","id","create","permissions","resolveGlobal","relations","globalPermissions","resolveRealm","realmPermissions","clientPermissions","clientKeys","Object","keys","clientKey","client","entities","resolveClient","push","length","roles","globalRoles","realmRoles","clientRoles"],"sources":["../../../../../src/core/provisioning/synchronizer/user/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026-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 type {\n Permission, \n Role, \n UserPermission, \n UserRole,\n} from '@authup/core-kit';\nimport { buildUserFakeEmail } from '@authup/core-kit';\nimport { pickRecord } from '@authup/kit';\nimport type {\n IClientRepository,\n IUserRepository,\n} from '../../../entities/index.ts';\nimport type { UserProvisioningEntity } from '../../entities/user/index.ts';\nimport { ProvisioningEntityStrategyType, normalizeEntityProvisioningStrategy } from '../../strategy/index.ts';\nimport { BaseProvisioningSynchronizer } from '../base.ts';\nimport { ProvisioningEntityResolver } from '../entity-resolver.ts';\nimport { ProvisioningJunctionSynchronizer } from '../junction-synchronizer.ts';\nimport type { UserProvisioningSynchronizerContext } from './types.ts';\n\nexport class UserProvisioningSynchronizer extends BaseProvisioningSynchronizer<UserProvisioningEntity> {\n protected userRepository: IUserRepository;\n\n protected clientRepository: IClientRepository;\n\n protected permissionResolver: ProvisioningEntityResolver<Permission>;\n\n protected roleResolver: ProvisioningEntityResolver<Role>;\n\n protected permissionJunction: ProvisioningJunctionSynchronizer<UserPermission>;\n\n protected roleJunction: ProvisioningJunctionSynchronizer<UserRole>;\n\n constructor(ctx: UserProvisioningSynchronizerContext) {\n super();\n\n this.userRepository = ctx.userRepository;\n this.clientRepository = ctx.clientRepository;\n\n this.permissionResolver = new ProvisioningEntityResolver(ctx.permissionRepository);\n this.roleResolver = new ProvisioningEntityResolver(ctx.roleRepository);\n\n this.permissionJunction = new ProvisioningJunctionSynchronizer({\n repository: ctx.userPermissionRepository,\n ownerKey: 'userId',\n ownerRealmKey: 'userRealmId',\n });\n this.roleJunction = new ProvisioningJunctionSynchronizer({\n repository: ctx.userRoleRepository,\n ownerKey: 'userId',\n ownerRealmKey: 'userRealmId',\n });\n }\n\n async synchronize(input: UserProvisioningEntity): Promise<UserProvisioningEntity> {\n this.canonicalizeName(input.attributes);\n\n const strategy = normalizeEntityProvisioningStrategy(input.strategy);\n\n let attributes = await this.userRepository.findOneBy({\n name: input.attributes.name,\n realmId: input.attributes.realmId || null,\n });\n\n if (strategy.type === ProvisioningEntityStrategyType.ABSENT) {\n if (attributes) {\n await this.userRepository.remove(attributes);\n }\n return {\n ...input,\n attributes: attributes || input.attributes, \n };\n }\n\n if (attributes) {\n switch (strategy.type) {\n case ProvisioningEntityStrategyType.MERGE:\n if (\n strategy.attributes &&\n strategy.attributes.includes('email')\n ) {\n input.attributes.email = input.attributes.email ||\n attributes.email ||\n buildUserFakeEmail(input.attributes.name || attributes.name);\n }\n\n attributes = this.userRepository.merge(\n attributes,\n strategy.attributes ?\n pickRecord(input.attributes, strategy.attributes) :\n input.attributes,\n );\n\n attributes = await this.userRepository.save(attributes);\n break;\n case ProvisioningEntityStrategyType.REPLACE:\n input.attributes.email = input.attributes.email ||\n attributes.email ||\n (input.attributes.name ? buildUserFakeEmail(input.attributes.name) : undefined);\n\n input.attributes.id = attributes.id;\n attributes = await this.userRepository.save(this.userRepository.create(input.attributes));\n break;\n }\n } else {\n if (!input.attributes.email && input.attributes.name) {\n input.attributes.email = buildUserFakeEmail(input.attributes.name);\n }\n\n attributes = await this.userRepository.save(this.userRepository.create(input.attributes));\n }\n\n // Permissions (Global, Realm & Client)\n const permissions : Permission[] = [\n ...await this.permissionResolver.resolveGlobal(\n input.relations && input.relations.globalPermissions,\n ),\n ...(attributes.realmId ?\n await this.permissionResolver.resolveRealm(\n input.relations && input.relations.realmPermissions,\n attributes.realmId,\n ) :\n []),\n ];\n\n if (input.relations && input.relations.clientPermissions) {\n const clientKeys = Object.keys(input.relations.clientPermissions);\n for (const clientKey of clientKeys) {\n const client = await this.clientRepository.findOneBy({\n name: clientKey,\n realmId: attributes.realmId,\n });\n\n if (client) {\n const entities = await this.permissionResolver.resolveClient(\n input.relations.clientPermissions[clientKey],\n attributes.realmId,\n client.id,\n );\n permissions.push(...entities);\n }\n }\n }\n\n if (permissions.length > 0) {\n await this.permissionJunction.synchronize(\n attributes,\n permissions,\n 'permissionId',\n 'permissionRealmId',\n );\n }\n\n // Roles (Global, Realm & Client)\n const roles : Role[] = [\n ...await this.roleResolver.resolveGlobal(\n input.relations && input.relations.globalRoles,\n ),\n ...(attributes.realmId ?\n await this.roleResolver.resolveRealm(\n input.relations && input.relations.realmRoles,\n attributes.realmId,\n ) :\n []),\n ];\n\n if (input.relations && input.relations.clientRoles) {\n const clientKeys = Object.keys(input.relations.clientRoles);\n for (const clientKey of clientKeys) {\n const client = await this.clientRepository.findOneBy({\n name: clientKey,\n realmId: attributes.realmId,\n });\n\n if (client) {\n const entities = await this.roleResolver.resolveClient(\n input.relations.clientRoles[clientKey],\n attributes.realmId,\n client.id,\n );\n roles.push(...entities);\n }\n }\n }\n\n if (roles.length > 0) {\n await this.roleJunction.synchronize(\n attributes,\n roles,\n 'ro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AE;KAEbE,YAAYc,KAAI,GAAIF,QAAAA;IACxB;GACJ;EACJ;EAEA,IAAIZ,YAAYe,SAAS,GACrB,MAAM,KAAK7C,mBAAmBU,YAC1BG,YACAiB,aACA,gBACA,mBAAA;EAKR,MAAMgB,QAAiB,CAChB,GAAA,MAAM,KAAK/C,aAAagC,cACvBpB,MAAMqB,aAAarB,MAAMqB,UAAUe,WAAW,GAE9ClC,GAAAA,WAAWI,UACX,MAAM,KAAKlB,aAAamC,aACpBvB,MAAMqB,aAAarB,MAAMqB,UAAUgB,YACnCnC,WAAWI,OAAO,IAEtB,CAAA,CACP;EAED,IAAIN,MAAMqB,aAAarB,MAAMqB,UAAUiB,aAAa;GAChD,MAAMZ,aAAaC,OAAOC,KAAK5B,MAAMqB,UAAUiB,WAAW;GAC1D,KAAK,MAAMT,aAAaH,YAAY;IAChC,MAAMI,SAAS,MAAM,KAAK5C,iBAAiBkB,UAAU;KACjDC,MAAMwB;KACNvB,SAASJ,WAAWI;IACxB,CAAA;IAEA,IAAIwB,QAAQ;KACR,MAAMC,WAAW,MAAM,KAAK3C,aAAa4C,cACrChC,MAAMqB,UAAUiB,YAAYT,YAC5B3B,WAAWI,SACXwB,OAAOb,EAAE;KAEbkB,MAAMF,KAAI,GAAIF,QAAAA;IAClB;GACJ;EACJ;EAEA,IAAII,MAAMD,SAAS,GACf,MAAM,KAAK5C,aAAaS,YACpBG,YACAiC,OACA,UACA,aAAA;EAIR,OAAO;GACH,GAAGnC;GACHE;EACJ;CACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"module.mjs","names":["createURLCodec","Query","SchemaRegistry","isObject","clientSchema","clientPermissionSchema","clientRoleSchema","clientScopeSchema","consentSchema","eventSchema","identityProviderSchema","identityProviderRoleMappingSchema","keySchema","permissionSchema","permissionPolicySchema","policySchema","realmSchema","roleSchema","roleAttributeSchema","rolePermissionSchema","scopeSchema","sessionSchema","trustAnchorSchema","userSchema","userAttributeSchema","userAuthenticatorSchema","userPermissionSchema","userRoleSchema","schemaRegistry","schemas","schema","add","queryCodec","decodeQuery","input","options","normalized","parsed","decodeAsync","parameters","context","actor","appendQueryConditions","query","conditions","fields","filters","and","relations","pagination","sorts"],"sources":["../../../src/core/query/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 { createURLCodec } from '@rapiq/codec-url';\nimport type {\n ICondition, \n IQuery, \n ObjectLiteral, \n Schema,\n} from '@rapiq/core';\nimport { Query, SchemaRegistry, isObject } from '@rapiq/core';\nimport { clientSchema } from '../entities/client/schema.ts';\nimport { clientPermissionSchema } from '../entities/client-permission/schema.ts';\nimport { clientRoleSchema } from '../entities/client-role/schema.ts';\nimport { clientScopeSchema } from '../entities/client-scope/schema.ts';\nimport { consentSchema } from '../entities/consent/schema.ts';\nimport { eventSchema } from '../entities/event/schema.ts';\nimport { identityProviderSchema } from '../entities/identity-provider/schema.ts';\nimport { identityProviderRoleMappingSchema } from '../entities/identity-provider-role-mapping/schema.ts';\nimport { keySchema } from '../entities/key/schema.ts';\nimport { permissionSchema } from '../entities/permission/schema.ts';\nimport { permissionPolicySchema } from '../entities/permission-policy/schema.ts';\nimport { policySchema } from '../entities/policy/schema.ts';\nimport { realmSchema } from '../entities/realm/schema.ts';\nimport { roleSchema } from '../entities/role/schema.ts';\nimport { roleAttributeSchema } from '../entities/role-attribute/schema.ts';\nimport { rolePermissionSchema } from '../entities/role-permission/schema.ts';\nimport { scopeSchema } from '../entities/scope/schema.ts';\nimport { sessionSchema } from '../entities/session/schema.ts';\nimport { trustAnchorSchema } from '../entities/trust-anchor/schema.ts';\nimport { userSchema } from '../entities/user/schema.ts';\nimport { userAttributeSchema } from '../entities/user-attribute/schema.ts';\nimport { userAuthenticatorSchema } from '../entities/user-authenticator/schema.ts';\nimport { userPermissionSchema } from '../entities/user-permission/schema.ts';\nimport { userRoleSchema } from '../entities/user-role/schema.ts';\nimport type { DecodeQueryOptions, QueryDecodeContext } from './types.ts';\n\n/**\n * Registry of every entity schema — the server-side allow-list layer.\n * Relation traversal (e.g. a `realm.name` filter) resolves through the\n * `schemaMapping` of the owning schema into the related schema's own\n * allow-lists.\n *\n * The registry deliberately lives in core (persistence-agnostic): the\n * schemas are security policy over the domain types, and services\n * consume them to decode wire queries into the rapiq IR. A repository\n * layer MAY extend the registry with additional, storage-derived\n * schemas (e.g. `@rapiq/typeorm`'s `defineSchemaRegistryWithDataSource`\n * with the `registry` option — already-registered schemas take\n * precedence), but the allow-lists themselves stay explicit and are\n * never auto-derived from entity metadata.\n */\nexport const schemaRegistry = new SchemaRegistry();\n\nconst schemas : Schema<any>[] = [\n clientSchema,\n clientPermissionSchema,\n clientRoleSchema,\n clientScopeSchema,\n consentSchema,\n eventSchema,\n identityProviderSchema,\n identityProviderRoleMappingSchema,\n keySchema,\n permissionSchema,\n permissionPolicySchema,\n policySchema,\n realmSchema,\n roleSchema,\n roleAttributeSchema,\n rolePermissionSchema,\n scopeSchema,\n sessionSchema,\n trustAnchorSchema,\n userSchema,\n userAttributeSchema,\n userAuthenticatorSchema,\n userPermissionSchema,\n userRoleSchema,\n];\n\nfor (const schema of schemas) {\n schemaRegistry.add(schema);\n}\n\n/**\n * URL transport codec bound to the schema registry: decodes both the\n * v2 expression dialect (stamped or detected) and legacy v1 bracket\n * payloads, so pre-v2 clients keep working.\n */\nexport const queryCodec = createURLCodec(schemaRegistry);\n\n/**\n * Decode a raw wire query (routup `useRequestQuery` output or a raw\n * query string) against a registered schema into the rapiq IR. The\n * schema's allow-lists, defaults and pagination bounds are applied\n * here — downstream consumers (repository adapters) only execute the\n * returned query.\n *\n * Async because the schema validate hooks are: the relations read\n * gate (`createRelationsReadGate`) awaits the actor's permission\n * pre-gate per include, and rapiq refuses async validators on the\n * synchronous decode path. Pass the acting identity via\n * `options.actor` on every request-driven decode (authenticated or\n * anonymous — the HTTP adapter always builds one); a decode without\n * an actor is a system call and runs unrestricted.\n */\nexport async function decodeQuery<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: DecodeQueryOptions<RECORD>,\n) : Promise<Query> {\n const normalized = isObject(input) || typeof input === 'string' ? input : {};\n\n const parsed = await queryCodec.decodeAsync(normalized, {\n // Schema<RECORD> is invariant; the codec's non-generic options\n // accept Schema<ObjectLiteral>, so collapse the variance here.\n schema: options.schema as Schema<any> | string,\n parameters: options.parameters,\n context: { actor: options.actor } satisfies QueryDecodeContext,\n });\n\n return parsed ?? new Query({});\n}\n\n/**\n * Append server-derived conditions (a route realm, an owner scope, ...)\n * onto a decoded query by AND-wrapping its filter tree. The wrap makes\n * the appended scope non-displaceable: unlike a filters merge (per-field\n * replace, flat-root-AND restriction), a client-sent condition on the\n * same field intersects with the scope instead of replacing it, and\n * compound client trees (`or(...)`) are preserved as-is. Same guarantee\n * class as a mandatory `andWhere` at the repository — expressed once in\n * the IR. Appended conditions do not pass through `decodeQuery`, so the\n * schema allow-lists do not constrain them (server-derived context).\n *\n * Immutable: returns a new `Query` whose filters node is the\n * AND-wrapped successor (`IFilters.and`); every other parameter node is\n * carried over **by reference**, so the input query stays untouched and\n * nothing is copied. The node enumeration mirrors rapiq's\n * `QueryContext` — keep it in sync when the IR gains a parameter.\n */\nexport function appendQueryConditions(query: IQuery, ...conditions: ICondition[]) : Query {\n return new Query({\n fields: query.fields,\n filters: query.filters.and(...conditions),\n relations: query.relations,\n pagination: query.pagination,\n sorts: query.sorts,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDA,MAAa4B,iBAAiB,IAAI1B,eAAAA;AAElC,MAAM2B,UAA0B;CAC5BzB;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;;AAGJ,KAAK,MAAMG,UAAUD,SACjBD,eAAeG,IAAID,MAAAA;;;;;GAQvB,MAAaE,aAAahC,eAAe4B,cAAAA;;;;;;;;;;;;;;;GAiBzC,eAAsBK,YAClBC,OACAC,SAAmC;CAEnC,MAAMC,aAAajC,SAAS+B,KAAAA,KAAU,OAAOA,UAAU,WAAWA,QAAQ,CAAC;CAU3E,OAAOG,MARcL,WAAWM,YAAYF,YAAY;EAGpDN,QAAQK,QAAQL;EAChBS,YAAYJ,QAAQI;EACpBC,SAAS,EAAEC,OAAON,QAAQM,MAAM;CACpC,CAAA,KAEiB,IAAIxC,MAAM,CAAC,CAAA;AAChC;;;;;;;;;;;;;;;;;GAmBA,SAAgByC,sBAAsBC,OAAe,GAAGC,YAAwB;CAC5E,OAAO,IAAI3C,MAAM;EACb4C,QAAQF,MAAME;EACdC,SAASH,MAAMG,QAAQC,IAAG,GAAIH,UAAAA;EAC9BI,WAAWL,MAAMK;EACjBC,YAAYN,MAAMM;EAClBC,OAAOP,MAAMO;CACjB,CAAA;AACJ"}
1
+ {"version":3,"file":"module.mjs","names":["createURLCodec","Query","SchemaRegistry","isObject","clientSchema","clientPermissionSchema","clientRoleSchema","clientScopeSchema","consentSchema","eventSchema","identityProviderSchema","identityProviderRoleMappingSchema","keySchema","permissionSchema","permissionPolicySchema","policySchema","realmSchema","roleSchema","roleAttributeSchema","rolePermissionSchema","scopeSchema","sessionSchema","trustAnchorSchema","userSchema","userAttributeSchema","userAuthenticatorSchema","userPermissionSchema","userRoleSchema","schemaRegistry","schemas","schema","add","queryCodec","decodeQuery","input","options","normalized","parsed","decodeAsync","parameters","context","actor","appendQueryConditions","query","conditions","fields","filters","and","relations","pagination","sorts"],"sources":["../../../src/core/query/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 { createURLCodec } from '@rapiq/codec-url';\nimport type {\n ICondition, \n IQuery, \n ObjectLiteral, \n Schema,\n} from '@rapiq/core';\nimport { Query, SchemaRegistry, isObject } from '@rapiq/core';\nimport { clientSchema } from '../entities/client/schema.ts';\nimport { clientPermissionSchema } from '../entities/client-permission/schema.ts';\nimport { clientRoleSchema } from '../entities/client-role/schema.ts';\nimport { clientScopeSchema } from '../entities/client-scope/schema.ts';\nimport { consentSchema } from '../entities/consent/schema.ts';\nimport { eventSchema } from '../entities/event/schema.ts';\nimport { identityProviderSchema } from '../entities/identity-provider/schema.ts';\nimport { identityProviderRoleMappingSchema } from '../entities/identity-provider-role-mapping/schema.ts';\nimport { keySchema } from '../entities/key/schema.ts';\nimport { permissionSchema } from '../entities/permission/schema.ts';\nimport { permissionPolicySchema } from '../entities/permission-policy/schema.ts';\nimport { policySchema } from '../entities/policy/schema.ts';\nimport { realmSchema } from '../entities/realm/schema.ts';\nimport { roleSchema } from '../entities/role/schema.ts';\nimport { roleAttributeSchema } from '../entities/role-attribute/schema.ts';\nimport { rolePermissionSchema } from '../entities/role-permission/schema.ts';\nimport { scopeSchema } from '../entities/scope/schema.ts';\nimport { sessionSchema } from '../entities/session/schema.ts';\nimport { trustAnchorSchema } from '../entities/trust-anchor/schema.ts';\nimport { userSchema } from '../entities/user/schema.ts';\nimport { userAttributeSchema } from '../entities/user-attribute/schema.ts';\nimport { userAuthenticatorSchema } from '../entities/user-authenticator/schema.ts';\nimport { userPermissionSchema } from '../entities/user-permission/schema.ts';\nimport { userRoleSchema } from '../entities/user-role/schema.ts';\nimport type { DecodeQueryOptions, QueryDecodeContext } from './types.ts';\n\n/**\n * Registry of every entity schema — the server-side allow-list layer.\n * Relation traversal (e.g. a `realm.name` filter) resolves through the\n * `schemaMapping` of the owning schema into the related schema's own\n * allow-lists.\n *\n * The registry deliberately lives in core (persistence-agnostic): the\n * schemas are security policy over the domain types, and services\n * consume them to decode wire queries into the rapiq IR. A repository\n * layer MAY extend the registry with additional, storage-derived\n * schemas (e.g. `@rapiq/typeorm`'s `defineSchemaRegistryWithDataSource`\n * with the `registry` option — already-registered schemas take\n * precedence), but the allow-lists themselves stay explicit and are\n * never auto-derived from entity metadata.\n */\nexport const schemaRegistry = new SchemaRegistry();\n\nconst schemas : Schema<any>[] = [\n clientSchema,\n clientPermissionSchema,\n clientRoleSchema,\n clientScopeSchema,\n consentSchema,\n eventSchema,\n identityProviderSchema,\n identityProviderRoleMappingSchema,\n keySchema,\n permissionSchema,\n permissionPolicySchema,\n policySchema,\n realmSchema,\n roleSchema,\n roleAttributeSchema,\n rolePermissionSchema,\n scopeSchema,\n sessionSchema,\n trustAnchorSchema,\n userSchema,\n userAttributeSchema,\n userAuthenticatorSchema,\n userPermissionSchema,\n userRoleSchema,\n];\n\nfor (const schema of schemas) {\n schemaRegistry.add(schema);\n}\n\n/**\n * URL transport codec bound to the schema registry: decodes both the\n * v2 expression dialect (stamped or detected) and legacy v1 bracket\n * payloads, so pre-v2 clients keep working.\n */\nexport const queryCodec = createURLCodec(schemaRegistry);\n\n/**\n * Decode a raw wire query (routup `useRequestQuery` output or a raw\n * query string) against a registered schema into the rapiq IR. The\n * schema's allow-lists, defaults and pagination bounds are applied\n * here — downstream consumers (repository adapters) only execute the\n * returned query.\n *\n * Async because the schema validate hooks are: the relations read\n * gate (`createRelationsReadGate`) awaits the actor's permission\n * pre-gate per include, and rapiq refuses async validators on the\n * synchronous decode path. Pass the acting identity via\n * `options.actor` on every request-driven decode (authenticated or\n * anonymous — the HTTP adapter always builds one); a decode without\n * an actor is a system call and runs unrestricted.\n */\nexport async function decodeQuery<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: DecodeQueryOptions<RECORD>,\n) : Promise<Query> {\n const normalized = isObject(input) || typeof input === 'string' ? input : {};\n\n const parsed = await queryCodec.decodeAsync(normalized, {\n // Schema<RECORD> is invariant; the codec's non-generic options\n // accept Schema<ObjectLiteral>, so collapse the variance here.\n schema: options.schema as Schema<any> | string,\n parameters: options.parameters,\n context: { actor: options.actor } satisfies QueryDecodeContext,\n });\n\n return parsed ?? new Query({});\n}\n\n/**\n * Append server-derived conditions (a route realm, an owner scope, ...)\n * onto a decoded query by AND-wrapping its filter tree. The wrap makes\n * the appended scope non-displaceable: unlike a filters merge (per-field\n * replace, flat-root-AND restriction), a client-sent condition on the\n * same field intersects with the scope instead of replacing it, and\n * compound client trees (`or(...)`) are preserved as-is. Same guarantee\n * class as a mandatory `andWhere` at the repository — expressed once in\n * the IR. Appended conditions do not pass through `decodeQuery`, so the\n * schema allow-lists do not constrain them (server-derived context).\n *\n * Immutable: returns a new `Query` whose filters node is the\n * AND-wrapped successor (`IFilters.and`); every other parameter node is\n * carried over **by reference**, so the input query stays untouched and\n * nothing is copied. The node enumeration mirrors rapiq's\n * `QueryContext` — keep it in sync when the IR gains a parameter.\n */\nexport function appendQueryConditions(query: IQuery, ...conditions: ICondition[]) : Query {\n return new Query({\n fields: query.fields,\n filters: query.filters.and(...conditions),\n relations: query.relations,\n pagination: query.pagination,\n sorts: query.sorts,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDA,MAAa4B,iBAAiB,IAAI1B,eAAAA;AAElC,MAAM2B,UAA0B;CAC5BzB;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;AACH;AAED,KAAK,MAAMG,UAAUD,SACjBD,eAAeG,IAAID,MAAAA;;;;;GAQvB,MAAaE,aAAahC,eAAe4B,cAAAA;;;;;;;;;;;;;;;GAiBzC,eAAsBK,YAClBC,OACAC,SAAmC;CAEnC,MAAMC,aAAajC,SAAS+B,KAAAA,KAAU,OAAOA,UAAU,WAAWA,QAAQ,CAAC;CAU3E,OAAOG,MARcL,WAAWM,YAAYF,YAAY;EAGpDN,QAAQK,QAAQL;EAChBS,YAAYJ,QAAQI;EACpBC,SAAS,EAAEC,OAAON,QAAQM,MAAM;CACpC,CAAA,KAEiB,IAAIxC,MAAM,CAAC,CAAA;AAChC;;;;;;;;;;;;;;;;;GAmBA,SAAgByC,sBAAsBC,OAAe,GAAGC,YAAwB;CAC5E,OAAO,IAAI3C,MAAM;EACb4C,QAAQF,MAAME;EACdC,SAASH,MAAMG,QAAQC,IAAG,GAAIH,UAAAA;EAC9BI,WAAWL,MAAMK;EACjBC,YAAYN,MAAMM;EAClBC,OAAOP,MAAMO;CACjB,CAAA;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"relations.mjs","names":["EntityType","PermissionName","RELATION_TARGET_READ_GATES","CLIENT","CLIENT_READ","CLIENT_UPDATE","CLIENT_DELETE","USER","USER_READ","USER_UPDATE","USER_DELETE","ROLE","ROLE_READ","ROLE_UPDATE","ROLE_DELETE","SCOPE","SCOPE_READ","SCOPE_UPDATE","SCOPE_DELETE","PERMISSION","PERMISSION_READ","PERMISSION_UPDATE","PERMISSION_DELETE","POLICY","createRelationsReadGate","mapping","name","context","target","permissions","actor","permissionEvaluator","preEvaluateOneOf"],"sources":["../../../src/core/query/relations.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 type { KeyValidator } from '@rapiq/core';\nimport { EntityType, PermissionName } from '@authup/core-kit';\nimport type { QueryDecodeContext } from './types.ts';\n\n/**\n * Read gate per include target: the permission disjunction an actor\n * must hold (data-availability-derived pre-gate, issue #3290) for the\n * target entity type to be joinable via `include=` OR reachable via a\n * dotted `filter`/`sort`/`field` key. Mirrors each target service's own\n * `getMany` read pre-gate, so \"may list the entity type\" and \"may join\n * it onto another list\" stay one predicate.\n * Policies are deliberately gated under the PERMISSION family — they\n * are managed under the permission domain.\n *\n * Absent entries are ungated: `realm` (the realm list is public — the\n * login realm chooser reads it anonymously) and `identityProvider`\n * (the anonymous login page lists providers; its schema field\n * allow-list is the safe-DTO layer).\n */\nconst RELATION_TARGET_READ_GATES : Partial<Record<`${EntityType}`, PermissionName[]>> = {\n [EntityType.CLIENT]: [\n PermissionName.CLIENT_READ,\n PermissionName.CLIENT_UPDATE,\n PermissionName.CLIENT_DELETE,\n ],\n [EntityType.USER]: [\n PermissionName.USER_READ,\n PermissionName.USER_UPDATE,\n PermissionName.USER_DELETE,\n ],\n [EntityType.ROLE]: [\n PermissionName.ROLE_READ,\n PermissionName.ROLE_UPDATE,\n PermissionName.ROLE_DELETE,\n ],\n [EntityType.SCOPE]: [\n PermissionName.SCOPE_READ,\n PermissionName.SCOPE_UPDATE,\n PermissionName.SCOPE_DELETE,\n ],\n [EntityType.PERMISSION]: [\n PermissionName.PERMISSION_READ,\n PermissionName.PERMISSION_UPDATE,\n PermissionName.PERMISSION_DELETE,\n ],\n [EntityType.POLICY]: [\n PermissionName.PERMISSION_READ,\n PermissionName.PERMISSION_UPDATE,\n PermissionName.PERMISSION_DELETE,\n ],\n};\n\n/**\n * Build a rapiq `relations.validate` hook gating each include on the\n * TARGET entity type's read permission (issue #3295): the actor must\n * pass the derived pre-gate (`preEvaluateOneOf`, #3290) for the\n * relation's mapped entity type — row data is unknown at decode time,\n * so only a settled-false (the actor can never read that entity type)\n * denies. A denial STRIPS the relation silently — the explicit\n * `include=`, and (since rapiq beta.7, tada5hi/rapiq#815) every dotted\n * `filter`/`sort`/`field` key that traverses the denied relation,\n * whether or not it was explicitly included. rapiq records one\n * authorization obligation per distinct relation reached by any\n * parameter, evaluates this hook once for it, and prunes the dependent\n * keys — the same fail-soft flavor as the allow-lists, so a scoped\n * reader degrades to the un-joined / un-filtered row shape instead of\n * a 403.\n *\n * `mapping` is the schema's own relation → entity-type `schemaMapping`;\n * rapiq invokes the hook per include segment against the schema\n * governing it, so nested paths (`include=user.realm`) are gated hop\n * by hop by each governing schema's own hook. Unmapped relations and\n * ungated targets neutral-pass.\n *\n * Caller classes: a SYSTEM call (no actor in the decode context) is\n * unrestricted — the gate neutral-passes. A REQUEST call always\n * carries an actor (`buildActorContext` supplies one even for an\n * anonymous request), so restriction attaches at the request\n * boundary: an authenticated actor is gated by its grants, an\n * anonymous actor holds none and every gated include strips. A gate\n * evaluation failure fails closed (strip).\n *\n * NOTE: schemas import this file DIRECTLY (never the `core/query`\n * barrel) — the barrel reaches `module.ts`, which imports every\n * schema; importing it from a schema would create a TDZ cycle.\n */\nexport function createRelationsReadGate(\n mapping: Record<string, `${EntityType}`>,\n) : KeyValidator<QueryDecodeContext | undefined> {\n return async (name, context) => {\n const target = mapping[name];\n if (!target) {\n return true;\n }\n\n const permissions = RELATION_TARGET_READ_GATES[target];\n if (!permissions) {\n return true;\n }\n\n if (!context || !context.actor) {\n return true;\n }\n\n try {\n await context.actor.permissionEvaluator.preEvaluateOneOf({ name: permissions });\n return true;\n } catch {\n return false;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;GA0BA,MAAME,6BAAkF;EACnFF,WAAWG,SAAS;EACjBF,eAAeG;EACfH,eAAeI;EACfJ,eAAeK;;EAElBN,WAAWO,OAAO;EACfN,eAAeO;EACfP,eAAeQ;EACfR,eAAeS;;EAElBV,WAAWW,OAAO;EACfV,eAAeW;EACfX,eAAeY;EACfZ,eAAea;;EAElBd,WAAWe,QAAQ;EAChBd,eAAee;EACff,eAAegB;EACfhB,eAAeiB;;EAElBlB,WAAWmB,aAAa;EACrBlB,eAAemB;EACfnB,eAAeoB;EACfpB,eAAeqB;;EAElBtB,WAAWuB,SAAS;EACjBtB,eAAemB;EACfnB,eAAeoB;EACfpB,eAAeqB;;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCA,SAAgBE,wBACZC,SAAwC;CAExC,OAAO,OAAOC,MAAMC,YAAAA;EAChB,MAAMC,SAASH,QAAQC;EACvB,IAAI,CAACE,QACD,OAAO;EAGX,MAAMC,cAAc3B,2BAA2B0B;EAC/C,IAAI,CAACC,aACD,OAAO;EAGX,IAAI,CAACF,WAAW,CAACA,QAAQG,OACrB,OAAO;EAGX,IAAI;GACA,MAAMH,QAAQG,MAAMC,oBAAoBC,iBAAiB,EAAEN,MAAMG,YAAY,CAAA;GAC7E,OAAO;EACX,QAAQ;GACJ,OAAO;EACX;CACJ;AACJ"}
1
+ {"version":3,"file":"relations.mjs","names":["EntityType","PermissionName","RELATION_TARGET_READ_GATES","CLIENT","CLIENT_READ","CLIENT_UPDATE","CLIENT_DELETE","USER","USER_READ","USER_UPDATE","USER_DELETE","ROLE","ROLE_READ","ROLE_UPDATE","ROLE_DELETE","SCOPE","SCOPE_READ","SCOPE_UPDATE","SCOPE_DELETE","PERMISSION","PERMISSION_READ","PERMISSION_UPDATE","PERMISSION_DELETE","POLICY","createRelationsReadGate","mapping","name","context","target","permissions","actor","permissionEvaluator","preEvaluateOneOf"],"sources":["../../../src/core/query/relations.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 type { KeyValidator } from '@rapiq/core';\nimport { EntityType, PermissionName } from '@authup/core-kit';\nimport type { QueryDecodeContext } from './types.ts';\n\n/**\n * Read gate per include target: the permission disjunction an actor\n * must hold (data-availability-derived pre-gate, issue #3290) for the\n * target entity type to be joinable via `include=` OR reachable via a\n * dotted `filter`/`sort`/`field` key. Mirrors each target service's own\n * `getMany` read pre-gate, so \"may list the entity type\" and \"may join\n * it onto another list\" stay one predicate.\n * Policies are deliberately gated under the PERMISSION family — they\n * are managed under the permission domain.\n *\n * Absent entries are ungated: `realm` (the realm list is public — the\n * login realm chooser reads it anonymously) and `identityProvider`\n * (the anonymous login page lists providers; its schema field\n * allow-list is the safe-DTO layer).\n */\nconst RELATION_TARGET_READ_GATES : Partial<Record<`${EntityType}`, PermissionName[]>> = {\n [EntityType.CLIENT]: [\n PermissionName.CLIENT_READ,\n PermissionName.CLIENT_UPDATE,\n PermissionName.CLIENT_DELETE,\n ],\n [EntityType.USER]: [\n PermissionName.USER_READ,\n PermissionName.USER_UPDATE,\n PermissionName.USER_DELETE,\n ],\n [EntityType.ROLE]: [\n PermissionName.ROLE_READ,\n PermissionName.ROLE_UPDATE,\n PermissionName.ROLE_DELETE,\n ],\n [EntityType.SCOPE]: [\n PermissionName.SCOPE_READ,\n PermissionName.SCOPE_UPDATE,\n PermissionName.SCOPE_DELETE,\n ],\n [EntityType.PERMISSION]: [\n PermissionName.PERMISSION_READ,\n PermissionName.PERMISSION_UPDATE,\n PermissionName.PERMISSION_DELETE,\n ],\n [EntityType.POLICY]: [\n PermissionName.PERMISSION_READ,\n PermissionName.PERMISSION_UPDATE,\n PermissionName.PERMISSION_DELETE,\n ],\n};\n\n/**\n * Build a rapiq `relations.validate` hook gating each include on the\n * TARGET entity type's read permission (issue #3295): the actor must\n * pass the derived pre-gate (`preEvaluateOneOf`, #3290) for the\n * relation's mapped entity type — row data is unknown at decode time,\n * so only a settled-false (the actor can never read that entity type)\n * denies. A denial STRIPS the relation silently — the explicit\n * `include=`, and (since rapiq beta.7, tada5hi/rapiq#815) every dotted\n * `filter`/`sort`/`field` key that traverses the denied relation,\n * whether or not it was explicitly included. rapiq records one\n * authorization obligation per distinct relation reached by any\n * parameter, evaluates this hook once for it, and prunes the dependent\n * keys — the same fail-soft flavor as the allow-lists, so a scoped\n * reader degrades to the un-joined / un-filtered row shape instead of\n * a 403.\n *\n * `mapping` is the schema's own relation → entity-type `schemaMapping`;\n * rapiq invokes the hook per include segment against the schema\n * governing it, so nested paths (`include=user.realm`) are gated hop\n * by hop by each governing schema's own hook. Unmapped relations and\n * ungated targets neutral-pass.\n *\n * Caller classes: a SYSTEM call (no actor in the decode context) is\n * unrestricted — the gate neutral-passes. A REQUEST call always\n * carries an actor (`buildActorContext` supplies one even for an\n * anonymous request), so restriction attaches at the request\n * boundary: an authenticated actor is gated by its grants, an\n * anonymous actor holds none and every gated include strips. A gate\n * evaluation failure fails closed (strip).\n *\n * NOTE: schemas import this file DIRECTLY (never the `core/query`\n * barrel) — the barrel reaches `module.ts`, which imports every\n * schema; importing it from a schema would create a TDZ cycle.\n */\nexport function createRelationsReadGate(\n mapping: Record<string, `${EntityType}`>,\n) : KeyValidator<QueryDecodeContext | undefined> {\n return async (name, context) => {\n const target = mapping[name];\n if (!target) {\n return true;\n }\n\n const permissions = RELATION_TARGET_READ_GATES[target];\n if (!permissions) {\n return true;\n }\n\n if (!context || !context.actor) {\n return true;\n }\n\n try {\n await context.actor.permissionEvaluator.preEvaluateOneOf({ name: permissions });\n return true;\n } catch {\n return false;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;GA0BA,MAAME,6BAAkF;EACnFF,WAAWG,SAAS;EACjBF,eAAeG;EACfH,eAAeI;EACfJ,eAAeK;CAClB;EACAN,WAAWO,OAAO;EACfN,eAAeO;EACfP,eAAeQ;EACfR,eAAeS;CAClB;EACAV,WAAWW,OAAO;EACfV,eAAeW;EACfX,eAAeY;EACfZ,eAAea;CAClB;EACAd,WAAWe,QAAQ;EAChBd,eAAee;EACff,eAAegB;EACfhB,eAAeiB;CAClB;EACAlB,WAAWmB,aAAa;EACrBlB,eAAemB;EACfnB,eAAeoB;EACfpB,eAAeqB;CAClB;EACAtB,WAAWuB,SAAS;EACjBtB,eAAemB;EACfnB,eAAeoB;EACfpB,eAAeqB;CAClB;AACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCA,SAAgBE,wBACZC,SAAwC;CAExC,OAAO,OAAOC,MAAMC,YAAAA;EAChB,MAAMC,SAASH,QAAQC;EACvB,IAAI,CAACE,QACD,OAAO;EAGX,MAAMC,cAAc3B,2BAA2B0B;EAC/C,IAAI,CAACC,aACD,OAAO;EAGX,IAAI,CAACF,WAAW,CAACA,QAAQG,OACrB,OAAO;EAGX,IAAI;GACA,MAAMH,QAAQG,MAAMC,oBAAoBC,iBAAiB,EAAEN,MAAMG,YAAY,CAAA;GAC7E,OAAO;EACX,QAAQ;GACJ,OAAO;EACX;CACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator.mjs","names":["and","or","BuiltInPolicyType","IdentityPolicyEvaluator","PermissionBindingPolicyValidator","PolicyEngine","PolicyIssueCode","RealmMatchPolicyEvaluator","RealmScope","aggregatePermissionPolicyBindings","definePolicyIssueItem","maybeInvertPolicyOutcome","normalizeRealmScope","PermissionBindingPolicyEvaluator","validator","identityEvaluator","realmMatchEvaluator","identityPermissionProvider","requires","PERMISSION_BINDING","accessData","ctx","data","has","isValidated","get","set","setValidated","evaluate","value","policy","run","identity","success","issues","code","DATA_MISSING","message","path","binding","identityBindings","getFor","then","bindings","filter","item","permission","name","realmId","clientId","length","invert","aggr","pendingIssues","conditions","pending","lowerable","grant","grants","reachCondition","realmOutcome","scope","realmScope","NONE","ANY","condition","push","engine","evaluators","outcome","withConditions","result"],"sources":["../../../../src/core/security/policy/evaluator.ts"],"sourcesContent":["/*\n * Copyright (c) 2024-2024.\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 type { ICondition } from '@rapiq/core';\nimport { and, or } from '@rapiq/core';\nimport type { Issue } from 'validup';\nimport type {\n IPolicyEvaluator,\n PermissionPolicyBindingAggregated,\n PolicyEvaluationContext,\n PolicyEvaluationResult,\n} from '@authup/access';\nimport {\n BuiltInPolicyType,\n IdentityPolicyEvaluator,\n PermissionBindingPolicyValidator,\n PolicyEngine,\n PolicyIssueCode,\n RealmMatchPolicyEvaluator,\n RealmScope,\n aggregatePermissionPolicyBindings,\n definePolicyIssueItem,\n maybeInvertPolicyOutcome,\n normalizeRealmScope,\n} from '@authup/access';\nimport type { IIdentityPermissionProvider } from '../../identity/permission/types.ts';\n\nexport class PermissionBindingPolicyEvaluator implements IPolicyEvaluator {\n protected validator : PermissionBindingPolicyValidator;\n\n protected identityEvaluator: IdentityPolicyEvaluator;\n\n protected realmMatchEvaluator : RealmMatchPolicyEvaluator;\n\n protected identityPermissionProvider: IIdentityPermissionProvider;\n\n constructor(identityPermissionProvider: IIdentityPermissionProvider) {\n this.validator = new PermissionBindingPolicyValidator();\n this.identityEvaluator = new IdentityPolicyEvaluator();\n this.realmMatchEvaluator = new RealmMatchPolicyEvaluator();\n this.identityPermissionProvider = identityPermissionProvider;\n }\n\n requires() : string[] {\n // IDENTITY is deliberately NOT declared: a missing identity must stay a\n // settled DATA_MISSING deny (fail-closed) so a scope-restricted or anonymous\n // bearer still fails the pre-gate through system.default — pending would be\n // permitted there.\n return [BuiltInPolicyType.PERMISSION_BINDING];\n }\n\n async accessData(ctx: PolicyEvaluationContext) : Promise<PermissionPolicyBindingAggregated | null> {\n if (!ctx.data.has(BuiltInPolicyType.PERMISSION_BINDING)) {\n return null;\n }\n\n if (ctx.data.isValidated(BuiltInPolicyType.PERMISSION_BINDING)) {\n return ctx.data.get(BuiltInPolicyType.PERMISSION_BINDING);\n }\n\n const data = ctx.data.get<PermissionPolicyBindingAggregated>(BuiltInPolicyType.PERMISSION_BINDING);\n\n ctx.data.set(BuiltInPolicyType.PERMISSION_BINDING, data);\n ctx.data.setValidated(BuiltInPolicyType.PERMISSION_BINDING);\n\n return data;\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n const policy = await this.validator.run(value);\n\n const identity = await this.identityEvaluator.accessData(ctx);\n if (!identity) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property identity is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n const binding = await this.accessData(ctx);\n if (!binding) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property permission is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n const identityBindings = await this.identityPermissionProvider.getFor(identity)\n .then((bindings) => bindings.filter((item) => {\n if (item.permission.name !== binding.permission.name) {\n return false;\n }\n\n return (binding.permission.realmId ?? null) === (item.permission.realmId ?? null) &&\n (binding.permission.clientId ?? null) === (item.permission.clientId ?? null);\n }));\n\n if (identityBindings.length === 0) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n\n const [aggr] = aggregatePermissionPolicyBindings(identityBindings);\n if (!aggr) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n\n // identityBindings is filtered to a single (name, realm_id, client_id) key, so the\n // aggregate yields exactly one entry whose `grants` are the actor's per-grant\n // (realm_scope, policy) disjunction terms; access is the DISJUNCTION over them:\n // ∃ grant . realmScopeMatches(grant.realmScope, resource) ∧ (grant.policy passes)\n // Pairing each grant's realm reach with its OWN policy is what fixes both the mixed\n // policy-free + policy-bound UNDER-grant (a policy-free `own` grant must not mask a\n // policy-bound `any` grant's wider reach) and the symmetric OVER-grant (an `own`\n // grant's passing policy must not ride an `any` grant's wider reach).\n const issues : Issue[] = [];\n const pendingIssues : Issue[] = [];\n const conditions : ICondition[] = [];\n let pending = false;\n let lowerable = true;\n for (const grant of aggr.grants) {\n // Realm reach (coarse, actor-relative) — a SEPARATE factor from the grant's\n // policy, ANDed with it. The realm-match evaluator runs in SCOPE MODE: it reads the\n // resource realm from ctx.data[REALM_MATCH] (fallback ATTRIBUTES.realmId) and\n // neutral-passes when absent (preEvaluate / gate checks / realm-less resources) —\n // key-PRESENCE is the discriminator. Invoked DIRECTLY (not via PolicyEngine) so\n // the reach factor can never be skipped by a caller's include/exclude filters or\n // deferred by the engine's data-availability gate.\n //\n // Under `withConditions` (query-build) with no resource realm present, the\n // reach PENDS with its condition form over the row's realm column instead of\n // neutral-passing — `any` stays unrestricted and `none` reaches nothing, so\n // neither pollutes the composed WHERE with constant terms.\n let reachCondition : ICondition | null = null;\n const realmOutcome = await this.realmMatchEvaluator.evaluate(\n { scope: grant.realmScope },\n ctx,\n );\n if (realmOutcome.pending) {\n const scope = normalizeRealmScope(grant.realmScope);\n if (scope === RealmScope.NONE) {\n continue;\n }\n\n if (scope !== RealmScope.ANY) {\n if (!realmOutcome.condition) {\n pending = true;\n lowerable = false;\n continue;\n }\n\n reachCondition = realmOutcome.condition;\n }\n } else if (!realmOutcome.success) {\n continue;\n }\n\n if (!grant.policy) {\n if (!reachCondition) {\n // Reach matches and this grant carries no further restriction.\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n // Reach is the grant's only restriction — a pure condition term.\n conditions.push(reachCondition);\n pending = true;\n continue;\n }\n\n // Missing evaluators is a misconfiguration: let the engine fail CLOSED with a\n // surfaced POLICY_EVALUATOR_NOT_FOUND issue (new PolicyEngine(undefined) defaults\n // to an empty registry, so grant.policy resolves to no evaluator) rather than\n // swallowing the grant with a silent issue-less deny.\n const engine = new PolicyEngine(ctx.evaluators);\n const outcome = await engine.evaluate(grant.policy, {\n ...ctx,\n path: [\n ...(ctx.path || []),\n ],\n });\n\n if (outcome.success) {\n if (!reachCondition) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n conditions.push(reachCondition);\n pending = true;\n continue;\n }\n\n // A PENDING junction policy (required data key absent — e.g. an ATTRIBUTES\n // policy at the pre-gate) leaves this grant term UNKNOWN, not failed: the\n // grant could still pass once the data arrives, so it must not settle the\n // disjunction to false.\n if (outcome.pending) {\n pending = true;\n\n if (ctx.withConditions && outcome.condition) {\n conditions.push(\n reachCondition ?\n and(reachCondition, outcome.condition) :\n outcome.condition,\n );\n } else {\n lowerable = false;\n }\n\n if (outcome.issues) {\n pendingIssues.push(...outcome.issues);\n }\n\n continue;\n }\n\n if (outcome.issues) {\n issues.push(...outcome.issues);\n }\n }\n\n // No grant term settled true. If some term is still pending, the disjunction is\n // pending — deliberately uninverted (unknown stays unknown under negation). The\n // condition form composes the grant terms as a disjunction, all-or-nothing: a\n // single non-expressible grant term makes the whole binding non-expressible\n // (pushing a partial OR would wrongly exclude rows).\n if (pending) {\n const result : PolicyEvaluationResult = {\n success: false,\n pending: true,\n issues: pendingIssues,\n };\n\n if (ctx.withConditions && lowerable && conditions.length > 0) {\n result.condition = conditions.length === 1 ?\n conditions[0]! :\n or(...conditions);\n }\n\n return result;\n }\n\n // No grant term satisfied (reach ∧ policies). Apply `invert` ONCE to the aggregated\n // disjunction outcome — never per term, which would corrupt the quantifier.\n const success = maybeInvertPolicyOutcome(false, policy.invert);\n return {\n success,\n issues: success ? [] : issues,\n };\n }\n}\n"],"mappings":";;;;;;AA+BA,IAAaa,mCAAb,MAAaA;CACCC;CAEAC;CAEAC;CAEAC;CAEV,YAAYA,4BAAyD;EACjE,KAAKH,YAAY,IAAIV,iCAAAA;EACrB,KAAKW,oBAAoB,IAAIZ,wBAAAA;EAC7B,KAAKa,sBAAsB,IAAIT,0BAAAA;EAC/B,KAAKU,6BAA6BA;CACtC;CAEAC,WAAsB;EAKlB,OAAO,CAAChB,kBAAkBiB,kBAAAA;CAC9B;CAEA,MAAMC,WAAWC,KAAkF;EAC/F,IAAI,CAACA,IAAIC,KAAKC,IAAIrB,kBAAkBiB,kBAAkB,GAClD,OAAO;EAGX,IAAIE,IAAIC,KAAKE,YAAYtB,kBAAkBiB,kBAAkB,GACzD,OAAOE,IAAIC,KAAKG,IAAIvB,kBAAkBiB,kBAAkB;EAG5D,MAAMG,OAAOD,IAAIC,KAAKG,IAAuCvB,kBAAkBiB,kBAAkB;EAEjGE,IAAIC,KAAKI,IAAIxB,kBAAkBiB,oBAAoBG,IAAAA;EACnDD,IAAIC,KAAKK,aAAazB,kBAAkBiB,kBAAkB;EAE1D,OAAOG;CACX;CAEA,MAAMM,SAASC,OAA4BR,KAA+D;EACtG,MAAMS,SAAS,MAAM,KAAKhB,UAAUiB,IAAIF,KAAAA;EAExC,MAAMG,WAAW,MAAM,KAAKjB,kBAAkBK,WAAWC,GAAAA;EACzD,IAAI,CAACW,UACD,OAAO;GACHC,SAAS;GACTC,QAAQ,CACJxB,sBAAsB;IAClByB,MAAM7B,gBAAgB8B;IACtBC,SAAS;IACTC,MAAMjB,IAAIiB;GACd,CAAA,CAAA;EAER;EAEJ,MAAMC,UAAU,MAAM,KAAKnB,WAAWC,GAAAA;EACtC,IAAI,CAACkB,SACD,OAAO;GAC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mjs","names":["and","or","BuiltInPolicyType","IdentityPolicyEvaluator","PermissionBindingPolicyValidator","PolicyEngine","PolicyIssueCode","RealmMatchPolicyEvaluator","RealmScope","aggregatePermissionPolicyBindings","definePolicyIssueItem","maybeInvertPolicyOutcome","normalizeRealmScope","PermissionBindingPolicyEvaluator","validator","identityEvaluator","realmMatchEvaluator","identityPermissionProvider","requires","PERMISSION_BINDING","accessData","ctx","data","has","isValidated","get","set","setValidated","evaluate","value","policy","run","identity","success","issues","code","DATA_MISSING","message","path","binding","identityBindings","getFor","then","bindings","filter","item","permission","name","realmId","clientId","length","invert","aggr","pendingIssues","conditions","pending","lowerable","grant","grants","reachCondition","realmOutcome","scope","realmScope","NONE","ANY","condition","push","engine","evaluators","outcome","withConditions","result"],"sources":["../../../../src/core/security/policy/evaluator.ts"],"sourcesContent":["/*\n * Copyright (c) 2024-2024.\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 type { ICondition } from '@rapiq/core';\nimport { and, or } from '@rapiq/core';\nimport type { Issue } from 'validup';\nimport type {\n IPolicyEvaluator,\n PermissionPolicyBindingAggregated,\n PolicyEvaluationContext,\n PolicyEvaluationResult,\n} from '@authup/access';\nimport {\n BuiltInPolicyType,\n IdentityPolicyEvaluator,\n PermissionBindingPolicyValidator,\n PolicyEngine,\n PolicyIssueCode,\n RealmMatchPolicyEvaluator,\n RealmScope,\n aggregatePermissionPolicyBindings,\n definePolicyIssueItem,\n maybeInvertPolicyOutcome,\n normalizeRealmScope,\n} from '@authup/access';\nimport type { IIdentityPermissionProvider } from '../../identity/permission/types.ts';\n\nexport class PermissionBindingPolicyEvaluator implements IPolicyEvaluator {\n protected validator : PermissionBindingPolicyValidator;\n\n protected identityEvaluator: IdentityPolicyEvaluator;\n\n protected realmMatchEvaluator : RealmMatchPolicyEvaluator;\n\n protected identityPermissionProvider: IIdentityPermissionProvider;\n\n constructor(identityPermissionProvider: IIdentityPermissionProvider) {\n this.validator = new PermissionBindingPolicyValidator();\n this.identityEvaluator = new IdentityPolicyEvaluator();\n this.realmMatchEvaluator = new RealmMatchPolicyEvaluator();\n this.identityPermissionProvider = identityPermissionProvider;\n }\n\n requires() : string[] {\n // IDENTITY is deliberately NOT declared: a missing identity must stay a\n // settled DATA_MISSING deny (fail-closed) so a scope-restricted or anonymous\n // bearer still fails the pre-gate through system.default — pending would be\n // permitted there.\n return [BuiltInPolicyType.PERMISSION_BINDING];\n }\n\n async accessData(ctx: PolicyEvaluationContext) : Promise<PermissionPolicyBindingAggregated | null> {\n if (!ctx.data.has(BuiltInPolicyType.PERMISSION_BINDING)) {\n return null;\n }\n\n if (ctx.data.isValidated(BuiltInPolicyType.PERMISSION_BINDING)) {\n return ctx.data.get(BuiltInPolicyType.PERMISSION_BINDING);\n }\n\n const data = ctx.data.get<PermissionPolicyBindingAggregated>(BuiltInPolicyType.PERMISSION_BINDING);\n\n ctx.data.set(BuiltInPolicyType.PERMISSION_BINDING, data);\n ctx.data.setValidated(BuiltInPolicyType.PERMISSION_BINDING);\n\n return data;\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n const policy = await this.validator.run(value);\n\n const identity = await this.identityEvaluator.accessData(ctx);\n if (!identity) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property identity is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n const binding = await this.accessData(ctx);\n if (!binding) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property permission is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n const identityBindings = await this.identityPermissionProvider.getFor(identity)\n .then((bindings) => bindings.filter((item) => {\n if (item.permission.name !== binding.permission.name) {\n return false;\n }\n\n return (binding.permission.realmId ?? null) === (item.permission.realmId ?? null) &&\n (binding.permission.clientId ?? null) === (item.permission.clientId ?? null);\n }));\n\n if (identityBindings.length === 0) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n\n const [aggr] = aggregatePermissionPolicyBindings(identityBindings);\n if (!aggr) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n\n // identityBindings is filtered to a single (name, realm_id, client_id) key, so the\n // aggregate yields exactly one entry whose `grants` are the actor's per-grant\n // (realm_scope, policy) disjunction terms; access is the DISJUNCTION over them:\n // ∃ grant . realmScopeMatches(grant.realmScope, resource) ∧ (grant.policy passes)\n // Pairing each grant's realm reach with its OWN policy is what fixes both the mixed\n // policy-free + policy-bound UNDER-grant (a policy-free `own` grant must not mask a\n // policy-bound `any` grant's wider reach) and the symmetric OVER-grant (an `own`\n // grant's passing policy must not ride an `any` grant's wider reach).\n const issues : Issue[] = [];\n const pendingIssues : Issue[] = [];\n const conditions : ICondition[] = [];\n let pending = false;\n let lowerable = true;\n for (const grant of aggr.grants) {\n // Realm reach (coarse, actor-relative) — a SEPARATE factor from the grant's\n // policy, ANDed with it. The realm-match evaluator runs in SCOPE MODE: it reads the\n // resource realm from ctx.data[REALM_MATCH] (fallback ATTRIBUTES.realmId) and\n // neutral-passes when absent (preEvaluate / gate checks / realm-less resources) —\n // key-PRESENCE is the discriminator. Invoked DIRECTLY (not via PolicyEngine) so\n // the reach factor can never be skipped by a caller's include/exclude filters or\n // deferred by the engine's data-availability gate.\n //\n // Under `withConditions` (query-build) with no resource realm present, the\n // reach PENDS with its condition form over the row's realm column instead of\n // neutral-passing — `any` stays unrestricted and `none` reaches nothing, so\n // neither pollutes the composed WHERE with constant terms.\n let reachCondition : ICondition | null = null;\n const realmOutcome = await this.realmMatchEvaluator.evaluate(\n { scope: grant.realmScope },\n ctx,\n );\n if (realmOutcome.pending) {\n const scope = normalizeRealmScope(grant.realmScope);\n if (scope === RealmScope.NONE) {\n continue;\n }\n\n if (scope !== RealmScope.ANY) {\n if (!realmOutcome.condition) {\n pending = true;\n lowerable = false;\n continue;\n }\n\n reachCondition = realmOutcome.condition;\n }\n } else if (!realmOutcome.success) {\n continue;\n }\n\n if (!grant.policy) {\n if (!reachCondition) {\n // Reach matches and this grant carries no further restriction.\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n // Reach is the grant's only restriction — a pure condition term.\n conditions.push(reachCondition);\n pending = true;\n continue;\n }\n\n // Missing evaluators is a misconfiguration: let the engine fail CLOSED with a\n // surfaced POLICY_EVALUATOR_NOT_FOUND issue (new PolicyEngine(undefined) defaults\n // to an empty registry, so grant.policy resolves to no evaluator) rather than\n // swallowing the grant with a silent issue-less deny.\n const engine = new PolicyEngine(ctx.evaluators);\n const outcome = await engine.evaluate(grant.policy, {\n ...ctx,\n path: [\n ...(ctx.path || []),\n ],\n });\n\n if (outcome.success) {\n if (!reachCondition) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n conditions.push(reachCondition);\n pending = true;\n continue;\n }\n\n // A PENDING junction policy (required data key absent — e.g. an ATTRIBUTES\n // policy at the pre-gate) leaves this grant term UNKNOWN, not failed: the\n // grant could still pass once the data arrives, so it must not settle the\n // disjunction to false.\n if (outcome.pending) {\n pending = true;\n\n if (ctx.withConditions && outcome.condition) {\n conditions.push(\n reachCondition ?\n and(reachCondition, outcome.condition) :\n outcome.condition,\n );\n } else {\n lowerable = false;\n }\n\n if (outcome.issues) {\n pendingIssues.push(...outcome.issues);\n }\n\n continue;\n }\n\n if (outcome.issues) {\n issues.push(...outcome.issues);\n }\n }\n\n // No grant term settled true. If some term is still pending, the disjunction is\n // pending — deliberately uninverted (unknown stays unknown under negation). The\n // condition form composes the grant terms as a disjunction, all-or-nothing: a\n // single non-expressible grant term makes the whole binding non-expressible\n // (pushing a partial OR would wrongly exclude rows).\n if (pending) {\n const result : PolicyEvaluationResult = {\n success: false,\n pending: true,\n issues: pendingIssues,\n };\n\n if (ctx.withConditions && lowerable && conditions.length > 0) {\n result.condition = conditions.length === 1 ?\n conditions[0]! :\n or(...conditions);\n }\n\n return result;\n }\n\n // No grant term satisfied (reach ∧ policies). Apply `invert` ONCE to the aggregated\n // disjunction outcome — never per term, which would corrupt the quantifier.\n const success = maybeInvertPolicyOutcome(false, policy.invert);\n return {\n success,\n issues: success ? [] : issues,\n };\n }\n}\n"],"mappings":";;;;;;AA+BA,IAAaa,mCAAb,MAAaA;CACCC;CAEAC;CAEAC;CAEAC;CAEV,YAAYA,4BAAyD;EACjE,KAAKH,YAAY,IAAIV,iCAAAA;EACrB,KAAKW,oBAAoB,IAAIZ,wBAAAA;EAC7B,KAAKa,sBAAsB,IAAIT,0BAAAA;EAC/B,KAAKU,6BAA6BA;CACtC;CAEAC,WAAsB;EAKlB,OAAO,CAAChB,kBAAkBiB,kBAAmB;CACjD;CAEA,MAAMC,WAAWC,KAAkF;EAC/F,IAAI,CAACA,IAAIC,KAAKC,IAAIrB,kBAAkBiB,kBAAkB,GAClD,OAAO;EAGX,IAAIE,IAAIC,KAAKE,YAAYtB,kBAAkBiB,kBAAkB,GACzD,OAAOE,IAAIC,KAAKG,IAAIvB,kBAAkBiB,kBAAkB;EAG5D,MAAMG,OAAOD,IAAIC,KAAKG,IAAuCvB,kBAAkBiB,kBAAkB;EAEjGE,IAAIC,KAAKI,IAAIxB,kBAAkBiB,oBAAoBG,IAAAA;EACnDD,IAAIC,KAAKK,aAAazB,kBAAkBiB,kBAAkB;EAE1D,OAAOG;CACX;CAEA,MAAMM,SAASC,OAA4BR,KAA+D;EACtG,MAAMS,SAAS,MAAM,KAAKhB,UAAUiB,IAAIF,KAAAA;EAExC,MAAMG,WAAW,MAAM,KAAKjB,kBAAkBK,WAAWC,GAAAA;EACzD,IAAI,CAACW,UACD,OAAO;GACHC,SAAS;GACTC,QAAQ,CACJxB,sBAAsB;IAClByB,MAAM7B,gBAAgB8B;IACtBC,SAAS;IACTC,MAAMjB,IAAIiB;GACd,CAAA,CACH;EACL;EAEJ,MAAMC,UAAU,MAAM,KAAKnB,WAAWC,GAAAA;EACtC,IAAI,CAACkB,SACD,OAA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