@authup/server-core 1.0.0-beta.52 → 1.0.0-beta.53

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 (742) hide show
  1. package/dist/adapters/database/data-source/options/module.d.ts.map +1 -1
  2. package/dist/adapters/database/data-source/options/module.mjs +18 -8
  3. package/dist/adapters/database/data-source/options/module.mjs.map +1 -1
  4. package/dist/adapters/database/domains/client/entity.d.ts +5 -2
  5. package/dist/adapters/database/domains/client/entity.d.ts.map +1 -1
  6. package/dist/adapters/database/domains/client/entity.mjs +28 -4
  7. package/dist/adapters/database/domains/client/entity.mjs.map +1 -1
  8. package/dist/adapters/database/domains/client-permission/entity.mjs +2 -2
  9. package/dist/adapters/database/domains/consent/entity.d.ts +20 -0
  10. package/dist/adapters/database/domains/consent/entity.d.ts.map +1 -0
  11. package/dist/adapters/database/domains/consent/entity.mjs +110 -0
  12. package/dist/adapters/database/domains/consent/entity.mjs.map +1 -0
  13. package/dist/adapters/database/domains/consent/index.d.ts +3 -0
  14. package/dist/adapters/database/domains/consent/index.d.ts.map +1 -0
  15. package/dist/adapters/database/domains/consent/index.mjs +6 -0
  16. package/dist/adapters/database/domains/consent/subscriber.d.ts +6 -0
  17. package/dist/adapters/database/domains/consent/subscriber.d.ts.map +1 -0
  18. package/dist/adapters/database/domains/consent/subscriber.mjs +45 -0
  19. package/dist/adapters/database/domains/consent/subscriber.mjs.map +1 -0
  20. package/dist/adapters/database/domains/constants.d.ts +1 -0
  21. package/dist/adapters/database/domains/constants.d.ts.map +1 -1
  22. package/dist/adapters/database/domains/constants.mjs +1 -0
  23. package/dist/adapters/database/domains/constants.mjs.map +1 -1
  24. package/dist/adapters/database/domains/event/entity.d.ts +22 -0
  25. package/dist/adapters/database/domains/event/entity.d.ts.map +1 -0
  26. package/dist/adapters/database/domains/event/entity.mjs +174 -0
  27. package/dist/adapters/database/domains/event/entity.mjs.map +1 -0
  28. package/dist/adapters/database/domains/event/index.d.ts +2 -0
  29. package/dist/adapters/database/domains/event/index.d.ts.map +1 -0
  30. package/dist/adapters/database/domains/event/index.mjs +5 -0
  31. package/dist/adapters/database/domains/identity-provider-account/entity.mjs +2 -2
  32. package/dist/adapters/database/domains/index.d.ts +4 -0
  33. package/dist/adapters/database/domains/index.d.ts.map +1 -1
  34. package/dist/adapters/database/domains/index.mjs +24 -15
  35. package/dist/adapters/database/domains/key/entity.d.ts +7 -3
  36. package/dist/adapters/database/domains/key/entity.d.ts.map +1 -1
  37. package/dist/adapters/database/domains/key/entity.mjs +35 -10
  38. package/dist/adapters/database/domains/key/entity.mjs.map +1 -1
  39. package/dist/adapters/database/domains/permission-policy/entity.mjs +2 -2
  40. package/dist/adapters/database/domains/policy/repository.d.ts.map +1 -1
  41. package/dist/adapters/database/domains/policy/repository.mjs +3 -3
  42. package/dist/adapters/database/domains/policy/repository.mjs.map +1 -1
  43. package/dist/adapters/database/domains/robot-permission/entity.mjs +2 -2
  44. package/dist/adapters/database/domains/role/repository.mjs +1 -1
  45. package/dist/adapters/database/domains/role-permission/entity.mjs +2 -2
  46. package/dist/adapters/database/domains/session/entity.d.ts +3 -1
  47. package/dist/adapters/database/domains/session/entity.d.ts.map +1 -1
  48. package/dist/adapters/database/domains/session/entity.mjs +12 -0
  49. package/dist/adapters/database/domains/session/entity.mjs.map +1 -1
  50. package/dist/adapters/database/domains/trust-anchor/entity.d.ts +13 -0
  51. package/dist/adapters/database/domains/trust-anchor/entity.d.ts.map +1 -0
  52. package/dist/adapters/database/domains/trust-anchor/entity.mjs +55 -0
  53. package/dist/adapters/database/domains/trust-anchor/entity.mjs.map +1 -0
  54. package/dist/adapters/database/domains/trust-anchor/index.d.ts +2 -0
  55. package/dist/adapters/database/domains/trust-anchor/index.d.ts.map +1 -0
  56. package/dist/adapters/database/domains/trust-anchor/index.mjs +5 -0
  57. package/dist/adapters/database/domains/user-authenticator/entity.d.ts +20 -0
  58. package/dist/adapters/database/domains/user-authenticator/entity.d.ts.map +1 -0
  59. package/dist/adapters/database/domains/user-authenticator/entity.mjs +98 -0
  60. package/dist/adapters/database/domains/user-authenticator/entity.mjs.map +1 -0
  61. package/dist/adapters/database/domains/user-authenticator/index.d.ts +2 -0
  62. package/dist/adapters/database/domains/user-authenticator/index.d.ts.map +1 -0
  63. package/dist/adapters/database/domains/user-authenticator/index.mjs +5 -0
  64. package/dist/adapters/database/domains/user-permission/entity.mjs +1 -1
  65. package/dist/adapters/database/errors/driver.d.ts +14 -0
  66. package/dist/adapters/database/errors/driver.d.ts.map +1 -0
  67. package/dist/adapters/database/errors/driver.mjs +32 -0
  68. package/dist/adapters/database/errors/driver.mjs.map +1 -0
  69. package/dist/adapters/database/errors/index.d.ts +1 -0
  70. package/dist/adapters/database/errors/index.d.ts.map +1 -1
  71. package/dist/adapters/database/errors/index.mjs +2 -1
  72. package/dist/adapters/database/index.mjs +17 -11
  73. package/dist/adapters/database/migrations/mysql/1783769340000-Default.d.ts +50 -0
  74. package/dist/adapters/database/migrations/mysql/1783769340000-Default.d.ts.map +1 -0
  75. package/dist/adapters/database/migrations/mysql/1783769340000-Default.mjs +320 -0
  76. package/dist/adapters/database/migrations/mysql/1783769340000-Default.mjs.map +1 -0
  77. package/dist/adapters/database/migrations/postgres/1783769340000-Default.d.ts +50 -0
  78. package/dist/adapters/database/migrations/postgres/1783769340000-Default.d.ts.map +1 -0
  79. package/dist/adapters/database/migrations/postgres/1783769340000-Default.mjs +310 -0
  80. package/dist/adapters/database/migrations/postgres/1783769340000-Default.mjs.map +1 -0
  81. package/dist/adapters/database/subscriber/module.d.ts +1 -1
  82. package/dist/adapters/database/subscriber/module.d.ts.map +1 -1
  83. package/dist/adapters/database/subscriber/module.mjs +4 -3
  84. package/dist/adapters/database/subscriber/module.mjs.map +1 -1
  85. package/dist/adapters/http/adapters/index.mjs +2 -1
  86. package/dist/adapters/http/adapters/oauth2/authorization/module.d.ts +4 -1
  87. package/dist/adapters/http/adapters/oauth2/authorization/module.d.ts.map +1 -1
  88. package/dist/adapters/http/adapters/oauth2/authorization/module.mjs +27 -2
  89. package/dist/adapters/http/adapters/oauth2/authorization/module.mjs.map +1 -1
  90. package/dist/adapters/http/adapters/oauth2/authorization/types.d.ts +9 -1
  91. package/dist/adapters/http/adapters/oauth2/authorization/types.d.ts.map +1 -1
  92. package/dist/adapters/http/adapters/oauth2/grant-types/authorize.d.ts +4 -1
  93. package/dist/adapters/http/adapters/oauth2/grant-types/authorize.d.ts.map +1 -1
  94. package/dist/adapters/http/adapters/oauth2/grant-types/authorize.mjs +23 -3
  95. package/dist/adapters/http/adapters/oauth2/grant-types/authorize.mjs.map +1 -1
  96. package/dist/adapters/http/adapters/oauth2/grant-types/client-credentials.d.ts +4 -3
  97. package/dist/adapters/http/adapters/oauth2/grant-types/client-credentials.d.ts.map +1 -1
  98. package/dist/adapters/http/adapters/oauth2/grant-types/client-credentials.mjs +13 -6
  99. package/dist/adapters/http/adapters/oauth2/grant-types/client-credentials.mjs.map +1 -1
  100. package/dist/adapters/http/adapters/oauth2/grant-types/index.mjs +2 -1
  101. package/dist/adapters/http/adapters/oauth2/grant-types/password.d.ts +38 -2
  102. package/dist/adapters/http/adapters/oauth2/grant-types/password.d.ts.map +1 -1
  103. package/dist/adapters/http/adapters/oauth2/grant-types/password.mjs +119 -6
  104. package/dist/adapters/http/adapters/oauth2/grant-types/password.mjs.map +1 -1
  105. package/dist/adapters/http/adapters/oauth2/grant-types/refresh_token.d.ts +2 -0
  106. package/dist/adapters/http/adapters/oauth2/grant-types/refresh_token.d.ts.map +1 -1
  107. package/dist/adapters/http/adapters/oauth2/grant-types/refresh_token.mjs +16 -3
  108. package/dist/adapters/http/adapters/oauth2/grant-types/refresh_token.mjs.map +1 -1
  109. package/dist/adapters/http/adapters/oauth2/grant-types/types.d.ts +14 -3
  110. package/dist/adapters/http/adapters/oauth2/grant-types/types.d.ts.map +1 -1
  111. package/dist/adapters/http/adapters/oauth2/grant-types/utils/certificate.d.ts +5 -0
  112. package/dist/adapters/http/adapters/oauth2/grant-types/utils/certificate.d.ts.map +1 -0
  113. package/dist/adapters/http/adapters/oauth2/grant-types/utils/certificate.mjs +18 -0
  114. package/dist/adapters/http/adapters/oauth2/grant-types/utils/certificate.mjs.map +1 -0
  115. package/dist/adapters/http/adapters/oauth2/grant-types/utils/credentials.mjs +1 -1
  116. package/dist/adapters/http/adapters/oauth2/grant-types/utils/guess.mjs +1 -1
  117. package/dist/adapters/http/adapters/oauth2/grant-types/utils/index.d.ts +1 -0
  118. package/dist/adapters/http/adapters/oauth2/grant-types/utils/index.d.ts.map +1 -1
  119. package/dist/adapters/http/adapters/oauth2/grant-types/utils/index.mjs +2 -1
  120. package/dist/adapters/http/adapters/oauth2/index.mjs +2 -1
  121. package/dist/adapters/http/controllers/entities/consent/index.d.ts +2 -0
  122. package/dist/adapters/http/controllers/entities/consent/index.d.ts.map +1 -0
  123. package/dist/adapters/http/controllers/entities/consent/index.mjs +5 -0
  124. package/dist/adapters/http/controllers/entities/consent/module.d.ts +15 -0
  125. package/dist/adapters/http/controllers/entities/consent/module.d.ts.map +1 -0
  126. package/dist/adapters/http/controllers/entities/consent/module.mjs +82 -0
  127. package/dist/adapters/http/controllers/entities/consent/module.mjs.map +1 -0
  128. package/dist/adapters/http/controllers/entities/event/index.d.ts +2 -0
  129. package/dist/adapters/http/controllers/entities/event/index.d.ts.map +1 -0
  130. package/dist/adapters/http/controllers/entities/event/index.mjs +5 -0
  131. package/dist/adapters/http/controllers/entities/event/module.d.ts +14 -0
  132. package/dist/adapters/http/controllers/entities/event/module.d.ts.map +1 -0
  133. package/dist/adapters/http/controllers/entities/event/module.mjs +68 -0
  134. package/dist/adapters/http/controllers/entities/event/module.mjs.map +1 -0
  135. package/dist/adapters/http/controllers/entities/identity-provider/module.d.ts +4 -1
  136. package/dist/adapters/http/controllers/entities/identity-provider/module.d.ts.map +1 -1
  137. package/dist/adapters/http/controllers/entities/identity-provider/module.mjs +38 -10
  138. package/dist/adapters/http/controllers/entities/identity-provider/module.mjs.map +1 -1
  139. package/dist/adapters/http/controllers/entities/identity-provider/types.d.ts +3 -1
  140. package/dist/adapters/http/controllers/entities/identity-provider/types.d.ts.map +1 -1
  141. package/dist/adapters/http/controllers/entities/index.d.ts +5 -0
  142. package/dist/adapters/http/controllers/entities/index.d.ts.map +1 -1
  143. package/dist/adapters/http/controllers/entities/index.mjs +11 -1
  144. package/dist/adapters/http/controllers/entities/key/index.d.ts +2 -0
  145. package/dist/adapters/http/controllers/entities/key/index.d.ts.map +1 -0
  146. package/dist/adapters/http/controllers/entities/key/index.mjs +5 -0
  147. package/dist/adapters/http/controllers/entities/key/module.d.ts +17 -0
  148. package/dist/adapters/http/controllers/entities/key/module.d.ts.map +1 -0
  149. package/dist/adapters/http/controllers/entities/key/module.mjs +122 -0
  150. package/dist/adapters/http/controllers/entities/key/module.mjs.map +1 -0
  151. package/dist/adapters/http/controllers/entities/policy/utils/validation.mjs +1 -1
  152. package/dist/adapters/http/controllers/entities/realm/module.d.ts +2 -0
  153. package/dist/adapters/http/controllers/entities/realm/module.d.ts.map +1 -1
  154. package/dist/adapters/http/controllers/entities/realm/module.mjs +16 -1
  155. package/dist/adapters/http/controllers/entities/realm/module.mjs.map +1 -1
  156. package/dist/adapters/http/controllers/entities/trust-anchor/index.d.ts +2 -0
  157. package/dist/adapters/http/controllers/entities/trust-anchor/index.d.ts.map +1 -0
  158. package/dist/adapters/http/controllers/entities/trust-anchor/index.mjs +5 -0
  159. package/dist/adapters/http/controllers/entities/trust-anchor/module.d.ts +17 -0
  160. package/dist/adapters/http/controllers/entities/trust-anchor/module.d.ts.map +1 -0
  161. package/dist/adapters/http/controllers/entities/trust-anchor/module.mjs +120 -0
  162. package/dist/adapters/http/controllers/entities/trust-anchor/module.mjs.map +1 -0
  163. package/dist/adapters/http/controllers/entities/user-authenticator/index.d.ts +2 -0
  164. package/dist/adapters/http/controllers/entities/user-authenticator/index.d.ts.map +1 -0
  165. package/dist/adapters/http/controllers/entities/user-authenticator/index.mjs +5 -0
  166. package/dist/adapters/http/controllers/entities/user-authenticator/module.d.ts +21 -0
  167. package/dist/adapters/http/controllers/entities/user-authenticator/module.d.ts.map +1 -0
  168. package/dist/adapters/http/controllers/entities/user-authenticator/module.mjs +154 -0
  169. package/dist/adapters/http/controllers/entities/user-authenticator/module.mjs.map +1 -0
  170. package/dist/adapters/http/controllers/index.mjs +7 -1
  171. package/dist/adapters/http/controllers/workflows/authenticator-challenge/index.d.ts +2 -0
  172. package/dist/adapters/http/controllers/workflows/authenticator-challenge/index.d.ts.map +1 -0
  173. package/dist/adapters/http/controllers/workflows/authenticator-challenge/index.mjs +5 -0
  174. package/dist/adapters/http/controllers/workflows/authenticator-challenge/module.d.ts +46 -0
  175. package/dist/adapters/http/controllers/workflows/authenticator-challenge/module.d.ts.map +1 -0
  176. package/dist/adapters/http/controllers/workflows/authenticator-challenge/module.mjs +132 -0
  177. package/dist/adapters/http/controllers/workflows/authenticator-challenge/module.mjs.map +1 -0
  178. package/dist/adapters/http/controllers/workflows/authorize/module.d.ts.map +1 -1
  179. package/dist/adapters/http/controllers/workflows/authorize/module.mjs +34 -6
  180. package/dist/adapters/http/controllers/workflows/authorize/module.mjs.map +1 -1
  181. package/dist/adapters/http/controllers/workflows/authorize/types.d.ts +17 -1
  182. package/dist/adapters/http/controllers/workflows/authorize/types.d.ts.map +1 -1
  183. package/dist/adapters/http/controllers/workflows/index.d.ts +1 -0
  184. package/dist/adapters/http/controllers/workflows/index.d.ts.map +1 -1
  185. package/dist/adapters/http/controllers/workflows/index.mjs +3 -1
  186. package/dist/adapters/http/controllers/workflows/jwks/handlers/read.d.ts.map +1 -1
  187. package/dist/adapters/http/controllers/workflows/jwks/handlers/read.mjs +28 -14
  188. package/dist/adapters/http/controllers/workflows/jwks/handlers/read.mjs.map +1 -1
  189. package/dist/adapters/http/controllers/workflows/jwks/module.d.ts.map +1 -1
  190. package/dist/adapters/http/controllers/workflows/jwks/module.mjs +28 -14
  191. package/dist/adapters/http/controllers/workflows/jwks/module.mjs.map +1 -1
  192. package/dist/adapters/http/controllers/workflows/token/module.d.ts +2 -1
  193. package/dist/adapters/http/controllers/workflows/token/module.d.ts.map +1 -1
  194. package/dist/adapters/http/controllers/workflows/token/module.mjs +28 -8
  195. package/dist/adapters/http/controllers/workflows/token/module.mjs.map +1 -1
  196. package/dist/adapters/http/controllers/workflows/token/types.d.ts +11 -4
  197. package/dist/adapters/http/controllers/workflows/token/types.d.ts.map +1 -1
  198. package/dist/adapters/http/index.mjs +13 -3
  199. package/dist/adapters/http/middleware/built-in/assets.mjs +1 -1
  200. package/dist/adapters/http/middleware/built-in/authorization/module.d.ts +13 -0
  201. package/dist/adapters/http/middleware/built-in/authorization/module.d.ts.map +1 -1
  202. package/dist/adapters/http/middleware/built-in/authorization/module.mjs +52 -2
  203. package/dist/adapters/http/middleware/built-in/authorization/module.mjs.map +1 -1
  204. package/dist/adapters/http/middleware/built-in/authorization/types.d.ts +2 -0
  205. package/dist/adapters/http/middleware/built-in/authorization/types.d.ts.map +1 -1
  206. package/dist/adapters/http/middleware/built-in/index.mjs +2 -2
  207. package/dist/adapters/http/middleware/built-in/prometheus.d.ts +12 -1
  208. package/dist/adapters/http/middleware/built-in/prometheus.d.ts.map +1 -1
  209. package/dist/adapters/http/middleware/built-in/prometheus.mjs +75 -6
  210. package/dist/adapters/http/middleware/built-in/prometheus.mjs.map +1 -1
  211. package/dist/adapters/http/middleware/index.mjs +2 -2
  212. package/dist/adapters/http/request/client-certificate.d.ts +5 -0
  213. package/dist/adapters/http/request/client-certificate.d.ts.map +1 -0
  214. package/dist/adapters/http/request/client-certificate.mjs +88 -0
  215. package/dist/adapters/http/request/client-certificate.mjs.map +1 -0
  216. package/dist/adapters/http/request/constants.d.ts +1 -0
  217. package/dist/adapters/http/request/constants.d.ts.map +1 -1
  218. package/dist/adapters/http/request/constants.mjs +6 -1
  219. package/dist/adapters/http/request/constants.mjs.map +1 -1
  220. package/dist/adapters/http/request/event-context.d.ts +19 -0
  221. package/dist/adapters/http/request/event-context.d.ts.map +1 -0
  222. package/dist/adapters/http/request/event-context.mjs +37 -0
  223. package/dist/adapters/http/request/event-context.mjs.map +1 -0
  224. package/dist/adapters/http/request/helpers/index.d.ts +1 -0
  225. package/dist/adapters/http/request/helpers/index.d.ts.map +1 -1
  226. package/dist/adapters/http/request/helpers/index.mjs +2 -1
  227. package/dist/adapters/http/request/helpers/mfa-login-ticket.d.ts +16 -0
  228. package/dist/adapters/http/request/helpers/mfa-login-ticket.d.ts.map +1 -0
  229. package/dist/adapters/http/request/helpers/mfa-login-ticket.mjs +15 -0
  230. package/dist/adapters/http/request/helpers/mfa-login-ticket.mjs.map +1 -0
  231. package/dist/adapters/http/request/index.d.ts +3 -0
  232. package/dist/adapters/http/request/index.d.ts.map +1 -1
  233. package/dist/adapters/http/request/index.mjs +5 -2
  234. package/dist/adapters/http/request/types.d.ts +3 -0
  235. package/dist/adapters/http/request/types.d.ts.map +1 -0
  236. package/dist/adapters/http/ui/render.mjs +2 -2
  237. package/dist/app/index.mjs +11 -5
  238. package/dist/app/modules/components/module.d.ts.map +1 -1
  239. package/dist/app/modules/components/module.mjs +22 -2
  240. package/dist/app/modules/components/module.mjs.map +1 -1
  241. package/dist/app/modules/config/constants.d.ts +14 -0
  242. package/dist/app/modules/config/constants.d.ts.map +1 -1
  243. package/dist/app/modules/config/constants.mjs +14 -0
  244. package/dist/app/modules/config/constants.mjs.map +1 -1
  245. package/dist/app/modules/config/normalize.d.ts.map +1 -1
  246. package/dist/app/modules/config/normalize.mjs +30 -2
  247. package/dist/app/modules/config/normalize.mjs.map +1 -1
  248. package/dist/app/modules/config/read/env.d.ts.map +1 -1
  249. package/dist/app/modules/config/read/env.mjs +57 -0
  250. package/dist/app/modules/config/read/env.mjs.map +1 -1
  251. package/dist/app/modules/config/types.d.ts +101 -0
  252. package/dist/app/modules/config/types.d.ts.map +1 -1
  253. package/dist/app/modules/config/validator.d.ts.map +1 -1
  254. package/dist/app/modules/config/validator.mjs +16 -0
  255. package/dist/app/modules/config/validator.mjs.map +1 -1
  256. package/dist/app/modules/database/constants.d.ts +3 -0
  257. package/dist/app/modules/database/constants.d.ts.map +1 -1
  258. package/dist/app/modules/database/constants.mjs +3 -1
  259. package/dist/app/modules/database/constants.mjs.map +1 -1
  260. package/dist/app/modules/database/index.mjs +7 -3
  261. package/dist/app/modules/database/module.d.ts +1 -0
  262. package/dist/app/modules/database/module.d.ts.map +1 -1
  263. package/dist/app/modules/database/module.mjs +32 -1
  264. package/dist/app/modules/database/module.mjs.map +1 -1
  265. package/dist/app/modules/database/repositories/client/repository.d.ts.map +1 -1
  266. package/dist/app/modules/database/repositories/client/repository.mjs +8 -4
  267. package/dist/app/modules/database/repositories/client/repository.mjs.map +1 -1
  268. package/dist/app/modules/database/repositories/event/index.d.ts.map +1 -0
  269. package/dist/app/modules/database/repositories/event/index.mjs +5 -0
  270. package/dist/app/modules/database/repositories/event/repository.d.ts +15 -0
  271. package/dist/app/modules/database/repositories/event/repository.d.ts.map +1 -0
  272. package/dist/app/modules/database/repositories/event/repository.mjs +113 -0
  273. package/dist/app/modules/database/repositories/event/repository.mjs.map +1 -0
  274. package/dist/app/modules/database/repositories/helpers.d.ts +4 -2
  275. package/dist/app/modules/database/repositories/helpers.d.ts.map +1 -1
  276. package/dist/app/modules/database/repositories/helpers.mjs +7 -3
  277. package/dist/app/modules/database/repositories/helpers.mjs.map +1 -1
  278. package/dist/app/modules/database/repositories/index.d.ts +4 -0
  279. package/dist/app/modules/database/repositories/index.d.ts.map +1 -1
  280. package/dist/app/modules/database/repositories/index.mjs +9 -1
  281. package/dist/app/modules/database/repositories/key/index.d.ts +2 -0
  282. package/dist/app/modules/database/repositories/key/index.d.ts.map +1 -0
  283. package/dist/app/modules/database/repositories/key/index.mjs +5 -0
  284. package/dist/app/modules/database/repositories/key/repository.d.ts +50 -0
  285. package/dist/app/modules/database/repositories/key/repository.d.ts.map +1 -0
  286. package/dist/app/modules/database/repositories/key/repository.mjs +273 -0
  287. package/dist/app/modules/database/repositories/key/repository.mjs.map +1 -0
  288. package/dist/app/modules/database/repositories/permission-provider/module.mjs +1 -1
  289. package/dist/app/modules/database/repositories/trust-anchor/index.d.ts +2 -0
  290. package/dist/app/modules/database/repositories/trust-anchor/index.d.ts.map +1 -0
  291. package/dist/app/modules/database/repositories/trust-anchor/index.mjs +5 -0
  292. package/dist/app/modules/database/repositories/trust-anchor/repository.d.ts +24 -0
  293. package/dist/app/modules/database/repositories/trust-anchor/repository.d.ts.map +1 -0
  294. package/dist/app/modules/database/repositories/trust-anchor/repository.mjs +113 -0
  295. package/dist/app/modules/database/repositories/trust-anchor/repository.mjs.map +1 -0
  296. package/dist/app/modules/database/repositories/user-authenticator/index.d.ts +2 -0
  297. package/dist/app/modules/database/repositories/user-authenticator/index.d.ts.map +1 -0
  298. package/dist/app/modules/database/repositories/user-authenticator/index.mjs +5 -0
  299. package/dist/app/modules/database/repositories/user-authenticator/repository.d.ts +19 -0
  300. package/dist/app/modules/database/repositories/user-authenticator/repository.d.ts.map +1 -0
  301. package/dist/app/modules/database/repositories/user-authenticator/repository.mjs +92 -0
  302. package/dist/app/modules/database/repositories/user-authenticator/repository.mjs.map +1 -0
  303. package/dist/app/modules/http/module.d.ts +8 -0
  304. package/dist/app/modules/http/module.d.ts.map +1 -1
  305. package/dist/app/modules/http/module.mjs +19 -1
  306. package/dist/app/modules/http/module.mjs.map +1 -1
  307. package/dist/app/modules/http/modules/controller.d.ts +16 -3
  308. package/dist/app/modules/http/modules/controller.d.ts.map +1 -1
  309. package/dist/app/modules/http/modules/controller.mjs +186 -15
  310. package/dist/app/modules/http/modules/controller.mjs.map +1 -1
  311. package/dist/app/modules/http/modules/middleware.d.ts +1 -0
  312. package/dist/app/modules/http/modules/middleware.d.ts.map +1 -1
  313. package/dist/app/modules/http/modules/middleware.mjs +10 -4
  314. package/dist/app/modules/http/modules/middleware.mjs.map +1 -1
  315. package/dist/app/modules/identity/module.mjs +2 -2
  316. package/dist/app/modules/index.d.ts +1 -0
  317. package/dist/app/modules/index.d.ts.map +1 -1
  318. package/dist/app/modules/index.mjs +13 -6
  319. package/dist/app/modules/mail/module.d.ts.map +1 -1
  320. package/dist/app/modules/mail/module.mjs +2 -1
  321. package/dist/app/modules/mail/module.mjs.map +1 -1
  322. package/dist/app/modules/metrics/constants.d.ts +4 -0
  323. package/dist/app/modules/metrics/constants.d.ts.map +1 -0
  324. package/dist/app/modules/metrics/constants.mjs +10 -0
  325. package/dist/app/modules/metrics/constants.mjs.map +1 -0
  326. package/dist/app/modules/metrics/index.d.ts +3 -0
  327. package/dist/app/modules/metrics/index.d.ts.map +1 -0
  328. package/dist/app/modules/metrics/index.mjs +6 -0
  329. package/dist/app/modules/metrics/prom.d.ts +15 -0
  330. package/dist/app/modules/metrics/prom.d.ts.map +1 -0
  331. package/dist/app/modules/metrics/prom.mjs +42 -0
  332. package/dist/app/modules/metrics/prom.mjs.map +1 -0
  333. package/dist/app/modules/oauth2/constants.d.ts +9 -2
  334. package/dist/app/modules/oauth2/constants.d.ts.map +1 -1
  335. package/dist/app/modules/oauth2/constants.mjs +7 -1
  336. package/dist/app/modules/oauth2/constants.mjs.map +1 -1
  337. package/dist/app/modules/oauth2/module.d.ts.map +1 -1
  338. package/dist/app/modules/oauth2/module.mjs +23 -4
  339. package/dist/app/modules/oauth2/module.mjs.map +1 -1
  340. package/dist/app/modules/oauth2/repositories/consent/index.d.ts +2 -0
  341. package/dist/app/modules/oauth2/repositories/consent/index.d.ts.map +1 -0
  342. package/dist/app/modules/oauth2/repositories/consent/index.mjs +5 -0
  343. package/dist/app/modules/oauth2/repositories/consent/repository.d.ts +20 -0
  344. package/dist/app/modules/oauth2/repositories/consent/repository.d.ts.map +1 -0
  345. package/dist/app/modules/oauth2/repositories/consent/repository.mjs +116 -0
  346. package/dist/app/modules/oauth2/repositories/consent/repository.mjs.map +1 -0
  347. package/dist/app/modules/oauth2/repositories/index.d.ts +1 -1
  348. package/dist/app/modules/oauth2/repositories/index.d.ts.map +1 -1
  349. package/dist/app/modules/oauth2/repositories/index.mjs +3 -3
  350. package/dist/app/modules/oauth2/repositories/token/repository.d.ts +1 -0
  351. package/dist/app/modules/oauth2/repositories/token/repository.d.ts.map +1 -1
  352. package/dist/app/modules/oauth2/repositories/token/repository.mjs +8 -0
  353. package/dist/app/modules/oauth2/repositories/token/repository.mjs.map +1 -1
  354. package/dist/app/modules/provisioning/module.d.ts.map +1 -1
  355. package/dist/app/modules/provisioning/module.mjs +16 -5
  356. package/dist/app/modules/provisioning/module.mjs.map +1 -1
  357. package/dist/app/modules/provisioning/sources/default/module.d.ts.map +1 -1
  358. package/dist/app/modules/provisioning/sources/default/module.mjs +22 -7
  359. package/dist/app/modules/provisioning/sources/default/module.mjs.map +1 -1
  360. package/dist/app/modules/provisioning/sources/file/module.d.ts.map +1 -1
  361. package/dist/app/modules/provisioning/sources/file/module.mjs +12 -2
  362. package/dist/app/modules/provisioning/sources/file/module.mjs.map +1 -1
  363. package/dist/components/event-cleaner/index.d.ts +2 -0
  364. package/dist/components/event-cleaner/index.d.ts.map +1 -0
  365. package/dist/components/event-cleaner/index.mjs +5 -0
  366. package/dist/components/event-cleaner/module.d.ts +5 -0
  367. package/dist/components/event-cleaner/module.d.ts.map +1 -0
  368. package/dist/components/event-cleaner/module.mjs +30 -0
  369. package/dist/components/event-cleaner/module.mjs.map +1 -0
  370. package/dist/components/index.d.ts +1 -0
  371. package/dist/components/index.d.ts.map +1 -1
  372. package/dist/components/index.mjs +3 -1
  373. package/dist/components/oauth2-cleaner/module.d.ts +2 -1
  374. package/dist/components/oauth2-cleaner/module.d.ts.map +1 -1
  375. package/dist/components/oauth2-cleaner/module.mjs +9 -4
  376. package/dist/components/oauth2-cleaner/module.mjs.map +1 -1
  377. package/dist/core/authentication/credential/entities/client/module.d.ts +1 -1
  378. package/dist/core/authentication/credential/entities/client/module.d.ts.map +1 -1
  379. package/dist/core/authentication/credential/entities/client/module.mjs +2 -1
  380. package/dist/core/authentication/credential/entities/client/module.mjs.map +1 -1
  381. package/dist/core/authentication/entities/client/module.mjs +2 -2
  382. package/dist/core/authentication/entities/client/module.mjs.map +1 -1
  383. package/dist/core/authentication/index.d.ts +1 -0
  384. package/dist/core/authentication/index.d.ts.map +1 -1
  385. package/dist/core/authentication/index.mjs +3 -1
  386. package/dist/core/authentication/login-throttle/index.d.ts +3 -0
  387. package/dist/core/authentication/login-throttle/index.d.ts.map +1 -0
  388. package/dist/core/authentication/login-throttle/index.mjs +5 -0
  389. package/dist/core/authentication/login-throttle/service.d.ts +13 -0
  390. package/dist/core/authentication/login-throttle/service.d.ts.map +1 -0
  391. package/dist/core/authentication/login-throttle/service.mjs +33 -0
  392. package/dist/core/authentication/login-throttle/service.mjs.map +1 -0
  393. package/dist/core/authentication/login-throttle/types.d.ts +34 -0
  394. package/dist/core/authentication/login-throttle/types.d.ts.map +1 -0
  395. package/dist/core/authentication/session/module.d.ts +1 -0
  396. package/dist/core/authentication/session/module.d.ts.map +1 -1
  397. package/dist/core/authentication/session/module.mjs +4 -0
  398. package/dist/core/authentication/session/module.mjs.map +1 -1
  399. package/dist/core/authentication/session/types.d.ts +6 -0
  400. package/dist/core/authentication/session/types.d.ts.map +1 -1
  401. package/dist/core/authentication/session/types.mjs.map +1 -1
  402. package/dist/core/client-certificate/index.d.ts +3 -0
  403. package/dist/core/client-certificate/index.d.ts.map +1 -0
  404. package/dist/core/client-certificate/index.mjs +5 -0
  405. package/dist/core/client-certificate/module.d.ts +18 -0
  406. package/dist/core/client-certificate/module.d.ts.map +1 -0
  407. package/dist/core/client-certificate/module.mjs +195 -0
  408. package/dist/core/client-certificate/module.mjs.map +1 -0
  409. package/dist/core/client-certificate/types.d.ts +22 -0
  410. package/dist/core/client-certificate/types.d.ts.map +1 -0
  411. package/dist/core/client-certificate/types.mjs +4 -0
  412. package/dist/core/entities/client/service.d.ts.map +1 -1
  413. package/dist/core/entities/client/service.mjs +15 -7
  414. package/dist/core/entities/client/service.mjs.map +1 -1
  415. package/dist/core/entities/client/web-client.d.ts.map +1 -1
  416. package/dist/core/entities/client/web-client.mjs +3 -2
  417. package/dist/core/entities/client/web-client.mjs.map +1 -1
  418. package/dist/core/entities/consent/index.d.ts +3 -0
  419. package/dist/core/entities/consent/index.d.ts.map +1 -0
  420. package/dist/core/entities/consent/index.mjs +6 -0
  421. package/dist/core/entities/consent/service.d.ts +19 -0
  422. package/dist/core/entities/consent/service.d.ts.map +1 -0
  423. package/dist/core/entities/consent/service.mjs +122 -0
  424. package/dist/core/entities/consent/service.mjs.map +1 -0
  425. package/dist/core/entities/consent/types.d.ts +97 -0
  426. package/dist/core/entities/consent/types.d.ts.map +1 -0
  427. package/dist/core/entities/consent/types.mjs +25 -0
  428. package/dist/core/entities/consent/types.mjs.map +1 -0
  429. package/dist/core/entities/event/constants.d.ts +7 -0
  430. package/dist/core/entities/event/constants.d.ts.map +1 -0
  431. package/dist/core/entities/event/constants.mjs +13 -0
  432. package/dist/core/entities/event/constants.mjs.map +1 -0
  433. package/dist/core/entities/event/diff.d.ts +20 -0
  434. package/dist/core/entities/event/diff.d.ts.map +1 -0
  435. package/dist/core/entities/event/diff.mjs +45 -0
  436. package/dist/core/entities/event/diff.mjs.map +1 -0
  437. package/dist/core/entities/event/entity-event-handler.d.ts +19 -0
  438. package/dist/core/entities/event/entity-event-handler.d.ts.map +1 -0
  439. package/dist/core/entities/event/entity-event-handler.mjs +100 -0
  440. package/dist/core/entities/event/entity-event-handler.mjs.map +1 -0
  441. package/dist/core/entities/event/index.d.ts +7 -0
  442. package/dist/core/entities/event/index.d.ts.map +1 -0
  443. package/dist/core/entities/event/index.mjs +9 -0
  444. package/dist/core/entities/event/sanitize.d.ts +2 -0
  445. package/dist/core/entities/event/sanitize.d.ts.map +1 -0
  446. package/dist/core/entities/event/sanitize.mjs +83 -0
  447. package/dist/core/entities/event/sanitize.mjs.map +1 -0
  448. package/dist/core/entities/event/service.d.ts +22 -0
  449. package/dist/core/entities/event/service.d.ts.map +1 -0
  450. package/dist/core/entities/event/service.mjs +169 -0
  451. package/dist/core/entities/event/service.mjs.map +1 -0
  452. package/dist/core/entities/event/types.d.ts +124 -0
  453. package/dist/core/entities/event/types.d.ts.map +1 -0
  454. package/dist/core/entities/event/types.mjs +4 -0
  455. package/dist/core/entities/identity-provider-role-mapping/service.mjs +2 -2
  456. package/dist/core/entities/identity-provider-role-mapping/service.mjs.map +1 -1
  457. package/dist/core/entities/index.d.ts +5 -0
  458. package/dist/core/entities/index.d.ts.map +1 -1
  459. package/dist/core/entities/index.mjs +20 -1
  460. package/dist/core/entities/key/index.d.ts +3 -0
  461. package/dist/core/entities/key/index.d.ts.map +1 -0
  462. package/dist/core/entities/key/index.mjs +5 -0
  463. package/dist/core/entities/key/service.d.ts +55 -0
  464. package/dist/core/entities/key/service.d.ts.map +1 -0
  465. package/dist/core/entities/key/service.mjs +301 -0
  466. package/dist/core/entities/key/service.mjs.map +1 -0
  467. package/dist/core/entities/key/types.d.ts +33 -0
  468. package/dist/core/entities/key/types.d.ts.map +1 -0
  469. package/dist/core/entities/key/types.mjs +4 -0
  470. package/dist/core/entities/permission/service.mjs +3 -3
  471. package/dist/core/entities/permission/service.mjs.map +1 -1
  472. package/dist/core/entities/policy/service.mjs +4 -4
  473. package/dist/core/entities/policy/service.mjs.map +1 -1
  474. package/dist/core/entities/realm/service.d.ts +3 -0
  475. package/dist/core/entities/realm/service.d.ts.map +1 -1
  476. package/dist/core/entities/realm/service.mjs +6 -3
  477. package/dist/core/entities/realm/service.mjs.map +1 -1
  478. package/dist/core/entities/role/service.mjs +2 -2
  479. package/dist/core/entities/role/service.mjs.map +1 -1
  480. package/dist/core/entities/role-attribute/service.mjs +3 -3
  481. package/dist/core/entities/role-attribute/service.mjs.map +1 -1
  482. package/dist/core/entities/session/service.mjs +5 -2
  483. package/dist/core/entities/session/service.mjs.map +1 -1
  484. package/dist/core/entities/trust-anchor/index.d.ts +3 -0
  485. package/dist/core/entities/trust-anchor/index.d.ts.map +1 -0
  486. package/dist/core/entities/trust-anchor/index.mjs +5 -0
  487. package/dist/core/entities/trust-anchor/service.d.ts +33 -0
  488. package/dist/core/entities/trust-anchor/service.d.ts.map +1 -0
  489. package/dist/core/entities/trust-anchor/service.mjs +175 -0
  490. package/dist/core/entities/trust-anchor/service.mjs.map +1 -0
  491. package/dist/core/entities/trust-anchor/types.d.ts +14 -0
  492. package/dist/core/entities/trust-anchor/types.d.ts.map +1 -0
  493. package/dist/core/entities/trust-anchor/types.mjs +4 -0
  494. package/dist/core/entities/user/service.mjs +2 -2
  495. package/dist/core/entities/user/service.mjs.map +1 -1
  496. package/dist/core/entities/user-attribute/service.mjs +4 -4
  497. package/dist/core/entities/user-attribute/service.mjs.map +1 -1
  498. package/dist/core/entities/user-authenticator/constants.d.ts +26 -0
  499. package/dist/core/entities/user-authenticator/constants.d.ts.map +1 -0
  500. package/dist/core/entities/user-authenticator/constants.mjs +32 -0
  501. package/dist/core/entities/user-authenticator/constants.mjs.map +1 -0
  502. package/dist/core/entities/user-authenticator/helpers.d.ts +10 -0
  503. package/dist/core/entities/user-authenticator/helpers.d.ts.map +1 -0
  504. package/dist/core/entities/user-authenticator/helpers.mjs +35 -0
  505. package/dist/core/entities/user-authenticator/helpers.mjs.map +1 -0
  506. package/dist/core/entities/user-authenticator/index.d.ts +6 -0
  507. package/dist/core/entities/user-authenticator/index.d.ts.map +1 -0
  508. package/dist/core/entities/user-authenticator/index.mjs +9 -0
  509. package/dist/core/entities/user-authenticator/service.d.ts +89 -0
  510. package/dist/core/entities/user-authenticator/service.d.ts.map +1 -0
  511. package/dist/core/entities/user-authenticator/service.mjs +709 -0
  512. package/dist/core/entities/user-authenticator/service.mjs.map +1 -0
  513. package/dist/core/entities/user-authenticator/types.d.ts +221 -0
  514. package/dist/core/entities/user-authenticator/types.d.ts.map +1 -0
  515. package/dist/core/entities/user-authenticator/types.mjs +15 -0
  516. package/dist/core/entities/user-authenticator/types.mjs.map +1 -0
  517. package/dist/core/entities/user-authenticator/webauthn.d.ts +28 -0
  518. package/dist/core/entities/user-authenticator/webauthn.d.ts.map +1 -0
  519. package/dist/core/entities/user-authenticator/webauthn.mjs +88 -0
  520. package/dist/core/entities/user-authenticator/webauthn.mjs.map +1 -0
  521. package/dist/core/identity/index.mjs +2 -1
  522. package/dist/core/identity/password-recovery/disabled.d.ts +2 -2
  523. package/dist/core/identity/password-recovery/disabled.d.ts.map +1 -1
  524. package/dist/core/identity/password-recovery/disabled.mjs +2 -2
  525. package/dist/core/identity/password-recovery/disabled.mjs.map +1 -1
  526. package/dist/core/identity/password-recovery/email-verification-required.d.ts +2 -2
  527. package/dist/core/identity/password-recovery/email-verification-required.d.ts.map +1 -1
  528. package/dist/core/identity/password-recovery/email-verification-required.mjs +2 -2
  529. package/dist/core/identity/password-recovery/email-verification-required.mjs.map +1 -1
  530. package/dist/core/identity/password-recovery/service.d.ts +2 -1
  531. package/dist/core/identity/password-recovery/service.d.ts.map +1 -1
  532. package/dist/core/identity/password-recovery/service.mjs +26 -4
  533. package/dist/core/identity/password-recovery/service.mjs.map +1 -1
  534. package/dist/core/identity/password-recovery/token-expired.d.ts +2 -2
  535. package/dist/core/identity/password-recovery/token-expired.d.ts.map +1 -1
  536. package/dist/core/identity/password-recovery/token-expired.mjs +2 -2
  537. package/dist/core/identity/password-recovery/token-expired.mjs.map +1 -1
  538. package/dist/core/identity/password-recovery/types.d.ts +2 -1
  539. package/dist/core/identity/password-recovery/types.d.ts.map +1 -1
  540. package/dist/core/identity/permission/index.d.ts +1 -0
  541. package/dist/core/identity/permission/index.d.ts.map +1 -1
  542. package/dist/core/identity/permission/index.mjs +2 -1
  543. package/dist/core/identity/policy/checker/service.mjs +1 -1
  544. package/dist/core/identity/policy/checker/service.mjs.map +1 -1
  545. package/dist/core/identity/provider/authentication/protocols/oauth2/module.mjs +2 -2
  546. package/dist/core/identity/provider/authentication/protocols/oauth2/module.mjs.map +1 -1
  547. package/dist/core/identity/registration/error.d.ts +2 -2
  548. package/dist/core/identity/registration/error.d.ts.map +1 -1
  549. package/dist/core/identity/registration/error.mjs +2 -2
  550. package/dist/core/identity/registration/error.mjs.map +1 -1
  551. package/dist/core/identity/registration/service.d.ts +2 -1
  552. package/dist/core/identity/registration/service.d.ts.map +1 -1
  553. package/dist/core/identity/registration/service.mjs +26 -4
  554. package/dist/core/identity/registration/service.mjs.map +1 -1
  555. package/dist/core/identity/registration/types.d.ts +2 -1
  556. package/dist/core/identity/registration/types.d.ts.map +1 -1
  557. package/dist/core/index.d.ts +3 -0
  558. package/dist/core/index.d.ts.map +1 -1
  559. package/dist/core/index.mjs +39 -8
  560. package/dist/core/key/certificate-error.d.ts +10 -0
  561. package/dist/core/key/certificate-error.d.ts.map +1 -0
  562. package/dist/core/key/certificate-error.mjs +19 -0
  563. package/dist/core/key/certificate-error.mjs.map +1 -0
  564. package/dist/core/key/certificate.d.ts +15 -0
  565. package/dist/core/key/certificate.d.ts.map +1 -0
  566. package/dist/core/key/certificate.mjs +72 -0
  567. package/dist/core/key/certificate.mjs.map +1 -0
  568. package/dist/core/key/check.d.ts +3 -0
  569. package/dist/core/key/check.d.ts.map +1 -0
  570. package/dist/core/key/check.mjs +13 -0
  571. package/dist/core/key/check.mjs.map +1 -0
  572. package/dist/core/key/constants.d.ts +10 -0
  573. package/dist/core/key/constants.d.ts.map +1 -0
  574. package/dist/core/key/constants.mjs +15 -0
  575. package/dist/core/key/constants.mjs.map +1 -0
  576. package/dist/core/key/error.d.ts +14 -0
  577. package/dist/core/key/error.d.ts.map +1 -0
  578. package/dist/core/key/error.mjs +23 -0
  579. package/dist/core/key/error.mjs.map +1 -0
  580. package/dist/core/key/index.d.ts +10 -0
  581. package/dist/core/key/index.d.ts.map +1 -0
  582. package/dist/core/key/index.mjs +12 -0
  583. package/dist/core/key/provisioner.d.ts +22 -0
  584. package/dist/core/key/provisioner.d.ts.map +1 -0
  585. package/dist/core/key/provisioner.mjs +30 -0
  586. package/dist/core/key/provisioner.mjs.map +1 -0
  587. package/dist/core/key/realm-cipher.d.ts +20 -0
  588. package/dist/core/key/realm-cipher.d.ts.map +1 -0
  589. package/dist/core/key/realm-cipher.mjs +60 -0
  590. package/dist/core/key/realm-cipher.mjs.map +1 -0
  591. package/dist/core/key/types.d.ts +59 -0
  592. package/dist/core/key/types.d.ts.map +1 -0
  593. package/dist/core/key/types.mjs +4 -0
  594. package/dist/core/key/wrap.d.ts +5 -0
  595. package/dist/core/key/wrap.d.ts.map +1 -0
  596. package/dist/core/key/wrap.mjs +21 -0
  597. package/dist/core/key/wrap.mjs.map +1 -0
  598. package/dist/core/mail/template/registry.d.ts.map +1 -1
  599. package/dist/core/mail/template/registry.mjs +3 -1
  600. package/dist/core/mail/template/registry.mjs.map +1 -1
  601. package/dist/core/mail/template/templates/mfa-email-otp.d.ts +3 -0
  602. package/dist/core/mail/template/templates/mfa-email-otp.d.ts.map +1 -0
  603. package/dist/core/mail/template/templates/mfa-email-otp.mjs +34 -0
  604. package/dist/core/mail/template/templates/mfa-email-otp.mjs.map +1 -0
  605. package/dist/core/mail/template/types.d.ts +6 -1
  606. package/dist/core/mail/template/types.d.ts.map +1 -1
  607. package/dist/core/mail/template/types.mjs +1 -0
  608. package/dist/core/mail/template/types.mjs.map +1 -1
  609. package/dist/core/metrics/index.d.ts +3 -0
  610. package/dist/core/metrics/index.d.ts.map +1 -0
  611. package/dist/core/metrics/index.mjs +5 -0
  612. package/dist/core/metrics/noop.d.ts +8 -0
  613. package/dist/core/metrics/noop.d.ts.map +1 -0
  614. package/dist/core/metrics/noop.mjs +14 -0
  615. package/dist/core/metrics/noop.mjs.map +1 -0
  616. package/dist/core/metrics/types.d.ts +19 -0
  617. package/dist/core/metrics/types.d.ts.map +1 -0
  618. package/dist/core/metrics/types.mjs +4 -0
  619. package/dist/core/oauth2/access-policy/index.d.ts +3 -0
  620. package/dist/core/oauth2/access-policy/index.d.ts.map +1 -0
  621. package/dist/core/oauth2/access-policy/index.mjs +5 -0
  622. package/dist/core/oauth2/access-policy/module.d.ts +12 -0
  623. package/dist/core/oauth2/access-policy/module.d.ts.map +1 -0
  624. package/dist/core/oauth2/access-policy/module.mjs +32 -0
  625. package/dist/core/oauth2/access-policy/module.mjs.map +1 -0
  626. package/dist/core/oauth2/access-policy/types.d.ts +19 -0
  627. package/dist/core/oauth2/access-policy/types.d.ts.map +1 -0
  628. package/dist/core/oauth2/access-policy/types.mjs +4 -0
  629. package/dist/core/oauth2/authorization/code/issuer/module.d.ts.map +1 -1
  630. package/dist/core/oauth2/authorization/code/issuer/module.mjs +2 -0
  631. package/dist/core/oauth2/authorization/code/issuer/module.mjs.map +1 -1
  632. package/dist/core/oauth2/authorization/code/issuer/types.d.ts +6 -1
  633. package/dist/core/oauth2/authorization/code/issuer/types.d.ts.map +1 -1
  634. package/dist/core/oauth2/authorization/code/verifier/module.mjs.map +1 -1
  635. package/dist/core/oauth2/authorization/code-request/validator.d.ts.map +1 -1
  636. package/dist/core/oauth2/authorization/code-request/validator.mjs +1 -0
  637. package/dist/core/oauth2/authorization/code-request/validator.mjs.map +1 -1
  638. package/dist/core/oauth2/authorization/code-request/verifier/module.mjs +3 -3
  639. package/dist/core/oauth2/authorization/code-request/verifier/module.mjs.map +1 -1
  640. package/dist/core/oauth2/authorization/helpers.d.ts +10 -1
  641. package/dist/core/oauth2/authorization/helpers.d.ts.map +1 -1
  642. package/dist/core/oauth2/authorization/helpers.mjs +28 -2
  643. package/dist/core/oauth2/authorization/helpers.mjs.map +1 -1
  644. package/dist/core/oauth2/authorization/index.mjs +2 -2
  645. package/dist/core/oauth2/authorization/module.d.ts +9 -0
  646. package/dist/core/oauth2/authorization/module.d.ts.map +1 -1
  647. package/dist/core/oauth2/authorization/module.mjs +80 -3
  648. package/dist/core/oauth2/authorization/module.mjs.map +1 -1
  649. package/dist/core/oauth2/authorization/types.d.ts +36 -0
  650. package/dist/core/oauth2/authorization/types.d.ts.map +1 -1
  651. package/dist/core/oauth2/client/authenticator.d.ts +16 -7
  652. package/dist/core/oauth2/client/authenticator.d.ts.map +1 -1
  653. package/dist/core/oauth2/client/authenticator.mjs +49 -12
  654. package/dist/core/oauth2/client/authenticator.mjs.map +1 -1
  655. package/dist/core/oauth2/end-session/service.d.ts +2 -1
  656. package/dist/core/oauth2/end-session/service.d.ts.map +1 -1
  657. package/dist/core/oauth2/end-session/service.mjs +13 -0
  658. package/dist/core/oauth2/end-session/service.mjs.map +1 -1
  659. package/dist/core/oauth2/end-session/types.d.ts +2 -1
  660. package/dist/core/oauth2/end-session/types.d.ts.map +1 -1
  661. package/dist/core/oauth2/grant-types/authorize.d.ts +2 -2
  662. package/dist/core/oauth2/grant-types/authorize.d.ts.map +1 -1
  663. package/dist/core/oauth2/grant-types/authorize.mjs +12 -8
  664. package/dist/core/oauth2/grant-types/authorize.mjs.map +1 -1
  665. package/dist/core/oauth2/grant-types/client-credentials.d.ts.map +1 -1
  666. package/dist/core/oauth2/grant-types/client-credentials.mjs +5 -3
  667. package/dist/core/oauth2/grant-types/client-credentials.mjs.map +1 -1
  668. package/dist/core/oauth2/grant-types/identity.d.ts.map +1 -1
  669. package/dist/core/oauth2/grant-types/identity.mjs +10 -3
  670. package/dist/core/oauth2/grant-types/identity.mjs.map +1 -1
  671. package/dist/core/oauth2/grant-types/password.d.ts +9 -0
  672. package/dist/core/oauth2/grant-types/password.d.ts.map +1 -1
  673. package/dist/core/oauth2/grant-types/password.mjs +32 -4
  674. package/dist/core/oauth2/grant-types/password.mjs.map +1 -1
  675. package/dist/core/oauth2/grant-types/refresh-token.d.ts +4 -0
  676. package/dist/core/oauth2/grant-types/refresh-token.d.ts.map +1 -1
  677. package/dist/core/oauth2/grant-types/refresh-token.mjs +17 -1
  678. package/dist/core/oauth2/grant-types/refresh-token.mjs.map +1 -1
  679. package/dist/core/oauth2/grant-types/robot-credentials.d.ts.map +1 -1
  680. package/dist/core/oauth2/grant-types/robot-credentials.mjs +3 -2
  681. package/dist/core/oauth2/grant-types/robot-credentials.mjs.map +1 -1
  682. package/dist/core/oauth2/grant-types/types.d.ts +10 -3
  683. package/dist/core/oauth2/grant-types/types.d.ts.map +1 -1
  684. package/dist/core/oauth2/index.d.ts +2 -1
  685. package/dist/core/oauth2/index.d.ts.map +1 -1
  686. package/dist/core/oauth2/index.mjs +7 -2
  687. package/dist/core/oauth2/mfa-login/index.d.ts +3 -0
  688. package/dist/core/oauth2/mfa-login/index.d.ts.map +1 -0
  689. package/dist/core/oauth2/mfa-login/index.mjs +5 -0
  690. package/dist/core/oauth2/mfa-login/module.d.ts +19 -0
  691. package/dist/core/oauth2/mfa-login/module.d.ts.map +1 -0
  692. package/dist/core/oauth2/mfa-login/module.mjs +109 -0
  693. package/dist/core/oauth2/mfa-login/module.mjs.map +1 -0
  694. package/dist/core/oauth2/mfa-login/types.d.ts +64 -0
  695. package/dist/core/oauth2/mfa-login/types.d.ts.map +1 -0
  696. package/dist/core/oauth2/mfa-login/types.mjs +4 -0
  697. package/dist/core/oauth2/token/index.mjs +2 -1
  698. package/dist/core/oauth2/token/issuer/index.d.ts +1 -0
  699. package/dist/core/oauth2/token/issuer/index.d.ts.map +1 -1
  700. package/dist/core/oauth2/token/issuer/index.mjs +3 -1
  701. package/dist/core/oauth2/token/issuer/mfa/index.d.ts +2 -0
  702. package/dist/core/oauth2/token/issuer/mfa/index.d.ts.map +1 -0
  703. package/dist/core/oauth2/token/issuer/mfa/index.mjs +5 -0
  704. package/dist/core/oauth2/token/issuer/mfa/module.d.ts +18 -0
  705. package/dist/core/oauth2/token/issuer/mfa/module.d.ts.map +1 -0
  706. package/dist/core/oauth2/token/issuer/mfa/module.mjs +36 -0
  707. package/dist/core/oauth2/token/issuer/mfa/module.mjs.map +1 -0
  708. package/dist/core/oauth2/token/repository/types.d.ts +10 -0
  709. package/dist/core/oauth2/token/repository/types.d.ts.map +1 -1
  710. package/dist/core/oauth2/token/revoker/module.d.ts.map +1 -1
  711. package/dist/core/oauth2/token/revoker/module.mjs +1 -0
  712. package/dist/core/oauth2/token/revoker/module.mjs.map +1 -1
  713. package/dist/core/oauth2/token/signer/module.d.ts +3 -3
  714. package/dist/core/oauth2/token/signer/module.d.ts.map +1 -1
  715. package/dist/core/oauth2/token/signer/module.mjs +5 -6
  716. package/dist/core/oauth2/token/signer/module.mjs.map +1 -1
  717. package/dist/core/oauth2/token/verifier/module.d.ts +3 -3
  718. package/dist/core/oauth2/token/verifier/module.d.ts.map +1 -1
  719. package/dist/core/oauth2/token/verifier/module.mjs +8 -5
  720. package/dist/core/oauth2/token/verifier/module.mjs.map +1 -1
  721. package/dist/index.mjs +52 -30
  722. package/dist/swagger.json +5431 -2952
  723. package/dist/ui/client/.vite/ssr-manifest.json +3888 -864
  724. package/dist/ui/client/assets/index-BmWsoQro.css +2 -0
  725. package/dist/ui/client/assets/{index-CP9HCHoS.js → index-CT0Nq5pA.js} +18 -17
  726. package/dist/ui/client/index.html +2 -2
  727. package/dist/ui/server/server.js +19470 -18436
  728. package/package.json +22 -16
  729. package/dist/app/modules/oauth2/repositories/key/index.d.ts.map +0 -1
  730. package/dist/app/modules/oauth2/repositories/key/index.mjs +0 -5
  731. package/dist/app/modules/oauth2/repositories/key/repository.d.ts +0 -14
  732. package/dist/app/modules/oauth2/repositories/key/repository.d.ts.map +0 -1
  733. package/dist/app/modules/oauth2/repositories/key/repository.mjs +0 -51
  734. package/dist/app/modules/oauth2/repositories/key/repository.mjs.map +0 -1
  735. package/dist/core/oauth2/key/index.d.ts +0 -2
  736. package/dist/core/oauth2/key/index.d.ts.map +0 -1
  737. package/dist/core/oauth2/key/types.d.ts +0 -16
  738. package/dist/core/oauth2/key/types.d.ts.map +0 -1
  739. package/dist/ui/client/assets/index-VM4JXBXw.css +0 -2
  740. /package/dist/{core/oauth2/key → adapters/http/request}/types.mjs +0 -0
  741. /package/dist/app/modules/{oauth2/repositories/key → database/repositories/event}/index.d.ts +0 -0
  742. /package/dist/core/{oauth2/key/index.mjs → authentication/login-throttle/types.mjs} +0 -0
