@nest-boot/auth 8.0.9-beta.0 → 8.0.9-beta.2

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 (347) hide show
  1. package/README.md +74 -34
  2. package/dist/adapters/mikro-orm/adapter-config.d.ts +5 -0
  3. package/dist/adapters/mikro-orm/adapter-config.js +5 -0
  4. package/dist/adapters/mikro-orm/adapter-config.js.map +1 -1
  5. package/dist/adapters/mikro-orm/create-custom-adapter.d.ts +9 -0
  6. package/dist/adapters/mikro-orm/create-custom-adapter.js +9 -0
  7. package/dist/adapters/mikro-orm/create-custom-adapter.js.map +1 -1
  8. package/dist/adapters/mikro-orm/entity-metadata-resolver.d.ts +7 -0
  9. package/dist/adapters/mikro-orm/entity-metadata-resolver.js +7 -0
  10. package/dist/adapters/mikro-orm/entity-metadata-resolver.js.map +1 -1
  11. package/dist/adapters/mikro-orm/where-compiler.d.ts +7 -0
  12. package/dist/adapters/mikro-orm/where-compiler.js +11 -0
  13. package/dist/adapters/mikro-orm/where-compiler.js.map +1 -1
  14. package/dist/api-key-usage.interceptor.d.ts +10 -2
  15. package/dist/api-key-usage.interceptor.js +10 -2
  16. package/dist/api-key-usage.interceptor.js.map +1 -1
  17. package/dist/auth-handler.middleware.d.ts +14 -3
  18. package/dist/auth-handler.middleware.js +14 -3
  19. package/dist/auth-handler.middleware.js.map +1 -1
  20. package/dist/auth.ability.d.ts +11 -2
  21. package/dist/auth.ability.js +11 -2
  22. package/dist/auth.ability.js.map +1 -1
  23. package/dist/auth.constants.d.ts +4 -1
  24. package/dist/auth.constants.js +4 -1
  25. package/dist/auth.constants.js.map +1 -1
  26. package/dist/auth.guard.d.ts +0 -4
  27. package/dist/auth.guard.js +0 -4
  28. package/dist/auth.guard.js.map +1 -1
  29. package/dist/auth.middleware.d.ts +24 -8
  30. package/dist/auth.middleware.js +41 -25
  31. package/dist/auth.middleware.js.map +1 -1
  32. package/dist/auth.module.d.ts +0 -1
  33. package/dist/auth.module.js +5 -6
  34. package/dist/auth.module.js.map +1 -1
  35. package/dist/connections/index.d.ts +1 -1
  36. package/dist/connections/index.js +1 -1
  37. package/dist/connections/index.js.map +1 -1
  38. package/dist/connections/member-api-key.connection-definition.d.ts +13 -0
  39. package/dist/connections/{workspace-api-key.connection-definition.js → member-api-key.connection-definition.js} +11 -11
  40. package/dist/connections/member-api-key.connection-definition.js.map +1 -0
  41. package/dist/connections/member.connection-definition.js +1 -0
  42. package/dist/connections/member.connection-definition.js.map +1 -1
  43. package/dist/decorators/can.decorator.d.ts +6 -1
  44. package/dist/decorators/can.decorator.js +6 -1
  45. package/dist/decorators/can.decorator.js.map +1 -1
  46. package/dist/decorators/public.decorator.d.ts +5 -1
  47. package/dist/decorators/public.decorator.js +5 -1
  48. package/dist/decorators/public.decorator.js.map +1 -1
  49. package/dist/entities/account.entity.d.ts +4 -1
  50. package/dist/entities/account.entity.js +4 -1
  51. package/dist/entities/account.entity.js.map +1 -1
  52. package/dist/entities/auth-entity-map.d.ts +2 -2
  53. package/dist/entities/auth-entity-map.js +2 -2
  54. package/dist/entities/auth-entity-map.js.map +1 -1
  55. package/dist/entities/index.d.ts +3 -3
  56. package/dist/entities/index.js +3 -3
  57. package/dist/entities/index.js.map +1 -1
  58. package/dist/entities/invitation.entity.d.ts +4 -1
  59. package/dist/entities/invitation.entity.js +4 -1
  60. package/dist/entities/invitation.entity.js.map +1 -1
  61. package/dist/entities/{workspace-api-key.entity.d.ts → member-api-key.entity.d.ts} +14 -6
  62. package/dist/entities/{workspace-api-key.entity.js → member-api-key.entity.js} +44 -29
  63. package/dist/entities/member-api-key.entity.js.map +1 -0
  64. package/dist/entities/member.entity.d.ts +10 -3
  65. package/dist/entities/member.entity.js +19 -3
  66. package/dist/entities/member.entity.js.map +1 -1
  67. package/dist/enums/index.d.ts +2 -1
  68. package/dist/enums/index.js +2 -1
  69. package/dist/enums/index.js.map +1 -1
  70. package/dist/enums/{workspace-api-key-permission.enum.d.ts → member-api-key-permission.enum.d.ts} +2 -2
  71. package/dist/enums/{workspace-api-key-permission.enum.js → member-api-key-permission.enum.js} +4 -4
  72. package/dist/enums/member-api-key-permission.enum.js.map +1 -0
  73. package/dist/enums/member-type.enum.d.ts +7 -0
  74. package/dist/enums/member-type.enum.js +11 -0
  75. package/dist/enums/member-type.enum.js.map +1 -0
  76. package/dist/features/invitations/invitation.resolver.d.ts +43 -8
  77. package/dist/features/invitations/invitation.resolver.js +43 -8
  78. package/dist/features/invitations/invitation.resolver.js.map +1 -1
  79. package/dist/features/invitations/invitation.service.d.ts +75 -12
  80. package/dist/features/invitations/invitation.service.js +75 -12
  81. package/dist/features/invitations/invitation.service.js.map +1 -1
  82. package/dist/index.d.ts +8 -7
  83. package/dist/index.js +8 -7
  84. package/dist/index.js.map +1 -1
  85. package/dist/infrastructure/api-key-authentication.service.d.ts +20 -4
  86. package/dist/infrastructure/api-key-authentication.service.js +45 -12
  87. package/dist/infrastructure/api-key-authentication.service.js.map +1 -1
  88. package/dist/infrastructure/api-key-lifecycle.d.ts +31 -5
  89. package/dist/infrastructure/api-key-lifecycle.js +31 -5
  90. package/dist/infrastructure/api-key-lifecycle.js.map +1 -1
  91. package/dist/infrastructure/auth-ability.factory.d.ts +14 -3
  92. package/dist/infrastructure/auth-ability.factory.js +31 -5
  93. package/dist/infrastructure/auth-ability.factory.js.map +1 -1
  94. package/dist/infrastructure/auth-enum-registry.d.ts +4 -1
  95. package/dist/infrastructure/auth-enum-registry.js +7 -4
  96. package/dist/infrastructure/auth-enum-registry.js.map +1 -1
  97. package/dist/infrastructure/auth-service.providers.d.ts +4 -1
  98. package/dist/infrastructure/auth-service.providers.js +4 -1
  99. package/dist/infrastructure/auth-service.providers.js.map +1 -1
  100. package/dist/infrastructure/better-auth-adapter.d.ts +6 -1
  101. package/dist/infrastructure/better-auth-adapter.js +2 -0
  102. package/dist/infrastructure/better-auth-adapter.js.map +1 -1
  103. package/dist/infrastructure/create-auth-instance.d.ts +20 -2
  104. package/dist/infrastructure/create-auth-instance.js +31 -4
  105. package/dist/infrastructure/create-auth-instance.js.map +1 -1
  106. package/dist/infrastructure/create-contextual-auth-service.d.ts +4 -0
  107. package/dist/infrastructure/create-contextual-auth-service.js +4 -0
  108. package/dist/infrastructure/create-contextual-auth-service.js.map +1 -1
  109. package/dist/infrastructure/request-identity.d.ts +89 -18
  110. package/dist/infrastructure/request-identity.js +113 -28
  111. package/dist/infrastructure/request-identity.js.map +1 -1
  112. package/dist/infrastructure/revoked-authentication.exception.d.ts +4 -1
  113. package/dist/infrastructure/revoked-authentication.exception.js +4 -1
  114. package/dist/infrastructure/revoked-authentication.exception.js.map +1 -1
  115. package/dist/inputs/add-member.input.d.ts +13 -2
  116. package/dist/inputs/add-member.input.js +34 -3
  117. package/dist/inputs/add-member.input.js.map +1 -1
  118. package/dist/inputs/{create-workspace-api-key.input.d.ts → create-member-api-key.input.d.ts} +6 -4
  119. package/dist/inputs/{create-workspace-api-key.input.js → create-member-api-key.input.js} +20 -13
  120. package/dist/inputs/create-member-api-key.input.js.map +1 -0
  121. package/dist/inputs/create-user-api-key.input.d.ts +1 -1
  122. package/dist/inputs/create-user-api-key.input.js +1 -1
  123. package/dist/inputs/create-user-api-key.input.js.map +1 -1
  124. package/dist/inputs/{update-workspace-api-key.input.d.ts → update-member-api-key.input.d.ts} +3 -3
  125. package/dist/inputs/{update-workspace-api-key.input.js → update-member-api-key.input.js} +11 -11
  126. package/dist/inputs/update-member-api-key.input.js.map +1 -0
  127. package/dist/interfaces/ability-context.interface.d.ts +3 -3
  128. package/dist/interfaces/add-member-options.interface.d.ts +1 -1
  129. package/dist/interfaces/auth-module-api-key-options.interface.d.ts +2 -2
  130. package/dist/interfaces/auth-module-api-key-scope-options.interface.d.ts +2 -2
  131. package/dist/interfaces/create-api-key-options.interface.d.ts +1 -1
  132. package/dist/interfaces/create-member-api-key-options.interface.d.ts +7 -0
  133. package/dist/interfaces/create-member-api-key-options.interface.js +2 -0
  134. package/dist/interfaces/create-member-api-key-options.interface.js.map +1 -0
  135. package/dist/interfaces/member-api-key-validation.interface.d.ts +17 -0
  136. package/dist/interfaces/member-api-key-validation.interface.js +2 -0
  137. package/dist/interfaces/member-api-key-validation.interface.js.map +1 -0
  138. package/dist/interfaces/request-identity-patch.interface.d.ts +4 -1
  139. package/dist/interfaces/request-permissions.interface.d.ts +5 -2
  140. package/dist/objects/{create-workspace-api-key-result.object.d.ts → create-member-api-key-result.object.d.ts} +3 -3
  141. package/dist/objects/{create-workspace-api-key-result.object.js → create-member-api-key-result.object.js} +10 -10
  142. package/dist/objects/create-member-api-key-result.object.js.map +1 -0
  143. package/dist/objects/member-api-key-permission-option.object.d.ts +10 -0
  144. package/dist/objects/{workspace-api-key-permission-option.object.js → member-api-key-permission-option.object.js} +12 -12
  145. package/dist/objects/member-api-key-permission-option.object.js.map +1 -0
  146. package/dist/policies/create-scope-policy.d.ts +7 -1
  147. package/dist/policies/create-scope-policy.js +7 -1
  148. package/dist/policies/create-scope-policy.js.map +1 -1
  149. package/dist/policies/user-scope.policy.d.ts +2 -0
  150. package/dist/policies/user-scope.policy.js +2 -0
  151. package/dist/policies/user-scope.policy.js.map +1 -1
  152. package/dist/policies/workspace-scope.policy.d.ts +2 -0
  153. package/dist/policies/workspace-scope.policy.js +2 -0
  154. package/dist/policies/workspace-scope.policy.js.map +1 -1
  155. package/dist/resolvers/auth.resolver.d.ts +85 -18
  156. package/dist/resolvers/auth.resolver.js +90 -18
  157. package/dist/resolvers/auth.resolver.js.map +1 -1
  158. package/dist/resolvers/member-api-key.resolver.d.ts +46 -0
  159. package/dist/resolvers/member-api-key.resolver.js +109 -0
  160. package/dist/resolvers/member-api-key.resolver.js.map +1 -0
  161. package/dist/resolvers/member.resolver.d.ts +26 -11
  162. package/dist/resolvers/member.resolver.js +37 -12
  163. package/dist/resolvers/member.resolver.js.map +1 -1
  164. package/dist/resolvers/session.resolver.d.ts +59 -12
  165. package/dist/resolvers/session.resolver.js +59 -12
  166. package/dist/resolvers/session.resolver.js.map +1 -1
  167. package/dist/resolvers/user-api-key.resolver.d.ts +26 -5
  168. package/dist/resolvers/user-api-key.resolver.js +26 -5
  169. package/dist/resolvers/user-api-key.resolver.js.map +1 -1
  170. package/dist/resolvers/user.resolver.d.ts +114 -19
  171. package/dist/resolvers/user.resolver.js +114 -19
  172. package/dist/resolvers/user.resolver.js.map +1 -1
  173. package/dist/resolvers/workspace.resolver.d.ts +39 -17
  174. package/dist/resolvers/workspace.resolver.js +42 -20
  175. package/dist/resolvers/workspace.resolver.js.map +1 -1
  176. package/dist/services/account.service.d.ts +11 -2
  177. package/dist/services/account.service.js +11 -2
  178. package/dist/services/account.service.js.map +1 -1
  179. package/dist/services/auth.service.d.ts +132 -27
  180. package/dist/services/auth.service.js +132 -27
  181. package/dist/services/auth.service.js.map +1 -1
  182. package/dist/services/member-api-key.service.d.ts +76 -0
  183. package/dist/services/{workspace-api-key.service.js → member-api-key.service.js} +117 -54
  184. package/dist/services/member-api-key.service.js.map +1 -0
  185. package/dist/services/member.service.d.ts +111 -20
  186. package/dist/services/member.service.js +153 -35
  187. package/dist/services/member.service.js.map +1 -1
  188. package/dist/services/session.service.d.ts +37 -10
  189. package/dist/services/session.service.js +69 -10
  190. package/dist/services/session.service.js.map +1 -1
  191. package/dist/services/user-api-key.service.d.ts +40 -7
  192. package/dist/services/user-api-key.service.js +43 -8
  193. package/dist/services/user-api-key.service.js.map +1 -1
  194. package/dist/services/user-deletion.service.d.ts +7 -1
  195. package/dist/services/user-deletion.service.js +7 -1
  196. package/dist/services/user-deletion.service.js.map +1 -1
  197. package/dist/services/user.service.d.ts +109 -20
  198. package/dist/services/user.service.js +109 -20
  199. package/dist/services/user.service.js.map +1 -1
  200. package/dist/services/workspace.service.d.ts +50 -11
  201. package/dist/services/workspace.service.js +51 -20
  202. package/dist/services/workspace.service.js.map +1 -1
  203. package/dist/tsconfig.tsbuildinfo +1 -1
  204. package/dist/types/api-key-validation.type.d.ts +2 -2
  205. package/dist/types/api-key.type.d.ts +3 -3
  206. package/dist/types/lowercase-identifier.type.d.ts +4 -1
  207. package/dist/utils/api-key-credential.util.d.ts +12 -2
  208. package/dist/utils/api-key-credential.util.js +12 -2
  209. package/dist/utils/api-key-credential.util.js.map +1 -1
  210. package/dist/utils/api-key-permissions.util.d.ts +16 -4
  211. package/dist/utils/api-key-permissions.util.js +15 -3
  212. package/dist/utils/api-key-permissions.util.js.map +1 -1
  213. package/dist/utils/append-metadata.util.d.ts +6 -1
  214. package/dist/utils/append-metadata.util.js +6 -1
  215. package/dist/utils/append-metadata.util.js.map +1 -1
  216. package/dist/utils/apply-auth-response-cookies.util.d.ts +4 -1
  217. package/dist/utils/apply-auth-response-cookies.util.js +4 -1
  218. package/dist/utils/apply-auth-response-cookies.util.js.map +1 -1
  219. package/dist/utils/auth-role.util.d.ts +50 -8
  220. package/dist/utils/auth-role.util.js +50 -8
  221. package/dist/utils/auth-role.util.js.map +1 -1
  222. package/dist/utils/authorize.util.d.ts +6 -1
  223. package/dist/utils/authorize.util.js +6 -1
  224. package/dist/utils/authorize.util.js.map +1 -1
  225. package/dist/utils/build-request-ability.util.d.ts +5 -1
  226. package/dist/utils/build-request-ability.util.js +11 -17
  227. package/dist/utils/build-request-ability.util.js.map +1 -1
  228. package/dist/utils/can.util.d.ts +7 -1
  229. package/dist/utils/can.util.js +7 -1
  230. package/dist/utils/can.util.js.map +1 -1
  231. package/dist/utils/create-email-and-password-config.d.ts +8 -0
  232. package/dist/utils/create-email-and-password-config.js +8 -0
  233. package/dist/utils/create-email-and-password-config.js.map +1 -1
  234. package/dist/utils/create-email-verification-config.d.ts +6 -1
  235. package/dist/utils/create-email-verification-config.js +6 -1
  236. package/dist/utils/create-email-verification-config.js.map +1 -1
  237. package/dist/utils/create-generic-oauth-config.d.ts +7 -1
  238. package/dist/utils/create-generic-oauth-config.js +7 -1
  239. package/dist/utils/create-generic-oauth-config.js.map +1 -1
  240. package/dist/utils/create-oidc-config.d.ts +5 -0
  241. package/dist/utils/create-oidc-config.js +5 -0
  242. package/dist/utils/create-oidc-config.js.map +1 -1
  243. package/dist/utils/create-permission-enum.util.d.ts +5 -1
  244. package/dist/utils/create-permission-enum.util.js +5 -1
  245. package/dist/utils/create-permission-enum.util.js.map +1 -1
  246. package/dist/utils/create-social-provider-config.d.ts +7 -0
  247. package/dist/utils/create-social-provider-config.js +7 -0
  248. package/dist/utils/create-social-provider-config.js.map +1 -1
  249. package/dist/utils/create-social-providers-config.d.ts +6 -0
  250. package/dist/utils/create-social-providers-config.js +6 -0
  251. package/dist/utils/create-social-providers-config.js.map +1 -1
  252. package/dist/utils/create-user-config.d.ts +7 -1
  253. package/dist/utils/create-user-config.js +7 -1
  254. package/dist/utils/create-user-config.js.map +1 -1
  255. package/dist/utils/estimate-entropy.d.ts +0 -1
  256. package/dist/utils/estimate-entropy.js +0 -1
  257. package/dist/utils/estimate-entropy.js.map +1 -1
  258. package/dist/utils/extend-ability.util.d.ts +9 -1
  259. package/dist/utils/extend-ability.util.js +24 -1
  260. package/dist/utils/extend-ability.util.js.map +1 -1
  261. package/dist/utils/extract-api-key.util.d.ts +5 -1
  262. package/dist/utils/extract-api-key.util.js +5 -1
  263. package/dist/utils/extract-api-key.util.js.map +1 -1
  264. package/dist/utils/get-auth-ability.util.d.ts +1 -0
  265. package/dist/utils/get-auth-ability.util.js +1 -0
  266. package/dist/utils/get-auth-ability.util.js.map +1 -1
  267. package/dist/utils/get-current-api-key.util.d.ts +5 -1
  268. package/dist/utils/get-current-api-key.util.js +5 -1
  269. package/dist/utils/get-current-api-key.util.js.map +1 -1
  270. package/dist/utils/has-oidc-env-config.d.ts +4 -0
  271. package/dist/utils/has-oidc-env-config.js +4 -0
  272. package/dist/utils/has-oidc-env-config.js.map +1 -1
  273. package/dist/utils/has-social-provider-credential-env-config.d.ts +5 -0
  274. package/dist/utils/has-social-provider-credential-env-config.js +5 -0
  275. package/dist/utils/has-social-provider-credential-env-config.js.map +1 -1
  276. package/dist/utils/has-social-provider-env-config.d.ts +5 -0
  277. package/dist/utils/has-social-provider-env-config.js +5 -0
  278. package/dist/utils/has-social-provider-env-config.js.map +1 -1
  279. package/dist/utils/is-env-true.d.ts +5 -0
  280. package/dist/utils/is-env-true.js +5 -0
  281. package/dist/utils/is-env-true.js.map +1 -1
  282. package/dist/utils/omit-credentials.util.d.ts +7 -1
  283. package/dist/utils/omit-credentials.util.js +7 -1
  284. package/dist/utils/omit-credentials.util.js.map +1 -1
  285. package/dist/utils/permission-grants.util.d.ts +28 -4
  286. package/dist/utils/permission-grants.util.js +30 -4
  287. package/dist/utils/permission-grants.util.js.map +1 -1
  288. package/dist/utils/resolve-auth-catalog.util.d.ts +6 -1
  289. package/dist/utils/resolve-auth-catalog.util.js +6 -1
  290. package/dist/utils/resolve-auth-catalog.util.js.map +1 -1
  291. package/dist/utils/resolve-effective-permissions.util.d.ts +21 -3
  292. package/dist/utils/resolve-effective-permissions.util.js +21 -3
  293. package/dist/utils/resolve-effective-permissions.util.js.map +1 -1
  294. package/dist/utils/resolve-oidc-prompt.d.ts +4 -0
  295. package/dist/utils/resolve-oidc-prompt.js +4 -0
  296. package/dist/utils/resolve-oidc-prompt.js.map +1 -1
  297. package/dist/utils/resolve-oidc-scopes.d.ts +4 -0
  298. package/dist/utils/resolve-oidc-scopes.js +4 -0
  299. package/dist/utils/resolve-oidc-scopes.js.map +1 -1
  300. package/dist/utils/resolve-request-member.util.d.ts +7 -0
  301. package/dist/utils/resolve-request-member.util.js +27 -0
  302. package/dist/utils/resolve-request-member.util.js.map +1 -0
  303. package/dist/utils/resolve-request-permissions.util.d.ts +10 -2
  304. package/dist/utils/resolve-request-permissions.util.js +21 -18
  305. package/dist/utils/resolve-request-permissions.util.js.map +1 -1
  306. package/dist/utils/resolve-required-oidc-env.d.ts +5 -0
  307. package/dist/utils/resolve-required-oidc-env.js +5 -0
  308. package/dist/utils/resolve-required-oidc-env.js.map +1 -1
  309. package/dist/utils/resolve-required-social-provider-env.d.ts +6 -0
  310. package/dist/utils/resolve-required-social-provider-env.js +6 -0
  311. package/dist/utils/resolve-required-social-provider-env.js.map +1 -1
  312. package/dist/utils/resolve-secret.d.ts +5 -0
  313. package/dist/utils/resolve-secret.js +5 -0
  314. package/dist/utils/resolve-secret.js.map +1 -1
  315. package/dist/utils/resolve-social-provider-enabled.d.ts +5 -0
  316. package/dist/utils/resolve-social-provider-enabled.js +5 -0
  317. package/dist/utils/resolve-social-provider-enabled.js.map +1 -1
  318. package/dist/utils/run-auth-query.d.ts +3 -0
  319. package/dist/utils/run-auth-query.js +3 -0
  320. package/dist/utils/run-auth-query.js.map +1 -1
  321. package/dist/utils/serialize-ability-rules.util.d.ts +5 -1
  322. package/dist/utils/serialize-ability-rules.util.js +15 -1
  323. package/dist/utils/serialize-ability-rules.util.js.map +1 -1
  324. package/dist/utils/split-auth-providers.d.ts +5 -1
  325. package/dist/utils/split-auth-providers.js +6 -4
  326. package/dist/utils/split-auth-providers.js.map +1 -1
  327. package/dist/workspace.constants.d.ts +3 -3
  328. package/dist/workspace.constants.js +6 -2
  329. package/dist/workspace.constants.js.map +1 -1
  330. package/package.json +17 -23
  331. package/dist/connections/workspace-api-key.connection-definition.d.ts +0 -13
  332. package/dist/connections/workspace-api-key.connection-definition.js.map +0 -1
  333. package/dist/entities/workspace-api-key.entity.js.map +0 -1
  334. package/dist/enums/workspace-api-key-permission.enum.js.map +0 -1
  335. package/dist/inputs/create-workspace-api-key.input.js.map +0 -1
  336. package/dist/inputs/update-workspace-api-key.input.js.map +0 -1
  337. package/dist/interfaces/workspace-api-key-validation.interface.d.ts +0 -11
  338. package/dist/interfaces/workspace-api-key-validation.interface.js +0 -2
  339. package/dist/interfaces/workspace-api-key-validation.interface.js.map +0 -1
  340. package/dist/objects/create-workspace-api-key-result.object.js.map +0 -1
  341. package/dist/objects/workspace-api-key-permission-option.object.d.ts +0 -10
  342. package/dist/objects/workspace-api-key-permission-option.object.js.map +0 -1
  343. package/dist/resolvers/workspace-api-key.resolver.d.ts +0 -25
  344. package/dist/resolvers/workspace-api-key.resolver.js +0 -84
  345. package/dist/resolvers/workspace-api-key.resolver.js.map +0 -1
  346. package/dist/services/workspace-api-key.service.d.ts +0 -41
  347. package/dist/services/workspace-api-key.service.js.map +0 -1
