@contember/engine-tenant-api 2.2.0-alpha.3 → 2.2.0-alpha.6

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 (1316) hide show
  1. package/CLAUDE.md +36 -2
  2. package/dist/development/index.cjs +32 -0
  3. package/dist/development/index.cjs.map +1 -1
  4. package/dist/development/index.js +33 -1
  5. package/dist/development/index.js.map +1 -1
  6. package/dist/development/src/TenantContainer.cjs +15 -3
  7. package/dist/development/src/TenantContainer.cjs.map +1 -1
  8. package/dist/development/src/TenantContainer.js +15 -3
  9. package/dist/development/src/TenantContainer.js.map +1 -1
  10. package/dist/development/src/bridges/system/IdentityFetcher.cjs +2 -1
  11. package/dist/development/src/bridges/system/IdentityFetcher.cjs.map +1 -1
  12. package/dist/development/src/bridges/system/IdentityFetcher.js +2 -1
  13. package/dist/development/src/bridges/system/IdentityFetcher.js.map +1 -1
  14. package/dist/development/src/migrations/2026-06-18-120000-idp-claim-mapping.cjs +10 -0
  15. package/dist/development/src/migrations/2026-06-18-120000-idp-claim-mapping.cjs.map +1 -0
  16. package/dist/development/src/migrations/2026-06-18-120000-idp-claim-mapping.js +11 -0
  17. package/dist/development/src/migrations/2026-06-18-120000-idp-claim-mapping.js.map +1 -0
  18. package/dist/development/src/migrations/2026-08-03-120000-person-enable-auth-log.cjs +9 -0
  19. package/dist/development/src/migrations/2026-08-03-120000-person-enable-auth-log.cjs.map +1 -0
  20. package/dist/development/src/migrations/2026-08-03-120000-person-enable-auth-log.js +10 -0
  21. package/dist/development/src/migrations/2026-08-03-120000-person-enable-auth-log.js.map +1 -0
  22. package/dist/development/src/migrations/2026-08-04-120000-config-panel.cjs +11 -0
  23. package/dist/development/src/migrations/2026-08-04-120000-config-panel.cjs.map +1 -0
  24. package/dist/development/src/migrations/2026-08-04-120000-config-panel.js +12 -0
  25. package/dist/development/src/migrations/2026-08-04-120000-config-panel.js.map +1 -0
  26. package/dist/development/src/migrations/2026-09-04-120000-idp-disable-local-authentication.cjs +18 -0
  27. package/dist/development/src/migrations/2026-09-04-120000-idp-disable-local-authentication.cjs.map +1 -0
  28. package/dist/development/src/migrations/2026-09-04-120000-idp-disable-local-authentication.js +19 -0
  29. package/dist/development/src/migrations/2026-09-04-120000-idp-disable-local-authentication.js.map +1 -0
  30. package/dist/development/src/migrations/runner.cjs +11 -2
  31. package/dist/development/src/migrations/runner.cjs.map +1 -1
  32. package/dist/development/src/migrations/runner.js +11 -2
  33. package/dist/development/src/migrations/runner.js.map +1 -1
  34. package/dist/development/src/migrations/snapshot.cjs +8 -2
  35. package/dist/development/src/migrations/snapshot.cjs.map +1 -1
  36. package/dist/development/src/migrations/snapshot.js +8 -2
  37. package/dist/development/src/migrations/snapshot.js.map +1 -1
  38. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.cjs +5 -3
  39. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.cjs.map +1 -1
  40. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.js +5 -3
  41. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.js.map +1 -1
  42. package/dist/development/src/model/commands/idp/CreateIdpCommand.cjs +8 -2
  43. package/dist/development/src/model/commands/idp/CreateIdpCommand.cjs.map +1 -1
  44. package/dist/development/src/model/commands/idp/CreateIdpCommand.js +8 -2
  45. package/dist/development/src/model/commands/idp/CreateIdpCommand.js.map +1 -1
  46. package/dist/development/src/model/commands/idp/UpdateIdpCommand.cjs +6 -2
  47. package/dist/development/src/model/commands/idp/UpdateIdpCommand.cjs.map +1 -1
  48. package/dist/development/src/model/commands/idp/UpdateIdpCommand.js +6 -2
  49. package/dist/development/src/model/commands/idp/UpdateIdpCommand.js.map +1 -1
  50. package/dist/development/src/model/commands/membership/{RemoveProjectMembershipsCommand.cjs → RemoveProjectMembershipCommand.cjs} +1 -1
  51. package/dist/development/src/model/commands/membership/RemoveProjectMembershipCommand.cjs.map +1 -0
  52. package/dist/development/src/model/commands/membership/{RemoveProjectMembershipsCommand.js → RemoveProjectMembershipCommand.js} +1 -1
  53. package/dist/development/src/model/commands/membership/RemoveProjectMembershipCommand.js.map +1 -0
  54. package/dist/development/src/model/commands/membership/UpdateProjectMemberCommand.cjs +2 -2
  55. package/dist/development/src/model/commands/membership/UpdateProjectMemberCommand.cjs.map +1 -1
  56. package/dist/development/src/model/commands/membership/UpdateProjectMemberCommand.js +1 -1
  57. package/dist/development/src/model/commands/membership/UpdateProjectMemberCommand.js.map +1 -1
  58. package/dist/development/src/model/commands/person/EnablePersonCommand.cjs +17 -0
  59. package/dist/development/src/model/commands/person/EnablePersonCommand.cjs.map +1 -0
  60. package/dist/development/src/model/commands/person/EnablePersonCommand.js +17 -0
  61. package/dist/development/src/model/commands/person/EnablePersonCommand.js.map +1 -0
  62. package/dist/development/src/model/queries/configuration/ConfigurationQuery.cjs +4 -0
  63. package/dist/development/src/model/queries/configuration/ConfigurationQuery.cjs.map +1 -1
  64. package/dist/development/src/model/queries/configuration/ConfigurationQuery.js +4 -0
  65. package/dist/development/src/model/queries/configuration/ConfigurationQuery.js.map +1 -1
  66. package/dist/development/src/model/queries/idp/LocalAuthDisablingIdpsQuery.cjs +21 -0
  67. package/dist/development/src/model/queries/idp/LocalAuthDisablingIdpsQuery.cjs.map +1 -0
  68. package/dist/development/src/model/queries/idp/LocalAuthDisablingIdpsQuery.js +21 -0
  69. package/dist/development/src/model/queries/idp/LocalAuthDisablingIdpsQuery.js.map +1 -0
  70. package/dist/development/src/model/queries/idp/PersonIdentityProvidersQuery.cjs +1 -1
  71. package/dist/development/src/model/queries/idp/PersonIdentityProvidersQuery.cjs.map +1 -1
  72. package/dist/development/src/model/queries/idp/PersonIdentityProvidersQuery.js +1 -1
  73. package/dist/development/src/model/queries/idp/PersonIdentityProvidersQuery.js.map +1 -1
  74. package/dist/development/src/model/queries/idp/helpers.cjs +3 -3
  75. package/dist/development/src/model/queries/idp/helpers.cjs.map +1 -1
  76. package/dist/development/src/model/queries/idp/helpers.js +3 -3
  77. package/dist/development/src/model/queries/idp/helpers.js.map +1 -1
  78. package/dist/development/src/model/queries/membership/ProjectMembersQuery.cjs +1 -1
  79. package/dist/development/src/model/queries/membership/ProjectMembersQuery.cjs.map +1 -1
  80. package/dist/development/src/model/queries/membership/ProjectMembersQuery.js +1 -1
  81. package/dist/development/src/model/queries/membership/ProjectMembersQuery.js.map +1 -1
  82. package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.cjs +1 -1
  83. package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.cjs.map +1 -1
  84. package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.js +1 -1
  85. package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.js.map +1 -1
  86. package/dist/development/src/model/service/AuthLogService.cjs +8 -2
  87. package/dist/development/src/model/service/AuthLogService.cjs.map +1 -1
  88. package/dist/development/src/model/service/AuthLogService.js +8 -2
  89. package/dist/development/src/model/service/AuthLogService.js.map +1 -1
  90. package/dist/development/src/model/service/IDPSignInManager.cjs +29 -2
  91. package/dist/development/src/model/service/IDPSignInManager.cjs.map +1 -1
  92. package/dist/development/src/model/service/IDPSignInManager.js +29 -2
  93. package/dist/development/src/model/service/IDPSignInManager.js.map +1 -1
  94. package/dist/development/src/model/service/PanelAccessResolver.cjs +31 -0
  95. package/dist/development/src/model/service/PanelAccessResolver.cjs.map +1 -0
  96. package/dist/development/src/model/service/PanelAccessResolver.js +31 -0
  97. package/dist/development/src/model/service/PanelAccessResolver.js.map +1 -0
  98. package/dist/development/src/model/service/PasswordResetManager.cjs +5 -0
  99. package/dist/development/src/model/service/PasswordResetManager.cjs.map +1 -1
  100. package/dist/development/src/model/service/PasswordResetManager.js +5 -0
  101. package/dist/development/src/model/service/PasswordResetManager.js.map +1 -1
  102. package/dist/development/src/model/service/PasswordlessSignInManager.cjs +19 -0
  103. package/dist/development/src/model/service/PasswordlessSignInManager.cjs.map +1 -1
  104. package/dist/development/src/model/service/PasswordlessSignInManager.js +19 -0
  105. package/dist/development/src/model/service/PasswordlessSignInManager.js.map +1 -1
  106. package/dist/development/src/model/service/PersonAccessManager.cjs +10 -2
  107. package/dist/development/src/model/service/PersonAccessManager.cjs.map +1 -1
  108. package/dist/development/src/model/service/PersonAccessManager.js +10 -2
  109. package/dist/development/src/model/service/PersonAccessManager.js.map +1 -1
  110. package/dist/development/src/model/service/SignInManager.cjs +5 -0
  111. package/dist/development/src/model/service/SignInManager.cjs.map +1 -1
  112. package/dist/development/src/model/service/SignInManager.js +5 -0
  113. package/dist/development/src/model/service/SignInManager.js.map +1 -1
  114. package/dist/development/src/model/service/apiKey/ApiKeyManager.cjs +4 -3
  115. package/dist/development/src/model/service/apiKey/ApiKeyManager.cjs.map +1 -1
  116. package/dist/development/src/model/service/apiKey/ApiKeyManager.js +4 -3
  117. package/dist/development/src/model/service/apiKey/ApiKeyManager.js.map +1 -1
  118. package/dist/development/src/model/service/apiKey/UnpersistedApiKeyManager.cjs +7 -0
  119. package/dist/development/src/model/service/apiKey/UnpersistedApiKeyManager.cjs.map +1 -1
  120. package/dist/development/src/model/service/apiKey/UnpersistedApiKeyManager.js +8 -1
  121. package/dist/development/src/model/service/apiKey/UnpersistedApiKeyManager.js.map +1 -1
  122. package/dist/development/src/model/service/idp/ClaimMapping.cjs +187 -0
  123. package/dist/development/src/model/service/idp/ClaimMapping.cjs.map +1 -0
  124. package/dist/development/src/model/service/idp/ClaimMapping.js +170 -0
  125. package/dist/development/src/model/service/idp/ClaimMapping.js.map +1 -0
  126. package/dist/development/src/model/service/idp/ClaimMappingEvaluator.cjs +155 -0
  127. package/dist/development/src/model/service/idp/ClaimMappingEvaluator.cjs.map +1 -0
  128. package/dist/development/src/model/service/idp/ClaimMappingEvaluator.js +155 -0
  129. package/dist/development/src/model/service/idp/ClaimMappingEvaluator.js.map +1 -0
  130. package/dist/development/src/model/service/idp/ClaimMappingValidation.cjs +83 -0
  131. package/dist/development/src/model/service/idp/ClaimMappingValidation.cjs.map +1 -0
  132. package/dist/development/src/model/service/idp/ClaimMappingValidation.js +83 -0
  133. package/dist/development/src/model/service/idp/ClaimMappingValidation.js.map +1 -0
  134. package/dist/development/src/model/service/idp/IDPClaimSyncService.cjs +260 -0
  135. package/dist/development/src/model/service/idp/IDPClaimSyncService.cjs.map +1 -0
  136. package/dist/development/src/model/service/idp/IDPClaimSyncService.js +260 -0
  137. package/dist/development/src/model/service/idp/IDPClaimSyncService.js.map +1 -0
  138. package/dist/development/src/model/service/idp/IDPManager.cjs +96 -20
  139. package/dist/development/src/model/service/idp/IDPManager.cjs.map +1 -1
  140. package/dist/development/src/model/service/idp/IDPManager.js +96 -20
  141. package/dist/development/src/model/service/idp/IDPManager.js.map +1 -1
  142. package/dist/development/src/model/service/idp/IdpSessionRevalidator.cjs +55 -1
  143. package/dist/development/src/model/service/idp/IdpSessionRevalidator.cjs.map +1 -1
  144. package/dist/development/src/model/service/idp/IdpSessionRevalidator.js +55 -1
  145. package/dist/development/src/model/service/idp/IdpSessionRevalidator.js.map +1 -1
  146. package/dist/development/src/model/service/idp/PersonIdentityProviderManager.cjs +6 -0
  147. package/dist/development/src/model/service/idp/PersonIdentityProviderManager.cjs.map +1 -1
  148. package/dist/development/src/model/service/idp/PersonIdentityProviderManager.js +6 -0
  149. package/dist/development/src/model/service/idp/PersonIdentityProviderManager.js.map +1 -1
  150. package/dist/development/src/model/service/idp/providers/OIDCHelpers.cjs +69 -33
  151. package/dist/development/src/model/service/idp/providers/OIDCHelpers.cjs.map +1 -1
  152. package/dist/development/src/model/service/idp/providers/OIDCHelpers.js +69 -33
  153. package/dist/development/src/model/service/idp/providers/OIDCHelpers.js.map +1 -1
  154. package/dist/development/src/model/service/idp/providers/OIDCProvider.cjs +4 -1
  155. package/dist/development/src/model/service/idp/providers/OIDCProvider.cjs.map +1 -1
  156. package/dist/development/src/model/service/idp/providers/OIDCProvider.js +4 -1
  157. package/dist/development/src/model/service/idp/providers/OIDCProvider.js.map +1 -1
  158. package/dist/development/src/model/utils/DatabaseContext.cjs +7 -2
  159. package/dist/development/src/model/utils/DatabaseContext.cjs.map +1 -1
  160. package/dist/development/src/model/utils/DatabaseContext.js +8 -3
  161. package/dist/development/src/model/utils/DatabaseContext.js.map +1 -1
  162. package/dist/development/src/resolvers/ResolverFactory.cjs +6 -2
  163. package/dist/development/src/resolvers/ResolverFactory.cjs.map +1 -1
  164. package/dist/development/src/resolvers/ResolverFactory.js +6 -2
  165. package/dist/development/src/resolvers/ResolverFactory.js.map +1 -1
  166. package/dist/development/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.cjs +2 -1
  167. package/dist/development/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.cjs.map +1 -1
  168. package/dist/development/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.js +2 -1
  169. package/dist/development/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.js.map +1 -1
  170. package/dist/development/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.cjs +2 -1
  171. package/dist/development/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.cjs.map +1 -1
  172. package/dist/development/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.js +2 -1
  173. package/dist/development/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.js.map +1 -1
  174. package/dist/development/src/resolvers/mutation/configuration/AuthPolicyMutationResolver.cjs +2 -1
  175. package/dist/development/src/resolvers/mutation/configuration/AuthPolicyMutationResolver.cjs.map +1 -1
  176. package/dist/development/src/resolvers/mutation/configuration/AuthPolicyMutationResolver.js +2 -1
  177. package/dist/development/src/resolvers/mutation/configuration/AuthPolicyMutationResolver.js.map +1 -1
  178. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs +2 -1
  179. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs.map +1 -1
  180. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js +2 -1
  181. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js.map +1 -1
  182. package/dist/development/src/resolvers/mutation/identity/GlobalRolesMutationResolver.cjs +2 -1
  183. package/dist/development/src/resolvers/mutation/identity/GlobalRolesMutationResolver.cjs.map +1 -1
  184. package/dist/development/src/resolvers/mutation/identity/GlobalRolesMutationResolver.js +2 -1
  185. package/dist/development/src/resolvers/mutation/identity/GlobalRolesMutationResolver.js.map +1 -1
  186. package/dist/development/src/resolvers/mutation/idp/AddIDPMutationResolver.cjs +4 -2
  187. package/dist/development/src/resolvers/mutation/idp/AddIDPMutationResolver.cjs.map +1 -1
  188. package/dist/development/src/resolvers/mutation/idp/AddIDPMutationResolver.js +4 -2
  189. package/dist/development/src/resolvers/mutation/idp/AddIDPMutationResolver.js.map +1 -1
  190. package/dist/development/src/resolvers/mutation/idp/DisableIDPMutationResolver.cjs +2 -1
  191. package/dist/development/src/resolvers/mutation/idp/DisableIDPMutationResolver.cjs.map +1 -1
  192. package/dist/development/src/resolvers/mutation/idp/DisableIDPMutationResolver.js +2 -1
  193. package/dist/development/src/resolvers/mutation/idp/DisableIDPMutationResolver.js.map +1 -1
  194. package/dist/development/src/resolvers/mutation/idp/DisconnectMyIdentityProviderMutationResolver.cjs +2 -1
  195. package/dist/development/src/resolvers/mutation/idp/DisconnectMyIdentityProviderMutationResolver.cjs.map +1 -1
  196. package/dist/development/src/resolvers/mutation/idp/DisconnectMyIdentityProviderMutationResolver.js +2 -1
  197. package/dist/development/src/resolvers/mutation/idp/DisconnectMyIdentityProviderMutationResolver.js.map +1 -1
  198. package/dist/development/src/resolvers/mutation/idp/EnableIDPMutationResolver.cjs +2 -1
  199. package/dist/development/src/resolvers/mutation/idp/EnableIDPMutationResolver.cjs.map +1 -1
  200. package/dist/development/src/resolvers/mutation/idp/EnableIDPMutationResolver.js +2 -1
  201. package/dist/development/src/resolvers/mutation/idp/EnableIDPMutationResolver.js.map +1 -1
  202. package/dist/development/src/resolvers/mutation/idp/UpdateIDPMutationResolver.cjs +4 -2
  203. package/dist/development/src/resolvers/mutation/idp/UpdateIDPMutationResolver.cjs.map +1 -1
  204. package/dist/development/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js +4 -2
  205. package/dist/development/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js.map +1 -1
  206. package/dist/development/src/resolvers/mutation/idp/audit.cjs +1 -0
  207. package/dist/development/src/resolvers/mutation/idp/audit.cjs.map +1 -1
  208. package/dist/development/src/resolvers/mutation/idp/audit.js +1 -0
  209. package/dist/development/src/resolvers/mutation/idp/audit.js.map +1 -1
  210. package/dist/development/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.cjs +2 -1
  211. package/dist/development/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.cjs.map +1 -1
  212. package/dist/development/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.js +2 -1
  213. package/dist/development/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.js.map +1 -1
  214. package/dist/development/src/resolvers/mutation/person/ChangePasswordMutationResolver.cjs +2 -1
  215. package/dist/development/src/resolvers/mutation/person/ChangePasswordMutationResolver.cjs.map +1 -1
  216. package/dist/development/src/resolvers/mutation/person/ChangePasswordMutationResolver.js +2 -1
  217. package/dist/development/src/resolvers/mutation/person/ChangePasswordMutationResolver.js.map +1 -1
  218. package/dist/development/src/resolvers/mutation/person/ChangeProfileMutationResolver.cjs +2 -1
  219. package/dist/development/src/resolvers/mutation/person/ChangeProfileMutationResolver.cjs.map +1 -1
  220. package/dist/development/src/resolvers/mutation/person/ChangeProfileMutationResolver.js +2 -1
  221. package/dist/development/src/resolvers/mutation/person/ChangeProfileMutationResolver.js.map +1 -1
  222. package/dist/development/src/resolvers/mutation/person/DisablePersonMutationResolver.cjs +4 -3
  223. package/dist/development/src/resolvers/mutation/person/DisablePersonMutationResolver.cjs.map +1 -1
  224. package/dist/development/src/resolvers/mutation/person/DisablePersonMutationResolver.js +4 -3
  225. package/dist/development/src/resolvers/mutation/person/DisablePersonMutationResolver.js.map +1 -1
  226. package/dist/development/src/resolvers/mutation/person/EmailOtpMutationResolver.cjs +2 -1
  227. package/dist/development/src/resolvers/mutation/person/EmailOtpMutationResolver.cjs.map +1 -1
  228. package/dist/development/src/resolvers/mutation/person/EmailOtpMutationResolver.js +2 -1
  229. package/dist/development/src/resolvers/mutation/person/EmailOtpMutationResolver.js.map +1 -1
  230. package/dist/development/src/resolvers/mutation/person/EmailVerificationMutationResolver.cjs +2 -1
  231. package/dist/development/src/resolvers/mutation/person/EmailVerificationMutationResolver.cjs.map +1 -1
  232. package/dist/development/src/resolvers/mutation/person/EmailVerificationMutationResolver.js +2 -1
  233. package/dist/development/src/resolvers/mutation/person/EmailVerificationMutationResolver.js.map +1 -1
  234. package/dist/development/src/resolvers/mutation/person/EnablePersonMutationResolver.cjs +60 -0
  235. package/dist/development/src/resolvers/mutation/person/EnablePersonMutationResolver.cjs.map +1 -0
  236. package/dist/development/src/resolvers/mutation/person/EnablePersonMutationResolver.js +60 -0
  237. package/dist/development/src/resolvers/mutation/person/EnablePersonMutationResolver.js.map +1 -0
  238. package/dist/development/src/resolvers/mutation/person/ForceSignOutMutationResolver.cjs +2 -1
  239. package/dist/development/src/resolvers/mutation/person/ForceSignOutMutationResolver.cjs.map +1 -1
  240. package/dist/development/src/resolvers/mutation/person/ForceSignOutMutationResolver.js +2 -1
  241. package/dist/development/src/resolvers/mutation/person/ForceSignOutMutationResolver.js.map +1 -1
  242. package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.cjs +27 -1
  243. package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.cjs.map +1 -1
  244. package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.js +27 -1
  245. package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.js.map +1 -1
  246. package/dist/development/src/resolvers/mutation/person/InviteMutationResolver.cjs +2 -1
  247. package/dist/development/src/resolvers/mutation/person/InviteMutationResolver.cjs.map +1 -1
  248. package/dist/development/src/resolvers/mutation/person/InviteMutationResolver.js +2 -1
  249. package/dist/development/src/resolvers/mutation/person/InviteMutationResolver.js.map +1 -1
  250. package/dist/development/src/resolvers/mutation/person/OtpMutationResolver.cjs +2 -1
  251. package/dist/development/src/resolvers/mutation/person/OtpMutationResolver.cjs.map +1 -1
  252. package/dist/development/src/resolvers/mutation/person/OtpMutationResolver.js +2 -1
  253. package/dist/development/src/resolvers/mutation/person/OtpMutationResolver.js.map +1 -1
  254. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs +6 -1
  255. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs.map +1 -1
  256. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.js +6 -1
  257. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.js.map +1 -1
  258. package/dist/development/src/resolvers/mutation/person/RegenerateBackupCodesMutationResolver.cjs +2 -1
  259. package/dist/development/src/resolvers/mutation/person/RegenerateBackupCodesMutationResolver.cjs.map +1 -1
  260. package/dist/development/src/resolvers/mutation/person/RegenerateBackupCodesMutationResolver.js +2 -1
  261. package/dist/development/src/resolvers/mutation/person/RegenerateBackupCodesMutationResolver.js.map +1 -1
  262. package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs +2 -1
  263. package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs.map +1 -1
  264. package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.js +2 -1
  265. package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.js.map +1 -1
  266. package/dist/development/src/resolvers/mutation/person/ResetPersonMfaMutationResolver.cjs +2 -1
  267. package/dist/development/src/resolvers/mutation/person/ResetPersonMfaMutationResolver.cjs.map +1 -1
  268. package/dist/development/src/resolvers/mutation/person/ResetPersonMfaMutationResolver.js +2 -1
  269. package/dist/development/src/resolvers/mutation/person/ResetPersonMfaMutationResolver.js.map +1 -1
  270. package/dist/development/src/resolvers/mutation/person/RevokeSessionMutationResolver.cjs +2 -1
  271. package/dist/development/src/resolvers/mutation/person/RevokeSessionMutationResolver.cjs.map +1 -1
  272. package/dist/development/src/resolvers/mutation/person/RevokeSessionMutationResolver.js +2 -1
  273. package/dist/development/src/resolvers/mutation/person/RevokeSessionMutationResolver.js.map +1 -1
  274. package/dist/development/src/resolvers/mutation/person/SignInMutationResolver.cjs +4 -3
  275. package/dist/development/src/resolvers/mutation/person/SignInMutationResolver.cjs.map +1 -1
  276. package/dist/development/src/resolvers/mutation/person/SignInMutationResolver.js +4 -3
  277. package/dist/development/src/resolvers/mutation/person/SignInMutationResolver.js.map +1 -1
  278. package/dist/development/src/resolvers/mutation/person/SignOutMutationResolver.cjs +2 -1
  279. package/dist/development/src/resolvers/mutation/person/SignOutMutationResolver.cjs.map +1 -1
  280. package/dist/development/src/resolvers/mutation/person/SignOutMutationResolver.js +2 -1
  281. package/dist/development/src/resolvers/mutation/person/SignOutMutationResolver.js.map +1 -1
  282. package/dist/development/src/resolvers/mutation/person/SignUpMutationResolver.cjs +2 -1
  283. package/dist/development/src/resolvers/mutation/person/SignUpMutationResolver.cjs.map +1 -1
  284. package/dist/development/src/resolvers/mutation/person/SignUpMutationResolver.js +2 -1
  285. package/dist/development/src/resolvers/mutation/person/SignUpMutationResolver.js.map +1 -1
  286. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs +2 -1
  287. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs.map +1 -1
  288. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js +2 -1
  289. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js.map +1 -1
  290. package/dist/development/src/resolvers/mutation/project/CreateProjectMutationResolver.cjs +2 -1
  291. package/dist/development/src/resolvers/mutation/project/CreateProjectMutationResolver.cjs.map +1 -1
  292. package/dist/development/src/resolvers/mutation/project/CreateProjectMutationResolver.js +2 -1
  293. package/dist/development/src/resolvers/mutation/project/CreateProjectMutationResolver.js.map +1 -1
  294. package/dist/development/src/resolvers/mutation/project/SetProjectSecretMutationResolver.cjs +2 -1
  295. package/dist/development/src/resolvers/mutation/project/SetProjectSecretMutationResolver.cjs.map +1 -1
  296. package/dist/development/src/resolvers/mutation/project/SetProjectSecretMutationResolver.js +2 -1
  297. package/dist/development/src/resolvers/mutation/project/SetProjectSecretMutationResolver.js.map +1 -1
  298. package/dist/development/src/resolvers/mutation/project/UpdateProjectMutationResolver.cjs +2 -1
  299. package/dist/development/src/resolvers/mutation/project/UpdateProjectMutationResolver.cjs.map +1 -1
  300. package/dist/development/src/resolvers/mutation/project/UpdateProjectMutationResolver.js +2 -1
  301. package/dist/development/src/resolvers/mutation/project/UpdateProjectMutationResolver.js.map +1 -1
  302. package/dist/development/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.cjs +2 -1
  303. package/dist/development/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.cjs.map +1 -1
  304. package/dist/development/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.js +2 -1
  305. package/dist/development/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.js.map +1 -1
  306. package/dist/development/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.cjs +2 -1
  307. package/dist/development/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.cjs.map +1 -1
  308. package/dist/development/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.js +2 -1
  309. package/dist/development/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.js.map +1 -1
  310. package/dist/development/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.cjs +2 -1
  311. package/dist/development/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.cjs.map +1 -1
  312. package/dist/development/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.js +2 -1
  313. package/dist/development/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.js.map +1 -1
  314. package/dist/development/src/resolvers/query/ApiKeyQueryResolver.cjs +2 -1
  315. package/dist/development/src/resolvers/query/ApiKeyQueryResolver.cjs.map +1 -1
  316. package/dist/development/src/resolvers/query/ApiKeyQueryResolver.js +2 -1
  317. package/dist/development/src/resolvers/query/ApiKeyQueryResolver.js.map +1 -1
  318. package/dist/development/src/resolvers/query/AuthLogQueryResolver.cjs +2 -1
  319. package/dist/development/src/resolvers/query/AuthLogQueryResolver.cjs.map +1 -1
  320. package/dist/development/src/resolvers/query/AuthLogQueryResolver.js +2 -1
  321. package/dist/development/src/resolvers/query/AuthLogQueryResolver.js.map +1 -1
  322. package/dist/development/src/resolvers/query/AuthPolicyQueryResolver.cjs +2 -1
  323. package/dist/development/src/resolvers/query/AuthPolicyQueryResolver.cjs.map +1 -1
  324. package/dist/development/src/resolvers/query/AuthPolicyQueryResolver.js +2 -1
  325. package/dist/development/src/resolvers/query/AuthPolicyQueryResolver.js.map +1 -1
  326. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.cjs +2 -1
  327. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.cjs.map +1 -1
  328. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.js +2 -1
  329. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.js.map +1 -1
  330. package/dist/development/src/resolvers/query/IDPQueryResolver.cjs +2 -1
  331. package/dist/development/src/resolvers/query/IDPQueryResolver.cjs.map +1 -1
  332. package/dist/development/src/resolvers/query/IDPQueryResolver.js +2 -1
  333. package/dist/development/src/resolvers/query/IDPQueryResolver.js.map +1 -1
  334. package/dist/development/src/resolvers/query/MailTemplateQueryResolver.cjs +2 -1
  335. package/dist/development/src/resolvers/query/MailTemplateQueryResolver.cjs.map +1 -1
  336. package/dist/development/src/resolvers/query/MailTemplateQueryResolver.js +2 -1
  337. package/dist/development/src/resolvers/query/MailTemplateQueryResolver.js.map +1 -1
  338. package/dist/development/src/resolvers/query/PersonQueryResolver.cjs +2 -1
  339. package/dist/development/src/resolvers/query/PersonQueryResolver.cjs.map +1 -1
  340. package/dist/development/src/resolvers/query/PersonQueryResolver.js +2 -1
  341. package/dist/development/src/resolvers/query/PersonQueryResolver.js.map +1 -1
  342. package/dist/development/src/resolvers/query/ProjectMembersQueryResolver.cjs +2 -1
  343. package/dist/development/src/resolvers/query/ProjectMembersQueryResolver.cjs.map +1 -1
  344. package/dist/development/src/resolvers/query/ProjectMembersQueryResolver.js +2 -1
  345. package/dist/development/src/resolvers/query/ProjectMembersQueryResolver.js.map +1 -1
  346. package/dist/development/src/resolvers/query/ProjectQueryResolver.cjs +5 -3
  347. package/dist/development/src/resolvers/query/ProjectQueryResolver.cjs.map +1 -1
  348. package/dist/development/src/resolvers/query/ProjectQueryResolver.js +5 -3
  349. package/dist/development/src/resolvers/query/ProjectQueryResolver.js.map +1 -1
  350. package/dist/development/src/resolvers/responseHelpers/ApiKeyResponseFactory.cjs +2 -1
  351. package/dist/development/src/resolvers/responseHelpers/ApiKeyResponseFactory.cjs.map +1 -1
  352. package/dist/development/src/resolvers/responseHelpers/ApiKeyResponseFactory.js +2 -1
  353. package/dist/development/src/resolvers/responseHelpers/ApiKeyResponseFactory.js.map +1 -1
  354. package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.cjs +5 -0
  355. package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.cjs.map +1 -1
  356. package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.js +5 -0
  357. package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.js.map +1 -1
  358. package/dist/development/src/resolvers/responseHelpers/ProjectResponseFactory.cjs +23 -0
  359. package/dist/development/src/resolvers/responseHelpers/ProjectResponseFactory.cjs.map +1 -0
  360. package/dist/development/src/resolvers/responseHelpers/ProjectResponseFactory.js +23 -0
  361. package/dist/development/src/resolvers/responseHelpers/ProjectResponseFactory.js.map +1 -0
  362. package/dist/development/src/resolvers/responseHelpers/SignInResponseFactory.cjs +2 -1
  363. package/dist/development/src/resolvers/responseHelpers/SignInResponseFactory.cjs.map +1 -1
  364. package/dist/development/src/resolvers/responseHelpers/SignInResponseFactory.js +2 -1
  365. package/dist/development/src/resolvers/responseHelpers/SignInResponseFactory.js.map +1 -1
  366. package/dist/development/src/resolvers/types/IdentityTypeResolver.cjs +37 -4
  367. package/dist/development/src/resolvers/types/IdentityTypeResolver.cjs.map +1 -1
  368. package/dist/development/src/resolvers/types/IdentityTypeResolver.js +37 -4
  369. package/dist/development/src/resolvers/types/IdentityTypeResolver.js.map +1 -1
  370. package/dist/development/src/resolvers/types/PersonTypeResolver.cjs +30 -1
  371. package/dist/development/src/resolvers/types/PersonTypeResolver.cjs.map +1 -1
  372. package/dist/development/src/resolvers/types/PersonTypeResolver.js +30 -1
  373. package/dist/development/src/resolvers/types/PersonTypeResolver.js.map +1 -1
  374. package/dist/development/src/resolvers/types/ProjectTypeResolver.cjs +25 -1
  375. package/dist/development/src/resolvers/types/ProjectTypeResolver.cjs.map +1 -1
  376. package/dist/development/src/resolvers/types/ProjectTypeResolver.js +25 -1
  377. package/dist/development/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
  378. package/dist/development/src/schema/tenant.graphql.cjs +144 -0
  379. package/dist/development/src/schema/tenant.graphql.cjs.map +1 -1
  380. package/dist/development/src/schema/tenant.graphql.js +144 -0
  381. package/dist/development/src/schema/tenant.graphql.js.map +1 -1
  382. package/dist/production/index.cjs +32 -0
  383. package/dist/production/index.cjs.map +1 -1
  384. package/dist/production/index.js +33 -1
  385. package/dist/production/index.js.map +1 -1
  386. package/dist/production/src/TenantContainer.cjs +15 -3
  387. package/dist/production/src/TenantContainer.cjs.map +1 -1
  388. package/dist/production/src/TenantContainer.js +15 -3
  389. package/dist/production/src/TenantContainer.js.map +1 -1
  390. package/dist/production/src/bridges/system/IdentityFetcher.cjs +2 -1
  391. package/dist/production/src/bridges/system/IdentityFetcher.cjs.map +1 -1
  392. package/dist/production/src/bridges/system/IdentityFetcher.js +2 -1
  393. package/dist/production/src/bridges/system/IdentityFetcher.js.map +1 -1
  394. package/dist/production/src/migrations/2026-06-18-120000-idp-claim-mapping.cjs +10 -0
  395. package/dist/production/src/migrations/2026-06-18-120000-idp-claim-mapping.cjs.map +1 -0
  396. package/dist/production/src/migrations/2026-06-18-120000-idp-claim-mapping.js +11 -0
  397. package/dist/production/src/migrations/2026-06-18-120000-idp-claim-mapping.js.map +1 -0
  398. package/dist/production/src/migrations/2026-08-03-120000-person-enable-auth-log.cjs +9 -0
  399. package/dist/production/src/migrations/2026-08-03-120000-person-enable-auth-log.cjs.map +1 -0
  400. package/dist/production/src/migrations/2026-08-03-120000-person-enable-auth-log.js +10 -0
  401. package/dist/production/src/migrations/2026-08-03-120000-person-enable-auth-log.js.map +1 -0
  402. package/dist/production/src/migrations/2026-08-04-120000-config-panel.cjs +11 -0
  403. package/dist/production/src/migrations/2026-08-04-120000-config-panel.cjs.map +1 -0
  404. package/dist/production/src/migrations/2026-08-04-120000-config-panel.js +12 -0
  405. package/dist/production/src/migrations/2026-08-04-120000-config-panel.js.map +1 -0
  406. package/dist/production/src/migrations/2026-09-04-120000-idp-disable-local-authentication.cjs +18 -0
  407. package/dist/production/src/migrations/2026-09-04-120000-idp-disable-local-authentication.cjs.map +1 -0
  408. package/dist/production/src/migrations/2026-09-04-120000-idp-disable-local-authentication.js +19 -0
  409. package/dist/production/src/migrations/2026-09-04-120000-idp-disable-local-authentication.js.map +1 -0
  410. package/dist/production/src/migrations/runner.cjs +11 -2
  411. package/dist/production/src/migrations/runner.cjs.map +1 -1
  412. package/dist/production/src/migrations/runner.js +11 -2
  413. package/dist/production/src/migrations/runner.js.map +1 -1
  414. package/dist/production/src/migrations/snapshot.cjs +8 -2
  415. package/dist/production/src/migrations/snapshot.cjs.map +1 -1
  416. package/dist/production/src/migrations/snapshot.js +8 -2
  417. package/dist/production/src/migrations/snapshot.js.map +1 -1
  418. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.cjs +5 -3
  419. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.cjs.map +1 -1
  420. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.js +5 -3
  421. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.js.map +1 -1
  422. package/dist/production/src/model/commands/idp/CreateIdpCommand.cjs +8 -2
  423. package/dist/production/src/model/commands/idp/CreateIdpCommand.cjs.map +1 -1
  424. package/dist/production/src/model/commands/idp/CreateIdpCommand.js +8 -2
  425. package/dist/production/src/model/commands/idp/CreateIdpCommand.js.map +1 -1
  426. package/dist/production/src/model/commands/idp/UpdateIdpCommand.cjs +6 -2
  427. package/dist/production/src/model/commands/idp/UpdateIdpCommand.cjs.map +1 -1
  428. package/dist/production/src/model/commands/idp/UpdateIdpCommand.js +6 -2
  429. package/dist/production/src/model/commands/idp/UpdateIdpCommand.js.map +1 -1
  430. package/dist/production/src/model/commands/membership/{RemoveProjectMembershipsCommand.cjs → RemoveProjectMembershipCommand.cjs} +1 -1
  431. package/dist/production/src/model/commands/membership/RemoveProjectMembershipCommand.cjs.map +1 -0
  432. package/dist/production/src/model/commands/membership/{RemoveProjectMembershipsCommand.js → RemoveProjectMembershipCommand.js} +1 -1
  433. package/dist/production/src/model/commands/membership/RemoveProjectMembershipCommand.js.map +1 -0
  434. package/dist/production/src/model/commands/membership/UpdateProjectMemberCommand.cjs +2 -2
  435. package/dist/production/src/model/commands/membership/UpdateProjectMemberCommand.cjs.map +1 -1
  436. package/dist/production/src/model/commands/membership/UpdateProjectMemberCommand.js +1 -1
  437. package/dist/production/src/model/commands/membership/UpdateProjectMemberCommand.js.map +1 -1
  438. package/dist/production/src/model/commands/person/EnablePersonCommand.cjs +17 -0
  439. package/dist/production/src/model/commands/person/EnablePersonCommand.cjs.map +1 -0
  440. package/dist/production/src/model/commands/person/EnablePersonCommand.js +17 -0
  441. package/dist/production/src/model/commands/person/EnablePersonCommand.js.map +1 -0
  442. package/dist/production/src/model/queries/configuration/ConfigurationQuery.cjs +4 -0
  443. package/dist/production/src/model/queries/configuration/ConfigurationQuery.cjs.map +1 -1
  444. package/dist/production/src/model/queries/configuration/ConfigurationQuery.js +4 -0
  445. package/dist/production/src/model/queries/configuration/ConfigurationQuery.js.map +1 -1
  446. package/dist/production/src/model/queries/idp/LocalAuthDisablingIdpsQuery.cjs +21 -0
  447. package/dist/production/src/model/queries/idp/LocalAuthDisablingIdpsQuery.cjs.map +1 -0
  448. package/dist/production/src/model/queries/idp/LocalAuthDisablingIdpsQuery.js +21 -0
  449. package/dist/production/src/model/queries/idp/LocalAuthDisablingIdpsQuery.js.map +1 -0
  450. package/dist/production/src/model/queries/idp/PersonIdentityProvidersQuery.cjs +1 -1
  451. package/dist/production/src/model/queries/idp/PersonIdentityProvidersQuery.cjs.map +1 -1
  452. package/dist/production/src/model/queries/idp/PersonIdentityProvidersQuery.js +1 -1
  453. package/dist/production/src/model/queries/idp/PersonIdentityProvidersQuery.js.map +1 -1
  454. package/dist/production/src/model/queries/idp/helpers.cjs +3 -3
  455. package/dist/production/src/model/queries/idp/helpers.cjs.map +1 -1
  456. package/dist/production/src/model/queries/idp/helpers.js +3 -3
  457. package/dist/production/src/model/queries/idp/helpers.js.map +1 -1
  458. package/dist/production/src/model/queries/membership/ProjectMembersQuery.cjs +1 -1
  459. package/dist/production/src/model/queries/membership/ProjectMembersQuery.cjs.map +1 -1
  460. package/dist/production/src/model/queries/membership/ProjectMembersQuery.js +1 -1
  461. package/dist/production/src/model/queries/membership/ProjectMembersQuery.js.map +1 -1
  462. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.cjs +1 -1
  463. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.cjs.map +1 -1
  464. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.js +1 -1
  465. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.js.map +1 -1
  466. package/dist/production/src/model/service/AuthLogService.cjs +8 -2
  467. package/dist/production/src/model/service/AuthLogService.cjs.map +1 -1
  468. package/dist/production/src/model/service/AuthLogService.js +8 -2
  469. package/dist/production/src/model/service/AuthLogService.js.map +1 -1
  470. package/dist/production/src/model/service/IDPSignInManager.cjs +29 -2
  471. package/dist/production/src/model/service/IDPSignInManager.cjs.map +1 -1
  472. package/dist/production/src/model/service/IDPSignInManager.js +29 -2
  473. package/dist/production/src/model/service/IDPSignInManager.js.map +1 -1
  474. package/dist/production/src/model/service/PanelAccessResolver.cjs +31 -0
  475. package/dist/production/src/model/service/PanelAccessResolver.cjs.map +1 -0
  476. package/dist/production/src/model/service/PanelAccessResolver.js +31 -0
  477. package/dist/production/src/model/service/PanelAccessResolver.js.map +1 -0
  478. package/dist/production/src/model/service/PasswordResetManager.cjs +5 -0
  479. package/dist/production/src/model/service/PasswordResetManager.cjs.map +1 -1
  480. package/dist/production/src/model/service/PasswordResetManager.js +5 -0
  481. package/dist/production/src/model/service/PasswordResetManager.js.map +1 -1
  482. package/dist/production/src/model/service/PasswordlessSignInManager.cjs +19 -0
  483. package/dist/production/src/model/service/PasswordlessSignInManager.cjs.map +1 -1
  484. package/dist/production/src/model/service/PasswordlessSignInManager.js +19 -0
  485. package/dist/production/src/model/service/PasswordlessSignInManager.js.map +1 -1
  486. package/dist/production/src/model/service/PersonAccessManager.cjs +10 -2
  487. package/dist/production/src/model/service/PersonAccessManager.cjs.map +1 -1
  488. package/dist/production/src/model/service/PersonAccessManager.js +10 -2
  489. package/dist/production/src/model/service/PersonAccessManager.js.map +1 -1
  490. package/dist/production/src/model/service/SignInManager.cjs +5 -0
  491. package/dist/production/src/model/service/SignInManager.cjs.map +1 -1
  492. package/dist/production/src/model/service/SignInManager.js +5 -0
  493. package/dist/production/src/model/service/SignInManager.js.map +1 -1
  494. package/dist/production/src/model/service/apiKey/ApiKeyManager.cjs +4 -3
  495. package/dist/production/src/model/service/apiKey/ApiKeyManager.cjs.map +1 -1
  496. package/dist/production/src/model/service/apiKey/ApiKeyManager.js +4 -3
  497. package/dist/production/src/model/service/apiKey/ApiKeyManager.js.map +1 -1
  498. package/dist/production/src/model/service/apiKey/UnpersistedApiKeyManager.cjs +7 -0
  499. package/dist/production/src/model/service/apiKey/UnpersistedApiKeyManager.cjs.map +1 -1
  500. package/dist/production/src/model/service/apiKey/UnpersistedApiKeyManager.js +8 -1
  501. package/dist/production/src/model/service/apiKey/UnpersistedApiKeyManager.js.map +1 -1
  502. package/dist/production/src/model/service/idp/ClaimMapping.cjs +187 -0
  503. package/dist/production/src/model/service/idp/ClaimMapping.cjs.map +1 -0
  504. package/dist/production/src/model/service/idp/ClaimMapping.js +170 -0
  505. package/dist/production/src/model/service/idp/ClaimMapping.js.map +1 -0
  506. package/dist/production/src/model/service/idp/ClaimMappingEvaluator.cjs +155 -0
  507. package/dist/production/src/model/service/idp/ClaimMappingEvaluator.cjs.map +1 -0
  508. package/dist/production/src/model/service/idp/ClaimMappingEvaluator.js +155 -0
  509. package/dist/production/src/model/service/idp/ClaimMappingEvaluator.js.map +1 -0
  510. package/dist/production/src/model/service/idp/ClaimMappingValidation.cjs +83 -0
  511. package/dist/production/src/model/service/idp/ClaimMappingValidation.cjs.map +1 -0
  512. package/dist/production/src/model/service/idp/ClaimMappingValidation.js +83 -0
  513. package/dist/production/src/model/service/idp/ClaimMappingValidation.js.map +1 -0
  514. package/dist/production/src/model/service/idp/IDPClaimSyncService.cjs +260 -0
  515. package/dist/production/src/model/service/idp/IDPClaimSyncService.cjs.map +1 -0
  516. package/dist/production/src/model/service/idp/IDPClaimSyncService.js +260 -0
  517. package/dist/production/src/model/service/idp/IDPClaimSyncService.js.map +1 -0
  518. package/dist/production/src/model/service/idp/IDPManager.cjs +96 -20
  519. package/dist/production/src/model/service/idp/IDPManager.cjs.map +1 -1
  520. package/dist/production/src/model/service/idp/IDPManager.js +96 -20
  521. package/dist/production/src/model/service/idp/IDPManager.js.map +1 -1
  522. package/dist/production/src/model/service/idp/IdpSessionRevalidator.cjs +55 -1
  523. package/dist/production/src/model/service/idp/IdpSessionRevalidator.cjs.map +1 -1
  524. package/dist/production/src/model/service/idp/IdpSessionRevalidator.js +55 -1
  525. package/dist/production/src/model/service/idp/IdpSessionRevalidator.js.map +1 -1
  526. package/dist/production/src/model/service/idp/PersonIdentityProviderManager.cjs +6 -0
  527. package/dist/production/src/model/service/idp/PersonIdentityProviderManager.cjs.map +1 -1
  528. package/dist/production/src/model/service/idp/PersonIdentityProviderManager.js +6 -0
  529. package/dist/production/src/model/service/idp/PersonIdentityProviderManager.js.map +1 -1
  530. package/dist/production/src/model/service/idp/providers/OIDCHelpers.cjs +69 -33
  531. package/dist/production/src/model/service/idp/providers/OIDCHelpers.cjs.map +1 -1
  532. package/dist/production/src/model/service/idp/providers/OIDCHelpers.js +69 -33
  533. package/dist/production/src/model/service/idp/providers/OIDCHelpers.js.map +1 -1
  534. package/dist/production/src/model/service/idp/providers/OIDCProvider.cjs +4 -1
  535. package/dist/production/src/model/service/idp/providers/OIDCProvider.cjs.map +1 -1
  536. package/dist/production/src/model/service/idp/providers/OIDCProvider.js +4 -1
  537. package/dist/production/src/model/service/idp/providers/OIDCProvider.js.map +1 -1
  538. package/dist/production/src/model/utils/DatabaseContext.cjs +7 -2
  539. package/dist/production/src/model/utils/DatabaseContext.cjs.map +1 -1
  540. package/dist/production/src/model/utils/DatabaseContext.js +8 -3
  541. package/dist/production/src/model/utils/DatabaseContext.js.map +1 -1
  542. package/dist/production/src/resolvers/ResolverFactory.cjs +6 -2
  543. package/dist/production/src/resolvers/ResolverFactory.cjs.map +1 -1
  544. package/dist/production/src/resolvers/ResolverFactory.js +6 -2
  545. package/dist/production/src/resolvers/ResolverFactory.js.map +1 -1
  546. package/dist/production/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.cjs +2 -1
  547. package/dist/production/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.cjs.map +1 -1
  548. package/dist/production/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.js +2 -1
  549. package/dist/production/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.js.map +1 -1
  550. package/dist/production/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.cjs +2 -1
  551. package/dist/production/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.cjs.map +1 -1
  552. package/dist/production/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.js +2 -1
  553. package/dist/production/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.js.map +1 -1
  554. package/dist/production/src/resolvers/mutation/configuration/AuthPolicyMutationResolver.cjs +2 -1
  555. package/dist/production/src/resolvers/mutation/configuration/AuthPolicyMutationResolver.cjs.map +1 -1
  556. package/dist/production/src/resolvers/mutation/configuration/AuthPolicyMutationResolver.js +2 -1
  557. package/dist/production/src/resolvers/mutation/configuration/AuthPolicyMutationResolver.js.map +1 -1
  558. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs +2 -1
  559. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs.map +1 -1
  560. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js +2 -1
  561. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js.map +1 -1
  562. package/dist/production/src/resolvers/mutation/identity/GlobalRolesMutationResolver.cjs +2 -1
  563. package/dist/production/src/resolvers/mutation/identity/GlobalRolesMutationResolver.cjs.map +1 -1
  564. package/dist/production/src/resolvers/mutation/identity/GlobalRolesMutationResolver.js +2 -1
  565. package/dist/production/src/resolvers/mutation/identity/GlobalRolesMutationResolver.js.map +1 -1
  566. package/dist/production/src/resolvers/mutation/idp/AddIDPMutationResolver.cjs +4 -2
  567. package/dist/production/src/resolvers/mutation/idp/AddIDPMutationResolver.cjs.map +1 -1
  568. package/dist/production/src/resolvers/mutation/idp/AddIDPMutationResolver.js +4 -2
  569. package/dist/production/src/resolvers/mutation/idp/AddIDPMutationResolver.js.map +1 -1
  570. package/dist/production/src/resolvers/mutation/idp/DisableIDPMutationResolver.cjs +2 -1
  571. package/dist/production/src/resolvers/mutation/idp/DisableIDPMutationResolver.cjs.map +1 -1
  572. package/dist/production/src/resolvers/mutation/idp/DisableIDPMutationResolver.js +2 -1
  573. package/dist/production/src/resolvers/mutation/idp/DisableIDPMutationResolver.js.map +1 -1
  574. package/dist/production/src/resolvers/mutation/idp/DisconnectMyIdentityProviderMutationResolver.cjs +2 -1
  575. package/dist/production/src/resolvers/mutation/idp/DisconnectMyIdentityProviderMutationResolver.cjs.map +1 -1
  576. package/dist/production/src/resolvers/mutation/idp/DisconnectMyIdentityProviderMutationResolver.js +2 -1
  577. package/dist/production/src/resolvers/mutation/idp/DisconnectMyIdentityProviderMutationResolver.js.map +1 -1
  578. package/dist/production/src/resolvers/mutation/idp/EnableIDPMutationResolver.cjs +2 -1
  579. package/dist/production/src/resolvers/mutation/idp/EnableIDPMutationResolver.cjs.map +1 -1
  580. package/dist/production/src/resolvers/mutation/idp/EnableIDPMutationResolver.js +2 -1
  581. package/dist/production/src/resolvers/mutation/idp/EnableIDPMutationResolver.js.map +1 -1
  582. package/dist/production/src/resolvers/mutation/idp/UpdateIDPMutationResolver.cjs +4 -2
  583. package/dist/production/src/resolvers/mutation/idp/UpdateIDPMutationResolver.cjs.map +1 -1
  584. package/dist/production/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js +4 -2
  585. package/dist/production/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js.map +1 -1
  586. package/dist/production/src/resolvers/mutation/idp/audit.cjs +1 -0
  587. package/dist/production/src/resolvers/mutation/idp/audit.cjs.map +1 -1
  588. package/dist/production/src/resolvers/mutation/idp/audit.js +1 -0
  589. package/dist/production/src/resolvers/mutation/idp/audit.js.map +1 -1
  590. package/dist/production/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.cjs +2 -1
  591. package/dist/production/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.cjs.map +1 -1
  592. package/dist/production/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.js +2 -1
  593. package/dist/production/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.js.map +1 -1
  594. package/dist/production/src/resolvers/mutation/person/ChangePasswordMutationResolver.cjs +2 -1
  595. package/dist/production/src/resolvers/mutation/person/ChangePasswordMutationResolver.cjs.map +1 -1
  596. package/dist/production/src/resolvers/mutation/person/ChangePasswordMutationResolver.js +2 -1
  597. package/dist/production/src/resolvers/mutation/person/ChangePasswordMutationResolver.js.map +1 -1
  598. package/dist/production/src/resolvers/mutation/person/ChangeProfileMutationResolver.cjs +2 -1
  599. package/dist/production/src/resolvers/mutation/person/ChangeProfileMutationResolver.cjs.map +1 -1
  600. package/dist/production/src/resolvers/mutation/person/ChangeProfileMutationResolver.js +2 -1
  601. package/dist/production/src/resolvers/mutation/person/ChangeProfileMutationResolver.js.map +1 -1
  602. package/dist/production/src/resolvers/mutation/person/DisablePersonMutationResolver.cjs +4 -3
  603. package/dist/production/src/resolvers/mutation/person/DisablePersonMutationResolver.cjs.map +1 -1
  604. package/dist/production/src/resolvers/mutation/person/DisablePersonMutationResolver.js +4 -3
  605. package/dist/production/src/resolvers/mutation/person/DisablePersonMutationResolver.js.map +1 -1
  606. package/dist/production/src/resolvers/mutation/person/EmailOtpMutationResolver.cjs +2 -1
  607. package/dist/production/src/resolvers/mutation/person/EmailOtpMutationResolver.cjs.map +1 -1
  608. package/dist/production/src/resolvers/mutation/person/EmailOtpMutationResolver.js +2 -1
  609. package/dist/production/src/resolvers/mutation/person/EmailOtpMutationResolver.js.map +1 -1
  610. package/dist/production/src/resolvers/mutation/person/EmailVerificationMutationResolver.cjs +2 -1
  611. package/dist/production/src/resolvers/mutation/person/EmailVerificationMutationResolver.cjs.map +1 -1
  612. package/dist/production/src/resolvers/mutation/person/EmailVerificationMutationResolver.js +2 -1
  613. package/dist/production/src/resolvers/mutation/person/EmailVerificationMutationResolver.js.map +1 -1
  614. package/dist/production/src/resolvers/mutation/person/EnablePersonMutationResolver.cjs +60 -0
  615. package/dist/production/src/resolvers/mutation/person/EnablePersonMutationResolver.cjs.map +1 -0
  616. package/dist/production/src/resolvers/mutation/person/EnablePersonMutationResolver.js +60 -0
  617. package/dist/production/src/resolvers/mutation/person/EnablePersonMutationResolver.js.map +1 -0
  618. package/dist/production/src/resolvers/mutation/person/ForceSignOutMutationResolver.cjs +2 -1
  619. package/dist/production/src/resolvers/mutation/person/ForceSignOutMutationResolver.cjs.map +1 -1
  620. package/dist/production/src/resolvers/mutation/person/ForceSignOutMutationResolver.js +2 -1
  621. package/dist/production/src/resolvers/mutation/person/ForceSignOutMutationResolver.js.map +1 -1
  622. package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.cjs +27 -1
  623. package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.cjs.map +1 -1
  624. package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.js +27 -1
  625. package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.js.map +1 -1
  626. package/dist/production/src/resolvers/mutation/person/InviteMutationResolver.cjs +2 -1
  627. package/dist/production/src/resolvers/mutation/person/InviteMutationResolver.cjs.map +1 -1
  628. package/dist/production/src/resolvers/mutation/person/InviteMutationResolver.js +2 -1
  629. package/dist/production/src/resolvers/mutation/person/InviteMutationResolver.js.map +1 -1
  630. package/dist/production/src/resolvers/mutation/person/OtpMutationResolver.cjs +2 -1
  631. package/dist/production/src/resolvers/mutation/person/OtpMutationResolver.cjs.map +1 -1
  632. package/dist/production/src/resolvers/mutation/person/OtpMutationResolver.js +2 -1
  633. package/dist/production/src/resolvers/mutation/person/OtpMutationResolver.js.map +1 -1
  634. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs +6 -1
  635. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs.map +1 -1
  636. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.js +6 -1
  637. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.js.map +1 -1
  638. package/dist/production/src/resolvers/mutation/person/RegenerateBackupCodesMutationResolver.cjs +2 -1
  639. package/dist/production/src/resolvers/mutation/person/RegenerateBackupCodesMutationResolver.cjs.map +1 -1
  640. package/dist/production/src/resolvers/mutation/person/RegenerateBackupCodesMutationResolver.js +2 -1
  641. package/dist/production/src/resolvers/mutation/person/RegenerateBackupCodesMutationResolver.js.map +1 -1
  642. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs +2 -1
  643. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs.map +1 -1
  644. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.js +2 -1
  645. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.js.map +1 -1
  646. package/dist/production/src/resolvers/mutation/person/ResetPersonMfaMutationResolver.cjs +2 -1
  647. package/dist/production/src/resolvers/mutation/person/ResetPersonMfaMutationResolver.cjs.map +1 -1
  648. package/dist/production/src/resolvers/mutation/person/ResetPersonMfaMutationResolver.js +2 -1
  649. package/dist/production/src/resolvers/mutation/person/ResetPersonMfaMutationResolver.js.map +1 -1
  650. package/dist/production/src/resolvers/mutation/person/RevokeSessionMutationResolver.cjs +2 -1
  651. package/dist/production/src/resolvers/mutation/person/RevokeSessionMutationResolver.cjs.map +1 -1
  652. package/dist/production/src/resolvers/mutation/person/RevokeSessionMutationResolver.js +2 -1
  653. package/dist/production/src/resolvers/mutation/person/RevokeSessionMutationResolver.js.map +1 -1
  654. package/dist/production/src/resolvers/mutation/person/SignInMutationResolver.cjs +4 -3
  655. package/dist/production/src/resolvers/mutation/person/SignInMutationResolver.cjs.map +1 -1
  656. package/dist/production/src/resolvers/mutation/person/SignInMutationResolver.js +4 -3
  657. package/dist/production/src/resolvers/mutation/person/SignInMutationResolver.js.map +1 -1
  658. package/dist/production/src/resolvers/mutation/person/SignOutMutationResolver.cjs +2 -1
  659. package/dist/production/src/resolvers/mutation/person/SignOutMutationResolver.cjs.map +1 -1
  660. package/dist/production/src/resolvers/mutation/person/SignOutMutationResolver.js +2 -1
  661. package/dist/production/src/resolvers/mutation/person/SignOutMutationResolver.js.map +1 -1
  662. package/dist/production/src/resolvers/mutation/person/SignUpMutationResolver.cjs +2 -1
  663. package/dist/production/src/resolvers/mutation/person/SignUpMutationResolver.cjs.map +1 -1
  664. package/dist/production/src/resolvers/mutation/person/SignUpMutationResolver.js +2 -1
  665. package/dist/production/src/resolvers/mutation/person/SignUpMutationResolver.js.map +1 -1
  666. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs +2 -1
  667. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs.map +1 -1
  668. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js +2 -1
  669. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js.map +1 -1
  670. package/dist/production/src/resolvers/mutation/project/CreateProjectMutationResolver.cjs +2 -1
  671. package/dist/production/src/resolvers/mutation/project/CreateProjectMutationResolver.cjs.map +1 -1
  672. package/dist/production/src/resolvers/mutation/project/CreateProjectMutationResolver.js +2 -1
  673. package/dist/production/src/resolvers/mutation/project/CreateProjectMutationResolver.js.map +1 -1
  674. package/dist/production/src/resolvers/mutation/project/SetProjectSecretMutationResolver.cjs +2 -1
  675. package/dist/production/src/resolvers/mutation/project/SetProjectSecretMutationResolver.cjs.map +1 -1
  676. package/dist/production/src/resolvers/mutation/project/SetProjectSecretMutationResolver.js +2 -1
  677. package/dist/production/src/resolvers/mutation/project/SetProjectSecretMutationResolver.js.map +1 -1
  678. package/dist/production/src/resolvers/mutation/project/UpdateProjectMutationResolver.cjs +2 -1
  679. package/dist/production/src/resolvers/mutation/project/UpdateProjectMutationResolver.cjs.map +1 -1
  680. package/dist/production/src/resolvers/mutation/project/UpdateProjectMutationResolver.js +2 -1
  681. package/dist/production/src/resolvers/mutation/project/UpdateProjectMutationResolver.js.map +1 -1
  682. package/dist/production/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.cjs +2 -1
  683. package/dist/production/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.cjs.map +1 -1
  684. package/dist/production/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.js +2 -1
  685. package/dist/production/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.js.map +1 -1
  686. package/dist/production/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.cjs +2 -1
  687. package/dist/production/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.cjs.map +1 -1
  688. package/dist/production/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.js +2 -1
  689. package/dist/production/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.js.map +1 -1
  690. package/dist/production/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.cjs +2 -1
  691. package/dist/production/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.cjs.map +1 -1
  692. package/dist/production/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.js +2 -1
  693. package/dist/production/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.js.map +1 -1
  694. package/dist/production/src/resolvers/query/ApiKeyQueryResolver.cjs +2 -1
  695. package/dist/production/src/resolvers/query/ApiKeyQueryResolver.cjs.map +1 -1
  696. package/dist/production/src/resolvers/query/ApiKeyQueryResolver.js +2 -1
  697. package/dist/production/src/resolvers/query/ApiKeyQueryResolver.js.map +1 -1
  698. package/dist/production/src/resolvers/query/AuthLogQueryResolver.cjs +2 -1
  699. package/dist/production/src/resolvers/query/AuthLogQueryResolver.cjs.map +1 -1
  700. package/dist/production/src/resolvers/query/AuthLogQueryResolver.js +2 -1
  701. package/dist/production/src/resolvers/query/AuthLogQueryResolver.js.map +1 -1
  702. package/dist/production/src/resolvers/query/AuthPolicyQueryResolver.cjs +2 -1
  703. package/dist/production/src/resolvers/query/AuthPolicyQueryResolver.cjs.map +1 -1
  704. package/dist/production/src/resolvers/query/AuthPolicyQueryResolver.js +2 -1
  705. package/dist/production/src/resolvers/query/AuthPolicyQueryResolver.js.map +1 -1
  706. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.cjs +2 -1
  707. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.cjs.map +1 -1
  708. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.js +2 -1
  709. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.js.map +1 -1
  710. package/dist/production/src/resolvers/query/IDPQueryResolver.cjs +2 -1
  711. package/dist/production/src/resolvers/query/IDPQueryResolver.cjs.map +1 -1
  712. package/dist/production/src/resolvers/query/IDPQueryResolver.js +2 -1
  713. package/dist/production/src/resolvers/query/IDPQueryResolver.js.map +1 -1
  714. package/dist/production/src/resolvers/query/MailTemplateQueryResolver.cjs +2 -1
  715. package/dist/production/src/resolvers/query/MailTemplateQueryResolver.cjs.map +1 -1
  716. package/dist/production/src/resolvers/query/MailTemplateQueryResolver.js +2 -1
  717. package/dist/production/src/resolvers/query/MailTemplateQueryResolver.js.map +1 -1
  718. package/dist/production/src/resolvers/query/PersonQueryResolver.cjs +2 -1
  719. package/dist/production/src/resolvers/query/PersonQueryResolver.cjs.map +1 -1
  720. package/dist/production/src/resolvers/query/PersonQueryResolver.js +2 -1
  721. package/dist/production/src/resolvers/query/PersonQueryResolver.js.map +1 -1
  722. package/dist/production/src/resolvers/query/ProjectMembersQueryResolver.cjs +2 -1
  723. package/dist/production/src/resolvers/query/ProjectMembersQueryResolver.cjs.map +1 -1
  724. package/dist/production/src/resolvers/query/ProjectMembersQueryResolver.js +2 -1
  725. package/dist/production/src/resolvers/query/ProjectMembersQueryResolver.js.map +1 -1
  726. package/dist/production/src/resolvers/query/ProjectQueryResolver.cjs +5 -3
  727. package/dist/production/src/resolvers/query/ProjectQueryResolver.cjs.map +1 -1
  728. package/dist/production/src/resolvers/query/ProjectQueryResolver.js +5 -3
  729. package/dist/production/src/resolvers/query/ProjectQueryResolver.js.map +1 -1
  730. package/dist/production/src/resolvers/responseHelpers/ApiKeyResponseFactory.cjs +2 -1
  731. package/dist/production/src/resolvers/responseHelpers/ApiKeyResponseFactory.cjs.map +1 -1
  732. package/dist/production/src/resolvers/responseHelpers/ApiKeyResponseFactory.js +2 -1
  733. package/dist/production/src/resolvers/responseHelpers/ApiKeyResponseFactory.js.map +1 -1
  734. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.cjs +5 -0
  735. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.cjs.map +1 -1
  736. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.js +5 -0
  737. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.js.map +1 -1
  738. package/dist/production/src/resolvers/responseHelpers/ProjectResponseFactory.cjs +23 -0
  739. package/dist/production/src/resolvers/responseHelpers/ProjectResponseFactory.cjs.map +1 -0
  740. package/dist/production/src/resolvers/responseHelpers/ProjectResponseFactory.js +23 -0
  741. package/dist/production/src/resolvers/responseHelpers/ProjectResponseFactory.js.map +1 -0
  742. package/dist/production/src/resolvers/responseHelpers/SignInResponseFactory.cjs +2 -1
  743. package/dist/production/src/resolvers/responseHelpers/SignInResponseFactory.cjs.map +1 -1
  744. package/dist/production/src/resolvers/responseHelpers/SignInResponseFactory.js +2 -1
  745. package/dist/production/src/resolvers/responseHelpers/SignInResponseFactory.js.map +1 -1
  746. package/dist/production/src/resolvers/types/IdentityTypeResolver.cjs +37 -4
  747. package/dist/production/src/resolvers/types/IdentityTypeResolver.cjs.map +1 -1
  748. package/dist/production/src/resolvers/types/IdentityTypeResolver.js +37 -4
  749. package/dist/production/src/resolvers/types/IdentityTypeResolver.js.map +1 -1
  750. package/dist/production/src/resolvers/types/PersonTypeResolver.cjs +30 -1
  751. package/dist/production/src/resolvers/types/PersonTypeResolver.cjs.map +1 -1
  752. package/dist/production/src/resolvers/types/PersonTypeResolver.js +30 -1
  753. package/dist/production/src/resolvers/types/PersonTypeResolver.js.map +1 -1
  754. package/dist/production/src/resolvers/types/ProjectTypeResolver.cjs +25 -1
  755. package/dist/production/src/resolvers/types/ProjectTypeResolver.cjs.map +1 -1
  756. package/dist/production/src/resolvers/types/ProjectTypeResolver.js +25 -1
  757. package/dist/production/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
  758. package/dist/production/src/schema/tenant.graphql.cjs +144 -0
  759. package/dist/production/src/schema/tenant.graphql.cjs.map +1 -1
  760. package/dist/production/src/schema/tenant.graphql.js +144 -0
  761. package/dist/production/src/schema/tenant.graphql.js.map +1 -1
  762. package/dist/tests/cases/integration/mocked/configurationPanel.test.d.ts +2 -0
  763. package/dist/tests/cases/integration/mocked/configurationPanel.test.d.ts.map +1 -0
  764. package/dist/tests/cases/integration/mocked/disablePersonMutation.test.d.ts +2 -0
  765. package/dist/tests/cases/integration/mocked/disablePersonMutation.test.d.ts.map +1 -0
  766. package/dist/tests/cases/integration/mocked/enablePersonMutation.test.d.ts +2 -0
  767. package/dist/tests/cases/integration/mocked/enablePersonMutation.test.d.ts.map +1 -0
  768. package/dist/tests/cases/integration/mocked/gql/addProjectMember.d.ts.map +1 -1
  769. package/dist/tests/cases/integration/mocked/gql/changeMyPassword.d.ts.map +1 -1
  770. package/dist/tests/cases/integration/mocked/gql/changeMyProfile.d.ts.map +1 -1
  771. package/dist/tests/cases/integration/mocked/gql/changePassword.d.ts.map +1 -1
  772. package/dist/tests/cases/integration/mocked/gql/changeProfile.d.ts.map +1 -1
  773. package/dist/tests/cases/integration/mocked/gql/confirmOtp.d.ts.map +1 -1
  774. package/dist/tests/cases/integration/mocked/gql/createApiKey.d.ts.map +1 -1
  775. package/dist/tests/cases/integration/mocked/gql/createResetPasswordRequest.d.ts.map +1 -1
  776. package/dist/tests/cases/integration/mocked/gql/createSessionToken.d.ts.map +1 -1
  777. package/dist/tests/cases/integration/mocked/gql/emailOtp.d.ts.map +1 -1
  778. package/dist/tests/cases/integration/mocked/gql/emailVerification.d.ts.map +1 -1
  779. package/dist/tests/cases/integration/mocked/gql/invite.d.ts.map +1 -1
  780. package/dist/tests/cases/integration/mocked/gql/myIdentityProviders.d.ts.map +1 -1
  781. package/dist/tests/cases/integration/mocked/gql/passwordless.d.ts +4 -1
  782. package/dist/tests/cases/integration/mocked/gql/passwordless.d.ts.map +1 -1
  783. package/dist/tests/cases/integration/mocked/gql/prepareOtp.d.ts.map +1 -1
  784. package/dist/tests/cases/integration/mocked/gql/resetPassword.d.ts.map +1 -1
  785. package/dist/tests/cases/integration/mocked/gql/signIn.d.ts.map +1 -1
  786. package/dist/tests/cases/integration/mocked/gql/signInIdp.d.ts.map +1 -1
  787. package/dist/tests/cases/integration/mocked/gql/signUp.d.ts.map +1 -1
  788. package/dist/tests/cases/integration/mocked/gql/unmanagedInvite.d.ts.map +1 -1
  789. package/dist/tests/cases/integration/mocked/gql/updateProjectMember.d.ts.map +1 -1
  790. package/dist/tests/cases/integration/mocked/idpClaimMappingConfig.test.d.ts +2 -0
  791. package/dist/tests/cases/integration/mocked/idpClaimMappingConfig.test.d.ts.map +1 -0
  792. package/dist/tests/cases/integration/mocked/localAuthenticationDisabled.test.d.ts +2 -0
  793. package/dist/tests/cases/integration/mocked/localAuthenticationDisabled.test.d.ts.map +1 -0
  794. package/dist/tests/cases/integration/mocked/permissionsQuery.test.d.ts +2 -0
  795. package/dist/tests/cases/integration/mocked/permissionsQuery.test.d.ts.map +1 -0
  796. package/dist/tests/cases/integration/mocked/signInIdpClaimMapping.test.d.ts +2 -0
  797. package/dist/tests/cases/integration/mocked/signInIdpClaimMapping.test.d.ts.map +1 -0
  798. package/dist/tests/cases/integration/mocked/signInIdpClaimMappingFixes.test.d.ts +2 -0
  799. package/dist/tests/cases/integration/mocked/signInIdpClaimMappingFixes.test.d.ts.map +1 -0
  800. package/dist/tests/cases/integration/mocked/signInIdpClaimMappingSafety.test.d.ts +2 -0
  801. package/dist/tests/cases/integration/mocked/signInIdpClaimMappingSafety.test.d.ts.map +1 -0
  802. package/dist/tests/cases/integration/mocked/sql/authLogSql.d.ts.map +1 -1
  803. package/dist/tests/cases/integration/mocked/sql/authPolicySql.d.ts.map +1 -1
  804. package/dist/tests/cases/integration/mocked/sql/consumeBackupCodeSql.d.ts.map +1 -1
  805. package/dist/tests/cases/integration/mocked/sql/createApiKeySql.d.ts.map +1 -1
  806. package/dist/tests/cases/integration/mocked/sql/createIdentitySql.d.ts.map +1 -1
  807. package/dist/tests/cases/integration/mocked/sql/createMembershipSql.d.ts.map +1 -1
  808. package/dist/tests/cases/integration/mocked/sql/createMembershipVariableSql.d.ts.map +1 -1
  809. package/dist/tests/cases/integration/mocked/sql/createPersonSql.d.ts.map +1 -1
  810. package/dist/tests/cases/integration/mocked/sql/createPersonTokenSql.d.ts.map +1 -1
  811. package/dist/tests/cases/integration/mocked/sql/createSessionKeySql.d.ts.map +1 -1
  812. package/dist/tests/cases/integration/mocked/sql/disableApiKeySql.d.ts.map +1 -1
  813. package/dist/tests/cases/integration/mocked/sql/disableOneOffKeySql.d.ts.map +1 -1
  814. package/dist/tests/cases/integration/mocked/sql/emailOtpSql.d.ts.map +1 -1
  815. package/dist/tests/cases/integration/mocked/sql/generateBackupCodesSql.d.ts.map +1 -1
  816. package/dist/tests/cases/integration/mocked/sql/getApiKeySql.d.ts.map +1 -1
  817. package/dist/tests/cases/integration/mocked/sql/getConfigSql.d.ts.map +1 -1
  818. package/dist/tests/cases/integration/mocked/sql/getIdentityByIdSql.d.ts.map +1 -1
  819. package/dist/tests/cases/integration/mocked/sql/getIdentityProjectsSql.d.ts.map +1 -1
  820. package/dist/tests/cases/integration/mocked/sql/getIdpBySlugSql.d.ts.map +1 -1
  821. package/dist/tests/cases/integration/mocked/sql/getIdpSessionByApiKeySql.d.ts.map +1 -1
  822. package/dist/tests/cases/integration/mocked/sql/getMailTemplateSql.d.ts.map +1 -1
  823. package/dist/tests/cases/integration/mocked/sql/getNextLoginAttemptSql.d.ts.map +1 -1
  824. package/dist/tests/cases/integration/mocked/sql/getNextMailAttemptSql.d.ts +1 -1
  825. package/dist/tests/cases/integration/mocked/sql/getNextMailAttemptSql.d.ts.map +1 -1
  826. package/dist/tests/cases/integration/mocked/sql/getPersonByEmailSql.d.ts.map +1 -1
  827. package/dist/tests/cases/integration/mocked/sql/getPersonByIdSql.d.ts.map +1 -1
  828. package/dist/tests/cases/integration/mocked/sql/getPersonByIdentity.d.ts.map +1 -1
  829. package/dist/tests/cases/integration/mocked/sql/getPersonByIdpSql.d.ts.map +1 -1
  830. package/dist/tests/cases/integration/mocked/sql/getPersonsByIdentitySql.d.ts.map +1 -1
  831. package/dist/tests/cases/integration/mocked/sql/getProjectBySlugSql.d.ts +1 -1
  832. package/dist/tests/cases/integration/mocked/sql/getProjectBySlugSql.d.ts.map +1 -1
  833. package/dist/tests/cases/integration/mocked/sql/getProjectMembershipSql.d.ts.map +1 -1
  834. package/dist/tests/cases/integration/mocked/sql/listApiKeysSql.d.ts.map +1 -1
  835. package/dist/tests/cases/integration/mocked/sql/listPersonsSql.d.ts +2 -0
  836. package/dist/tests/cases/integration/mocked/sql/listPersonsSql.d.ts.map +1 -1
  837. package/dist/tests/cases/integration/mocked/sql/listProjectSecretsSql.d.ts.map +1 -1
  838. package/dist/tests/cases/integration/mocked/sql/listSessionsSql.d.ts.map +1 -1
  839. package/dist/tests/cases/integration/mocked/sql/localAuthDisablingIdpsSql.d.ts +10 -0
  840. package/dist/tests/cases/integration/mocked/sql/localAuthDisablingIdpsSql.d.ts.map +1 -0
  841. package/dist/tests/cases/integration/mocked/sql/loginHistorySql.d.ts.map +1 -1
  842. package/dist/tests/cases/integration/mocked/sql/patchVariablesSql.d.ts.map +1 -1
  843. package/dist/tests/cases/integration/mocked/sql/personIdentityProvidersSql.d.ts +1 -0
  844. package/dist/tests/cases/integration/mocked/sql/personIdentityProvidersSql.d.ts.map +1 -1
  845. package/dist/tests/cases/integration/mocked/sql/removeMembershipSql.d.ts +8 -0
  846. package/dist/tests/cases/integration/mocked/sql/removeMembershipSql.d.ts.map +1 -0
  847. package/dist/tests/cases/integration/mocked/sql/selectMembershipsSql.d.ts.map +1 -1
  848. package/dist/tests/cases/integration/mocked/sql/setEmailOtpEnabledSql.d.ts.map +1 -1
  849. package/dist/tests/cases/integration/mocked/sql/sqlTransaction.d.ts.map +1 -1
  850. package/dist/tests/cases/integration/mocked/sql/updatePesonNameSql.d.ts.map +1 -1
  851. package/dist/tests/cases/integration/mocked/sql/updatePesonPasswordSql.d.ts.map +1 -1
  852. package/dist/tests/cases/unit/databaseContextRetry.test.d.ts +2 -0
  853. package/dist/tests/cases/unit/databaseContextRetry.test.d.ts.map +1 -0
  854. package/dist/tests/cases/unit/idp/claimMappingEvaluator.test.d.ts +2 -0
  855. package/dist/tests/cases/unit/idp/claimMappingEvaluator.test.d.ts.map +1 -0
  856. package/dist/tests/cases/unit/idp/claimMappingValidation.test.d.ts +2 -0
  857. package/dist/tests/cases/unit/idp/claimMappingValidation.test.d.ts.map +1 -0
  858. package/dist/tests/cases/unit/idp/idpManagerConfigMerge.test.d.ts +2 -0
  859. package/dist/tests/cases/unit/idp/idpManagerConfigMerge.test.d.ts.map +1 -0
  860. package/dist/tests/cases/unit/idp/idpManagerUnknownConfigKeys.test.d.ts +2 -0
  861. package/dist/tests/cases/unit/idp/idpManagerUnknownConfigKeys.test.d.ts.map +1 -0
  862. package/dist/tests/cases/unit/idp/oidcClaims.test.d.ts +2 -0
  863. package/dist/tests/cases/unit/idp/oidcClaims.test.d.ts.map +1 -0
  864. package/dist/tests/cases/unit/panelAccessResolver.test.d.ts +2 -0
  865. package/dist/tests/cases/unit/panelAccessResolver.test.d.ts.map +1 -0
  866. package/dist/tests/cases/unit/updateConfigurationCommand.test.d.ts +2 -0
  867. package/dist/tests/cases/unit/updateConfigurationCommand.test.d.ts.map +1 -0
  868. package/dist/tests/src/IdPMock.d.ts.map +1 -1
  869. package/dist/tests/src/dbUtils.d.ts.map +1 -1
  870. package/dist/tests/src/tags.d.ts.map +1 -1
  871. package/dist/tests/src/testGraphql.d.ts.map +1 -1
  872. package/dist/tests/src/testTenant.d.ts +7 -1
  873. package/dist/tests/src/testTenant.d.ts.map +1 -1
  874. package/dist/tests/src/testUuid.d.ts.map +1 -1
  875. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  876. package/dist/types/TenantContainer.d.ts +21 -13
  877. package/dist/types/TenantContainer.d.ts.map +1 -1
  878. package/dist/types/bridges/system/IdentityFetcher.d.ts +2 -2
  879. package/dist/types/bridges/system/IdentityFetcher.d.ts.map +1 -1
  880. package/dist/types/exceptions.d.ts.map +1 -1
  881. package/dist/types/migrations/2026-06-18-120000-idp-claim-mapping.d.ts +3 -0
  882. package/dist/types/migrations/2026-06-18-120000-idp-claim-mapping.d.ts.map +1 -0
  883. package/dist/types/migrations/2026-08-03-120000-person-enable-auth-log.d.ts +3 -0
  884. package/dist/types/migrations/2026-08-03-120000-person-enable-auth-log.d.ts.map +1 -0
  885. package/dist/types/migrations/2026-08-04-120000-config-panel.d.ts +3 -0
  886. package/dist/types/migrations/2026-08-04-120000-config-panel.d.ts.map +1 -0
  887. package/dist/types/migrations/2026-09-04-120000-idp-disable-local-authentication.d.ts +3 -0
  888. package/dist/types/migrations/2026-09-04-120000-idp-disable-local-authentication.d.ts.map +1 -0
  889. package/dist/types/migrations/runner.d.ts.map +1 -1
  890. package/dist/types/migrations/snapshot-factory.d.ts.map +1 -1
  891. package/dist/types/migrations/snapshot.d.ts.map +1 -1
  892. package/dist/types/migrations/tenantCredentials.d.ts.map +1 -1
  893. package/dist/types/model/authorization/AclSchemaAccessNodeFactory.d.ts.map +1 -1
  894. package/dist/types/model/authorization/DirectPermissionsAccessNode.d.ts.map +1 -1
  895. package/dist/types/model/authorization/Identity.d.ts.map +1 -1
  896. package/dist/types/model/authorization/IdentityFactory.d.ts.map +1 -1
  897. package/dist/types/model/authorization/IdentityScope.d.ts.map +1 -1
  898. package/dist/types/model/authorization/MembershipMatcher.d.ts.map +1 -1
  899. package/dist/types/model/authorization/PermissionActions.d.ts.map +1 -1
  900. package/dist/types/model/authorization/PermissionContext.d.ts.map +1 -1
  901. package/dist/types/model/authorization/PermissionContextFactory.d.ts.map +1 -1
  902. package/dist/types/model/authorization/PermissionsFactory.d.ts.map +1 -1
  903. package/dist/types/model/authorization/ProjectScope.d.ts.map +1 -1
  904. package/dist/types/model/authorization/ProjectScopeFactory.d.ts.map +1 -1
  905. package/dist/types/model/commands/CommandBus.d.ts.map +1 -1
  906. package/dist/types/model/commands/apiKey/ApiKeyHelper.d.ts.map +1 -1
  907. package/dist/types/model/commands/apiKey/CreateApiKeyCommand.d.ts.map +1 -1
  908. package/dist/types/model/commands/apiKey/DisableApiKeyCommand.d.ts.map +1 -1
  909. package/dist/types/model/commands/apiKey/DisableIdentityApiKeysCommand.d.ts.map +1 -1
  910. package/dist/types/model/commands/apiKey/DisableOneOffApiKeyCommand.d.ts.map +1 -1
  911. package/dist/types/model/commands/apiKey/ProlongApiKeyCommand.d.ts +1 -1
  912. package/dist/types/model/commands/apiKey/ProlongApiKeyCommand.d.ts.map +1 -1
  913. package/dist/types/model/commands/authLog/CreateAuthLogEntryCommand.d.ts.map +1 -1
  914. package/dist/types/model/commands/authPolicy/CreateAuthPolicyCommand.d.ts.map +1 -1
  915. package/dist/types/model/commands/authPolicy/DeleteAuthPolicyCommand.d.ts.map +1 -1
  916. package/dist/types/model/commands/authPolicy/UpdateAuthPolicyCommand.d.ts.map +1 -1
  917. package/dist/types/model/commands/backupCode/ConsumeBackupCodeCommand.d.ts.map +1 -1
  918. package/dist/types/model/commands/backupCode/CreateBackupCodeCommand.d.ts.map +1 -1
  919. package/dist/types/model/commands/backupCode/DeleteBackupCodesCommand.d.ts.map +1 -1
  920. package/dist/types/model/commands/configuration/UpdateConfigurationCommand.d.ts.map +1 -1
  921. package/dist/types/model/commands/identity/CreateIdentityCommand.d.ts.map +1 -1
  922. package/dist/types/model/commands/identity/PatchIdentityGlobalRoles.d.ts.map +1 -1
  923. package/dist/types/model/commands/idp/ClaimIdpRevalidationCommand.d.ts.map +1 -1
  924. package/dist/types/model/commands/idp/CreateIdpCommand.d.ts.map +1 -1
  925. package/dist/types/model/commands/idp/CreateIdpSessionCommand.d.ts.map +1 -1
  926. package/dist/types/model/commands/idp/DisableIdpCommand.d.ts.map +1 -1
  927. package/dist/types/model/commands/idp/DisconnectPersonIdentityProviderCommand.d.ts.map +1 -1
  928. package/dist/types/model/commands/idp/EnableIdpCommand.d.ts.map +1 -1
  929. package/dist/types/model/commands/idp/UpdateIdpCommand.d.ts.map +1 -1
  930. package/dist/types/model/commands/idp/UpdateIdpSessionCommand.d.ts.map +1 -1
  931. package/dist/types/model/commands/mailTemplate/AddMailTemplateCommand.d.ts.map +1 -1
  932. package/dist/types/model/commands/mailTemplate/RemoveMailTemplateCommand.d.ts.map +1 -1
  933. package/dist/types/model/commands/membership/AddProjectMemberCommand.d.ts.map +1 -1
  934. package/dist/types/model/commands/membership/CreateOrUpdateProjectMembershipCommand.d.ts.map +1 -1
  935. package/dist/types/model/commands/membership/RemoveProjectMemberCommand.d.ts.map +1 -1
  936. package/dist/types/model/commands/membership/{RemoveProjectMembershipsCommand.d.ts → RemoveProjectMembershipCommand.d.ts} +1 -1
  937. package/dist/types/model/commands/membership/RemoveProjectMembershipCommand.d.ts.map +1 -0
  938. package/dist/types/model/commands/membership/UpdateProjectMemberCommand.d.ts.map +1 -1
  939. package/dist/types/model/commands/membership/index.d.ts +2 -1
  940. package/dist/types/model/commands/membership/index.d.ts.map +1 -1
  941. package/dist/types/model/commands/membership/variables/PatchProjectMembershipVariableValuesCommand.d.ts.map +1 -1
  942. package/dist/types/model/commands/membership/variables/PatchProjectMembershipVariablesCommand.d.ts.map +1 -1
  943. package/dist/types/model/commands/membership/variables/SetProjectMembershipVariableValuesCommand.d.ts.map +1 -1
  944. package/dist/types/model/commands/membership/variables/index.d.ts +1 -0
  945. package/dist/types/model/commands/membership/variables/index.d.ts.map +1 -1
  946. package/dist/types/model/commands/otp/ConfirmOtpCommand.d.ts.map +1 -1
  947. package/dist/types/model/commands/otp/DisableOtpCommand.d.ts.map +1 -1
  948. package/dist/types/model/commands/otp/PrepareOtpCommand.d.ts.map +1 -1
  949. package/dist/types/model/commands/otp/ReEncryptOtpSecretCommand.d.ts.map +1 -1
  950. package/dist/types/model/commands/otp/SetEmailOtpEnabledCommand.d.ts.map +1 -1
  951. package/dist/types/model/commands/person/ChangePasswordCommand.d.ts.map +1 -1
  952. package/dist/types/model/commands/person/ChangeProfileCommand.d.ts.map +1 -1
  953. package/dist/types/model/commands/person/CreatePersonCommand.d.ts.map +1 -1
  954. package/dist/types/model/commands/person/CreatePersonIdentityProviderIdentifierCommand.d.ts.map +1 -1
  955. package/dist/types/model/commands/person/DisablePersonCommand.d.ts.map +1 -1
  956. package/dist/types/model/commands/person/EnablePersonCommand.d.ts +7 -0
  957. package/dist/types/model/commands/person/EnablePersonCommand.d.ts.map +1 -0
  958. package/dist/types/model/commands/person/MarkEmailVerifiedCommand.d.ts.map +1 -1
  959. package/dist/types/model/commands/person/ResetPersonMfaCommand.d.ts.map +1 -1
  960. package/dist/types/model/commands/person/SetMfaGraceUntilCommand.d.ts.map +1 -1
  961. package/dist/types/model/commands/person/TogglePersonPasswordlessCommand.d.ts.map +1 -1
  962. package/dist/types/model/commands/personToken/ActivateOtpCommand.d.ts.map +1 -1
  963. package/dist/types/model/commands/personToken/ClaimOtpAttemptCommand.d.ts.map +1 -1
  964. package/dist/types/model/commands/personToken/CreatePersonTokenCommand.d.ts.map +1 -1
  965. package/dist/types/model/commands/personToken/IncreaseOtpAttemptCommand.d.ts.map +1 -1
  966. package/dist/types/model/commands/personToken/InvalidateEmailOtpTokensCommand.d.ts.map +1 -1
  967. package/dist/types/model/commands/personToken/InvalidateTokenCommand.d.ts.map +1 -1
  968. package/dist/types/model/commands/personToken/ResetPasswordCommand.d.ts.map +1 -1
  969. package/dist/types/model/commands/personToken/SaveEmailOtpTokenCommand.d.ts.map +1 -1
  970. package/dist/types/model/commands/personToken/SavePersonTokenCommand.d.ts.map +1 -1
  971. package/dist/types/model/commands/project/CreateProjectCommand.d.ts.map +1 -1
  972. package/dist/types/model/commands/project/SetProjectSecretCommand.d.ts.map +1 -1
  973. package/dist/types/model/commands/project/UpdateProjectCommand.d.ts.map +1 -1
  974. package/dist/types/model/commands/rateLimit/RecordRateLimitEventCommand.d.ts.map +1 -1
  975. package/dist/types/model/dtos/Password.d.ts.map +1 -1
  976. package/dist/types/model/mailing/UserMailer.d.ts.map +1 -1
  977. package/dist/types/model/mailing/templates/BackupCodesExhausted.mustache.d.ts.map +1 -1
  978. package/dist/types/model/mailing/templates/EmailChangeNotify.mustache.d.ts.map +1 -1
  979. package/dist/types/model/mailing/templates/EmailChangeVerify.mustache.d.ts.map +1 -1
  980. package/dist/types/model/mailing/templates/EmailOtp.mustache.d.ts.map +1 -1
  981. package/dist/types/model/mailing/templates/EmailVerification.mustache.d.ts.map +1 -1
  982. package/dist/types/model/mailing/templates/ExistingUserInvited.mustache.d.ts.map +1 -1
  983. package/dist/types/model/mailing/templates/ForcedSignOut.mustache.d.ts.map +1 -1
  984. package/dist/types/model/mailing/templates/Layout.mustache.d.ts.map +1 -1
  985. package/dist/types/model/mailing/templates/NewUserInvited.mustache.d.ts.map +1 -1
  986. package/dist/types/model/mailing/templates/PasswordReset.mustache.d.ts.map +1 -1
  987. package/dist/types/model/mailing/templates/PasswordlessSignIn.mustache.d.ts.map +1 -1
  988. package/dist/types/model/mailing/templates/UnusualLogin.mustache.d.ts.map +1 -1
  989. package/dist/types/model/mailing/type.d.ts.map +1 -1
  990. package/dist/types/model/queries/apiKey/ApiKeyListQuery.d.ts.map +1 -1
  991. package/dist/types/model/queries/apiKey/ApiKeyQuery.d.ts.map +1 -1
  992. package/dist/types/model/queries/apiKey/ApiKeySessionsQuery.d.ts.map +1 -1
  993. package/dist/types/model/queries/authLog/AuthLogQuery.d.ts.map +1 -1
  994. package/dist/types/model/queries/authLog/NextLoginAttemptQuery.d.ts.map +1 -1
  995. package/dist/types/model/queries/authLog/NextMailAttemptQuery.d.ts.map +1 -1
  996. package/dist/types/model/queries/authPolicy/AuthPoliciesQuery.d.ts.map +1 -1
  997. package/dist/types/model/queries/configuration/ConfigurationQuery.d.ts.map +1 -1
  998. package/dist/types/model/queries/identity/IdentityQuery.d.ts.map +1 -1
  999. package/dist/types/model/queries/idp/IdentityProviderBySlugQuery.d.ts.map +1 -1
  1000. package/dist/types/model/queries/idp/IdentityProvidersQuery.d.ts.map +1 -1
  1001. package/dist/types/model/queries/idp/IdpSessionByApiKeyQuery.d.ts.map +1 -1
  1002. package/dist/types/model/queries/idp/IdpSessionsBySidQuery.d.ts.map +1 -1
  1003. package/dist/types/model/queries/idp/IdpSessionsBySubQuery.d.ts.map +1 -1
  1004. package/dist/types/model/queries/idp/LocalAuthDisablingIdpsQuery.d.ts +18 -0
  1005. package/dist/types/model/queries/idp/LocalAuthDisablingIdpsQuery.d.ts.map +1 -0
  1006. package/dist/types/model/queries/idp/PersonIdentityProvidersQuery.d.ts +1 -0
  1007. package/dist/types/model/queries/idp/PersonIdentityProvidersQuery.d.ts.map +1 -1
  1008. package/dist/types/model/queries/idp/helpers.d.ts +1 -1
  1009. package/dist/types/model/queries/idp/helpers.d.ts.map +1 -1
  1010. package/dist/types/model/queries/idp/index.d.ts +1 -0
  1011. package/dist/types/model/queries/idp/index.d.ts.map +1 -1
  1012. package/dist/types/model/queries/idp/types.d.ts +1 -0
  1013. package/dist/types/model/queries/idp/types.d.ts.map +1 -1
  1014. package/dist/types/model/queries/mailTemplate/MailTemplateListQuery.d.ts.map +1 -1
  1015. package/dist/types/model/queries/mailTemplate/MailTemplateQuery.d.ts.map +1 -1
  1016. package/dist/types/model/queries/membership/AllProjectRolesByIdentityQuery.d.ts.map +1 -1
  1017. package/dist/types/model/queries/membership/ProjectMembersQuery.d.ts.map +1 -1
  1018. package/dist/types/model/queries/membership/ProjectMembershipByIdentityQuery.d.ts.map +1 -1
  1019. package/dist/types/model/queries/membership/ProjectRolesByIdentityQuery.d.ts.map +1 -1
  1020. package/dist/types/model/queries/membership/ProjectSlugSpecification.d.ts.map +1 -1
  1021. package/dist/types/model/queries/person/PersonByIdPQuery.d.ts.map +1 -1
  1022. package/dist/types/model/queries/person/PersonByIdentityBatchQuery.d.ts.map +1 -1
  1023. package/dist/types/model/queries/person/PersonQuery.d.ts.map +1 -1
  1024. package/dist/types/model/queries/person/PersonQueryBuilderFactory.d.ts.map +1 -1
  1025. package/dist/types/model/queries/person/PersonsQuery.d.ts.map +1 -1
  1026. package/dist/types/model/queries/person/types.d.ts +1 -0
  1027. package/dist/types/model/queries/person/types.d.ts.map +1 -1
  1028. package/dist/types/model/queries/personToken/PersonTokenQuery.d.ts.map +1 -1
  1029. package/dist/types/model/queries/project/ProjectBySlugQuery.d.ts.map +1 -1
  1030. package/dist/types/model/queries/project/ProjectSecretKeysQuery.d.ts.map +1 -1
  1031. package/dist/types/model/queries/project/ProjectSecretsQuery.d.ts.map +1 -1
  1032. package/dist/types/model/queries/project/ProjectUpdateTimestampQuery.d.ts.map +1 -1
  1033. package/dist/types/model/queries/project/ProjectsByIdentityQuery.d.ts.map +1 -1
  1034. package/dist/types/model/queries/project/ProjectsQuery.d.ts.map +1 -1
  1035. package/dist/types/model/queries/rateLimit/RateLimitCountQuery.d.ts.map +1 -1
  1036. package/dist/types/model/service/AuthLogService.d.ts.map +1 -1
  1037. package/dist/types/model/service/AuthPolicyManager.d.ts.map +1 -1
  1038. package/dist/types/model/service/AuthPolicyResolver.d.ts.map +1 -1
  1039. package/dist/types/model/service/BackupCodeManager.d.ts.map +1 -1
  1040. package/dist/types/model/service/ConfigurationManager.d.ts.map +1 -1
  1041. package/dist/types/model/service/EmailChangeManager.d.ts.map +1 -1
  1042. package/dist/types/model/service/EmailOtpManager.d.ts.map +1 -1
  1043. package/dist/types/model/service/EmailValidator.d.ts.map +1 -1
  1044. package/dist/types/model/service/EmailVerificationManager.d.ts.map +1 -1
  1045. package/dist/types/model/service/HibpChecker.d.ts.map +1 -1
  1046. package/dist/types/model/service/IDPSignInManager.d.ts +11 -1
  1047. package/dist/types/model/service/IDPSignInManager.d.ts.map +1 -1
  1048. package/dist/types/model/service/InviteManager.d.ts.map +1 -1
  1049. package/dist/types/model/service/LoginRiskAnalyzer.d.ts +1 -1
  1050. package/dist/types/model/service/LoginRiskAnalyzer.d.ts.map +1 -1
  1051. package/dist/types/model/service/MailTemplateManager.d.ts.map +1 -1
  1052. package/dist/types/model/service/MembershipValidator.d.ts.map +1 -1
  1053. package/dist/types/model/service/OtpAuthenticator.d.ts.map +1 -1
  1054. package/dist/types/model/service/OtpManager.d.ts.map +1 -1
  1055. package/dist/types/model/service/PanelAccessResolver.d.ts +19 -0
  1056. package/dist/types/model/service/PanelAccessResolver.d.ts.map +1 -0
  1057. package/dist/types/model/service/PasswordChangeManager.d.ts.map +1 -1
  1058. package/dist/types/model/service/PasswordResetManager.d.ts.map +1 -1
  1059. package/dist/types/model/service/PasswordStrengthValidator.d.ts.map +1 -1
  1060. package/dist/types/model/service/PasswordlessSignInManager.d.ts.map +1 -1
  1061. package/dist/types/model/service/PersonAccessManager.d.ts +5 -2
  1062. package/dist/types/model/service/PersonAccessManager.d.ts.map +1 -1
  1063. package/dist/types/model/service/PersonManager.d.ts.map +1 -1
  1064. package/dist/types/model/service/ProjectManager.d.ts.map +1 -1
  1065. package/dist/types/model/service/ProjectMemberManager.d.ts.map +1 -1
  1066. package/dist/types/model/service/RateLimiter.d.ts.map +1 -1
  1067. package/dist/types/model/service/RolesManager.d.ts.map +1 -1
  1068. package/dist/types/model/service/SecretsManager.d.ts.map +1 -1
  1069. package/dist/types/model/service/SignInManager.d.ts.map +1 -1
  1070. package/dist/types/model/service/SignOutManager.d.ts.map +1 -1
  1071. package/dist/types/model/service/SignUpManager.d.ts.map +1 -1
  1072. package/dist/types/model/service/apiKey/ApiKeyManager.d.ts.map +1 -1
  1073. package/dist/types/model/service/apiKey/ApiKeyService.d.ts.map +1 -1
  1074. package/dist/types/model/service/apiKey/UnpersistedApiKeyManager.d.ts +18 -0
  1075. package/dist/types/model/service/apiKey/UnpersistedApiKeyManager.d.ts.map +1 -1
  1076. package/dist/types/model/service/captcha/CaptchaValidator.d.ts.map +1 -1
  1077. package/dist/types/model/service/captcha/HCaptchaProvider.d.ts.map +1 -1
  1078. package/dist/types/model/service/captcha/RecaptchaV3Provider.d.ts.map +1 -1
  1079. package/dist/types/model/service/captcha/TurnstileProvider.d.ts.map +1 -1
  1080. package/dist/types/model/service/helpers/getPreferredProject.d.ts.map +1 -1
  1081. package/dist/types/model/service/helpers/isPasswordlessEnabled.d.ts.map +1 -1
  1082. package/dist/types/model/service/idp/BackchannelLogoutManager.d.ts.map +1 -1
  1083. package/dist/types/model/service/idp/ClaimMapping.d.ts +330 -0
  1084. package/dist/types/model/service/idp/ClaimMapping.d.ts.map +1 -0
  1085. package/dist/types/model/service/idp/ClaimMappingEvaluator.d.ts +30 -0
  1086. package/dist/types/model/service/idp/ClaimMappingEvaluator.d.ts.map +1 -0
  1087. package/dist/types/model/service/idp/ClaimMappingValidation.d.ts +55 -0
  1088. package/dist/types/model/service/idp/ClaimMappingValidation.d.ts.map +1 -0
  1089. package/dist/types/model/service/idp/IDPClaimSyncService.d.ts +113 -0
  1090. package/dist/types/model/service/idp/IDPClaimSyncService.d.ts.map +1 -0
  1091. package/dist/types/model/service/idp/IDPHandlerRegistry.d.ts.map +1 -1
  1092. package/dist/types/model/service/idp/IDPManager.d.ts +31 -1
  1093. package/dist/types/model/service/idp/IDPManager.d.ts.map +1 -1
  1094. package/dist/types/model/service/idp/IdentityProviderHandler.d.ts +7 -0
  1095. package/dist/types/model/service/idp/IdentityProviderHandler.d.ts.map +1 -1
  1096. package/dist/types/model/service/idp/IdpSessionRevalidator.d.ts +13 -1
  1097. package/dist/types/model/service/idp/IdpSessionRevalidator.d.ts.map +1 -1
  1098. package/dist/types/model/service/idp/PersonIdentityProviderManager.d.ts.map +1 -1
  1099. package/dist/types/model/service/idp/index.d.ts +4 -0
  1100. package/dist/types/model/service/idp/index.d.ts.map +1 -1
  1101. package/dist/types/model/service/idp/providers/AppleProvider.d.ts +2 -2
  1102. package/dist/types/model/service/idp/providers/AppleProvider.d.ts.map +1 -1
  1103. package/dist/types/model/service/idp/providers/FacebookProvider.d.ts +2 -2
  1104. package/dist/types/model/service/idp/providers/FacebookProvider.d.ts.map +1 -1
  1105. package/dist/types/model/service/idp/providers/OIDCHelpers.d.ts +13 -1
  1106. package/dist/types/model/service/idp/providers/OIDCHelpers.d.ts.map +1 -1
  1107. package/dist/types/model/service/idp/providers/OIDCProvider.d.ts +1 -1
  1108. package/dist/types/model/service/idp/providers/OIDCProvider.d.ts.map +1 -1
  1109. package/dist/types/model/service/idp/providers/OIDCTypes.d.ts +5 -5
  1110. package/dist/types/model/service/idp/providers/helpers.d.ts.map +1 -1
  1111. package/dist/types/model/service/index.d.ts +1 -0
  1112. package/dist/types/model/service/index.d.ts.map +1 -1
  1113. package/dist/types/model/service/membershipUtils.d.ts.map +1 -1
  1114. package/dist/types/model/type/AuthLog.d.ts +1 -1
  1115. package/dist/types/model/type/AuthLog.d.ts.map +1 -1
  1116. package/dist/types/model/type/Config.d.ts +2 -0
  1117. package/dist/types/model/type/Config.d.ts.map +1 -1
  1118. package/dist/types/model/type/IdentityProvider.d.ts +2 -0
  1119. package/dist/types/model/type/IdentityProvider.d.ts.map +1 -1
  1120. package/dist/types/model/type/RateLimit.d.ts +6 -6
  1121. package/dist/types/model/type/RateLimit.d.ts.map +1 -1
  1122. package/dist/types/model/utils/DatabaseContext.d.ts +14 -1
  1123. package/dist/types/model/utils/DatabaseContext.d.ts.map +1 -1
  1124. package/dist/types/model/utils/Response.d.ts.map +1 -1
  1125. package/dist/types/model/utils/email.d.ts.map +1 -1
  1126. package/dist/types/model/utils/hex.d.ts.map +1 -1
  1127. package/dist/types/model/utils/interval.d.ts.map +1 -1
  1128. package/dist/types/model/utils/time.d.ts.map +1 -1
  1129. package/dist/types/model/utils/token.d.ts.map +1 -1
  1130. package/dist/types/resolvers/ResolverFactory.d.ts +2 -0
  1131. package/dist/types/resolvers/ResolverFactory.d.ts.map +1 -1
  1132. package/dist/types/resolvers/TenantResolverContextFactory.d.ts.map +1 -1
  1133. package/dist/types/resolvers/errorUtils.d.ts.map +1 -1
  1134. package/dist/types/resolvers/membershipUtils.d.ts.map +1 -1
  1135. package/dist/types/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.d.ts.map +1 -1
  1136. package/dist/types/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.d.ts.map +1 -1
  1137. package/dist/types/resolvers/mutation/configuration/AuthPolicyMutationResolver.d.ts.map +1 -1
  1138. package/dist/types/resolvers/mutation/configuration/ConfigurationMutationResolver.d.ts.map +1 -1
  1139. package/dist/types/resolvers/mutation/identity/GlobalRolesMutationResolver.d.ts.map +1 -1
  1140. package/dist/types/resolvers/mutation/idp/AddIDPMutationResolver.d.ts.map +1 -1
  1141. package/dist/types/resolvers/mutation/idp/DisableIDPMutationResolver.d.ts.map +1 -1
  1142. package/dist/types/resolvers/mutation/idp/DisconnectMyIdentityProviderMutationResolver.d.ts.map +1 -1
  1143. package/dist/types/resolvers/mutation/idp/EnableIDPMutationResolver.d.ts.map +1 -1
  1144. package/dist/types/resolvers/mutation/idp/UpdateIDPMutationResolver.d.ts.map +1 -1
  1145. package/dist/types/resolvers/mutation/idp/audit.d.ts.map +1 -1
  1146. package/dist/types/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.d.ts.map +1 -1
  1147. package/dist/types/resolvers/mutation/person/ChangePasswordMutationResolver.d.ts.map +1 -1
  1148. package/dist/types/resolvers/mutation/person/ChangeProfileMutationResolver.d.ts.map +1 -1
  1149. package/dist/types/resolvers/mutation/person/DisablePersonMutationResolver.d.ts +1 -1
  1150. package/dist/types/resolvers/mutation/person/DisablePersonMutationResolver.d.ts.map +1 -1
  1151. package/dist/types/resolvers/mutation/person/EmailOtpMutationResolver.d.ts.map +1 -1
  1152. package/dist/types/resolvers/mutation/person/EmailVerificationMutationResolver.d.ts.map +1 -1
  1153. package/dist/types/resolvers/mutation/person/EnablePersonMutationResolver.d.ts +11 -0
  1154. package/dist/types/resolvers/mutation/person/EnablePersonMutationResolver.d.ts.map +1 -0
  1155. package/dist/types/resolvers/mutation/person/ForceSignOutMutationResolver.d.ts.map +1 -1
  1156. package/dist/types/resolvers/mutation/person/IDPMutationResolver.d.ts.map +1 -1
  1157. package/dist/types/resolvers/mutation/person/InviteMutationResolver.d.ts.map +1 -1
  1158. package/dist/types/resolvers/mutation/person/OtpMutationResolver.d.ts.map +1 -1
  1159. package/dist/types/resolvers/mutation/person/PasswordlessMutationResolver.d.ts.map +1 -1
  1160. package/dist/types/resolvers/mutation/person/RegenerateBackupCodesMutationResolver.d.ts.map +1 -1
  1161. package/dist/types/resolvers/mutation/person/ResetPasswordMutationResolver.d.ts.map +1 -1
  1162. package/dist/types/resolvers/mutation/person/ResetPersonMfaMutationResolver.d.ts.map +1 -1
  1163. package/dist/types/resolvers/mutation/person/RevokeSessionMutationResolver.d.ts.map +1 -1
  1164. package/dist/types/resolvers/mutation/person/SignInMutationResolver.d.ts.map +1 -1
  1165. package/dist/types/resolvers/mutation/person/SignOutMutationResolver.d.ts.map +1 -1
  1166. package/dist/types/resolvers/mutation/person/SignUpMutationResolver.d.ts.map +1 -1
  1167. package/dist/types/resolvers/mutation/person/TogglePasswordlessMutationResolver.d.ts.map +1 -1
  1168. package/dist/types/resolvers/mutation/project/CreateProjectMutationResolver.d.ts.map +1 -1
  1169. package/dist/types/resolvers/mutation/project/SetProjectSecretMutationResolver.d.ts.map +1 -1
  1170. package/dist/types/resolvers/mutation/project/UpdateProjectMutationResolver.d.ts.map +1 -1
  1171. package/dist/types/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.d.ts.map +1 -1
  1172. package/dist/types/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.d.ts.map +1 -1
  1173. package/dist/types/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.d.ts.map +1 -1
  1174. package/dist/types/resolvers/mutation/projectMember/audit.d.ts +1 -1
  1175. package/dist/types/resolvers/mutation/projectMember/audit.d.ts.map +1 -1
  1176. package/dist/types/resolvers/query/ApiKeyQueryResolver.d.ts.map +1 -1
  1177. package/dist/types/resolvers/query/AuthLogQueryResolver.d.ts.map +1 -1
  1178. package/dist/types/resolvers/query/AuthPolicyQueryResolver.d.ts.map +1 -1
  1179. package/dist/types/resolvers/query/ConfigurationQueryResolver.d.ts.map +1 -1
  1180. package/dist/types/resolvers/query/IDPQueryResolver.d.ts.map +1 -1
  1181. package/dist/types/resolvers/query/MailTemplateQueryResolver.d.ts.map +1 -1
  1182. package/dist/types/resolvers/query/MeQueryResolver.d.ts.map +1 -1
  1183. package/dist/types/resolvers/query/PersonQueryResolver.d.ts.map +1 -1
  1184. package/dist/types/resolvers/query/ProjectMembersQueryResolver.d.ts.map +1 -1
  1185. package/dist/types/resolvers/query/ProjectQueryResolver.d.ts.map +1 -1
  1186. package/dist/types/resolvers/responseHelpers/ApiKeyResponseFactory.d.ts.map +1 -1
  1187. package/dist/types/resolvers/responseHelpers/PersonResponseFactory.d.ts.map +1 -1
  1188. package/dist/types/resolvers/responseHelpers/ProjectResponseFactory.d.ts +10 -0
  1189. package/dist/types/resolvers/responseHelpers/ProjectResponseFactory.d.ts.map +1 -0
  1190. package/dist/types/resolvers/responseHelpers/SignInResponseFactory.d.ts.map +1 -1
  1191. package/dist/types/resolvers/types/IdentityTypeResolver.d.ts.map +1 -1
  1192. package/dist/types/resolvers/types/PersonTypeResolver.d.ts +15 -1
  1193. package/dist/types/resolvers/types/PersonTypeResolver.d.ts.map +1 -1
  1194. package/dist/types/resolvers/types/ProjectTypeResolver.d.ts +15 -6
  1195. package/dist/types/resolvers/types/ProjectTypeResolver.d.ts.map +1 -1
  1196. package/dist/types/schema/index.d.ts +194 -4
  1197. package/dist/types/schema/index.d.ts.map +1 -1
  1198. package/dist/types/schema/tenant.graphql.d.ts.map +1 -1
  1199. package/dist/types/schema/types.d.ts +2 -2
  1200. package/dist/types/schema/types.d.ts.map +1 -1
  1201. package/dist/types/tsconfig.tsbuildinfo +1 -1
  1202. package/dist/types/utils/Mailer.d.ts.map +1 -1
  1203. package/dist/types/utils/TemplateRenderer.d.ts.map +1 -1
  1204. package/dist/types/utils/array.d.ts.map +1 -1
  1205. package/dist/types/utils/batchQuery.d.ts.map +1 -1
  1206. package/package.json +12 -12
  1207. package/src/TenantContainer.ts +17 -3
  1208. package/src/migrations/2026-06-18-120000-idp-claim-mapping.ts +15 -0
  1209. package/src/migrations/2026-08-03-120000-person-enable-auth-log.ts +12 -0
  1210. package/src/migrations/2026-08-04-120000-config-panel.ts +13 -0
  1211. package/src/migrations/2026-09-04-120000-idp-disable-local-authentication.ts +18 -0
  1212. package/src/migrations/runner.ts +8 -0
  1213. package/src/migrations/snapshot.ts +8 -2
  1214. package/src/model/commands/configuration/UpdateConfigurationCommand.ts +5 -4
  1215. package/src/model/commands/idp/CreateIdpCommand.ts +7 -1
  1216. package/src/model/commands/idp/UpdateIdpCommand.ts +5 -1
  1217. package/src/model/commands/membership/UpdateProjectMemberCommand.ts +1 -1
  1218. package/src/model/commands/membership/index.ts +2 -1
  1219. package/src/model/commands/membership/variables/index.ts +1 -0
  1220. package/src/model/commands/person/EnablePersonCommand.ts +18 -0
  1221. package/src/model/queries/configuration/ConfigurationQuery.ts +4 -0
  1222. package/src/model/queries/idp/LocalAuthDisablingIdpsQuery.ts +41 -0
  1223. package/src/model/queries/idp/PersonIdentityProvidersQuery.ts +2 -0
  1224. package/src/model/queries/idp/helpers.ts +3 -2
  1225. package/src/model/queries/idp/index.ts +1 -0
  1226. package/src/model/queries/idp/types.ts +1 -0
  1227. package/src/model/queries/membership/ProjectMembersQuery.ts +1 -0
  1228. package/src/model/queries/person/PersonQueryBuilderFactory.ts +1 -0
  1229. package/src/model/queries/person/types.ts +1 -0
  1230. package/src/model/service/AuthLogService.ts +18 -2
  1231. package/src/model/service/IDPSignInManager.ts +49 -1
  1232. package/src/model/service/PanelAccessResolver.ts +32 -0
  1233. package/src/model/service/PasswordResetManager.ts +9 -1
  1234. package/src/model/service/PasswordlessSignInManager.ts +23 -1
  1235. package/src/model/service/PersonAccessManager.ts +19 -3
  1236. package/src/model/service/SignInManager.ts +9 -1
  1237. package/src/model/service/apiKey/ApiKeyManager.ts +5 -3
  1238. package/src/model/service/apiKey/UnpersistedApiKeyManager.ts +24 -0
  1239. package/src/model/service/idp/ClaimMapping.ts +283 -0
  1240. package/src/model/service/idp/ClaimMappingEvaluator.ts +226 -0
  1241. package/src/model/service/idp/ClaimMappingValidation.ts +158 -0
  1242. package/src/model/service/idp/IDPClaimSyncService.ts +401 -0
  1243. package/src/model/service/idp/IDPManager.ts +126 -21
  1244. package/src/model/service/idp/IdentityProviderHandler.ts +7 -0
  1245. package/src/model/service/idp/IdpSessionRevalidator.ts +90 -0
  1246. package/src/model/service/idp/PersonIdentityProviderManager.ts +8 -0
  1247. package/src/model/service/idp/index.ts +4 -0
  1248. package/src/model/service/idp/providers/OIDCHelpers.ts +161 -53
  1249. package/src/model/service/idp/providers/OIDCProvider.ts +4 -1
  1250. package/src/model/service/index.ts +1 -0
  1251. package/src/model/type/AuthLog.ts +3 -0
  1252. package/src/model/type/Config.ts +3 -0
  1253. package/src/model/type/IdentityProvider.ts +2 -0
  1254. package/src/model/utils/DatabaseContext.ts +27 -6
  1255. package/src/resolvers/ResolverFactory.ts +6 -0
  1256. package/src/resolvers/mutation/idp/AddIDPMutationResolver.ts +1 -0
  1257. package/src/resolvers/mutation/idp/UpdateIDPMutationResolver.ts +1 -0
  1258. package/src/resolvers/mutation/idp/audit.ts +1 -0
  1259. package/src/resolvers/mutation/person/DisablePersonMutationResolver.ts +3 -3
  1260. package/src/resolvers/mutation/person/EnablePersonMutationResolver.ts +50 -0
  1261. package/src/resolvers/mutation/person/IDPMutationResolver.ts +31 -0
  1262. package/src/resolvers/mutation/person/PasswordlessMutationResolver.ts +7 -0
  1263. package/src/resolvers/mutation/person/SignInMutationResolver.ts +2 -2
  1264. package/src/resolvers/query/ProjectQueryResolver.ts +3 -2
  1265. package/src/resolvers/responseHelpers/PersonResponseFactory.ts +5 -0
  1266. package/src/resolvers/responseHelpers/ProjectResponseFactory.ts +24 -0
  1267. package/src/resolvers/types/IdentityTypeResolver.ts +39 -3
  1268. package/src/resolvers/types/PersonTypeResolver.ts +35 -2
  1269. package/src/resolvers/types/ProjectTypeResolver.ts +33 -1
  1270. package/src/schema/index.ts +212 -0
  1271. package/src/schema/tenant.graphql.ts +144 -0
  1272. package/tests/cases/integration/mocked/configurationPanel.test.ts +105 -0
  1273. package/tests/cases/integration/mocked/disablePersonMutation.test.ts +89 -0
  1274. package/tests/cases/integration/mocked/enablePersonMutation.test.ts +130 -0
  1275. package/tests/cases/integration/mocked/gql/passwordless.ts +10 -0
  1276. package/tests/cases/integration/mocked/idpClaimMappingConfig.test.ts +332 -0
  1277. package/tests/cases/integration/mocked/listProjectMembersQuery.test.ts +8 -3
  1278. package/tests/cases/integration/mocked/localAuthenticationDisabled.test.ts +182 -0
  1279. package/tests/cases/integration/mocked/permissionsQuery.test.ts +153 -0
  1280. package/tests/cases/integration/mocked/personIdentityProviders.test.ts +67 -0
  1281. package/tests/cases/integration/mocked/personsQuery.test.ts +38 -5
  1282. package/tests/cases/integration/mocked/signInAnomalyDetection.test.ts +11 -0
  1283. package/tests/cases/integration/mocked/signInIdpClaimMapping.test.ts +1258 -0
  1284. package/tests/cases/integration/mocked/signInIdpClaimMappingFixes.test.ts +344 -0
  1285. package/tests/cases/integration/mocked/signInIdpClaimMappingSafety.test.ts +531 -0
  1286. package/tests/cases/integration/mocked/signInIdpMutation.test.ts +5 -0
  1287. package/tests/cases/integration/mocked/signInMfaEnforcement.test.ts +7 -0
  1288. package/tests/cases/integration/mocked/signInMutation.test.ts +14 -0
  1289. package/tests/cases/integration/mocked/signInPasswordlessMutation.test.ts +36 -0
  1290. package/tests/cases/integration/mocked/sql/getConfigSql.ts +3 -0
  1291. package/tests/cases/integration/mocked/sql/getIdpBySlugSql.ts +1 -1
  1292. package/tests/cases/integration/mocked/sql/getProjectBySlugSql.ts +1 -1
  1293. package/tests/cases/integration/mocked/sql/listPersonsSql.ts +5 -2
  1294. package/tests/cases/integration/mocked/sql/localAuthDisablingIdpsSql.ts +21 -0
  1295. package/tests/cases/integration/mocked/sql/personIdentityProvidersSql.ts +3 -1
  1296. package/tests/cases/integration/mocked/sql/removeMembershipSql.ts +14 -0
  1297. package/tests/cases/integration/mocked/trustForwardedClientInfo.test.ts +3 -0
  1298. package/tests/cases/unit/databaseContextRetry.test.ts +81 -0
  1299. package/tests/cases/unit/idp/claimMappingEvaluator.test.ts +554 -0
  1300. package/tests/cases/unit/idp/claimMappingValidation.test.ts +134 -0
  1301. package/tests/cases/unit/idp/idpManagerConfigMerge.test.ts +97 -0
  1302. package/tests/cases/unit/idp/idpManagerUnknownConfigKeys.test.ts +108 -0
  1303. package/tests/cases/unit/idp/idpSessionRevalidator.test.ts +226 -24
  1304. package/tests/cases/unit/idp/oidcClaims.test.ts +29 -0
  1305. package/tests/cases/unit/idp/oidcResponse.test.ts +54 -0
  1306. package/tests/cases/unit/idp/oidcRevalidate.test.ts +94 -2
  1307. package/tests/cases/unit/panelAccessResolver.test.ts +57 -0
  1308. package/tests/cases/unit/updateConfigurationCommand.test.ts +63 -0
  1309. package/tests/src/IdPMock.ts +4 -0
  1310. package/tests/src/testTenant.ts +32 -1
  1311. package/dist/development/src/model/commands/membership/RemoveProjectMembershipsCommand.cjs.map +0 -1
  1312. package/dist/development/src/model/commands/membership/RemoveProjectMembershipsCommand.js.map +0 -1
  1313. package/dist/production/src/model/commands/membership/RemoveProjectMembershipsCommand.cjs.map +0 -1
  1314. package/dist/production/src/model/commands/membership/RemoveProjectMembershipsCommand.js.map +0 -1
  1315. package/dist/types/model/commands/membership/RemoveProjectMembershipsCommand.d.ts.map +0 -1
  1316. /package/src/model/commands/membership/{RemoveProjectMembershipsCommand.ts → RemoveProjectMembershipCommand.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"IdpSessionRevalidator.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/idp/IdpSessionRevalidator.ts"],"sourcesContent":["import { DatabaseContext } from '../../utils/index.js'\nimport { ApiKeyRequestInfo } from '../../commands/index.js'\nimport { ApiKeyRow } from '../../queries/apiKey/ApiKeyQuery.js'\nimport { IdpSessionByApiKeyQuery, IdpSessionRow } from '../../queries/idp/IdpSessionByApiKeyQuery.js'\nimport { IDPHandlerRegistry } from './IDPHandlerRegistry.js'\nimport { ClaimIdpRevalidationCommand } from '../../commands/idp/ClaimIdpRevalidationCommand.js'\nimport { UpdateIdpSessionCommand } from '../../commands/idp/UpdateIdpSessionCommand.js'\nimport { DisableApiKeyCommand } from '../../commands/index.js'\nimport { CreateAuthLogEntryCommand } from '../../commands/authLog/CreateAuthLogEntryCommand.js'\nimport { REVALIDATION_DEFAULT_FALLBACK_INTERVAL, REVALIDATION_DEFAULT_MIN_INTERVAL, REVALIDATION_DEFAULT_SOFT_THRESHOLD } from './IDPRevalidation.js'\nimport { IdentityProviderHandler, RevalidationResult } from './IdentityProviderHandler.js'\n\nexport type RevalidationOutcome = 'valid' | 'revoked'\n\ntype ResolvedRevalidationConfig = {\n\tenabled: boolean\n\tsoftThreshold: number\n\tminInterval: string\n\tfallbackInterval: string\n\tmode: 'auto' | 'blocking'\n}\n\n/**\n * Decision for the current request: whether to attempt a revalidation, and if so whether it\n * must block the request. `claimInterval` is the single-flight floor for the atomic claim.\n */\ntype Decision = null | { blocking: boolean; claimInterval: string }\n\n/**\n * Re-validates IdP-backed sessions against their identity provider on the verify hot path\n * (A24). Invoked from `ApiKeyManager.verifyAndProlong`. Operates entirely through the supplied\n * database contexts and the command bus, so it does not depend on `ApiKeyManager` (no DI cycle).\n *\n * The cadence is driven by the **access-token lifetime**, not a fixed interval:\n * - while the token is fresh (before `softRefreshThreshold` of its lifetime) → skip, free;\n * - past the threshold but not yet expired → a proactive **background (SWR)** refresh, so the\n * request keeps zero added latency and the token is renewed before it dies;\n * - once the token has actually expired → a **blocking** refresh (we can't serve a dead token).\n * `mode: 'blocking'` forces every revalidation synchronous (zero revocation lag). When the IdP\n * returns no token expiry, falls back to a plain `fallbackInterval` background throttle.\n */\nexport class IdpSessionRevalidator {\n\tconstructor(\n\t\tprivate readonly idpRegistry: IDPHandlerRegistry,\n\t) {\n\t}\n\n\tasync revalidate(\n\t\tdbContext: DatabaseContext,\n\t\treadDbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<RevalidationOutcome> {\n\t\tconst row = await readDbContext.queryHandler.fetch(new IdpSessionByApiKeyQuery(apiKeyRow.id, readDbContext.providers))\n\t\tif (!row) {\n\t\t\t// not a federated session (password / IdP without revalidation) — fast no-op\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tconst config = this.resolveConfig(row.providerConfiguration)\n\t\tif (!config.enabled) {\n\t\t\treturn 'valid'\n\t\t}\n\n\t\t// A disabled IdP no longer vouches for its sessions.\n\t\tif (row.providerDisabledAt) {\n\t\t\tawait this.revoke(dbContext, apiKeyRow, row, 'idp_disabled', requestInfo)\n\t\t\treturn 'revoked'\n\t\t}\n\n\t\tconst handler = this.idpRegistry.getHandlerOrNull(row.providerType)\n\t\tif (!handler?.revalidate) {\n\t\t\t// provider can't actively re-validate (e.g. SAML) — rely on expiry / SLO\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tconst decision = this.decide(row, config, dbContext.providers.now())\n\t\tif (!decision) {\n\t\t\t// token still fresh — vouched for, no IdP call\n\t\t\treturn 'valid'\n\t\t}\n\n\t\t// Atomic claim = single-flight. Loser (within the floor window, or lost the race) serves stale.\n\t\tlet claimed: boolean\n\t\ttry {\n\t\t\tclaimed = await dbContext.commandBus.execute(new ClaimIdpRevalidationCommand(row.id, decision.claimInterval))\n\t\t} catch {\n\t\t\t// invalid interval string or transient DB error — fail open, retry next request\n\t\t\treturn 'valid'\n\t\t}\n\t\tif (!claimed) {\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tif (decision.blocking) {\n\t\t\treturn await this.runRevalidation(dbContext, handler, row, apiKeyRow, requestInfo)\n\t\t}\n\n\t\t// SWR: serve this request from the (still valid) token, refresh after the response.\n\t\t// The work runs detached (after the response is sent), so any rejection — a transient\n\t\t// DB error in the revoke / persist writes, a corrupt-config throw — must be swallowed\n\t\t// here; otherwise it becomes an unhandledRejection and can take the worker down. The\n\t\t// session is simply kept and re-tried on a later request (the claim floor throttles).\n\t\tsetImmediate(() => {\n\t\t\tthis.runRevalidation(dbContext, handler, row, apiKeyRow, requestInfo).catch(() => {})\n\t\t})\n\t\treturn 'valid'\n\t}\n\n\t/**\n\t * Decide whether (and how) to revalidate, purely from timestamps — no interval parsing in\n\t * JS (the claim handles intervals in SQL). Returns null to skip.\n\t */\n\tprivate decide(row: IdpSessionRow, config: ResolvedRevalidationConfig, now: Date): Decision {\n\t\tconst expiresAt = row.session.expiresAt\n\t\tconst obtainedAt = row.tokenObtainedAt\n\n\t\t// No lifetime info from the IdP → plain background throttle on fallbackInterval.\n\t\tif (!expiresAt || !obtainedAt) {\n\t\t\treturn { blocking: config.mode === 'blocking', claimInterval: config.fallbackInterval }\n\t\t}\n\n\t\tconst lifetimeMs = expiresAt.getTime() - obtainedAt.getTime()\n\t\tconst softAtMs = obtainedAt.getTime() + lifetimeMs * config.softThreshold\n\t\tconst nowMs = now.getTime()\n\n\t\tif (nowMs < softAtMs) {\n\t\t\treturn null // still within the trusted window\n\t\t}\n\n\t\tconst expired = nowMs >= expiresAt.getTime()\n\t\treturn { blocking: config.mode === 'blocking' || expired, claimInterval: config.minInterval }\n\t}\n\n\tprivate async runRevalidation(\n\t\tdbContext: DatabaseContext,\n\t\thandler: IdentityProviderHandler<{}>,\n\t\trow: IdpSessionRow,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<RevalidationOutcome> {\n\t\tlet config: {}\n\t\ttry {\n\t\t\tconfig = handler.validateConfiguration(row.providerConfiguration)\n\t\t} catch {\n\t\t\t// corrupt stored config — must NOT revoke; keep the session and retry later. Audit\n\t\t\t// it so the operator can tell \"vouched for\" apart from \"silently broken\" (without an\n\t\t\t// entry, a config typo disables re-validation invisibly for the life of every session).\n\t\t\tawait this.logRevalidationFailed(dbContext, apiKeyRow, row, 'config_invalid', requestInfo)\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tlet result: RevalidationResult\n\t\ttry {\n\t\t\tresult = await handler.revalidate!(config, row.session)\n\t\t} catch {\n\t\t\t// transient failure (network / IdP down) — must NOT revoke; keep the session and retry\n\t\t\t// on a later request (the claim floor prevents hammering the IdP). Audited (throttled\n\t\t\t// to one entry per claim window) so a prolonged IdP outage is visible rather than a\n\t\t\t// silent fail-open.\n\t\t\tawait this.logRevalidationFailed(dbContext, apiKeyRow, row, 'revalidation_error', requestInfo)\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tif (result.status === 'revoked') {\n\t\t\tawait this.revoke(dbContext, apiKeyRow, row, result.reason, requestInfo)\n\t\t\treturn 'revoked'\n\t\t}\n\n\t\t// Still valid — persist the rotated token (resets the lifetime reference) / refreshed\n\t\t// expiry. A rotation is a real, low-frequency event (token-lifetime cadence), so we\n\t\t// audit it as `idp_session_revalidated`; the no-op userinfo/introspection probes\n\t\t// (no rotated session) are intentionally NOT logged to keep the audit log usable.\n\t\t//\n\t\t// The IdP has already vouched for the session, so these post-success writes are pure\n\t\t// best-effort bookkeeping (they only reset the SWR cadence reference). A transient DB\n\t\t// error or an `encrypt()` throw here must NOT fail the request — otherwise a blocking\n\t\t// revalidation fails closed on a successful refresh, contradicting \"fail open\" (the SWR\n\t\t// path already swallows this). Keep the existing row; the claim floor throttles a retry.\n\t\tif (result.idpSession) {\n\t\t\ttry {\n\t\t\t\tawait dbContext.commandBus.execute(new UpdateIdpSessionCommand(row.id, result.idpSession))\n\t\t\t\tawait this.logRevalidated(dbContext, apiKeyRow, row, requestInfo)\n\t\t\t} catch {\n\t\t\t\t// fall through — session stays valid, persist retried on a later request\n\t\t\t}\n\t\t}\n\t\treturn 'valid'\n\t}\n\n\tprivate async logRevalidated(dbContext: DatabaseContext, apiKeyRow: ApiKeyRow, row: IdpSessionRow, requestInfo?: ApiKeyRequestInfo): Promise<void> {\n\t\tawait dbContext.commandBus.execute(\n\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\ttype: 'idp_session_revalidated',\n\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\tsuccess: true,\n\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * Audit a fail-open: the IdP couldn't be consulted (transient outage) or the stored config is\n\t * corrupt, so we kept the session rather than revoking it. Naturally throttled to one entry\n\t * per claim window (we only reach here after a successful claim, which bumps\n\t * `last_validated_at`). The write is best-effort and self-contained — a failure to audit must\n\t * never propagate and fail a blocking verify request (the whole point of failing open).\n\t */\n\tprivate async logRevalidationFailed(\n\t\tdbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trow: IdpSessionRow,\n\t\terrorCode: 'config_invalid' | 'revalidation_error',\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait dbContext.commandBus.execute(\n\t\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\t\ttype: 'idp_session_revalidation_failed',\n\t\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\t\t// not a security failure (the session is kept) — a fail-open marker the operator\n\t\t\t\t\t// can alert on. `success: true` keeps it out of the failed-login funnels.\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\terrorCode,\n\t\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t\t}),\n\t\t\t)\n\t\t} catch {\n\t\t\t// best-effort observability — never fail the request because the audit write failed\n\t\t}\n\t}\n\n\tprivate async revoke(\n\t\tdbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trow: IdpSessionRow,\n\t\treason: string,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableApiKeyCommand(apiKeyRow.id))\n\t\tawait dbContext.commandBus.execute(\n\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\ttype: 'idp_session_revoked',\n\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\tsuccess: false,\n\t\t\t\terrorCode: reason,\n\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t\t// the action payload belongs in `event_data` (where every other audit event puts\n\t\t\t\t// it and where the admin UI / AuthLogQueryResolver reads it); `metadata` is for\n\t\t\t\t// transport context (forwarder IP/UA).\n\t\t\t\teventData: { reason },\n\t\t\t}),\n\t\t)\n\t}\n\n\tprivate resolveConfig(configuration: Record<string, unknown>): ResolvedRevalidationConfig {\n\t\tconst raw = (configuration.revalidation ?? {}) as Record<string, unknown>\n\t\tconst threshold = typeof raw.softRefreshThreshold === 'number' && raw.softRefreshThreshold > 0 && raw.softRefreshThreshold <= 1\n\t\t\t? raw.softRefreshThreshold\n\t\t\t: REVALIDATION_DEFAULT_SOFT_THRESHOLD\n\t\treturn {\n\t\t\tenabled: raw.enabled === true,\n\t\t\tsoftThreshold: threshold,\n\t\t\tminInterval: typeof raw.minInterval === 'string' ? raw.minInterval : REVALIDATION_DEFAULT_MIN_INTERVAL,\n\t\t\tfallbackInterval: typeof raw.fallbackInterval === 'string' ? raw.fallbackInterval : REVALIDATION_DEFAULT_FALLBACK_INTERVAL,\n\t\t\tmode: raw.mode === 'blocking' ? 'blocking' : 'auto',\n\t\t}\n\t}\n}\n"],"names":["IdpSessionByApiKeyQuery","ClaimIdpRevalidationCommand","UpdateIdpSessionCommand","CreateAuthLogEntryCommand","DisableApiKeyCommand","REVALIDATION_DEFAULT_SOFT_THRESHOLD","REVALIDATION_DEFAULT_MIN_INTERVAL","REVALIDATION_DEFAULT_FALLBACK_INTERVAL"],"mappings":"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"}