@@ -1,19 +1,24 @@
1
1
  import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
+ import { deriveAmrAcr } from "../authorization/helpers.mjs";
4
5
  import { OAuth2BaseGrant } from "./base.mjs";
5
6
  import { buildOAuth2BearerTokenResponse } from "../response/bearer.mjs";
6
- import { IdentityType, ScopeName } from "@authup/core-kit";
7
- import { OAuth2SubKind } from "@authup/specs";
7
+ import { EventName, EventRefType, EventScope, IdentityType, ScopeName, SessionAuthMethod } from "@authup/core-kit";
8
+ import { OAuth2SubKind, OAuth2TokenGrant } from "@authup/specs";
8
9
  //#region src/core/oauth2/grant-types/password.ts
9
10
  var PasswordGrantType = class extends OAuth2BaseGrant {
10
11
  refreshTokenIssuer;
12
+ eventService;
13
+ metrics;
11
14
  constructor(ctx) {
12
15
  super({
13
16
  accessTokenIssuer: ctx.accessTokenIssuer,
14
17
  sessionManager: ctx.sessionManager
15
18
  });
16
19
  this.refreshTokenIssuer = ctx.refreshTokenIssuer;
20
+ this.eventService = ctx.eventService;
21
+ this.metrics = ctx.metrics;
17
22
  }
18
23
  async runWith(input, options = {}) {
19
24
  const { user, client } = input;
@@ -24,8 +29,11 @@ var PasswordGrantType = class extends OAuth2BaseGrant {
24
29
  realm_id: user.realm_id,
25
30
  client_id: clientId,
26
31
  sub: user.id,
27
- sub_kind: IdentityType.USER
32
+ sub_kind: IdentityType.USER,
33
+ mfa_at: input.mfaVerifiedAt ?? null,
34
+ auth_method: SessionAuthMethod.PASSWORD
28
35
  });
36
+ const amrAcr = deriveAmrAcr(session);
29
37
  const issuePayload = {
30
38
  client_id: clientId,
31
39
  session_id: session.id,
@@ -35,10 +43,30 @@ var PasswordGrantType = class extends OAuth2BaseGrant {
35
43
  sub: user.id,
36
44
  sub_kind: OAuth2SubKind.USER,
37
45
  realm_id: user.realm_id,
38
- realm_name: user.realm?.name
46
+ realm_name: user.realm?.name,
47
+ ...options.confirmation ? { cnf: options.confirmation } : {},
48
+ ...amrAcr
39
49
  };
40
50
  const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue(issuePayload);
41
51
  const [refreshToken, refreshTokenPayload] = await this.refreshTokenIssuer.issue(issuePayload);
52
+ await this.eventService?.record({
53
+ scope: EventScope.OAUTH2,
54
+ name: EventName.LOGIN,
55
+ refType: EventRefType.SESSION,
56
+ refId: session.id,
57
+ clientId: clientId ?? null,
58
+ actorType: IdentityType.USER,
59
+ actorId: user.id,
60
+ actorName: user.name,
61
+ realmId: user.realm_id,
62
+ requestIpAddress: options.ipAddress ?? null,
63
+ requestUserAgent: options.userAgent ?? null,
64
+ data: {
65
+ grant_type: OAuth2TokenGrant.PASSWORD,
66
+ session_id: session.id
67
+ }
68
+ });
69
+ this.metrics?.recordLogin("success");
42
70
  return buildOAuth2BearerTokenResponse({
43
71
  accessToken,
44
72
  accessTokenPayload,
@@ -1 +1 @@
1
- {"version":3,"file":"password.mjs","names":["OAuth2SubKind","IdentityType","ScopeName","buildOAuth2BearerTokenResponse","OAuth2BaseGrant","PasswordGrantType","refreshTokenIssuer","ctx","accessTokenIssuer","sessionManager","runWith","input","options","user","client","clientId","id","session","create","user_agent","userAgent","ip_address","ipAddress","realm_id","client_id","sub","sub_kind","USER","issuePayload","session_id","remote_address","scope","GLOBAL","realm_name","realm","name","accessToken","accessTokenPayload","issue","refreshToken","refreshTokenPayload"],"sources":["../../../../src/core/oauth2/grant-types/password.ts"],"sourcesContent":["/*\n * Copyright (c) 2022-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse, OAuth2TokenPayload } from '@authup/specs';\nimport { OAuth2SubKind } from '@authup/specs';\nimport type { Client, User } from '@authup/core-kit';\nimport {\n IdentityType,\n ScopeName,\n} from '@authup/core-kit';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { IOAuth2TokenIssuer } from '../token/index.ts';\nimport { OAuth2BaseGrant } from './base.ts';\nimport type { OAuth2GrantRunWIthOptions, OAuth2PasswordGrantContext } from './types.ts';\n\nexport type OAuth2PasswordGrantInput = {\n user: User,\n client?: Client,\n};\n\nexport class PasswordGrantType extends OAuth2BaseGrant<OAuth2PasswordGrantInput> {\n protected refreshTokenIssuer : IOAuth2TokenIssuer;\n\n constructor(ctx: OAuth2PasswordGrantContext) {\n super({\n accessTokenIssuer: ctx.accessTokenIssuer,\n sessionManager: ctx.sessionManager,\n });\n\n this.refreshTokenIssuer = ctx.refreshTokenIssuer;\n }\n\n async runWith(input: OAuth2PasswordGrantInput, options: OAuth2GrantRunWIthOptions = {}) : Promise<OAuth2TokenGrantResponse> {\n const { user, client } = input;\n const clientId = client?.id;\n\n const session = await this.sessionManager.create({\n user_agent: options.userAgent,\n ip_address: options.ipAddress,\n realm_id: user.realm_id,\n client_id: clientId,\n sub: user.id,\n sub_kind: IdentityType.USER,\n });\n\n const issuePayload : Partial<OAuth2TokenPayload> = {\n client_id: clientId,\n session_id: session.id,\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n scope: ScopeName.GLOBAL,\n sub: user.id,\n sub_kind: OAuth2SubKind.USER,\n realm_id: user.realm_id,\n realm_name: user.realm?.name,\n };\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue(issuePayload);\n const [refreshToken, refreshTokenPayload] = await this.refreshTokenIssuer.issue(issuePayload);\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n refreshToken,\n refreshTokenPayload,\n });\n }\n}\n"],"mappings":";;;;;;;;AAwBA,IAAaK,oBAAb,cAAuCD,gBAAAA;CACzBE;CAEV,YAAYC,KAAiC;EACzC,MAAM;GACFC,mBAAmBD,IAAIC;GACvBC,gBAAgBF,IAAIE;EACxB,CAAA;EAEA,KAAKH,qBAAqBC,IAAID;CAClC;CAEA,MAAMI,QAAQC,OAAiCC,UAAqC,CAAC,GAAuC;EACxH,MAAM,EAAEC,MAAMC,WAAWH;EACzB,MAAMI,WAAWD,QAAQE;EAEzB,MAAMC,UAAU,MAAM,KAAKR,eAAeS,OAAO;GAC7CC,YAAYP,QAAQQ;GACpBC,YAAYT,QAAQU;GACpBC,UAAUV,KAAKU;GACfC,WAAWT;GACXU,KAAKZ,KAAKG;GACVU,UAAUzB,aAAa0B;EAC3B,CAAA;EAEA,MAAMC,eAA6C;GAC/CJ,WAAWT;GACXc,YAAYZ,QAAQD;GACpBG,YAAYF,QAAQE;GACpBW,gBAAgBb,QAAQI;GACxBU,OAAO7B,UAAU8B;GACjBP,KAAKZ,KAAKG;GACVU,UAAU1B,cAAc2B;GACxBJ,UAAUV,KAAKU;GACfU,YAAYpB,KAAKqB,OAAOC;EAC5B;EAEA,MAAM,CAACC,aAAaC,sBAAsB,MAAM,KAAK7B,kBAAkB8B,MAAMV,YAAAA;EAC7E,MAAM,CAACW,cAAcC,uBAAuB,MAAM,KAAKlC,mBAAmBgC,MAAMV,YAAAA;EAEhF,OAAOzB,+BAA+B;GAClCiC;GACAC;GACAE;GACAC;EACJ,CAAA;CACJ;AACJ"}
1
+ {"version":3,"file":"password.mjs","names":["OAuth2SubKind","OAuth2TokenGrant","EventName","EventRefType","EventScope","IdentityType","ScopeName","SessionAuthMethod","deriveAmrAcr","buildOAuth2BearerTokenResponse","OAuth2BaseGrant","PasswordGrantType","refreshTokenIssuer","eventService","metrics","ctx","accessTokenIssuer","sessionManager","runWith","input","options","user","client","clientId","id","session","create","user_agent","userAgent","ip_address","ipAddress","realm_id","client_id","sub","sub_kind","USER","mfa_at","mfaVerifiedAt","auth_method","PASSWORD","amrAcr","issuePayload","session_id","remote_address","scope","GLOBAL","realm_name","realm","name","confirmation","cnf","accessToken","accessTokenPayload","issue","refreshToken","refreshTokenPayload","record","OAUTH2","LOGIN","refType","SESSION","refId","actorType","actorId","actorName","realmId","requestIpAddress","requestUserAgent","data","grant_type","recordLogin"],"sources":["../../../../src/core/oauth2/grant-types/password.ts"],"sourcesContent":["/*\n * Copyright (c) 2022-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse, OAuth2TokenPayload } from '@authup/specs';\nimport { OAuth2SubKind, OAuth2TokenGrant } from '@authup/specs';\nimport type { Client, User } from '@authup/core-kit';\nimport {\n EventName,\n EventRefType,\n EventScope,\n IdentityType,\n ScopeName,\n SessionAuthMethod,\n} from '@authup/core-kit';\nimport type { IEventService } from '../../entities/index.ts';\nimport type { IAuthFlowMetrics } from '../../metrics/index.ts';\nimport { deriveAmrAcr } from '../authorization/helpers.ts';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { IOAuth2TokenIssuer } from '../token/index.ts';\nimport { OAuth2BaseGrant } from './base.ts';\nimport type { OAuth2GrantRunWIthOptions, OAuth2PasswordGrantContext } from './types.ts';\n\nexport type OAuth2PasswordGrantInput = {\n user: User,\n client?: Client,\n /**\n * Instant the user passed a second-factor challenge alongside the\n * grant (the `otp` parameter) — stamped onto the session as mfa_at.\n */\n mfaVerifiedAt?: string,\n};\n\nexport class PasswordGrantType extends OAuth2BaseGrant<OAuth2PasswordGrantInput> {\n protected refreshTokenIssuer : IOAuth2TokenIssuer;\n\n protected eventService? : IEventService;\n\n protected metrics? : IAuthFlowMetrics;\n\n constructor(ctx: OAuth2PasswordGrantContext) {\n super({\n accessTokenIssuer: ctx.accessTokenIssuer,\n sessionManager: ctx.sessionManager,\n });\n\n this.refreshTokenIssuer = ctx.refreshTokenIssuer;\n this.eventService = ctx.eventService;\n this.metrics = ctx.metrics;\n }\n\n async runWith(input: OAuth2PasswordGrantInput, options: OAuth2GrantRunWIthOptions = {}) : Promise<OAuth2TokenGrantResponse> {\n const { user, client } = input;\n const clientId = client?.id;\n\n const session = await this.sessionManager.create({\n user_agent: options.userAgent,\n ip_address: options.ipAddress,\n realm_id: user.realm_id,\n client_id: clientId,\n sub: user.id,\n sub_kind: IdentityType.USER,\n mfa_at: input.mfaVerifiedAt ?? null,\n auth_method: SessionAuthMethod.PASSWORD,\n });\n\n // amr/acr derive from the session's auth_method + mfa_at — deliberately\n // on every token kind, so a direct password grant's tokens advertise the\n // method the same way the authorization_code exchange does.\n const amrAcr = deriveAmrAcr(session);\n\n const issuePayload : Partial<OAuth2TokenPayload> = {\n client_id: clientId,\n session_id: session.id,\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n scope: ScopeName.GLOBAL,\n sub: user.id,\n sub_kind: OAuth2SubKind.USER,\n realm_id: user.realm_id,\n realm_name: user.realm?.name,\n ...(options.confirmation ? { cnf: options.confirmation } : {}),\n ...amrAcr,\n };\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue(issuePayload);\n const [refreshToken, refreshTokenPayload] = await this.refreshTokenIssuer.issue(issuePayload);\n\n await this.eventService?.record({\n scope: EventScope.OAUTH2,\n name: EventName.LOGIN,\n refType: EventRefType.SESSION,\n refId: session.id,\n clientId: clientId ?? null,\n actorType: IdentityType.USER,\n actorId: user.id,\n actorName: user.name,\n realmId: user.realm_id,\n requestIpAddress: options.ipAddress ?? null,\n requestUserAgent: options.userAgent ?? null,\n data: {\n grant_type: OAuth2TokenGrant.PASSWORD,\n session_id: session.id,\n },\n });\n this.metrics?.recordLogin('success');\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n refreshToken,\n refreshTokenPayload,\n });\n }\n}\n"],"mappings":";;;;;;;;;AAoCA,IAAaW,oBAAb,cAAuCD,gBAAAA;CACzBE;CAEAC;CAEAC;CAEV,YAAYC,KAAiC;EACzC,MAAM;GACFC,mBAAmBD,IAAIC;GACvBC,gBAAgBF,IAAIE;EACxB,CAAA;EAEA,KAAKL,qBAAqBG,IAAIH;EAC9B,KAAKC,eAAeE,IAAIF;EACxB,KAAKC,UAAUC,IAAID;CACvB;CAEA,MAAMI,QAAQC,OAAiCC,UAAqC,CAAC,GAAuC;EACxH,MAAM,EAAEC,MAAMC,WAAWH;EACzB,MAAMI,WAAWD,QAAQE;EAEzB,MAAMC,UAAU,MAAM,KAAKR,eAAeS,OAAO;GAC7CC,YAAYP,QAAQQ;GACpBC,YAAYT,QAA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'@authup/specs';
2
2
  import type { Logger } from '@authup/server-kit';
3
+ import type { IEventService } from '../../entities/index.ts';
4
+ import type { IAuthFlowMetrics } from '../../metrics/index.ts';
3
5
  import type { ISessionTokenRepository } from '../session-token/index.ts';
4
6
  import type { IOAuth2TokenIssuer, IOAuth2TokenRepository, IOAuth2TokenVerifier } from '../token/index.ts';
5
7
  import { OAuth2BaseGrant } from './base.ts';
@@ -9,6 +11,8 @@ export declare class OAuth2RefreshTokenGrant extends OAuth2BaseGrant<string | OA
9
11
  protected tokenVerifier: IOAuth2TokenVerifier;
10
12
  protected tokenRepository: IOAuth2TokenRepository;
11
13
  protected sessionTokenRepository: ISessionTokenRepository;
14
+ protected eventService?: IEventService;
15
+ protected metrics?: IAuthFlowMetrics;
12
16
  protected logger?: Logger;
13
17
  protected gracePeriod: number;
14
18
  constructor(ctx: OAuth2RefreshTokenGrantContext);
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-token.d.ts","sourceRoot":"","sources":["../../../../src/core/oauth2/grant-types/refresh-token.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAElF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAE1G,qBAAa,uBAAwB,SAAQ,eAAe,CAAC,MAAM,GAAG,kBAAkB,CAAE,YAAW,YAAY;IAC7G,SAAS,CAAC,kBAAkB,EAAG,kBAAkB,CAAC;IAElD,SAAS,CAAC,aAAa,EAAG,oBAAoB,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,eAAe,CAAC,MAAM,GAAG,kBAAkB,CAAE,YAAW,YAAY;IAC7G,SAAS,CAAC,kBAAkB,EAAG,kBAAkB,CAAC;IAElD,SAAS,CAAC,aAAa,EAAG,oBAAoB,CAAC;IAE/C,SAAS,CAAC,eAAe,EAAG,sBAAsB,CAAC;IAEnD,SAAS,CAAC,sBAAsB,EAAG,uBAAuB,CAAC;IAE3D,SAAS,CAAC,YAAY,CAAC,EAAG,aAAa,CAAC;IAExC,SAAS,CAAC,OAAO,CAAC,EAAG,gBAAgB,CAAC;IAEtC,SAAS,CAAC,MAAM,CAAC,EAAG,MAAM,CAAC;IAE3B,SAAS,CAAC,WAAW,EAAG,MAAM,CAAC;gBAEnB,GAAG,EAAE,8BAA8B;IAgBzC,OAAO,CACT,KAAK,EAAE,MAAM,GAAG,kBAAkB,EAClC,OAAO,GAAE,yBAA8B,GACvC,OAAO,CAAC,wBAAwB,CAAC;IAuGrC;;;;;OAKG;cACa,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,GAAI,OAAO,CAAC,OAAO,CAAC;IAqB9E;;;;;OAKG;cACa,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAI,OAAO,CAAC,IAAI,CAAC;CA4B3F"}
@@ -3,13 +3,16 @@ import "node:url";
3
3
  import.meta.url;
4
4
  import { OAuth2BaseGrant } from "./base.mjs";
5
5
  import { buildOAuth2BearerTokenResponse } from "../response/bearer.mjs";
6
- import { JWTError, OAuth2GrantError } from "@authup/specs";
6
+ import { EventName, EventRefType, EventScope } from "@authup/core-kit";
7
+ import { JWTError, OAuth2GrantError, OAuth2TokenKind } from "@authup/specs";
7
8
  //#region src/core/oauth2/grant-types/refresh-token.ts
8
9
  var OAuth2RefreshTokenGrant = class extends OAuth2BaseGrant {
9
10
  refreshTokenIssuer;
10
11
  tokenVerifier;
11
12
  tokenRepository;
12
13
  sessionTokenRepository;
14
+ eventService;
15
+ metrics;
13
16
  logger;
14
17
  gracePeriod;
15
18
  constructor(ctx) {
@@ -21,6 +24,8 @@ var OAuth2RefreshTokenGrant = class extends OAuth2BaseGrant {
21
24
  this.tokenVerifier = ctx.tokenVerifier;
22
25
  this.tokenRepository = ctx.tokenRepository;
23
26
  this.sessionTokenRepository = ctx.sessionTokenRepository;
27
+ this.eventService = ctx.eventService;
28
+ this.metrics = ctx.metrics;
24
29
  this.logger = ctx.logger;
25
30
  this.gracePeriod = ctx.options?.gracePeriod ?? 0;
26
31
  }
@@ -30,6 +35,7 @@ var OAuth2RefreshTokenGrant = class extends OAuth2BaseGrant {
30
35
  else payload = input;
31
36
  if (!payload.jti) throw JWTError.payloadPropertyInvalid("jti");
32
37
  if (!payload.session_id) throw JWTError.payloadPropertyInvalid("session_id");
38
+ if (payload.kind && payload.kind !== OAuth2TokenKind.REFRESH) throw OAuth2GrantError.invalid("unexpected token kind");
33
39
  const row = await this.sessionTokenRepository.findOneById(payload.jti);
34
40
  if (!row || row.kind !== "refresh") throw OAuth2GrantError.invalid("refresh token is unknown");
35
41
  if (row.revoked_at) throw OAuth2GrantError.invalid("refresh token has been revoked");
@@ -51,6 +57,7 @@ var OAuth2RefreshTokenGrant = class extends OAuth2BaseGrant {
51
57
  await this.sessionManager.refresh(session);
52
58
  const [refreshToken, refreshTokenPayload] = await this.refreshTokenIssuer.issue({
53
59
  ...payload,
60
+ ...options.confirmation ? { cnf: options.confirmation } : {},
54
61
  user_agent: session.user_agent,
55
62
  remote_address: session.ip_address,
56
63
  exp: this.refreshTokenIssuer.buildExp(),
@@ -58,6 +65,7 @@ var OAuth2RefreshTokenGrant = class extends OAuth2BaseGrant {
58
65
  });
59
66
  const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue({
60
67
  ...payload,
68
+ ...options.confirmation ? { cnf: options.confirmation } : {},
61
69
  user_agent: session.user_agent,
62
70
  remote_address: session.ip_address,
63
71
  exp: this.accessTokenIssuer.buildExp(),
@@ -91,6 +99,14 @@ var OAuth2RefreshTokenGrant = class extends OAuth2BaseGrant {
91
99
  session_id: sessionId,
92
100
  jti
93
101
  });
102
+ await this.eventService?.record({
103
+ scope: EventScope.OAUTH2,
104
+ name: EventName.REFRESH_REPLAY_DETECTED,
105
+ refType: EventRefType.SESSION,
106
+ refId: sessionId,
107
+ data: { jti }
108
+ });
109
+ this.metrics?.recordRefreshReplay();
94
110
  const rows = await this.sessionTokenRepository.revokeBySessionId(sessionId, at);
95
111
  await Promise.allSettled(rows.map((row) => this.tokenRepository.setInactive(row.id, Math.floor(new Date(row.expires_at).getTime() / 1e3))));
96
112
  await this.sessionManager.revoke(sessionId);
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-token.mjs","names":["JWTError","OAuth2GrantError","buildOAuth2BearerTokenResponse","OAuth2BaseGrant","OAuth2RefreshTokenGrant","refreshTokenIssuer","tokenVerifier","tokenRepository","sessionTokenRepository","logger","gracePeriod","ctx","accessTokenIssuer","sessionManager","options","runWith","input","payload","verify","skipActiveCheck","jti","payloadPropertyInvalid","session_id","row","findOneById","kind","invalid","revoked_at","now","Date","nowISO","toISOString","consumed","markRefreshConsumed","withinGrace","isWithinGraceWindow","revokeFamily","setInactive","exp","session","userAgent","user_agent","ipAddress","ip_address","refresh","refreshToken","refreshTokenPayload","issue","remote_address","buildExp","parent_id","accessToken","accessTokenPayload","refresh_token_id","current","consumed_at","getTime","chainAdvanced","hasConsumedChild","sessionId","at","warn","rows","revokeBySessionId","Promise","allSettled","map","id","Math","floor","expires_at","revoke"],"sources":["../../../../src/core/oauth2/grant-types/refresh-token.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse, OAuth2TokenPayload } from '@authup/specs';\nimport { JWTError, OAuth2GrantError } from '@authup/specs';\nimport type { Logger } from '@authup/server-kit';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { ISessionTokenRepository } from '../session-token/index.ts';\nimport type { IOAuth2TokenIssuer, IOAuth2TokenRepository, IOAuth2TokenVerifier } from '../token/index.ts';\nimport { OAuth2BaseGrant } from './base.ts';\nimport type { IOAuth2Grant, OAuth2GrantRunWIthOptions, OAuth2RefreshTokenGrantContext } from './types.ts';\n\nexport class OAuth2RefreshTokenGrant extends OAuth2BaseGrant<string | OAuth2TokenPayload> implements IOAuth2Grant {\n protected refreshTokenIssuer : IOAuth2TokenIssuer;\n\n protected tokenVerifier : IOAuth2TokenVerifier;\n\n protected tokenRepository : IOAuth2TokenRepository;\n\n protected sessionTokenRepository : ISessionTokenRepository;\n\n protected logger? : Logger;\n\n protected gracePeriod : number;\n\n constructor(ctx: OAuth2RefreshTokenGrantContext) {\n super({\n accessTokenIssuer: ctx.accessTokenIssuer,\n sessionManager: ctx.sessionManager,\n });\n\n this.refreshTokenIssuer = ctx.refreshTokenIssuer;\n this.tokenVerifier = ctx.tokenVerifier;\n this.tokenRepository = ctx.tokenRepository;\n this.sessionTokenRepository = ctx.sessionTokenRepository;\n this.logger = ctx.logger;\n this.gracePeriod = ctx.options?.gracePeriod ?? 0;\n }\n\n async runWith(\n input: string | OAuth2TokenPayload,\n options: OAuth2GrantRunWIthOptions = {},\n ) : Promise<OAuth2TokenGrantResponse> {\n let payload : OAuth2TokenPayload;\n if (typeof input === 'string') {\n // The auth_session_tokens row — not the cache blocklist — is the\n // authority for refresh-token validity, so skip the active check.\n payload = await this.tokenVerifier.verify(input, { skipActiveCheck: true });\n } else {\n payload = input;\n }\n\n if (!payload.jti) {\n throw JWTError.payloadPropertyInvalid('jti');\n }\n if (!payload.session_id) {\n throw JWTError.payloadPropertyInvalid('session_id');\n }\n\n const row = await this.sessionTokenRepository.findOneById(payload.jti);\n if (!row || row.kind !== 'refresh') {\n // Row missing = expired-and-swept or a pre-rotation legacy token\n // (hard cutover). Either way the client must re-authenticate.\n throw OAuth2GrantError.invalid('refresh token is unknown');\n }\n if (row.revoked_at) {\n throw OAuth2GrantError.invalid('refresh token has been revoked');\n }\n if (row.session_id !== payload.session_id) {\n // The row is written with the token's own session_id and jti is\n // globally unique, so a mismatch means corruption / jti reuse — fail\n // closed rather than refresh or revoke against the wrong session.\n throw OAuth2GrantError.invalid('refresh token session mismatch');\n }\n\n const now = new Date();\n const nowISO = now.toISOString();\n\n const consumed = await this.sessionTokenRepository.markRefreshConsumed(payload.jti, nowISO);\n if (!consumed) {\n // Lost the atomic consume — either a replay of an already-rotated\n // token, or a benign concurrent-refresh race the grace window\n // absorbs.\n const withinGrace = await this.isWithinGraceWindow(payload.jti, now);\n if (!withinGrace) {\n await this.revokeFamily(row.session_id, payload.jti, nowISO);\n throw OAuth2GrantError.invalid('refresh token replay detected; session revoked');\n }\n }\n\n // Blocklist the presented refresh token in the cache so introspection\n // reports it inactive. Deliberately NOT a DB revoke — that would set\n // revoked_at and break the grace window.\n await this.tokenRepository.setInactive(payload.jti, payload.exp);\n\n const session = await this.sessionManager.findOneById(payload.session_id);\n if (!session) {\n throw JWTError.payloadPropertyInvalid('session_id');\n }\n\n await this.sessionManager.verify(session);\n\n if (options.userAgent) {\n session.user_agent = options.userAgent;\n }\n if (options.ipAddress) {\n session.ip_address = options.ipAddress;\n }\n await this.sessionManager.refresh(session);\n\n const [refreshToken, refreshTokenPayload] = await this.refreshTokenIssuer.issue({\n ...payload,\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n exp: this.refreshTokenIssuer.buildExp(),\n parent_id: payload.jti,\n });\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue({\n ...payload,\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n exp: this.accessTokenIssuer.buildExp(),\n refresh_token_id: refreshTokenPayload.jti,\n });\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n refreshToken,\n refreshTokenPayload,\n });\n }\n\n /**\n * The grace window (opt-in via `tokenRefreshGracePeriod`) absorbs benign\n * concurrent / multi-tab refreshes of the SAME still-current token. It is\n * scoped to the chain tip: a token whose descendant has already been\n * consumed is a stale ancestor (a real replay), never a grace re-use.\n */\n protected async isWithinGraceWindow(jti: string, now: Date) : Promise<boolean> {\n if (this.gracePeriod <= 0) {\n return false;\n }\n\n const current = await this.sessionTokenRepository.findOneById(jti);\n if (\n !current ||\n current.revoked_at !== null ||\n current.consumed_at === null ||\n (now.getTime() - new Date(current.consumed_at).getTime()) > this.gracePeriod * 1_000\n ) {\n return false;\n }\n\n // Grace applies ONLY to the most-recent consumed token: a consumed\n // descendant proves the rotation advanced past this one (stale replay).\n const chainAdvanced = await this.sessionTokenRepository.hasConsumedChild(jti);\n return !chainAdvanced;\n }\n\n /**\n * RFC 6819 §5.2.2.3 reaction strategy — revoke the whole token family\n * (the auth_sessions row) on replay: soft-revoke every session-token row,\n * blocklist their jtis in the cache, and delete the session so its access\n * tokens stop verifying on authup's own API.\n */\n protected async revokeFamily(sessionId: string, jti: string, at: string) : Promise<void> {\n this.logger?.warn('OAuth2 refresh token replay detected; revoking session', {\n session_id: sessionId,\n jti,\n });\n\n // Blocklisting is best-effort (cache) — settle all of them so one cache\n // failure cannot skip the rest or, worse, abort the session delete\n // below (the load-bearing part of the revocation). Pin each TTL to the\n // token's real expiry (unix seconds) so a long-lived refresh token\n // cannot resurface as active via introspection after the fallback 1h.\n const rows = await this.sessionTokenRepository.revokeBySessionId(sessionId, at);\n await Promise.allSettled(rows.map((row) => this.tokenRepository.setInactive(\n row.id,\n Math.floor(new Date(row.expires_at).getTime() / 1_000),\n )));\n\n await this.sessionManager.revoke(sessionId);\n }\n}\n"],"mappings":";;;;;;;AAgBA,IAAaI,0BAAb,cAA6CD,gBAAAA;CAC/BE;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEV,YAAYC,KAAqC;EAC7C,MAAM;GACFC,mBAAmBD,IAAIC;GACvBC,gBAAgBF,IAAIE;EACxB,CAAA;EAEA,KAAKR,qBAAqBM,IAAIN;EAC9B,KAAKC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uBuD,kBAAkBJ,WAAWC,EAAAA;EAC5E,MAAMI,QAAQC,WAAWH,KAAKI,KAAK3C,QAAQ,KAAKhB,gBAAgB8B,YAC5Dd,IAAI4C,IACJC,KAAKC,MAAM,IAAIxC,KAAKN,IAAI+C,UAAU,CAAA,CAAEd,QAAO,IAAK,GAAA,CAAA,CAAA,CAAA;EAGpD,MAAM,KAAK3C,eAAe0D,OAAOZ,SAAAA;CACrC;AACJ"}
1
+ {"version":3,"file":"refresh-token.mjs","names":["JWTError","OAuth2GrantError","OAuth2TokenKind","EventName","EventRefType","EventScope","buildOAuth2BearerTokenResponse","OAuth2BaseGrant","OAuth2RefreshTokenGrant","refreshTokenIssuer","tokenVerifier","tokenRepository","sessionTokenRepository","eventService","metrics","logger","gracePeriod","ctx","accessTokenIssuer","sessionManager","options","runWith","input","payload","verify","skipActiveCheck","jti","payloadPropertyInvalid","session_id","kind","REFRESH","invalid","row","findOneById","revoked_at","now","Date","nowISO","toISOString","consumed","markRefreshConsumed","withinGrace","isWithinGraceWindow","revokeFamily","setInactive","exp","session","userAgent","user_agent","ipAddress","ip_address","refresh","refreshToken","refreshTokenPayload","issue","confirmation","cnf","remote_address","buildExp","parent_id","accessToken","accessTokenPayload","refresh_token_id","current","consumed_at","getTime","chainAdvanced","hasConsumedChild","sessionId","at","warn","record","scope","OAUTH2","name","REFRESH_REPLAY_DETECTED","refType","SESSION","refId","data","recordRefreshReplay","rows","revokeBySessionId","Promise","allSettled","map","id","Math","floor","expires_at","revoke"],"sources":["../../../../src/core/oauth2/grant-types/refresh-token.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse, OAuth2TokenPayload } from '@authup/specs';\nimport { JWTError, OAuth2GrantError, OAuth2TokenKind } from '@authup/specs';\nimport { EventName, EventRefType, EventScope } from '@authup/core-kit';\nimport type { Logger } from '@authup/server-kit';\nimport type { IEventService } from '../../entities/index.ts';\nimport type { IAuthFlowMetrics } from '../../metrics/index.ts';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { ISessionTokenRepository } from '../session-token/index.ts';\nimport type { IOAuth2TokenIssuer, IOAuth2TokenRepository, IOAuth2TokenVerifier } from '../token/index.ts';\nimport { OAuth2BaseGrant } from './base.ts';\nimport type { IOAuth2Grant, OAuth2GrantRunWIthOptions, OAuth2RefreshTokenGrantContext } from './types.ts';\n\nexport class OAuth2RefreshTokenGrant extends OAuth2BaseGrant<string | OAuth2TokenPayload> implements IOAuth2Grant {\n protected refreshTokenIssuer : IOAuth2TokenIssuer;\n\n protected tokenVerifier : IOAuth2TokenVerifier;\n\n protected tokenRepository : IOAuth2TokenRepository;\n\n protected sessionTokenRepository : ISessionTokenRepository;\n\n protected eventService? : IEventService;\n\n protected metrics? : IAuthFlowMetrics;\n\n protected logger? : Logger;\n\n protected gracePeriod : number;\n\n constructor(ctx: OAuth2RefreshTokenGrantContext) {\n super({\n accessTokenIssuer: ctx.accessTokenIssuer,\n sessionManager: ctx.sessionManager,\n });\n\n this.refreshTokenIssuer = ctx.refreshTokenIssuer;\n this.tokenVerifier = ctx.tokenVerifier;\n this.tokenRepository = ctx.tokenRepository;\n this.sessionTokenRepository = ctx.sessionTokenRepository;\n this.eventService = ctx.eventService;\n this.metrics = ctx.metrics;\n this.logger = ctx.logger;\n this.gracePeriod = ctx.options?.gracePeriod ?? 0;\n }\n\n async runWith(\n input: string | OAuth2TokenPayload,\n options: OAuth2GrantRunWIthOptions = {},\n ) : Promise<OAuth2TokenGrantResponse> {\n let payload : OAuth2TokenPayload;\n if (typeof input === 'string') {\n // The auth_session_tokens row — not the cache blocklist — is the\n // authority for refresh-token validity, so skip the active check.\n payload = await this.tokenVerifier.verify(input, { skipActiveCheck: true });\n } else {\n payload = input;\n }\n\n if (!payload.jti) {\n throw JWTError.payloadPropertyInvalid('jti');\n }\n if (!payload.session_id) {\n throw JWTError.payloadPropertyInvalid('session_id');\n }\n\n // Explicit kind guard (defense in depth). Authup signs access tokens\n // and the MFA-pending login ticket with the same keys; only a refresh\n // token may be exchanged here. The ticket is also rejected implicitly\n // (it writes no auth_session_tokens row), but do not rely on that\n // second-order fact alone.\n if (payload.kind && payload.kind !== OAuth2TokenKind.REFRESH) {\n throw OAuth2GrantError.invalid('unexpected token kind');\n }\n\n const row = await this.sessionTokenRepository.findOneById(payload.jti);\n if (!row || row.kind !== 'refresh') {\n // Row missing = expired-and-swept or a pre-rotation legacy token\n // (hard cutover). Either way the client must re-authenticate.\n throw OAuth2GrantError.invalid('refresh token is unknown');\n }\n if (row.revoked_at) {\n throw OAuth2GrantError.invalid('refresh token has been revoked');\n }\n if (row.session_id !== payload.session_id) {\n // The row is written with the token's own session_id and jti is\n // globally unique, so a mismatch means corruption / jti reuse — fail\n // closed rather than refresh or revoke against the wrong session.\n throw OAuth2GrantError.invalid('refresh token session mismatch');\n }\n\n const now = new Date();\n const nowISO = now.toISOString();\n\n const consumed = await this.sessionTokenRepository.markRefreshConsumed(payload.jti, nowISO);\n if (!consumed) {\n // Lost the atomic consume — either a replay of an already-rotated\n // token, or a benign concurrent-refresh race the grace window\n // absorbs.\n const withinGrace = await this.isWithinGraceWindow(payload.jti, now);\n if (!withinGrace) {\n await this.revokeFamily(row.session_id, payload.jti, nowISO);\n throw OAuth2GrantError.invalid('refresh token replay detected; session revoked');\n }\n }\n\n // Blocklist the presented refresh token in the cache so introspection\n // reports it inactive. Deliberately NOT a DB revoke — that would set\n // revoked_at and break the grace window.\n await this.tokenRepository.setInactive(payload.jti, payload.exp);\n\n const session = await this.sessionManager.findOneById(payload.session_id);\n if (!session) {\n throw JWTError.payloadPropertyInvalid('session_id');\n }\n\n await this.sessionManager.verify(session);\n\n if (options.userAgent) {\n session.user_agent = options.userAgent;\n }\n if (options.ipAddress) {\n session.ip_address = options.ipAddress;\n }\n await this.sessionManager.refresh(session);\n\n const [refreshToken, refreshTokenPayload] = await this.refreshTokenIssuer.issue({\n ...payload,\n ...(options.confirmation ? { cnf: options.confirmation } : {}),\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n exp: this.refreshTokenIssuer.buildExp(),\n parent_id: payload.jti,\n });\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue({\n ...payload,\n ...(options.confirmation ? { cnf: options.confirmation } : {}),\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n exp: this.accessTokenIssuer.buildExp(),\n refresh_token_id: refreshTokenPayload.jti,\n });\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n refreshToken,\n refreshTokenPayload,\n });\n }\n\n /**\n * The grace window (opt-in via `tokenRefreshGracePeriod`) absorbs benign\n * concurrent / multi-tab refreshes of the SAME still-current token. It is\n * scoped to the chain tip: a token whose descendant has already been\n * consumed is a stale ancestor (a real replay), never a grace re-use.\n */\n protected async isWithinGraceWindow(jti: string, now: Date) : Promise<boolean> {\n if (this.gracePeriod <= 0) {\n return false;\n }\n\n const current = await this.sessionTokenRepository.findOneById(jti);\n if (\n !current ||\n current.revoked_at !== null ||\n current.consumed_at === null ||\n (now.getTime() - new Date(current.consumed_at).getTime()) > this.gracePeriod * 1_000\n ) {\n return false;\n }\n\n // Grace applies ONLY to the most-recent consumed token: a consumed\n // descendant proves the rotation advanced past this one (stale replay).\n const chainAdvanced = await this.sessionTokenRepository.hasConsumedChild(jti);\n return !chainAdvanced;\n }\n\n /**\n * RFC 6819 §5.2.2.3 reaction strategy — revoke the whole token family\n * (the auth_sessions row) on replay: soft-revoke every session-token row,\n * blocklist their jtis in the cache, and delete the session so its access\n * tokens stop verifying on authup's own API.\n */\n protected async revokeFamily(sessionId: string, jti: string, at: string) : Promise<void> {\n this.logger?.warn('OAuth2 refresh token replay detected; revoking session', {\n session_id: sessionId,\n jti,\n });\n\n await this.eventService?.record({\n scope: EventScope.OAUTH2,\n name: EventName.REFRESH_REPLAY_DETECTED,\n refType: EventRefType.SESSION,\n refId: sessionId,\n data: { jti },\n });\n this.metrics?.recordRefreshReplay();\n\n // Blocklisting is best-effort (cache) — settle all of them so one cache\n // failure cannot skip the rest or, worse, abort the session delete\n // below (the load-bearing part of the revocation). Pin each TTL to the\n // token's real expiry (unix seconds) so a long-lived refresh token\n // cannot resurface as active via introspection after the fallback 1h.\n const rows = await this.sessionTokenRepository.revokeBySessionId(sessionId, at);\n await Promise.allSettled(rows.map((row) => this.tokenRepository.setInactive(\n row.id,\n Math.floor(new Date(row.expires_at).getTime() / 1_000),\n )));\n\n await this.sessionManager.revoke(sessionId);\n }\n}\n"],"mappings":";;;;;;;;AAmBA,IAAaQ,0BAAb,cAA6CD,gBAAAA;CAC/BE;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEV,YAAYC,KAAqC;EAC7C,MAAM;GACFC,mBAAmBD,IAAIC;GACvBC,gBAAgBF,IAAIE;EACxB,CAAA;EAEA,KAAKV,qBAAqBQ,IAAIR;EAC9B,KAAKC,gBAAgBO,IAAIP;EACzB,KAAKC,kBAAkBM,IAAIN;EAC3B,KAAKC,yBAAyBK,IAAIL;EAClC,KAAKC,eAAeI,IAAIJ;EACxB,KAAKC,UAAUG,IAAIH;EACnB,KAAKC,SAASE,IAAIF;EAClB,KAAKC,cAAcC,IAAIG,SAASJ,eAAe;CACnD;CAEA,MAAMK,QACFC,OACAF,UAAqC,CAAC,GACJ;EAClC,IAAIG;EACJ,IAAI,OAAOD,UAAU,UAGjBC,UAAU,MAAM,KAAKb,cAAcc,OAAOF,OAAO,EAAEG,iBAAiB,KAAK,CAAA;OAEzEF,UAAUD;EAGd,IAAI,CAACC,QAAQG,KACT,MAAM1B,SAAS2B,uBAAuB,KAAA;EAE1C,IAAI,CAACJ,QAAQK,YACT,MAAM5B,SAAS2B,uBAAuB,YAAA;EAQ1C,IAAIJ,QAAQM,QAAQN,QAAQM,SAAS3B,gBAAgB4B,SACjD,MAAM7B,iBAAiB8B,QAAQ,uBAAA;EAGnC,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JC,KAAKC,MAAM,IAAIpD,KAAKJ,IAAIyD,UAAU,CAAA,CAAExB,QAAO,IAAK,GAAA,CAAA,CAAA,CAAA;EAGpD,MAAM,KAAK9C,eAAeuE,OAAOtB,SAAAA;CACrC;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"robot-credentials.d.ts","sourceRoot":"","sources":["../../../../src/core/oauth2/grant-types/robot-credentials.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAK9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,KAAK,CAAC;IACvD,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,GAAE,yBAA8B,GAAI,OAAO,CAAC,wBAAwB,CAAC;CA0B3G"}
1
+ {"version":3,"file":"robot-credentials.d.ts","sourceRoot":"","sources":["../../../../src/core/oauth2/grant-types/robot-credentials.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAM9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,KAAK,CAAC;IACvD,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,GAAE,yBAA8B,GAAI,OAAO,CAAC,wBAAwB,CAAC;CA2B3G"}
@@ -3,7 +3,7 @@ import "node:url";
3
3
  import.meta.url;
4
4
  import { OAuth2BaseGrant } from "./base.mjs";
5
5
  import { buildOAuth2BearerTokenResponse } from "../response/bearer.mjs";
6
- import { IdentityType, ScopeName } from "@authup/core-kit";
6
+ import { IdentityType, ScopeName, SessionAuthMethod } from "@authup/core-kit";
7
7
  import { OAuth2SubKind } from "@authup/specs";
8
8
  //#region src/core/oauth2/grant-types/robot-credentials.ts
9
9
  var RobotCredentialsGrant = class extends OAuth2BaseGrant {
@@ -13,7 +13,8 @@ var RobotCredentialsGrant = class extends OAuth2BaseGrant {
13
13
  ip_address: options.ipAddress,
14
14
  realm_id: input.realm_id,
15
15
  sub: input.id,
16
- sub_kind: IdentityType.ROBOT
16
+ sub_kind: IdentityType.ROBOT,
17
+ auth_method: SessionAuthMethod.ROBOT
17
18
  });
18
19
  const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue({
19
20
  session_id: session.id,
@@ -1 +1 @@
1
- {"version":3,"file":"robot-credentials.mjs","names":["OAuth2SubKind","IdentityType","ScopeName","OAuth2BaseGrant","buildOAuth2BearerTokenResponse","RobotCredentialsGrant","runWith","input","options","session","sessionManager","create","user_agent","userAgent","ip_address","ipAddress","realm_id","sub","id","sub_kind","ROBOT","accessToken","accessTokenPayload","accessTokenIssuer","issue","session_id","remote_address","scope","GLOBAL","realm","realm_name","name","client_id","undefined"],"sources":["../../../../src/core/oauth2/grant-types/robot-credentials.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse } from '@authup/specs';\nimport { OAuth2SubKind } from '@authup/specs';\nimport type { Robot } from '@authup/core-kit';\nimport {\n IdentityType,\n ScopeName,\n} from '@authup/core-kit';\nimport { OAuth2BaseGrant } from './base.ts';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { OAuth2GrantRunWIthOptions } from './types.ts';\n\nexport class RobotCredentialsGrant extends OAuth2BaseGrant<Robot> {\n async runWith(input: Robot, options: OAuth2GrantRunWIthOptions = {}) : Promise<OAuth2TokenGrantResponse> {\n const session = await this.sessionManager.create({\n user_agent: options.userAgent,\n ip_address: options.ipAddress,\n realm_id: input.realm_id,\n sub: input.id,\n sub_kind: IdentityType.ROBOT,\n });\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue({\n session_id: session.id,\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n scope: ScopeName.GLOBAL,\n sub: input.id,\n sub_kind: OAuth2SubKind.ROBOT,\n realm_id: input.realm.id,\n realm_name: input.realm.name,\n client_id: input.client_id || undefined,\n });\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n });\n }\n}\n"],"mappings":";;;;;;;;AAkBA,IAAaK,wBAAb,cAA2CF,gBAAAA;CACvC,MAAMG,QAAQC,OAAcC,UAAqC,CAAC,GAAuC;EACrG,MAAMC,UAAU,MAAM,KAAKC,eAAeC,OAAO;GAC7CC,YAAYJ,QAAQK;GACpBC,YAAYN,QAAQO;GACpBC,UAAUT,MAAMS;GAChBC,KAAKV,MAAMW;GACXC,UAAUlB,aAAamB;EAC3B,CAAA;EAEA,MAAM,CAACC,aAAaC,sBAAsB,MAAM,KAAKC,kBAAkBC,MAAM;GACzEC,YAAYhB,QAAQS;GACpBN,YAAYH,QAAQG;GACpBc,gBAAgBjB,QAAQK;GACxBa,OAAOzB,UAAU0B;GACjBX,KAAKV,MAAMW;GACXC,UAAUnB,cAAcoB;GACxBJ,UAAUT,MAAMsB,MAAMX;GACtBY,YAAYvB,MAAMsB,MAAME;GACxBC,WAAWzB,MAAMyB,aAAaC,KAAAA;EAClC,CAAA;EAEA,OAAO7B,+BAA+B;GAClCiB;GACAC;EACJ,CAAA;CACJ;AACJ"}
1
+ {"version":3,"file":"robot-credentials.mjs","names":["OAuth2SubKind","IdentityType","ScopeName","SessionAuthMethod","OAuth2BaseGrant","buildOAuth2BearerTokenResponse","RobotCredentialsGrant","runWith","input","options","session","sessionManager","create","user_agent","userAgent","ip_address","ipAddress","realm_id","sub","id","sub_kind","ROBOT","auth_method","accessToken","accessTokenPayload","accessTokenIssuer","issue","session_id","remote_address","scope","GLOBAL","realm","realm_name","name","client_id","undefined"],"sources":["../../../../src/core/oauth2/grant-types/robot-credentials.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse } from '@authup/specs';\nimport { OAuth2SubKind } from '@authup/specs';\nimport type { Robot } from '@authup/core-kit';\nimport {\n IdentityType,\n ScopeName, \n SessionAuthMethod,\n} from '@authup/core-kit';\nimport { OAuth2BaseGrant } from './base.ts';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { OAuth2GrantRunWIthOptions } from './types.ts';\n\nexport class RobotCredentialsGrant extends OAuth2BaseGrant<Robot> {\n async runWith(input: Robot, options: OAuth2GrantRunWIthOptions = {}) : Promise<OAuth2TokenGrantResponse> {\n const session = await this.sessionManager.create({\n user_agent: options.userAgent,\n ip_address: options.ipAddress,\n realm_id: input.realm_id,\n sub: input.id,\n sub_kind: IdentityType.ROBOT,\n auth_method: SessionAuthMethod.ROBOT,\n });\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue({\n session_id: session.id,\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n scope: ScopeName.GLOBAL,\n sub: input.id,\n sub_kind: OAuth2SubKind.ROBOT,\n realm_id: input.realm.id,\n realm_name: input.realm.name,\n client_id: input.client_id || undefined,\n });\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n });\n }\n}\n"],"mappings":";;;;;;;;AAmBA,IAAaM,wBAAb,cAA2CF,gBAAAA;CACvC,MAAMG,QAAQC,OAAcC,UAAqC,CAAC,GAAuC;EACrG,MAAMC,UAAU,MAAM,KAAKC,eAAeC,OAAO;GAC7CC,YAAYJ,QAAQK;GACpBC,YAAYN,QAAQO;GACpBC,UAAUT,MAAMS;GAChBC,KAAKV,MAAMW;GACXC,UAAUnB,aAAaoB;GACvBC,aAAanB,kBAAkBkB;EACnC,CAAA;EAEA,MAAM,CAACE,aAAaC,sBAAsB,MAAM,KAAKC,kBAAkBC,MAAM;GACzEC,YAAYjB,QAAQS;GACpBN,YAAYH,QAAQG;GACpBe,gBAAgBlB,QAAQK;GACxBc,OAAO3B,UAAU4B;GACjBZ,KAAKV,MAAMW;GACXC,UAAUpB,cAAcqB;GACxBJ,UAAUT,MAAMuB,MAAMZ;GACtBa,YAAYxB,MAAMuB,MAAME;GACxBC,WAAW1B,MAAM0B,aAAaC,KAAAA;EAClC,CAAA;EAEA,OAAO9B,+BAA+B;GAClCkB;GACAC;EACJ,CAAA;CACJ;AACJ"}
@@ -1,8 +1,10 @@
1
1
  import type { ObjectLiteral } from '@authup/kit';
2
- import type { OAuth2TokenGrantResponse } from '@authup/specs';
2
+ import type { OAuth2TokenConfirmation, OAuth2TokenGrantResponse } from '@authup/specs';
3
3
  import type { Logger } from '@authup/server-kit';
4
4
  import type { ISessionManager } from '../../authentication/index.ts';
5
- import type { IOAuth2KeyRepository } from '../key/index.ts';
5
+ import type { IEventService } from '../../entities/index.ts';
6
+ import type { IAuthFlowMetrics } from '../../metrics/index.ts';
7
+ import type { IKeyStore } from '../../key/index.ts';
6
8
  import type { ISessionTokenRepository } from '../session-token/index.ts';
7
9
  import type { IOAuth2OpenIDTokenIssuer, IOAuth2TokenIssuer, IOAuth2TokenRepository, IOAuth2TokenVerifier } from '../token/index.ts';
8
10
  export type BaseGrantContext = {
@@ -16,13 +18,15 @@ export type OAuth2AuthorizeGrantContext = BaseGrantContext & {
16
18
  * The realm's signing key determines the id_token's JWS alg — and with it
17
19
  * the at_hash digest (OIDC Core §3.1.3.6).
18
20
  */
19
- keyRepository: IOAuth2KeyRepository;
21
+ keyStore: IKeyStore;
20
22
  };
21
23
  export type OAuth2IdentityGrantContext = BaseGrantContext & {
22
24
  refreshTokenIssuer: IOAuth2TokenIssuer;
23
25
  };
24
26
  export type OAuth2PasswordGrantContext = BaseGrantContext & {
25
27
  refreshTokenIssuer: IOAuth2TokenIssuer;
28
+ eventService?: IEventService;
29
+ metrics?: IAuthFlowMetrics;
26
30
  };
27
31
  export type OAuth2RefreshTokenGrantOptions = {
28
32
  /**
@@ -37,12 +41,15 @@ export type OAuth2RefreshTokenGrantContext = BaseGrantContext & {
37
41
  tokenVerifier: IOAuth2TokenVerifier;
38
42
  tokenRepository: IOAuth2TokenRepository;
39
43
  sessionTokenRepository: ISessionTokenRepository;
44
+ eventService?: IEventService;
45
+ metrics?: IAuthFlowMetrics;
40
46
  logger?: Logger;
41
47
  options?: OAuth2RefreshTokenGrantOptions;
42
48
  };
43
49
  export type OAuth2GrantRunWIthOptions = {
44
50
  userAgent?: string;
45
51
  ipAddress?: string;
52
+ confirmation?: OAuth2TokenConfirmation;
46
53
  };
47
54
  export interface IOAuth2Grant<T = ObjectLiteral> {
48
55
  runWith(data: T, base?: OAuth2GrantRunWIthOptions): Promise<OAuth2TokenGrantResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/oauth2/grant-types/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EACR,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,gBAAgB,GAAG;IAC3B,iBAAiB,EAAE,kBAAkB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AE,oBAAoB,CAAC;IACpC,eAAe,EAAE,sBAAsB,CAAC;IACxC,sBAAsB,EAAE,uBAAuB,CAAC;IAChD,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,8BAA8B,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,uBAAuB,CAAC;CAC1C,CAAC;AAEF,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,aAAa;IAC3C,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,yBAAyB,GAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAC1F"}
@@ -1,8 +1,9 @@
1
+ export * from './access-policy/index.ts';
1
2
  export * from './authorization/index.ts';
2
3
  export * from './client/index.ts';
3
4
  export * from './end-session/index.ts';
4
5
  export * from './grant-types/index.ts';
5
- export * from './key/index.ts';
6
+ export * from './mfa-login/index.ts';
6
7
  export * from './openid/index.ts';
7
8
  export * from './response/index.ts';
8
9
  export * from './scope/index.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/oauth2/index.ts"],"names":[],"mappings":"AAOA,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/oauth2/index.ts"],"names":[],"mappings":"AAOA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC"}
@@ -1,8 +1,10 @@
1
1
  import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
+ import { OAuth2AccessPolicyEvaluator } from "./access-policy/module.mjs";
5
+ import "./access-policy/index.mjs";
4
6
  import { OAuth2AuthorizationCodeIssuer } from "./authorization/code/issuer/module.mjs";
5
- import { base64URLEncode, buildOAuth2CodeChallenge, buildOAuth2TokenHash, generateOAuth2CodeVerifier } from "./authorization/helpers.mjs";
7
+ import { base64URLEncode, buildOAuth2CodeChallenge, buildOAuth2TokenHash, deriveAmrAcr, generateOAuth2CodeVerifier } from "./authorization/helpers.mjs";
6
8
  import { OAuth2AuthorizationCodeVerifier } from "./authorization/code/verifier/module.mjs";
7
9
  import { OAuth2ClientAuthenticator } from "./client/authenticator.mjs";
8
10
  import { assertClientGrantAllowed } from "./client/grant-type.mjs";
@@ -23,15 +25,18 @@ import { PasswordGrantType } from "./grant-types/password.mjs";
23
25
  import { OAuth2RefreshTokenGrant } from "./grant-types/refresh-token.mjs";
24
26
  import { RobotCredentialsGrant } from "./grant-types/robot-credentials.mjs";
25
27
  import "./grant-types/index.mjs";
28
+ import { OAuth2MfaLoginService } from "./mfa-login/module.mjs";
29
+ import "./mfa-login/index.mjs";
26
30
  import { OAuth2OpenIDClaimsBuilder } from "./openid/claims.mjs";
27
31
  import "./openid/index.mjs";
28
32
  import { OAuth2ScopeAttributesResolver } from "./scope/resolver.mjs";
29
33
  import "./scope/index.mjs";
30
34
  import { OAuth2AccessTokenIssuer } from "./token/issuer/access/module.mjs";
35
+ import { OAuth2MfaTokenIssuer } from "./token/issuer/mfa/module.mjs";
31
36
  import { OAuth2OpenIDTokenIssuer } from "./token/issuer/open-id/module.mjs";
32
37
  import { OAuth2RefreshTokenIssuer } from "./token/issuer/refresh/module.mjs";
33
38
  import { OAuth2TokenRevoker } from "./token/revoker/module.mjs";
34
39
  import { OAuth2TokenSigner } from "./token/signer/module.mjs";
35
40
  import { OAuth2TokenVerifier } from "./token/verifier/module.mjs";
36
41
  import "./token/index.mjs";
37
- export { ClientCredentialsGrant, IdentityGrantType, OAuth2AccessTokenIssuer, OAuth2Authorization, OAuth2AuthorizationCodeIssuer, OAuth2AuthorizationCodeRequestValidator, OAuth2AuthorizationCodeRequestVerifier, OAuth2AuthorizationCodeVerifier, OAuth2AuthorizationStateManager, OAuth2AuthorizeGrant, OAuth2ClientAuthenticator, OAuth2EndSessionRequestValidator, OAuth2EndSessionService, OAuth2OpenIDClaimsBuilder, OAuth2OpenIDTokenIssuer, OAuth2RefreshTokenGrant, OAuth2RefreshTokenIssuer, OAuth2ScopeAttributesResolver, OAuth2TokenRevoker, OAuth2TokenSigner, OAuth2TokenVerifier, PasswordGrantType, RobotCredentialsGrant, assertClientGrantAllowed, base64URLEncode, buildOAuth2BearerTokenResponse, buildOAuth2CodeChallenge, buildOAuth2TokenHash, generateOAuth2CodeVerifier };
42
+ export { ClientCredentialsGrant, IdentityGrantType, OAuth2AccessPolicyEvaluator, OAuth2AccessTokenIssuer, OAuth2Authorization, OAuth2AuthorizationCodeIssuer, OAuth2AuthorizationCodeRequestValidator, OAuth2AuthorizationCodeRequestVerifier, OAuth2AuthorizationCodeVerifier, OAuth2AuthorizationStateManager, OAuth2AuthorizeGrant, OAuth2ClientAuthenticator, OAuth2EndSessionRequestValidator, OAuth2EndSessionService, OAuth2MfaLoginService, OAuth2MfaTokenIssuer, OAuth2OpenIDClaimsBuilder, OAuth2OpenIDTokenIssuer, OAuth2RefreshTokenGrant, OAuth2RefreshTokenIssuer, OAuth2ScopeAttributesResolver, OAuth2TokenRevoker, OAuth2TokenSigner, OAuth2TokenVerifier, PasswordGrantType, RobotCredentialsGrant, assertClientGrantAllowed, base64URLEncode, buildOAuth2BearerTokenResponse, buildOAuth2CodeChallenge, buildOAuth2TokenHash, deriveAmrAcr, generateOAuth2CodeVerifier };
@@ -0,0 +1,3 @@
1
+ export * from './module.ts';
2
+ export * from './types.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/oauth2/mfa-login/index.ts"],"names":[],"mappings":"AAOA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { OAuth2MfaLoginService } from "./module.mjs";
5
+ export { OAuth2MfaLoginService };
@@ -0,0 +1,19 @@
1
+ import type { OAuth2TokenGrantResponse } from '@authup/specs';
2
+ import type { IEventService } from '../../entities/index.ts';
3
+ import type { IAuthFlowMetrics } from '../../metrics/index.ts';
4
+ import type { ISessionManager } from '../../authentication/index.ts';
5
+ import type { IOAuth2TokenIssuer, IOAuth2TokenRepository } from '../token/index.ts';
6
+ import type { IOAuth2MfaLoginService, OAuth2MfaLoginCompleteInput, OAuth2MfaLoginServiceContext, OAuth2MfaLoginTicket, OAuth2MfaLoginTicketIssueInput, OAuth2MfaLoginTicketIssueOptions } from './types.ts';
7
+ export declare class OAuth2MfaLoginService implements IOAuth2MfaLoginService {
8
+ protected sessionManager: ISessionManager;
9
+ protected ticketIssuer: IOAuth2TokenIssuer;
10
+ protected accessTokenIssuer: IOAuth2TokenIssuer;
11
+ protected refreshTokenIssuer: IOAuth2TokenIssuer;
12
+ protected tokenRepository: IOAuth2TokenRepository;
13
+ protected eventService?: IEventService;
14
+ protected metrics?: IAuthFlowMetrics;
15
+ constructor(ctx: OAuth2MfaLoginServiceContext);
16
+ issueTicket(input: OAuth2MfaLoginTicketIssueInput, options?: OAuth2MfaLoginTicketIssueOptions): Promise<OAuth2MfaLoginTicket>;
17
+ complete(input: OAuth2MfaLoginCompleteInput): Promise<OAuth2TokenGrantResponse>;
18
+ }
19
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../src/core/oauth2/mfa-login/module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAsB,MAAM,eAAe,CAAC;AAUlF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,KAAK,EACR,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,gCAAgC,EACnC,MAAM,YAAY,CAAC;AAEpB,qBAAa,qBAAsB,YAAW,sBAAsB;IAChE,SAAS,CAAC,cAAc,EAAG,eAAe,CAAC;IAE3C,SAAS,CAAC,YAAY,EAAG,kBAAkB,CAAC;IAE5C,SAAS,CAAC,iBAAiB,EAAG,kBAAkB,CAAC;IAEjD,SAAS,CAAC,kBAAkB,EAAG,kBAAkB,CAAC;IAElD,SAAS,CAAC,eAAe,EAAG,sBAAsB,CAAC;IAEnD,SAAS,CAAC,YAAY,CAAC,EAAG,aAAa,CAAC;IAExC,SAAS,CAAC,OAAO,CAAC,EAAG,gBAAgB,CAAC;gBAE1B,GAAG,EAAE,4BAA4B;IAUvC,WAAW,CACb,KAAK,EAAE,8BAA8B,EACrC,OAAO,GAAE,gCAAqC,GAC9C,OAAO,CAAC,oBAAoB,CAAC;IA8C3B,QAAQ,CAAC,KAAK,EAAE,2BAA2B,GAAI,OAAO,CAAC,wBAAwB,CAAC;CAmEzF"}
@@ -0,0 +1,109 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { deriveAmrAcr } from "../authorization/helpers.mjs";
5
+ import { buildOAuth2BearerTokenResponse } from "../response/bearer.mjs";
6
+ import { EventName, EventRefType, EventScope, IdentityType, ScopeName, SessionAuthMethod } from "@authup/core-kit";
7
+ import { OAuth2GrantError, OAuth2SubKind, OAuth2TokenGrant } from "@authup/specs";
8
+ //#region src/core/oauth2/mfa-login/module.ts
9
+ var OAuth2MfaLoginService = class {
10
+ sessionManager;
11
+ ticketIssuer;
12
+ accessTokenIssuer;
13
+ refreshTokenIssuer;
14
+ tokenRepository;
15
+ eventService;
16
+ metrics;
17
+ constructor(ctx) {
18
+ this.sessionManager = ctx.sessionManager;
19
+ this.ticketIssuer = ctx.ticketIssuer;
20
+ this.accessTokenIssuer = ctx.accessTokenIssuer;
21
+ this.refreshTokenIssuer = ctx.refreshTokenIssuer;
22
+ this.tokenRepository = ctx.tokenRepository;
23
+ this.eventService = ctx.eventService;
24
+ this.metrics = ctx.metrics;
25
+ }
26
+ async issueTicket(input, options = {}) {
27
+ const { user } = input;
28
+ const clientId = input.clientId ?? void 0;
29
+ const expiresAt = this.ticketIssuer.buildExp();
30
+ const session = await this.sessionManager.create({
31
+ user_agent: options.userAgent,
32
+ ip_address: options.ipAddress,
33
+ realm_id: user.realm_id,
34
+ client_id: clientId,
35
+ sub: user.id,
36
+ sub_kind: IdentityType.USER,
37
+ mfa_at: null,
38
+ auth_method: SessionAuthMethod.PASSWORD,
39
+ expires_at: (/* @__PURE__ */ new Date(expiresAt * 1e3)).toISOString()
40
+ });
41
+ const [token, payload] = await this.ticketIssuer.issue({
42
+ client_id: clientId,
43
+ session_id: session.id,
44
+ user_agent: session.user_agent,
45
+ remote_address: session.ip_address,
46
+ sub: user.id,
47
+ sub_kind: OAuth2SubKind.USER,
48
+ realm_id: user.realm_id,
49
+ realm_name: user.realm?.name,
50
+ ...input.confirmation ? { cnf: input.confirmation } : {},
51
+ exp: expiresAt
52
+ });
53
+ return {
54
+ token,
55
+ expiresIn: payload.exp ? payload.exp - Math.floor(Date.now() / 1e3) : 0
56
+ };
57
+ }
58
+ async complete(input) {
59
+ const { ticket } = input;
60
+ const session = await this.sessionManager.refresh(input.session);
61
+ const amrAcr = deriveAmrAcr(session);
62
+ if (ticket.jti) {
63
+ if (!await this.tokenRepository.claimInactive(ticket.jti, ticket.exp)) throw OAuth2GrantError.invalid("mfa login ticket has already been used");
64
+ }
65
+ const issuePayload = {
66
+ client_id: session.client_id ?? void 0,
67
+ session_id: session.id,
68
+ user_agent: session.user_agent,
69
+ remote_address: session.ip_address,
70
+ scope: ScopeName.GLOBAL,
71
+ sub: session.sub,
72
+ sub_kind: OAuth2SubKind.USER,
73
+ realm_id: session.realm_id,
74
+ realm_name: ticket.realm_name,
75
+ ...ticket.cnf ? { cnf: ticket.cnf } : {},
76
+ ...amrAcr
77
+ };
78
+ const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue(issuePayload);
79
+ const [refreshToken, refreshTokenPayload] = await this.refreshTokenIssuer.issue(issuePayload);
80
+ await this.eventService?.record({
81
+ scope: EventScope.OAUTH2,
82
+ name: EventName.LOGIN,
83
+ refType: EventRefType.SESSION,
84
+ refId: session.id,
85
+ clientId: session.client_id ?? null,
86
+ actorType: IdentityType.USER,
87
+ actorId: session.sub,
88
+ actorName: input.userName ?? null,
89
+ realmId: session.realm_id,
90
+ requestIpAddress: session.ip_address ?? null,
91
+ requestUserAgent: session.user_agent ?? null,
92
+ data: {
93
+ grant_type: OAuth2TokenGrant.PASSWORD,
94
+ session_id: session.id
95
+ }
96
+ });
97
+ this.metrics?.recordLogin("success");
98
+ return buildOAuth2BearerTokenResponse({
99
+ accessToken,
100
+ accessTokenPayload,
101
+ refreshToken,
102
+ refreshTokenPayload
103
+ });
104
+ }
105
+ };
106
+ //#endregion
107
+ export { OAuth2MfaLoginService };
108
+
109
+ //# sourceMappingURL=module.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.mjs","names":["OAuth2GrantError","OAuth2SubKind","OAuth2TokenGrant","EventName","EventRefType","EventScope","IdentityType","ScopeName","SessionAuthMethod","deriveAmrAcr","buildOAuth2BearerTokenResponse","OAuth2MfaLoginService","sessionManager","ticketIssuer","accessTokenIssuer","refreshTokenIssuer","tokenRepository","eventService","metrics","ctx","issueTicket","input","options","user","clientId","undefined","expiresAt","buildExp","session","create","user_agent","userAgent","ip_address","ipAddress","realm_id","client_id","sub","id","sub_kind","USER","mfa_at","auth_method","PASSWORD","expires_at","Date","toISOString","token","payload","issue","session_id","remote_address","realm_name","realm","name","confirmation","cnf","exp","expiresIn","Math","floor","now","complete","ticket","refresh","amrAcr","jti","claimed","claimInactive","invalid","issuePayload","scope","GLOBAL","accessToken","accessTokenPayload","refreshToken","refreshTokenPayload","record","OAUTH2","LOGIN","refType","SESSION","refId","actorType","actorId","actorName","userName","realmId","requestIpAddress","requestUserAgent","data","grant_type","recordLogin"],"sources":["../../../../src/core/oauth2/mfa-login/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2TokenGrantResponse, OAuth2TokenPayload } from '@authup/specs';\nimport { OAuth2GrantError, OAuth2SubKind, OAuth2TokenGrant } from '@authup/specs';\nimport {\n EventName,\n EventRefType,\n EventScope,\n IdentityType,\n ScopeName,\n SessionAuthMethod,\n} from '@authup/core-kit';\nimport type { IEventService } from '../../entities/index.ts';\nimport type { IAuthFlowMetrics } from '../../metrics/index.ts';\nimport type { ISessionManager } from '../../authentication/index.ts';\nimport { deriveAmrAcr } from '../authorization/helpers.ts';\nimport { buildOAuth2BearerTokenResponse } from '../response/index.ts';\nimport type { IOAuth2TokenIssuer, IOAuth2TokenRepository } from '../token/index.ts';\nimport type {\n IOAuth2MfaLoginService,\n OAuth2MfaLoginCompleteInput,\n OAuth2MfaLoginServiceContext,\n OAuth2MfaLoginTicket,\n OAuth2MfaLoginTicketIssueInput,\n OAuth2MfaLoginTicketIssueOptions,\n} from './types.ts';\n\nexport class OAuth2MfaLoginService implements IOAuth2MfaLoginService {\n protected sessionManager : ISessionManager;\n\n protected ticketIssuer : IOAuth2TokenIssuer;\n\n protected accessTokenIssuer : IOAuth2TokenIssuer;\n\n protected refreshTokenIssuer : IOAuth2TokenIssuer;\n\n protected tokenRepository : IOAuth2TokenRepository;\n\n protected eventService? : IEventService;\n\n protected metrics? : IAuthFlowMetrics;\n\n constructor(ctx: OAuth2MfaLoginServiceContext) {\n this.sessionManager = ctx.sessionManager;\n this.ticketIssuer = ctx.ticketIssuer;\n this.accessTokenIssuer = ctx.accessTokenIssuer;\n this.refreshTokenIssuer = ctx.refreshTokenIssuer;\n this.tokenRepository = ctx.tokenRepository;\n this.eventService = ctx.eventService;\n this.metrics = ctx.metrics;\n }\n\n async issueTicket(\n input: OAuth2MfaLoginTicketIssueInput,\n options: OAuth2MfaLoginTicketIssueOptions = {},\n ) : Promise<OAuth2MfaLoginTicket> {\n const { user } = input;\n const clientId = input.clientId ?? undefined;\n\n // One expiration instant for BOTH artifacts — the pending session\n // lives exactly as long as the ticket (an abandoned login\n // self-expires and is swept with the regular session sweep;\n // completion extends it to the full lifetime). Computed once so\n // the two cannot drift.\n const expiresAt = this.ticketIssuer.buildExp();\n\n const session = await this.sessionManager.create({\n user_agent: options.userAgent,\n ip_address: options.ipAddress,\n realm_id: user.realm_id,\n client_id: clientId,\n sub: user.id,\n sub_kind: IdentityType.USER,\n mfa_at: null,\n auth_method: SessionAuthMethod.PASSWORD,\n expires_at: new Date(expiresAt * 1000).toISOString(),\n });\n\n // No scope, no role claims — the ticket is not a bearer; it only\n // unlocks the challenge routes (which opt in by kind).\n const [token, payload] = await this.ticketIssuer.issue({\n client_id: clientId,\n session_id: session.id,\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n sub: user.id,\n sub_kind: OAuth2SubKind.USER,\n realm_id: user.realm_id,\n realm_name: user.realm?.name,\n ...(input.confirmation ? { cnf: input.confirmation } : {}),\n exp: expiresAt,\n });\n\n return {\n token,\n expiresIn: payload.exp ?\n payload.exp - Math.floor(Date.now() / 1000) :\n 0,\n };\n }\n\n async complete(input: OAuth2MfaLoginCompleteInput) : Promise<OAuth2TokenGrantResponse> {\n const { ticket } = input;\n\n // Extend the ticket-scoped pending session to the regular session\n // lifetime — the login is complete now.\n const session = await this.sessionManager.refresh(input.session);\n\n // mfa_at was stamped inside the verify unit of work, so the claims\n // advertise the completed factor (amr +otp, acr urn:authup:mfa).\n const amrAcr = deriveAmrAcr(session);\n\n // Single use: atomically claim the ticket BEFORE minting so two\n // concurrent completions (a mixed-kind user presenting two distinct\n // fresh factors) cannot both issue a token pair — `claimInactive` is a\n // set-if-absent write, so exactly one racer wins. The trade-off vs.\n // claiming after minting is that a mint failure burns the ticket — the\n // safer bias for a single-use login credential (the user re-authenticates).\n if (ticket.jti) {\n const claimed = await this.tokenRepository.claimInactive(ticket.jti, ticket.exp);\n if (!claimed) {\n throw OAuth2GrantError.invalid('mfa login ticket has already been used');\n }\n }\n\n const issuePayload : Partial<OAuth2TokenPayload> = {\n client_id: session.client_id ?? undefined,\n session_id: session.id,\n user_agent: session.user_agent,\n remote_address: session.ip_address,\n scope: ScopeName.GLOBAL,\n sub: session.sub,\n sub_kind: OAuth2SubKind.USER,\n realm_id: session.realm_id,\n realm_name: ticket.realm_name,\n ...(ticket.cnf ? { cnf: ticket.cnf } : {}),\n ...amrAcr,\n };\n\n const [accessToken, accessTokenPayload] = await this.accessTokenIssuer.issue(issuePayload);\n const [refreshToken, refreshTokenPayload] = await this.refreshTokenIssuer.issue(issuePayload);\n\n await this.eventService?.record({\n scope: EventScope.OAUTH2,\n name: EventName.LOGIN,\n refType: EventRefType.SESSION,\n refId: session.id,\n clientId: session.client_id ?? null,\n actorType: IdentityType.USER,\n actorId: session.sub,\n actorName: input.userName ?? null,\n realmId: session.realm_id,\n requestIpAddress: session.ip_address ?? null,\n requestUserAgent: session.user_agent ?? null,\n data: {\n grant_type: OAuth2TokenGrant.PASSWORD,\n session_id: session.id,\n },\n });\n this.metrics?.recordLogin('success');\n\n return buildOAuth2BearerTokenResponse({\n accessToken,\n accessTokenPayload,\n refreshToken,\n refreshTokenPayload,\n });\n }\n}\n"],"mappings":";;;;;;;;AAgCA,IAAaW,wBAAb,MAAaA;CACCC;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEV,YAAYC,KAAmC;EAC3C,KAAKP,iBAAiBO,IAAIP;EAC1B,KAAKC,eAAeM,IAAIN;EACxB,KAAKC,oBAAoBK,IAAIL;EAC7B,KAAKC,qBAAqBI,IAAIJ;EAC9B,KAAKC,kBAAkBG,IAAIH;EAC3B,KAAKC,eAAeE,IAAIF;EACxB,KAAKC,UAAUC,IAAID;CACvB;CAEA,MAAME,YACFC,OACAC,UAA4C,CAAC,GACf;EAC9B,MAAM,EAAEC,SAASF;EACjB,MAAMG,WAAWH,MAAMG,YAAYC,KAAAA;EAOnC,MAAMC,YAAY,KAAKb,aAAac,SAAQ;EAE5C,MAAMC,UAAU,MAAM,KAAKhB,eAAeiB,OAAO;GAC7CC,YAAYR,QAAQS;GACpBC,YAAYV,QAAQW;GACpBC,UAAUX,KAAKW;GACfC,WAAWX;GACXY,KAAKb,KAAKc;GACVC,UAAUhC,aAAaiC;GACvBC,QAAQ;GACRC,aAAajC,kBAAkBkC;GAC/BC,6BAAY,IAAIC,KAAKlB,YAAY,GAAA,EAAA,CAAMmB,YAAW;EACtD,CAAA;EAIA,MAAM,CAACC,OAAOC,WAAW,MAAM,KAAKlC,aAAamC,MAAM;GACnDb,WAAWX;GACXyB,YAAYrB,QAAQS;GACpBP,YAAYF,QAAQE;GACpBoB,gBAAgBtB,QAAQI;GACxBI,KAAKb,KAAKc;GACVC,UAAUrC,cAAcsC;GACxBL,UAAUX,K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