@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
@@ -10,39 +10,49 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
- var WorkspaceApiKeyService_1;
13
+ var MemberApiKeyService_1;
14
14
  import { EntityManager, Reference } from "@mikro-orm/core";
15
15
  import { ConnectionManager, } from "@nest-boot/graphql-connection";
16
16
  import { RequestContext } from "@nest-boot/request-context";
17
17
  import { ForbiddenException, Inject, Injectable, Logger, NotFoundException, } from "@nestjs/common";
18
18
  import { MODULE_OPTIONS_TOKEN } from "../auth.module-definition.js";
19
- import { WorkspaceApiKeyConnection } from "../connections/workspace-api-key.connection-definition.js";
19
+ import { MemberApiKeyConnection } from "../connections/member-api-key.connection-definition.js";
20
20
  import { Member } from "../entities/member.entity.js";
21
- import { WorkspaceApiKey } from "../entities/workspace-api-key.entity.js";
21
+ import { MemberApiKey } from "../entities/member-api-key.entity.js";
22
+ import { User } from "../entities/user.entity.js";
22
23
  import { ApiKeyLifecycle } from "../infrastructure/api-key-lifecycle.js";
23
24
  import { RequestIdentity } from "../infrastructure/request-identity.js";
24
25
  import { normalizeApiKeyPermissions, resolveApiKeyPermissionCatalog, } from "../utils/api-key-permissions.util.js";
25
26
  import { authorize } from "../utils/authorize.util.js";
26
27
  import { getCurrentApiKey } from "../utils/get-current-api-key.util.js";
27
28
  import { omitCredentials } from "../utils/omit-credentials.util.js";
28
- import { assertApiKeyPermissionCeiling, assertCanGrantPermissions, canGrantPermissions, } from "../utils/permission-grants.util.js";
29
+ import { assertApiKeyPermissionCeiling, assertCanGrantPermissions, assertPermissionCeiling, canGrantPermissions, } from "../utils/permission-grants.util.js";
30
+ import { resolveMemberPermissions } from "../utils/resolve-effective-permissions.util.js";
29
31
  import { resolveRequestPermissions } from "../utils/resolve-request-permissions.util.js";