@@ -1,12 +1,17 @@
1
1
  import type { createAuthInstance } from "./create-auth-instance.js";
2
2
  type AuthInstance = ReturnType<typeof createAuthInstance>;
3
- /** The upstream API surface consumed by application services. @internal */
3
+ /**
4
+ * The upstream API surface consumed by application services.
5
+ * @internal
6
+ */
4
7
  export type BetterAuthAdapter = Pick<AuthInstance, "$context"> & {
5
8
  api: Pick<AuthInstance["api"], "accountInfo" | "changeEmail" | "changePassword" | "deleteUser" | "getAccessToken" | "getSession" | "linkSocialAccount" | "listSessions" | "listUserAccounts" | "refreshToken" | "requestPasswordReset" | "resetPassword" | "revokeOtherSessions" | "revokeSession" | "revokeSessions" | "sendVerificationEmail" | "setPassword" | "signInEmail" | "signInSocial" | "signOut" | "signUpEmail" | "unlinkAccount" | "updateUser" | "verifyPassword">;
6
9
  };
7
10
  /**
8
11
  * Adapts the untyped Nest injection boundary once, using the factory's upstream types.
9
12
  * Domain result normalization and response cookies remain in services and applyAuthResponseCookies.
13
+ * @param auth - Configured Better Auth instance.
14
+ * @returns Better Auth instance viewed through the internal adapter interface.
10
15
  * @internal
11
16
  */
