@burdenoff/be-sdk 2026.1110.2 → 2026.1110.4

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 (497) hide show
  1. package/configs/eslint/index.js +1 -1
  2. package/configs/tsconfig/tsconfig.json +1 -1
  3. package/dist/EventQueueFactory-9NGZV9jl.js +1457 -0
  4. package/dist/EventQueueFactory-9NGZV9jl.js.map +1 -0
  5. package/dist/RedisStreamsConnection-CY8WySJy.js +283 -0
  6. package/dist/RedisStreamsConnection-CY8WySJy.js.map +1 -0
  7. package/dist/activity/index.d.ts +165 -0
  8. package/dist/activity/index.js +389 -0
  9. package/dist/activity/index.js.map +1 -0
  10. package/dist/ai-credits/index.d.ts +2 -3
  11. package/dist/ai-credits/index.js +3 -4
  12. package/dist/ai-credits/index.js.map +1 -1
  13. package/dist/ai-credits-xxfwGpHS.js +546 -0
  14. package/dist/ai-credits-xxfwGpHS.js.map +1 -0
  15. package/dist/{assistant-session-CJZhF4D6.d.ts → assistant-session-DA5ZKJOr.d.ts} +4 -5
  16. package/dist/auth/index.d.ts +2 -77
  17. package/dist/auth/index.js +3 -7
  18. package/dist/auth/index.js.map +1 -1
  19. package/dist/auth-C5ctwSLp.js +228 -0
  20. package/dist/auth-C5ctwSLp.js.map +1 -0
  21. package/dist/bootstrap/index.d.ts +74 -0
  22. package/dist/bootstrap/index.js +282 -0
  23. package/dist/bootstrap/index.js.map +1 -0
  24. package/dist/cache/index.d.ts +2 -3
  25. package/dist/cache/index.js +3 -7
  26. package/dist/cache/index.js.map +1 -1
  27. package/dist/cache-CU0uLwcS.js +1837 -0
  28. package/dist/cache-CU0uLwcS.js.map +1 -0
  29. package/dist/captcha/index.d.ts +2 -1
  30. package/dist/captcha/index.js +3 -3
  31. package/dist/captcha/index.js.map +1 -1
  32. package/dist/captcha-BT7yh1YS.js +77 -0
  33. package/dist/captcha-BT7yh1YS.js.map +1 -0
  34. package/dist/client/internal-client.d.ts +4 -7
  35. package/dist/client/internal-client.js +172 -4
  36. package/dist/client/internal-client.js.map +1 -1
  37. package/dist/client-BgAEvDC2.d.ts +86 -0
  38. package/dist/client-sAJTrb4i.js +565 -0
  39. package/dist/client-sAJTrb4i.js.map +1 -0
  40. package/dist/collector-endpoint-iyQYeI50.js +50 -0
  41. package/dist/collector-endpoint-iyQYeI50.js.map +1 -0
  42. package/dist/context/index.d.ts +35 -0
  43. package/dist/context/index.js +283 -0
  44. package/dist/context/index.js.map +1 -0
  45. package/dist/crypto/index.d.ts +2 -1
  46. package/dist/crypto/index.js +3 -3
  47. package/dist/crypto/index.js.map +1 -1
  48. package/dist/crypto-DO9fM0FO.js +145 -0
  49. package/dist/crypto-DO9fM0FO.js.map +1 -0
  50. package/dist/database/index.d.ts +104 -108
  51. package/dist/database/index.js +468 -6
  52. package/dist/database/index.js.map +1 -1
  53. package/dist/dataloader/index.d.ts +2 -1
  54. package/dist/dataloader/index.js +3 -3
  55. package/dist/dataloader/index.js.map +1 -1
  56. package/dist/dataloader-DwpT3YoS.js +294 -0
  57. package/dist/dataloader-DwpT3YoS.js.map +1 -0
  58. package/dist/deployed-environment-p_Tdl3sT.js +38 -0
  59. package/dist/deployed-environment-p_Tdl3sT.js.map +1 -0
  60. package/dist/dist-BGKdXVy3.js +1718 -0
  61. package/dist/dist-BGKdXVy3.js.map +1 -0
  62. package/dist/env-DdaoGjIt.js +74 -0
  63. package/dist/env-DdaoGjIt.js.map +1 -0
  64. package/dist/event-queue/index.d.ts +2 -7
  65. package/dist/event-queue/index.js +7 -9
  66. package/dist/event-queue/index.js.map +1 -1
  67. package/dist/event-queue-Cw-YJPY_.js +1384 -0
  68. package/dist/event-queue-Cw-YJPY_.js.map +1 -0
  69. package/dist/{explicit-activity-scope-CCoxVwAr.d.ts → explicit-activity-scope-D8VeGGpt.d.ts} +1 -2
  70. package/dist/explicit-activity-scope-DikJ7NAE.js +57 -0
  71. package/dist/explicit-activity-scope-DikJ7NAE.js.map +1 -0
  72. package/dist/export/index.d.ts +2 -2
  73. package/dist/export/index.js +3 -14
  74. package/dist/export/index.js.map +1 -1
  75. package/dist/export-DJXE3Osa.js +642 -0
  76. package/dist/export-DJXE3Osa.js.map +1 -0
  77. package/dist/feature-flags/index.d.ts +2 -10
  78. package/dist/feature-flags/index.js +3 -6
  79. package/dist/feature-flags/index.js.map +1 -1
  80. package/dist/feature-flags-CP1KRgwD.js +422 -0
  81. package/dist/feature-flags-CP1KRgwD.js.map +1 -0
  82. package/dist/files/index.d.ts +2 -3
  83. package/dist/files/index.js +3 -4
  84. package/dist/files/index.js.map +1 -1
  85. package/dist/files-h5U-D2AF.js +830 -0
  86. package/dist/files-h5U-D2AF.js.map +1 -0
  87. package/dist/gateway/index.d.ts +4 -6
  88. package/dist/gateway/index.js +7 -13
  89. package/dist/gateway/index.js.map +1 -1
  90. package/dist/gateway/security/index.d.ts +2 -2
  91. package/dist/gateway/security/index.js +3 -5
  92. package/dist/gateway/security/index.js.map +1 -1
  93. package/dist/gateway-ByVo-n37.js +50 -0
  94. package/dist/gateway-ByVo-n37.js.map +1 -0
  95. package/dist/graph/index.d.ts +3 -10
  96. package/dist/graph/index.js +4 -13
  97. package/dist/graph/index.js.map +1 -1
  98. package/dist/graph-CR7u4lpl.js +2152 -0
  99. package/dist/graph-CR7u4lpl.js.map +1 -0
  100. package/dist/graph-emitter-CdOXP7Tn.js +621 -0
  101. package/dist/graph-emitter-CdOXP7Tn.js.map +1 -0
  102. package/dist/graphql/index.d.ts +3 -2
  103. package/dist/graphql/index.js +4 -6
  104. package/dist/graphql/index.js.map +1 -1
  105. package/dist/graphql/services/index.d.ts +2 -24
  106. package/dist/graphql/services/index.js +3 -4
  107. package/dist/graphql/services/index.js.map +1 -1
  108. package/dist/graphql-CUDyhibV.d.ts +21 -0
  109. package/dist/graphql-DHAHHcww.js +161 -0
  110. package/dist/graphql-DHAHHcww.js.map +1 -0
  111. package/dist/i18n/index.d.ts +3 -3
  112. package/dist/i18n/index.js +3 -4
  113. package/dist/i18n/index.js.map +1 -1
  114. package/dist/i18n-BBMYFd0P.js +860 -0
  115. package/dist/i18n-BBMYFd0P.js.map +1 -0
  116. package/dist/import-optional-peer-B82VYxeX.js +18 -0
  117. package/dist/import-optional-peer-B82VYxeX.js.map +1 -0
  118. package/dist/index-3KOZ1zN9.d.ts +233 -0
  119. package/dist/index-ADmsX0BI.d.ts +646 -0
  120. package/dist/index-B2LCaK0R.d.ts +500 -0
  121. package/dist/index-BBqooJ52.d.ts +45 -0
  122. package/dist/index-BGzMYJsm.d.ts +209 -0
  123. package/dist/index-BMIMnp6T.d.ts +8 -0
  124. package/dist/index-BVOL7458.d.ts +10 -0
  125. package/dist/index-BcqQs-Uq.d.ts +69 -0
  126. package/dist/index-BeVtqGO-.d.ts +208 -0
  127. package/dist/index-BiTzGUZP.d.ts +114 -0
  128. package/dist/index-C0qLquY0.d.ts +150 -0
  129. package/dist/index-C5uEKchX.d.ts +60 -0
  130. package/dist/index-CDOqxSIi.d.ts +37 -0
  131. package/dist/index-CG6wj66Y.d.ts +148 -0
  132. package/dist/index-CHwMhK6v.d.ts +63 -0
  133. package/dist/index-CIgoeobA.d.ts +145 -0
  134. package/dist/index-CPQDMSFS.d.ts +103 -0
  135. package/dist/index-CSRcgkVi.d.ts +23 -0
  136. package/dist/index-CTTwo9av.d.ts +102 -0
  137. package/dist/index-CVCyKzhB.d.ts +207 -0
  138. package/dist/index-C_GXXF32.d.ts +704 -0
  139. package/dist/index-CaM9JUcc.d.ts +144 -0
  140. package/dist/index-CliOgq6L.d.ts +203 -0
  141. package/dist/index-Cot73bdh.d.ts +63 -0
  142. package/dist/index-DGgh9DWn.d.ts +59 -0
  143. package/dist/index-DY3dNhMN.d.ts +420 -0
  144. package/dist/index-DqbGqfAy.d.ts +127 -0
  145. package/dist/index-Dt1HJPTX.d.ts +12 -0
  146. package/dist/index-DtI6aBtB.d.ts +22 -0
  147. package/dist/index-FKohsiex.d.ts +38 -0
  148. package/dist/index-FRRaa6h2.d.ts +999 -0
  149. package/dist/index-FbXPfen7.d.ts +132 -0
  150. package/dist/index-MArCb8Aq.d.ts +306 -0
  151. package/dist/index-U_tu3zUl.d.ts +303 -0
  152. package/dist/index-YOShAwkq.d.ts +45 -0
  153. package/dist/index-cmR9k9ga.d.ts +26 -0
  154. package/dist/index-yBSjMY32.d.ts +24 -0
  155. package/dist/index-zd_NPGJo.d.ts +206 -0
  156. package/dist/index.d.ts +106 -609
  157. package/dist/index.js +769 -2590
  158. package/dist/index.js.map +1 -1
  159. package/dist/init/index.d.ts +2 -2
  160. package/dist/init/index.js +3 -16
  161. package/dist/init/index.js.map +1 -1
  162. package/dist/init-CQPFmOOe.js +325 -0
  163. package/dist/init-CQPFmOOe.js.map +1 -0
  164. package/dist/instrumentation/index.d.ts +3 -4
  165. package/dist/instrumentation/index.js +5 -5
  166. package/dist/instrumentation/index.js.map +1 -1
  167. package/dist/instrumentation-xkkmDgJ0.js +1678 -0
  168. package/dist/instrumentation-xkkmDgJ0.js.map +1 -0
  169. package/dist/lake/index.d.ts +50 -54
  170. package/dist/lake/index.js +169 -193
  171. package/dist/lake/index.js.map +1 -1
  172. package/dist/layer/index.d.ts +3 -2
  173. package/dist/layer/index.js +4 -5
  174. package/dist/layer/index.js.map +1 -1
  175. package/dist/layer-BZBZZWeV.d.ts +69 -0
  176. package/dist/layer-Bcix-WCl.js +105 -0
  177. package/dist/layer-Bcix-WCl.js.map +1 -0
  178. package/dist/layer-CEKy6cm8.js +252 -0
  179. package/dist/layer-CEKy6cm8.js.map +1 -0
  180. package/dist/lifecycle/index.d.ts +2 -1
  181. package/dist/lifecycle/index.js +3 -4
  182. package/dist/lifecycle/index.js.map +1 -1
  183. package/dist/lifecycle-DeoLSX0U.js +76 -0
  184. package/dist/lifecycle-DeoLSX0U.js.map +1 -0
  185. package/dist/logger/index.d.ts +2 -3
  186. package/dist/logger/index.js +3 -3
  187. package/dist/logger/index.js.map +1 -1
  188. package/dist/logger-B6rCpb7D.js +290 -0
  189. package/dist/logger-B6rCpb7D.js.map +1 -0
  190. package/dist/metrics/index.d.ts +13 -14
  191. package/dist/metrics/index.js +3 -4
  192. package/dist/metrics/index.js.map +1 -1
  193. package/dist/metrics-BrLwNUrb.js +52 -0
  194. package/dist/metrics-BrLwNUrb.js.map +1 -0
  195. package/dist/metrics-collector-C2eShrlW.js +922 -0
  196. package/dist/metrics-collector-C2eShrlW.js.map +1 -0
  197. package/dist/middleware/index.d.ts +3 -3
  198. package/dist/middleware/index.js +3 -4
  199. package/dist/middleware/index.js.map +1 -1
  200. package/dist/middleware-CUxJVUpD.js +1243 -0
  201. package/dist/middleware-CUxJVUpD.js.map +1 -0
  202. package/dist/middleware-Cq0zFMGp.js +253 -0
  203. package/dist/middleware-Cq0zFMGp.js.map +1 -0
  204. package/dist/notifications/index.d.ts +2 -5
  205. package/dist/notifications/index.js +3 -6
  206. package/dist/notifications/index.js.map +1 -1
  207. package/dist/notifications-DY_i37WN.js +869 -0
  208. package/dist/notifications-DY_i37WN.js.map +1 -0
  209. package/dist/observability/index.d.ts +2 -3
  210. package/dist/observability/index.js +3 -4
  211. package/dist/observability/index.js.map +1 -1
  212. package/dist/observability-DBDXipTU.js +272 -0
  213. package/dist/observability-DBDXipTU.js.map +1 -0
  214. package/dist/payments/index.d.ts +144 -0
  215. package/dist/payments/index.js +404 -0
  216. package/dist/payments/index.js.map +1 -0
  217. package/dist/platform/index.d.ts +2 -1
  218. package/dist/platform/index.js +3 -5
  219. package/dist/platform/index.js.map +1 -1
  220. package/dist/platform-DZwczW7v.js +1510 -0
  221. package/dist/platform-DZwczW7v.js.map +1 -0
  222. package/dist/prisma/generator/index.d.ts +1 -1
  223. package/dist/prisma/generator/index.js +97 -84
  224. package/dist/prisma/generator/index.js.map +1 -1
  225. package/dist/prisma/index.d.ts +4 -7
  226. package/dist/prisma/index.js +5 -12
  227. package/dist/prisma/index.js.map +1 -1
  228. package/dist/prisma-BzOOdt79.js +863 -0
  229. package/dist/prisma-BzOOdt79.js.map +1 -0
  230. package/dist/prisma-extension-Cfl09swM.d.ts +172 -0
  231. package/dist/product-alias/index.d.ts +2 -1
  232. package/dist/product-alias/index.js +3 -3
  233. package/dist/product-alias/index.js.map +1 -1
  234. package/dist/product-alias-BPqtskMq.js +273 -0
  235. package/dist/product-alias-BPqtskMq.js.map +1 -0
  236. package/dist/rate-limit-CBrK_U5H.js +142 -0
  237. package/dist/rate-limit-CBrK_U5H.js.map +1 -0
  238. package/dist/rbac/index.d.ts +2 -122
  239. package/dist/rbac/index.js +3 -6
  240. package/dist/rbac/index.js.map +1 -1
  241. package/dist/rbac-Dvz0YzEt.js +1486 -0
  242. package/dist/rbac-Dvz0YzEt.js.map +1 -0
  243. package/dist/resource-caps/index.d.ts +66 -72
  244. package/dist/resource-caps/index.js +430 -5
  245. package/dist/resource-caps/index.js.map +1 -1
  246. package/dist/rolldown-runtime-ad2WFvuA.js +17 -0
  247. package/dist/sdk-Dju9o-sq.js +124 -0
  248. package/dist/sdk-Dju9o-sq.js.map +1 -0
  249. package/dist/search/index.d.ts +112 -0
  250. package/dist/search/index.js +266 -0
  251. package/dist/search/index.js.map +1 -0
  252. package/dist/security/index.d.ts +2 -0
  253. package/dist/security/index.js +4 -0
  254. package/dist/security/index.js.map +1 -0
  255. package/dist/security/rate-limit/index.d.ts +2 -0
  256. package/dist/security/rate-limit/index.js +4 -0
  257. package/dist/security/rate-limit/index.js.map +1 -0
  258. package/dist/security-DIG-95Ic.js +1647 -0
  259. package/dist/security-DIG-95Ic.js.map +1 -0
  260. package/dist/server/index.d.ts +7 -164
  261. package/dist/server/index.js +2001 -1507
  262. package/dist/server/index.js.map +1 -1
  263. package/dist/service-jwt-Bu-WNA_-.js +80 -0
  264. package/dist/service-jwt-Bu-WNA_-.js.map +1 -0
  265. package/dist/services-BWzfz7vG.js +102 -0
  266. package/dist/services-BWzfz7vG.js.map +1 -0
  267. package/dist/sharding/index.d.ts +41 -44
  268. package/dist/sharding/index.js +156 -137
  269. package/dist/sharding/index.js.map +1 -1
  270. package/dist/sharing/index.d.ts +2 -1
  271. package/dist/sharing/index.js +3 -4
  272. package/dist/sharing/index.js.map +1 -1
  273. package/dist/sharing-CflDsSJ-.js +911 -0
  274. package/dist/sharing-CflDsSJ-.js.map +1 -0
  275. package/dist/stub-BUnfMiAS.js +577 -0
  276. package/dist/stub-BUnfMiAS.js.map +1 -0
  277. package/dist/tags/index.d.ts +2 -3
  278. package/dist/tags/index.js +3 -4
  279. package/dist/tags/index.js.map +1 -1
  280. package/dist/tags-CbijgoqR.js +868 -0
  281. package/dist/{chunk-PBZFAAOM.js.map → tags-CbijgoqR.js.map} +1 -1
  282. package/dist/telemetry/index.d.ts +64 -76
  283. package/dist/telemetry/index.js +369 -201
  284. package/dist/telemetry/index.js.map +1 -1
  285. package/dist/temporal/index.d.ts +2 -148
  286. package/dist/temporal/index.js +3 -5
  287. package/dist/temporal/index.js.map +1 -1
  288. package/dist/temporal-B534uYK8.js +706 -0
  289. package/dist/temporal-B534uYK8.js.map +1 -0
  290. package/dist/tracker/index.d.ts +5 -11
  291. package/dist/tracker/index.js +7 -20
  292. package/dist/tracker/index.js.map +1 -1
  293. package/dist/tracker-PQztSlhJ.js +458 -0
  294. package/dist/tracker-PQztSlhJ.js.map +1 -0
  295. package/dist/translation/index.d.ts +120 -0
  296. package/dist/translation/index.js +573 -0
  297. package/dist/translation/index.js.map +1 -0
  298. package/dist/types/index.d.ts +3 -0
  299. package/dist/types/index.js +90 -0
  300. package/dist/types/index.js.map +1 -0
  301. package/dist/types-BYMYND1L.js +44 -0
  302. package/dist/types-BYMYND1L.js.map +1 -0
  303. package/dist/types-C6EKaS3V.d.ts +106 -0
  304. package/dist/types-CWybW61E.d.ts +323 -0
  305. package/dist/types-C_yfu3XK.d.ts +34 -0
  306. package/dist/types-DgaQqvxo.d.ts +70 -0
  307. package/dist/usage/index.d.ts +2 -213
  308. package/dist/usage/index.js +3 -15
  309. package/dist/usage/index.js.map +1 -1
  310. package/dist/usage-BRqVP3CJ.js +682 -0
  311. package/dist/usage-BRqVP3CJ.js.map +1 -0
  312. package/dist/utils/index.d.ts +2 -1
  313. package/dist/utils/index.js +3 -3
  314. package/dist/utils/index.js.map +1 -1
  315. package/dist/utils-DL85Tnbn.js +500 -0
  316. package/dist/utils-DL85Tnbn.js.map +1 -0
  317. package/dist/validation/index.d.ts +2 -2
  318. package/dist/validation/index.js +3 -3
  319. package/dist/validation/index.js.map +1 -1
  320. package/dist/validation-CPUITdMk.js +762 -0
  321. package/dist/validation-CPUITdMk.js.map +1 -0
  322. package/dist/workspace-extension-COrC0dYi.js +979 -0
  323. package/dist/workspace-extension-COrC0dYi.js.map +1 -0
  324. package/dist/{workspace-extension-BGwTOV_r.d.ts → workspace-extension-DTFTdGVF.d.ts} +43 -45
  325. package/package.json +7 -10
  326. package/dist/EventQueueFactory-GXC3A7DH.js +0 -8
  327. package/dist/EventQueueFactory-GXC3A7DH.js.map +0 -1
  328. package/dist/chunk-4XIBXZ6J.js +0 -276
  329. package/dist/chunk-4XIBXZ6J.js.map +0 -1
  330. package/dist/chunk-554Z4C2K.js +0 -1006
  331. package/dist/chunk-554Z4C2K.js.map +0 -1
  332. package/dist/chunk-5CAFHK2Z.js +0 -107
  333. package/dist/chunk-5CAFHK2Z.js.map +0 -1
  334. package/dist/chunk-63ZXJ42X.js +0 -451
  335. package/dist/chunk-63ZXJ42X.js.map +0 -1
  336. package/dist/chunk-6XEXJATV.js +0 -304
  337. package/dist/chunk-6XEXJATV.js.map +0 -1
  338. package/dist/chunk-726AR6Q7.js +0 -1532
  339. package/dist/chunk-726AR6Q7.js.map +0 -1
  340. package/dist/chunk-A5F6Z5UE.js +0 -21
  341. package/dist/chunk-A5F6Z5UE.js.map +0 -1
  342. package/dist/chunk-A6DE32ZS.js +0 -1507
  343. package/dist/chunk-A6DE32ZS.js.map +0 -1
  344. package/dist/chunk-AXJDGQPE.js +0 -690
  345. package/dist/chunk-AXJDGQPE.js.map +0 -1
  346. package/dist/chunk-BJQOGOVW.js +0 -602
  347. package/dist/chunk-BJQOGOVW.js.map +0 -1
  348. package/dist/chunk-CFXWH2IS.js +0 -52
  349. package/dist/chunk-CFXWH2IS.js.map +0 -1
  350. package/dist/chunk-DRWH5XCJ.js +0 -876
  351. package/dist/chunk-DRWH5XCJ.js.map +0 -1
  352. package/dist/chunk-E4QNLVY4.js +0 -909
  353. package/dist/chunk-E4QNLVY4.js.map +0 -1
  354. package/dist/chunk-EBDHIL7V.js +0 -774
  355. package/dist/chunk-EBDHIL7V.js.map +0 -1
  356. package/dist/chunk-ELU7VL3E.js +0 -245
  357. package/dist/chunk-ELU7VL3E.js.map +0 -1
  358. package/dist/chunk-FZRODKIN.js +0 -31
  359. package/dist/chunk-FZRODKIN.js.map +0 -1
  360. package/dist/chunk-GCIB76AJ.js +0 -882
  361. package/dist/chunk-GCIB76AJ.js.map +0 -1
  362. package/dist/chunk-HC6MPUIH.js +0 -1571
  363. package/dist/chunk-HC6MPUIH.js.map +0 -1
  364. package/dist/chunk-HNMHPSAM.js +0 -272
  365. package/dist/chunk-HNMHPSAM.js.map +0 -1
  366. package/dist/chunk-HTLEGD3Q.js +0 -1480
  367. package/dist/chunk-HTLEGD3Q.js.map +0 -1
  368. package/dist/chunk-I3KOWRT3.js +0 -89
  369. package/dist/chunk-I3KOWRT3.js.map +0 -1
  370. package/dist/chunk-ID3WR4JS.js +0 -509
  371. package/dist/chunk-ID3WR4JS.js.map +0 -1
  372. package/dist/chunk-JS52ZHTK.js +0 -1346
  373. package/dist/chunk-JS52ZHTK.js.map +0 -1
  374. package/dist/chunk-JVMAQOA3.js +0 -521
  375. package/dist/chunk-JVMAQOA3.js.map +0 -1
  376. package/dist/chunk-KH4TRQCO.js +0 -1063
  377. package/dist/chunk-KH4TRQCO.js.map +0 -1
  378. package/dist/chunk-KJOSPVB2.js +0 -57
  379. package/dist/chunk-KJOSPVB2.js.map +0 -1
  380. package/dist/chunk-KO2ZXZ7W.js +0 -61
  381. package/dist/chunk-KO2ZXZ7W.js.map +0 -1
  382. package/dist/chunk-KS2HQCJR.js +0 -56
  383. package/dist/chunk-KS2HQCJR.js.map +0 -1
  384. package/dist/chunk-LA5KPWZ2.js +0 -413
  385. package/dist/chunk-LA5KPWZ2.js.map +0 -1
  386. package/dist/chunk-MESLAC5W.js +0 -574
  387. package/dist/chunk-MESLAC5W.js.map +0 -1
  388. package/dist/chunk-MWPYA2HD.js +0 -94
  389. package/dist/chunk-MWPYA2HD.js.map +0 -1
  390. package/dist/chunk-NUB5GQTU.js +0 -270
  391. package/dist/chunk-NUB5GQTU.js.map +0 -1
  392. package/dist/chunk-OBBCR6WY.js +0 -277
  393. package/dist/chunk-OBBCR6WY.js.map +0 -1
  394. package/dist/chunk-OQDSAOG3.js +0 -1908
  395. package/dist/chunk-OQDSAOG3.js.map +0 -1
  396. package/dist/chunk-OXNCBE7P.js +0 -971
  397. package/dist/chunk-OXNCBE7P.js.map +0 -1
  398. package/dist/chunk-PBZFAAOM.js +0 -941
  399. package/dist/chunk-PN6GIF3R.js +0 -1185
  400. package/dist/chunk-PN6GIF3R.js.map +0 -1
  401. package/dist/chunk-PYD44IHJ.js +0 -728
  402. package/dist/chunk-PYD44IHJ.js.map +0 -1
  403. package/dist/chunk-QVPIACWD.js +0 -679
  404. package/dist/chunk-QVPIACWD.js.map +0 -1
  405. package/dist/chunk-QWNNFE4P.js +0 -41
  406. package/dist/chunk-QWNNFE4P.js.map +0 -1
  407. package/dist/chunk-RU266375.js +0 -327
  408. package/dist/chunk-RU266375.js.map +0 -1
  409. package/dist/chunk-RYTSVGGA.js +0 -1624
  410. package/dist/chunk-RYTSVGGA.js.map +0 -1
  411. package/dist/chunk-RZOFS2BQ.js +0 -225
  412. package/dist/chunk-RZOFS2BQ.js.map +0 -1
  413. package/dist/chunk-SBS4S2PJ.js +0 -100
  414. package/dist/chunk-SBS4S2PJ.js.map +0 -1
  415. package/dist/chunk-SPRG6G6G.js +0 -530
  416. package/dist/chunk-SPRG6G6G.js.map +0 -1
  417. package/dist/chunk-STWFX5E2.js +0 -233
  418. package/dist/chunk-STWFX5E2.js.map +0 -1
  419. package/dist/chunk-UNASM5VJ.js +0 -419
  420. package/dist/chunk-UNASM5VJ.js.map +0 -1
  421. package/dist/chunk-VAT66FJA.js +0 -245
  422. package/dist/chunk-VAT66FJA.js.map +0 -1
  423. package/dist/chunk-VFCMR5GX.js +0 -49
  424. package/dist/chunk-VFCMR5GX.js.map +0 -1
  425. package/dist/chunk-VGAHZKNJ.js +0 -66
  426. package/dist/chunk-VGAHZKNJ.js.map +0 -1
  427. package/dist/chunk-VTJTAAXC.js +0 -627
  428. package/dist/chunk-VTJTAAXC.js.map +0 -1
  429. package/dist/chunk-VXVLKRU6.js +0 -758
  430. package/dist/chunk-VXVLKRU6.js.map +0 -1
  431. package/dist/chunk-WWUU5ETI.js +0 -163
  432. package/dist/chunk-WWUU5ETI.js.map +0 -1
  433. package/dist/chunk-XE4OXN2W.js +0 -10
  434. package/dist/chunk-XE4OXN2W.js.map +0 -1
  435. package/dist/chunk-XOJORS75.js +0 -1853
  436. package/dist/chunk-XOJORS75.js.map +0 -1
  437. package/dist/chunk-YMZEUTD2.js +0 -110
  438. package/dist/chunk-YMZEUTD2.js.map +0 -1
  439. package/dist/chunk-Z77BTSOK.js +0 -617
  440. package/dist/chunk-Z77BTSOK.js.map +0 -1
  441. package/dist/chunk-ZZK3WEDI.js +0 -181
  442. package/dist/chunk-ZZK3WEDI.js.map +0 -1
  443. package/dist/client-CCXpAZ2r.d.ts +0 -89
  444. package/dist/client-DSI_760t.d.ts +0 -36
  445. package/dist/client-JU6T3UPB.js +0 -11
  446. package/dist/client-JU6T3UPB.js.map +0 -1
  447. package/dist/dist-2X4Q7PJA.js +0 -1491
  448. package/dist/dist-2X4Q7PJA.js.map +0 -1
  449. package/dist/env-4UWSUS64.js +0 -4
  450. package/dist/env-4UWSUS64.js.map +0 -1
  451. package/dist/graph-emitter-r5TylDBm.d.ts +0 -47
  452. package/dist/graphql-CMHMQjvd.d.ts +0 -23
  453. package/dist/i18n-Qm2AkPC-.d.ts +0 -33
  454. package/dist/index--yvpa6ay.d.ts +0 -83
  455. package/dist/index-4gKQKZ2B.d.ts +0 -71
  456. package/dist/index-5x0XMKXN.d.ts +0 -149
  457. package/dist/index-B70b5mYS.d.ts +0 -33
  458. package/dist/index-B8KrxO4j.d.ts +0 -755
  459. package/dist/index-BOuDKnqD.d.ts +0 -201
  460. package/dist/index-BTMt4OjA.d.ts +0 -201
  461. package/dist/index-BejbszA7.d.ts +0 -39
  462. package/dist/index-BkeOYZye.d.ts +0 -198
  463. package/dist/index-BuAj5nXg.d.ts +0 -83
  464. package/dist/index-BvkVcW8I.d.ts +0 -349
  465. package/dist/index-CWmH_-RZ.d.ts +0 -247
  466. package/dist/index-CbgWNcus.d.ts +0 -258
  467. package/dist/index-CmfPeQza.d.ts +0 -166
  468. package/dist/index-CmpG-zak.d.ts +0 -607
  469. package/dist/index-CoMKgL-p.d.ts +0 -12
  470. package/dist/index-D8HGwglK.d.ts +0 -541
  471. package/dist/index-DCaVm66D.d.ts +0 -1101
  472. package/dist/index-DE2w7E0d.d.ts +0 -83
  473. package/dist/index-DSOpj8DI.d.ts +0 -17
  474. package/dist/index-DW9q22GH.d.ts +0 -75
  475. package/dist/index-DnjJ9CwI.d.ts +0 -347
  476. package/dist/index-DwMJZ8PP.d.ts +0 -317
  477. package/dist/index-PaojfSdd.d.ts +0 -71
  478. package/dist/index-aHtYvc3i.d.ts +0 -284
  479. package/dist/index-e_18DzAg.d.ts +0 -18
  480. package/dist/index-ffmipXSA.d.ts +0 -55
  481. package/dist/index-joONjwLt.d.ts +0 -33
  482. package/dist/index-kssw5ziY.d.ts +0 -250
  483. package/dist/index-lFffh5-G.d.ts +0 -125
  484. package/dist/index-pxYge_6k.d.ts +0 -79
  485. package/dist/layer-Cv9vSwBx.d.ts +0 -70
  486. package/dist/pino-logger-H4HPW5P6.js +0 -5
  487. package/dist/pino-logger-H4HPW5P6.js.map +0 -1
  488. package/dist/prisma-extension-gYhYriA0.d.ts +0 -174
  489. package/dist/sdk-L75WWUP3.js +0 -156
  490. package/dist/sdk-L75WWUP3.js.map +0 -1
  491. package/dist/shutdown-registry-CW9LryO8.d.ts +0 -10
  492. package/dist/types-Bo2wkjSP.d.ts +0 -35
  493. package/dist/types-DVpvrAhd.d.ts +0 -71
  494. package/dist/types-DgJ4lDYA.d.ts +0 -108
  495. package/dist/types-USOv09qy.d.ts +0 -327
  496. package/dist/workspace-guard-NXVYYBVJ.js +0 -5
  497. package/dist/workspace-guard-NXVYYBVJ.js.map +0 -1