30
- /** Manages workspace-owned API keys within the current request's authorization scope. */
31
- let WorkspaceApiKeyService = WorkspaceApiKeyService_1 = class WorkspaceApiKeyService {
32
+ /** Manages member-owned, workspace-scoped API keys within the current request's authorization scope. */
33
+ let MemberApiKeyService = MemberApiKeyService_1 = class MemberApiKeyService {
32
34
  em;
33
35
  authOptions;
34
- logger = new Logger(WorkspaceApiKeyService_1.name);
35
- /** Creates an API-key domain service. */
36
+ logger = new Logger(MemberApiKeyService_1.name);
37
+ /**
38
+ * Creates an API-key domain service.
39
+ * @param em - Entity manager used for persistence.
40
+ * @param authOptions - Authentication module configuration.
41
+ */
36
42
  constructor(
37
43
  /** MikroORM entity manager used for API-key persistence. */
38
44
  em, authOptions) {
39
45
  this.em = em;
40
46
  this.authOptions = authOptions;
41
47
  }
42
- /** Lists API-key grants available to the caller in the selected workspace. */
43
- getWorkspaceApiKeyPermissions(workspace) {
48
+ /**
49
+ * Lists API-key grants available to the caller in the selected workspace.
50
+ * @param workspace - The workspace that scopes this operation.
51
+ * @returns Member API key permission choices with defaults and grant availability.
52
+ */
53
+ getMemberApiKeyPermissions(workspace) {
44
54
  RequestIdentity.assertCurrentWorkspace(workspace);
45
- const { permissions, allowed, defaults } = resolveApiKeyPermissionCatalog(this.authOptions, "workspace");
55
+ const { permissions, allowed, defaults } = resolveApiKeyPermissionCatalog(this.authOptions, "member");
46
56
  const allowedSet = new Set(allowed);
47
57
  return permissions.map((permission) => ({
48
58
  permission,
@@ -51,24 +61,36 @@ let WorkspaceApiKeyService = WorkspaceApiKeyService_1 = class WorkspaceApiKeySer
51
61
  canGrantPermissions(this.authOptions, "workspace", [permission]),
52
62
  }));
53
63
  }
54
- /** Returns a key owned by the authenticated workspace and within the caller's scope. */
55
- async getWorkspaceApiKey(id, workspace) {
64
+ /**
65
+ * Returns a member-owned key in the selected workspace and within the caller's scope.
66
+ * @param id - Identifier of the record to access.
67
+ * @param workspace - The workspace that scopes this operation.
68
+ * @returns Matching API key metadata with the credential hash omitted, or null.
69
+ */
70
+ async getMemberApiKey(id, workspace) {
56
71
  this.assertWorkspacePrincipal(workspace);
57
- authorize("read", WorkspaceApiKey);
72
+ authorize("read", MemberApiKey);
58
73
  const apiKey = await this.getVisibleApiKey(id, workspace);
59
74
  if (apiKey) {
60
75
  authorize("read", apiKey);
61
76
  }
62
77
  return apiKey ? omitCredentials(apiKey, ["key"]) : null;
63
78
  }
64
- /** Paginates selected-workspace keys after applying ownership and permission ceilings. */
65
- async getWorkspaceApiKeyConnection(workspace, args, info) {
79
+ /**
80
+ * Paginates all selected-workspace member keys within the caller's permission ceilings.
81
+ * @param workspace - The workspace that scopes this operation.
82
+ * @param args - Pagination, filtering, and ordering arguments.
83
+ * @param info - GraphQL selection information used to shape the query.
84
+ * @returns Paginated member API key metadata with credential hashes omitted.
85
+ */
86
+ async getMemberApiKeyConnection(workspace, args, info) {
66
87
  this.assertWorkspacePrincipal(workspace);
67
- authorize("read", WorkspaceApiKey);
88
+ authorize("read", MemberApiKey);
68
89
  const where = this.getOwnedListFilter(workspace);
69
- const connection = await new ConnectionManager(this.em).find(WorkspaceApiKeyConnection, args, {
90
+ const connection = await new ConnectionManager(this.em).find(MemberApiKeyConnection, args, {
70
91
  ...(info && { info }),
71
92
  where,
93
+ populate: ["member.workspace"],
72
94
  exclude: ["key"],
73
95
  });
74
96
  // Reject the whole page rather than silently changing cursor pagination.
@@ -83,45 +105,78 @@ let WorkspaceApiKeyService = WorkspaceApiKeyService_1 = class WorkspaceApiKeySer
83
105
  })),
84
106
  };
85
107
  }
86
- /** Creates an API key owned by a workspace. */
87
- async createWorkspaceApiKey(workspace, options) {
108
+ /**
109
+ * Creates an API key owned by a workspace member.
110
+ * @param workspace - The workspace that scopes this operation.
111
+ * @param options - Configuration for this operation.
112
+ * @returns Created key metadata and its one-time plaintext credential.
113
+ */
114
+ async createMemberApiKey(workspace, options) {
88
115
  this.assertWorkspacePrincipal(workspace);
89
- authorize("write", WorkspaceApiKey);
90
- const permissions = normalizeApiKeyPermissions(this.authOptions, "workspace", options.permissions);
91
- assertCanGrantPermissions(this.authOptions, "workspace", permissions);
92
- return await this.createKey(workspace, options, permissions);
93
- }
94
- /** Updates a key owned by the authenticated workspace. */
95
- async updateWorkspaceApiKey(id, input) {
96
- authorize("write", WorkspaceApiKey);
116
+ authorize("write", MemberApiKey);
117
+ const permissions = normalizeApiKeyPermissions(this.authOptions, "member", options.permissions);
118
+ const member = await this.getCreationMember(workspace, options.member);
119
+ this.assertMemberPermissionCeiling(member, permissions);
120
+ return await this.createKey(member, options, permissions);
121
+ }
122
+ /**
123
+ * Updates a member-owned key in the selected workspace.
124
+ * @param id - Identifier of the record to access.
125
+ * @param input - Requested field values for the operation.
126
+ * @returns Updated API key metadata without the stored credential hash.
127
+ */
128
+ async updateMemberApiKey(id, input) {
129
+ authorize("write", MemberApiKey);
97
130
  const apiKey = await this.findWritableApiKey(id);
98
131
  authorize("write", apiKey);
99
132
  const permissions = input.permissions === undefined
100
133
  ? undefined
101
- : normalizeApiKeyPermissions(this.authOptions, "workspace", input.permissions ?? []);
134
+ : normalizeApiKeyPermissions(this.authOptions, "member", input.permissions ?? []);
102
135
  // Allow disabling stale grants without replacing them.
103
136
  if (input.enabled !== false || permissions !== undefined) {
104
137
  const finalPermissions = permissions ??
105
- normalizeApiKeyPermissions(this.authOptions, "workspace", apiKey.permissions ?? []);
106
- assertCanGrantPermissions(this.authOptions, "workspace", finalPermissions);
138
+ normalizeApiKeyPermissions(this.authOptions, "member", apiKey.permissions ?? []);
139
+ this.assertMemberPermissionCeiling(Reference.unwrapReference(apiKey.member), finalPermissions);
107
140
  }
108
141
  return omitCredentials(await ApiKeyLifecycle.update(this.em, this.authOptions, apiKey, input, permissions), ["key"]);
109
142
  }
110
- /** Deletes a key owned by the authenticated workspace. */
111
- async deleteWorkspaceApiKey(id) {
112
- authorize("write", WorkspaceApiKey);
143
+ /**
144
+ * Deletes a member-owned key in the selected workspace.
145
+ * @param id - Identifier of the record to access.
146
+ * @returns Deleted API key metadata without the stored credential hash.
147
+ */
148
+ async deleteMemberApiKey(id) {
149
+ authorize("write", MemberApiKey);
113
150
  const apiKey = await this.findWritableApiKey(id);
114
151
  authorize("write", apiKey);
115
152
  return omitCredentials(await ApiKeyLifecycle.delete(this.em, this.authOptions, apiKey), ["key"]);
116
153
  }
117
- async createKey(workspace, options, permissions) {
118
- const { apiKey, data } = ApiKeyLifecycle.prepareCreation(options, permissions, this.authOptions.apiKey?.workspace?.defaultPrefix ??
154
+ async getCreationMember(workspace, owner) {
155
+ const member = typeof owner === "string"
156
+ ? await this.em.findOne(Member, { id: owner, workspace }, { populate: ["workspace", "user"], refresh: true })
157
+ : (owner ?? RequestContext.get(Member));
158
+ if (!member)
159
+ throw new NotFoundException("Workspace member not found");
160
+ if (member.status !== "ACTIVE")
161
+ throw new ForbiddenException("An active workspace member is required");
162
+ if (member.workspace.id !== workspace.id)
163
+ throw new ForbiddenException("The operation belongs to another workspace");
164
+ if (member.type !== "SERVICE_ACCOUNT" &&
165
+ (!RequestContext.get(User) ||
166
+ !member.user ||
167
+ member.user.id !== RequestContext.get(User)?.id)) {
168
+ throw new ForbiddenException("You may only create API keys for yourself or a service account");
169
+ }
170
+ return member;
171
+ }
172
+ async createKey(member, options, permissions) {
173
+ const { apiKey, data } = ApiKeyLifecycle.prepareCreation(options, permissions, this.authOptions.apiKey?.member?.defaultPrefix ??
119
174
  process.env.API_KEY_PREFIX ??
120
175
  "ws_");
121
176
  const entity = await this.em.transactional(async (em) => {
122
- const entity = em.create(WorkspaceApiKey, {
177
+ const entity = em.create(MemberApiKey, {
123
178
  ...data,
124
- workspace,
179
+ member,
125
180
  });
126
181
  authorize("write", entity);
127
182
  await em.persist(entity).flush();
@@ -129,15 +184,15 @@ let WorkspaceApiKeyService = WorkspaceApiKeyService_1 = class WorkspaceApiKeySer
129
184
  }, { clear: true });
130
185
  this.logger.log("API key created", {
131
186
  apiKeyId: entity.id,
132
- ownerId: workspace.id,
133
- ownerType: "workspace",
187
+ ownerId: member.id,
188
+ ownerType: "member",
134
189
  });
135
190
  return { apiKey, entity };
136
191
  }
137
192
  async getVisibleApiKey(id, workspace) {
138
- const apiKey = await this.em.findOne(WorkspaceApiKey, {
193
+ const apiKey = await this.em.findOne(MemberApiKey, {
139
194
  $and: [{ id }, this.getOwnedListFilter(workspace)],
140
- }, { populate: ["workspace"], exclude: ["key"] });
195
+ }, { populate: ["member.workspace"], exclude: ["key"] });
141
196
  if (apiKey) {
142
197
  this.assertWorkspace(apiKey, workspace);
143
198
  assertApiKeyPermissionCeiling(this.authOptions, apiKey.permissions ?? []);
@@ -145,8 +200,8 @@ let WorkspaceApiKeyService = WorkspaceApiKeyService_1 = class WorkspaceApiKeySer
145
200
  return apiKey;
146
201
  }
147
202
  async findWritableApiKey(id) {
148
- const apiKey = await this.em.findOne(WorkspaceApiKey, { id }, {
149
- populate: ["workspace"],
203
+ const apiKey = await this.em.findOne(MemberApiKey, { id }, {
204
+ populate: ["member.workspace"],
150
205
  exclude: ["key"],
151
206
  refresh: true,
152
207
  });
@@ -160,16 +215,17 @@ let WorkspaceApiKeyService = WorkspaceApiKeyService_1 = class WorkspaceApiKeySer
160
215
  getOwnedListFilter(workspace) {
161
216
  const ceiling = resolveRequestPermissions(this.authOptions).apiKey;
162
217
  return {
163
- workspace,
164
- ...(ceiling !== null ? { permissions: { $contained: ceiling } } : {}),
218
+ member: { workspace },
219
+ ...(ceiling !== null
220
+ ? { permissions: { $contained: ceiling, $ne: [] } }
221
+ : {}),
165
222
  };
166
223
  }
167
224
  assertWorkspacePrincipal(workspace) {
168
225
  RequestIdentity.assertCurrentWorkspace(workspace);
169
226
  const apiKey = getCurrentApiKey();
170
- if (apiKey && apiKey instanceof WorkspaceApiKey) {
227
+ if (apiKey && apiKey instanceof MemberApiKey) {
171
228
  this.assertWorkspace(apiKey, workspace);
172
- return;
173
229
  }
174
230
  const member = RequestContext.get(Member);
175
231
  if (member?.status !== "ACTIVE") {
@@ -187,15 +243,22 @@ let WorkspaceApiKeyService = WorkspaceApiKeyService_1 = class WorkspaceApiKeySer
187
243
  }
188
244
  }
189
245
  unwrapWorkspace(apiKey) {
190
- if (!apiKey.workspace)
246
+ if (!apiKey.member)
191
247
  throw new ForbiddenException("API key owner is missing");
192
- return Reference.unwrapReference(apiKey.workspace);
248
+ return Reference.unwrapReference(Reference.unwrapReference(apiKey.member).workspace);
249
+ }
250
+ assertMemberPermissionCeiling(member, permissions) {
251
+ const ownerPermissions = resolveMemberPermissions(this.authOptions, member);
252
+ if (!permissions.length)
253
+ assertApiKeyPermissionCeiling(this.authOptions, permissions);
254
+ assertPermissionCeiling(permissions, ownerPermissions, "Member API key permissions exceed owner permissions");
255
+ assertCanGrantPermissions(this.authOptions, "workspace", permissions.length ? permissions : ownerPermissions);
193
256
  }
194
257
  };
195
- WorkspaceApiKeyService = WorkspaceApiKeyService_1 = __decorate([
258
+ MemberApiKeyService = MemberApiKeyService_1 = __decorate([
196
259
  Injectable(),
197
260
  __param(1, Inject(MODULE_OPTIONS_TOKEN)),
198
261
  __metadata("design:paramtypes", [EntityManager, Object])
199
- ], WorkspaceApiKeyService);
200
- export { WorkspaceApiKeyService };
201
- //# sourceMappingURL=workspace-api-key.service.js.map
262
+ ], MemberApiKeyService);
263
+ export { MemberApiKeyService };
264
+ //# sourceMappingURL=member-api-key.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"member-api-key.service.js","sourceRoot":"","sources":["../../src/services/member-api-key.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAoB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7E,OAAO,EAEL,iBAAiB,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,UAAU,EACV,MAAM,EAC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W,EACX,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAgB,CACpD,CAAC;IACJ,CAAC;CACF,CAAA;AAzVY,mBAAmB;IAD/B,UAAU,EAAE;IAYR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;qCADN,aAAa;GAV3B,mBAAmB,CAyV/B"}
@@ -1,4 +1,4 @@
1
- import { EntityManager, type FilterQuery } from "@mikro-orm/core";
1
+ import { EntityManager, type FilterObject } from "@mikro-orm/core";
2
2
  import { type ConnectionArgsInterface, type ConnectionResult } from "@nest-boot/graphql-connection";
3
3
  import type { GraphQLResolveInfo } from "graphql";
4
4
  import type { AuthModuleOptions } from "../auth-module-options.interface.js";
@@ -15,52 +15,143 @@ export declare class MemberService {
15
15
  /** MikroORM entity manager used for workspace persistence. */
16
16
  protected readonly em: EntityManager;
17
17
  private readonly authOptions;
18
- /** Creates a workspace member domain service. */
18
+ /**
19
+ * Creates a workspace member domain service.
20
+ * @param em - Entity manager used for persistence.
21
+ * @param authOptions - Authentication module configuration.
22
+ */
19
23
  constructor(
20
24
  /** MikroORM entity manager used for workspace persistence. */
21
25
  em: EntityManager, authOptions: AuthModuleOptions);
22
- /** Returns the current member after membership and instance read checks. */
26
+ /**
27
+ * Returns the current member after membership and instance read checks.
28
+ * @returns Active member in the selected workspace, or null if unavailable.
29
+ */
23
30
  getCurrentMember(): Member | null;
24
- /** Authorizes member pagination and scopes it to the selected workspace. */
25
- getMemberListFilter(workspace: Workspace): FilterQuery<Member>;
26
- /** Paginates members within the selected workspace and its RLS scope. */
31
+ /**
32
+ * Authorizes member pagination and scopes it to the selected workspace.
33
+ * @param workspace - The workspace that scopes this operation.
34
+ * @returns Filter restricted to the workspace and readable member types.
35
+ */
36
+ getMemberListFilter(workspace: Workspace): FilterObject<Member>;
37
+ /**
38
+ * Paginates members within the selected workspace and its RLS scope.
39
+ * @param workspace - The workspace that scopes this operation.
40
+ * @param args - Pagination, filtering, and ordering arguments.
41
+ * @param info - GraphQL selection information used to shape the query.
42
+ * @returns Paginated members visible to the current principal.
43
+ */
27
44
  getMemberConnectionByWorkspace(workspace: Workspace, args: ConnectionArgsInterface<Member>, info?: GraphQLResolveInfo): Promise<ConnectionResult<Member>>;
28
- /** Finds the active membership linking a user and workspace. */
45
+ /**
46
+ * Finds the active membership linking a user and workspace.
47
+ * @param workspace - The workspace that scopes this operation.
48
+ * @param user - The user whose account is being accessed.
49
+ * @returns Matching membership, or null if the user is not a member.
50
+ */
29
51
  getMemberByUser(workspace: Workspace, user: User): Promise<Member | null>;
30
- /** Finds a member by identifier within the request's selected workspace. */
52
+ /**
53
+ * Finds a member by identifier within the request's selected workspace.
54
+ * @param id - Identifier of the record to access.
55
+ * @returns Authorized membership in the selected workspace.
56
+ */
31
57
  getMember(id: string): Promise<Member | null>;
32
- /** Resolves a member's user with workspace authorization and request RLS. */
58
+ /**
59
+ * Resolves a member's user with workspace authorization and request RLS.
60
+ * @param member - The workspace membership to inspect or change.
61
+ * @returns User associated with the membership, or null for a service account.
62
+ */
33
63
  getMemberUser(member: Member): Promise<User | null>;
34
- /** Adds an existing user to a workspace. */
64
+ /**
65
+ * Adds an existing user to a workspace.
66
+ * @param workspace - The workspace that scopes this operation.
67
+ * @param user - The user whose account is being accessed.
68
+ * @param input - Requested field values for the operation.
69
+ * @returns Created workspace membership.
70
+ */
35
71
  addMember(workspace: Workspace, user: User, input?: AddMemberOptions): Promise<Member>;
36
- /** Adds an existing user to a workspace by normalized email address. */
72
+ /**
73
+ * Adds a service account without creating a login user.
74
+ * @param workspace - The workspace that scopes this operation.
75
+ * @param name - Name used to identify the resource.
76
+ * @param input - Requested field values for the operation.
77
+ * @returns Created service account membership.
78
+ */
79
+ addServiceAccount(workspace: Workspace, name: string, input?: AddMemberOptions): Promise<Member>;
80
+ /**
81
+ * Adds an existing user to a workspace by normalized email address.
82
+ * @param workspace - The workspace that scopes this operation.
83
+ * @param email - Email address used to identify the user.
84
+ * @param input - Requested field values for the operation.
85
+ * @returns Membership created for the user with the supplied email.
86
+ */
37
87
  addMemberByEmail(workspace: Workspace, email: string, input?: AddMemberOptions): Promise<Member>;
38
88
  /**
39
89
  * Looks up a user for explicitly authorized membership creation.
40
90
  * Infrastructure isolates this lookup; membership writes retain request RLS.
91
+ * @param workspace - The workspace that scopes this operation.
92
+ * @param email - Email address used to identify the user.
93
+ * @returns User resolved for membership creation.
41
94
  * @internal
42
95
  */
43
96
  getUserForMembership(workspace: Workspace, email: string): Promise<User>;
44
97
  private resolveMemberForAction;
45
- /** Updates workspace-visible member profile fields and active state. */
98
+ /**
99
+ * Updates workspace-visible member profile fields and active state.
100
+ * @param member - The workspace membership to inspect or change.
101
+ * @param input - Requested field values for the operation.
102
+ * @returns Membership after the requested profile changes.
103
+ */
46
104
  updateMember(member: Member | string, input: UpdateMemberOptions): Promise<Member>;
47
- /** Replaces a workspace member's roles within the caller's permission scope. */
105
+ /**
106
+ * Replaces a workspace member's roles within the caller's permission scope.
107
+ * @param member - The workspace membership to inspect or change.
108
+ * @param roleNames - Role names to validate.
109
+ * @returns Membership after its assigned roles are replaced.
110
+ */
48
111
  setMemberRoles(member: Member | string, roleNames: string | readonly string[]): Promise<Member>;
49
- /** Replaces direct permissions assigned to a workspace member. */
112
+ /**
113
+ * Replaces direct permissions assigned to a workspace member.
114
+ * @param member - The workspace membership to inspect or change.
115
+ * @param permissions - Permission names to apply.
116
+ * @returns Membership after its direct permissions are replaced.
117
+ */
50
118
  setMemberPermissions(member: Member | string, permissions: readonly string[]): Promise<Member>;
51
119
  private assertAuthorizationCanCommit;
52
120
  private isCurrentMember;
53
- /** Removes a member after checking write ability; self-removal uses leaveWorkspace. */
121
+ /**
122
+ * Removes a member after checking write ability; self-removal uses leaveWorkspace.
123
+ * @param member - The workspace membership to inspect or change.
124
+ * @returns Removed membership.
125
+ */
54
126
  removeMember(member: Member | string): Promise<Member>;
55
- /** Lets the current member leave its workspace regardless of role. */
127
+ /**
128
+ * Lets the current member leave its workspace regardless of role.
129
+ * @param member - The workspace membership to inspect or change.
130
+ * @returns Membership removed from the current user's workspace.
131
+ */
56
132
  leaveWorkspace(member: Member): Promise<Member>;
57
- /** Checks flattened `subject:action` values against member permissions. */
133
+ /**
134
+ * Checks flattened `subject:action` values against member permissions.
135
+ * @param member - The workspace membership to inspect or change.
136
+ * @param input - Requested field values for the operation.
137
+ * @returns Whether every requested permission is effective for the principal.
138
+ */
58
139
  hasPermissions(member: Member, input: WorkspaceHasPermissionsOptions): boolean;
59
- /** Lists all roles with grant availability; mutations still authorize their targets. */
140
+ /**
141
+ * Lists all roles with grant availability; mutations still authorize their targets.
142
+ * @returns Role choices and whether each is within the caller's grant ceiling.
143
+ */
60
144
  listRoles(): WorkspaceRoleOption[];
61
- /** Lists all direct-permission options without authorizing a particular member. */
145
+ /**
146
+ * Lists all direct-permission options without authorizing a particular member.
147
+ * @returns Permission choices and whether each is within the caller's grant ceiling.
148
+ */
62
149
  listPermissions(): WorkspacePermissionOption[];
63
- /** Resolves permissions inherited from roles plus direct member permissions. */
150
+ /**
151
+ * Resolves permissions inherited from roles plus direct member permissions.
152
+ * @param member - The workspace membership to inspect or change.
153
+ * @returns Union of the member's role permissions and direct permissions.
154
+ */
64
155
  getEffectiveMemberPermissions(member: Member): string[];
65
156
  private lockWorkspace;
66
157
  private normalizeRoles;