12
17
  export declare function adaptBetterAuth(auth: unknown): BetterAuthAdapter;
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Adapts the untyped Nest injection boundary once, using the factory's upstream types.
3
3
  * Domain result normalization and response cookies remain in services and applyAuthResponseCookies.
4
+ * @param auth - Configured Better Auth instance.
5
+ * @returns Better Auth instance viewed through the internal adapter interface.
4
6
  * @internal
5
7
  */
6
8
  export function adaptBetterAuth(auth) {
@@ -1 +1 @@
1
- {"version":3,"file":"better-auth-adapter.js","sourceRoot":"","sources":["../../src/infrastructure/better-auth-adapter.ts"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,OAAO,IAAyB,CAAC;AACnC,CAAC"}
1
+ {"version":3,"file":"better-auth-adapter.js","sourceRoot":"","sources":["../../src/infrastructure/better-auth-adapter.ts"],"names":[],"mappings":"AAsCA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,OAAO,IAAyB,CAAC;AACnC,CAAC"}
@@ -4,7 +4,25 @@ import type { Mailer } from "@nest-boot/mailer";
4
4
  import { betterAuth, type BetterAuthOptions } from "better-auth";
5
5
  import { type AuthModuleOptions } from "../auth-module-options.interface.js";
6
6
  import type { UserDeletionService } from "../services/user-deletion.service.js";
7
- /** Resolves framework configuration before constructing the upstream instance. @internal */
7
+ /**
8
+ * Resolves framework configuration before constructing the upstream instance.
9
+ * @param options - Authentication module configuration.
10
+ * @param orm - MikroORM instance used for persistence.
11
+ * @param mailer - Mailer used to deliver authentication emails.
12
+ * @param hashService - Service for hashing and verifying passwords.
13
+ * @param userDeletionService - Service that deletes users and their related records.
14
+ * @returns Better Auth options assembled from the module configuration.
15
+ * @internal
16
+ */
8
17
  export declare function resolveBetterAuthOptions(options: AuthModuleOptions, orm: MikroORM, mailer: Mailer, hashService: HashService, userDeletionService: UserDeletionService): BetterAuthOptions;
9
- /** Constructs the single BetterAuth instance used by Nest providers. @internal */
18
+ /**
19
+ * Constructs the single BetterAuth instance used by Nest providers.
20
+ * @param options - Authentication module configuration.
21
+ * @param orm - MikroORM instance used for persistence.
22
+ * @param mailer - Mailer used to deliver authentication emails.
23
+ * @param hashService - Service for hashing and verifying passwords.
24
+ * @param userDeletionService - Service that deletes users and their related records.
25
+ * @returns Configured Better Auth instance.
26
+ * @internal
27
+ */
10
28
  export declare function createAuthInstance(options: AuthModuleOptions, orm: MikroORM, mailer: Mailer, hashService: HashService, userDeletionService: UserDeletionService): ReturnType<typeof betterAuth>;
@@ -20,7 +20,16 @@ import { runAuthQuery } from "../utils/run-auth-query.js";
20
20
  import { splitAuthProviders } from "../utils/split-auth-providers.js";
21
21
  import { DEFAULT_WORKSPACE_CREATOR_ROLE, DEFAULT_WORKSPACE_ROLE, } from "../workspace.constants.js";
22
22
  import { RequestIdentity } from "./request-identity.js";
23
- /** Resolves framework configuration before constructing the upstream instance. @internal */
23
+ /**
24
+ * Resolves framework configuration before constructing the upstream instance.
25
+ * @param options - Authentication module configuration.
26
+ * @param orm - MikroORM instance used for persistence.
27
+ * @param mailer - Mailer used to deliver authentication emails.
28
+ * @param hashService - Service for hashing and verifying passwords.
29
+ * @param userDeletionService - Service that deletes users and their related records.
30
+ * @returns Better Auth options assembled from the module configuration.
31
+ * @internal
32
+ */
24
33
  export function resolveBetterAuthOptions(options, orm, mailer, hashService, userDeletionService) {
25
34
  validateAuthOptions(options);
26
35
  const secret = resolveSecret(options);
@@ -66,10 +75,23 @@ export function resolveBetterAuthOptions(options, orm, mailer, hashService, user
66
75
  copyBetterAuthOptions(betterAuthOptions, options);
67
76
  return betterAuthOptions;
68
77
  }
69
- /** Constructs the single BetterAuth instance used by Nest providers. @internal */
78
+ /**
79
+ * Constructs the single BetterAuth instance used by Nest providers.
80
+ * @param options - Authentication module configuration.
81
+ * @param orm - MikroORM instance used for persistence.
82
+ * @param mailer - Mailer used to deliver authentication emails.
83
+ * @param hashService - Service for hashing and verifying passwords.
84
+ * @param userDeletionService - Service that deletes users and their related records.
85
+ * @returns Configured Better Auth instance.
86
+ * @internal
87
+ */
70
88
  export function createAuthInstance(options, orm, mailer, hashService, userDeletionService) {
71
89
  return betterAuth(resolveBetterAuthOptions(options, orm, mailer, hashService, userDeletionService));
72
90
  }
91
+ /**
92
+ * Validates authentication options before constructing Better Auth.
93
+ * @param options - Authentication module configuration.
94
+ */
73
95
  function validateAuthOptions(options) {
74
96
  const { roles: userRoles, permissions: userPermissions } = resolveAuthCatalog(options, "user");
75
97
  const { roles: workspaceRoles, permissions: workspacePermissions } = resolveAuthCatalog(options, "workspace");
@@ -78,9 +100,9 @@ function validateAuthOptions(options) {
78
100
  if (options.apiKey &&
79
101
  ("defaultPermissions" in options.apiKey ||
80
102
  "allowedPermissions" in options.apiKey)) {
81
- throw new Error("Configure API key permissions under apiKey.user or apiKey.workspace");
103
+ throw new Error("Configure API key permissions under apiKey.user or apiKey.member");
82
104
  }
83
- for (const scope of ["user", "workspace"]) {
105
+ for (const scope of ["user", "member"]) {
84
106
  const { permissions: catalog, defaults } = resolveApiKeyPermissionCatalog(options, scope);
85
107
  const configured = options.apiKey?.[scope];
86
108
  const allowed = configured?.allowedPermissions ?? catalog;
@@ -93,6 +115,11 @@ function validateAuthOptions(options) {
93
115
  assertAuthRolesExist(workspaceRoles, [options.workspace?.defaultRole ?? DEFAULT_WORKSPACE_ROLE], "workspace.defaultRole");
94
116
  assertAuthRolesExist(workspaceRoles, [options.workspace?.creatorRole ?? DEFAULT_WORKSPACE_CREATOR_ROLE], "workspace.creatorRole");
95
117
  }
118
+ /**
119
+ * Copies supported module options into the Better Auth configuration.
120
+ * @param target - Object that receives the configuration.
121
+ * @param source - Source value to read from.
122
+ */
96
123
  function copyBetterAuthOptions(target, source) {
97
124
  if (source.basePath !== undefined)
98
125
  target.basePath = source.basePath;
@@ -1 +1 @@
1
- {"version":3,"file":"create-auth-instance.js","sourceRoot":"","sources":["../../src/infrastructure/create-auth-instance.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CA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"authentication" | "invitation-identity";
4
4
  * Installs the explicit infrastructure-owned execution boundaries for auth services.
5
5
  * Domain methods only use their injected manager. Unlisted methods keep request RLS.
6
6
  * Contextual instances are created per invocation, never by mutating a shared EM.
7
+ * @param em - Entity manager used for persistence.
8
+ * @param create - Mock implementation of the create operation.
9
+ * @param operations - Concurrent operations to execute.
10
+ * @returns Authentication service bound to the active request context.
7
11
  * @internal
8
12
  */
9
13
  export declare function createContextualAuthService<T extends object>(em: EntityManager, create: (em: EntityManager) => T, operations: Partial<Record<keyof T, ExecutionContext>>): T;
@@ -5,6 +5,10 @@ import { runAuthQuery } from "../utils/run-auth-query.js";
5
5
  * Installs the explicit infrastructure-owned execution boundaries for auth services.
6
6
  * Domain methods only use their injected manager. Unlisted methods keep request RLS.
7
7
  * Contextual instances are created per invocation, never by mutating a shared EM.
8
+ * @param em - Entity manager used for persistence.
9
+ * @param create - Mock implementation of the create operation.
10
+ * @param operations - Concurrent operations to execute.
11
+ * @returns Authentication service bound to the active request context.
8
12
  * @internal
9
13
  */
10
14
  export function createContextualAuthService(em, create, operations) {
@@ -1 +1 @@
1
- {"version":3,"file":"create-contextual-auth-service.js","sourceRoot":"","sources":["../../src/infrastructure/create-contextual-auth-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,EAAiB,EACjB,MAAgC,EAChC,UAAsD;IAEtD,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACzD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE;YACnC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;oBACF,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;oBAC3C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;oBACrC,MAAM,UAAU,CAAC,OAAO,CACtB,mBAAmB,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAChD,EAAE,EACF,KAAK,EACL,WAAW,CACZ,CAAC;oBACF,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC,CAAC;gBACL,OAAO,cAAc,CAAC,QAAQ,EAAE;oBAC9B,CAAC,CAAC,MAAM,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC;oBACjC,CAAC,CAAC,MAAM,cAAc,CAAC,GAAG,CACtB,IAAI,cAAc,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,EACnD,GAAG,CACJ,CAAC;YACR,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"create-contextual-auth-service.js","sourceRoot":"","sources":["../../src/infrastructure/create-contextual-auth-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CACzC,EAAiB,EACjB,MAAgC,EAChC,UAAsD;IAEtD,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACzD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE;YACnC,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,KAAK,EAAE,GAAG,IAA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C;oBAC3C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;oBACrC,MAAM,UAAU,CAAC,OAAO,CACtB,mBAAmB,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAChD,EAAE,EACF,KAAK,EACL,WAAW,CACZ,CAAC;oBACF,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC,CAAC;gBACL,OAAO,cAAc,CAAC,QAAQ,EAAE;oBAC9B,CAAC,CAAC,MAAM,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC;oBACjC,CAAC,CAAC,MAAM,cAAc,CAAC,GAAG,CACtB,IAAI,cAAc,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,EACnD,GAAG,CACJ,CAAC;YACR,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -6,41 +6,112 @@ import { User } from "../entities/user.entity.js";
6
6
  import { Workspace } from "../entities/workspace.entity.js";
7
7
  import type { RequestIdentityPatch } from "../interfaces/request-identity-patch.interface.js";
8
8
  import type { ApiKeyMetadata } from "../types/api-key-metadata.type.js";
9
- /** Owns request identity publication, authorization invalidation, and database scope. @internal */
9
+ /**
10
+ * Owns request identity publication, authorization invalidation, and database scope.
11
+ * @internal
12
+ */
10
13
  export declare class RequestIdentity {
11
- /** Throws unless the supplied user is the authenticated user. */
14
+ /**
15
+ * Returns the active request member, rejecting user API keys outside their membership.
16
+ * @returns Active member in the selected workspace, or null if unavailable.
17
+ */
18
+ static getCurrentMember(): Member | null;
19
+ /**
20
+ * Throws unless the supplied user is the authenticated user.
21
+ * @param user - The user whose account is being accessed.
22
+ */
12
23
  static assertCurrentUser(user: User): void;
13
- /** Authorizes an explicit self-service path without granting a general resource ability. */
24
+ /**
25
+ * Authorizes an explicit self-service path without granting a general resource ability.
26
+ * @param user - The user whose account is being accessed.
27
+ */
14
28
  static assertUserSession(user: User): void;
15
- /** Throws unless the supplied session is the authenticated session. */
29
+ /**
30
+ * Throws unless the supplied session is the authenticated session.
31
+ * @param session - Session whose metadata is being accessed.
32
+ */
16
33
  static assertCurrentSession(session: Session): void;
17
- /** Throws unless the supplied workspace is selected for the current request. */
34
+ /**
35
+ * Throws unless the supplied workspace is selected for the current request.
36
+ * @param workspace - The workspace that scopes this operation.
37
+ */
18
38
  static assertCurrentWorkspace(workspace: Workspace): void;
19
- /** Throws unless the supplied member is the current workspace member. */
39
+ /**
40
+ * Throws unless the supplied member is the current workspace member.
41
+ * @param member - The workspace membership to inspect or change.
42
+ */
20
43
  static assertCurrentMember(member: Member | null | undefined): void;
21
- /** Matches credentials by both table and ID. */
44
+ /**
45
+ * Matches credentials by both table and ID.
46
+ * @param apiKey - API key whose metadata is being accessed.
47
+ * @returns Whether the key matches the credential authenticating this request.
48
+ */
22
49
  static isCurrentApiKey(apiKey: ApiKeyMetadata): boolean;
23
- /** Rejects publishing an authenticating credential before its outer transaction commits. */
50
+ /**
51
+ * Rejects publishing an authenticating credential before its outer transaction commits.
52
+ * @param em - Entity manager used for persistence.
53
+ * @param apiKey - API key whose metadata is being accessed.
54
+ */
24
55
  static assertApiKeyCanCommit(em: EntityManager, apiKey: ApiKeyMetadata): void;
25
- /** Publishes only changes to the user represented by this request. */
56
+ /**
57
+ * Publishes only changes to the user represented by this request.
58
+ * @param em - Entity manager used for persistence.
59
+ * @param options - Authentication module configuration.
60
+ * @param user - The user whose account is being accessed.
61
+ */
26
62
  static updateUser(em: EntityManager, options: AuthModuleOptions, user: User): void;
27
- /** Publishes only current membership changes, clearing departed workspace scope. */
63
+ /**
64
+ * Publishes only current membership changes, clearing departed workspace scope.
65
+ * @param em - Entity manager used for persistence.
66
+ * @param options - Authentication module configuration.
67
+ * @param member - The workspace membership to inspect or change.
68
+ */
28
69
  static updateMember(em: EntityManager, options: AuthModuleOptions, member: Member): void;
29
- /** Publishes committed credential changes or revokes the entire request. */
70
+ /**
71
+ * Publishes committed credential changes or revokes the entire request.
72
+ * @param em - Entity manager used for persistence.
73
+ * @param options - Authentication module configuration.
74
+ * @param apiKey - API key whose metadata is being accessed.
75
+ * @param deleted - Whether the API key has been deleted.
76
+ */
30
77
  static updateApiKey(em: EntityManager, options: AuthModuleOptions, apiKey: ApiKeyMetadata, deleted?: boolean): void;
31
- /** Prepares the request ability once, failing closed when configuration rejects. */
78
+ /**
79
+ * Prepares the request ability once, failing closed when configuration rejects.
80
+ * @param options - Authentication module configuration.
81
+ */
32
82
  static prepare(options: AuthModuleOptions): void;
33
- /** Stages identity while authentication is being resolved, before a guard can run. */
83
+ /**
84
+ * Stages identity while authentication is being resolved, before a guard can run.
85
+ * @param patch - Identity fields to replace.
86
+ */
34
87
  static stage(patch: RequestIdentityPatch): void;
35
- /** Rebuilds one ability, never retaining old grants on failure. */
88
+ /**
89
+ * Rebuilds one ability, never retaining old grants on failure.
90
+ * @param options - Authentication module configuration.
91
+ */
36
92
  static refresh(options: AuthModuleOptions): void;
37
- /** Publishes a committed identity change; failures revoke the request instead of retaining stale grants. */
93
+ /**
94
+ * Publishes a committed identity change; failures revoke the request instead of retaining stale grants.
95
+ * @param em - Entity manager used for persistence.
96
+ * @param options - Authentication module configuration.
97
+ * @param patch - Identity fields to replace.
98
+ */
38
99
  static update(em: EntityManager, options: AuthModuleOptions, patch: RequestIdentityPatch): void;
39
- /** Removes all credentials without falling back to another authentication method. */
100
+ /**
101
+ * Removes all credentials without falling back to another authentication method.
102
+ * @param em - Entity manager used for persistence.
103
+ */
40
104
  static clear(em: EntityManager): void;
41
- /** Revokes workspace rules and rebuilds the remaining user ability after a committed change. */
105
+ /**
106
+ * Revokes workspace rules and rebuilds the remaining user ability after a committed change.
107
+ * @param em - Entity manager used for persistence.
108
+ * @param options - Authentication module configuration.
109
+ */
42
110
  static clearWorkspace(em: EntityManager, options: AuthModuleOptions): void;
43
- /** Synchronizes only identity values; database policies never receive application permissions. */
111
+ /**
112
+ * Synchronizes only identity values; database policies never receive application permissions.
113
+ * @param em - Entity manager used for persistence.
114
+ */
44
115
  static syncDatabase(em: EntityManager): void;
45
116
  private static databaseScope;
46
117
  }
@@ -3,16 +3,34 @@ import { BadRequestException, ForbiddenException } from "@nestjs/common";
3
3
  import { AuthAbility } from "../auth.ability.js";
4
4
  import { API_KEY } from "../auth.constants.js";
5
5
  import { Member } from "../entities/member.entity.js";
6
+ import { MemberApiKey } from "../entities/member-api-key.entity.js";
6
7
  import { Session } from "../entities/session.entity.js";
7
8
  import { User } from "../entities/user.entity.js";
8
9
  import { Workspace } from "../entities/workspace.entity.js";
9
- import { WorkspaceApiKey } from "../entities/workspace-api-key.entity.js";
10
10
  import { buildRequestAbility } from "../utils/build-request-ability.util.js";
11
11
  import { getCurrentApiKey } from "../utils/get-current-api-key.util.js";
12
+ import { resolveRequestMember } from "../utils/resolve-request-member.util.js";
12
13
  import { invalidateRequestPermissions } from "../utils/resolve-request-permissions.util.js";
13
- /** Owns request identity publication, authorization invalidation, and database scope. @internal */
14
+ /**
15
+ * Owns request identity publication, authorization invalidation, and database scope.
16
+ * @internal
17
+ */
14
18
  export class RequestIdentity {
15
- /** Throws unless the supplied user is the authenticated user. */
19
+ /**
20
+ * Returns the active request member, rejecting user API keys outside their membership.
21
+ * @returns Active member in the selected workspace, or null if unavailable.
22
+ */
23
+ static getCurrentMember() {
24
+ const member = resolveRequestMember();
25
+ if (getCurrentApiKey() && RequestContext.get(User) && !member) {
26
+ throw new ForbiddenException("The API key owner is not a member of this workspace");
27
+ }
28
+ return member;
29
+ }
30
+ /**
31
+ * Throws unless the supplied user is the authenticated user.
32
+ * @param user - The user whose account is being accessed.
33
+ */
16
34
  static assertCurrentUser(user) {
17
35
  const currentUser = RequestContext.isActive()
18
36
  ? RequestContext.get(User)
@@ -21,14 +39,20 @@ export class RequestIdentity {
21
39
  throw new ForbiddenException("The operation belongs to another user");
22
40
  }
23
41
  }
24
- /** Authorizes an explicit self-service path without granting a general resource ability. */
42
+ /**
43
+ * Authorizes an explicit self-service path without granting a general resource ability.
44
+ * @param user - The user whose account is being accessed.
45
+ */
25
46
  static assertUserSession(user) {
26
47
  this.assertCurrentUser(user);
27
48
  if (getCurrentApiKey()) {
28
49
  throw new ForbiddenException("This self-service operation requires a user session");
29
50
  }
30
51
  }
31
- /** Throws unless the supplied session is the authenticated session. */
52
+ /**
53
+ * Throws unless the supplied session is the authenticated session.
54
+ * @param session - Session whose metadata is being accessed.
55
+ */
32
56
  static assertCurrentSession(session) {
33
57
  const currentSession = RequestContext.isActive()
34
58
  ? RequestContext.get(Session)
@@ -37,7 +61,10 @@ export class RequestIdentity {
37
61
  throw new ForbiddenException("The operation belongs to another session");
38
62
  }
39
63
  }
40
- /** Throws unless the supplied workspace is selected for the current request. */
64
+ /**
65
+ * Throws unless the supplied workspace is selected for the current request.
66
+ * @param workspace - The workspace that scopes this operation.
67
+ */
41
68
  static assertCurrentWorkspace(workspace) {
42
69
  const currentWorkspace = RequestContext.isActive()
43
70
  ? RequestContext.get(Workspace)
@@ -47,7 +74,10 @@ export class RequestIdentity {
47
74
  throw new ForbiddenException("The operation belongs to another workspace");
48
75
  }
49
76
  }
50
- /** Throws unless the supplied member is the current workspace member. */
77
+ /**
78
+ * Throws unless the supplied member is the current workspace member.
79
+ * @param member - The workspace membership to inspect or change.
80
+ */
51
81
  static assertCurrentMember(member) {
52
82
  const currentMember = RequestContext.isActive()
53
83
  ? RequestContext.get(Member)
@@ -58,26 +88,44 @@ export class RequestIdentity {
58
88
  throw new ForbiddenException("The operation belongs to another workspace member");
59
89
  }
60
90
  }
61
- /** Matches credentials by both table and ID. */
91
+ /**
92
+ * Matches credentials by both table and ID.
93
+ * @param apiKey - API key whose metadata is being accessed.
94
+ * @returns Whether the key matches the credential authenticating this request.
95
+ */
62
96
  static isCurrentApiKey(apiKey) {
63
97
  const current = getCurrentApiKey();
64
98
  return (!!current &&
65
99
  current.constructor === apiKey.constructor &&
66
100
  current.id === apiKey.id);
67
101
  }
68
- /** Rejects publishing an authenticating credential before its outer transaction commits. */
102
+ /**
103
+ * Rejects publishing an authenticating credential before its outer transaction commits.
104
+ * @param em - Entity manager used for persistence.
105
+ * @param apiKey - API key whose metadata is being accessed.
106
+ */
69
107
  static assertApiKeyCanCommit(em, apiKey) {
70
108
  if (this.isCurrentApiKey(apiKey) && em.isInTransaction()) {
71
109
  throw new BadRequestException("Change the authenticating API key outside an active transaction");
72
110
  }
73
111
  }
74
- /** Publishes only changes to the user represented by this request. */
112
+ /**
113
+ * Publishes only changes to the user represented by this request.
114
+ * @param em - Entity manager used for persistence.
115
+ * @param options - Authentication module configuration.
116
+ * @param user - The user whose account is being accessed.
117
+ */
75
118
  static updateUser(em, options, user) {
76
119
  if (!RequestContext.isActive() || RequestContext.get(User)?.id !== user.id)
77
120
  return;
78
121
  this.update(em, options, { user });
79
122
  }
80
- /** Publishes only current membership changes, clearing departed workspace scope. */
123
+ /**
124
+ * Publishes only current membership changes, clearing departed workspace scope.
125
+ * @param em - Entity manager used for persistence.
126
+ * @param options - Authentication module configuration.
127
+ * @param member - The workspace membership to inspect or change.
128
+ */
81
129
  static updateMember(em, options, member) {
82
130
  if (!RequestContext.isActive() ||
83
131
  RequestContext.get(Member)?.id !== member.id)
@@ -87,7 +135,13 @@ export class RequestIdentity {
87
135
  else
88
136
  this.update(em, options, { member });
89
137
  }
90
- /** Publishes committed credential changes or revokes the entire request. */
138
+ /**
139
+ * Publishes committed credential changes or revokes the entire request.
140
+ * @param em - Entity manager used for persistence.
141
+ * @param options - Authentication module configuration.
142
+ * @param apiKey - API key whose metadata is being accessed.
143
+ * @param deleted - Whether the API key has been deleted.
144
+ */
91
145
  static updateApiKey(em, options, apiKey, deleted = false) {
92
146
  if (!this.isCurrentApiKey(apiKey))
93
147
  return;
@@ -98,13 +152,19 @@ export class RequestIdentity {
98
152
  else
99
153
  this.update(em, options, { apiKey });
100
154
  }
101
- /** Prepares the request ability once, failing closed when configuration rejects. */
155
+ /**
156
+ * Prepares the request ability once, failing closed when configuration rejects.
157
+ * @param options - Authentication module configuration.
158
+ */
102
159
  static prepare(options) {
103
160
  if (!RequestContext.isActive() || RequestContext.get(AuthAbility))
104
161
  return;
105
162
  this.refresh(options);
106
163
  }
107
- /** Stages identity while authentication is being resolved, before a guard can run. */
164
+ /**
165
+ * Stages identity while authentication is being resolved, before a guard can run.
166
+ * @param patch - Identity fields to replace.
167
+ */
108
168
  static stage(patch) {
109
169
  if (!RequestContext.isActive())
110
170
  return;
@@ -121,7 +181,10 @@ export class RequestIdentity {
121
181
  invalidateRequestPermissions();
122
182
  RequestContext.set(AuthAbility, null);
123
183
  }
124
- /** Rebuilds one ability, never retaining old grants on failure. */
184
+ /**
185
+ * Rebuilds one ability, never retaining old grants on failure.
186
+ * @param options - Authentication module configuration.
187
+ */
125
188
  static refresh(options) {
126
189
  if (!RequestContext.isActive())
127
190
  return;
@@ -129,16 +192,24 @@ export class RequestIdentity {
129
192
  RequestContext.set(AuthAbility, new AuthAbility());
130
193
  RequestContext.set(AuthAbility, buildRequestAbility(options));
131
194
  }
132
- /** Publishes a committed identity change; failures revoke the request instead of retaining stale grants. */
195
+ /**
196
+ * Publishes a committed identity change; failures revoke the request instead of retaining stale grants.
197
+ * @param em - Entity manager used for persistence.
198
+ * @param options - Authentication module configuration.
199
+ * @param patch - Identity fields to replace.
200
+ */
133
201
  static update(em, options, patch) {
134
202
  if (!RequestContext.isActive())
135
203
  return;
136
- const previousScope = JSON.stringify(this.databaseScope());
137
204
  this.stage(patch);
138
205
  try {
139
- if (em.getSessionContext() &&
140
- previousScope !== JSON.stringify(this.databaseScope()))
141
- this.syncDatabase(em);
206
+ const currentScope = em.getSessionContext();
207
+ const scope = this.databaseScope();
208
+ // Compare with the published scope: ORM entities may already be mutated.
209
+ if (currentScope &&
210
+ (currentScope.role !== scope.role ||
211
+ Object.entries(scope.variables).some(([key, value]) => currentScope.variables?.[key] !== value)))
212
+ em.setSessionContext(scope);
142
213
  this.refresh(options);
143
214
  }
144
215
  catch (error) {
@@ -146,7 +217,10 @@ export class RequestIdentity {
146
217
  throw error;
147
218
  }
148
219
  }
149
- /** Removes all credentials without falling back to another authentication method. */
220
+ /**
221
+ * Removes all credentials without falling back to another authentication method.
222
+ * @param em - Entity manager used for persistence.
223
+ */
150
224
  static clear(em) {
151
225
  this.stage({
152
226
  user: null,
@@ -161,18 +235,29 @@ export class RequestIdentity {
161
235
  if (em.getSessionContext())
162
236
  em.setSessionContext({
163
237
  role: "anonymous",
164
- variables: { "app.user.id": "", "app.workspace.id": "" },
238
+ variables: {
239
+ "app.user.id": "",
240
+ "app.workspace.id": "",
241
+ "app.member.id": "",
242
+ },
165
243
  });
166
244
  }
167
- /** Revokes workspace rules and rebuilds the remaining user ability after a committed change. */
245
+ /**
246
+ * Revokes workspace rules and rebuilds the remaining user ability after a committed change.
247
+ * @param em - Entity manager used for persistence.
248
+ * @param options - Authentication module configuration.
249
+ */
168
250
  static clearWorkspace(em, options) {
169
- if (getCurrentApiKey() instanceof WorkspaceApiKey) {
251
+ if (getCurrentApiKey() instanceof MemberApiKey) {
170
252
  this.clear(em);
171
253
  return;
172
254
  }
173
255
  this.update(em, options, { member: null, workspace: null });
174
256
  }
175
- /** Synchronizes only identity values; database policies never receive application permissions. */
257
+ /**
258
+ * Synchronizes only identity values; database policies never receive application permissions.
259
+ * @param em - Entity manager used for persistence.
260
+ */
176
261
  static syncDatabase(em) {
177
262
  em.setSessionContext(this.databaseScope());
178
263
  }
@@ -180,14 +265,14 @@ export class RequestIdentity {
180
265
  const user = RequestContext.get(User);
181
266
  const apiKey = getCurrentApiKey();
182
267
  const workspace = RequestContext.get(Workspace);
183
- const member = RequestContext.get(Member);
268
+ const member = resolveRequestMember();
184
269
  const authenticated = Boolean(user ?? apiKey);
185
- const canUseWorkspace = Boolean(member ?? (apiKey && !user));
186
270
  return {
187
271
  role: authenticated ? "authenticated" : "anonymous",
188
272
  variables: {
189
273
  "app.user.id": user?.id ?? "",
190
- "app.workspace.id": !authenticated || canUseWorkspace ? (workspace?.id ?? "") : "",
274
+ "app.workspace.id": !authenticated || member ? (workspace?.id ?? "") : "",
275
+ "app.member.id": member?.id ?? "",
191
276
  },
192
277
  };
193
278
  }
@@ -1 +1 @@
1
- {"version":3,"file":"request-identity.js","sourceRoot":"","sources":["../../src/infrastructure/request-identity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAG1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAE5F,mGAAmG;AACnG,MAAM,OAAO,eAAe;IAC1B,iEAAiE;IACjE,MAAM,CAAC,iBAAiB,CAAC,IAAU;QACjC,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,EAAE;YAC3C,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC;YAC1B,CAAC,CAAC,SAAS,CAAC;QAEd,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAC/D,MAAM,IAAI,kBAAkB,CAAC,uCAAuC,CAAC,CAAC;Q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