@spinajs/rbac-http-user 2.0.486 → 2.0.488

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 (239) hide show
  1. package/lib/cjs/config/rbac-http.d.ts +0 -15
  2. package/lib/cjs/config/rbac-http.d.ts.map +1 -1
  3. package/lib/cjs/config/rbac-http.js +6 -16
  4. package/lib/cjs/config/rbac-http.js.map +1 -1
  5. package/lib/cjs/controllers/ActiveRoleController.d.ts +2 -1
  6. package/lib/cjs/controllers/ActiveRoleController.d.ts.map +1 -1
  7. package/lib/cjs/controllers/ActiveRoleController.js +7 -17
  8. package/lib/cjs/controllers/ActiveRoleController.js.map +1 -1
  9. package/lib/cjs/controllers/ImpersonationController.d.ts +7 -9
  10. package/lib/cjs/controllers/ImpersonationController.d.ts.map +1 -1
  11. package/lib/cjs/controllers/ImpersonationController.js +31 -56
  12. package/lib/cjs/controllers/ImpersonationController.js.map +1 -1
  13. package/lib/cjs/controllers/LoginController.d.ts +10 -3
  14. package/lib/cjs/controllers/LoginController.d.ts.map +1 -1
  15. package/lib/cjs/controllers/LoginController.js +39 -40
  16. package/lib/cjs/controllers/LoginController.js.map +1 -1
  17. package/lib/cjs/controllers/PasswordResetController.d.ts +54 -0
  18. package/lib/cjs/controllers/PasswordResetController.d.ts.map +1 -0
  19. package/lib/cjs/controllers/PasswordResetController.js +129 -0
  20. package/lib/cjs/controllers/PasswordResetController.js.map +1 -0
  21. package/lib/cjs/controllers/SessionsController.d.ts +65 -0
  22. package/lib/cjs/controllers/SessionsController.d.ts.map +1 -0
  23. package/lib/cjs/controllers/SessionsController.js +143 -0
  24. package/lib/cjs/controllers/SessionsController.js.map +1 -0
  25. package/lib/cjs/controllers/TwoFactorAuthController.d.ts +24 -23
  26. package/lib/cjs/controllers/TwoFactorAuthController.d.ts.map +1 -1
  27. package/lib/cjs/controllers/TwoFactorAuthController.js +39 -72
  28. package/lib/cjs/controllers/TwoFactorAuthController.js.map +1 -1
  29. package/lib/cjs/controllers/TwoFactorAuthUserController.d.ts +98 -0
  30. package/lib/cjs/controllers/TwoFactorAuthUserController.d.ts.map +1 -0
  31. package/lib/cjs/controllers/TwoFactorAuthUserController.js +195 -0
  32. package/lib/cjs/controllers/TwoFactorAuthUserController.js.map +1 -0
  33. package/lib/cjs/controllers/UserController.d.ts +10 -7
  34. package/lib/cjs/controllers/UserController.d.ts.map +1 -1
  35. package/lib/cjs/controllers/UserController.js +56 -58
  36. package/lib/cjs/controllers/UserController.js.map +1 -1
  37. package/lib/cjs/controllers/UserMetadataController.d.ts +6 -12
  38. package/lib/cjs/controllers/UserMetadataController.d.ts.map +1 -1
  39. package/lib/cjs/controllers/UserMetadataController.js +23 -72
  40. package/lib/cjs/controllers/UserMetadataController.js.map +1 -1
  41. package/lib/cjs/dto/confirm-password-dto.d.ts +23 -0
  42. package/lib/cjs/dto/confirm-password-dto.d.ts.map +1 -0
  43. package/lib/cjs/dto/{restore-password-dto.js → confirm-password-dto.js} +16 -12
  44. package/lib/cjs/dto/confirm-password-dto.js.map +1 -0
  45. package/lib/cjs/dto/password-reset-dto.d.ts +58 -0
  46. package/lib/cjs/dto/password-reset-dto.d.ts.map +1 -0
  47. package/lib/cjs/dto/password-reset-dto.js +57 -0
  48. package/lib/cjs/dto/password-reset-dto.js.map +1 -0
  49. package/lib/cjs/handlers/DefaultLogoutHandler.d.ts +4 -1
  50. package/lib/cjs/handlers/DefaultLogoutHandler.d.ts.map +1 -1
  51. package/lib/cjs/handlers/DefaultLogoutHandler.js +20 -13
  52. package/lib/cjs/handlers/DefaultLogoutHandler.js.map +1 -1
  53. package/lib/cjs/handlers/ImpersonationLogoutHandler.d.ts +4 -7
  54. package/lib/cjs/handlers/ImpersonationLogoutHandler.d.ts.map +1 -1
  55. package/lib/cjs/handlers/ImpersonationLogoutHandler.js +30 -31
  56. package/lib/cjs/handlers/ImpersonationLogoutHandler.js.map +1 -1
  57. package/lib/cjs/index.d.ts +20 -0
  58. package/lib/cjs/index.d.ts.map +1 -1
  59. package/lib/cjs/index.js +22 -0
  60. package/lib/cjs/index.js.map +1 -1
  61. package/lib/cjs/logout.d.ts +7 -0
  62. package/lib/cjs/logout.d.ts.map +1 -1
  63. package/lib/cjs/logout.js.map +1 -1
  64. package/lib/cjs/policies/2FaPolicy.d.ts +21 -1
  65. package/lib/cjs/policies/2FaPolicy.d.ts.map +1 -1
  66. package/lib/cjs/policies/2FaPolicy.js +31 -7
  67. package/lib/cjs/policies/2FaPolicy.js.map +1 -1
  68. package/lib/cjs/services/ImpersonationService.d.ts +90 -0
  69. package/lib/cjs/services/ImpersonationService.d.ts.map +1 -0
  70. package/lib/cjs/services/ImpersonationService.js +147 -0
  71. package/lib/cjs/services/ImpersonationService.js.map +1 -0
  72. package/lib/cjs/services/SessionCookies.d.ts +41 -0
  73. package/lib/cjs/services/SessionCookies.d.ts.map +1 -0
  74. package/lib/cjs/services/SessionCookies.js +62 -0
  75. package/lib/cjs/services/SessionCookies.js.map +1 -0
  76. package/lib/cjs/services/UserMetadataService.d.ts +53 -0
  77. package/lib/cjs/services/UserMetadataService.d.ts.map +1 -0
  78. package/lib/cjs/services/UserMetadataService.js +94 -0
  79. package/lib/cjs/services/UserMetadataService.js.map +1 -0
  80. package/lib/cjs/services/grants.d.ts +29 -0
  81. package/lib/cjs/services/grants.d.ts.map +1 -0
  82. package/lib/cjs/services/grants.js +43 -0
  83. package/lib/cjs/services/grants.js.map +1 -0
  84. package/lib/mjs/config/rbac-http.d.ts +0 -15
  85. package/lib/mjs/config/rbac-http.d.ts.map +1 -1
  86. package/lib/mjs/config/rbac-http.js +6 -16
  87. package/lib/mjs/config/rbac-http.js.map +1 -1
  88. package/lib/mjs/controllers/ActiveRoleController.d.ts +2 -1
  89. package/lib/mjs/controllers/ActiveRoleController.d.ts.map +1 -1
  90. package/lib/mjs/controllers/ActiveRoleController.js +8 -18
  91. package/lib/mjs/controllers/ActiveRoleController.js.map +1 -1
  92. package/lib/mjs/controllers/ImpersonationController.d.ts +7 -9
  93. package/lib/mjs/controllers/ImpersonationController.d.ts.map +1 -1
  94. package/lib/mjs/controllers/ImpersonationController.js +32 -57
  95. package/lib/mjs/controllers/ImpersonationController.js.map +1 -1
  96. package/lib/mjs/controllers/LoginController.d.ts +10 -3
  97. package/lib/mjs/controllers/LoginController.d.ts.map +1 -1
  98. package/lib/mjs/controllers/LoginController.js +42 -43
  99. package/lib/mjs/controllers/LoginController.js.map +1 -1
  100. package/lib/mjs/controllers/PasswordResetController.d.ts +54 -0
  101. package/lib/mjs/controllers/PasswordResetController.d.ts.map +1 -0
  102. package/lib/mjs/controllers/PasswordResetController.js +126 -0
  103. package/lib/mjs/controllers/PasswordResetController.js.map +1 -0
  104. package/lib/mjs/controllers/SessionsController.d.ts +65 -0
  105. package/lib/mjs/controllers/SessionsController.d.ts.map +1 -0
  106. package/lib/mjs/controllers/SessionsController.js +140 -0
  107. package/lib/mjs/controllers/SessionsController.js.map +1 -0
  108. package/lib/mjs/controllers/TwoFactorAuthController.d.ts +24 -23
  109. package/lib/mjs/controllers/TwoFactorAuthController.d.ts.map +1 -1
  110. package/lib/mjs/controllers/TwoFactorAuthController.js +43 -76
  111. package/lib/mjs/controllers/TwoFactorAuthController.js.map +1 -1
  112. package/lib/mjs/controllers/TwoFactorAuthUserController.d.ts +98 -0
  113. package/lib/mjs/controllers/TwoFactorAuthUserController.d.ts.map +1 -0
  114. package/lib/mjs/controllers/TwoFactorAuthUserController.js +192 -0
  115. package/lib/mjs/controllers/TwoFactorAuthUserController.js.map +1 -0
  116. package/lib/mjs/controllers/UserController.d.ts +10 -7
  117. package/lib/mjs/controllers/UserController.d.ts.map +1 -1
  118. package/lib/mjs/controllers/UserController.js +59 -28
  119. package/lib/mjs/controllers/UserController.js.map +1 -1
  120. package/lib/mjs/controllers/UserMetadataController.d.ts +6 -12
  121. package/lib/mjs/controllers/UserMetadataController.d.ts.map +1 -1
  122. package/lib/mjs/controllers/UserMetadataController.js +23 -72
  123. package/lib/mjs/controllers/UserMetadataController.js.map +1 -1
  124. package/lib/mjs/dto/confirm-password-dto.d.ts +23 -0
  125. package/lib/mjs/dto/confirm-password-dto.d.ts.map +1 -0
  126. package/lib/mjs/dto/{user-dto.js → confirm-password-dto.js} +15 -10
  127. package/lib/mjs/dto/confirm-password-dto.js.map +1 -0
  128. package/lib/mjs/dto/password-reset-dto.d.ts +58 -0
  129. package/lib/mjs/dto/password-reset-dto.d.ts.map +1 -0
  130. package/lib/mjs/dto/password-reset-dto.js +54 -0
  131. package/lib/mjs/dto/password-reset-dto.js.map +1 -0
  132. package/lib/mjs/handlers/DefaultLogoutHandler.d.ts +4 -1
  133. package/lib/mjs/handlers/DefaultLogoutHandler.d.ts.map +1 -1
  134. package/lib/mjs/handlers/DefaultLogoutHandler.js +23 -16
  135. package/lib/mjs/handlers/DefaultLogoutHandler.js.map +1 -1
  136. package/lib/mjs/handlers/ImpersonationLogoutHandler.d.ts +4 -7
  137. package/lib/mjs/handlers/ImpersonationLogoutHandler.d.ts.map +1 -1
  138. package/lib/mjs/handlers/ImpersonationLogoutHandler.js +31 -32
  139. package/lib/mjs/handlers/ImpersonationLogoutHandler.js.map +1 -1
  140. package/lib/mjs/index.d.ts +20 -0
  141. package/lib/mjs/index.d.ts.map +1 -1
  142. package/lib/mjs/index.js +22 -0
  143. package/lib/mjs/index.js.map +1 -1
  144. package/lib/mjs/logout.d.ts +7 -0
  145. package/lib/mjs/logout.d.ts.map +1 -1
  146. package/lib/mjs/logout.js.map +1 -1
  147. package/lib/mjs/policies/2FaPolicy.d.ts +21 -1
  148. package/lib/mjs/policies/2FaPolicy.d.ts.map +1 -1
  149. package/lib/mjs/policies/2FaPolicy.js +29 -6
  150. package/lib/mjs/policies/2FaPolicy.js.map +1 -1
  151. package/lib/mjs/services/ImpersonationService.d.ts +90 -0
  152. package/lib/mjs/services/ImpersonationService.d.ts.map +1 -0
  153. package/lib/mjs/services/ImpersonationService.js +144 -0
  154. package/lib/mjs/services/ImpersonationService.js.map +1 -0
  155. package/lib/mjs/services/SessionCookies.d.ts +41 -0
  156. package/lib/mjs/services/SessionCookies.d.ts.map +1 -0
  157. package/lib/mjs/services/SessionCookies.js +59 -0
  158. package/lib/mjs/services/SessionCookies.js.map +1 -0
  159. package/lib/mjs/services/UserMetadataService.d.ts +53 -0
  160. package/lib/mjs/services/UserMetadataService.d.ts.map +1 -0
  161. package/lib/mjs/services/UserMetadataService.js +91 -0
  162. package/lib/mjs/services/UserMetadataService.js.map +1 -0
  163. package/lib/mjs/services/grants.d.ts +29 -0
  164. package/lib/mjs/services/grants.d.ts.map +1 -0
  165. package/lib/mjs/services/grants.js +38 -0
  166. package/lib/mjs/services/grants.js.map +1 -0
  167. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  168. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  169. package/package.json +17 -11
  170. package/lib/cjs/controllers/AuthController.d.ts +0 -1
  171. package/lib/cjs/controllers/AuthController.d.ts.map +0 -1
  172. package/lib/cjs/controllers/AuthController.js +0 -211
  173. package/lib/cjs/controllers/AuthController.js.map +0 -1
  174. package/lib/cjs/controllers/FederatedLoginController.d.ts +0 -1
  175. package/lib/cjs/controllers/FederatedLoginController.d.ts.map +0 -1
  176. package/lib/cjs/controllers/FederatedLoginController.js +0 -38
  177. package/lib/cjs/controllers/FederatedLoginController.js.map +0 -1
  178. package/lib/cjs/dto/login-dto.d.ts +0 -17
  179. package/lib/cjs/dto/login-dto.d.ts.map +0 -1
  180. package/lib/cjs/dto/login-dto.js +0 -33
  181. package/lib/cjs/dto/login-dto.js.map +0 -1
  182. package/lib/cjs/dto/restore-password-dto.d.ts +0 -24
  183. package/lib/cjs/dto/restore-password-dto.d.ts.map +0 -1
  184. package/lib/cjs/dto/restore-password-dto.js.map +0 -1
  185. package/lib/cjs/dto/user-dto.d.ts +0 -22
  186. package/lib/cjs/dto/user-dto.d.ts.map +0 -1
  187. package/lib/cjs/dto/user-dto.js +0 -33
  188. package/lib/cjs/dto/user-dto.js.map +0 -1
  189. package/lib/cjs/fingerprint/FingerprintJs.d.ts +0 -1
  190. package/lib/cjs/fingerprint/FingerprintJs.d.ts.map +0 -1
  191. package/lib/cjs/fingerprint/FingerprintJs.js +0 -5
  192. package/lib/cjs/fingerprint/FingerprintJs.js.map +0 -1
  193. package/lib/cjs/middlewares/AttributeFilter.d.ts +0 -11
  194. package/lib/cjs/middlewares/AttributeFilter.d.ts.map +0 -1
  195. package/lib/cjs/middlewares/AttributeFilter.js +0 -19
  196. package/lib/cjs/middlewares/AttributeFilter.js.map +0 -1
  197. package/lib/cjs/policies/AllowFederatedLoginPolicy.d.ts +0 -7
  198. package/lib/cjs/policies/AllowFederatedLoginPolicy.d.ts.map +0 -1
  199. package/lib/cjs/policies/AllowFederatedLoginPolicy.js +0 -32
  200. package/lib/cjs/policies/AllowFederatedLoginPolicy.js.map +0 -1
  201. package/lib/cjs/policies/CaptchaPolicy.d.ts +0 -1
  202. package/lib/cjs/policies/CaptchaPolicy.d.ts.map +0 -1
  203. package/lib/cjs/policies/CaptchaPolicy.js +0 -1
  204. package/lib/cjs/policies/CaptchaPolicy.js.map +0 -1
  205. package/lib/mjs/controllers/AuthController.d.ts +0 -2
  206. package/lib/mjs/controllers/AuthController.d.ts.map +0 -1
  207. package/lib/mjs/controllers/AuthController.js +0 -212
  208. package/lib/mjs/controllers/AuthController.js.map +0 -1
  209. package/lib/mjs/controllers/FederatedLoginController.d.ts +0 -2
  210. package/lib/mjs/controllers/FederatedLoginController.d.ts.map +0 -1
  211. package/lib/mjs/controllers/FederatedLoginController.js +0 -39
  212. package/lib/mjs/controllers/FederatedLoginController.js.map +0 -1
  213. package/lib/mjs/dto/login-dto.d.ts +0 -17
  214. package/lib/mjs/dto/login-dto.d.ts.map +0 -1
  215. package/lib/mjs/dto/login-dto.js +0 -30
  216. package/lib/mjs/dto/login-dto.js.map +0 -1
  217. package/lib/mjs/dto/restore-password-dto.d.ts +0 -24
  218. package/lib/mjs/dto/restore-password-dto.d.ts.map +0 -1
  219. package/lib/mjs/dto/restore-password-dto.js +0 -31
  220. package/lib/mjs/dto/restore-password-dto.js.map +0 -1
  221. package/lib/mjs/dto/user-dto.d.ts +0 -22
  222. package/lib/mjs/dto/user-dto.d.ts.map +0 -1
  223. package/lib/mjs/dto/user-dto.js.map +0 -1
  224. package/lib/mjs/fingerprint/FingerprintJs.d.ts +0 -2
  225. package/lib/mjs/fingerprint/FingerprintJs.d.ts.map +0 -1
  226. package/lib/mjs/fingerprint/FingerprintJs.js +0 -6
  227. package/lib/mjs/fingerprint/FingerprintJs.js.map +0 -1
  228. package/lib/mjs/middlewares/AttributeFilter.d.ts +0 -11
  229. package/lib/mjs/middlewares/AttributeFilter.d.ts.map +0 -1
  230. package/lib/mjs/middlewares/AttributeFilter.js +0 -15
  231. package/lib/mjs/middlewares/AttributeFilter.js.map +0 -1
  232. package/lib/mjs/policies/AllowFederatedLoginPolicy.d.ts +0 -7
  233. package/lib/mjs/policies/AllowFederatedLoginPolicy.d.ts.map +0 -1
  234. package/lib/mjs/policies/AllowFederatedLoginPolicy.js +0 -28
  235. package/lib/mjs/policies/AllowFederatedLoginPolicy.js.map +0 -1
  236. package/lib/mjs/policies/CaptchaPolicy.d.ts +0 -2
  237. package/lib/mjs/policies/CaptchaPolicy.d.ts.map +0 -1
  238. package/lib/mjs/policies/CaptchaPolicy.js +0 -2
  239. package/lib/mjs/policies/CaptchaPolicy.js.map +0 -1