1
+ {"version":3,"file":"IdpSessionRevalidator.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/idp/IdpSessionRevalidator.ts"],"sourcesContent":["import { DatabaseContext } from '../../utils/index.js'\nimport { ApiKeyRequestInfo } from '../../commands/index.js'\nimport { ApiKeyRow } from '../../queries/apiKey/ApiKeyQuery.js'\nimport { IdpSessionByApiKeyQuery, IdpSessionRow } from '../../queries/idp/IdpSessionByApiKeyQuery.js'\nimport { IDPHandlerRegistry } from './IDPHandlerRegistry.js'\nimport { ClaimIdpRevalidationCommand } from '../../commands/idp/ClaimIdpRevalidationCommand.js'\nimport { UpdateIdpSessionCommand } from '../../commands/idp/UpdateIdpSessionCommand.js'\nimport { DisableApiKeyCommand } from '../../commands/index.js'\nimport { CreateAuthLogEntryCommand } from '../../commands/authLog/CreateAuthLogEntryCommand.js'\nimport { REVALIDATION_DEFAULT_FALLBACK_INTERVAL, REVALIDATION_DEFAULT_MIN_INTERVAL, REVALIDATION_DEFAULT_SOFT_THRESHOLD } from './IDPRevalidation.js'\nimport { IdentityProviderHandler, RevalidationResult } from './IdentityProviderHandler.js'\nimport { IDPClaimSyncService } from './IDPClaimSyncService.js'\nimport { parseClaimMapping } from './ClaimMapping.js'\nimport { JSONValue } from '@contember/schema'\n\nexport type RevalidationOutcome = 'valid' | 'revoked'\n\ntype ResolvedRevalidationConfig = {\n\tenabled: boolean\n\tsoftThreshold: number\n\tminInterval: string\n\tfallbackInterval: string\n\tmode: 'auto' | 'blocking'\n}\n\n/**\n * Decision for the current request: whether to attempt a revalidation, and if so whether it\n * must block the request. `claimInterval` is the single-flight floor for the atomic claim.\n */\ntype Decision = null | { blocking: boolean; claimInterval: string }\n\n/**\n * Re-validates IdP-backed sessions against their identity provider on the verify hot path\n * (A24). Invoked from `ApiKeyManager.verifyAndProlong`. Operates entirely through the supplied\n * database contexts and the command bus, so it does not depend on `ApiKeyManager` (no DI cycle).\n *\n * The cadence is driven by the **access-token lifetime**, not a fixed interval:\n * - while the token is fresh (before `softRefreshThreshold` of its lifetime) → skip, free;\n * - past the threshold but not yet expired → a proactive **background (SWR)** refresh, so the\n * request keeps zero added latency and the token is renewed before it dies;\n * - once the token has actually expired → a **blocking** refresh (we can't serve a dead token).\n * `mode: 'blocking'` forces every revalidation synchronous (zero revocation lag). When the IdP\n * returns no token expiry, falls back to a plain `fallbackInterval` background throttle.\n */\nexport class IdpSessionRevalidator {\n\tconstructor(\n\t\tprivate readonly idpRegistry: IDPHandlerRegistry,\n\t\tprivate readonly claimSyncService: IDPClaimSyncService,\n\t) {\n\t}\n\n\tasync revalidate(\n\t\tdbContext: DatabaseContext,\n\t\treadDbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<RevalidationOutcome> {\n\t\tconst row = await readDbContext.queryHandler.fetch(new IdpSessionByApiKeyQuery(apiKeyRow.id, readDbContext.providers))\n\t\tif (!row) {\n\t\t\t// not a federated session (password / IdP without revalidation) — fast no-op\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tconst config = this.resolveConfig(row.providerConfiguration)\n\t\tif (!config.enabled) {\n\t\t\treturn 'valid'\n\t\t}\n\n\t\t// A disabled IdP no longer vouches for its sessions.\n\t\tif (row.providerDisabledAt) {\n\t\t\tawait this.revoke(dbContext, apiKeyRow, row, 'idp_disabled', requestInfo)\n\t\t\treturn 'revoked'\n\t\t}\n\n\t\tconst handler = this.idpRegistry.getHandlerOrNull(row.providerType)\n\t\tif (!handler?.revalidate) {\n\t\t\t// provider can't actively re-validate (e.g. SAML) — rely on expiry / SLO\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tconst decision = this.decide(row, config, dbContext.providers.now())\n\t\tif (!decision) {\n\t\t\t// token still fresh — vouched for, no IdP call\n\t\t\treturn 'valid'\n\t\t}\n\n\t\t// Atomic claim = single-flight. Loser (within the floor window, or lost the race) serves stale.\n\t\tlet claimed: boolean\n\t\ttry {\n\t\t\tclaimed = await dbContext.commandBus.execute(new ClaimIdpRevalidationCommand(row.id, decision.claimInterval))\n\t\t} catch {\n\t\t\t// invalid interval string or transient DB error — fail open, retry next request\n\t\t\treturn 'valid'\n\t\t}\n\t\tif (!claimed) {\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tif (decision.blocking) {\n\t\t\treturn await this.runRevalidation(dbContext, handler, row, apiKeyRow, requestInfo)\n\t\t}\n\n\t\t// SWR: serve this request from the (still valid) token, refresh after the response.\n\t\t// The work runs detached (after the response is sent), so any rejection — a transient\n\t\t// DB error in the revoke / persist writes, a corrupt-config throw — must be swallowed\n\t\t// here; otherwise it becomes an unhandledRejection and can take the worker down. The\n\t\t// session is simply kept and re-tried on a later request (the claim floor throttles).\n\t\tsetImmediate(() => {\n\t\t\tthis.runRevalidation(dbContext, handler, row, apiKeyRow, requestInfo).catch(() => {})\n\t\t})\n\t\treturn 'valid'\n\t}\n\n\t/**\n\t * Decide whether (and how) to revalidate, purely from timestamps — no interval parsing in\n\t * JS (the claim handles intervals in SQL). Returns null to skip.\n\t */\n\tprivate decide(row: IdpSessionRow, config: ResolvedRevalidationConfig, now: Date): Decision {\n\t\tconst expiresAt = row.session.expiresAt\n\t\tconst obtainedAt = row.tokenObtainedAt\n\n\t\t// No lifetime info from the IdP → plain background throttle on fallbackInterval.\n\t\tif (!expiresAt || !obtainedAt) {\n\t\t\treturn { blocking: config.mode === 'blocking', claimInterval: config.fallbackInterval }\n\t\t}\n\n\t\tconst lifetimeMs = expiresAt.getTime() - obtainedAt.getTime()\n\t\tconst softAtMs = obtainedAt.getTime() + lifetimeMs * config.softThreshold\n\t\tconst nowMs = now.getTime()\n\n\t\tif (nowMs < softAtMs) {\n\t\t\treturn null // still within the trusted window\n\t\t}\n\n\t\tconst expired = nowMs >= expiresAt.getTime()\n\t\treturn { blocking: config.mode === 'blocking' || expired, claimInterval: config.minInterval }\n\t}\n\n\tprivate async runRevalidation(\n\t\tdbContext: DatabaseContext,\n\t\thandler: IdentityProviderHandler<{}>,\n\t\trow: IdpSessionRow,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<RevalidationOutcome> {\n\t\tlet config: {}\n\t\ttry {\n\t\t\tconfig = handler.validateConfiguration(row.providerConfiguration)\n\t\t} catch {\n\t\t\t// corrupt stored config — must NOT revoke; keep the session and retry later. Audit\n\t\t\t// it so the operator can tell \"vouched for\" apart from \"silently broken\" (without an\n\t\t\t// entry, a config typo disables re-validation invisibly for the life of every session).\n\t\t\tawait this.logRevalidationFailed(dbContext, apiKeyRow, row, 'config_invalid', requestInfo)\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tlet result: RevalidationResult\n\t\ttry {\n\t\t\tresult = await handler.revalidate!(config, row.session)\n\t\t} catch {\n\t\t\t// transient failure (network / IdP down) — must NOT revoke; keep the session and retry\n\t\t\t// on a later request (the claim floor prevents hammering the IdP). Audited (throttled\n\t\t\t// to one entry per claim window) so a prolonged IdP outage is visible rather than a\n\t\t\t// silent fail-open.\n\t\t\tawait this.logRevalidationFailed(dbContext, apiKeyRow, row, 'revalidation_error', requestInfo)\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tif (result.status === 'revoked') {\n\t\t\tawait this.revoke(dbContext, apiKeyRow, row, result.reason, requestInfo)\n\t\t\treturn 'revoked'\n\t\t}\n\n\t\t// Still valid — persist the rotated token (resets the lifetime reference) / refreshed\n\t\t// expiry. A rotation is a real, low-frequency event (token-lifetime cadence), so we\n\t\t// audit it as `idp_session_revalidated`; the no-op userinfo/introspection probes\n\t\t// (no rotated session) are intentionally NOT logged to keep the audit log usable.\n\t\t//\n\t\t// The IdP has already vouched for the session, so these post-success writes are pure\n\t\t// best-effort bookkeeping (they only reset the SWR cadence reference). A transient DB\n\t\t// error or an `encrypt()` throw here must NOT fail the request — otherwise a blocking\n\t\t// revalidation fails closed on a successful refresh, contradicting \"fail open\" (the SWR\n\t\t// path already swallows this). Keep the existing row; the claim floor throttles a retry.\n\t\tif (result.idpSession) {\n\t\t\ttry {\n\t\t\t\tawait dbContext.commandBus.execute(new UpdateIdpSessionCommand(row.id, result.idpSession))\n\t\t\t\tawait this.logRevalidated(dbContext, apiKeyRow, row, requestInfo)\n\t\t\t} catch {\n\t\t\t\t// fall through — session stays valid, persist retried on a later request\n\t\t\t}\n\t\t}\n\n\t\t// A09 — re-apply the IdP's claim mapping when the refresh returned fresh claims, so an `always`\n\t\t// mapping keeps an established session's project memberships in sync with the IdP's current claims\n\t\t// without requiring a full re-login. `sticky` mappings self-skip (the sync passes isNewPerson=false).\n\t\t// `claimsComplete` tells the sync whether the refresh rebuilt sign-in's full claim surface, so it can\n\t\t// reconcile (incl. `unmatched: \"remove\"`) exactly like sign-in. Strictly fail-open — see `syncClaims`.\n\t\tif (result.claims) {\n\t\t\tawait this.syncClaims(dbContext, row, apiKeyRow, result.claims, result.claimsComplete === true, requestInfo)\n\t\t}\n\t\treturn 'valid'\n\t}\n\n\t/**\n\t * Re-apply the claim mapping on a successful refresh. Runs in its own transaction (atomic apply of\n\t * the membership changes) and never throws: the IdP has already vouched for the session, so a\n\t * malformed mapping or a transient apply error must not revoke or fail it. A real membership change\n\t * is audited as `idp_role_mapped`; a failure is audited as `idp_role_mapping_failed` (fail-open\n\t * marker), mirroring the sign-in path. `claimsComplete` carries whether the refresh rebuilt sign-in's\n\t * full claim surface (so removal reconciliation is safe) — see `allowRemoval` below.\n\t */\n\tprivate async syncClaims(\n\t\tdbContext: DatabaseContext,\n\t\trow: IdpSessionRow,\n\t\tapiKeyRow: ApiKeyRow,\n\t\tclaims: Record<string, unknown>,\n\t\tclaimsComplete: boolean,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tconst mapping = parseClaimMapping(row.providerConfiguration)\n\t\t\tif (!mapping) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Atomic apply in its own transaction (the verify path has no surrounding one). `always`-only:\n\t\t\t// the sync passes isNewPerson=false, so a `sticky` mapping self-skips and returns a null audit.\n\t\t\t// Refresh mirrors sign-in as closely as the claim surface allows: when the provider returned its\n\t\t\t// COMPLETE surface (`claimsComplete` — `method: \"refresh\"` rebuilding sign-in's id-token + userinfo\n\t\t\t// merge), `unmatched: \"remove\"` reconciliation runs here too. A partial surface (a userinfo-only\n\t\t\t// probe, or a refresh whose userinfo fetch failed) passes `allowRemoval: false`, so refresh stays\n\t\t\t// additive-only and a membership the IdP still asserts is never stripped off an incomplete surface.\n\t\t\tconst { audit, droppedUnsafeRules } = await dbContext.transaction(db =>\n\t\t\t\tthis.claimSyncService.sync(db, mapping, claims, { id: apiKeyRow.identity_id }, false, { allowRemoval: claimsComplete })\n\t\t\t)\n\t\t\tif (audit) {\n\t\t\t\tawait this.logRoleMapping(dbContext, apiKeyRow, row, 'idp_role_mapped', audit, requestInfo)\n\t\t\t}\n\t\t\t// The apply-time safety backstop dropped a configured rule — emit the fail-open marker so a broken\n\t\t\t// mapping is visible on the refresh path too, mirroring sign-in (the marker carries no claim values).\n\t\t\tif (droppedUnsafeRules) {\n\t\t\t\tawait this.logRoleMapping(dbContext, apiKeyRow, row, 'idp_role_mapping_failed', undefined, requestInfo)\n\t\t\t}\n\t\t} catch {\n\t\t\t// Strictly fail-open: a malformed mapping or a transient apply error must never revoke or\n\t\t\t// fail an already-vouched-for session. The transaction rolls back any partial apply.\n\t\t\tawait this.logRoleMapping(dbContext, apiKeyRow, row, 'idp_role_mapping_failed', undefined, requestInfo)\n\t\t}\n\t}\n\n\tprivate async logRoleMapping(\n\t\tdbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trow: IdpSessionRow,\n\t\ttype: 'idp_role_mapped' | 'idp_role_mapping_failed',\n\t\teventData: JSONValue | undefined,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait dbContext.commandBus.execute(\n\t\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\t\ttype,\n\t\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\t\t// The membership change affects this session's own person — record it as the target too,\n\t\t\t\t\t// so an admin querying membership changes by target_person_id sees IdP-driven grants/revokes\n\t\t\t\t\t// (consistent with the project_membership_* audit events).\n\t\t\t\t\ttargetPersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\teventData,\n\t\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t\t}),\n\t\t\t)\n\t\t} catch {\n\t\t\t// best-effort audit — never fail the request because the audit write failed\n\t\t}\n\t}\n\n\tprivate async logRevalidated(dbContext: DatabaseContext, apiKeyRow: ApiKeyRow, row: IdpSessionRow, requestInfo?: ApiKeyRequestInfo): Promise<void> {\n\t\tawait dbContext.commandBus.execute(\n\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\ttype: 'idp_session_revalidated',\n\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\tsuccess: true,\n\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * Audit a fail-open: the IdP couldn't be consulted (transient outage) or the stored config is\n\t * corrupt, so we kept the session rather than revoking it. Naturally throttled to one entry\n\t * per claim window (we only reach here after a successful claim, which bumps\n\t * `last_validated_at`). The write is best-effort and self-contained — a failure to audit must\n\t * never propagate and fail a blocking verify request (the whole point of failing open).\n\t */\n\tprivate async logRevalidationFailed(\n\t\tdbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trow: IdpSessionRow,\n\t\terrorCode: 'config_invalid' | 'revalidation_error',\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait dbContext.commandBus.execute(\n\t\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\t\ttype: 'idp_session_revalidation_failed',\n\t\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\t\t// not a security failure (the session is kept) — a fail-open marker the operator\n\t\t\t\t\t// can alert on. `success: true` keeps it out of the failed-login funnels.\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\terrorCode,\n\t\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t\t}),\n\t\t\t)\n\t\t} catch {\n\t\t\t// best-effort observability — never fail the request because the audit write failed\n\t\t}\n\t}\n\n\tprivate async revoke(\n\t\tdbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trow: IdpSessionRow,\n\t\treason: string,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableApiKeyCommand(apiKeyRow.id))\n\t\tawait dbContext.commandBus.execute(\n\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\ttype: 'idp_session_revoked',\n\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\tsuccess: false,\n\t\t\t\terrorCode: reason,\n\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t\t// the action payload belongs in `event_data` (where every other audit event puts\n\t\t\t\t// it and where the admin UI / AuthLogQueryResolver reads it); `metadata` is for\n\t\t\t\t// transport context (forwarder IP/UA).\n\t\t\t\teventData: { reason },\n\t\t\t}),\n\t\t)\n\t}\n\n\tprivate resolveConfig(configuration: Record<string, unknown>): ResolvedRevalidationConfig {\n\t\tconst raw = (configuration.revalidation ?? {}) as Record<string, unknown>\n\t\tconst threshold = typeof raw.softRefreshThreshold === 'number' && raw.softRefreshThreshold > 0 && raw.softRefreshThreshold <= 1\n\t\t\t? raw.softRefreshThreshold\n\t\t\t: REVALIDATION_DEFAULT_SOFT_THRESHOLD\n\t\treturn {\n\t\t\tenabled: raw.enabled === true,\n\t\t\tsoftThreshold: threshold,\n\t\t\tminInterval: typeof raw.minInterval === 'string' ? raw.minInterval : REVALIDATION_DEFAULT_MIN_INTERVAL,\n\t\t\tfallbackInterval: typeof raw.fallbackInterval === 'string' ? raw.fallbackInterval : REVALIDATION_DEFAULT_FALLBACK_INTERVAL,\n\t\t\tmode: raw.mode === 'blocking' ? 'blocking' : 'auto',\n\t\t}\n\t}\n}\n"],"names":["IdpSessionByApiKeyQuery","ClaimIdpRevalidationCommand","UpdateIdpSessionCommand","parseClaimMapping","CreateAuthLogEntryCommand","DisableApiKeyCommand","REVALIDATION_DEFAULT_SOFT_THRESHOLD","REVALIDATION_DEFAULT_MIN_INTERVAL","REVALIDATION_DEFAULT_FALLBACK_INTERVAL"],"mappings":"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"}
@@ -7,9 +7,11 @@ import "node:crypto";
7
7
  import { DisableApiKeyCommand } from "../../commands/apiKey/DisableApiKeyCommand.js";
