@webiny/api-core 0.0.0-unstable.9f53ea597d → 0.0.0-unstable.a85ef555b2

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 (452) hide show
  1. package/ApiCoreFeature.d.ts +2 -2
  2. package/ApiCoreFeature.js +35 -5
  3. package/ApiCoreFeature.js.map +1 -1
  4. package/exports/api/tasks.d.ts +1 -0
  5. package/exports/api/tasks.js +1 -1
  6. package/exports/api.d.ts +2 -1
  7. package/exports/api.js +2 -1
  8. package/features/ai/Ai.d.ts +3 -1
  9. package/features/ai/Ai.js +36 -28
  10. package/features/ai/Ai.js.map +1 -1
  11. package/features/ai/AiModelRegistry.d.ts +14 -0
  12. package/features/ai/AiModelRegistry.js +39 -0
  13. package/features/ai/AiModelRegistry.js.map +1 -0
  14. package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
  15. package/features/ai/AiSdkToolHandlerResolver.js +19 -0
  16. package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
  17. package/features/ai/AiSdkTools.d.ts +4 -3
  18. package/features/ai/AiSdkTools.js +11 -9
  19. package/features/ai/AiSdkTools.js.map +1 -1
  20. package/features/ai/AnthropicSdkFactory.js +24 -4
  21. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  22. package/features/ai/DEVELOPERS.md +183 -0
  23. package/features/ai/GoogleSdkFactory.d.ts +10 -0
  24. package/features/ai/GoogleSdkFactory.js +65 -0
  25. package/features/ai/GoogleSdkFactory.js.map +1 -0
  26. package/features/ai/OpenAiSdkFactory.js +67 -11
  27. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  28. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  29. package/features/ai/OpenRouterSdkFactory.js +112 -0
  30. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  31. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  32. package/features/ai/RemoteAiModelCatalog.js +74 -0
  33. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  34. package/features/ai/abstractions.d.ts +102 -7
  35. package/features/ai/abstractions.js +6 -2
  36. package/features/ai/abstractions.js.map +1 -1
  37. package/features/ai/feature.js +10 -0
  38. package/features/ai/feature.js.map +1 -1
  39. package/features/ai/index.d.ts +2 -4
  40. package/features/ai/index.js +1 -1
  41. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  42. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  43. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  44. package/features/dateFormatter/abstractions.d.ts +13 -0
  45. package/features/dateFormatter/abstractions.js +5 -0
  46. package/features/dateFormatter/abstractions.js.map +1 -0
  47. package/features/dateFormatter/feature.d.ts +4 -0
  48. package/features/dateFormatter/feature.js +11 -0
  49. package/features/dateFormatter/feature.js.map +1 -0
  50. package/features/dateFormatter/index.d.ts +3 -0
  51. package/features/dateFormatter/index.js +2 -0
  52. package/features/debugger/Debugger.d.ts +30 -0
  53. package/features/debugger/Debugger.js +142 -0
  54. package/features/debugger/Debugger.js.map +1 -0
  55. package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
  56. package/features/debugger/DebuggerRouteDecorator.js +107 -0
  57. package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
  58. package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
  59. package/features/debugger/GraphQLDebuggerTransport.js +45 -0
  60. package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
  61. package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
  62. package/features/debugger/__tests__/matchNamespace.test.js +68 -0
  63. package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
  64. package/features/debugger/__tests__/serialize.test.d.ts +1 -0
  65. package/features/debugger/__tests__/serialize.test.js +220 -0
  66. package/features/debugger/__tests__/serialize.test.js.map +1 -0
  67. package/features/debugger/abstractions.d.ts +100 -0
  68. package/features/debugger/abstractions.js +6 -0
  69. package/features/debugger/abstractions.js.map +1 -0
  70. package/features/debugger/feature.d.ts +5 -0
  71. package/features/debugger/feature.js +15 -0
  72. package/features/debugger/feature.js.map +1 -0
  73. package/features/debugger/index.d.ts +12 -0
  74. package/features/debugger/index.js +7 -0
  75. package/features/debugger/limits.d.ts +18 -0
  76. package/features/debugger/limits.js +11 -0
  77. package/features/debugger/limits.js.map +1 -0
  78. package/features/debugger/matchNamespace.d.ts +14 -0
  79. package/features/debugger/matchNamespace.js +35 -0
  80. package/features/debugger/matchNamespace.js.map +1 -0
  81. package/features/debugger/parseNamespaceHeader.d.ts +7 -0
  82. package/features/debugger/parseNamespaceHeader.js +16 -0
  83. package/features/debugger/parseNamespaceHeader.js.map +1 -0
  84. package/features/debugger/permissions.d.ts +14 -0
  85. package/features/debugger/permissions.js +8 -0
  86. package/features/debugger/permissions.js.map +1 -0
  87. package/features/debugger/permissionsSchema.d.ts +17 -0
  88. package/features/debugger/permissionsSchema.js +18 -0
  89. package/features/debugger/permissionsSchema.js.map +1 -0
  90. package/features/debugger/serialize.d.ts +11 -0
  91. package/features/debugger/serialize.js +121 -0
  92. package/features/debugger/serialize.js.map +1 -0
  93. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  94. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  95. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  96. package/features/encryption/EncryptionService.d.ts +2 -1
  97. package/features/encryption/EncryptionService.js +11 -4
  98. package/features/encryption/EncryptionService.js.map +1 -1
  99. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  100. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  101. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  102. package/features/encryption/abstractions.d.ts +11 -0
  103. package/features/encryption/abstractions.js +2 -1
  104. package/features/encryption/abstractions.js.map +1 -1
  105. package/features/encryption/index.d.ts +1 -0
  106. package/features/encryption/index.js +1 -0
  107. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  108. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +62 -0
  109. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  110. package/features/hashing/ScryptHasher.d.ts +11 -0
  111. package/features/hashing/ScryptHasher.js +74 -0
  112. package/features/hashing/ScryptHasher.js.map +1 -0
  113. package/features/hashing/abstractions.d.ts +18 -0
  114. package/features/hashing/abstractions.js +5 -0
  115. package/features/hashing/abstractions.js.map +1 -0
  116. package/features/hashing/feature.d.ts +4 -0
  117. package/features/hashing/feature.js +11 -0
  118. package/features/hashing/feature.js.map +1 -0
  119. package/features/hashing/index.d.ts +2 -0
  120. package/features/hashing/index.js +1 -0
  121. package/features/httpClient/HttpClient.d.ts +7 -0
  122. package/features/httpClient/HttpClient.js +72 -0
  123. package/features/httpClient/HttpClient.js.map +1 -0
  124. package/features/httpClient/HttpRequestError.d.ts +10 -0
  125. package/features/httpClient/HttpRequestError.js +13 -0
  126. package/features/httpClient/HttpRequestError.js.map +1 -0
  127. package/features/httpClient/HttpStatusError.d.ts +12 -0
  128. package/features/httpClient/HttpStatusError.js +12 -0
  129. package/features/httpClient/HttpStatusError.js.map +1 -0
  130. package/features/httpClient/abstractions.d.ts +32 -0
  131. package/features/httpClient/abstractions.js +5 -0
  132. package/features/httpClient/abstractions.js.map +1 -0
  133. package/features/httpClient/feature.d.ts +4 -0
  134. package/features/httpClient/feature.js +11 -0
  135. package/features/httpClient/feature.js.map +1 -0
  136. package/features/httpClient/index.d.ts +3 -0
  137. package/features/httpClient/index.js +3 -0
  138. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  139. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  140. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  141. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  142. package/features/keyValueStore/KeyValueStore.js +13 -3
  143. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  144. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  145. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  146. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  147. package/features/keyValueStore/abstractions.d.ts +132 -14
  148. package/features/keyValueStore/abstractions.js.map +1 -1
  149. package/features/keyValueStore/errors.d.ts +29 -0
  150. package/features/keyValueStore/errors.js +49 -1
  151. package/features/keyValueStore/errors.js.map +1 -1
  152. package/features/keyValueStore/index.d.ts +4 -1
  153. package/features/keyValueStore/index.js +1 -1
  154. package/features/publicUrls/NullPublicUrls.d.ts +11 -0
  155. package/features/publicUrls/NullPublicUrls.js +17 -0
  156. package/features/publicUrls/NullPublicUrls.js.map +1 -0
  157. package/features/publicUrls/PublicUrl.d.ts +24 -0
  158. package/features/publicUrls/PublicUrl.js +43 -0
  159. package/features/publicUrls/PublicUrl.js.map +1 -0
  160. package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
  161. package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
  162. package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
  163. package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
  164. package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
  165. package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
  166. package/features/publicUrls/abstractions.d.ts +27 -0
  167. package/features/publicUrls/abstractions.js +5 -0
  168. package/features/publicUrls/abstractions.js.map +1 -0
  169. package/features/publicUrls/feature.d.ts +8 -0
  170. package/features/publicUrls/feature.js +11 -0
  171. package/features/publicUrls/feature.js.map +1 -0
  172. package/features/publicUrls/index.d.ts +3 -0
  173. package/features/publicUrls/index.js +3 -0
  174. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  175. package/features/requestContext/RawAssumePermissions.js +19 -0
  176. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  177. package/features/requestContext/RawAuthToken.d.ts +14 -0
  178. package/features/requestContext/RawAuthToken.js +19 -0
  179. package/features/requestContext/RawAuthToken.js.map +1 -0
  180. package/features/requestContext/RawTenantId.d.ts +14 -0
  181. package/features/requestContext/RawTenantId.js +19 -0
  182. package/features/requestContext/RawTenantId.js.map +1 -0
  183. package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
  184. package/features/requestContext/RequestIdentityLoader.js +26 -0
  185. package/features/requestContext/RequestIdentityLoader.js.map +1 -0
  186. package/features/requestContext/RequestTenantLoader.d.ts +18 -0
  187. package/features/requestContext/RequestTenantLoader.js +52 -0
  188. package/features/requestContext/RequestTenantLoader.js.map +1 -0
  189. package/features/requestContext/abstractions.d.ts +75 -0
  190. package/features/requestContext/abstractions.js +9 -0
  191. package/features/requestContext/abstractions.js.map +1 -0
  192. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  193. package/features/requestContext/extractAssumePermissions.js +32 -0
  194. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  195. package/features/requestContext/feature.d.ts +12 -0
  196. package/features/requestContext/feature.js +19 -0
  197. package/features/requestContext/feature.js.map +1 -0
  198. package/features/requestContext/index.d.ts +4 -0
  199. package/features/requestContext/index.js +3 -0
  200. package/features/security/IdentityContext/IdentityContext.d.ts +4 -3
  201. package/features/security/IdentityContext/IdentityContext.js +9 -6
  202. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  203. package/features/security/IdentityContext/abstractions.d.ts +5 -0
  204. package/features/security/IdentityContext/abstractions.js.map +1 -1
  205. package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
  206. package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
  207. package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
  208. package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
  209. package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
  210. package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
  211. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  212. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  213. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -1
  214. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -1
  215. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  216. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  217. package/features/security/apiKeys/feature.js +4 -0
  218. package/features/security/apiKeys/feature.js.map +1 -1
  219. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  220. package/features/security/apiKeys/shared/schemas.js +2 -2
  221. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  222. package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +12 -3
  223. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +31 -18
  224. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
  225. package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
  226. package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
  227. package/features/security/authorization/AuthorizationContext/feature.js +6 -1
  228. package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
  229. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  230. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  231. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  232. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
  233. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  234. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  235. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  236. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  237. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  238. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  239. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  240. package/features/security/roles/CreateRole/schema.js +1 -1
  241. package/features/security/roles/CreateRole/schema.js.map +1 -1
  242. package/features/security/roles/Installer/RolesInstaller.js +1 -0
  243. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  244. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  245. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  246. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  247. package/features/security/roles/UpdateRole/schema.js +1 -1
  248. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  249. package/features/security/shared/description.d.ts +4 -0
  250. package/features/security/shared/description.js +7 -0
  251. package/features/security/shared/description.js.map +1 -0
  252. package/features/security/shared/index.d.ts +1 -0
  253. package/features/security/shared/index.js +1 -0
  254. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  255. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  256. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  257. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  258. package/features/security/teams/CreateTeam/schema.js +1 -1
  259. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  260. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  261. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  262. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  263. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  264. package/features/security/teams/UpdateTeam/schema.js +1 -1
  265. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  266. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  267. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  268. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  269. package/features/slugify/DefaultSlugify.d.ts +8 -0
  270. package/features/slugify/DefaultSlugify.js +20 -0
  271. package/features/slugify/DefaultSlugify.js.map +1 -0
  272. package/features/slugify/abstractions.d.ts +12 -0
  273. package/features/slugify/abstractions.js +5 -0
  274. package/features/slugify/abstractions.js.map +1 -0
  275. package/features/slugify/feature.d.ts +4 -0
  276. package/features/slugify/feature.js +11 -0
  277. package/features/slugify/feature.js.map +1 -0
  278. package/features/slugify/index.d.ts +3 -0
  279. package/features/slugify/index.js +2 -0
  280. package/features/storageOperations/abstractions.d.ts +21 -0
  281. package/features/storageOperations/abstractions.js +10 -0
  282. package/features/storageOperations/abstractions.js.map +1 -0
  283. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  284. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  285. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  286. package/features/stringFormatter/abstractions.d.ts +11 -0
  287. package/features/stringFormatter/abstractions.js +5 -0
  288. package/features/stringFormatter/abstractions.js.map +1 -0
  289. package/features/stringFormatter/feature.d.ts +4 -0
  290. package/features/stringFormatter/feature.js +13 -0
  291. package/features/stringFormatter/feature.js.map +1 -0
  292. package/features/stringFormatter/index.d.ts +3 -0
  293. package/features/stringFormatter/index.js +2 -0
  294. package/features/task/TaskDefinition/abstractions.d.ts +69 -4
  295. package/features/task/TaskDefinition/abstractions.js +2 -1
  296. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  297. package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
  298. package/features/tenancy/TenantContext/TenantContext.js +13 -8
  299. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  300. package/features/users/shared/types.d.ts +9 -7
  301. package/features/wcp/WcpContext/WcpContext.d.ts +11 -5
  302. package/features/wcp/WcpContext/WcpContext.js +26 -2
  303. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  304. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +10 -69
  305. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +66 -35
  306. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  307. package/features/wcp/WcpContext/feature.d.ts +1 -2
  308. package/features/wcp/WcpContext/feature.js +2 -2
  309. package/features/wcp/WcpContext/feature.js.map +1 -1
  310. package/features/wcp/WcpContext/index.d.ts +0 -1
  311. package/features/wcp/WcpContext/types.d.ts +0 -4
  312. package/features/wcp/WcpFeature.d.ts +1 -1
  313. package/features/wcp/WcpFeature.js +7 -2
  314. package/features/wcp/WcpFeature.js.map +1 -1
  315. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  316. package/features/wcp/WcpLicenseLoader.js +58 -0
  317. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  318. package/features/wcp/WcpLicenseProvider.d.ts +21 -0
  319. package/features/wcp/WcpLicenseProvider.js +14 -0
  320. package/features/wcp/WcpLicenseProvider.js.map +1 -0
  321. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  322. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  323. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  324. package/graphql/ApiCoreSchemaFactory.d.ts +16 -0
  325. package/graphql/ApiCoreSchemaFactory.js +58 -0
  326. package/graphql/ApiCoreSchemaFactory.js.map +1 -0
  327. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
  328. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
  329. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  330. package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
  331. package/graphql/security/NotAuthorizedResponse.js +1 -1
  332. package/graphql/security/NotAuthorizedResponse.js.map +1 -1
  333. package/graphql/security/SecuritySchemaFactory.d.ts +15 -0
  334. package/graphql/security/SecuritySchemaFactory.js +27 -0
  335. package/graphql/security/SecuritySchemaFactory.js.map +1 -0
  336. package/graphql/security/addApiKeySchema.d.ts +2 -0
  337. package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
  338. package/graphql/security/addApiKeySchema.js.map +1 -0
  339. package/graphql/security/addIdentitySchema.d.ts +2 -0
  340. package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
  341. package/graphql/security/addIdentitySchema.js.map +1 -0
  342. package/graphql/security/addRoleSchema.d.ts +2 -0
  343. package/graphql/security/addRoleSchema.js +137 -0
  344. package/graphql/security/addRoleSchema.js.map +1 -0
  345. package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
  346. package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
  347. package/graphql/security/addSecurityBaseSchema.js.map +1 -0
  348. package/graphql/security/addTeamSchema.d.ts +2 -0
  349. package/graphql/security/addTeamSchema.js +157 -0
  350. package/graphql/security/addTeamSchema.js.map +1 -0
  351. package/graphql/system/SystemSchemaFactory.d.ts +10 -0
  352. package/graphql/system/SystemSchemaFactory.js +70 -0
  353. package/graphql/system/SystemSchemaFactory.js.map +1 -0
  354. package/graphql/users/UsersSchemaFactory.d.ts +10 -0
  355. package/graphql/users/UsersSchemaFactory.js +195 -0
  356. package/graphql/users/UsersSchemaFactory.js.map +1 -0
  357. package/graphql/wcp/WcpSchemaFactory.d.ts +10 -0
  358. package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +31 -18
  359. package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
  360. package/idp/JwksCache.d.ts +14 -3
  361. package/idp/JwksCache.js +97 -17
  362. package/idp/JwksCache.js.map +1 -1
  363. package/idp/JwksStoreFeature.d.ts +8 -0
  364. package/idp/JwksStoreFeature.js +11 -0
  365. package/idp/JwksStoreFeature.js.map +1 -0
  366. package/idp/MemoryJwksStore.d.ts +14 -0
  367. package/idp/MemoryJwksStore.js +21 -0
  368. package/idp/MemoryJwksStore.js.map +1 -0
  369. package/idp/OidcJwtIdentityProvider.js +5 -1
  370. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  371. package/idp/abstractions.d.ts +24 -0
  372. package/idp/abstractions.js +2 -1
  373. package/idp/abstractions.js.map +1 -1
  374. package/idp/feature.js +1 -2
  375. package/idp/feature.js.map +1 -1
  376. package/idp/index.d.ts +1 -0
  377. package/idp/index.js +1 -0
  378. package/index.d.ts +3 -1
  379. package/index.js +3 -1
  380. package/package.json +22 -21
  381. package/testing/environment.d.ts +14 -0
  382. package/testing/environment.js +18 -0
  383. package/testing/environment.js.map +1 -0
  384. package/types/core.d.ts +17 -5
  385. package/types/security.d.ts +0 -6
  386. package/types/tenancy.d.ts +0 -17
  387. package/types/users.d.ts +2 -16
  388. package/createApiCore.d.ts +0 -7
  389. package/createApiCore.js +0 -26
  390. package/createApiCore.js.map +0 -1
  391. package/graphql/security/apiKey.gql.d.ts +0 -4
  392. package/graphql/security/apiKey.gql.js.map +0 -1
  393. package/graphql/security/base.gql.d.ts +0 -4
  394. package/graphql/security/base.gql.js.map +0 -1
  395. package/graphql/security/identity.gql.d.ts +0 -4
  396. package/graphql/security/identity.gql.js.map +0 -1
  397. package/graphql/security/index.d.ts +0 -1
  398. package/graphql/security/index.js +0 -15
  399. package/graphql/security/index.js.map +0 -1
  400. package/graphql/security/role.gql.d.ts +0 -4
  401. package/graphql/security/role.gql.js +0 -106
  402. package/graphql/security/role.gql.js.map +0 -1
  403. package/graphql/security/team.gql.d.ts +0 -4
  404. package/graphql/security/team.gql.js +0 -119
  405. package/graphql/security/team.gql.js.map +0 -1
  406. package/graphql/system/createSystemGraphQL.d.ts +0 -2
  407. package/graphql/system/createSystemGraphQL.js +0 -54
  408. package/graphql/system/createSystemGraphQL.js.map +0 -1
  409. package/graphql/users/user.gql.d.ts +0 -3
  410. package/graphql/users/user.gql.js +0 -167
  411. package/graphql/users/user.gql.js.map +0 -1
  412. package/graphql/wcp/graphql.d.ts +0 -2
  413. package/graphql/wcp/graphql.js.map +0 -1
  414. package/legacy/security/LegacyContext.d.ts +0 -36
  415. package/legacy/security/LegacyContext.js +0 -152
  416. package/legacy/security/LegacyContext.js.map +0 -1
  417. package/legacy/security/createSecurityContext.d.ts +0 -3
  418. package/legacy/security/createSecurityContext.js +0 -10
  419. package/legacy/security/createSecurityContext.js.map +0 -1
  420. package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
  421. package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
  422. package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
  423. package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
  424. package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
  425. package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
  426. package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
  427. package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
  428. package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
  429. package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
  430. package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
  431. package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
  432. package/legacy/security/plugins/secureHeaders.d.ts +0 -1
  433. package/legacy/security/plugins/secureHeaders.js +0 -30
  434. package/legacy/security/plugins/secureHeaders.js.map +0 -1
  435. package/legacy/tenancy/LegacyContext.d.ts +0 -15
  436. package/legacy/tenancy/LegacyContext.js +0 -57
  437. package/legacy/tenancy/LegacyContext.js.map +0 -1
  438. package/legacy/tenancy/createTenancyContext.d.ts +0 -3
  439. package/legacy/tenancy/createTenancyContext.js +0 -31
  440. package/legacy/tenancy/createTenancyContext.js.map +0 -1
  441. package/legacy/users/LegacyContext.d.ts +0 -13
  442. package/legacy/users/LegacyContext.js +0 -55
  443. package/legacy/users/LegacyContext.js.map +0 -1
  444. package/legacy/users/createAdminUsersContext.d.ts +0 -3
  445. package/legacy/users/createAdminUsersContext.js +0 -12
  446. package/legacy/users/createAdminUsersContext.js.map +0 -1
  447. package/legacy/wcp/LegacyWcpContext.d.ts +0 -38
  448. package/legacy/wcp/LegacyWcpContext.js +0 -99
  449. package/legacy/wcp/LegacyWcpContext.js.map +0 -1
  450. package/legacy/wcp/context.d.ts +0 -5
  451. package/legacy/wcp/context.js +0 -46
  452. package/legacy/wcp/context.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/requestContext/extractAssumePermissions.js","sources":["../../../src/features/requestContext/extractAssumePermissions.ts"],"sourcesContent":["import { RawAssumePermissions } from \"./abstractions.js\";\n\nexport const ASSUME_PERMISSIONS_HEADER = \"x-webiny-assume-permissions\";\n\ntype HeaderValue = string | string[] | undefined;\ntype Headers = Record<string, HeaderValue> | undefined;\n\nfunction readHeader(headers: Headers, name: string): string | null {\n if (!headers) {\n return null;\n }\n\n /*\n * Header names are case-insensitive, and the casing that reaches us depends on the transport\n * and on the client, so match on the lowercased key rather than guessing a spelling. Node's\n * IncomingMessage also hands back an array when a header repeats.\n */\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() !== name) {\n continue;\n }\n\n const value = headers[key];\n if (Array.isArray(value)) {\n return value[0] ?? null;\n }\n\n return value ?? null;\n }\n\n return null;\n}\n\n/**\n * Reads the `x-webiny-assume-permissions` header and parses it into the role or team whose\n * permissions should be previewed. The value is `role:<id>` or `team:<id>`.\n *\n * Anything else parses to null, which leaves the caller's own permissions untouched. Lives in\n * api-core rather than in a transport package so the HTTP transports cannot drift on the format or\n * on header casing.\n */\nexport function extractAssumePermissions(headers: Headers): RawAssumePermissions.Target | null {\n const value = readHeader(headers, ASSUME_PERMISSIONS_HEADER);\n if (!value) {\n return null;\n }\n\n const separatorIndex = value.indexOf(\":\");\n if (separatorIndex < 1) {\n return null;\n }\n\n const type = value.slice(0, separatorIndex).trim();\n const id = value.slice(separatorIndex + 1).trim();\n\n if (id === \"\") {\n return null;\n }\n\n if (type === \"role\") {\n return { type: \"role\", id };\n }\n\n if (type === \"team\") {\n return { type: \"team\", id };\n }\n\n return null;\n}\n"],"names":["ASSUME_PERMISSIONS_HEADER","readHeader","headers","name","key","Object","value","Array","extractAssumePermissions","separatorIndex","type","id"],"mappings":"AAEO,MAAMA,4BAA4B;AAKzC,SAASC,WAAWC,OAAgB,EAAEC,IAAY;IAC9C,IAAI,CAACD,SACD,OAAO;IAQX,KAAK,MAAME,OAAOC,OAAO,IAAI,CAACH,SAAU;QACpC,IAAIE,IAAI,WAAW,OAAOD,MACtB;QAGJ,MAAMG,QAAQJ,OAAO,CAACE,IAAI;QAC1B,IAAIG,MAAM,OAAO,CAACD,QACd,OAAOA,KAAK,CAAC,EAAE,IAAI;QAGvB,OAAOA,SAAS;IACpB;IAEA,OAAO;AACX;AAUO,SAASE,yBAAyBN,OAAgB;IACrD,MAAMI,QAAQL,WAAWC,SAASF;IAClC,IAAI,CAACM,OACD,OAAO;IAGX,MAAMG,iBAAiBH,MAAM,OAAO,CAAC;IACrC,IAAIG,iBAAiB,GACjB,OAAO;IAGX,MAAMC,OAAOJ,MAAM,KAAK,CAAC,GAAGG,gBAAgB,IAAI;IAChD,MAAME,KAAKL,MAAM,KAAK,CAACG,iBAAiB,GAAG,IAAI;IAE/C,IAAIE,AAAO,OAAPA,IACA,OAAO;IAGX,IAAID,AAAS,WAATA,MACA,OAAO;QAAE,MAAM;QAAQC;IAAG;IAG9B,IAAID,AAAS,WAATA,MACA,OAAO;QAAE,MAAM;QAAQC;IAAG;IAG9B,OAAO;AACX"}