@@ -11,14 +11,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
13
  import { PasswordDto } from '../dto/password-dto.js';
14
- import { User as UserModel, PasswordProvider, SessionProvider, passwordMatch, changePassword, _unwindGrants, AccessControl } from '@spinajs/rbac';
15
- import { BaseController, BasePath, Get, Ok, Body, Patch, Cookie, Policy } from '@spinajs/http';
14
+ import { User as UserModel, PasswordProvider, SessionProvider, UserSession, passwordMatch, changePassword, AccessControl } from '@spinajs/rbac';
15
+ import { BaseController, BasePath, Get, Ok, Body, Patch, Policy } from '@spinajs/http';
16
16
  import { InvalidArgument } from '@spinajs/exceptions';
17
17
  import { Autoinject } from '@spinajs/di';
18
- import { Config } from '@spinajs/configuration';
19
- import * as cs from 'cookie-signature';
20
- import { AuthorizedPolicy, Permission, Resource, User } from '@spinajs/rbac-http';
18
+ import { AuthorizedPolicy, Permission, Resource, User, Session as SessionRouteArg, SessionId as SessionIdArg } from '@spinajs/rbac-http';
21
19
  import { _chain, _either } from '@spinajs/util';
20
+ import { activeRoleOf, grantsFor } from '../services/grants.js';
21
+ import { SessionCookieFactory } from '../services/SessionCookies.js';
22
22
  /**
23
23
  * Current user profile management.
24
24
  * Allows an authenticated user to read and modify their own account — refresh profile data,
@@ -39,10 +39,11 @@ let UserController = class UserController extends BaseController {
39
39
  // get user data from db
40
40
  await user.refresh();
41
41
  await user.Metadata.populate();
42
- // refresh session data from DB
43
- const sId = cs.unsign(ssid, this.CoockieSecret);
44
- if (sId) {
45
- const session = await this.SessionProvider.restore(sId);
42
+ // `@Cookie(true)` hands over the already-unsigned session id the previous
43
+ // unsigned read plus a hand-rolled `cookie-signature` call duplicated what
44
+ // the framework's own extractor does, secret lookup included.
45
+ if (ssid) {
46
+ const session = await this.SessionProvider.restore(ssid);
46
47
  if (session) {
47
48
  // Session stores the user UUID (see LoginController) — RbacUserFactory
48
49
  // resolves the user from it on each request. Storing a dehydrated object
@@ -51,22 +52,28 @@ let UserController = class UserController extends BaseController {
51
52
  await this.SessionProvider.save(session);
52
53
  }
53
54
  }
54
- return new Ok(user.dehydrate());
55
+ // Same shape as every other user-bearing response ( login, whoami, 2FA
56
+ // verify ): relations included and DateTime rendered as ISO strings. Plain
57
+ // `dehydrate()` dropped Role/Metadata and emitted raw DateTime objects, so
58
+ // a client refreshing its profile got a different user than it logged in with.
59
+ return new Ok(user.dehydrateWithRelations({ dateTimeFormat: 'iso' }));
55
60
  }
56
61
  /**
57
62
  * Get current user grants
58
- * Returns the flattened RBAC grants for the authenticated user, combining all roles
59
- * the user is assigned to into a single permission map keyed by resource.
63
+ * Returns the flattened RBAC grants in effect for the authenticated user those of
64
+ * the session's active role, resolved through its inheritance chain. Switching the
65
+ * active role (`POST /auth/active-role`) changes what this returns.
60
66
  * @security cookieAuth
61
- * @returns {IGrantsMap} Combined RBAC grants map: resource → action → permission descriptor
67
+ * @returns {IGrantsMap} RBAC grants map for the active role: resource → action → permission descriptor
62
68
  * @response 401 Unauthorized — valid session required
63
69
  * @response 403 Forbidden — insufficient permissions
64
70
  */