@@ -1,1507 +0,0 @@
1
- import { ValidationError, PermissionDeniedError } from './chunk-I3KOWRT3.js';
2
- import { DEFAULT_GATEWAY_ROUTING, DEFAULT_LAYER_RESOURCES } from './chunk-5CAFHK2Z.js';
3
- import { logger } from './chunk-RU266375.js';
4
- import { __name } from './chunk-XE4OXN2W.js';
5
- import { GraphQLError } from 'graphql';
6
- import { GraphQLClient } from 'graphql-request';
7
-
8
- var LRUCache = class LRUCache2 {
9
- static {
10
- __name(this, "LRUCache");
11
- }
12
- cache = /* @__PURE__ */ new Map();
13
- maxSize;
14
- ttl;
15
- constructor(maxSize, ttl) {
16
- this.maxSize = maxSize;
17
- this.ttl = ttl;
18
- }
19
- get(key) {
20
- const entry = this.cache.get(key);
21
- if (!entry) return void 0;
22
- if (Date.now() > entry.expiry) {
23
- this.cache.delete(key);
24
- return void 0;
25
- }
26
- this.cache.delete(key);
27
- this.cache.set(key, entry);
28
- return entry.value;
29
- }
30
- set(key, value) {
31
- if (this.cache.size >= this.maxSize) {
32
- const firstKey = this.cache.keys().next().value;
33
- if (firstKey !== void 0) {
34
- this.cache.delete(firstKey);
35
- }
36
- }
37
- this.cache.set(key, {
38
- value,
39
- expiry: Date.now() + this.ttl
40
- });
41
- }
42
- clear() {
43
- this.cache.clear();
44
- }
45
- /**
46
- * Invalidate all entries whose key starts with the given prefix.
47
- * Used to evict all cached permissions for a specific actor.
48
- */
49
- invalidateByPrefix(prefix) {
50
- let count = 0;
51
- for (const key of [
52
- ...this.cache.keys()
53
- ]) {
54
- if (typeof key === "string" && key.startsWith(prefix)) {
55
- this.cache.delete(key);
56
- count++;
57
- }
58
- }
59
- return count;
60
- }
61
- };
62
- var RBACClient = class RBACClient2 {
63
- static {
64
- __name(this, "RBACClient");
65
- }
66
- client;
67
- cache;
68
- config;
69
- /**
70
- * Per-request timeout (ms) for the RBAC service call.
71
- * Bounds each checkPermission so a slow/cold RBAC gateway cannot hang the
72
- * request indefinitely (previously the federation gateway killed the hung
73
- * call at ~90s → 502). Defaults to 5000ms (matches RBACDirectiveConfig.timeout).
74
- */
75
- timeoutMs;
76
- constructor(config) {
77
- this.client = new GraphQLClient(config.rbacServiceUrl);
78
- this.timeoutMs = config.timeout ?? 5e3;
79
- this.config = {
80
- failClosed: config.failClosed !== false,
81
- layer: config.layer || "wspace"
82
- };
83
- if (config.enableCaching !== false) {
84
- this.cache = new LRUCache(
85
- config.cacheMaxSize || 1e4,
86
- config.cacheTTL || 6e4
87
- // 1 minute
88
- );
89
- }
90
- }
91
- /**
92
- * Parse permission string into resourceType and action
93
- * @example "project:read" => { resourceType: "project", action: "read" }
94
- * @example "rbac:role:create" => { resourceType: "rbac", action: "role:create" }
95
- */
96
- parsePermission(permission) {
97
- const colonIndex = permission.indexOf(":");
98
- if (colonIndex === -1) {
99
- return {
100
- resourceType: permission,
101
- action: "read"
102
- };
103
- }
104
- return {
105
- resourceType: permission.substring(0, colonIndex),
106
- action: permission.substring(colonIndex + 1)
107
- };
108
- }
109
- /**
110
- * Check if actor has permission using the new PBAC checkPermission query
111
- */
112
- async checkPermission(actorId, actorType, scopeId, permission, resourceId) {
113
- const { resourceType, action } = this.parsePermission(permission);
114
- const cacheKey = `${actorId}:${actorType}:${scopeId}:${resourceType}:${action}:${resourceId || ""}`;
115
- if (this.cache) {
116
- const cached = this.cache.get(cacheKey);
117
- if (cached !== void 0) {
118
- logger.debug("[RBAC Directive] Cache hit", {
119
- actorId,
120
- actorType,
121
- scopeId,
122
- resourceType,
123
- action,
124
- resourceId,
125
- hasPermission: cached
126
- });
127
- return {
128
- hasPermission: cached,
129
- reason: cached ? "Cached: Permission granted" : "Cached: Permission denied"
130
- };
131
- }
132
- }
133
- const CHECK_PERMISSION_QUERY = `
134
- query CheckPermission($input: PermissionCheckInput!) {
135
- checkPermission(input: $input) {
136
- allowed
137
- decisionPath
138
- roleName
139
- roleLevel
140
- overrideType
141
- }
142
- }
143
- `;
144
- const input = {
145
- actorId,
146
- actorType,
147
- scopeId,
148
- resourceType,
149
- action,
150
- resourceId
151
- };
152
- try {
153
- logger.debug("[RBAC Directive] Checking permission via RBAC service (PBAC)", {
154
- input,
155
- layer: this.config.layer
156
- });
157
- const result = await this.client.request({
158
- document: CHECK_PERMISSION_QUERY,
159
- variables: {
160
- input
161
- },
162
- signal: AbortSignal.timeout(this.timeoutMs)
163
- });
164
- const hasPermission = result.checkPermission.allowed;
165
- const decisionPath = result.checkPermission.decisionPath;
166
- if (this.cache) {
167
- this.cache.set(cacheKey, hasPermission);
168
- }
169
- logger.debug("[RBAC Directive] Permission check result", {
170
- actorId,
171
- resourceType,
172
- action,
173
- hasPermission,
174
- decisionPath
175
- });
176
- return {
177
- hasPermission,
178
- reason: decisionPath
179
- };
180
- } catch (error) {
181
- logger.error("[RBAC Directive] RBAC service error", {
182
- error,
183
- input,
184
- layer: this.config.layer
185
- });
186
- if (this.config.failClosed) {
187
- return {
188
- hasPermission: false,
189
- reason: "RBAC service unavailable - access denied (fail-closed)"
190
- };
191
- } else {
192
- logger.warn("[RBAC Directive] Fail-open mode: allowing access despite RBAC error");
193
- return {
194
- hasPermission: true,
195
- reason: "RBAC service unavailable - access allowed (fail-open)"
196
- };
197
- }
198
- }
199
- }
200
- /**
201
- * Clear permission cache (useful for testing or when permissions change)
202
- */
203
- clearCache() {
204
- this.cache?.clear();
205
- }
206
- /**
207
- * Invalidate cached permissions for a specific actor.
208
- * Call this when an actor's roles or permissions change to avoid stale cache hits.
209
- *
210
- * @param actorId - The actor whose cached permissions should be evicted
211
- * @returns Number of cache entries invalidated
212
- */
213
- invalidateForActor(actorId) {
214
- if (!this.cache) return 0;
215
- const count = this.cache.invalidateByPrefix(`${actorId}:`);
216
- if (count > 0) {
217
- logger.info("[RBAC Directive] Invalidated cached permissions for actor", {
218
- actorId,
219
- entriesRemoved: count
220
- });
221
- }
222
- return count;
223
- }
224
- /**
225
- * Get the configured layer
226
- */
227
- getLayer() {
228
- return this.config.layer;
229
- }
230
- };
231
- function getValueAtPath(obj, path) {
232
- const parts = path.split(".");
233
- let current = obj;
234
- for (const part of parts) {
235
- if (current === null || current === void 0) {
236
- return void 0;
237
- }
238
- if (typeof current !== "object") {
239
- return void 0;
240
- }
241
- current = current[part];
242
- }
243
- return typeof current === "string" ? current : void 0;
244
- }
245
- __name(getValueAtPath, "getValueAtPath");
246
- function getDirectiveArgument(directive, name) {
247
- const arg = directive.arguments?.find((a) => a.name.value === name);
248
- if (arg && arg.value.kind === "StringValue") {
249
- return arg.value.value;
250
- }
251
- return void 0;
252
- }
253
- __name(getDirectiveArgument, "getDirectiveArgument");
254
- function parseFieldArguments(field, variableValues) {
255
- const args = {};
256
- for (const arg of field.arguments || []) {
257
- const argName = arg.name.value;
258
- const argValue = arg.value;
259
- if (argValue.kind === "Variable") {
260
- args[argName] = variableValues[argValue.name.value];
261
- } else if (argValue.kind === "ObjectValue") {
262
- args[argName] = parseObjectValue(argValue, variableValues);
263
- } else if ("value" in argValue) {
264
- args[argName] = argValue.value;
265
- }
266
- }
267
- return args;
268
- }
269
- __name(parseFieldArguments, "parseFieldArguments");
270
- function parseObjectValue(obj, variableValues) {
271
- const result = {};
272
- for (const field of obj.fields || []) {
273
- const fieldName = field.name.value;
274
- const fieldValue = field.value;
275
- if (fieldValue.kind === "Variable") {
276
- result[fieldName] = variableValues[fieldValue.name.value];
277
- } else if (fieldValue.kind === "ObjectValue") {
278
- result[fieldName] = parseObjectValue(fieldValue, variableValues);
279
- } else if ("value" in fieldValue) {
280
- result[fieldName] = fieldValue.value;
281
- }
282
- }
283
- return result;
284
- }
285
- __name(parseObjectValue, "parseObjectValue");
286
- function toActorId(userId) {
287
- return userId;
288
- }
289
- __name(toActorId, "toActorId");
290
- function sanitizeHeadersForLogging(headers) {
291
- const sanitized = {};
292
- for (const [key, value] of Object.entries(headers)) {
293
- const lowerKey = key.toLowerCase();
294
- if (lowerKey.includes("auth") || lowerKey.includes("token") || lowerKey.includes("password") || lowerKey.includes("secret") || lowerKey.includes("key") || lowerKey.includes("credential")) {
295
- sanitized[key] = "***REDACTED***";
296
- } else {
297
- sanitized[key] = value;
298
- }
299
- }
300
- return sanitized;
301
- }
302
- __name(sanitizeHeadersForLogging, "sanitizeHeadersForLogging");
303
- function getHeader(context, key) {
304
- if (context.request?.headers) {
305
- if (typeof context.request.headers.get === "function") {
306
- const value2 = context.request.headers.get(key);
307
- if (value2) return value2;
308
- }
309
- const requestHeaders = context.request.headers;
310
- const value = requestHeaders[key];
311
- if (value) return value;
312
- }
313
- if (context.headers) {
314
- const contextHeaders = context.headers;
315
- const value = contextHeaders[key];
316
- if (value) return value;
317
- }
318
- return void 0;
319
- }
320
- __name(getHeader, "getHeader");
321
- function validateBypassTimestamp(timestamp) {
322
- try {
323
- const timestampMs = parseInt(timestamp, 10);
324
- if (isNaN(timestampMs)) {
325
- return false;
326
- }
327
- const now = Date.now();
328
- const age = now - timestampMs;
329
- const MAX_AGE = 60 * 1e3;
330
- if (age > MAX_AGE || age < 0) {
331
- logger.warn("[RBAC Directive] Stale bypass timestamp", {
332
- age,
333
- timestamp: timestampMs,
334
- now
335
- });
336
- return false;
337
- }
338
- return true;
339
- } catch (error) {
340
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
341
- logger.warn("[RBAC Directive] Invalid bypass timestamp format", {
342
- timestamp,
343
- error: errorMessage
344
- });
345
- return false;
346
- }
347
- }
348
- __name(validateBypassTimestamp, "validateBypassTimestamp");
349
- function checkBypassHeaders(context) {
350
- const actorType = getHeader(context, "x-actor-type");
351
- const actorId = getHeader(context, "x-actor-id");
352
- if (actorType === "service" || actorType === "super_admin") {
353
- logger.debug("[RBAC Directive] Actor type bypass - service/super_admin", {
354
- actorType,
355
- actorId
356
- });
357
- return {
358
- shouldBypass: true
359
- };
360
- }
361
- logger.debug("[RBAC Directive] Checking bypass headers - context structure", {
362
- hasRequest: !!context.request,
363
- hasRequestHeaders: !!context.request?.headers,
364
- hasContextHeaders: !!context.headers,
365
- requestHeadersType: context.request?.headers ? typeof context.request.headers : "undefined",
366
- contextHeadersType: context.headers ? typeof context.headers : "undefined",
367
- actorType,
368
- actorId
369
- });
370
- const allHeaders = {};
371
- if (context.request?.headers) {
372
- if (typeof context.request.headers.get === "function") {
373
- logger.debug("[RBAC Directive] Headers object has get method");
374
- } else {
375
- const headers = context.request.headers;
376
- Object.keys(headers).forEach((key) => {
377
- const value = headers[key];
378
- if (value) allHeaders[key] = value;
379
- });
380
- const sanitizedHeaders = sanitizeHeadersForLogging(allHeaders);
381
- logger.debug("[RBAC Directive] Request headers (plain object)", {
382
- headers: sanitizedHeaders
383
- });
384
- }
385
- }
386
- if (context.headers) {
387
- const headers = context.headers;
388
- const contextHeadersObj = {};
389
- Object.keys(headers).forEach((key) => {
390
- const value = headers[key];
391
- if (value) contextHeadersObj[key] = value;
392
- });
393
- const sanitizedHeaders = sanitizeHeadersForLogging(contextHeadersObj);
394
- logger.debug("[RBAC Directive] Context headers", {
395
- headers: sanitizedHeaders
396
- });
397
- }
398
- const bypassHeader = getHeader(context, "x-rbac-bypass");
399
- const bypassSource = getHeader(context, "x-bypass-source");
400
- const bypassTimestamp = getHeader(context, "x-bypass-timestamp");
401
- logger.debug("[RBAC Directive] Extracted bypass headers", {
402
- bypassHeader,
403
- bypassSource,
404
- bypassTimestamp
405
- });
406
- const bypassAttempted = !!(bypassHeader || bypassSource || bypassTimestamp);
407
- if (!bypassHeader || !bypassSource || !bypassTimestamp) {
408
- logger.debug("[RBAC Directive] Missing bypass headers - bypass NOT granted", {
409
- hasRbacBypass: !!bypassHeader,
410
- hasBypassSource: !!bypassSource,
411
- hasBypassTimestamp: !!bypassTimestamp
412
- });
413
- if (bypassAttempted) {
414
- return {
415
- shouldBypass: false,
416
- bypassContext: {
417
- bypassAttempted: true,
418
- bypassSource,
419
- bypassTimestamp,
420
- bypassFailureReason: "Missing required bypass headers"
421
- }
422
- };
423
- }
424
- return {
425
- shouldBypass: false
426
- };
427
- }
428
- if (bypassHeader !== "true") {
429
- logger.warn("[RBAC Directive] Invalid bypass header value", {
430
- value: bypassHeader
431
- });
432
- return {
433
- shouldBypass: false,
434
- bypassContext: {
435
- bypassAttempted: true,
436
- bypassSource,
437
- bypassTimestamp,
438
- bypassFailureReason: `Invalid bypass header value: ${bypassHeader}`
439
- }
440
- };
441
- }
442
- if (!validateBypassTimestamp(bypassTimestamp)) {
443
- logger.warn("[RBAC Directive] Bypass rejected: stale timestamp", {
444
- source: bypassSource,
445
- timestamp: bypassTimestamp
446
- });
447
- return {
448
- shouldBypass: false,
449
- bypassContext: {
450
- bypassAttempted: true,
451
- bypassSource,
452
- bypassTimestamp,
453
- bypassFailureReason: "Stale or invalid timestamp (replay attack prevention)"
454
- }
455
- };
456
- }
457
- logger.debug("[RBAC Directive] Valid bypass headers detected", {
458
- source: bypassSource,
459
- timestamp: bypassTimestamp
460
- });
461
- return {
462
- shouldBypass: true
463
- };
464
- }
465
- __name(checkBypassHeaders, "checkBypassHeaders");
466
- function verifyAuthentication(contextValue, fieldName, permission) {
467
- const ctx = contextValue;
468
- const user = ctx.user ?? (ctx.actor?.id ? {
469
- id: ctx.actor.id,
470
- email: ctx.actor.email,
471
- workspace_id: ctx.workspace?.id
472
- } : ctx.actorId ? {
473
- id: ctx.actorId,
474
- workspace_id: ctx.workspace?.id
475
- } : void 0);
476
- logger.debug("[RBAC Directive] Checking authentication", {
477
- hasUser: !!user,
478
- userId: user?.id,
479
- fieldName
480
- });
481
- if (!user?.id) {
482
- logger.warn("[RBAC Directive] Authentication required but user not found", {
483
- fieldName,
484
- permission
485
- });
486
- throw new GraphQLError("Authentication required", {
487
- extensions: {
488
- code: "UNAUTHENTICATED",
489
- field: fieldName,
490
- permission
491
- }
492
- });
493
- }
494
- return user;
495
- }
496
- __name(verifyAuthentication, "verifyAuthentication");
497
- async function resolveResourceId(resourceIdField, selection, variableValues, config, _rbacClient, _ctx, permission, fieldName) {
498
- let resourceId;
499
- const fieldArgs = parseFieldArguments(selection, variableValues || {});
500
- if (resourceIdField) {
501
- resourceId = getValueAtPath(fieldArgs, resourceIdField);
502
- if (!resourceId) {
503
- logger.error("[RBAC Directive] Resource ID not found at specified path", {
504
- resourceIdField,
505
- fieldName,
506
- permission,
507
- availableArgs: Object.keys(fieldArgs)
508
- });
509
- throw new GraphQLError(`Resource ID not found at specified path "${resourceIdField}" for permission "${permission}"`, {
510
- extensions: {
511
- code: "INVALID_RESOURCE_CONFIGURATION",
512
- field: fieldName,
513
- permission,
514
- resourceIdField,
515
- hint: `Check that the field path "${resourceIdField}" exists in your arguments`
516
- }
517
- });
518
- }
519
- logger.debug("[RBAC Directive] Using explicit resourceIdField", {
520
- resourceIdField,
521
- resourceId,
522
- fieldName
523
- });
524
- } else {
525
- const defaultPaths = [
526
- "id",
527
- "input.id"
528
- ];
529
- for (const path of defaultPaths) {
530
- resourceId = getValueAtPath(fieldArgs, path);
531
- if (resourceId) {
532
- logger.debug("[RBAC Directive] Auto-resolved resource ID from convention", {
533
- path,
534
- resourceId,
535
- fieldName,
536
- permission
537
- });
538
- break;
539
- }
540
- }
541
- if (!resourceId) {
542
- const contextWorkspaceId = _ctx.workspace?.id;
543
- if (contextWorkspaceId) {
544
- resourceId = contextWorkspaceId;
545
- logger.debug("[RBAC Directive] Using workspace ID from context headers", {
546
- resourceId,
547
- fieldName,
548
- permission
549
- });
550
- } else {
551
- logger.error("[RBAC Directive] No resource ID available for permission check", {
552
- permission,
553
- fieldName,
554
- triedPaths: defaultPaths,
555
- availableArgs: Object.keys(fieldArgs)
556
- });
557
- throw new GraphQLError(`Cannot check permission "${permission}": No resource ID available. Tried default paths: ${defaultPaths.join(", ")}. Either provide one of these fields in your arguments, specify resourceIdField in the directive, or pass x-workspace-id header.`, {
558
- extensions: {
559
- code: "INVALID_RESOURCE_CONFIGURATION",
560
- field: fieldName,
561
- permission,
562
- triedPaths: defaultPaths,
563
- hint: 'Add resourceIdField parameter to @requiresPermission directive (e.g., resourceIdField: "input.workspaceId") or pass x-workspace-id header'
564
- }
565
- });
566
- }
567
- }
568
- }
569
- if (resourceId && config.resourceResolver) {
570
- const resolved = await config.resourceResolver(resourceId, permission.split(":")[0]);
571
- if (!resolved) {
572
- logger.warn("[RBAC Directive] Custom resource resolver returned null", {
573
- originalResourceId: resourceId,
574
- permission,
575
- fieldName
576
- });
577
- throw new GraphQLError("Resource not found or invalid", {
578
- extensions: {
579
- code: "FORBIDDEN",
580
- field: fieldName,
581
- permission,
582
- resourceId,
583
- hint: "Resource resolver could not resolve the resource ID"
584
- }
585
- });
586
- }
587
- logger.debug("[RBAC Directive] Custom resource resolver applied", {
588
- originalResourceId: resourceId,
589
- resolvedResourceId: resolved,
590
- fieldName
591
- });
592
- return resolved;
593
- }
594
- return resourceId;
595
- }
596
- __name(resolveResourceId, "resolveResourceId");
597
- function extractScopeId(ctx, layer) {
598
- if (layer === "wspace") {
599
- const workspaceId = getHeader(ctx, "x-workspace-id") || ctx.workspace?.id;
600
- if (!workspaceId) {
601
- throw new GraphQLError("Workspace ID required for workspace-layer RBAC", {
602
- extensions: {
603
- code: "BAD_REQUEST",
604
- hint: "Pass x-workspace-id header or ensure workspace context is set"
605
- }
606
- });
607
- }
608
- return workspaceId;
609
- } else {
610
- const tenantId = getHeader(ctx, "x-tenant-id") || ctx.tenant?.id || "global";
611
- return tenantId;
612
- }
613
- }
614
- __name(extractScopeId, "extractScopeId");
615
- function extractActorType(ctx) {
616
- const actorTypeHeader = getHeader(ctx, "x-actor-type");
617
- if (actorTypeHeader) {
618
- const upperType = actorTypeHeader.toUpperCase();
619
- if ([
620
- "USER",
621
- "BOT",
622
- "INTEGRATION",
623
- "DELEGATED_AGENT"
624
- ].includes(upperType)) {
625
- return upperType;
626
- }
627
- }
628
- return "USER";
629
- }
630
- __name(extractActorType, "extractActorType");
631
- async function checkAndEnforcePermission(rbacClient, ctx, actorId, permission, resolvedResourceId, userId, fieldName, bypassContext) {
632
- const layer = rbacClient.getLayer();
633
- const actorType = extractActorType(ctx);
634
- const scopeId = extractScopeId(ctx, layer);
635
- logger.info("[RBAC Directive] Checking permission", {
636
- userId,
637
- actorId,
638
- actorType,
639
- scopeId,
640
- permission,
641
- resourceId: resolvedResourceId,
642
- fieldName,
643
- layer,
644
- bypassAttempted: bypassContext?.bypassAttempted ?? false
645
- });
646
- const { hasPermission, reason } = await rbacClient.checkPermission(actorId, actorType, scopeId, permission, resolvedResourceId);
647
- if (!hasPermission) {
648
- logger.warn("[RBAC Directive] Permission denied", {
649
- userId,
650
- actorType,
651
- scopeId,
652
- permission,
653
- reason,
654
- fieldName,
655
- bypassContext
656
- });
657
- const reasonSuffix = reason ? ` - ${reason}` : "";
658
- const errorMessage = `Forbidden: Missing permission "${permission}"${reasonSuffix}`;
659
- const extensions = {
660
- code: "FORBIDDEN",
661
- permission,
662
- reason,
663
- field: fieldName,
664
- resourceId: resolvedResourceId,
665
- scopeId,
666
- layer
667
- };
668
- if (bypassContext?.bypassAttempted) {
669
- extensions["bypassAttempted"] = true;
670
- extensions["bypassSource"] = bypassContext.bypassSource;
671
- extensions["bypassTimestamp"] = bypassContext.bypassTimestamp;
672
- extensions["bypassFailureReason"] = bypassContext.bypassFailureReason;
673
- }
674
- throw new GraphQLError(errorMessage, {
675
- extensions
676
- });
677
- }
678
- logger.info("[RBAC Directive] Permission granted", {
679
- userId,
680
- permission,
681
- fieldName,
682
- reason
683
- });
684
- }
685
- __name(checkAndEnforcePermission, "checkAndEnforcePermission");
686
- function createRBACDirective(config) {
687
- const skipRbac = process.env["SKIP_RBAC"] === "true" || config.skipRbac === true;
688
- if (skipRbac) {
689
- const isProduction = process.env["NODE_ENV"] === "production";
690
- if (isProduction) {
691
- throw new Error("[RBAC Directive] FATAL: SKIP_RBAC cannot be enabled in production environments. This would bypass all authorization checks and is a critical security vulnerability. Remove SKIP_RBAC=true from your environment configuration.");
692
- }
693
- logger.warn("[RBAC Directive] \u26A0\uFE0F RBAC CHECKS ARE DISABLED (SKIP_RBAC=true) - DO NOT USE IN PRODUCTION!");
694
- return {
695
- async onExecute({ args }) {
696
- const { document } = args;
697
- const operation = document.definitions.find((def) => def.kind === "OperationDefinition");
698
- const operationName = operation?.name?.value || "anonymous";
699
- logger.warn("[RBAC Directive] RBAC check skipped for operation", {
700
- operationName
701
- });
702
- }
703
- };
704
- }
705
- const rbacClient = new RBACClient(config);
706
- return {
707
- // 🔒 CRITICAL: Use onExecute (not onExecuteDone) to block BEFORE execution
708
- async onExecute({ args }) {
709
- logger.debug("[RBAC Directive] onExecute called");
710
- const { schema, document, contextValue, variableValues } = args;
711
- const operation = document.definitions.find((def) => def.kind === "OperationDefinition");
712
- if (!operation) {
713
- logger.debug("[RBAC Directive] No operation definition found, skipping");
714
- return;
715
- }
716
- const typeName = operation.operation === "mutation" ? "Mutation" : "Query";
717
- const type = schema.getType(typeName);
718
- if (!type || !("getFields" in type)) {
719
- logger.debug(`[RBAC Directive] Type ${typeName} not found, skipping`);
720
- return;
721
- }
722
- const fields = type.getFields();
723
- for (const selection of operation.selectionSet.selections) {
724
- if (selection.kind !== "Field") {
725
- continue;
726
- }
727
- const fieldName = selection.name.value;
728
- const fieldDef = fields[fieldName];
729
- if (!fieldDef?.astNode) {
730
- continue;
731
- }
732
- const directive = fieldDef.astNode.directives?.find((d) => d.name.value === "requiresPermission");
733
- if (!directive) {
734
- continue;
735
- }
736
- const permission = getDirectiveArgument(directive, "permission");
737
- const resourceIdField = getDirectiveArgument(directive, "resourceIdField");
738
- if (!permission) {
739
- throw new GraphQLError("Invalid @requiresPermission directive: permission argument is required and must be a string", {
740
- extensions: {
741
- code: "INTERNAL_SERVER_ERROR",
742
- field: fieldName
743
- }
744
- });
745
- }
746
- const ctx = contextValue;
747
- const bypassCheckResult = checkBypassHeaders(ctx);
748
- if (bypassCheckResult.shouldBypass) {
749
- const bypassSource = getHeader(ctx, "x-bypass-source");
750
- const bypassTimestamp = getHeader(ctx, "x-bypass-timestamp");
751
- logger.info("[RBAC Directive] RBAC bypassed for internal service call", {
752
- field: fieldName,
753
- permission,
754
- resource: resourceIdField,
755
- bypassSource,
756
- bypassTimestamp,
757
- operationType: operation.operation
758
- });
759
- continue;
760
- }
761
- const user = verifyAuthentication(contextValue, fieldName, permission);
762
- let resolvedResourceId;
763
- try {
764
- resolvedResourceId = await resolveResourceId(resourceIdField, selection, variableValues, config, rbacClient, ctx, permission, fieldName);
765
- } catch (error) {
766
- if (!resourceIdField) {
767
- logger.debug("[RBAC Directive] No resource ID resolved, checking permission at scope level", {
768
- fieldName,
769
- permission
770
- });
771
- } else {
772
- throw error;
773
- }
774
- }
775
- const actorId = toActorId(user.id);
776
- await checkAndEnforcePermission(rbacClient, ctx, actorId, permission, resolvedResourceId, user.id, fieldName, bypassCheckResult.bypassContext);
777
- }
778
- }
779
- };
780
- }
781
- __name(createRBACDirective, "createRBACDirective");
782
- function buildRBACServiceUrl(layer) {
783
- const routing = DEFAULT_GATEWAY_ROUTING[layer];
784
- const gateway = layer === "wspace" ? routing.internalGateway : routing.crossLayerGateway;
785
- return `http://${gateway.host}:${gateway.port}${gateway.graphqlPath}`;
786
- }
787
- __name(buildRBACServiceUrl, "buildRBACServiceUrl");
788
- function createRBACDirectiveForLayer(layer, config) {
789
- const envPrefix = layer.toUpperCase();
790
- const rbacServiceUrl = config?.rbacServiceUrl || process.env[`${envPrefix}_RBAC_GATEWAY_URL`] || process.env["RBAC_GATEWAY_URL"] || buildRBACServiceUrl(layer);
791
- const rbacLayer = layer;
792
- logger.info("[RBAC Directive] Creating layer-aware RBAC directive", {
793
- layer: rbacLayer,
794
- rbacServiceUrl,
795
- enableCaching: config?.enableCaching ?? true
796
- });
797
- return createRBACDirective({
798
- rbacServiceUrl,
799
- layer: rbacLayer,
800
- enableCaching: config?.enableCaching ?? true,
801
- cacheTTL: config?.cacheTTL,
802
- cacheMaxSize: config?.cacheMaxSize,
803
- timeout: config?.timeout,
804
- failClosed: config?.failClosed,
805
- resourceResolver: config?.resourceResolver,
806
- skipRbac: config?.skipRbac
807
- });
808
- }
809
- __name(createRBACDirectiveForLayer, "createRBACDirectiveForLayer");
810
- function createRBACDirectiveFromEnv(serviceName, config) {
811
- const layer = process.env["SERVICE_LAYER"] || (serviceName.startsWith("global-") ? "global" : "wspace");
812
- return createRBACDirectiveForLayer(layer, config);
813
- }
814
- __name(createRBACDirectiveFromEnv, "createRBACDirectiveFromEnv");
815
-
816
- // src/rbac/index.ts
817
- function createRBACClientFromEnv(options = {}) {
818
- const layer = options.layer ?? (process.env["SERVICE_LAYER"] || "wspace");
819
- const envPrefix = layer.toUpperCase();
820
- const rbacServiceUrl = options.rbacServiceUrl || process.env[`${envPrefix}_RBAC_GATEWAY_URL`] || process.env["RBAC_GATEWAY_URL"] || DEFAULT_LAYER_RESOURCES[layer].rbacGatewayUrl;
821
- return new RBACClient({
822
- rbacServiceUrl,
823
- layer,
824
- failClosed: options.failClosed
825
- });
826
- }
827
- __name(createRBACClientFromEnv, "createRBACClientFromEnv");
828
- var RBACModule = class {
829
- static {
830
- __name(this, "RBACModule");
831
- }
832
- client;
833
- context;
834
- constructor(client, context) {
835
- this.client = client;
836
- this.context = context;
837
- }
838
- /**
839
- * Check if user has permission (returns boolean)
840
- */
841
- async checkPermission(options) {
842
- try {
843
- await this.requirePermission(options);
844
- return true;
845
- } catch {
846
- return false;
847
- }
848
- }
849
- /**
850
- * Require permission (throws if denied)
851
- */
852
- async requirePermission(options) {
853
- if (!options.userId) {
854
- throw new ValidationError("User ID is required");
855
- }
856
- if (!options.action) {
857
- throw new ValidationError("Action is required");
858
- }
859
- if (!options.resourceType) {
860
- throw new ValidationError("Resource type is required");
861
- }
862
- logger.debug("[RBAC] Checking permission", options);
863
- const query = `
864
- query CheckPermission($input: PermissionCheckInput!) {
865
- checkPermission(input: $input) {
866
- allowed
867
- decisionPath
868
- }
869
- }
870
- `;
871
- const variables = {
872
- input: {
873
- actorId: options.userId,
874
- actorType: options.actorType || "USER",
875
- scopeId: options.workspaceId || this.context.workspaceId || this.context.tenantId || "",
876
- resourceType: options.resourceType,
877
- action: options.action,
878
- resourceId: options.resourceId
879
- }
880
- };
881
- const response = options.workspaceId || this.context.workspaceId ? await this.client.query(query, variables, this.context) : await this.client.tenantQuery(query, variables, this.context);
882
- if (!response.checkPermission.allowed) {
883
- throw new PermissionDeniedError(`Permission denied: ${response.checkPermission.decisionPath}`, {
884
- action: options.action,
885
- resourceType: options.resourceType,
886
- resourceId: options.resourceId,
887
- userId: options.userId
888
- });
889
- }
890
- logger.debug("[RBAC] Permission granted", {
891
- ...options,
892
- decisionPath: response.checkPermission.decisionPath
893
- });
894
- }
895
- /**
896
- * Get user roles in workspace
897
- * Uses the new PBAC actorRoleAssignments query
898
- */
899
- async getUserRoles(userId, workspaceId) {
900
- logger.debug("[RBAC] Getting user roles", {
901
- userId,
902
- workspaceId
903
- });
904
- const query = `
905
- query GetActorRoleAssignments($actorId: String!, $scopeId: String!) {
906
- actorRoleAssignments(actorId: $actorId, scopeId: $scopeId) {
907
- id
908
- role {
909
- id
910
- name
911
- description
912
- defaultPermissions {
913
- resourceType
914
- level
915
- }
916
- }
917
- }
918
- }
919
- `;
920
- const variables = {
921
- actorId: userId,
922
- scopeId: workspaceId
923
- };
924
- const contextWithWorkspace = {
925
- ...this.context,
926
- workspaceId
927
- };
928
- const response = await this.client.query(query, variables, contextWithWorkspace);
929
- return response.actorRoleAssignments.map((assignment) => ({
930
- id: assignment.role.id,
931
- name: assignment.role.name,
932
- description: assignment.role.description,
933
- defaultPermissions: assignment.role.defaultPermissions
934
- }));
935
- }
936
- /**
937
- * Assign role to user
938
- * Uses the new PBAC assignRoleToActor mutation
939
- */
940
- async assignRoleToUser(userId, roleId, workspaceId, actorType = "USER") {
941
- logger.debug("[RBAC] Assigning role to user", {
942
- userId,
943
- roleId,
944
- workspaceId,
945
- actorType
946
- });
947
- const mutation = `
948
- mutation AssignRoleToActor($input: AssignRoleInput!) {
949
- assignRoleToActor(input: $input) {
950
- id
951
- actorId
952
- roleId
953
- scopeId
954
- }
955
- }
956
- `;
957
- const variables = {
958
- input: {
959
- actorId: userId,
960
- actorType,
961
- roleId,
962
- scopeId: workspaceId
963
- }
964
- };
965
- const contextWithWorkspace = {
966
- ...this.context,
967
- workspaceId
968
- };
969
- await this.client.query(mutation, variables, contextWithWorkspace);
970
- logger.info("[RBAC] Role assigned to actor", {
971
- userId,
972
- roleId,
973
- workspaceId
974
- });
975
- return true;
976
- }
977
- /**
978
- * Remove role from user
979
- * Uses the new PBAC removeRoleFromActor mutation
980
- * Note: This first finds the assignment ID, then removes it
981
- */
982
- async removeRoleFromUser(userId, roleId, workspaceId) {
983
- logger.debug("[RBAC] Removing role from user", {
984
- userId,
985
- roleId,
986
- workspaceId
987
- });
988
- const contextWithWorkspace = {
989
- ...this.context,
990
- workspaceId
991
- };
992
- const findQuery = `
993
- query FindAssignment($actorId: String!, $scopeId: String!) {
994
- actorRoleAssignments(actorId: $actorId, scopeId: $scopeId) {
995
- id
996
- roleId
997
- }
998
- }
999
- `;
1000
- const findResponse = await this.client.query(findQuery, {
1001
- actorId: userId,
1002
- scopeId: workspaceId
1003
- }, contextWithWorkspace);
1004
- const assignment = findResponse.actorRoleAssignments.find((a) => a.roleId === roleId);
1005
- if (!assignment) {
1006
- logger.warn("[RBAC] No role assignment found to remove", {
1007
- userId,
1008
- roleId,
1009
- workspaceId
1010
- });
1011
- return false;
1012
- }
1013
- const mutation = `
1014
- mutation RemoveRoleFromActor($assignmentId: ID!) {
1015
- removeRoleFromActor(assignmentId: $assignmentId)
1016
- }
1017
- `;
1018
- await this.client.query(mutation, {
1019
- assignmentId: assignment.id
1020
- }, contextWithWorkspace);
1021
- logger.info("[RBAC] Role removed from actor", {
1022
- userId,
1023
- roleId,
1024
- workspaceId,
1025
- assignmentId: assignment.id
1026
- });
1027
- return true;
1028
- }
1029
- /**
1030
- * Create custom role with default permissions
1031
- *
1032
- * Uses the new PBAC createRole mutation and setRoleDefaultPermission for permissions.
1033
- *
1034
- * @param name - Role name
1035
- * @param description - Role description
1036
- * @param defaultPermissions - Array of default permission configurations
1037
- * (e.g., [{ resourceType: 'project', level: 'ADMIN' }])
1038
- * OR legacy permission strings (converted to ADMIN level)
1039
- * @param workspaceId - Workspace ID (scopeId)
1040
- */
1041
- async createRole(name, description, defaultPermissions, workspaceId) {
1042
- logger.debug("[RBAC] Creating role", {
1043
- name,
1044
- workspaceId,
1045
- permissionCount: defaultPermissions.length
1046
- });
1047
- const contextWithWorkspace = {
1048
- ...this.context,
1049
- workspaceId
1050
- };
1051
- const createRoleMutation = `
1052
- mutation CreateRole($input: CreateRoleInput!) {
1053
- createRole(input: $input) {
1054
- id
1055
- name
1056
- description
1057
- defaultPermissions {
1058
- resourceType
1059
- level
1060
- }
1061
- }
1062
- }
1063
- `;
1064
- const createRoleVariables = {
1065
- input: {
1066
- name,
1067
- description,
1068
- scopeId: workspaceId,
1069
- scopeType: "workspace"
1070
- }
1071
- };
1072
- const createResponse = await this.client.query(createRoleMutation, createRoleVariables, contextWithWorkspace);
1073
- const roleId = createResponse.createRole.id;
1074
- logger.info("[RBAC] Role created", {
1075
- name,
1076
- roleId
1077
- });
1078
- if (defaultPermissions.length > 0) {
1079
- logger.debug("[RBAC] Setting default permissions for role", {
1080
- roleId,
1081
- count: defaultPermissions.length
1082
- });
1083
- const normalizedPermissions = defaultPermissions.map((perm) => {
1084
- if (typeof perm === "string") {
1085
- const resourceType = perm.split(":")[0] || perm;
1086
- return {
1087
- resourceType,
1088
- level: "ADMIN"
1089
- };
1090
- }
1091
- return perm;
1092
- });
1093
- const permMap = /* @__PURE__ */ new Map();
1094
- const levelPriority = {
1095
- ADMIN: 4,
1096
- EDITOR: 3,
1097
- VIEWER: 2,
1098
- NONE: 1
1099
- };
1100
- for (const perm of normalizedPermissions) {
1101
- const existing = permMap.get(perm.resourceType);
1102
- if (!existing || levelPriority[perm.level] > levelPriority[existing]) {
1103
- permMap.set(perm.resourceType, perm.level);
1104
- }
1105
- }
1106
- const setPermissionMutation = `
1107
- mutation SetRoleDefaultPermission($input: SetRoleDefaultPermissionInput!) {
1108
- setRoleDefaultPermission(input: $input) {
1109
- id
1110
- defaultPermissions {
1111
- resourceType
1112
- level
1113
- }
1114
- }
1115
- }
1116
- `;
1117
- const failedPermissions = [];
1118
- for (const [resourceType, level] of permMap) {
1119
- try {
1120
- await this.client.query(setPermissionMutation, {
1121
- input: {
1122
- roleId,
1123
- resourceType,
1124
- level
1125
- }
1126
- }, contextWithWorkspace);
1127
- logger.debug("[RBAC] Set default permission", {
1128
- roleId,
1129
- resourceType,
1130
- level
1131
- });
1132
- } catch (error) {
1133
- const errorMsg = error instanceof Error ? error.message : String(error);
1134
- logger.error("[RBAC] Failed to set default permission", {
1135
- roleId,
1136
- resourceType,
1137
- level,
1138
- error: errorMsg
1139
- });
1140
- failedPermissions.push({
1141
- resourceType,
1142
- level,
1143
- error: errorMsg
1144
- });
1145
- }
1146
- }
1147
- if (failedPermissions.length > 0) {
1148
- const failedTypes = failedPermissions.map((p) => p.resourceType).join(", ");
1149
- throw new ValidationError(`Role created but failed to set ${failedPermissions.length} default permission(s): ${failedTypes}. Role ID: ${roleId}. Check logs for details.`);
1150
- }
1151
- logger.info("[RBAC] Default permissions set for role", {
1152
- roleId,
1153
- count: permMap.size
1154
- });
1155
- }
1156
- const roleQuery = `
1157
- query GetRole($id: ID!) {
1158
- role(id: $id) {
1159
- id
1160
- name
1161
- description
1162
- defaultPermissions {
1163
- resourceType
1164
- level
1165
- }
1166
- }
1167
- }
1168
- `;
1169
- const roleResponse = await this.client.query(roleQuery, {
1170
- id: roleId
1171
- }, contextWithWorkspace);
1172
- const role = roleResponse.role || createResponse.createRole;
1173
- return {
1174
- id: role.id,
1175
- name: role.name,
1176
- description: role.description,
1177
- defaultPermissions: role.defaultPermissions
1178
- };
1179
- }
1180
- /**
1181
- * Get all available action definitions (replaces getAvailablePermissions)
1182
- * Returns actions organized by resource type
1183
- */
1184
- async getAvailablePermissions() {
1185
- logger.debug("[RBAC] Getting available action definitions");
1186
- const resourceTypesQuery = `
1187
- query GetResourceTypes {
1188
- resourceTypes
1189
- }
1190
- `;
1191
- const hasWorkspace = !!this.context.workspaceId;
1192
- const resourceTypesResponse = hasWorkspace ? await this.client.query(resourceTypesQuery, {}, this.context) : await this.client.tenantQuery(resourceTypesQuery, {}, this.context);
1193
- const permissions = [];
1194
- const actionsQuery = `
1195
- query GetActionDefinitions($resourceType: String!) {
1196
- actionDefinitions(resourceType: $resourceType) {
1197
- id
1198
- action
1199
- resourceType
1200
- description
1201
- }
1202
- }
1203
- `;
1204
- for (const resourceType of resourceTypesResponse.resourceTypes) {
1205
- const actionsResponse = hasWorkspace ? await this.client.query(actionsQuery, {
1206
- resourceType
1207
- }, this.context) : await this.client.tenantQuery(actionsQuery, {
1208
- resourceType
1209
- }, this.context);
1210
- for (const action of actionsResponse.actionDefinitions) {
1211
- permissions.push({
1212
- id: action.id,
1213
- action: action.action,
1214
- resourceType: action.resourceType,
1215
- description: action.description
1216
- });
1217
- }
1218
- }
1219
- return permissions;
1220
- }
1221
- /**
1222
- * Check multiple permissions at once
1223
- * Uses the new PBAC checkPermissions query
1224
- */
1225
- async checkMultiplePermissions(checks) {
1226
- logger.debug("[RBAC] Checking multiple permissions", {
1227
- count: checks.length
1228
- });
1229
- const query = `
1230
- query CheckPermissions($inputs: [PermissionCheckInput!]!) {
1231
- checkPermissions(inputs: $inputs) {
1232
- allowed
1233
- decisionPath
1234
- }
1235
- }
1236
- `;
1237
- const inputs = checks.map((check) => ({
1238
- actorId: check.userId,
1239
- actorType: check.actorType || "USER",
1240
- scopeId: check.workspaceId || this.context.workspaceId || this.context.tenantId || "",
1241
- resourceType: check.resourceType,
1242
- action: check.action,
1243
- resourceId: check.resourceId
1244
- }));
1245
- const hasWorkspace = checks.some((c) => c.workspaceId) || !!this.context.workspaceId;
1246
- const response = hasWorkspace ? await this.client.query(query, {
1247
- inputs
1248
- }, this.context) : await this.client.tenantQuery(query, {
1249
- inputs
1250
- }, this.context);
1251
- return response.checkPermissions.map((result) => ({
1252
- allowed: result.allowed,
1253
- reason: result.decisionPath
1254
- }));
1255
- }
1256
- /**
1257
- * Get effective permissions for a user in a workspace
1258
- * New method that uses the PBAC effectivePermissions query
1259
- */
1260
- async getEffectivePermissions(userId, workspaceId, actorType = "USER") {
1261
- logger.debug("[RBAC] Getting effective permissions", {
1262
- userId,
1263
- workspaceId,
1264
- actorType
1265
- });
1266
- const query = `
1267
- query EffectivePermissions($actorId: String!, $actorType: ActorType!, $scopeId: String!) {
1268
- effectivePermissions(actorId: $actorId, actorType: $actorType, scopeId: $scopeId) {
1269
- actorId
1270
- scopeId
1271
- permissions {
1272
- resourceType
1273
- level
1274
- allowedActions
1275
- source
1276
- }
1277
- }
1278
- }
1279
- `;
1280
- const variables = {
1281
- actorId: userId,
1282
- actorType,
1283
- scopeId: workspaceId
1284
- };
1285
- const contextWithWorkspace = {
1286
- ...this.context,
1287
- workspaceId
1288
- };
1289
- const response = await this.client.query(query, variables, contextWithWorkspace);
1290
- return response.effectivePermissions;
1291
- }
1292
- /**
1293
- * Initialize workspace roles by cloning system roles
1294
- * New method for workspace initialization
1295
- */
1296
- async initializeWorkspaceRoles(workspaceId, ownerId) {
1297
- logger.debug("[RBAC] Initializing workspace roles", {
1298
- workspaceId,
1299
- ownerId
1300
- });
1301
- const mutation = `
1302
- mutation InitializeWorkspaceRoles($workspaceId: String!, $ownerId: String!) {
1303
- initializeWorkspaceRoles(workspaceId: $workspaceId, ownerId: $ownerId) {
1304
- success
1305
- rolesCreated
1306
- roleNames
1307
- ownerAssigned
1308
- message
1309
- }
1310
- }
1311
- `;
1312
- const contextWithWorkspace = {
1313
- ...this.context,
1314
- workspaceId
1315
- };
1316
- const response = await this.client.query(mutation, {
1317
- workspaceId,
1318
- ownerId
1319
- }, contextWithWorkspace);
1320
- logger.info("[RBAC] Workspace roles initialized", response.initializeWorkspaceRoles);
1321
- return response.initializeWorkspaceRoles;
1322
- }
1323
- /**
1324
- * Update an existing role
1325
- * Uses the new PBAC updateRole mutation
1326
- *
1327
- * @param roleId - Role ID to update
1328
- * @param updates - Fields to update (name, description, priority)
1329
- * @param workspaceId - Workspace ID (scopeId)
1330
- */
1331
- async updateRole(roleId, updates, workspaceId) {
1332
- logger.debug("[RBAC] Updating role", {
1333
- roleId,
1334
- updates,
1335
- workspaceId
1336
- });
1337
- const contextWithWorkspace = {
1338
- ...this.context,
1339
- workspaceId
1340
- };
1341
- const mutation = `
1342
- mutation UpdateRole($id: ID!, $input: UpdateRoleInput!) {
1343
- updateRole(id: $id, input: $input) {
1344
- id
1345
- name
1346
- description
1347
- priority
1348
- defaultPermissions {
1349
- resourceType
1350
- level
1351
- }
1352
- }
1353
- }
1354
- `;
1355
- const response = await this.client.query(mutation, {
1356
- id: roleId,
1357
- input: updates
1358
- }, contextWithWorkspace);
1359
- logger.info("[RBAC] Role updated", {
1360
- roleId,
1361
- name: response.updateRole.name
1362
- });
1363
- return {
1364
- id: response.updateRole.id,
1365
- name: response.updateRole.name,
1366
- description: response.updateRole.description,
1367
- defaultPermissions: response.updateRole.defaultPermissions
1368
- };
1369
- }
1370
- /**
1371
- * Delete a role
1372
- * Uses the new PBAC deleteRole mutation
1373
- *
1374
- * @param roleId - Role ID to delete
1375
- * @param workspaceId - Workspace ID (scopeId)
1376
- * @param reassignToRoleId - Optional role ID to reassign existing actors to
1377
- */
1378
- async deleteRole(roleId, workspaceId, reassignToRoleId) {
1379
- logger.debug("[RBAC] Deleting role", {
1380
- roleId,
1381
- workspaceId,
1382
- reassignToRoleId
1383
- });
1384
- const contextWithWorkspace = {
1385
- ...this.context,
1386
- workspaceId
1387
- };
1388
- const mutation = `
1389
- mutation DeleteRole($id: ID!, $reassignToRoleId: ID) {
1390
- deleteRole(id: $id, reassignToRoleId: $reassignToRoleId)
1391
- }
1392
- `;
1393
- const response = await this.client.query(mutation, {
1394
- id: roleId,
1395
- reassignToRoleId
1396
- }, contextWithWorkspace);
1397
- logger.info("[RBAC] Role deleted", {
1398
- roleId,
1399
- success: response.deleteRole
1400
- });
1401
- return response.deleteRole;
1402
- }
1403
- /**
1404
- * List roles in a workspace
1405
- * Uses the new PBAC roles query
1406
- *
1407
- * @param workspaceId - Workspace ID (scopeId)
1408
- * @param options - Filter and pagination options
1409
- */
1410
- async listRoles(workspaceId, options) {
1411
- logger.debug("[RBAC] Listing roles", {
1412
- workspaceId,
1413
- options
1414
- });
1415
- const contextWithWorkspace = {
1416
- ...this.context,
1417
- workspaceId
1418
- };
1419
- const query = `
1420
- query ListRoles($scopeId: String!, $filter: RoleFilterInput, $pagination: PaginationInput) {
1421
- roles(scopeId: $scopeId, filter: $filter, pagination: $pagination) {
1422
- id
1423
- name
1424
- description
1425
- isSystem
1426
- priority
1427
- defaultPermissions {
1428
- resourceType
1429
- level
1430
- }
1431
- }
1432
- }
1433
- `;
1434
- const variables = {
1435
- scopeId: workspaceId,
1436
- filter: options?.includeSystem !== void 0 ? {
1437
- includeSystem: options.includeSystem
1438
- } : void 0,
1439
- pagination: {
1440
- limit: options?.limit ?? 50,
1441
- offset: options?.offset ?? 0
1442
- }
1443
- };
1444
- const response = await this.client.query(query, variables, contextWithWorkspace);
1445
- logger.debug("[RBAC] Roles listed", {
1446
- workspaceId,
1447
- count: response.roles.length
1448
- });
1449
- return response.roles.map((role) => ({
1450
- id: role.id,
1451
- name: role.name,
1452
- description: role.description,
1453
- defaultPermissions: role.defaultPermissions
1454
- }));
1455
- }
1456
- /**
1457
- * Get a specific role by ID
1458
- * Uses the new PBAC role query
1459
- *
1460
- * @param roleId - Role ID
1461
- * @param workspaceId - Workspace ID (scopeId)
1462
- */
1463
- async getRole(roleId, workspaceId) {
1464
- logger.debug("[RBAC] Getting role", {
1465
- roleId,
1466
- workspaceId
1467
- });
1468
- const contextWithWorkspace = {
1469
- ...this.context,
1470
- workspaceId
1471
- };
1472
- const query = `
1473
- query GetRole($id: ID!) {
1474
- role(id: $id) {
1475
- id
1476
- name
1477
- description
1478
- isSystem
1479
- priority
1480
- defaultPermissions {
1481
- resourceType
1482
- level
1483
- }
1484
- }
1485
- }
1486
- `;
1487
- const response = await this.client.query(query, {
1488
- id: roleId
1489
- }, contextWithWorkspace);
1490
- if (!response.role) {
1491
- logger.debug("[RBAC] Role not found", {
1492
- roleId
1493
- });
1494
- return null;
1495
- }
1496
- return {
1497
- id: response.role.id,
1498
- name: response.role.name,
1499
- description: response.role.description,
1500
- defaultPermissions: response.role.defaultPermissions
1501
- };
1502
- }
1503
- };
1504
-
1505
- export { RBACClient, RBACModule, createRBACClientFromEnv, createRBACDirective, createRBACDirectiveForLayer, createRBACDirectiveFromEnv };
1506
- //# sourceMappingURL=chunk-A6DE32ZS.js.map
1507
- //# sourceMappingURL=chunk-A6DE32ZS.js.map