@@ -0,0 +1,12 @@
1
+ import type { Container } from "@webiny/di";
2
+ /**
3
+ * Registers the request-context pieces:
4
+ * - RawTenantId / RawAuthToken / RawAssumePermissions: per-request holders that the transport's
5
+ * EXTRACT step writes to.
6
+ * - RequestIdentityLoader / RequestTenantLoader: transport-agnostic LOAD steps that read
7
+ * the holders and set IdentityContext / TenantContext.
8
+ */
9
+ export declare const RequestContextFeature: {
10
+ name: string;
11
+ register(container: Container): void;
12
+ };
@@ -0,0 +1,19 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { RawTenantId } from "./RawTenantId.js";
3
+ import { RawAuthToken } from "./RawAuthToken.js";
4
+ import { RawAssumePermissions } from "./RawAssumePermissions.js";
5
+ import { RequestIdentityLoader } from "./RequestIdentityLoader.js";
6
+ import { RequestTenantLoader } from "./RequestTenantLoader.js";
7
+ const RequestContextFeature = createFeature({
8
+ name: "RequestContext",
9
+ register (container) {
10
+ container.register(RawTenantId).inSingletonScope();
11
+ container.register(RawAuthToken).inSingletonScope();
12
+ container.register(RawAssumePermissions).inSingletonScope();
13
+ container.register(RequestIdentityLoader);
14
+ container.register(RequestTenantLoader);
15
+ }
16
+ });
17
+ export { RequestContextFeature };
18
+
19
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/requestContext/feature.js","sources":["../../../src/features/requestContext/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { Container } from \"@webiny/di\";\nimport { RawTenantId } from \"./RawTenantId.js\";\nimport { RawAuthToken } from \"./RawAuthToken.js\";\nimport { RawAssumePermissions } from \"./RawAssumePermissions.js\";\nimport { RequestIdentityLoader } from \"./RequestIdentityLoader.js\";\nimport { RequestTenantLoader } from \"./RequestTenantLoader.js\";\n\n/**\n * Registers the request-context pieces:\n * - RawTenantId / RawAuthToken / RawAssumePermissions: per-request holders that the transport's\n * EXTRACT step writes to.\n * - RequestIdentityLoader / RequestTenantLoader: transport-agnostic LOAD steps that read\n * the holders and set IdentityContext / TenantContext.\n */\nexport const RequestContextFeature = createFeature({\n name: \"RequestContext\",\n register(container: Container) {\n // Singleton so the value the transport's EXTRACT step sets is the same instance the LOAD\n // establisher reads. Registered per request (RequestContextFeature runs per-request), so it's\n // singleton *within the request container* — a fresh holder per request.\n container.register(RawTenantId).inSingletonScope();\n container.register(RawAuthToken).inSingletonScope();\n container.register(RawAssumePermissions).inSingletonScope();\n container.register(RequestIdentityLoader);\n container.register(RequestTenantLoader);\n }\n});\n"],"names":["RequestContextFeature","createFeature","container","RawTenantId","RawAuthToken","RawAssumePermissions","RequestIdentityLoader","RequestTenantLoader"],"mappings":";;;;;;AAeO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAoB;QAIzBA,UAAU,QAAQ,CAACC,aAAa,gBAAgB;QAChDD,UAAU,QAAQ,CAACE,cAAc,gBAAgB;QACjDF,UAAU,QAAQ,CAACG,sBAAsB,gBAAgB;QACzDH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;IACvB;AACJ"}
@@ -0,0 +1,4 @@
1
+ export { RawTenantId, RawAuthToken, RawAssumePermissions, RequestIdentityLoader, RequestTenantLoader } from "./abstractions.js";
2
+ export { RequestContextFeature } from "./feature.js";
3
+ export { ASSUME_PERMISSIONS_HEADER } from "./extractAssumePermissions.js";
4
+ export { extractAssumePermissions } from "./extractAssumePermissions.js";
@@ -0,0 +1,3 @@
1
+ export { RawAssumePermissions, RawAuthToken, RawTenantId, RequestIdentityLoader, RequestTenantLoader } from "./abstractions.js";
2
+ export { RequestContextFeature } from "./feature.js";
3
+ export { ASSUME_PERMISSIONS_HEADER, extractAssumePermissions } from "./extractAssumePermissions.js";
@@ -2,16 +2,17 @@ import { IdentityContext as Abstraction } from "./abstractions.js";
2
2
  import { Identity } from "./Identity.js";