65
- async getGrants(user) {
66
- const grants = this.AC.getGrants();
67
- const userGrants = user.Role.map(r => _unwindGrants(r, grants));
68
- const combinedGrants = Object.assign({}, ...userGrants);
69
- return new Ok(combinedGrants);
71
+ async getGrants(user, session) {
72
+ // Enforcement is bound to the session's ActiveRole, so reporting the union
73
+ // of every assigned role told clients about actions the server would then
74
+ // refuse a user holding both 'admin' and 'user' saw admin grants while
75
+ // acting as 'user'. Resolve exactly what the middleware resolves.
76
+ return new Ok(grantsFor(this.AC, activeRoleOf(user, session)));
70
77
  }
71
78
  /**
72
79
  * Change own password
@@ -77,23 +84,41 @@ let UserController = class UserController extends BaseController {
77
84
  * @response 401 Unauthorized — valid session required
78
85
  * @response 403 Forbidden — insufficient permissions
79
86
  */
80
- async newPassword(user, pwd) {
87
+ async newPassword(user, pwd, session) {
81
88
  if (pwd.Password !== pwd.ConfirmPassword) {
82
89
  throw new InvalidArgument('password does not match');
83
90
  }
84
- return new Ok(_chain(user, _either(passwordMatch(pwd.OldPassword), changePassword(pwd.Password), () => {
91
+ await _chain(user, _either(passwordMatch(pwd.OldPassword), changePassword(pwd.Password), () => {
85
92
  throw new InvalidArgument('Old password is incorrect');
86
- })));
93
+ }));
94
+ // `changePassword` destroys every session of this user — anyone who got in
95
+ // with the old password is out, which is the whole point. That includes the
96
+ // caller's own session, so it is replaced here with a brand new one ( a new
97
+ // id, not the old one revived ) and the client is handed the new cookie.
98
+ const replacement = new UserSession();
99
+ replacement.UserId = user.Id;
100
+ if (session) {
101
+ for (const [key, value] of session.Data) {
102
+ replacement.Data.set(key, value);
103
+ }
104
+ }
105
+ else {
106
+ replacement.Data.set('User', user.Uuid);
107
+ replacement.Data.set('Logged', true);
108
+ replacement.Data.set('Authorized', true);
109
+ replacement.Data.set('ActiveRole', user.Role?.[0]);
110
+ }
111
+ await this.SessionProvider.save(replacement);
112
+ return new Ok(null, {
113
+ Coockies: [this.SessionCookies.issue(replacement)],
114
+ Headers: [{ Name: 'Cache-Control', Value: 'no-store' }],
115
+ });
87
116
  }
88
117
  };
89
118
  __decorate([
90
119
  Autoinject(),
91
120
  __metadata("design:type", PasswordProvider)
92
121
  ], UserController.prototype, "PasswordProvider", void 0);
93
- __decorate([
94
- Config('http.cookie.secret'),
95
- __metadata("design:type", String)
96
- ], UserController.prototype, "CoockieSecret", void 0);
97
122
  __decorate([
98
123
  Autoinject(),
99
124
  __metadata("design:type", SessionProvider)
@@ -102,11 +127,15 @@ __decorate([
102
127
  Autoinject(AccessControl),
103
128
  __metadata("design:type", AccessControl)
104
129
  ], UserController.prototype, "AC", void 0);
130
+ __decorate([
131
+ Autoinject(SessionCookieFactory),
132
+ __metadata("design:type", SessionCookieFactory)
133
+ ], UserController.prototype, "SessionCookies", void 0);
105
134
  __decorate([
106
135
  Get(),
107
136
  Permission(['readOwn']),
108
137
  __param(0, User()),
109
- __param(1, Cookie()),
138
+ __param(1, SessionIdArg()),
110
139
  __metadata("design:type", Function),
111
140
  __metadata("design:paramtypes", [UserModel, String]),
112
141
  __metadata("design:returntype", Promise)
@@ -115,8 +144,9 @@ __decorate([
115
144
  Get("grants"),
116
145
  Permission(['readOwn']),
117
146
  __param(0, User()),
147
+ __param(1, SessionRouteArg()),
118
148
  __metadata("design:type", Function),
119
- __metadata("design:paramtypes", [UserModel]),
149
+ __metadata("design:paramtypes", [UserModel, Object]),
120
150
  __metadata("design:returntype", Promise)
121
151
  ], UserController.prototype, "getGrants", null);
122
152
  __decorate([
@@ -124,8 +154,9 @@ __decorate([
124
154
  Permission(["updateOwn"]),
125
155
  __param(0, User()),
126
156
  __param(1, Body()),
157
+ __param(2, SessionRouteArg()),
127
158
  __metadata("design:type", Function),
128
- __metadata("design:paramtypes", [UserModel, PasswordDto]),
159
+ __metadata("design:paramtypes", [UserModel, PasswordDto, Object]),
129
160
  __metadata("design:returntype", Promise)
130
161
  ], UserController.prototype, "newPassword", null);
131
162
  UserController = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"UserController.js","sourceRoot":"","sources":["../../../src/controllers/UserController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAClJ,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAc,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIhD;;;;;GAKG;AAII,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,cAAc;IAahD;;;;;;;;OAQG;IAGU,AAAN,KAAK,CAAC,OAAO,CAAS,IAAe,EAAY,IAAY;QAClE,wBAAwB;QACxB,MAAM,IAAI,CAAC,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IAAI,EAAE,CAAA;IAAmB,WAAA,eAAe,EAAE,CAAA;;qCAA7B,SAAS;;+CAM7C;AAcY;IAFZ,KAAK,CAAC,UAAU,CAAC;IACjB,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACA,WAAA,IAAI,EAAE,CAAA;IAAmB,WAAA,IAAI,EAAE,CAAA;IAAoB,WAAA,eAAe,EAAE,CAAA;;qCAAvD,SAAS,EAAe,WAAW;;iDAuCzE;AAzHU,cAAc;IAH1B,QAAQ,CAAC,MAAM,CAAC;IAChB,QAAQ,CAAC,MAAM,CAAC;IAChB,MAAM,CAAC,gBAAgB,CAAC;GACZ,cAAc,CA0H1B"}
@@ -3,14 +3,20 @@ import { User as UserModel, UserMetadata } from '@spinajs/rbac';
3
3
  import { PaginationDTO, OrderDTO, IFilterRequest } from '@spinajs/orm-http';
4
4
  import { UserMetadataDto } from '../dto/metadata-dto.js';
5
5
  import { FilterableUserMetadata } from '../models/FilterableUserMetadata.js';
6
+ import { UserMetadataService } from '../services/UserMetadataService.js';
6
7
  /**
7
8
  * User metadata management.
8
9
  * Provides CRUD operations for key-value metadata entries attached to user accounts.
9
10
  * Admin routes operate on any user (identified by UUID), while own routes operate on the
10
11
  * currently authenticated user's metadata.
12
+ *
13
+ * Both families delegate to {@link UserMetadataService}, which owns the owner
14
+ * scoping — the only thing that ever differed between them is where the owner
15
+ * id comes from.
11
16
  * @tags User Metadata
12
17
  */
13
18
  export declare class UserMetadataController extends BaseController {
19
+ protected Metadata: UserMetadataService;
14
20
  /**
15
21
  * List metadata for a specific user (admin)
16
22
  * Returns a paginated, filtered, and ordered list of metadata entries for the given user.
@@ -74,18 +80,6 @@ export declare class UserMetadataController extends BaseController {
74
80
  * @response 404 User or metadata entry not found
75
81
  */
76
82
  deleteUserMetadata(user: UserModel, meta: number): Promise<Ok<any>>;
77
- /**
78
- * List own metadata
79
- * Returns a paginated, filtered, and ordered list of metadata entries for the authenticated user.
80
- * @security cookieAuth
81
- * @param pagination.page Page number (zero-based)
82
- * @param pagination.limit Number of entries per page
83
- * @param order.column Column to sort by (default: Id)
84
- * @param order.order Sort direction: ASC or DESC (default: DESC)
85
- * @returns {IUserMetadataEntry[]} Paginated list of own metadata entries
86
- * @response 401 Unauthorized — valid session required
87
- * @response 403 Forbidden — readOwn permission required
88
- */
89
83
  /**
90
84
  * List own metadata
91
85
  * Returns a paginated, filtered, and ordered list of metadata entries for the authenticated user.
@@ -1 +1 @@
1
- {"version":3,"file":"UserMetadataController.d.ts","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,EAAE,EAAwC,cAAc,EAAS,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAW,aAAa,EAAE,QAAQ,EAAU,cAAc,EAAa,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAS7E;;;;;;GAMG;AACH,qBAGa,sBAAuB,SAAQ,cAAc;IAEtD;;;;;;;;;;;;;OAaG;IAGU,YAAY,CACc,IAAI,EAAE,SAAS,EACzC,UAAU,CAAC,EAAE,aAAa,EAC1B,KAAK,CAAC,EAAE,QAAQ,EAEzB,MAAM,CAAC,EAAE,cAAc;IAc3B;;;;;;;;;;OAUG;IAGU,WAAW,CACe,IAAI,EAAE,SAAS,EACzC,GAAG,EAAE,MAAM;IAOxB;;;;;;;;;OASG;IAGU,eAAe,CACW,IAAI,EAAE,SAAS,EACvC,QAAQ,EAAE,YAAY;IAOrC;;;;;;;;;;;OAWG;IAGU,kBAAkB,CAOxB,IAAI,EAAE,YAAY,EACc,KAAK,EAAE,SAAS,EAC3C,IAAI,EAAE,eAAe;IAUjC;;;;;;;;;;OAUG;IAGU,kBAAkB,CACQ,IAAI,EAAE,SAAS,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AAC,EAAE,QAAQ,EAEzB,MAAM,CAAC,EAAE,cAAc;IAM3B;;;;;;;;;;OAUG;IAGU,WAAW,CACe,IAAI,EAAE,SAAS,EACzC,GAAG,EAAE,MAAM;IAIxB;;;;;;;;;OASG;IAGU,eAAe,CACW,IAAI,EAAE,SAAS,EACvC,QAAQ,EAAE,YAAY;IAMrC;;;;;;;;;;;OAWG;IAGU,kBAAkB,CAOxB,IAAI,EAAE,YAAY,EACc,KAAK,EAAE,SAAS,EAC3C,IAAI,EAAE,eAAe;IAUjC;;;;;;;;;;OAUG;IAGU,kBAAkB,CACQ,IAAI,EAAE,SAAS,EACzC,IAAI,EAAE,MAAM;IAMzB;;;;;;;;;;;OAWG;IAGU,QAAQ,CACT,IAAI,EAAE,SAAS,EACd,UAAU,CAAC,EAAE,aAAa,EAC1B,KAAK,CAAC,EAAE,QAAQ,EAEzB,MAAM,CAAC,EAAE,cAAc;IAK3B;;;;;;;;;OASG;IAGU,OAAO,CAAS,IAAI,EAAE,SAAS,EAAW,GAAG,EAAE,MAAM;IAIlE;;;;;;;OAOG;IAGU,WAAW,CAAS,IAAI,EAAE,SAAS,EAAa,QAAQ,EAAE,YAAY;IAKnF;;;;;;;;;;OAUG;IAGU,cAAc,CAAS,IAAI,EAAE,SAAS,EAAW,IAAI,EAAE,MAAM,EAAU,IAAI,EAAE,eAAe;IAMzG;;;;;;;;;OASG;IAGU,cAAc,CAAS,IAAI,EAAE,SAAS,EAAW,IAAI,EAAE,MAAM;CAK7E"}
@@ -12,22 +12,21 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  };
13
13
  import { Post, BasePath, Ok, Del, Body, Get, Query, Param, Policy, BaseController, Patch } from '@spinajs/http';
14
14
  import { User as UserModel, UserMetadata } from '@spinajs/rbac';
15
+ import { Autoinject } from '@spinajs/di';
15
16
  import { AuthorizedPolicy, Permission, Resource, User } from '@spinajs/rbac-http';
16
17
  import { AsModel, PaginationDTO, OrderDTO, Filter, FromModel } from '@spinajs/orm-http';
17
18
  import { UserMetadataDto } from '../dto/metadata-dto.js';
18
- import { InsertBehaviour, SortOrder } from '@spinajs/orm';
19
19
  import { FilterableUserMetadata } from '../models/FilterableUserMetadata.js';
20
- /**
21
- * Fallback page size. A request without a `limit` used to reach `take(0)`,
22
- * which the query builder rejects ( "take count should be a positive number" ),
23
- * so plain listing requests failed instead of returning the first page.
24
- */
25
- const DEFAULT_PAGE_SIZE = 10;
20
+ import { UserMetadataService } from '../services/UserMetadataService.js';
26
21
  /**
27
22
  * User metadata management.
28
23
  * Provides CRUD operations for key-value metadata entries attached to user accounts.
29
24
  * Admin routes operate on any user (identified by UUID), while own routes operate on the
30
25
  * currently authenticated user's metadata.
26
+ *
27
+ * Both families delegate to {@link UserMetadataService}, which owns the owner
28
+ * scoping — the only thing that ever differed between them is where the owner
29
+ * id comes from.
31
30
  * @tags User Metadata
32
31
  */
33
32
  let UserMetadataController = class UserMetadataController extends BaseController {
@@ -46,13 +45,7 @@ let UserMetadataController = class UserMetadataController extends BaseController
46
45
  * @response 404 User not found
47
46
  */
48
47
  async readUserMeta(user, pagination, order, filter) {
49
- const limit = pagination?.limit || DEFAULT_PAGE_SIZE;
50
- return new Ok(FilterableUserMetadata.select().where({
51
- user_id: user.Id
52
- }).filter(filter?.filters ?? [], filter?.op)
53
- .take(limit)
54
- .skip(limit * (pagination?.page ?? 0))
55
- .order(order?.column ?? 'Id', order?.order ?? SortOrder.DESC));
48
+ return new Ok(this.Metadata.list(user.Id, pagination, order, filter));
56
49
  }
57
50
  /**
58
51
  * Get a single metadata entry for a specific user (admin)
@@ -66,10 +59,7 @@ let UserMetadataController = class UserMetadataController extends BaseController
66
59
  * @response 404 User or metadata key not found
67
60
  */
68
61
  async getUserMeta(user, key) {
69
- return new Ok(UserMetadata.where({
70
- Key: key,
71
- user_id: user.Id
72
- }).firstOrFail());
62
+ return new Ok(this.Metadata.getByKey(user.Id, key));
73
63
  }
74
64
  /**
75
65
  * Add or update metadata for a specific user (admin)
@@ -82,8 +72,7 @@ let UserMetadataController = class UserMetadataController extends BaseController
82
72
  * @response 404 User not found
83
73
  */
84
74
  async addUserMetadata(user, metadata) {
85
- metadata.User.attach(user);
86
- await metadata.insert(InsertBehaviour.InsertOrUpdate);
75
+ await this.Metadata.upsert(user.Id, metadata);
87
76
  return new Ok();
88
77
  }
89
78
  /**
@@ -99,11 +88,10 @@ let UserMetadataController = class UserMetadataController extends BaseController
99
88
  * @response 404 User or metadata entry not found
100
89
  */
101
90
  async updateUserMetadata(meta, _user, data) {
102
- await meta.update({
103
- Key: data.Key,
104
- Value: data.Value,
105
- Type: data.Type
106
- });
91
+ // @FromModel already resolved the entry within the addressed user's
92
+ // scope ( so a miss is a 404 ); the write still goes through the
93
+ // owner-scoped service so the predicate is not restated here.
94
+ await this.Metadata.update(_user.Id, meta.Id, data);
107
95
  return new Ok();
108
96
  }
109
97
  /**
@@ -118,24 +106,9 @@ let UserMetadataController = class UserMetadataController extends BaseController
118
106
  * @response 404 User or metadata entry not found
119
107
  */
120
108
  async deleteUserMetadata(user, meta) {
121
- // NOTE: destroy() refuses to build an unbounded DELETE, so the entry id
122
- // goes in as the primary key and ownership is AND-ed on top of it —
123
- // deleting by id alone would let any user id delete anybody's entry.
124
- await UserMetadata.destroy(meta).andWhere('user_id', user.Id);
109
+ await this.Metadata.delete(user.Id, meta);
125
110
  return new Ok();
126
111
  }
127
- /**
128
- * List own metadata
129
- * Returns a paginated, filtered, and ordered list of metadata entries for the authenticated user.
130
- * @security cookieAuth
131
- * @param pagination.page Page number (zero-based)
132
- * @param pagination.limit Number of entries per page
133
- * @param order.column Column to sort by (default: Id)
134
- * @param order.order Sort direction: ASC or DESC (default: DESC)
135
- * @returns {IUserMetadataEntry[]} Paginated list of own metadata entries
136
- * @response 401 Unauthorized — valid session required
137
- * @response 403 Forbidden — readOwn permission required
138
- */
139
112
  /**
140
113
  * List own metadata
141
114
  * Returns a paginated, filtered, and ordered list of metadata entries for the authenticated user.
@@ -149,15 +122,7 @@ let UserMetadataController = class UserMetadataController extends BaseController
149
122
  * @response 403 Forbidden — readOwn permission required
150
123
  */
151
124
  async readMeta(user, pagination, order, filter) {
152
- // Explicit owner scoping: the rbac query middleware does not enforce
153
- // ownership for the metadata model (queries resolve to the unsafe base
154
- // model without an @OrmResource), so every own-route filters by the
155
- // authenticated user's id directly.
156
- const limit = pagination?.limit || DEFAULT_PAGE_SIZE;
157
- return new Ok(FilterableUserMetadata.select().where('user_id', user.Id).filter(filter?.filters ?? [], filter?.op)
158
- .take(limit)
159
- .skip(limit * (pagination?.page ?? 0))
160
- .order(order?.column ?? 'Id', order?.order ?? SortOrder.DESC));
125
+ return new Ok(this.Metadata.list(user.Id, pagination, order, filter));
161
126
  }
162
127
  /**
163
128
  * Get own metadata entry by key
@@ -170,10 +135,7 @@ let UserMetadataController = class UserMetadataController extends BaseController
170
135
  * @response 404 Metadata key not found
171
136
  */
172
137
  async getMeta(user, key) {
173
- return new Ok(UserMetadata.where({
174
- Key: key,
175
- user_id: user.Id,
176
- }).firstOrFail());
138
+ return new Ok(this.Metadata.getByKey(user.Id, key));
177
139
  }
178
140
  /**
179
141
  * Add or update own metadata
@@ -184,10 +146,7 @@ let UserMetadataController = class UserMetadataController extends BaseController
184
146
  * @response 403 Forbidden — updateOwn permission required
185
147
  */
186
148
  async addMetadata(user, metadata) {
187
- // force ownership to the authenticated user — never trust a user_id
188
- // supplied in the request body
189
- metadata.user_id = user.Id;
190
- await metadata.insert(InsertBehaviour.InsertOrUpdate);
149
+ await this.Metadata.upsert(user.Id, metadata);
191
150
  return new Ok();
192
151
  }
193
152
  /**
@@ -202,19 +161,7 @@ let UserMetadataController = class UserMetadataController extends BaseController
202
161
  * @response 404 Metadata entry not found
203
162
  */
204
163
  async updateMetadata(user, meta, data) {
205
- // The Key/Id lookup is grouped and AND-ed with an explicit ownership
206
- // filter. Without the grouping the flat "Key = ? OR Id = ? AND user_id = ?"
207
- // binds as "Key = ? OR (Id = ? AND user_id = ?)", letting any user update
208
- // another user's metadata by its Key. Scoping by user_id explicitly (not
209
- // relying on the query middleware, which does not fire for this model)
210
- // keeps the update owner-bound.
211
- await UserMetadata.update({
212
- Key: data.Key,
213
- Value: data.Value,
214
- Type: data.Type
215
- }).where(function () {
216
- this.where("Key", meta).orWhere("Id", meta);
217
- }).andWhere('user_id', user.Id);
164
+ await this.Metadata.update(user.Id, meta, data);
218
165
  return new Ok();
219
166
  }
220
167
  /**
@@ -228,10 +175,14 @@ let UserMetadataController = class UserMetadataController extends BaseController
228
175
  * @response 404 Metadata entry not found
229
176
  */
230
177
  async deleteMetadata(user, meta) {
231
- await UserMetadata.destroy(meta).andWhere('user_id', user.Id);
178
+ await this.Metadata.delete(user.Id, meta);
232
179
  return new Ok();
233
180
  }
234
181
  };
182
+ __decorate([
183
+ Autoinject(UserMetadataService),
184
+ __metadata("design:type", UserMetadataService)
185
+ ], UserMetadataController.prototype, "Metadata", void 0);
235
186
  __decorate([
236
187
  Get(":user/metadata"),
237
188
  Permission(['readAny']),
@@ -1 +1 @@
1
- {"version":3,"file":"UserMetadataController.js","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAkB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO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,CAAC,MAAM,CAAC;IAChB,QAAQ,CAAC,eAAe,CAAC;IACzB,MAAM,CAAC,gBAAgB,CAAC;GACZ,sBAAsB,CAwNlC"}
@@ -0,0 +1,23 @@
1
+ export declare const ConfirmPasswordDtoSchema: {
2
+ $schema: string;
3
+ title: string;
4
+ type: string;
5
+ properties: {
6
+ Password: {
7
+ type: string;
8
+ maxLength: number;
9
+ description: string;
10
+ };
11
+ };
12
+ required: string[];
13
+ };
14
+ /**
15
+ * Re-authentication payload for sensitive self-service operations — enabling or
16
+ * disabling 2FA. A hijacked session alone must not be enough to weaken a
17
+ * user's second factor.
18
+ */
19
+ export declare class ConfirmPasswordDto {
20
+ Password: string;
21
+ constructor(data: any);
22
+ }
23
+ //# sourceMappingURL=confirm-password-dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm-password-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/confirm-password-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB;;;;;;;;;;;;CAQpC,CAAC;AAEF;;;;GAIG;AACH,qBACa,kBAAkB;IACtB,QAAQ,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,GAAG;CAGtB"}
@@ -8,23 +8,28 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  import { Schema } from '@spinajs/validation';
11
- export const UserDtoSchema = {
11
+ export const ConfirmPasswordDtoSchema = {
12
12
  $schema: 'http://json-schema.org/draft-07/schema#',
13
- title: 'User DTO',
13
+ title: 'Confirm password DTO',
14
14
  type: 'object',
15
15
  properties: {
16
- Email: { type: 'string', format: 'email', maxLength: 64 },
17
- Login: { type: 'string', maxLength: 64 },
16
+ Password: { type: 'string', maxLength: 32, description: 'Current password, re-entered to confirm a sensitive change' },
18
17
  },
18
+ required: ['Password'],
19
19
  };
20
- let UserDto = class UserDto {
20
+ /**
21
+ * Re-authentication payload for sensitive self-service operations — enabling or
22
+ * disabling 2FA. A hijacked session alone must not be enough to weaken a
23
+ * user's second factor.
24
+ */
25
+ let ConfirmPasswordDto = class ConfirmPasswordDto {
21
26
  constructor(data) {
22
27
  Object.assign(this, data);
23
28
  }
24
29
  };
25
- UserDto = __decorate([
26
- Schema(UserDtoSchema),
30
+ ConfirmPasswordDto = __decorate([
31
+ Schema(ConfirmPasswordDtoSchema),
27
32
  __metadata("design:paramtypes", [Object])
28
- ], UserDto);
29
- export { UserDto };
30
- //# sourceMappingURL=user-dto.js.map
33
+ ], ConfirmPasswordDto);
34
+ export { ConfirmPasswordDto };
35
+ //# sourceMappingURL=confirm-password-dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm-password-dto.js","sourceRoot":"","sources":["../../../src/dto/confirm-password-dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,4DAA4D,EAAE;KACvH;IACD,QAAQ,EAAE,CAAC,UAAU,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAG7B,YAAY,IAAS;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AANY,kBAAkB;IAD9B,MAAM,CAAC,wBAAwB,CAAC;;GACpB,kBAAkB,CAM9B"}
@@ -0,0 +1,58 @@
1
+ export declare const PasswordResetRequestDtoSchema: {
2
+ $schema: string;
3
+ title: string;
4
+ type: string;
5
+ properties: {
6
+ Email: {
7
+ type: string;
8
+ format: string;
9
+ description: string;
10
+ };
11
+ };
12
+ required: string[];
13
+ };
14
+ /** Payload starting a password reset — identifies the account by email. */
15
+ export declare class PasswordResetRequestDto {
16
+ Email: string;
17
+ constructor(data: any);
18
+ }
19
+ export declare const PasswordResetConfirmDtoSchema: {
20
+ $schema: string;
21
+ title: string;
22
+ type: string;
23
+ properties: {
24
+ Email: {
25
+ type: string;
26
+ format: string;
27
+ description: string;
28
+ };
29
+ Token: {
30
+ type: string;
31
+ maxLength: number;
32
+ minLength: number;
33
+ description: string;
34
+ };
35
+ Password: {
36
+ type: string;
37
+ maxLength: number;
38
+ minLength: number;
39
+ description: string;
40
+ };
41
+ ConfirmPassword: {
42
+ type: string;
43
+ maxLength: number;
44
+ minLength: number;
45
+ description: string;
46
+ };
47
+ };
48
+ required: string[];
49
+ };
50
+ /** Payload completing a password reset with the issued token. */
51
+ export declare class PasswordResetConfirmDto {
52
+ Email: string;
53
+ Token: string;
54
+ Password: string;
55
+ ConfirmPassword: string;
56
+ constructor(data: any);
57
+ }
58
+ //# sourceMappingURL=password-reset-dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-reset-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/password-reset-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,6BAA6B;;;;;;;;;;;;CAQzC,CAAC;AAEF,2EAA2E;AAC3E,qBACa,uBAAuB;IAC3B,KAAK,EAAE,MAAM,CAAC;gBAET,IAAI,EAAE,GAAG;CAGtB;AAED,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWzC,CAAC;AAEF,iEAAiE;AACjE,qBACa,uBAAuB;IAC3B,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,EAAE,MAAM,CAAC;IAEd,QAAQ,EAAE,MAAM,CAAC;IAEjB,eAAe,EAAE,MAAM,CAAC;gBAEnB,IAAI,EAAE,GAAG;CAGtB"}
@@ -0,0 +1,54 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Schema } from '@spinajs/validation';
11
+ export const PasswordResetRequestDtoSchema = {
12
+ $schema: 'http://json-schema.org/draft-07/schema#',
13
+ title: 'Password reset request DTO',
14
+ type: 'object',
15
+ properties: {
16
+ Email: { type: 'string', format: 'email', description: 'Email address of the account to reset' },
17
+ },
18
+ required: ['Email'],
19
+ };
20
+ /** Payload starting a password reset — identifies the account by email. */
21
+ let PasswordResetRequestDto = class PasswordResetRequestDto {
22
+ constructor(data) {
23
+ Object.assign(this, data);
24
+ }
25
+ };
26
+ PasswordResetRequestDto = __decorate([
27
+ Schema(PasswordResetRequestDtoSchema),
28
+ __metadata("design:paramtypes", [Object])
29
+ ], PasswordResetRequestDto);
30
+ export { PasswordResetRequestDto };
31
+ export const PasswordResetConfirmDtoSchema = {
32
+ $schema: 'http://json-schema.org/draft-07/schema#',
33
+ title: 'Password reset confirmation DTO',
34
+ type: 'object',
35
+ properties: {
36
+ Email: { type: 'string', format: 'email', description: 'Email address the reset token was issued for' },
37
+ Token: { type: 'string', maxLength: 64, minLength: 1, description: 'Reset token delivered to the user' },
38
+ Password: { type: 'string', maxLength: 32, minLength: 6, description: 'New password (6–32 characters)' },
39
+ ConfirmPassword: { type: 'string', maxLength: 32, minLength: 6, description: 'Must match Password' },
40
+ },
41
+ required: ['Email', 'Token', 'Password', 'ConfirmPassword'],
42
+ };
43
+ /** Payload completing a password reset with the issued token. */
44
+ let PasswordResetConfirmDto = class PasswordResetConfirmDto {
45
+ constructor(data) {
46
+ Object.assign(this, data);
47
+ }
48
+ };
49
+ PasswordResetConfirmDto = __decorate([
50
+ Schema(PasswordResetConfirmDtoSchema),
51
+ __metadata("design:paramtypes", [Object])
52
+ ], PasswordResetConfirmDto);
53
+ export { PasswordResetConfirmDto };
54
+ //# sourceMappingURL=password-reset-dto.js.map