8
8
  import { CreateAuthLogEntryCommand } from "../../commands/authLog/CreateAuthLogEntryCommand.js";
9
9
  import { REVALIDATION_DEFAULT_SOFT_THRESHOLD, REVALIDATION_DEFAULT_FALLBACK_INTERVAL, REVALIDATION_DEFAULT_MIN_INTERVAL } from "./IDPRevalidation.js";
10
+ import { parseClaimMapping } from "./ClaimMapping.js";
10
11
  class IdpSessionRevalidator {
11
- constructor(idpRegistry) {
12
+ constructor(idpRegistry, claimSyncService) {
12
13
  this.idpRegistry = idpRegistry;
14
+ this.claimSyncService = claimSyncService;
13
15
  }
14
16
  async revalidate(dbContext, readDbContext, apiKeyRow, requestInfo) {
15
17
  const row = await readDbContext.queryHandler.fetch(new IdpSessionByApiKeyQuery(apiKeyRow.id, readDbContext.providers));
@@ -95,8 +97,60 @@ class IdpSessionRevalidator {
95
97
  } catch {
96
98
  }
97
99
  }
100
+ if (result.claims) {
101
+ await this.syncClaims(dbContext, row, apiKeyRow, result.claims, result.claimsComplete === true, requestInfo);
102
+ }
98
103
  return "valid";
99
104
  }
105
+ /**
106
+ * Re-apply the claim mapping on a successful refresh. Runs in its own transaction (atomic apply of
107
+ * the membership changes) and never throws: the IdP has already vouched for the session, so a
108
+ * malformed mapping or a transient apply error must not revoke or fail it. A real membership change
109
+ * is audited as `idp_role_mapped`; a failure is audited as `idp_role_mapping_failed` (fail-open
110
+ * marker), mirroring the sign-in path. `claimsComplete` carries whether the refresh rebuilt sign-in's
111
+ * full claim surface (so removal reconciliation is safe) — see `allowRemoval` below.
112
+ */
113
+ async syncClaims(dbContext, row, apiKeyRow, claims, claimsComplete, requestInfo) {
114
+ try {
115
+ const mapping = parseClaimMapping(row.providerConfiguration);
116
+ if (!mapping) {
117
+ return;
118
+ }
119
+ const { audit, droppedUnsafeRules } = await dbContext.transaction(
120
+ (db) => this.claimSyncService.sync(db, mapping, claims, { id: apiKeyRow.identity_id }, false, { allowRemoval: claimsComplete })
121
+ );
122
+ if (audit) {
123
+ await this.logRoleMapping(dbContext, apiKeyRow, row, "idp_role_mapped", audit, requestInfo);
124
+ }
125
+ if (droppedUnsafeRules) {
126
+ await this.logRoleMapping(dbContext, apiKeyRow, row, "idp_role_mapping_failed", void 0, requestInfo);
127
+ }
128
+ } catch {
129
+ await this.logRoleMapping(dbContext, apiKeyRow, row, "idp_role_mapping_failed", void 0, requestInfo);
130
+ }
131
+ }
132
+ async logRoleMapping(dbContext, apiKeyRow, row, type, eventData, requestInfo) {
133
+ try {
134
+ await dbContext.commandBus.execute(
135
+ new CreateAuthLogEntryCommand({
136
+ type,
137
+ invokedById: apiKeyRow.identity_id,
138
+ personId: apiKeyRow.person_id ?? void 0,
139
+ // The membership change affects this session's own person — record it as the target too,
140
+ // so an admin querying membership changes by target_person_id sees IdP-driven grants/revokes
141
+ // (consistent with the project_membership_* audit events).
142
+ targetPersonId: apiKeyRow.person_id ?? void 0,
143
+ identityProviderId: row.identityProviderId,
144
+ personTokenId: apiKeyRow.id,
145
+ success: true,
146
+ eventData,
147
+ ipAddress: requestInfo?.ip,
148
+ userAgent: requestInfo?.userAgent
149
+ })
150
+ );
151
+ } catch {
152
+ }
153
+ }
100
154
  async logRevalidated(dbContext, apiKeyRow, row, requestInfo) {
101
155
  await dbContext.commandBus.execute(
102
156
  new CreateAuthLogEntryCommand({
@@ -1 +1 @@
1
- {"version":3,"file":"IdpSessionRevalidator.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/idp/IdpSessionRevalidator.ts"],"sourcesContent":["import { DatabaseContext } from '../../utils/index.js'\nimport { ApiKeyRequestInfo } from '../../commands/index.js'\nimport { ApiKeyRow } from '../../queries/apiKey/ApiKeyQuery.js'\nimport { IdpSessionByApiKeyQuery, IdpSessionRow } from '../../queries/idp/IdpSessionByApiKeyQuery.js'\nimport { IDPHandlerRegistry } from './IDPHandlerRegistry.js'\nimport { ClaimIdpRevalidationCommand } from '../../commands/idp/ClaimIdpRevalidationCommand.js'\nimport { UpdateIdpSessionCommand } from '../../commands/idp/UpdateIdpSessionCommand.js'\nimport { DisableApiKeyCommand } from '../../commands/index.js'\nimport { CreateAuthLogEntryCommand } from '../../commands/authLog/CreateAuthLogEntryCommand.js'\nimport { REVALIDATION_DEFAULT_FALLBACK_INTERVAL, REVALIDATION_DEFAULT_MIN_INTERVAL, REVALIDATION_DEFAULT_SOFT_THRESHOLD } from './IDPRevalidation.js'\nimport { IdentityProviderHandler, RevalidationResult } from './IdentityProviderHandler.js'\n\nexport type RevalidationOutcome = 'valid' | 'revoked'\n\ntype ResolvedRevalidationConfig = {\n\tenabled: boolean\n\tsoftThreshold: number\n\tminInterval: string\n\tfallbackInterval: string\n\tmode: 'auto' | 'blocking'\n}\n\n/**\n * Decision for the current request: whether to attempt a revalidation, and if so whether it\n * must block the request. `claimInterval` is the single-flight floor for the atomic claim.\n */\ntype Decision = null | { blocking: boolean; claimInterval: string }\n\n/**\n * Re-validates IdP-backed sessions against their identity provider on the verify hot path\n * (A24). Invoked from `ApiKeyManager.verifyAndProlong`. Operates entirely through the supplied\n * database contexts and the command bus, so it does not depend on `ApiKeyManager` (no DI cycle).\n *\n * The cadence is driven by the **access-token lifetime**, not a fixed interval:\n * - while the token is fresh (before `softRefreshThreshold` of its lifetime) → skip, free;\n * - past the threshold but not yet expired → a proactive **background (SWR)** refresh, so the\n * request keeps zero added latency and the token is renewed before it dies;\n * - once the token has actually expired → a **blocking** refresh (we can't serve a dead token).\n * `mode: 'blocking'` forces every revalidation synchronous (zero revocation lag). When the IdP\n * returns no token expiry, falls back to a plain `fallbackInterval` background throttle.\n */\nexport class IdpSessionRevalidator {\n\tconstructor(\n\t\tprivate readonly idpRegistry: IDPHandlerRegistry,\n\t) {\n\t}\n\n\tasync revalidate(\n\t\tdbContext: DatabaseContext,\n\t\treadDbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<RevalidationOutcome> {\n\t\tconst row = await readDbContext.queryHandler.fetch(new IdpSessionByApiKeyQuery(apiKeyRow.id, readDbContext.providers))\n\t\tif (!row) {\n\t\t\t// not a federated session (password / IdP without revalidation) — fast no-op\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tconst config = this.resolveConfig(row.providerConfiguration)\n\t\tif (!config.enabled) {\n\t\t\treturn 'valid'\n\t\t}\n\n\t\t// A disabled IdP no longer vouches for its sessions.\n\t\tif (row.providerDisabledAt) {\n\t\t\tawait this.revoke(dbContext, apiKeyRow, row, 'idp_disabled', requestInfo)\n\t\t\treturn 'revoked'\n\t\t}\n\n\t\tconst handler = this.idpRegistry.getHandlerOrNull(row.providerType)\n\t\tif (!handler?.revalidate) {\n\t\t\t// provider can't actively re-validate (e.g. SAML) — rely on expiry / SLO\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tconst decision = this.decide(row, config, dbContext.providers.now())\n\t\tif (!decision) {\n\t\t\t// token still fresh — vouched for, no IdP call\n\t\t\treturn 'valid'\n\t\t}\n\n\t\t// Atomic claim = single-flight. Loser (within the floor window, or lost the race) serves stale.\n\t\tlet claimed: boolean\n\t\ttry {\n\t\t\tclaimed = await dbContext.commandBus.execute(new ClaimIdpRevalidationCommand(row.id, decision.claimInterval))\n\t\t} catch {\n\t\t\t// invalid interval string or transient DB error — fail open, retry next request\n\t\t\treturn 'valid'\n\t\t}\n\t\tif (!claimed) {\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tif (decision.blocking) {\n\t\t\treturn await this.runRevalidation(dbContext, handler, row, apiKeyRow, requestInfo)\n\t\t}\n\n\t\t// SWR: serve this request from the (still valid) token, refresh after the response.\n\t\t// The work runs detached (after the response is sent), so any rejection — a transient\n\t\t// DB error in the revoke / persist writes, a corrupt-config throw — must be swallowed\n\t\t// here; otherwise it becomes an unhandledRejection and can take the worker down. The\n\t\t// session is simply kept and re-tried on a later request (the claim floor throttles).\n\t\tsetImmediate(() => {\n\t\t\tthis.runRevalidation(dbContext, handler, row, apiKeyRow, requestInfo).catch(() => {})\n\t\t})\n\t\treturn 'valid'\n\t}\n\n\t/**\n\t * Decide whether (and how) to revalidate, purely from timestamps — no interval parsing in\n\t * JS (the claim handles intervals in SQL). Returns null to skip.\n\t */\n\tprivate decide(row: IdpSessionRow, config: ResolvedRevalidationConfig, now: Date): Decision {\n\t\tconst expiresAt = row.session.expiresAt\n\t\tconst obtainedAt = row.tokenObtainedAt\n\n\t\t// No lifetime info from the IdP → plain background throttle on fallbackInterval.\n\t\tif (!expiresAt || !obtainedAt) {\n\t\t\treturn { blocking: config.mode === 'blocking', claimInterval: config.fallbackInterval }\n\t\t}\n\n\t\tconst lifetimeMs = expiresAt.getTime() - obtainedAt.getTime()\n\t\tconst softAtMs = obtainedAt.getTime() + lifetimeMs * config.softThreshold\n\t\tconst nowMs = now.getTime()\n\n\t\tif (nowMs < softAtMs) {\n\t\t\treturn null // still within the trusted window\n\t\t}\n\n\t\tconst expired = nowMs >= expiresAt.getTime()\n\t\treturn { blocking: config.mode === 'blocking' || expired, claimInterval: config.minInterval }\n\t}\n\n\tprivate async runRevalidation(\n\t\tdbContext: DatabaseContext,\n\t\thandler: IdentityProviderHandler<{}>,\n\t\trow: IdpSessionRow,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<RevalidationOutcome> {\n\t\tlet config: {}\n\t\ttry {\n\t\t\tconfig = handler.validateConfiguration(row.providerConfiguration)\n\t\t} catch {\n\t\t\t// corrupt stored config — must NOT revoke; keep the session and retry later. Audit\n\t\t\t// it so the operator can tell \"vouched for\" apart from \"silently broken\" (without an\n\t\t\t// entry, a config typo disables re-validation invisibly for the life of every session).\n\t\t\tawait this.logRevalidationFailed(dbContext, apiKeyRow, row, 'config_invalid', requestInfo)\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tlet result: RevalidationResult\n\t\ttry {\n\t\t\tresult = await handler.revalidate!(config, row.session)\n\t\t} catch {\n\t\t\t// transient failure (network / IdP down) — must NOT revoke; keep the session and retry\n\t\t\t// on a later request (the claim floor prevents hammering the IdP). Audited (throttled\n\t\t\t// to one entry per claim window) so a prolonged IdP outage is visible rather than a\n\t\t\t// silent fail-open.\n\t\t\tawait this.logRevalidationFailed(dbContext, apiKeyRow, row, 'revalidation_error', requestInfo)\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tif (result.status === 'revoked') {\n\t\t\tawait this.revoke(dbContext, apiKeyRow, row, result.reason, requestInfo)\n\t\t\treturn 'revoked'\n\t\t}\n\n\t\t// Still valid — persist the rotated token (resets the lifetime reference) / refreshed\n\t\t// expiry. A rotation is a real, low-frequency event (token-lifetime cadence), so we\n\t\t// audit it as `idp_session_revalidated`; the no-op userinfo/introspection probes\n\t\t// (no rotated session) are intentionally NOT logged to keep the audit log usable.\n\t\t//\n\t\t// The IdP has already vouched for the session, so these post-success writes are pure\n\t\t// best-effort bookkeeping (they only reset the SWR cadence reference). A transient DB\n\t\t// error or an `encrypt()` throw here must NOT fail the request — otherwise a blocking\n\t\t// revalidation fails closed on a successful refresh, contradicting \"fail open\" (the SWR\n\t\t// path already swallows this). Keep the existing row; the claim floor throttles a retry.\n\t\tif (result.idpSession) {\n\t\t\ttry {\n\t\t\t\tawait dbContext.commandBus.execute(new UpdateIdpSessionCommand(row.id, result.idpSession))\n\t\t\t\tawait this.logRevalidated(dbContext, apiKeyRow, row, requestInfo)\n\t\t\t} catch {\n\t\t\t\t// fall through — session stays valid, persist retried on a later request\n\t\t\t}\n\t\t}\n\t\treturn 'valid'\n\t}\n\n\tprivate async logRevalidated(dbContext: DatabaseContext, apiKeyRow: ApiKeyRow, row: IdpSessionRow, requestInfo?: ApiKeyRequestInfo): Promise<void> {\n\t\tawait dbContext.commandBus.execute(\n\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\ttype: 'idp_session_revalidated',\n\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\tsuccess: true,\n\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * Audit a fail-open: the IdP couldn't be consulted (transient outage) or the stored config is\n\t * corrupt, so we kept the session rather than revoking it. Naturally throttled to one entry\n\t * per claim window (we only reach here after a successful claim, which bumps\n\t * `last_validated_at`). The write is best-effort and self-contained — a failure to audit must\n\t * never propagate and fail a blocking verify request (the whole point of failing open).\n\t */\n\tprivate async logRevalidationFailed(\n\t\tdbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trow: IdpSessionRow,\n\t\terrorCode: 'config_invalid' | 'revalidation_error',\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait dbContext.commandBus.execute(\n\t\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\t\ttype: 'idp_session_revalidation_failed',\n\t\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\t\t// not a security failure (the session is kept) — a fail-open marker the operator\n\t\t\t\t\t// can alert on. `success: true` keeps it out of the failed-login funnels.\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\terrorCode,\n\t\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t\t}),\n\t\t\t)\n\t\t} catch {\n\t\t\t// best-effort observability — never fail the request because the audit write failed\n\t\t}\n\t}\n\n\tprivate async revoke(\n\t\tdbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trow: IdpSessionRow,\n\t\treason: string,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableApiKeyCommand(apiKeyRow.id))\n\t\tawait dbContext.commandBus.execute(\n\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\ttype: 'idp_session_revoked',\n\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\tsuccess: false,\n\t\t\t\terrorCode: reason,\n\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t\t// the action payload belongs in `event_data` (where every other audit event puts\n\t\t\t\t// it and where the admin UI / AuthLogQueryResolver reads it); `metadata` is for\n\t\t\t\t// transport context (forwarder IP/UA).\n\t\t\t\teventData: { reason },\n\t\t\t}),\n\t\t)\n\t}\n\n\tprivate resolveConfig(configuration: Record<string, unknown>): ResolvedRevalidationConfig {\n\t\tconst raw = (configuration.revalidation ?? {}) as Record<string, unknown>\n\t\tconst threshold = typeof raw.softRefreshThreshold === 'number' && raw.softRefreshThreshold > 0 && raw.softRefreshThreshold <= 1\n\t\t\t? raw.softRefreshThreshold\n\t\t\t: REVALIDATION_DEFAULT_SOFT_THRESHOLD\n\t\treturn {\n\t\t\tenabled: raw.enabled === true,\n\t\t\tsoftThreshold: threshold,\n\t\t\tminInterval: typeof raw.minInterval === 'string' ? raw.minInterval : REVALIDATION_DEFAULT_MIN_INTERVAL,\n\t\t\tfallbackInterval: typeof raw.fallbackInterval === 'string' ? raw.fallbackInterval : REVALIDATION_DEFAULT_FALLBACK_INTERVAL,\n\t\t\tmode: raw.mode === 'blocking' ? 'blocking' : 'auto',\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"IdpSessionRevalidator.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/idp/IdpSessionRevalidator.ts"],"sourcesContent":["import { DatabaseContext } from '../../utils/index.js'\nimport { ApiKeyRequestInfo } from '../../commands/index.js'\nimport { ApiKeyRow } from '../../queries/apiKey/ApiKeyQuery.js'\nimport { IdpSessionByApiKeyQuery, IdpSessionRow } from '../../queries/idp/IdpSessionByApiKeyQuery.js'\nimport { IDPHandlerRegistry } from './IDPHandlerRegistry.js'\nimport { ClaimIdpRevalidationCommand } from '../../commands/idp/ClaimIdpRevalidationCommand.js'\nimport { UpdateIdpSessionCommand } from '../../commands/idp/UpdateIdpSessionCommand.js'\nimport { DisableApiKeyCommand } from '../../commands/index.js'\nimport { CreateAuthLogEntryCommand } from '../../commands/authLog/CreateAuthLogEntryCommand.js'\nimport { REVALIDATION_DEFAULT_FALLBACK_INTERVAL, REVALIDATION_DEFAULT_MIN_INTERVAL, REVALIDATION_DEFAULT_SOFT_THRESHOLD } from './IDPRevalidation.js'\nimport { IdentityProviderHandler, RevalidationResult } from './IdentityProviderHandler.js'\nimport { IDPClaimSyncService } from './IDPClaimSyncService.js'\nimport { parseClaimMapping } from './ClaimMapping.js'\nimport { JSONValue } from '@contember/schema'\n\nexport type RevalidationOutcome = 'valid' | 'revoked'\n\ntype ResolvedRevalidationConfig = {\n\tenabled: boolean\n\tsoftThreshold: number\n\tminInterval: string\n\tfallbackInterval: string\n\tmode: 'auto' | 'blocking'\n}\n\n/**\n * Decision for the current request: whether to attempt a revalidation, and if so whether it\n * must block the request. `claimInterval` is the single-flight floor for the atomic claim.\n */\ntype Decision = null | { blocking: boolean; claimInterval: string }\n\n/**\n * Re-validates IdP-backed sessions against their identity provider on the verify hot path\n * (A24). Invoked from `ApiKeyManager.verifyAndProlong`. Operates entirely through the supplied\n * database contexts and the command bus, so it does not depend on `ApiKeyManager` (no DI cycle).\n *\n * The cadence is driven by the **access-token lifetime**, not a fixed interval:\n * - while the token is fresh (before `softRefreshThreshold` of its lifetime) → skip, free;\n * - past the threshold but not yet expired → a proactive **background (SWR)** refresh, so the\n * request keeps zero added latency and the token is renewed before it dies;\n * - once the token has actually expired → a **blocking** refresh (we can't serve a dead token).\n * `mode: 'blocking'` forces every revalidation synchronous (zero revocation lag). When the IdP\n * returns no token expiry, falls back to a plain `fallbackInterval` background throttle.\n */\nexport class IdpSessionRevalidator {\n\tconstructor(\n\t\tprivate readonly idpRegistry: IDPHandlerRegistry,\n\t\tprivate readonly claimSyncService: IDPClaimSyncService,\n\t) {\n\t}\n\n\tasync revalidate(\n\t\tdbContext: DatabaseContext,\n\t\treadDbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<RevalidationOutcome> {\n\t\tconst row = await readDbContext.queryHandler.fetch(new IdpSessionByApiKeyQuery(apiKeyRow.id, readDbContext.providers))\n\t\tif (!row) {\n\t\t\t// not a federated session (password / IdP without revalidation) — fast no-op\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tconst config = this.resolveConfig(row.providerConfiguration)\n\t\tif (!config.enabled) {\n\t\t\treturn 'valid'\n\t\t}\n\n\t\t// A disabled IdP no longer vouches for its sessions.\n\t\tif (row.providerDisabledAt) {\n\t\t\tawait this.revoke(dbContext, apiKeyRow, row, 'idp_disabled', requestInfo)\n\t\t\treturn 'revoked'\n\t\t}\n\n\t\tconst handler = this.idpRegistry.getHandlerOrNull(row.providerType)\n\t\tif (!handler?.revalidate) {\n\t\t\t// provider can't actively re-validate (e.g. SAML) — rely on expiry / SLO\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tconst decision = this.decide(row, config, dbContext.providers.now())\n\t\tif (!decision) {\n\t\t\t// token still fresh — vouched for, no IdP call\n\t\t\treturn 'valid'\n\t\t}\n\n\t\t// Atomic claim = single-flight. Loser (within the floor window, or lost the race) serves stale.\n\t\tlet claimed: boolean\n\t\ttry {\n\t\t\tclaimed = await dbContext.commandBus.execute(new ClaimIdpRevalidationCommand(row.id, decision.claimInterval))\n\t\t} catch {\n\t\t\t// invalid interval string or transient DB error — fail open, retry next request\n\t\t\treturn 'valid'\n\t\t}\n\t\tif (!claimed) {\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tif (decision.blocking) {\n\t\t\treturn await this.runRevalidation(dbContext, handler, row, apiKeyRow, requestInfo)\n\t\t}\n\n\t\t// SWR: serve this request from the (still valid) token, refresh after the response.\n\t\t// The work runs detached (after the response is sent), so any rejection — a transient\n\t\t// DB error in the revoke / persist writes, a corrupt-config throw — must be swallowed\n\t\t// here; otherwise it becomes an unhandledRejection and can take the worker down. The\n\t\t// session is simply kept and re-tried on a later request (the claim floor throttles).\n\t\tsetImmediate(() => {\n\t\t\tthis.runRevalidation(dbContext, handler, row, apiKeyRow, requestInfo).catch(() => {})\n\t\t})\n\t\treturn 'valid'\n\t}\n\n\t/**\n\t * Decide whether (and how) to revalidate, purely from timestamps — no interval parsing in\n\t * JS (the claim handles intervals in SQL). Returns null to skip.\n\t */\n\tprivate decide(row: IdpSessionRow, config: ResolvedRevalidationConfig, now: Date): Decision {\n\t\tconst expiresAt = row.session.expiresAt\n\t\tconst obtainedAt = row.tokenObtainedAt\n\n\t\t// No lifetime info from the IdP → plain background throttle on fallbackInterval.\n\t\tif (!expiresAt || !obtainedAt) {\n\t\t\treturn { blocking: config.mode === 'blocking', claimInterval: config.fallbackInterval }\n\t\t}\n\n\t\tconst lifetimeMs = expiresAt.getTime() - obtainedAt.getTime()\n\t\tconst softAtMs = obtainedAt.getTime() + lifetimeMs * config.softThreshold\n\t\tconst nowMs = now.getTime()\n\n\t\tif (nowMs < softAtMs) {\n\t\t\treturn null // still within the trusted window\n\t\t}\n\n\t\tconst expired = nowMs >= expiresAt.getTime()\n\t\treturn { blocking: config.mode === 'blocking' || expired, claimInterval: config.minInterval }\n\t}\n\n\tprivate async runRevalidation(\n\t\tdbContext: DatabaseContext,\n\t\thandler: IdentityProviderHandler<{}>,\n\t\trow: IdpSessionRow,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<RevalidationOutcome> {\n\t\tlet config: {}\n\t\ttry {\n\t\t\tconfig = handler.validateConfiguration(row.providerConfiguration)\n\t\t} catch {\n\t\t\t// corrupt stored config — must NOT revoke; keep the session and retry later. Audit\n\t\t\t// it so the operator can tell \"vouched for\" apart from \"silently broken\" (without an\n\t\t\t// entry, a config typo disables re-validation invisibly for the life of every session).\n\t\t\tawait this.logRevalidationFailed(dbContext, apiKeyRow, row, 'config_invalid', requestInfo)\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tlet result: RevalidationResult\n\t\ttry {\n\t\t\tresult = await handler.revalidate!(config, row.session)\n\t\t} catch {\n\t\t\t// transient failure (network / IdP down) — must NOT revoke; keep the session and retry\n\t\t\t// on a later request (the claim floor prevents hammering the IdP). Audited (throttled\n\t\t\t// to one entry per claim window) so a prolonged IdP outage is visible rather than a\n\t\t\t// silent fail-open.\n\t\t\tawait this.logRevalidationFailed(dbContext, apiKeyRow, row, 'revalidation_error', requestInfo)\n\t\t\treturn 'valid'\n\t\t}\n\n\t\tif (result.status === 'revoked') {\n\t\t\tawait this.revoke(dbContext, apiKeyRow, row, result.reason, requestInfo)\n\t\t\treturn 'revoked'\n\t\t}\n\n\t\t// Still valid — persist the rotated token (resets the lifetime reference) / refreshed\n\t\t// expiry. A rotation is a real, low-frequency event (token-lifetime cadence), so we\n\t\t// audit it as `idp_session_revalidated`; the no-op userinfo/introspection probes\n\t\t// (no rotated session) are intentionally NOT logged to keep the audit log usable.\n\t\t//\n\t\t// The IdP has already vouched for the session, so these post-success writes are pure\n\t\t// best-effort bookkeeping (they only reset the SWR cadence reference). A transient DB\n\t\t// error or an `encrypt()` throw here must NOT fail the request — otherwise a blocking\n\t\t// revalidation fails closed on a successful refresh, contradicting \"fail open\" (the SWR\n\t\t// path already swallows this). Keep the existing row; the claim floor throttles a retry.\n\t\tif (result.idpSession) {\n\t\t\ttry {\n\t\t\t\tawait dbContext.commandBus.execute(new UpdateIdpSessionCommand(row.id, result.idpSession))\n\t\t\t\tawait this.logRevalidated(dbContext, apiKeyRow, row, requestInfo)\n\t\t\t} catch {\n\t\t\t\t// fall through — session stays valid, persist retried on a later request\n\t\t\t}\n\t\t}\n\n\t\t// A09 — re-apply the IdP's claim mapping when the refresh returned fresh claims, so an `always`\n\t\t// mapping keeps an established session's project memberships in sync with the IdP's current claims\n\t\t// without requiring a full re-login. `sticky` mappings self-skip (the sync passes isNewPerson=false).\n\t\t// `claimsComplete` tells the sync whether the refresh rebuilt sign-in's full claim surface, so it can\n\t\t// reconcile (incl. `unmatched: \"remove\"`) exactly like sign-in. Strictly fail-open — see `syncClaims`.\n\t\tif (result.claims) {\n\t\t\tawait this.syncClaims(dbContext, row, apiKeyRow, result.claims, result.claimsComplete === true, requestInfo)\n\t\t}\n\t\treturn 'valid'\n\t}\n\n\t/**\n\t * Re-apply the claim mapping on a successful refresh. Runs in its own transaction (atomic apply of\n\t * the membership changes) and never throws: the IdP has already vouched for the session, so a\n\t * malformed mapping or a transient apply error must not revoke or fail it. A real membership change\n\t * is audited as `idp_role_mapped`; a failure is audited as `idp_role_mapping_failed` (fail-open\n\t * marker), mirroring the sign-in path. `claimsComplete` carries whether the refresh rebuilt sign-in's\n\t * full claim surface (so removal reconciliation is safe) — see `allowRemoval` below.\n\t */\n\tprivate async syncClaims(\n\t\tdbContext: DatabaseContext,\n\t\trow: IdpSessionRow,\n\t\tapiKeyRow: ApiKeyRow,\n\t\tclaims: Record<string, unknown>,\n\t\tclaimsComplete: boolean,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tconst mapping = parseClaimMapping(row.providerConfiguration)\n\t\t\tif (!mapping) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Atomic apply in its own transaction (the verify path has no surrounding one). `always`-only:\n\t\t\t// the sync passes isNewPerson=false, so a `sticky` mapping self-skips and returns a null audit.\n\t\t\t// Refresh mirrors sign-in as closely as the claim surface allows: when the provider returned its\n\t\t\t// COMPLETE surface (`claimsComplete` — `method: \"refresh\"` rebuilding sign-in's id-token + userinfo\n\t\t\t// merge), `unmatched: \"remove\"` reconciliation runs here too. A partial surface (a userinfo-only\n\t\t\t// probe, or a refresh whose userinfo fetch failed) passes `allowRemoval: false`, so refresh stays\n\t\t\t// additive-only and a membership the IdP still asserts is never stripped off an incomplete surface.\n\t\t\tconst { audit, droppedUnsafeRules } = await dbContext.transaction(db =>\n\t\t\t\tthis.claimSyncService.sync(db, mapping, claims, { id: apiKeyRow.identity_id }, false, { allowRemoval: claimsComplete })\n\t\t\t)\n\t\t\tif (audit) {\n\t\t\t\tawait this.logRoleMapping(dbContext, apiKeyRow, row, 'idp_role_mapped', audit, requestInfo)\n\t\t\t}\n\t\t\t// The apply-time safety backstop dropped a configured rule — emit the fail-open marker so a broken\n\t\t\t// mapping is visible on the refresh path too, mirroring sign-in (the marker carries no claim values).\n\t\t\tif (droppedUnsafeRules) {\n\t\t\t\tawait this.logRoleMapping(dbContext, apiKeyRow, row, 'idp_role_mapping_failed', undefined, requestInfo)\n\t\t\t}\n\t\t} catch {\n\t\t\t// Strictly fail-open: a malformed mapping or a transient apply error must never revoke or\n\t\t\t// fail an already-vouched-for session. The transaction rolls back any partial apply.\n\t\t\tawait this.logRoleMapping(dbContext, apiKeyRow, row, 'idp_role_mapping_failed', undefined, requestInfo)\n\t\t}\n\t}\n\n\tprivate async logRoleMapping(\n\t\tdbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trow: IdpSessionRow,\n\t\ttype: 'idp_role_mapped' | 'idp_role_mapping_failed',\n\t\teventData: JSONValue | undefined,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait dbContext.commandBus.execute(\n\t\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\t\ttype,\n\t\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\t\t// The membership change affects this session's own person — record it as the target too,\n\t\t\t\t\t// so an admin querying membership changes by target_person_id sees IdP-driven grants/revokes\n\t\t\t\t\t// (consistent with the project_membership_* audit events).\n\t\t\t\t\ttargetPersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\teventData,\n\t\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t\t}),\n\t\t\t)\n\t\t} catch {\n\t\t\t// best-effort audit — never fail the request because the audit write failed\n\t\t}\n\t}\n\n\tprivate async logRevalidated(dbContext: DatabaseContext, apiKeyRow: ApiKeyRow, row: IdpSessionRow, requestInfo?: ApiKeyRequestInfo): Promise<void> {\n\t\tawait dbContext.commandBus.execute(\n\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\ttype: 'idp_session_revalidated',\n\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\tsuccess: true,\n\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * Audit a fail-open: the IdP couldn't be consulted (transient outage) or the stored config is\n\t * corrupt, so we kept the session rather than revoking it. Naturally throttled to one entry\n\t * per claim window (we only reach here after a successful claim, which bumps\n\t * `last_validated_at`). The write is best-effort and self-contained — a failure to audit must\n\t * never propagate and fail a blocking verify request (the whole point of failing open).\n\t */\n\tprivate async logRevalidationFailed(\n\t\tdbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trow: IdpSessionRow,\n\t\terrorCode: 'config_invalid' | 'revalidation_error',\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait dbContext.commandBus.execute(\n\t\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\t\ttype: 'idp_session_revalidation_failed',\n\t\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\t\t// not a security failure (the session is kept) — a fail-open marker the operator\n\t\t\t\t\t// can alert on. `success: true` keeps it out of the failed-login funnels.\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\terrorCode,\n\t\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t\t}),\n\t\t\t)\n\t\t} catch {\n\t\t\t// best-effort observability — never fail the request because the audit write failed\n\t\t}\n\t}\n\n\tprivate async revoke(\n\t\tdbContext: DatabaseContext,\n\t\tapiKeyRow: ApiKeyRow,\n\t\trow: IdpSessionRow,\n\t\treason: string,\n\t\trequestInfo?: ApiKeyRequestInfo,\n\t): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableApiKeyCommand(apiKeyRow.id))\n\t\tawait dbContext.commandBus.execute(\n\t\t\tnew CreateAuthLogEntryCommand({\n\t\t\t\ttype: 'idp_session_revoked',\n\t\t\t\tinvokedById: apiKeyRow.identity_id,\n\t\t\t\tpersonId: apiKeyRow.person_id ?? undefined,\n\t\t\t\tidentityProviderId: row.identityProviderId,\n\t\t\t\tpersonTokenId: apiKeyRow.id,\n\t\t\t\tsuccess: false,\n\t\t\t\terrorCode: reason,\n\t\t\t\tipAddress: requestInfo?.ip,\n\t\t\t\tuserAgent: requestInfo?.userAgent,\n\t\t\t\t// the action payload belongs in `event_data` (where every other audit event puts\n\t\t\t\t// it and where the admin UI / AuthLogQueryResolver reads it); `metadata` is for\n\t\t\t\t// transport context (forwarder IP/UA).\n\t\t\t\teventData: { reason },\n\t\t\t}),\n\t\t)\n\t}\n\n\tprivate resolveConfig(configuration: Record<string, unknown>): ResolvedRevalidationConfig {\n\t\tconst raw = (configuration.revalidation ?? {}) as Record<string, unknown>\n\t\tconst threshold = typeof raw.softRefreshThreshold === 'number' && raw.softRefreshThreshold > 0 && raw.softRefreshThreshold <= 1\n\t\t\t? raw.softRefreshThreshold\n\t\t\t: REVALIDATION_DEFAULT_SOFT_THRESHOLD\n\t\treturn {\n\t\t\tenabled: raw.enabled === true,\n\t\t\tsoftThreshold: threshold,\n\t\t\tminInterval: typeof raw.minInterval === 'string' ? raw.minInterval : REVALIDATION_DEFAULT_MIN_INTERVAL,\n\t\t\tfallbackInterval: typeof raw.fallbackInterval === 'string' ? raw.fallbackInterval : REVALIDATION_DEFAULT_FALLBACK_INTERVAL,\n\t\t\tmode: raw.mode === 'blocking' ? 'blocking' : 'auto',\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"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"}
@@ -24,6 +24,12 @@ class PersonIdentityProviderManager {
24
24
  if (!connection) {
25
25
  return new Response.ResponseError("NOT_FOUND", `You are not connected to the identity provider connection "${connectionId}".`);
26
26
  }
27
+ if (connection.identityProviderDisableLocalAuthentication) {
28
+ return new Response.ResponseError(
29
+ "IDP_REQUIRED",
30
+ `The identity provider "${connection.identityProviderSlug}" is the only way you may sign in; its connection cannot be removed.`
31
+ );
32
+ }
27
33
  const configuration = await db2.queryHandler.fetch(new ConfigurationQuery.ConfigurationQuery(db2.providers));
28
34
  const hasPassword = person.password_hash !== null;
29
35
  const hasPasswordless = isPasswordlessEnabled.isPasswordlessEnabled(configuration.passwordless.enabled, person.passwordless_enabled);
@@ -1 +1 @@
1
- {"version":3,"file":"PersonIdentityProviderManager.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/idp/PersonIdentityProviderManager.ts"],"sourcesContent":["import { Response, ResponseError, ResponseOk } from '../../utils/Response.js'\nimport { DisconnectIdpErrorCode } from '../../../schema/index.js'\nimport { DatabaseContext } from '../../utils/index.js'\nimport { ConfigurationQuery, PersonIdentityProviderRow, PersonIdentityProvidersQuery, PersonRow } from '../../queries/index.js'\nimport { DisconnectPersonIdentityProviderCommand } from '../../commands/idp/DisconnectPersonIdentityProviderCommand.js'\nimport { isPasswordlessEnabled } from '../helpers/isPasswordlessEnabled.js'\n\n/**\n * Manages the external IdP connections of the *currently authenticated* person.\n *\n * Lock-out policy: a person may always disconnect a provider as long as it does\n * not remove their last remaining sign-in method. A connection is refused only\n * when, after removal, the person would have no password, no passwordless\n * sign-in enabled and no other *usable* IdP connection left — which would lock\n * them out of their account entirely. Whether passwordless counts is decided by\n * the same tenant policy the sign-in flow applies, and connections to disabled\n * providers are not counted as a usable fallback (they cannot sign in).\n */\nexport class PersonIdentityProviderManager {\n\tpublic async listPersonIdentityProviders(db: DatabaseContext, personId: string): Promise<PersonIdentityProviderRow[]> {\n\t\treturn await db.queryHandler.fetch(new PersonIdentityProvidersQuery(personId))\n\t}\n\n\tpublic async disconnectIdentityProvider(db: DatabaseContext, person: PersonRow, connectionId: string): Promise<DisconnectIDPResponse> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst connections = await db.queryHandler.fetch(new PersonIdentityProvidersQuery(person.id))\n\t\t\tconst connection = connections.find(it => it.id === connectionId)\n\t\t\tif (!connection) {\n\t\t\t\treturn new ResponseError('NOT_FOUND', `You are not connected to the identity provider connection \"${connectionId}\".`)\n\t\t\t}\n\n\t\t\tconst configuration = await db.queryHandler.fetch(new ConfigurationQuery(db.providers))\n\t\t\tconst hasPassword = person.password_hash !== null\n\t\t\tconst hasPasswordless = isPasswordlessEnabled(configuration.passwordless.enabled, person.passwordless_enabled)\n\t\t\tconst otherUsableConnections = connections.filter(it => it.id !== connection.id && it.identityProviderDisabledAt === null)\n\t\t\tconst wouldLockOut = !hasPassword && !hasPasswordless && otherUsableConnections.length === 0\n\t\t\tif (wouldLockOut) {\n\t\t\t\treturn new ResponseError(\n\t\t\t\t\t'LAST_AUTH_METHOD',\n\t\t\t\t\t'Cannot disconnect the only remaining sign-in method. Set up a password or another sign-in method first.',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tawait db.commandBus.execute(new DisconnectPersonIdentityProviderCommand(person.id, connection.id))\n\t\t\treturn new ResponseOk({ slug: connection.identityProviderSlug })\n\t\t})\n\t}\n}\n\nexport interface DisconnectIDPResult {\n\treadonly slug: string\n}\n\nexport type DisconnectIDPResponse = Response<DisconnectIDPResult, DisconnectIdpErrorCode>\n"],"names":["PersonIdentityProvidersQuery","db","ResponseError","ConfigurationQuery","isPasswordlessEnabled","DisconnectPersonIdentityProviderCommand","ResponseOk"],"mappings":";;;;;;;;;;;;;;;AAkBO,MAAM,8BAA8B;AAAA,EAC1C,MAAa,4BAA4B,IAAqB,UAAwD;AACrH,WAAO,MAAM,GAAG,aAAa,MAAM,IAAIA,6BAAAA,6BAA6B,QAAQ,CAAC;AAAA,EAC9E;AAAA,EAEA,MAAa,2BAA2B,IAAqB,QAAmB,cAAsD;AACrI,WAAO,MAAM,GAAG,YAAY,OAAMC,QAAM;AACvC,YAAM,cAAc,MAAMA,IAAG,aAAa,MAAM,IAAID,6BAAAA,6BAA6B,OAAO,EAAE,CAAC;AAC3F,YAAM,aAAa,YAAY,KAAK,CAAA,OAAM,GAAG,OAAO,YAAY;AAChE,UAAI,CAAC,YAAY;AAChB,eAAO,IAAIE,SAAAA,cAAc,aAAa,8DAA8D,YAAY,IAAI;AAAA,MACrH;AAEA,YAAM,gBAAgB,MAAMD,IAAG,aAAa,MAAM,IAAIE,mBAAAA,mBAAmBF,IAAG,SAAS,CAAC;AACtF,YAAM,cAAc,OAAO,kBAAkB;AAC7C,YAAM,kBAAkBG,sBAAAA,sBAAsB,cAAc,aAAa,SAAS,OAAO,oBAAoB;AAC7G,YAAM,yBAAyB,YAAY,OAAO,CAAA,OAAM,GAAG,OAAO,WAAW,MAAM,GAAG,+BAA+B,IAAI;AACzH,YAAM,eAAe,CAAC,eAAe,CAAC,mBAAmB,uBAAuB,WAAW;AAC3F,UAAI,cAAc;AACjB,eAAO,IAAIF,SAAAA;AAAAA,UACV;AAAA,UACA;AAAA,QAAA;AAAA,MAEF;AAEA,YAAMD,IAAG,WAAW,QAAQ,IAAII,wCAAAA,wCAAwC,OAAO,IAAI,WAAW,EAAE,CAAC;AACjG,aAAO,IAAIC,SAAAA,WAAW,EAAE,MAAM,WAAW,sBAAsB;AAAA,IAChE,CAAC;AAAA,EACF;AACD;;"}
1
+ {"version":3,"file":"PersonIdentityProviderManager.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/idp/PersonIdentityProviderManager.ts"],"sourcesContent":["import { Response, ResponseError, ResponseOk } from '../../utils/Response.js'\nimport { DisconnectIdpErrorCode } from '../../../schema/index.js'\nimport { DatabaseContext } from '../../utils/index.js'\nimport { ConfigurationQuery, PersonIdentityProviderRow, PersonIdentityProvidersQuery, PersonRow } from '../../queries/index.js'\nimport { DisconnectPersonIdentityProviderCommand } from '../../commands/idp/DisconnectPersonIdentityProviderCommand.js'\nimport { isPasswordlessEnabled } from '../helpers/isPasswordlessEnabled.js'\n\n/**\n * Manages the external IdP connections of the *currently authenticated* person.\n *\n * Lock-out policy: a person may always disconnect a provider as long as it does\n * not remove their last remaining sign-in method. A connection is refused only\n * when, after removal, the person would have no password, no passwordless\n * sign-in enabled and no other *usable* IdP connection left — which would lock\n * them out of their account entirely. Whether passwordless counts is decided by\n * the same tenant policy the sign-in flow applies, and connections to disabled\n * providers are not counted as a usable fallback (they cannot sign in).\n */\nexport class PersonIdentityProviderManager {\n\tpublic async listPersonIdentityProviders(db: DatabaseContext, personId: string): Promise<PersonIdentityProviderRow[]> {\n\t\treturn await db.queryHandler.fetch(new PersonIdentityProvidersQuery(personId))\n\t}\n\n\tpublic async disconnectIdentityProvider(db: DatabaseContext, person: PersonRow, connectionId: string): Promise<DisconnectIDPResponse> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst connections = await db.queryHandler.fetch(new PersonIdentityProvidersQuery(person.id))\n\t\t\tconst connection = connections.find(it => it.id === connectionId)\n\t\t\tif (!connection) {\n\t\t\t\treturn new ResponseError('NOT_FOUND', `You are not connected to the identity provider connection \"${connectionId}\".`)\n\t\t\t}\n\n\t\t\t// The link is what binds the person to the provider's policy, so they cannot remove it themselves.\n\t\t\tif (connection.identityProviderDisableLocalAuthentication) {\n\t\t\t\treturn new ResponseError(\n\t\t\t\t\t'IDP_REQUIRED',\n\t\t\t\t\t`The identity provider \"${connection.identityProviderSlug}\" is the only way you may sign in; its connection cannot be removed.`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst configuration = await db.queryHandler.fetch(new ConfigurationQuery(db.providers))\n\t\t\tconst hasPassword = person.password_hash !== null\n\t\t\tconst hasPasswordless = isPasswordlessEnabled(configuration.passwordless.enabled, person.passwordless_enabled)\n\t\t\tconst otherUsableConnections = connections.filter(it => it.id !== connection.id && it.identityProviderDisabledAt === null)\n\t\t\tconst wouldLockOut = !hasPassword && !hasPasswordless && otherUsableConnections.length === 0\n\t\t\tif (wouldLockOut) {\n\t\t\t\treturn new ResponseError(\n\t\t\t\t\t'LAST_AUTH_METHOD',\n\t\t\t\t\t'Cannot disconnect the only remaining sign-in method. Set up a password or another sign-in method first.',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tawait db.commandBus.execute(new DisconnectPersonIdentityProviderCommand(person.id, connection.id))\n\t\t\treturn new ResponseOk({ slug: connection.identityProviderSlug })\n\t\t})\n\t}\n}\n\nexport interface DisconnectIDPResult {\n\treadonly slug: string\n}\n\nexport type DisconnectIDPResponse = Response<DisconnectIDPResult, DisconnectIdpErrorCode>\n"],"names":["PersonIdentityProvidersQuery","db","ResponseError","ConfigurationQuery","isPasswordlessEnabled","DisconnectPersonIdentityProviderCommand","ResponseOk"],"mappings":";;;;;;;;;;;;;;;AAkBO,MAAM,8BAA8B;AAAA,EAC1C,MAAa,4BAA4B,IAAqB,UAAwD;AACrH,WAAO,MAAM,GAAG,aAAa,MAAM,IAAIA,6BAAAA,6BAA6B,QAAQ,CAAC;AAAA,EAC9E;AAAA,EAEA,MAAa,2BAA2B,IAAqB,QAAmB,cAAsD;AACrI,WAAO,MAAM,GAAG,YAAY,OAAMC,QAAM;AACvC,YAAM,cAAc,MAAMA,IAAG,aAAa,MAAM,IAAID,6BAAAA,6BAA6B,OAAO,EAAE,CAAC;AAC3F,YAAM,aAAa,YAAY,KAAK,CAAA,OAAM,GAAG,OAAO,YAAY;AAChE,UAAI,CAAC,YAAY;AAChB,eAAO,IAAIE,SAAAA,cAAc,aAAa,8DAA8D,YAAY,IAAI;AAAA,MACrH;AAGA,UAAI,WAAW,4CAA4C;AAC1D,eAAO,IAAIA,SAAAA;AAAAA,UACV;AAAA,UACA,0BAA0B,WAAW,oBAAoB;AAAA,QAAA;AAAA,MAE3D;AAEA,YAAM,gBAAgB,MAAMD,IAAG,aAAa,MAAM,IAAIE,mBAAAA,mBAAmBF,IAAG,SAAS,CAAC;AACtF,YAAM,cAAc,OAAO,kBAAkB;AAC7C,YAAM,kBAAkBG,sBAAAA,sBAAsB,cAAc,aAAa,SAAS,OAAO,oBAAoB;AAC7G,YAAM,yBAAyB,YAAY,OAAO,CAAA,OAAM,GAAG,OAAO,WAAW,MAAM,GAAG,+BAA+B,IAAI;AACzH,YAAM,eAAe,CAAC,eAAe,CAAC,mBAAmB,uBAAuB,WAAW;AAC3F,UAAI,cAAc;AACjB,eAAO,IAAIF,SAAAA;AAAAA,UACV;AAAA,UACA;AAAA,QAAA;AAAA,MAEF;AAEA,YAAMD,IAAG,WAAW,QAAQ,IAAII,wCAAAA,wCAAwC,OAAO,IAAI,WAAW,EAAE,CAAC;AACjG,aAAO,IAAIC,SAAAA,WAAW,EAAE,MAAM,WAAW,sBAAsB;AAAA,IAChE,CAAC;AAAA,EACF;AACD;;"}
@@ -22,6 +22,12 @@ class PersonIdentityProviderManager {
22
22
  if (!connection) {
23
23
  return new ResponseError("NOT_FOUND", `You are not connected to the identity provider connection "${connectionId}".`);
24
24
  }
25
+ if (connection.identityProviderDisableLocalAuthentication) {
26
+ return new ResponseError(
27
+ "IDP_REQUIRED",
28
+ `The identity provider "${connection.identityProviderSlug}" is the only way you may sign in; its connection cannot be removed.`
29
+ );
30
+ }
25
31
  const configuration = await db2.queryHandler.fetch(new ConfigurationQuery(db2.providers));
26
32
  const hasPassword = person.password_hash !== null;
27
33
  const hasPasswordless = isPasswordlessEnabled(configuration.passwordless.enabled, person.passwordless_enabled);
@@ -1 +1 @@
1
- {"version":3,"file":"PersonIdentityProviderManager.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/idp/PersonIdentityProviderManager.ts"],"sourcesContent":["import { Response, ResponseError, ResponseOk } from '../../utils/Response.js'\nimport { DisconnectIdpErrorCode } from '../../../schema/index.js'\nimport { DatabaseContext } from '../../utils/index.js'\nimport { ConfigurationQuery, PersonIdentityProviderRow, PersonIdentityProvidersQuery, PersonRow } from '../../queries/index.js'\nimport { DisconnectPersonIdentityProviderCommand } from '../../commands/idp/DisconnectPersonIdentityProviderCommand.js'\nimport { isPasswordlessEnabled } from '../helpers/isPasswordlessEnabled.js'\n\n/**\n * Manages the external IdP connections of the *currently authenticated* person.\n *\n * Lock-out policy: a person may always disconnect a provider as long as it does\n * not remove their last remaining sign-in method. A connection is refused only\n * when, after removal, the person would have no password, no passwordless\n * sign-in enabled and no other *usable* IdP connection left — which would lock\n * them out of their account entirely. Whether passwordless counts is decided by\n * the same tenant policy the sign-in flow applies, and connections to disabled\n * providers are not counted as a usable fallback (they cannot sign in).\n */\nexport class PersonIdentityProviderManager {\n\tpublic async listPersonIdentityProviders(db: DatabaseContext, personId: string): Promise<PersonIdentityProviderRow[]> {\n\t\treturn await db.queryHandler.fetch(new PersonIdentityProvidersQuery(personId))\n\t}\n\n\tpublic async disconnectIdentityProvider(db: DatabaseContext, person: PersonRow, connectionId: string): Promise<DisconnectIDPResponse> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst connections = await db.queryHandler.fetch(new PersonIdentityProvidersQuery(person.id))\n\t\t\tconst connection = connections.find(it => it.id === connectionId)\n\t\t\tif (!connection) {\n\t\t\t\treturn new ResponseError('NOT_FOUND', `You are not connected to the identity provider connection \"${connectionId}\".`)\n\t\t\t}\n\n\t\t\tconst configuration = await db.queryHandler.fetch(new ConfigurationQuery(db.providers))\n\t\t\tconst hasPassword = person.password_hash !== null\n\t\t\tconst hasPasswordless = isPasswordlessEnabled(configuration.passwordless.enabled, person.passwordless_enabled)\n\t\t\tconst otherUsableConnections = connections.filter(it => it.id !== connection.id && it.identityProviderDisabledAt === null)\n\t\t\tconst wouldLockOut = !hasPassword && !hasPasswordless && otherUsableConnections.length === 0\n\t\t\tif (wouldLockOut) {\n\t\t\t\treturn new ResponseError(\n\t\t\t\t\t'LAST_AUTH_METHOD',\n\t\t\t\t\t'Cannot disconnect the only remaining sign-in method. Set up a password or another sign-in method first.',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tawait db.commandBus.execute(new DisconnectPersonIdentityProviderCommand(person.id, connection.id))\n\t\t\treturn new ResponseOk({ slug: connection.identityProviderSlug })\n\t\t})\n\t}\n}\n\nexport interface DisconnectIDPResult {\n\treadonly slug: string\n}\n\nexport type DisconnectIDPResponse = Response<DisconnectIDPResult, DisconnectIdpErrorCode>\n"],"names":["db"],"mappings":";;;;;;;;;;;;;AAkBO,MAAM,8BAA8B;AAAA,EAC1C,MAAa,4BAA4B,IAAqB,UAAwD;AACrH,WAAO,MAAM,GAAG,aAAa,MAAM,IAAI,6BAA6B,QAAQ,CAAC;AAAA,EAC9E;AAAA,EAEA,MAAa,2BAA2B,IAAqB,QAAmB,cAAsD;AACrI,WAAO,MAAM,GAAG,YAAY,OAAMA,QAAM;AACvC,YAAM,cAAc,MAAMA,IAAG,aAAa,MAAM,IAAI,6BAA6B,OAAO,EAAE,CAAC;AAC3F,YAAM,aAAa,YAAY,KAAK,CAAA,OAAM,GAAG,OAAO,YAAY;AAChE,UAAI,CAAC,YAAY;AAChB,eAAO,IAAI,cAAc,aAAa,8DAA8D,YAAY,IAAI;AAAA,MACrH;AAEA,YAAM,gBAAgB,MAAMA,IAAG,aAAa,MAAM,IAAI,mBAAmBA,IAAG,SAAS,CAAC;AACtF,YAAM,cAAc,OAAO,kBAAkB;AAC7C,YAAM,kBAAkB,sBAAsB,cAAc,aAAa,SAAS,OAAO,oBAAoB;AAC7G,YAAM,yBAAyB,YAAY,OAAO,CAAA,OAAM,GAAG,OAAO,WAAW,MAAM,GAAG,+BAA+B,IAAI;AACzH,YAAM,eAAe,CAAC,eAAe,CAAC,mBAAmB,uBAAuB,WAAW;AAC3F,UAAI,cAAc;AACjB,eAAO,IAAI;AAAA,UACV;AAAA,UACA;AAAA,QAAA;AAAA,MAEF;AAEA,YAAMA,IAAG,WAAW,QAAQ,IAAI,wCAAwC,OAAO,IAAI,WAAW,EAAE,CAAC;AACjG,aAAO,IAAI,WAAW,EAAE,MAAM,WAAW,sBAAsB;AAAA,IAChE,CAAC;AAAA,EACF;AACD;"}
1
+ {"version":3,"file":"PersonIdentityProviderManager.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/idp/PersonIdentityProviderManager.ts"],"sourcesContent":["import { Response, ResponseError, ResponseOk } from '../../utils/Response.js'\nimport { DisconnectIdpErrorCode } from '../../../schema/index.js'\nimport { DatabaseContext } from '../../utils/index.js'\nimport { ConfigurationQuery, PersonIdentityProviderRow, PersonIdentityProvidersQuery, PersonRow } from '../../queries/index.js'\nimport { DisconnectPersonIdentityProviderCommand } from '../../commands/idp/DisconnectPersonIdentityProviderCommand.js'\nimport { isPasswordlessEnabled } from '../helpers/isPasswordlessEnabled.js'\n\n/**\n * Manages the external IdP connections of the *currently authenticated* person.\n *\n * Lock-out policy: a person may always disconnect a provider as long as it does\n * not remove their last remaining sign-in method. A connection is refused only\n * when, after removal, the person would have no password, no passwordless\n * sign-in enabled and no other *usable* IdP connection left — which would lock\n * them out of their account entirely. Whether passwordless counts is decided by\n * the same tenant policy the sign-in flow applies, and connections to disabled\n * providers are not counted as a usable fallback (they cannot sign in).\n */\nexport class PersonIdentityProviderManager {\n\tpublic async listPersonIdentityProviders(db: DatabaseContext, personId: string): Promise<PersonIdentityProviderRow[]> {\n\t\treturn await db.queryHandler.fetch(new PersonIdentityProvidersQuery(personId))\n\t}\n\n\tpublic async disconnectIdentityProvider(db: DatabaseContext, person: PersonRow, connectionId: string): Promise<DisconnectIDPResponse> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst connections = await db.queryHandler.fetch(new PersonIdentityProvidersQuery(person.id))\n\t\t\tconst connection = connections.find(it => it.id === connectionId)\n\t\t\tif (!connection) {\n\t\t\t\treturn new ResponseError('NOT_FOUND', `You are not connected to the identity provider connection \"${connectionId}\".`)\n\t\t\t}\n\n\t\t\t// The link is what binds the person to the provider's policy, so they cannot remove it themselves.\n\t\t\tif (connection.identityProviderDisableLocalAuthentication) {\n\t\t\t\treturn new ResponseError(\n\t\t\t\t\t'IDP_REQUIRED',\n\t\t\t\t\t`The identity provider \"${connection.identityProviderSlug}\" is the only way you may sign in; its connection cannot be removed.`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst configuration = await db.queryHandler.fetch(new ConfigurationQuery(db.providers))\n\t\t\tconst hasPassword = person.password_hash !== null\n\t\t\tconst hasPasswordless = isPasswordlessEnabled(configuration.passwordless.enabled, person.passwordless_enabled)\n\t\t\tconst otherUsableConnections = connections.filter(it => it.id !== connection.id && it.identityProviderDisabledAt === null)\n\t\t\tconst wouldLockOut = !hasPassword && !hasPasswordless && otherUsableConnections.length === 0\n\t\t\tif (wouldLockOut) {\n\t\t\t\treturn new ResponseError(\n\t\t\t\t\t'LAST_AUTH_METHOD',\n\t\t\t\t\t'Cannot disconnect the only remaining sign-in method. Set up a password or another sign-in method first.',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tawait db.commandBus.execute(new DisconnectPersonIdentityProviderCommand(person.id, connection.id))\n\t\t\treturn new ResponseOk({ slug: connection.identityProviderSlug })\n\t\t})\n\t}\n}\n\nexport interface DisconnectIDPResult {\n\treadonly slug: string\n}\n\nexport type DisconnectIDPResponse = Response<DisconnectIDPResult, DisconnectIdpErrorCode>\n"],"names":["db"],"mappings":";;;;;;;;;;;;;AAkBO,MAAM,8BAA8B;AAAA,EAC1C,MAAa,4BAA4B,IAAqB,UAAwD;AACrH,WAAO,MAAM,GAAG,aAAa,MAAM,IAAI,6BAA6B,QAAQ,CAAC;AAAA,EAC9E;AAAA,EAEA,MAAa,2BAA2B,IAAqB,QAAmB,cAAsD;AACrI,WAAO,MAAM,GAAG,YAAY,OAAMA,QAAM;AACvC,YAAM,cAAc,MAAMA,IAAG,aAAa,MAAM,IAAI,6BAA6B,OAAO,EAAE,CAAC;AAC3F,YAAM,aAAa,YAAY,KAAK,CAAA,OAAM,GAAG,OAAO,YAAY;AAChE,UAAI,CAAC,YAAY;AAChB,eAAO,IAAI,cAAc,aAAa,8DAA8D,YAAY,IAAI;AAAA,MACrH;AAGA,UAAI,WAAW,4CAA4C;AAC1D,eAAO,IAAI;AAAA,UACV;AAAA,UACA,0BAA0B,WAAW,oBAAoB;AAAA,QAAA;AAAA,MAE3D;AAEA,YAAM,gBAAgB,MAAMA,IAAG,aAAa,MAAM,IAAI,mBAAmBA,IAAG,SAAS,CAAC;AACtF,YAAM,cAAc,OAAO,kBAAkB;AAC7C,YAAM,kBAAkB,sBAAsB,cAAc,aAAa,SAAS,OAAO,oBAAoB;AAC7G,YAAM,yBAAyB,YAAY,OAAO,CAAA,OAAM,GAAG,OAAO,WAAW,MAAM,GAAG,+BAA+B,IAAI;AACzH,YAAM,eAAe,CAAC,eAAe,CAAC,mBAAmB,uBAAuB,WAAW;AAC3F,UAAI,cAAc;AACjB,eAAO,IAAI;AAAA,UACV;AAAA,UACA;AAAA,QAAA;AAAA,MAEF;AAEA,YAAMA,IAAG,WAAW,QAAQ,IAAI,wCAAwC,OAAO,IAAI,WAAW,EAAE,CAAC;AACjG,aAAO,IAAI,WAAW,EAAE,MAAM,WAAW,sBAAsB;AAAA,IAChE,CAAC;AAAA,EACF;AACD;"}
@@ -33,9 +33,56 @@ const initOIDCAuth = async (client, { redirectUrl, scope, responseMode }) => {
33
33
  };
34
34
  };
35
35
  const getClaim = (source, path) => path.split(".").reduce(
36
- (acc, key) => acc != null && typeof acc === "object" ? acc[key] : void 0,
36
+ (acc, key) => acc != null && typeof acc === "object" && Object.prototype.hasOwnProperty.call(acc, key) ? acc[key] : void 0,
37
37
  source
38
38
  );
39
+ const liftNestedClaims = (source, attributesKey) => {
40
+ if (!attributesKey) {
41
+ return source;
42
+ }
43
+ const nested = Object.prototype.hasOwnProperty.call(source, attributesKey) ? source[attributesKey] : void 0;
44
+ if (nested !== null && typeof nested === "object" && !Array.isArray(nested)) {
45
+ return { ...nested, ...source };
46
+ }
47
+ return source;
48
+ };
49
+ const normalizeClaims = (rawSource, claimMapping, subFallback) => {
50
+ const source = liftNestedClaims(rawSource, claimMapping?.attributesKey);
51
+ const rawEmailVerified = source.email_verified;
52
+ const emailVerified = rawEmailVerified === true || rawEmailVerified === "true";
53
+ const mappedSubject = getClaim(source, claimMapping?.externalIdentifier ?? "sub");
54
+ let externalIdentifier;
55
+ if (mappedSubject === void 0 || mappedSubject === null) {
56
+ externalIdentifier = subFallback ?? "";
57
+ } else if (typeof mappedSubject === "string" || typeof mappedSubject === "number") {
58
+ externalIdentifier = String(mappedSubject);
59
+ } else {
60
+ throw new IDPValidationError.IDPValidationError(`The mapped externalIdentifier claim is not a scalar value`);
61
+ }
62
+ if (externalIdentifier === "") {
63
+ throw new IDPValidationError.IDPValidationError(`The mapped externalIdentifier claim resolved to an empty value`);
64
+ }
65
+ const email = getClaim(source, claimMapping?.email ?? "email");
66
+ const name = resolveName(source, claimMapping);
67
+ return {
68
+ ...source,
69
+ externalIdentifier,
70
+ email: typeof email === "string" ? email : void 0,
71
+ name,
72
+ emailVerified
73
+ };
74
+ };
75
+ const resolveName = (source, claimMapping) => {
76
+ const mapped = getClaim(source, claimMapping?.name ?? "name");
77
+ if (typeof mapped === "string" && mapped.trim() !== "") {
78
+ return mapped;
79
+ }
80
+ if (claimMapping?.name !== void 0) {
81
+ return void 0;
82
+ }
83
+ const parts = [getClaim(source, "given_name"), getClaim(source, "family_name")].filter((part) => typeof part === "string" && part.trim() !== "").map((part) => part.trim());
84
+ return parts.length > 0 ? parts.join(" ") : void 0;
85
+ };
39
86
  const handleOIDCResponse = async (client, { sessionData, redirectUrl, ...otherData }, { fetchUserInfo, returnOIDCResult, captureSession, claimMapping } = {}) => {
40
87
  const params = "parameters" in otherData ? otherData.parameters : client.callbackParams(otherData.url);
41
88
  if (params.state && !sessionData?.state) {
@@ -48,37 +95,10 @@ const handleOIDCResponse = async (client, { sessionData, redirectUrl, ...otherDa
48
95
  const userInfo = result.access_token && fetchUserInfo ? await client.userinfo(result) : {};
49
96
  const oidcResult = returnOIDCResult ? result : {};
50
97
  const idpSession = captureSession ? tokenSetToSessionState(result, typeof claims.sid === "string" ? claims.sid : void 0) : void 0;
51
- let source = { ...claimsWithoutHashes, ...userInfo };
52
- const attributesKey = claimMapping?.attributesKey;
53
- if (attributesKey) {
54
- const nested = source[attributesKey];
55
- if (nested && typeof nested === "object" && !Array.isArray(nested)) {
56
- source = { ...nested, ...source };
57
- }
58
- }
59
- const rawEmailVerified = source.email_verified;
60
- const emailVerified = rawEmailVerified === true || rawEmailVerified === "true";
61
- const mappedSubject = getClaim(source, claimMapping?.externalIdentifier ?? "sub");
62
- let externalIdentifier;
63
- if (mappedSubject === void 0 || mappedSubject === null) {
64
- externalIdentifier = claims.sub;
65
- } else if (typeof mappedSubject === "string" || typeof mappedSubject === "number") {
66
- externalIdentifier = String(mappedSubject);
67
- } else {
68
- throw new IDPValidationError.IDPValidationError(`The mapped externalIdentifier claim is not a scalar value`);
69
- }
70
- if (externalIdentifier === "") {
71
- throw new IDPValidationError.IDPValidationError(`The mapped externalIdentifier claim resolved to an empty value`);
72
- }
73
- const email = getClaim(source, claimMapping?.email ?? "email");
74
- const name = getClaim(source, claimMapping?.name ?? "name");
98
+ const normalized = normalizeClaims({ ...claimsWithoutHashes, ...userInfo }, claimMapping, claims.sub);
75
99
  return {
76
100
  ...oidcResult,
77
- ...source,
78
- externalIdentifier,
79
- email: typeof email === "string" ? email : void 0,
80
- name: typeof name === "string" ? name : void 0,
81
- emailVerified,
101
+ ...normalized,
82
102
  ...idpSession ? { idpSession } : {}
83
103
  };
84
104
  } catch (e) {
@@ -96,7 +116,8 @@ const handleOIDCResponse = async (client, { sessionData, redirectUrl, ...otherDa
96
116
  }
97
117
  };
98
118
  const REVOKED_OIDC_ERRORS = /* @__PURE__ */ new Set(["invalid_grant", "invalid_token", "expired_token"]);
99
- const revalidateOIDC = async (client, method, session) => {
119
+ const revalidateOIDC = async (client, method, session, options = {}) => {
120
+ const { claimMapping, fetchUserInfo } = options;
100
121
  const tokens = session.tokens ?? {};
101
122
  const refreshToken = typeof tokens.refresh_token === "string" ? tokens.refresh_token : void 0;
102
123
  const accessToken = typeof tokens.access_token === "string" ? tokens.access_token : void 0;
@@ -107,14 +128,22 @@ const revalidateOIDC = async (client, method, session) => {
107
128
  }
108
129
  const tokenSet = await client.refresh(refreshToken);
109
130
  let claims;
131
+ let claimsComplete = false;
110
132
  try {
111
- claims = tokenSet.id_token ? tokenSet.claims() : void 0;
133
+ if (tokenSet.id_token) {
134
+ const idClaims = tokenSet.claims();
135
+ const userInfo = tokenSet.access_token && fetchUserInfo ? await client.userinfo(tokenSet) : {};
136
+ claims = normalizeClaims({ ...idClaims, ...userInfo }, claimMapping, typeof idClaims.sub === "string" ? idClaims.sub : void 0);
137
+ claimsComplete = true;
138
+ }
112
139
  } catch {
113
140
  claims = void 0;
141
+ claimsComplete = false;
114
142
  }
115
143
  return {
116
144
  status: "valid",
117
145
  claims,
146
+ claimsComplete,
118
147
  // carry the stored tokens forward: a non-rotating IdP omits the refresh token here
119
148
  idpSession: tokenSetToSessionState(tokenSet, session.sessionId, tokens)
120
149
  };
@@ -124,7 +153,13 @@ const revalidateOIDC = async (client, method, session) => {
124
153
  return { status: "revoked", reason: "no_access_token" };
125
154
  }
126
155
  const userInfo = await client.userinfo(accessToken);
127
- return { status: "valid", claims: userInfo };
156
+ let claims;
157
+ try {
158
+ claims = normalizeClaims(userInfo, claimMapping, typeof userInfo.sub === "string" ? userInfo.sub : void 0);
159
+ } catch {
160
+ claims = void 0;
161
+ }
162
+ return { status: "valid", claims, claimsComplete: false };
128
163
  }
129
164
  const token = accessToken ?? refreshToken;
130
165
  if (!token) {
@@ -215,6 +250,7 @@ const validateOIDCLogoutToken = async (client, issuer, logoutToken) => {
215
250
  exports.buildOIDCLogoutUrl = buildOIDCLogoutUrl;
216
251
  exports.handleOIDCResponse = handleOIDCResponse;
217
252
  exports.initOIDCAuth = initOIDCAuth;
253
+ exports.liftNestedClaims = liftNestedClaims;
218
254
  exports.revalidateOIDC = revalidateOIDC;
219
255
  exports.tokenSetToSessionState = tokenSetToSessionState;
220
256
  exports.validateOIDCLogoutToken = validateOIDCLogoutToken;