3
3
  import { AuthorizationContext } from "../authorization/AuthorizationContext/index.js";
4
4
  import type { SecurityPermission } from "../../../types/security.js";
5
- import { WcpContext } from "../../wcp/WcpContext/index.js";
5
+ import { FeatureFlags } from "../../featureFlags/abstractions.js";
6
6
  declare class IdentityContextImpl implements Abstraction.Interface {
7
7
  private authorizationContext;
8
- private wcpContext;
8
+ private featureFlags;
9
9
  private identity;
10
- constructor(authorizationContext: AuthorizationContext.Interface, wcpContext: WcpContext.Interface);
10
+ constructor(authorizationContext: AuthorizationContext.Interface, featureFlags: FeatureFlags.Interface);
11
11
  getIdentity(): Identity;
12
12
  setIdentity(identity: Identity | undefined): void;
13
13
  withIdentity<T>(identity: Identity | undefined, cb: () => Promise<T>): Promise<T>;
14
14
  withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;
15
+ withAuthorization<T>(cb: () => Promise<T>): Promise<T>;
15
16
  isAuthorizationEnabled(): boolean;
16
17
  getPermission<TPermission extends SecurityPermission = SecurityPermission>(name: string): Promise<TPermission | null>;
17
18
  getPermissions<TPermission extends SecurityPermission = SecurityPermission>(name: string): Promise<TPermission[]>;
@@ -5,12 +5,12 @@ import { IdentityContext } from "./abstractions.js";
5
5
  import { AnonymousIdentity } from "./AnonymousIdentity.js";
6
6
  import { AuthorizationContext } from "../authorization/AuthorizationContext/index.js";
7
7
  import { filterOutCustomWbyAppsPermissions } from "../utils/filterOutCustomWbyAppsPermissions.js";
8
- import { WcpContext } from "../../wcp/WcpContext/index.js";
8
+ import { FeatureFlags } from "../../featureFlags/abstractions.js";
9
9
  const identityStorage = new AsyncLocalStorage();
10
10
  class IdentityContextImpl {
11
- constructor(authorizationContext, wcpContext){
11
+ constructor(authorizationContext, featureFlags){
12
12
  this.authorizationContext = authorizationContext;
13
- this.wcpContext = wcpContext;
13
+ this.featureFlags = featureFlags;
14
14
  this.identity = new AnonymousIdentity();
15
15
  }
16
16
  getIdentity() {
@@ -28,6 +28,9 @@ class IdentityContextImpl {
28
28
  withoutAuthorization(cb) {
29
29
  return this.authorizationContext.withoutAuthorization(cb);
30
30
  }
31
+ withAuthorization(cb) {
32
+ return this.authorizationContext.withAuthorization(cb);
33
+ }
31
34
  isAuthorizationEnabled() {
32
35
  return this.authorizationContext.isAuthorizationEnabled();
33
36
  }
@@ -63,8 +66,8 @@ class IdentityContextImpl {
63
66
  return permissions.some((p)=>"*" === p.name);
64
67
  }
65
68
  applyAaclLogic(permissions) {
66
- const aaclEnabled = this.wcpContext.canUseAacl();
67
- const teamsEnabled = this.wcpContext.canUseTeams();
69
+ const aaclEnabled = this.featureFlags.get().isEnabled("advancedAccessControlLayer");
70
+ const teamsEnabled = this.featureFlags.get().isEnabled("advancedAccessControlLayer.teams");
68
71
  if (aaclEnabled) return [
69
72
  ...permissions,
70
73
  {
@@ -80,7 +83,7 @@ const IdentityContext_IdentityContext = createImplementation({
80
83
  implementation: IdentityContextImpl,
81
84
  dependencies: [
82
85
  AuthorizationContext,
83
- WcpContext
86
+ FeatureFlags
84
87
  ]
85
88
  });
86
89
  export { IdentityContext_IdentityContext as IdentityContext };
@@ -1 +1 @@
1
- {"version":3,"file":"features/security/IdentityContext/IdentityContext.js","sources":["../../../../src/features/security/IdentityContext/IdentityContext.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"async_hooks\";\nimport { minimatch } from \"minimatch\";\nimport { createImplementation } from \"@webiny/di\";\nimport { IdentityContext as Abstraction } from \"./abstractions.js\";\nimport { Identity } from \"./Identity.js\";\nimport { AnonymousIdentity } from \"./AnonymousIdentity.js\";\nimport { AuthorizationContext } from \"../authorization/AuthorizationContext/index.js\";\nimport { filterOutCustomWbyAppsPermissions } from \"../utils/filterOutCustomWbyAppsPermissions.js\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport type { AaclPermission } from \"../../wcp/WcpContext/types.js\";\nimport { WcpContext } from \"../../wcp/WcpContext/index.js\";\n\nconst identityStorage = new AsyncLocalStorage<Identity | undefined>();\n\nclass IdentityContextImpl implements Abstraction.Interface {\n private identity: Identity = new AnonymousIdentity();\n\n constructor(\n private authorizationContext: AuthorizationContext.Interface,\n private wcpContext: WcpContext.Interface\n ) {}\n\n // ========================================================================\n // Identity Methods\n // ========================================================================\n\n getIdentity(): Identity {\n // Check for identity override first (from withIdentity())\n const override = identityStorage.getStore();\n if (override !== undefined) {\n return override;\n }\n return this.identity;\n }\n\n setIdentity(identity: Identity | undefined): void {\n // If undefined, set to anonymous identity\n this.identity = identity ?? new AnonymousIdentity();\n\n // Clear permissions cache when identity changes\n this.authorizationContext.clearPermissionsCache();\n }\n\n withIdentity<T>(identity: Identity | undefined, cb: () => Promise<T>): Promise<T> {\n return identityStorage.run(identity, cb);\n }\n\n // ========================================================================\n // Authorization State Methods\n // ========================================================================\n\n withoutAuthorization<T>(cb: () => Promise<T>): Promise<T> {\n return this.authorizationContext.withoutAuthorization(cb);\n }\n\n isAuthorizationEnabled(): boolean {\n return this.authorizationContext.isAuthorizationEnabled();\n }\n\n // ========================================================================\n // Permission Methods\n // ========================================================================\n\n async getPermission<TPermission extends SecurityPermission = SecurityPermission>(\n name: string\n ): Promise<TPermission | null> {\n if (!this.isAuthorizationEnabled()) {\n return { name: \"*\" } as TPermission;\n }\n\n const permissions = await this.listPermissions();\n\n // Try exact match first\n const exactMatch = permissions.find(p => p.name === name);\n if (exactMatch) {\n return exactMatch as TPermission;\n }\n\n // Try pattern matching\n const patternMatch = permissions.find(p => minimatch(name, p.name));\n if (patternMatch) {\n return patternMatch as TPermission;\n }\n\n return null;\n }\n\n async getPermissions<TPermission extends SecurityPermission = SecurityPermission>(\n name: string\n ): Promise<TPermission[]> {\n if (!this.isAuthorizationEnabled()) {\n return [{ name: \"*\" }] as TPermission[];\n }\n\n const permissions = await this.listPermissions();\n\n return permissions.filter(p => {\n if (p.name === name) {\n return true;\n }\n return minimatch(name, p.name);\n }) as TPermission[];\n }\n\n async listPermissions(): Promise<SecurityPermission[]> {\n const permissions = await this.authorizationContext.loadPermissions(this.getIdentity());\n // TODO: extract this into a decorator\n return this.applyAaclLogic(permissions);\n }\n\n async hasFullAccess(): Promise<boolean> {\n const permissions = await this.listPermissions();\n return permissions.some(p => p.name === \"*\");\n }\n\n // ========================================================================\n // Private Helper Methods\n // ========================================================================\n\n private applyAaclLogic(permissions: SecurityPermission[]): SecurityPermission[] {\n const aaclEnabled = this.wcpContext.canUseAacl();\n const teamsEnabled = this.wcpContext.canUseTeams();\n\n if (aaclEnabled) {\n // Add AACL metadata permission\n return [\n ...permissions,\n {\n name: \"aacl\",\n teams: teamsEnabled\n } as AaclPermission\n ];\n }\n\n // If AACL is not enabled, filter out custom Webiny apps permissions\n return filterOutCustomWbyAppsPermissions(permissions);\n }\n}\n\nexport const IdentityContext = createImplementation({\n abstraction: Abstraction,\n implementation: IdentityContextImpl,\n dependencies: [AuthorizationContext, WcpContext]\n});\n"],"names":["identityStorage","AsyncLocalStorage","IdentityContextImpl","authorizationContext","wcpContext","AnonymousIdentity","override","undefined","identity","cb","name","permissions","exactMatch","p","patternMatch","minimatch","aaclEnabled","teamsEnabled","filterOutCustomWbyAppsPermissions","IdentityContext","createImplementation","Abstraction","AuthorizationContext","WcpContext"],"mappings":";;;;;;;;AAYA,MAAMA,kBAAkB,IAAIC;AAE5B,MAAMC;IAGF,YACYC,oBAAoD,EACpDC,UAAgC,CAC1C;aAFUD,oBAAoB,GAApBA;aACAC,UAAU,GAAVA;aAJJ,QAAQ,GAAa,IAAIC;IAK9B;IAMH,cAAwB;QAEpB,MAAMC,WAAWN,gBAAgB,QAAQ;QACzC,IAAIM,AAAaC,WAAbD,UACA,OAAOA;QAEX,OAAO,IAAI,CAAC,QAAQ;IACxB;IAEA,YAAYE,QAA8B,EAAQ;QAE9C,IAAI,CAAC,QAAQ,GAAGA,YAAY,IAAIH;QAGhC,IAAI,CAAC,oBAAoB,CAAC,qBAAqB;IACnD;IAEA,aAAgBG,QAA8B,EAAEC,EAAoB,EAAc;QAC9E,OAAOT,gBAAgB,GAAG,CAACQ,UAAUC;IACzC;IAMA,qBAAwBA,EAAoB,EAAc;QACtD,OAAO,IAAI,CAAC,oBAAoB,CAAC,oBAAoB,CAACA;IAC1D;IAEA,yBAAkC;QAC9B,OAAO,IAAI,CAAC,oBAAoB,CAAC,sBAAsB;IAC3D;IAMA,MAAM,cACFC,IAAY,EACe;QAC3B,IAAI,CAAC,IAAI,CAAC,sBAAsB,IAC5B,OAAO;YAAE,MAAM;QAAI;QAGvB,MAAMC,cAAc,MAAM,IAAI,CAAC,eAAe;QAG9C,MAAMC,aAAaD,YAAY,IAAI,CAACE,CAAAA,IAAKA,EAAE,IAAI,KAAKH;QACpD,IAAIE,YACA,OAAOA;QAIX,MAAME,eAAeH,YAAY,IAAI,CAACE,CAAAA,IAAKE,UAAUL,MAAMG,EAAE,IAAI;QACjE,IAAIC,cACA,OAAOA;QAGX,OAAO;IACX;IAEA,MAAM,eACFJ,IAAY,EACU;QACtB,IAAI,CAAC,IAAI,CAAC,sBAAsB,IAC5B,OAAO;YAAC;gBAAE,MAAM;YAAI;SAAE;QAG1B,MAAMC,cAAc,MAAM,IAAI,CAAC,eAAe;QAE9C,OAAOA,YAAY,MAAM,CAACE,CAAAA;YACtB,IAAIA,EAAE,IAAI,KAAKH,MACX,OAAO;YAEX,OAAOK,UAAUL,MAAMG,EAAE,IAAI;QACjC;IACJ;IAEA,MAAM,kBAAiD;QACnD,MAAMF,cAAc,MAAM,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW;QAEpF,OAAO,IAAI,CAAC,cAAc,CAACA;IAC/B;IAEA,MAAM,gBAAkC;QACpC,MAAMA,cAAc,MAAM,IAAI,CAAC,eAAe;QAC9C,OAAOA,YAAY,IAAI,CAACE,CAAAA,IAAKA,AAAW,QAAXA,EAAE,IAAI;IACvC;IAMQ,eAAeF,WAAiC,EAAwB;QAC5E,MAAMK,cAAc,IAAI,CAAC,UAAU,CAAC,UAAU;QAC9C,MAAMC,eAAe,IAAI,CAAC,UAAU,CAAC,WAAW;QAEhD,IAAID,aAEA,OAAO;eACAL;YACH;gBACI,MAAM;gBACN,OAAOM;YACX;SACH;QAIL,OAAOC,kCAAkCP;IAC7C;AACJ;AAEO,MAAMQ,kCAAkBC,qBAAqB;IAChD,aAAaC;IACb,gBAAgBnB;IAChB,cAAc;QAACoB;QAAsBC;KAAW;AACpD"}
1
+ {"version":3,"file":"features/security/IdentityContext/IdentityContext.js","sources":["../../../../src/features/security/IdentityContext/IdentityContext.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"async_hooks\";\nimport { minimatch } from \"minimatch\";\nimport { createImplementation } from \"@webiny/di\";\nimport { IdentityContext as Abstraction } from \"./abstractions.js\";\nimport { Identity } from \"./Identity.js\";\nimport { AnonymousIdentity } from \"./AnonymousIdentity.js\";\nimport { AuthorizationContext } from \"../authorization/AuthorizationContext/index.js\";\nimport { filterOutCustomWbyAppsPermissions } from \"../utils/filterOutCustomWbyAppsPermissions.js\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport type { AaclPermission } from \"../../wcp/WcpContext/types.js\";\nimport { FeatureFlags } from \"../../featureFlags/abstractions.js\";\n\nconst identityStorage = new AsyncLocalStorage<Identity | undefined>();\n\nclass IdentityContextImpl implements Abstraction.Interface {\n private identity: Identity = new AnonymousIdentity();\n\n constructor(\n private authorizationContext: AuthorizationContext.Interface,\n private featureFlags: FeatureFlags.Interface\n ) {}\n\n // ========================================================================\n // Identity Methods\n // ========================================================================\n\n getIdentity(): Identity {\n // Check for identity override first (from withIdentity())\n const override = identityStorage.getStore();\n if (override !== undefined) {\n return override;\n }\n return this.identity;\n }\n\n setIdentity(identity: Identity | undefined): void {\n // If undefined, set to anonymous identity\n this.identity = identity ?? new AnonymousIdentity();\n\n // Clear permissions cache when identity changes\n this.authorizationContext.clearPermissionsCache();\n }\n\n withIdentity<T>(identity: Identity | undefined, cb: () => Promise<T>): Promise<T> {\n return identityStorage.run(identity, cb);\n }\n\n // ========================================================================\n // Authorization State Methods\n // ========================================================================\n\n withoutAuthorization<T>(cb: () => Promise<T>): Promise<T> {\n return this.authorizationContext.withoutAuthorization(cb);\n }\n\n withAuthorization<T>(cb: () => Promise<T>): Promise<T> {\n return this.authorizationContext.withAuthorization(cb);\n }\n\n isAuthorizationEnabled(): boolean {\n return this.authorizationContext.isAuthorizationEnabled();\n }\n\n // ========================================================================\n // Permission Methods\n // ========================================================================\n\n async getPermission<TPermission extends SecurityPermission = SecurityPermission>(\n name: string\n ): Promise<TPermission | null> {\n if (!this.isAuthorizationEnabled()) {\n return { name: \"*\" } as TPermission;\n }\n\n const permissions = await this.listPermissions();\n\n // Try exact match first\n const exactMatch = permissions.find(p => p.name === name);\n if (exactMatch) {\n return exactMatch as TPermission;\n }\n\n // Try pattern matching\n const patternMatch = permissions.find(p => minimatch(name, p.name));\n if (patternMatch) {\n return patternMatch as TPermission;\n }\n\n return null;\n }\n\n async getPermissions<TPermission extends SecurityPermission = SecurityPermission>(\n name: string\n ): Promise<TPermission[]> {\n if (!this.isAuthorizationEnabled()) {\n return [{ name: \"*\" }] as TPermission[];\n }\n\n const permissions = await this.listPermissions();\n\n return permissions.filter(p => {\n if (p.name === name) {\n return true;\n }\n return minimatch(name, p.name);\n }) as TPermission[];\n }\n\n async listPermissions(): Promise<SecurityPermission[]> {\n const permissions = await this.authorizationContext.loadPermissions(this.getIdentity());\n // TODO: extract this into a decorator\n return this.applyAaclLogic(permissions);\n }\n\n async hasFullAccess(): Promise<boolean> {\n const permissions = await this.listPermissions();\n return permissions.some(p => p.name === \"*\");\n }\n\n // ========================================================================\n // Private Helper Methods\n // ========================================================================\n\n private applyAaclLogic(permissions: SecurityPermission[]): SecurityPermission[] {\n const aaclEnabled = this.featureFlags.get().isEnabled(\"advancedAccessControlLayer\");\n const teamsEnabled = this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.teams\");\n\n if (aaclEnabled) {\n // Add AACL metadata permission\n return [\n ...permissions,\n {\n name: \"aacl\",\n teams: teamsEnabled\n } as AaclPermission\n ];\n }\n\n // If AACL is not enabled, filter out custom Webiny apps permissions\n return filterOutCustomWbyAppsPermissions(permissions);\n }\n}\n\nexport const IdentityContext = createImplementation({\n abstraction: Abstraction,\n implementation: IdentityContextImpl,\n dependencies: [AuthorizationContext, FeatureFlags]\n});\n"],"names":["identityStorage","AsyncLocalStorage","IdentityContextImpl","authorizationContext","featureFlags","AnonymousIdentity","override","undefined","identity","cb","name","permissions","exactMatch","p","patternMatch","minimatch","aaclEnabled","teamsEnabled","filterOutCustomWbyAppsPermissions","IdentityContext","createImplementation","Abstraction","AuthorizationContext","FeatureFlags"],"mappings":";;;;;;;;AAYA,MAAMA,kBAAkB,IAAIC;AAE5B,MAAMC;IAGF,YACYC,oBAAoD,EACpDC,YAAoC,CAC9C;aAFUD,oBAAoB,GAApBA;aACAC,YAAY,GAAZA;aAJJ,QAAQ,GAAa,IAAIC;IAK9B;IAMH,cAAwB;QAEpB,MAAMC,WAAWN,gBAAgB,QAAQ;QACzC,IAAIM,AAAaC,WAAbD,UACA,OAAOA;QAEX,OAAO,IAAI,CAAC,QAAQ;IACxB;IAEA,YAAYE,QAA8B,EAAQ;QAE9C,IAAI,CAAC,QAAQ,GAAGA,YAAY,IAAIH;QAGhC,IAAI,CAAC,oBAAoB,CAAC,qBAAqB;IACnD;IAEA,aAAgBG,QAA8B,EAAEC,EAAoB,EAAc;QAC9E,OAAOT,gBAAgB,GAAG,CAACQ,UAAUC;IACzC;IAMA,qBAAwBA,EAAoB,EAAc;QACtD,OAAO,IAAI,CAAC,oBAAoB,CAAC,oBAAoB,CAACA;IAC1D;IAEA,kBAAqBA,EAAoB,EAAc;QACnD,OAAO,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAACA;IACvD;IAEA,yBAAkC;QAC9B,OAAO,IAAI,CAAC,oBAAoB,CAAC,sBAAsB;IAC3D;IAMA,MAAM,cACFC,IAAY,EACe;QAC3B,IAAI,CAAC,IAAI,CAAC,sBAAsB,IAC5B,OAAO;YAAE,MAAM;QAAI;QAGvB,MAAMC,cAAc,MAAM,IAAI,CAAC,eAAe;QAG9C,MAAMC,aAAaD,YAAY,IAAI,CAACE,CAAAA,IAAKA,EAAE,IAAI,KAAKH;QACpD,IAAIE,YACA,OAAOA;QAIX,MAAME,eAAeH,YAAY,IAAI,CAACE,CAAAA,IAAKE,UAAUL,MAAMG,EAAE,IAAI;QACjE,IAAIC,cACA,OAAOA;QAGX,OAAO;IACX;IAEA,MAAM,eACFJ,IAAY,EACU;QACtB,IAAI,CAAC,IAAI,CAAC,sBAAsB,IAC5B,OAAO;YAAC;gBAAE,MAAM;YAAI;SAAE;QAG1B,MAAMC,cAAc,MAAM,IAAI,CAAC,eAAe;QAE9C,OAAOA,YAAY,MAAM,CAACE,CAAAA;YACtB,IAAIA,EAAE,IAAI,KAAKH,MACX,OAAO;YAEX,OAAOK,UAAUL,MAAMG,EAAE,IAAI;QACjC;IACJ;IAEA,MAAM,kBAAiD;QACnD,MAAMF,cAAc,MAAM,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW;QAEpF,OAAO,IAAI,CAAC,cAAc,CAACA;IAC/B;IAEA,MAAM,gBAAkC;QACpC,MAAMA,cAAc,MAAM,IAAI,CAAC,eAAe;QAC9C,OAAOA,YAAY,IAAI,CAACE,CAAAA,IAAKA,AAAW,QAAXA,EAAE,IAAI;IACvC;IAMQ,eAAeF,WAAiC,EAAwB;QAC5E,MAAMK,cAAc,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;QACtD,MAAMC,eAAe,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;QAEvD,IAAID,aAEA,OAAO;eACAL;YACH;gBACI,MAAM;gBACN,OAAOM;YACX;SACH;QAIL,OAAOC,kCAAkCP;IAC7C;AACJ;AAEO,MAAMQ,kCAAkBC,qBAAqB;IAChD,aAAaC;IACb,gBAAgBnB;IAChB,cAAc;QAACoB;QAAsBC;KAAa;AACtD"}
@@ -9,6 +9,11 @@ export interface IIdentityContext {
9
9
  listPermissions(): Promise<SecurityPermission[]>;
10
10
  hasFullAccess(): Promise<boolean>;
11
11
  withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;
12
+ /**
13
+ * Runs `cb` with authorization enabled, also inside `withoutAuthorization`. Combine with
14
+ * `withIdentity` to evaluate another user's real permissions from a background task.
15
+ */
16
+ withAuthorization<T>(cb: () => Promise<T>): Promise<T>;
12
17
  isAuthorizationEnabled(): boolean;
13
18
  }
14
19
  /** Provides access to the current identity and its permissions. */
@@ -1 +1 @@
1
- {"version":3,"file":"features/security/IdentityContext/abstractions.js","sources":["../../../../src/features/security/IdentityContext/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Identity } from \"./Identity.js\";\nimport type { SecurityPermission } from \"~/types/security.js\";\n\nexport interface IIdentityContext {\n // Identity methods\n getIdentity(): Identity;\n setIdentity(identity: Identity | undefined): void;\n withIdentity<T>(identity: Identity | undefined, cb: () => Promise<T>): Promise<T>;\n\n // Permission methods\n getPermission<TPermission extends SecurityPermission = SecurityPermission>(\n name: string\n ): Promise<TPermission | null>;\n\n getPermissions<TPermission extends SecurityPermission = SecurityPermission>(\n name: string\n ): Promise<TPermission[]>;\n\n listPermissions(): Promise<SecurityPermission[]>;\n\n hasFullAccess(): Promise<boolean>;\n\n // Authorization context methods\n withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;\n isAuthorizationEnabled(): boolean;\n}\n\n/** Provides access to the current identity and its permissions. */\nexport const IdentityContext = createAbstraction<IIdentityContext>(\"IdentityContext\");\n\nexport namespace IdentityContext {\n export type Interface = IIdentityContext;\n}\n"],"names":["IdentityContext","createAbstraction"],"mappings":";AA6BO,MAAMA,kBAAkBC,kBAAoC"}
1
+ {"version":3,"file":"features/security/IdentityContext/abstractions.js","sources":["../../../../src/features/security/IdentityContext/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Identity } from \"./Identity.js\";\nimport type { SecurityPermission } from \"~/types/security.js\";\n\nexport interface IIdentityContext {\n // Identity methods\n getIdentity(): Identity;\n setIdentity(identity: Identity | undefined): void;\n withIdentity<T>(identity: Identity | undefined, cb: () => Promise<T>): Promise<T>;\n\n // Permission methods\n getPermission<TPermission extends SecurityPermission = SecurityPermission>(\n name: string\n ): Promise<TPermission | null>;\n\n getPermissions<TPermission extends SecurityPermission = SecurityPermission>(\n name: string\n ): Promise<TPermission[]>;\n\n listPermissions(): Promise<SecurityPermission[]>;\n\n hasFullAccess(): Promise<boolean>;\n\n // Authorization context methods\n withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;\n /**\n * Runs `cb` with authorization enabled, also inside `withoutAuthorization`. Combine with\n * `withIdentity` to evaluate another user's real permissions from a background task.\n */\n withAuthorization<T>(cb: () => Promise<T>): Promise<T>;\n isAuthorizationEnabled(): boolean;\n}\n\n/** Provides access to the current identity and its permissions. */\nexport const IdentityContext = createAbstraction<IIdentityContext>(\"IdentityContext\");\n\nexport namespace IdentityContext {\n export type Interface = IIdentityContext;\n}\n"],"names":["IdentityContext","createAbstraction"],"mappings":";AAkCO,MAAMA,kBAAkBC,kBAAoC"}
@@ -0,0 +1,14 @@
1
+ import { Logger } from "../../../features/logger/index.js";
2
+ import type { IAuthenticator } from "../../../features/security/authentication/Authenticator/abstractions.js";
3
+ import type { IApiKeysRepository } from "./shared/abstractions.js";
4
+ import type { IdentityData } from "../../../features/security/IdentityContext/Identity.js";
5
+ declare class ApiKeyAuthenticatorImpl implements IAuthenticator {
6
+ private repository;
7
+ private logger;
8
+ constructor(repository: IApiKeysRepository, logger: Logger.Interface);
9
+ authenticate(token: string): Promise<IdentityData | null>;
10
+ }
11
+ export declare const ApiKeyAuthenticator: typeof ApiKeyAuthenticatorImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<IAuthenticator>;
13
+ };
14
+ export {};
@@ -0,0 +1,36 @@
1
+ import { Authenticator } from "../authentication/Authenticator/abstractions.js";
2
+ import { ApiKeysRepository } from "./shared/abstractions.js";
3
+ import { Logger } from "../../logger/index.js";
4
+ class ApiKeyAuthenticatorImpl {
5
+ constructor(repository, logger){
6
+ this.repository = repository;
7
+ this.logger = logger;
8
+ }
9
+ async authenticate(token) {
10
+ if ("string" != typeof token || !token.startsWith("wat_")) return null;
11
+ const result = await this.repository.getByToken(token);
12
+ if (!result.isOk()) {
13
+ this.logger.warn({
14
+ error: result.error
15
+ }, "API key authentication failed; request will proceed as anonymous.");
16
+ return null;
17
+ }
18
+ const apiKey = result.value;
19
+ return {
20
+ id: apiKey.id,
21
+ displayName: apiKey.name,
22
+ type: "api-key",
23
+ permissions: apiKey.permissions
24
+ };
25
+ }
26
+ }
27
+ const ApiKeyAuthenticator = Authenticator.createImplementation({
28
+ implementation: ApiKeyAuthenticatorImpl,
29
+ dependencies: [
30
+ ApiKeysRepository,
31
+ Logger
32
+ ]
33
+ });
34
+ export { ApiKeyAuthenticator };
35
+
36
+ //# sourceMappingURL=ApiKeyAuthenticator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/security/apiKeys/ApiKeyAuthenticator.js","sources":["../../../../src/features/security/apiKeys/ApiKeyAuthenticator.ts"],"sourcesContent":["import { Authenticator } from \"~/features/security/authentication/Authenticator/abstractions.js\";\nimport { ApiKeysRepository } from \"./shared/abstractions.js\";\nimport { Logger } from \"~/features/logger/index.js\";\nimport type { IAuthenticator } from \"~/features/security/authentication/Authenticator/abstractions.js\";\nimport type { IApiKeysRepository } from \"./shared/abstractions.js\";\nimport type { IdentityData } from \"~/features/security/IdentityContext/Identity.js\";\n\nclass ApiKeyAuthenticatorImpl implements IAuthenticator {\n constructor(\n private repository: IApiKeysRepository,\n private logger: Logger.Interface\n ) {}\n\n async authenticate(token: string): Promise<IdentityData | null> {\n if (typeof token !== \"string\" || !token.startsWith(\"wat_\")) {\n return null;\n }\n const result = await this.repository.getByToken(token);\n if (!result.isOk()) {\n // The token looked like an API key (\"wat_\") but could not be resolved. Log it — otherwise\n // this degrades silently to an anonymous request (which is what made the tenant-ordering\n // bug so hard to find). A genuine unknown/revoked key logs here too, which is acceptable.\n this.logger.warn(\n { error: result.error },\n \"API key authentication failed; request will proceed as anonymous.\"\n );\n return null;\n }\n const apiKey = result.value;\n return {\n id: apiKey.id,\n displayName: apiKey.name,\n type: \"api-key\",\n permissions: apiKey.permissions\n };\n }\n}\n\nexport const ApiKeyAuthenticator = Authenticator.createImplementation({\n implementation: ApiKeyAuthenticatorImpl,\n dependencies: [ApiKeysRepository, Logger]\n});\n"],"names":["ApiKeyAuthenticatorImpl","repository","logger","token","result","apiKey","ApiKeyAuthenticator","Authenticator","ApiKeysRepository","Logger"],"mappings":";;;AAOA,MAAMA;IACF,YACYC,UAA8B,EAC9BC,MAAwB,CAClC;aAFUD,UAAU,GAAVA;aACAC,MAAM,GAANA;IACT;IAEH,MAAM,aAAaC,KAAa,EAAgC;QAC5D,IAAI,AAAiB,YAAjB,OAAOA,SAAsB,CAACA,MAAM,UAAU,CAAC,SAC/C,OAAO;QAEX,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAACD;QAChD,IAAI,CAACC,OAAO,IAAI,IAAI;YAIhB,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ;gBAAE,OAAOA,OAAO,KAAK;YAAC,GACtB;YAEJ,OAAO;QACX;QACA,MAAMC,SAASD,OAAO,KAAK;QAC3B,OAAO;YACH,IAAIC,OAAO,EAAE;YACb,aAAaA,OAAO,IAAI;YACxB,MAAM;YACN,aAAaA,OAAO,WAAW;QACnC;IACJ;AACJ;AAEO,MAAMC,sBAAsBC,cAAc,oBAAoB,CAAC;IAClE,gBAAgBP;IAChB,cAAc;QAACQ;QAAmBC;KAAO;AAC7C"}
@@ -0,0 +1,10 @@
1
+ import type { IAuthorizer } from "../../../features/security/authorization/Authorizer/abstractions.js";
2
+ import type { Identity } from "../../../features/security/IdentityContext/Identity.js";
3
+ import type { SecurityPermission } from "../../../types/security.js";
4
+ declare class ApiKeyAuthorizerImpl implements IAuthorizer {
5
+ authorize(identity: Identity): Promise<SecurityPermission[] | null>;
6
+ }
7
+ export declare const ApiKeyAuthorizer: typeof ApiKeyAuthorizerImpl & {
8
+ __abstraction: import("@webiny/di").Abstraction<IAuthorizer>;
9
+ };
10
+ export {};
@@ -0,0 +1,15 @@
1
+ import { Authorizer } from "../authorization/Authorizer/abstractions.js";
2
+ class ApiKeyAuthorizerImpl {
3
+ async authorize(identity) {
4
+ if (!identity || "api-key" !== identity.type) return null;
5
+ const permissions = identity.permissions;
6
+ return Array.isArray(permissions) ? permissions : [];
7
+ }
8
+ }
9
+ const ApiKeyAuthorizer = Authorizer.createImplementation({
10
+ implementation: ApiKeyAuthorizerImpl,
11
+ dependencies: []
12
+ });
13
+ export { ApiKeyAuthorizer };
14
+
15
+ //# sourceMappingURL=ApiKeyAuthorizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/security/apiKeys/ApiKeyAuthorizer.js","sources":["../../../../src/features/security/apiKeys/ApiKeyAuthorizer.ts"],"sourcesContent":["import { Authorizer } from \"~/features/security/authorization/Authorizer/abstractions.js\";\nimport type { IAuthorizer } from \"~/features/security/authorization/Authorizer/abstractions.js\";\nimport type { Identity } from \"~/features/security/IdentityContext/Identity.js\";\nimport type { SecurityPermission } from \"~/types/security.js\";\n\nclass ApiKeyAuthorizerImpl implements IAuthorizer {\n async authorize(identity: Identity): Promise<SecurityPermission[] | null> {\n if (!identity || identity.type !== \"api-key\") {\n return null;\n }\n const permissions = (identity as any).permissions;\n return Array.isArray(permissions) ? (permissions as SecurityPermission[]) : [];\n }\n}\n\nexport const ApiKeyAuthorizer = Authorizer.createImplementation({\n implementation: ApiKeyAuthorizerImpl,\n dependencies: []\n});\n"],"names":["ApiKeyAuthorizerImpl","identity","permissions","Array","ApiKeyAuthorizer","Authorizer"],"mappings":";AAKA,MAAMA;IACF,MAAM,UAAUC,QAAkB,EAAwC;QACtE,IAAI,CAACA,YAAYA,AAAkB,cAAlBA,SAAS,IAAI,EAC1B,OAAO;QAEX,MAAMC,cAAeD,SAAiB,WAAW;QACjD,OAAOE,MAAM,OAAO,CAACD,eAAgBA,cAAuC,EAAE;IAClF;AACJ;AAEO,MAAME,mBAAmBC,WAAW,oBAAoB,CAAC;IAC5D,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -8,6 +8,7 @@ import { createApiKeyInputSchema } from "../shared/schemas.js";
8
8
  import { ApiKeyAfterCreateEvent, ApiKeyBeforeCreateEvent } from "./events.js";
9
9
  import { generateToken } from "../shared/generateToken.js";
10
10
  import { ApiKeyNotAuthorizedError, ApiKeyValidationError } from "../shared/errors.js";
11
+ import { descriptionOnCreate } from "../../shared/description.js";
11
12
  class CreateApiKeyUseCaseImpl {
12
13
  constructor(identityContext, eventPublisher, repository){
13
14
  this.identityContext = identityContext;
@@ -22,13 +23,17 @@ class CreateApiKeyUseCaseImpl {
22
23
  const token = generateToken();
23
24
  const identity = this.identityContext.getIdentity();
24
25
  const data = validation.data;
26
+ const createInput = {
27
+ ...data,
28
+ description: descriptionOnCreate(data.description)
29
+ };
25
30
  const apiKey = {
26
31
  id: mdbid(),
27
- name: data.name,
28
- slug: data.slug,
29
- description: data.description,
32
+ name: createInput.name,
33
+ slug: createInput.slug,
34
+ description: descriptionOnCreate(createInput.description),
30
35
  token,
31
- permissions: data.permissions,
36
+ permissions: createInput.permissions,
32
37
  createdOn: new Date().toISOString(),
33
38
  createdBy: {
34
39
  id: identity.id,
@@ -38,13 +43,13 @@ class CreateApiKeyUseCaseImpl {
38
43
  };
39
44
  await this.eventPublisher.publish(new ApiKeyBeforeCreateEvent({
40
45
  apiKey,
41
- input: validation.data
46
+ input: createInput
42
47
  }));
43
48
  const result = await this.repository.create(apiKey);
44
49
  if (result.isFail()) return Result.fail(result.error);
45
50
  await this.eventPublisher.publish(new ApiKeyAfterCreateEvent({
46
51
  apiKey,
47
- input: validation.data
52
+ input: createInput
48
53
  }));
49
54
  return Result.ok(apiKey);
50
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js","sources":["../../../../../src/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.ts"],"sourcesContent":["import { mdbid } from \"@webiny/utils\";\nimport { Result } from \"@webiny/feature/api\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { CreateApiKeyUseCase as CreateApiKeyUseCaseAbstraction } from \"./abstractions.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { createApiKeyInputSchema } from \"../shared/schemas.js\";\nimport { ApiKeyBeforeCreateEvent, ApiKeyAfterCreateEvent } from \"./events.js\";\nimport type { ApiKey, CreateApiKeyInput } from \"../shared/types.js\";\nimport type { ApiKeyPermission } from \"~/types/security.js\";\nimport { generateToken } from \"../shared/generateToken.js\";\nimport { ApiKeyValidationError, ApiKeyNotAuthorizedError } from \"../shared/errors.js\";\n\nclass CreateApiKeyUseCaseImpl implements CreateApiKeyUseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: ApiKeysRepository.Interface\n ) {}\n\n async execute(\n input: CreateApiKeyInput\n ): Promise<Result<ApiKey, CreateApiKeyUseCaseAbstraction.Error>> {\n const hasPermission =\n await this.identityContext.getPermission<ApiKeyPermission>(\"security.apiKey\");\n\n if (!hasPermission) {\n return Result.fail(new ApiKeyNotAuthorizedError());\n }\n\n const validation = createApiKeyInputSchema.safeParse(input);\n if (!validation.success) {\n return Result.fail(new ApiKeyValidationError(validation.error.issues[0].message));\n }\n\n const token = generateToken();\n const identity = this.identityContext.getIdentity();\n const data = validation.data;\n\n const apiKey: ApiKey = {\n id: mdbid(),\n name: data.name,\n slug: data.slug,\n description: data.description,\n token,\n permissions: data.permissions,\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n }\n };\n\n await this.eventPublisher.publish(\n new ApiKeyBeforeCreateEvent({ apiKey, input: validation.data })\n );\n\n const result = await this.repository.create(apiKey);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new ApiKeyAfterCreateEvent({ apiKey, input: validation.data })\n );\n\n return Result.ok(apiKey);\n }\n}\n\nexport const CreateApiKeyUseCase = CreateApiKeyUseCaseAbstraction.createImplementation({\n implementation: CreateApiKeyUseCaseImpl,\n dependencies: [IdentityContext, EventPublisher, ApiKeysRepository]\n});\n"],"names":["CreateApiKeyUseCaseImpl","identityContext","eventPublisher","repository","input","hasPermission","Result","ApiKeyNotAuthorizedError","validation","createApiKeyInputSchema","ApiKeyValidationError","token","generateToken","identity","data","apiKey","mdbid","Date","ApiKeyBeforeCreateEvent","result","ApiKeyAfterCreateEvent","CreateApiKeyUseCase","CreateApiKeyUseCaseAbstraction","IdentityContext","EventPublisher","ApiKeysRepository"],"mappings":";;;;;;;;;;AAaA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,cAAwC,EACxCC,UAAuC,CACjD;aAHUF,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QACFC,KAAwB,EACqC;QAC7D,MAAMC,gBACF,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAmB;QAE/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,wBAAwB,SAAS,CAACL;QACrD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,sBAAsBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAGnF,MAAMG,QAAQC;QACd,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,MAAMC,OAAON,WAAW,IAAI;QAE5B,MAAMO,SAAiB;YACnB,IAAIC;YACJ,MAAMF,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YACf,aAAaA,KAAK,WAAW;YAC7BH;YACA,aAAaG,KAAK,WAAW;YAC7B,WAAW,IAAIG,OAAO,WAAW;YACjC,WAAW;gBACP,IAAIJ,SAAS,EAAE;gBACf,aAAaA,SAAS,WAAW;gBACjC,MAAMA,SAAS,IAAI;YACvB;QACJ;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIK,wBAAwB;YAAEH;YAAQ,OAAOP,WAAW,IAAI;QAAC;QAGjE,MAAMW,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACJ;QAE5C,IAAII,OAAO,MAAM,IACb,OAAOb,OAAO,IAAI,CAACa,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,uBAAuB;YAAEL;YAAQ,OAAOP,WAAW,IAAI;QAAC;QAGhE,OAAOF,OAAO,EAAE,CAACS;IACrB;AACJ;AAEO,MAAMM,0CAAsBC,oBAAAA,oBAAmD,CAAC;IACnF,gBAAgBtB;IAChB,cAAc;QAACuB;QAAiBC;QAAgBC;KAAkB;AACtE"}
1
+ {"version":3,"file":"features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js","sources":["../../../../../src/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.ts"],"sourcesContent":["import { mdbid } from \"@webiny/utils\";\nimport { Result } from \"@webiny/feature/api\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { CreateApiKeyUseCase as CreateApiKeyUseCaseAbstraction } from \"./abstractions.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { createApiKeyInputSchema } from \"../shared/schemas.js\";\nimport { ApiKeyBeforeCreateEvent, ApiKeyAfterCreateEvent } from \"./events.js\";\nimport type { ApiKey, CreateApiKeyInput } from \"../shared/types.js\";\nimport type { ApiKeyPermission } from \"~/types/security.js\";\nimport { generateToken } from \"../shared/generateToken.js\";\nimport { ApiKeyValidationError, ApiKeyNotAuthorizedError } from \"../shared/errors.js\";\nimport { descriptionOnCreate } from \"../../shared/description.js\";\n\nclass CreateApiKeyUseCaseImpl implements CreateApiKeyUseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: ApiKeysRepository.Interface\n ) {}\n\n async execute(\n input: CreateApiKeyInput\n ): Promise<Result<ApiKey, CreateApiKeyUseCaseAbstraction.Error>> {\n const hasPermission =\n await this.identityContext.getPermission<ApiKeyPermission>(\"security.apiKey\");\n\n if (!hasPermission) {\n return Result.fail(new ApiKeyNotAuthorizedError());\n }\n\n const validation = createApiKeyInputSchema.safeParse(input);\n if (!validation.success) {\n return Result.fail(new ApiKeyValidationError(validation.error.issues[0].message));\n }\n\n const token = generateToken();\n const identity = this.identityContext.getIdentity();\n const data = validation.data;\n\n // Normalised up front so that null reaches neither the entity nor the published events.\n const createInput: CreateApiKeyInput = {\n ...data,\n description: descriptionOnCreate(data.description)\n };\n\n const apiKey: ApiKey = {\n id: mdbid(),\n name: createInput.name,\n slug: createInput.slug,\n description: descriptionOnCreate(createInput.description),\n token,\n permissions: createInput.permissions,\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n }\n };\n\n await this.eventPublisher.publish(\n new ApiKeyBeforeCreateEvent({ apiKey, input: createInput })\n );\n\n const result = await this.repository.create(apiKey);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new ApiKeyAfterCreateEvent({ apiKey, input: createInput })\n );\n\n return Result.ok(apiKey);\n }\n}\n\nexport const CreateApiKeyUseCase = CreateApiKeyUseCaseAbstraction.createImplementation({\n implementation: CreateApiKeyUseCaseImpl,\n dependencies: [IdentityContext, EventPublisher, ApiKeysRepository]\n});\n"],"names":["CreateApiKeyUseCaseImpl","identityContext","eventPublisher","repository","input","hasPermission","Result","ApiKeyNotAuthorizedError","validation","createApiKeyInputSchema","ApiKeyValidationError","token","generateToken","identity","data","createInput","descriptionOnCreate","apiKey","mdbid","Date","ApiKeyBeforeCreateEvent","result","ApiKeyAfterCreateEvent","CreateApiKeyUseCase","CreateApiKeyUseCaseAbstraction","IdentityContext","EventPublisher","ApiKeysRepository"],"mappings":";;;;;;;;;;;AAcA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,cAAwC,EACxCC,UAAuC,CACjD;aAHUF,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QACFC,KAAwB,EACqC;QAC7D,MAAMC,gBACF,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAmB;QAE/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,wBAAwB,SAAS,CAACL;QACrD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,sBAAsBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAGnF,MAAMG,QAAQC;QACd,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,MAAMC,OAAON,WAAW,IAAI;QAG5B,MAAMO,cAAiC;YACnC,GAAGD,IAAI;YACP,aAAaE,oBAAoBF,KAAK,WAAW;QACrD;QAEA,MAAMG,SAAiB;YACnB,IAAIC;YACJ,MAAMH,YAAY,IAAI;YACtB,MAAMA,YAAY,IAAI;YACtB,aAAaC,oBAAoBD,YAAY,WAAW;YACxDJ;YACA,aAAaI,YAAY,WAAW;YACpC,WAAW,IAAII,OAAO,WAAW;YACjC,WAAW;gBACP,IAAIN,SAAS,EAAE;gBACf,aAAaA,SAAS,WAAW;gBACjC,MAAMA,SAAS,IAAI;YACvB;QACJ;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIO,wBAAwB;YAAEH;YAAQ,OAAOF;QAAY;QAG7D,MAAMM,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACJ;QAE5C,IAAII,OAAO,MAAM,IACb,OAAOf,OAAO,IAAI,CAACe,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,uBAAuB;YAAEL;YAAQ,OAAOF;QAAY;QAG5D,OAAOT,OAAO,EAAE,CAACW;IACrB;AACJ;AAEO,MAAMM,0CAAsBC,oBAAAA,oBAAmD,CAAC;IACnF,gBAAgBxB;IAChB,cAAc;QAACyB;QAAiBC;QAAgBC;KAAkB;AACtE"}
@@ -3,7 +3,7 @@ import { ApiKeysRepository } from "../shared/abstractions.js";
3
3
  declare class GetApiKeyBySlugUseCaseImpl implements GetApiKeyBySlugUseCaseAbstraction.Interface {
4
4
  private repository;
5
5
  constructor(repository: ApiKeysRepository.Interface);
6
- execute(slug: string): Promise<import("@webiny/feature/api").Result<import("../shared/types.js").ApiKey, import("../shared/errors.js").ApiKeyNotFoundError | import("../shared/errors.js").ApiKeyPersistenceError | import("../shared/errors.js").ApiKeyValidationError>>;
6
+ execute(slug: string): Promise<import("@webiny/feature/api/Result.js").Result<import("../shared/types.js").ApiKey, import("../shared/errors.js").ApiKeyNotFoundError | import("../shared/errors.js").ApiKeyPersistenceError | import("../shared/errors.js").ApiKeyValidationError>>;
7
7
  }
8
8
  export declare const GetApiKeyBySlugUseCase: typeof GetApiKeyBySlugUseCaseImpl & {
9
9
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetApiKeyBySlug>;
@@ -3,7 +3,7 @@ import { ApiKeysRepository } from "../shared/abstractions.js";
3
3
  declare class GetApiKeyByTokenUseCaseImpl implements GetApiKeyByTokenUseCaseAbstraction.Interface {
4
4
  private repository;
5
5
  constructor(repository: ApiKeysRepository.Interface);
6
- execute(token: string): Promise<import("@webiny/feature/api").Result<import("../shared/types.js").ApiKey, import("../shared/errors.js").ApiKeyNotFoundError | import("../shared/errors.js").ApiKeyPersistenceError | import("../shared/errors.js").ApiKeyValidationError>>;
6
+ execute(token: string): Promise<import("@webiny/feature/api/Result.js").Result<import("../shared/types.js").ApiKey, import("../shared/errors.js").ApiKeyNotFoundError | import("../shared/errors.js").ApiKeyPersistenceError | import("../shared/errors.js").ApiKeyValidationError>>;
7
7
  }
8
8
  export declare const GetApiKeyByTokenUseCase: typeof GetApiKeyByTokenUseCaseImpl & {
9
9
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetApiKeyByToken>;
@@ -6,6 +6,7 @@ import { EventPublisher } from "../../../eventPublisher/index.js";
6
6
  import { updateApiKeyInputSchema } from "../shared/schemas.js";
7
7
  import { ApiKeyAfterUpdateEvent, ApiKeyBeforeUpdateEvent } from "./events.js";
8
8
  import { ApiKeyNotAuthorizedError, ApiKeyValidationError } from "../shared/errors.js";
9
+ import { descriptionOnUpdate } from "../../shared/description.js";
9
10
  class UpdateApiKeyUseCaseImpl {
10
11
  constructor(repository, identityContext, eventPublisher){
11
12
  this.repository = repository;
@@ -20,21 +21,26 @@ class UpdateApiKeyUseCaseImpl {
20
21
  const existingResult = await this.repository.get(id);
21
22
  if (existingResult.isFail()) return Result.fail(existingResult.error);
22
23
  const existingApiKey = existingResult.value;
24
+ const { description, ...rest } = validation.data;
25
+ const changes = {
26
+ ...rest,
27
+ ...descriptionOnUpdate(description)
28
+ };
23
29
  const updatedApiKey = {
24
30
  ...existingApiKey,
25
- ...validation.data
31
+ ...changes
26
32
  };
27
33
  await this.eventPublisher.publish(new ApiKeyBeforeUpdateEvent({
28
34
  original: existingApiKey,
29
35
  updated: updatedApiKey,
30
- input: validation.data
36
+ input: changes
31
37
  }));
32
38
  const result = await this.repository.update(updatedApiKey);
33
39
  if (result.isFail()) return Result.fail(result.error);
34
40
  await this.eventPublisher.publish(new ApiKeyAfterUpdateEvent({
35
41
  original: existingApiKey,
36
42
  updated: updatedApiKey,
37
- input: validation.data
43
+ input: changes
38
44
  }));
39
45
  return Result.ok(updatedApiKey);
40
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js","sources":["../../../../../src/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateApiKeyUseCase as UpdateApiKeyUseCaseAbstraction } from \"./abstractions.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateApiKeyInputSchema } from \"../shared/schemas.js\";\nimport { ApiKeyBeforeUpdateEvent, ApiKeyAfterUpdateEvent } from \"./events.js\";\nimport type { ApiKey, UpdateApiKeyInput } from \"../shared/types.js\";\nimport { ApiKeyNotAuthorizedError, ApiKeyValidationError } from \"../shared/errors.js\";\n\nclass UpdateApiKeyUseCaseImpl implements UpdateApiKeyUseCaseAbstraction.Interface {\n private repository: ApiKeysRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n\n constructor(\n repository: ApiKeysRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n }\n\n async execute(\n id: string,\n input: UpdateApiKeyInput\n ): Promise<Result<ApiKey, UpdateApiKeyUseCaseAbstraction.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.apiKey\");\n if (!hasPermission) {\n return Result.fail(new ApiKeyNotAuthorizedError());\n }\n\n const validation = updateApiKeyInputSchema.safeParse(input);\n if (!validation.success) {\n return Result.fail(new ApiKeyValidationError(validation.error.issues[0].message));\n }\n\n const existingResult = await this.repository.get(id);\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingApiKey = existingResult.value;\n\n const updatedApiKey: ApiKey = {\n ...existingApiKey,\n ...validation.data\n };\n\n await this.eventPublisher.publish(\n new ApiKeyBeforeUpdateEvent({\n original: existingApiKey,\n updated: updatedApiKey,\n input: validation.data\n })\n );\n\n const result = await this.repository.update(updatedApiKey);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new ApiKeyAfterUpdateEvent({\n original: existingApiKey,\n updated: updatedApiKey,\n input: validation.data\n })\n );\n\n return Result.ok(updatedApiKey);\n }\n}\n\nexport const UpdateApiKeyUseCase = UpdateApiKeyUseCaseAbstraction.createImplementation({\n implementation: UpdateApiKeyUseCaseImpl,\n dependencies: [ApiKeysRepository, IdentityContext, EventPublisher]\n});\n"],"names":["UpdateApiKeyUseCaseImpl","repository","identityContext","eventPublisher","id","input","hasPermission","Result","ApiKeyNotAuthorizedError","validation","updateApiKeyInputSchema","ApiKeyValidationError","existingResult","existingApiKey","updatedApiKey","ApiKeyBeforeUpdateEvent","result","ApiKeyAfterUpdateEvent","UpdateApiKeyUseCase","UpdateApiKeyUseCaseAbstraction","ApiKeysRepository","IdentityContext","EventPublisher"],"mappings":";;;;;;;;AAUA,MAAMA;IAKF,YACIC,UAAuC,EACvCC,eAA0C,EAC1CC,cAAwC,CAC1C;QACE,IAAI,CAAC,UAAU,GAAGF;QAClB,IAAI,CAAC,eAAe,GAAGC;QACvB,IAAI,CAAC,cAAc,GAAGC;IAC1B;IAEA,MAAM,QACFC,EAAU,EACVC,KAAwB,EACqC;QAC7D,MAAMC,gBAAgB,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAC/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,wBAAwB,SAAS,CAACL;QACrD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,sBAAsBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAGnF,MAAMG,iBAAiB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAACR;QACjD,IAAIQ,eAAe,MAAM,IACrB,OAAOL,OAAO,IAAI,CAACK,eAAe,KAAK;QAG3C,MAAMC,iBAAiBD,eAAe,KAAK;QAE3C,MAAME,gBAAwB;YAC1B,GAAGD,cAAc;YACjB,GAAGJ,WAAW,IAAI;QACtB;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIM,wBAAwB;YACxB,UAAUF;YACV,SAASC;YACT,OAAOL,WAAW,IAAI;QAC1B;QAGJ,MAAMO,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACF;QAE5C,IAAIE,OAAO,MAAM,IACb,OAAOT,OAAO,IAAI,CAACS,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,uBAAuB;YACvB,UAAUJ;YACV,SAASC;YACT,OAAOL,WAAW,IAAI;QAC1B;QAGJ,OAAOF,OAAO,EAAE,CAACO;IACrB;AACJ;AAEO,MAAMI,0CAAsBC,oBAAAA,oBAAmD,CAAC;IACnF,gBAAgBnB;IAChB,cAAc;QAACoB;QAAmBC;QAAiBC;KAAe;AACtE"}
1
+ {"version":3,"file":"features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js","sources":["../../../../../src/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateApiKeyUseCase as UpdateApiKeyUseCaseAbstraction } from \"./abstractions.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateApiKeyInputSchema } from \"../shared/schemas.js\";\nimport { ApiKeyBeforeUpdateEvent, ApiKeyAfterUpdateEvent } from \"./events.js\";\nimport type { ApiKey, UpdateApiKeyInput } from \"../shared/types.js\";\nimport { ApiKeyNotAuthorizedError, ApiKeyValidationError } from \"../shared/errors.js\";\nimport { descriptionOnUpdate } from \"../../shared/description.js\";\n\nclass UpdateApiKeyUseCaseImpl implements UpdateApiKeyUseCaseAbstraction.Interface {\n private repository: ApiKeysRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n\n constructor(\n repository: ApiKeysRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n }\n\n async execute(\n id: string,\n input: UpdateApiKeyInput\n ): Promise<Result<ApiKey, UpdateApiKeyUseCaseAbstraction.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.apiKey\");\n if (!hasPermission) {\n return Result.fail(new ApiKeyNotAuthorizedError());\n }\n\n const validation = updateApiKeyInputSchema.safeParse(input);\n if (!validation.success) {\n return Result.fail(new ApiKeyValidationError(validation.error.issues[0].message));\n }\n\n const existingResult = await this.repository.get(id);\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingApiKey = existingResult.value;\n\n // `description` is pulled out of the spread because it is the one field that accepts null.\n // Normalising it here keeps null out of both the entity and the published events, whose\n // input type declares `description?: string`.\n const { description, ...rest } = validation.data;\n\n const changes: UpdateApiKeyInput = {\n ...rest,\n ...descriptionOnUpdate(description)\n };\n\n const updatedApiKey: ApiKey = {\n ...existingApiKey,\n ...changes\n };\n\n await this.eventPublisher.publish(\n new ApiKeyBeforeUpdateEvent({\n original: existingApiKey,\n updated: updatedApiKey,\n input: changes\n })\n );\n\n const result = await this.repository.update(updatedApiKey);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new ApiKeyAfterUpdateEvent({\n original: existingApiKey,\n updated: updatedApiKey,\n input: changes\n })\n );\n\n return Result.ok(updatedApiKey);\n }\n}\n\nexport const UpdateApiKeyUseCase = UpdateApiKeyUseCaseAbstraction.createImplementation({\n implementation: UpdateApiKeyUseCaseImpl,\n dependencies: [ApiKeysRepository, IdentityContext, EventPublisher]\n});\n"],"names":["UpdateApiKeyUseCaseImpl","repository","identityContext","eventPublisher","id","input","hasPermission","Result","ApiKeyNotAuthorizedError","validation","updateApiKeyInputSchema","ApiKeyValidationError","existingResult","existingApiKey","description","rest","changes","descriptionOnUpdate","updatedApiKey","ApiKeyBeforeUpdateEvent","result","ApiKeyAfterUpdateEvent","UpdateApiKeyUseCase","UpdateApiKeyUseCaseAbstraction","ApiKeysRepository","IdentityContext","EventPublisher"],"mappings":";;;;;;;;;AAWA,MAAMA;IAKF,YACIC,UAAuC,EACvCC,eAA0C,EAC1CC,cAAwC,CAC1C;QACE,IAAI,CAAC,UAAU,GAAGF;QAClB,IAAI,CAAC,eAAe,GAAGC;QACvB,IAAI,CAAC,cAAc,GAAGC;IAC1B;IAEA,MAAM,QACFC,EAAU,EACVC,KAAwB,EACqC;QAC7D,MAAMC,gBAAgB,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAC/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,wBAAwB,SAAS,CAACL;QACrD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,sBAAsBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAGnF,MAAMG,iBAAiB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAACR;QACjD,IAAIQ,eAAe,MAAM,IACrB,OAAOL,OAAO,IAAI,CAACK,eAAe,KAAK;QAG3C,MAAMC,iBAAiBD,eAAe,KAAK;QAK3C,MAAM,EAAEE,WAAW,EAAE,GAAGC,MAAM,GAAGN,WAAW,IAAI;QAEhD,MAAMO,UAA6B;YAC/B,GAAGD,IAAI;YACP,GAAGE,oBAAoBH,YAAY;QACvC;QAEA,MAAMI,gBAAwB;YAC1B,GAAGL,cAAc;YACjB,GAAGG,OAAO;QACd;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIG,wBAAwB;YACxB,UAAUN;YACV,SAASK;YACT,OAAOF;QACX;QAGJ,MAAMI,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACF;QAE5C,IAAIE,OAAO,MAAM,IACb,OAAOb,OAAO,IAAI,CAACa,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,uBAAuB;YACvB,UAAUR;YACV,SAASK;YACT,OAAOF;QACX;QAGJ,OAAOT,OAAO,EAAE,CAACW;IACrB;AACJ;AAEO,MAAMI,0CAAsBC,oBAAAA,oBAAmD,CAAC;IACnF,gBAAgBvB;IAChB,cAAc;QAACwB;QAAmBC;QAAiBC;KAAe;AACtE"}
@@ -9,6 +9,8 @@ import { UpdateApiKeyFeature } from "./UpdateApiKey/feature.js";
9
9
  import { DeleteApiKeyFeature } from "./DeleteApiKey/feature.js";
10
10
  import { ApiKeyFactory, ApiKeyProvider } from "./shared/abstractions.js";
11
11
  import { ApiKeyProvider as ApiKeyProvider_js_ApiKeyProvider } from "./shared/ApiKeyProvider.js";
12
+ import { ApiKeyAuthenticator } from "./ApiKeyAuthenticator.js";
13
+ import { ApiKeyAuthorizer } from "./ApiKeyAuthorizer.js";
12
14
  import { TenantContext } from "../../tenancy/TenantContext/index.js";
13
15
  const ApiKeysFeature = createFeature({
14
16
  name: "ApiKeys",
@@ -18,6 +20,8 @@ const ApiKeysFeature = createFeature({
18
20
  const tenantContext = container.resolve(TenantContext);
19
21
  return new ApiKeyProvider_js_ApiKeyProvider(tenantContext, ()=>container.resolveAll(ApiKeyFactory));
20
22
  });
23
+ container.register(ApiKeyAuthenticator);
24
+ container.register(ApiKeyAuthorizer);
21
25
  GetApiKeyFeature.register(container);
22
26
  GetApiKeyByTokenFeature.register(container);
23
27
  GetApiKeyBySlugFeature.register(container);
@@ -1 +1 @@
1
- {"version":3,"file":"features/security/apiKeys/feature.js","sources":["../../../../src/features/security/apiKeys/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ApiKeysRepository } from \"./shared/ApiKeysRepository.js\";\nimport { GetApiKeyFeature } from \"./GetApiKey/feature.js\";\nimport { GetApiKeyByTokenFeature } from \"./GetApiKeyByToken/feature.js\";\nimport { GetApiKeyBySlugFeature } from \"./GetApiKeyBySlug/feature.js\";\nimport { ListApiKeysFeature } from \"./ListApiKeys/feature.js\";\nimport { CreateApiKeyFeature } from \"./CreateApiKey/feature.js\";\nimport { UpdateApiKeyFeature } from \"./UpdateApiKey/feature.js\";\nimport { DeleteApiKeyFeature } from \"./DeleteApiKey/feature.js\";\nimport {\n ApiKeyFactory,\n ApiKeyProvider as ApiKeyProviderAbstraction\n} from \"~/features/security/apiKeys/shared/abstractions.js\";\nimport { ApiKeyProvider } from \"./shared/ApiKeyProvider.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\n\nexport const ApiKeysFeature = createFeature({\n name: \"ApiKeys\",\n register(container) {\n // Register repository in singleton scope\n container.register(ApiKeysRepository).inSingletonScope();\n\n container.registerFactory(ApiKeyProviderAbstraction, () => {\n const tenantContext = container.resolve(TenantContext);\n return new ApiKeyProvider(tenantContext, () => {\n return container.resolveAll(ApiKeyFactory);\n });\n });\n\n // Register all use cases\n GetApiKeyFeature.register(container);\n GetApiKeyByTokenFeature.register(container);\n GetApiKeyBySlugFeature.register(container);\n ListApiKeysFeature.register(container);\n CreateApiKeyFeature.register(container);\n UpdateApiKeyFeature.register(container);\n DeleteApiKeyFeature.register(container);\n }\n});\n"],"names":["ApiKeysFeature","createFeature","container","ApiKeysRepository","ApiKeyProviderAbstraction","tenantContext","TenantContext","ApiKeyProvider","ApiKeyFactory","GetApiKeyFeature","GetApiKeyByTokenFeature","GetApiKeyBySlugFeature","ListApiKeysFeature","CreateApiKeyFeature","UpdateApiKeyFeature","DeleteApiKeyFeature"],"mappings":";;;;;;;;;;;;AAgBO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAS;QAEdA,UAAU,QAAQ,CAACC,mBAAmB,gBAAgB;QAEtDD,UAAU,eAAe,CAACE,gBAA2B;YACjD,MAAMC,gBAAgBH,UAAU,OAAO,CAACI;YACxC,OAAO,IAAIC,iCAAeF,eAAe,IAC9BH,UAAU,UAAU,CAACM;QAEpC;QAGAC,iBAAiB,QAAQ,CAACP;QAC1BQ,wBAAwB,QAAQ,CAACR;QACjCS,uBAAuB,QAAQ,CAACT;QAChCU,mBAAmB,QAAQ,CAACV;QAC5BW,oBAAoB,QAAQ,CAACX;QAC7BY,oBAAoB,QAAQ,CAACZ;QAC7Ba,oBAAoB,QAAQ,CAACb;IACjC;AACJ"}
1
+ {"version":3,"file":"features/security/apiKeys/feature.js","sources":["../../../../src/features/security/apiKeys/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ApiKeysRepository } from \"./shared/ApiKeysRepository.js\";\nimport { GetApiKeyFeature } from \"./GetApiKey/feature.js\";\nimport { GetApiKeyByTokenFeature } from \"./GetApiKeyByToken/feature.js\";\nimport { GetApiKeyBySlugFeature } from \"./GetApiKeyBySlug/feature.js\";\nimport { ListApiKeysFeature } from \"./ListApiKeys/feature.js\";\nimport { CreateApiKeyFeature } from \"./CreateApiKey/feature.js\";\nimport { UpdateApiKeyFeature } from \"./UpdateApiKey/feature.js\";\nimport { DeleteApiKeyFeature } from \"./DeleteApiKey/feature.js\";\nimport {\n ApiKeyFactory,\n ApiKeyProvider as ApiKeyProviderAbstraction\n} from \"~/features/security/apiKeys/shared/abstractions.js\";\nimport { ApiKeyProvider } from \"./shared/ApiKeyProvider.js\";\nimport { ApiKeyAuthenticator } from \"./ApiKeyAuthenticator.js\";\nimport { ApiKeyAuthorizer } from \"./ApiKeyAuthorizer.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\n\nexport const ApiKeysFeature = createFeature({\n name: \"ApiKeys\",\n register(container) {\n // Register repository in singleton scope\n container.register(ApiKeysRepository).inSingletonScope();\n\n container.registerFactory(ApiKeyProviderAbstraction, () => {\n const tenantContext = container.resolve(TenantContext);\n return new ApiKeyProvider(tenantContext, () => {\n return container.resolveAll(ApiKeyFactory);\n });\n });\n container.register(ApiKeyAuthenticator);\n container.register(ApiKeyAuthorizer);\n\n // Register all use cases\n GetApiKeyFeature.register(container);\n GetApiKeyByTokenFeature.register(container);\n GetApiKeyBySlugFeature.register(container);\n ListApiKeysFeature.register(container);\n CreateApiKeyFeature.register(container);\n UpdateApiKeyFeature.register(container);\n DeleteApiKeyFeature.register(container);\n }\n});\n"],"names":["ApiKeysFeature","createFeature","container","ApiKeysRepository","ApiKeyProviderAbstraction","tenantContext","TenantContext","ApiKeyProvider","ApiKeyFactory","ApiKeyAuthenticator","ApiKeyAuthorizer","GetApiKeyFeature","GetApiKeyByTokenFeature","GetApiKeyBySlugFeature","ListApiKeysFeature","CreateApiKeyFeature","UpdateApiKeyFeature","DeleteApiKeyFeature"],"mappings":";;;;;;;;;;;;;;AAkBO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAS;QAEdA,UAAU,QAAQ,CAACC,mBAAmB,gBAAgB;QAEtDD,UAAU,eAAe,CAACE,gBAA2B;YACjD,MAAMC,gBAAgBH,UAAU,OAAO,CAACI;YACxC,OAAO,IAAIC,iCAAeF,eAAe,IAC9BH,UAAU,UAAU,CAACM;QAEpC;QACAN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;QAGnBC,iBAAiB,QAAQ,CAACT;QAC1BU,wBAAwB,QAAQ,CAACV;QACjCW,uBAAuB,QAAQ,CAACX;QAChCY,mBAAmB,QAAQ,CAACZ;QAC5Ba,oBAAoB,QAAQ,CAACb;QAC7Bc,oBAAoB,QAAQ,CAACd;QAC7Be,oBAAoB,QAAQ,CAACf;IACjC;AACJ"}
@@ -2,14 +2,14 @@ import { z } from "zod";
2
2
  export declare const createApiKeyInputSchema: z.ZodObject<{
3
3
  name: z.ZodString;
4
4
  slug: z.ZodString;
5
- description: z.ZodString;
5
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
6
6
  permissions: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
7
7
  name: z.ZodString;
8
8
  }, z.core.$loose>>>>;
9
9
  }, z.core.$strip>;
10
10
  export declare const updateApiKeyInputSchema: z.ZodObject<{
11
11
  name: z.ZodOptional<z.ZodString>;
12
- description: z.ZodOptional<z.ZodString>;
12
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
13
  permissions: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
14
14
  name: z.ZodString;
15
15
  }, z.core.$loose>>>>;
@@ -2,14 +2,14 @@ import { z } from "zod";
2
2
  const createApiKeyInputSchema = z.object({
3
3
  name: z.string().min(1),
4
4
  slug: z.string().min(1),
5
- description: z.string(),
5
+ description: z.string().max(500).nullish(),
6
6
  permissions: z.array(z.looseObject({
7
7
  name: z.string()
8
8
  })).optional().default([])
9
9
  });
10
10
  const updateApiKeyInputSchema = z.object({
11
11
  name: z.string().min(1).optional(),
12
- description: z.string().optional(),
12
+ description: z.string().max(500).nullish(),
13
13
  permissions: z.array(z.looseObject({
14
14
  name: z.string()
15
15
  })).optional().default([])
@@ -1 +1 @@
1
- {"version":3,"file":"features/security/apiKeys/shared/schemas.js","sources":["../../../../../src/features/security/apiKeys/shared/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const createApiKeyInputSchema = z.object({\n name: z.string().min(1),\n slug: z.string().min(1),\n description: z.string(),\n permissions: z\n .array(z.looseObject({ name: z.string() }))\n .optional()\n .default([])\n});\n\nexport const updateApiKeyInputSchema = z.object({\n name: z.string().min(1).optional(),\n description: z.string().optional(),\n permissions: z\n .array(z.looseObject({ name: z.string() }))\n .optional()\n .default([])\n});\n\nexport const listApiKeysInputSchema = z.object({\n where: z\n .object({\n name: z.string().optional(),\n name_contains: z.string().optional(),\n description: z.string().optional(),\n description_contains: z.string().optional()\n })\n .optional(),\n limit: z.number().int().positive().max(100).optional(),\n after: z.string().optional(),\n sort: z.array(z.enum([\"createdOn_ASC\", \"createdOn_DESC\"])).optional()\n});\n"],"names":["createApiKeyInputSchema","z","updateApiKeyInputSchema","listApiKeysInputSchema"],"mappings":";AAEO,MAAMA,0BAA0BC,EAAE,MAAM,CAAC;IAC5C,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC;IACrB,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC;IACrB,aAAaA,EAAE,MAAM;IACrB,aAAaA,EAAAA,KACH,CAACA,EAAE,WAAW,CAAC;QAAE,MAAMA,EAAE,MAAM;IAAG,IACvC,QAAQ,GACR,OAAO,CAAC,EAAE;AACnB;AAEO,MAAMC,0BAA0BD,EAAE,MAAM,CAAC;IAC5C,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ;IAChC,aAAaA,EAAE,MAAM,GAAG,QAAQ;IAChC,aAAaA,EAAAA,KACH,CAACA,EAAE,WAAW,CAAC;QAAE,MAAMA,EAAE,MAAM;IAAG,IACvC,QAAQ,GACR,OAAO,CAAC,EAAE;AACnB;AAEO,MAAME,yBAAyBF,EAAE,MAAM,CAAC;IAC3C,OAAOA,EAAAA,MACI,CAAC;QACJ,MAAMA,EAAE,MAAM,GAAG,QAAQ;QACzB,eAAeA,EAAE,MAAM,GAAG,QAAQ;QAClC,aAAaA,EAAE,MAAM,GAAG,QAAQ;QAChC,sBAAsBA,EAAE,MAAM,GAAG,QAAQ;IAC7C,GACC,QAAQ;IACb,OAAOA,EAAE,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,CAAC,KAAK,QAAQ;IACpD,OAAOA,EAAE,MAAM,GAAG,QAAQ;IAC1B,MAAMA,EAAE,KAAK,CAACA,CAAC,CAADA,OAAM,CAAC;QAAC;QAAiB;KAAiB,GAAG,QAAQ;AACvE"}
1
+ {"version":3,"file":"features/security/apiKeys/shared/schemas.js","sources":["../../../../../src/features/security/apiKeys/shared/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const createApiKeyInputSchema = z.object({\n name: z.string().min(1),\n slug: z.string().min(1),\n // Nullable in the GraphQL schema - see `descriptionOnCreate` for why this is `.nullish()`.\n // This was a bare `z.string()`, so an API key created without a description was rejected\n // whether the client sent null or omitted the field entirely. `max` matches teams and roles.\n description: z.string().max(500).nullish(),\n permissions: z\n .array(z.looseObject({ name: z.string() }))\n .optional()\n .default([])\n});\n\nexport const updateApiKeyInputSchema = z.object({\n name: z.string().min(1).optional(),\n // Nullable in the GraphQL schema - see `descriptionOnUpdate` for why this is `.nullish()` and\n // must not carry a `.transform()`. `max` matches teams and roles.\n description: z.string().max(500).nullish(),\n permissions: z\n .array(z.looseObject({ name: z.string() }))\n .optional()\n .default([])\n});\n\nexport const listApiKeysInputSchema = z.object({\n where: z\n .object({\n name: z.string().optional(),\n name_contains: z.string().optional(),\n description: z.string().optional(),\n description_contains: z.string().optional()\n })\n .optional(),\n limit: z.number().int().positive().max(100).optional(),\n after: z.string().optional(),\n sort: z.array(z.enum([\"createdOn_ASC\", \"createdOn_DESC\"])).optional()\n});\n"],"names":["createApiKeyInputSchema","z","updateApiKeyInputSchema","listApiKeysInputSchema"],"mappings":";AAEO,MAAMA,0BAA0BC,EAAE,MAAM,CAAC;IAC5C,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC;IACrB,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC;IAIrB,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC,KAAK,OAAO;IACxC,aAAaA,EAAAA,KACH,CAACA,EAAE,WAAW,CAAC;QAAE,MAAMA,EAAE,MAAM;IAAG,IACvC,QAAQ,GACR,OAAO,CAAC,EAAE;AACnB;AAEO,MAAMC,0BAA0BD,EAAE,MAAM,CAAC;IAC5C,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ;IAGhC,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC,KAAK,OAAO;IACxC,aAAaA,EAAAA,KACH,CAACA,EAAE,WAAW,CAAC;QAAE,MAAMA,EAAE,MAAM;IAAG,IACvC,QAAQ,GACR,OAAO,CAAC,EAAE;AACnB;AAEO,MAAME,yBAAyBF,EAAE,MAAM,CAAC;IAC3C,OAAOA,EAAAA,MACI,CAAC;QACJ,MAAMA,EAAE,MAAM,GAAG,QAAQ;QACzB,eAAeA,EAAE,MAAM,GAAG,QAAQ;QAClC,aAAaA,EAAE,MAAM,GAAG,QAAQ;QAChC,sBAAsBA,EAAE,MAAM,GAAG,QAAQ;IAC7C,GACC,QAAQ;IACb,OAAOA,EAAE,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,CAAC,KAAK,QAAQ;IACpD,OAAOA,EAAE,MAAM,GAAG,QAAQ;IAC1B,MAAMA,EAAE,KAAK,CAACA,CAAC,CAADA,OAAM,CAAC;QAAC;QAAiB;KAAiB,GAAG,QAAQ;AACvE"}
@@ -2,16 +2,25 @@ import { AuthorizationContext as Abstraction, PermissionTransformer } from "./ab
2
2
  import { Authorizer } from "../Authorizer/index.js";
3
3
  import type { SecurityPermission } from "../../../../types/security.js";
4
4
  import { Identity } from "../../../../features/security/IdentityContext/index.js";
5
+ /**
6
+ * Loads and caches permissions per identity object and tenant for the lifetime of the request.
7
+ * `IdentityContext.withIdentity` can switch the identity mid-request and `TenantContext` the
8
+ * tenant, so permissions loaded for one identity or tenant never answer for another. Keying by the
9
+ * object (not by id or a fingerprint) means two identities with the same id but a different
10
+ * context never share an entry (R69). A failed load is evicted, so the next check retries.
11
+ */
5
12
  export declare class AuthorizationContext implements Abstraction.Interface {
6
13
  private getAuthorizers;
7
14
  private getTransformers;
8
- private permissions?;
9
- private permissionsLoader?;
10
- constructor(getAuthorizers: () => Authorizer.Interface[], getTransformers: () => PermissionTransformer.Interface[]);
15
+ private getTenantId;
16
+ private permissionsByIdentity;
17
+ constructor(getAuthorizers: () => Authorizer.Interface[], getTransformers: () => PermissionTransformer.Interface[], getTenantId: () => string | null);
11
18
  loadPermissions(identity: Identity): Promise<SecurityPermission[]>;
12
19
  isAuthorizationEnabled(): boolean;
13
20
  withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;
21
+ withAuthorization<T>(cb: () => Promise<T>): Promise<T>;
14
22
  clearPermissionsCache(): void;
23
+ private authorize;
15
24
  private transformPermissions;
16
25
  private deduplicatePermissions;
17
26
  }