@webiny/api-core 0.0.0-unstable.0d717d18dd → 0.0.0-unstable.33e4fd9647

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 (313) hide show
  1. package/ApiCoreFeature.js +12 -0
  2. package/ApiCoreFeature.js.map +1 -1
  3. package/exports/api/tasks.d.ts +1 -0
  4. package/exports/api/tasks.js +1 -1
  5. package/exports/api.d.ts +1 -1
  6. package/exports/api.js +1 -1
  7. package/features/ai/Ai.d.ts +3 -1
  8. package/features/ai/Ai.js +36 -28
  9. package/features/ai/Ai.js.map +1 -1
  10. package/features/ai/AiModelRegistry.d.ts +14 -0
  11. package/features/ai/AiModelRegistry.js +39 -0
  12. package/features/ai/AiModelRegistry.js.map +1 -0
  13. package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
  14. package/features/ai/AiSdkToolHandlerResolver.js +19 -0
  15. package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
  16. package/features/ai/AiSdkTools.d.ts +4 -3
  17. package/features/ai/AiSdkTools.js +11 -9
  18. package/features/ai/AiSdkTools.js.map +1 -1
  19. package/features/ai/AnthropicSdkFactory.js +12 -4
  20. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  21. package/features/ai/DEVELOPERS.md +183 -0
  22. package/features/ai/GoogleSdkFactory.d.ts +10 -0
  23. package/features/ai/GoogleSdkFactory.js +65 -0
  24. package/features/ai/GoogleSdkFactory.js.map +1 -0
  25. package/features/ai/OpenAiSdkFactory.js +51 -11
  26. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  27. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  28. package/features/ai/OpenRouterSdkFactory.js +112 -0
  29. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  30. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  31. package/features/ai/RemoteAiModelCatalog.js +74 -0
  32. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  33. package/features/ai/abstractions.d.ts +102 -7
  34. package/features/ai/abstractions.js +6 -2
  35. package/features/ai/abstractions.js.map +1 -1
  36. package/features/ai/feature.js +10 -0
  37. package/features/ai/feature.js.map +1 -1
  38. package/features/ai/index.d.ts +2 -4
  39. package/features/ai/index.js +1 -1
  40. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  41. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  42. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  43. package/features/dateFormatter/abstractions.d.ts +13 -0
  44. package/features/dateFormatter/abstractions.js +5 -0
  45. package/features/dateFormatter/abstractions.js.map +1 -0
  46. package/features/dateFormatter/feature.d.ts +4 -0
  47. package/features/dateFormatter/feature.js +11 -0
  48. package/features/dateFormatter/feature.js.map +1 -0
  49. package/features/dateFormatter/index.d.ts +3 -0
  50. package/features/dateFormatter/index.js +2 -0
  51. package/features/debugger/Debugger.d.ts +30 -0
  52. package/features/debugger/Debugger.js +142 -0
  53. package/features/debugger/Debugger.js.map +1 -0
  54. package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
  55. package/features/debugger/DebuggerRouteDecorator.js +107 -0
  56. package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
  57. package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
  58. package/features/debugger/GraphQLDebuggerTransport.js +45 -0
  59. package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
  60. package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
  61. package/features/debugger/__tests__/matchNamespace.test.js +68 -0
  62. package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
  63. package/features/debugger/__tests__/serialize.test.d.ts +1 -0
  64. package/features/debugger/__tests__/serialize.test.js +220 -0
  65. package/features/debugger/__tests__/serialize.test.js.map +1 -0
  66. package/features/debugger/abstractions.d.ts +100 -0
  67. package/features/debugger/abstractions.js +6 -0
  68. package/features/debugger/abstractions.js.map +1 -0
  69. package/features/debugger/feature.d.ts +5 -0
  70. package/features/debugger/feature.js +15 -0
  71. package/features/debugger/feature.js.map +1 -0
  72. package/features/debugger/index.d.ts +12 -0
  73. package/features/debugger/index.js +7 -0
  74. package/features/debugger/limits.d.ts +18 -0
  75. package/features/debugger/limits.js +11 -0
  76. package/features/debugger/limits.js.map +1 -0
  77. package/features/debugger/matchNamespace.d.ts +14 -0
  78. package/features/debugger/matchNamespace.js +35 -0
  79. package/features/debugger/matchNamespace.js.map +1 -0
  80. package/features/debugger/parseNamespaceHeader.d.ts +7 -0
  81. package/features/debugger/parseNamespaceHeader.js +16 -0
  82. package/features/debugger/parseNamespaceHeader.js.map +1 -0
  83. package/features/debugger/permissions.d.ts +14 -0
  84. package/features/debugger/permissions.js +8 -0
  85. package/features/debugger/permissions.js.map +1 -0
  86. package/features/debugger/permissionsSchema.d.ts +17 -0
  87. package/features/debugger/permissionsSchema.js +18 -0
  88. package/features/debugger/permissionsSchema.js.map +1 -0
  89. package/features/debugger/serialize.d.ts +11 -0
  90. package/features/debugger/serialize.js +121 -0
  91. package/features/debugger/serialize.js.map +1 -0
  92. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  93. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  94. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  95. package/features/encryption/EncryptionService.d.ts +2 -1
  96. package/features/encryption/EncryptionService.js +11 -4
  97. package/features/encryption/EncryptionService.js.map +1 -1
  98. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  99. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  100. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  101. package/features/encryption/abstractions.d.ts +11 -0
  102. package/features/encryption/abstractions.js +2 -1
  103. package/features/encryption/abstractions.js.map +1 -1
  104. package/features/encryption/index.d.ts +1 -0
  105. package/features/encryption/index.js +1 -0
  106. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  107. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +62 -0
  108. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  109. package/features/httpClient/HttpClient.d.ts +7 -0
  110. package/features/httpClient/HttpClient.js +72 -0
  111. package/features/httpClient/HttpClient.js.map +1 -0
  112. package/features/httpClient/HttpRequestError.d.ts +10 -0
  113. package/features/httpClient/HttpRequestError.js +13 -0
  114. package/features/httpClient/HttpRequestError.js.map +1 -0
  115. package/features/httpClient/HttpStatusError.d.ts +12 -0
  116. package/features/httpClient/HttpStatusError.js +12 -0
  117. package/features/httpClient/HttpStatusError.js.map +1 -0
  118. package/features/httpClient/abstractions.d.ts +32 -0
  119. package/features/httpClient/abstractions.js +5 -0
  120. package/features/httpClient/abstractions.js.map +1 -0
  121. package/features/httpClient/feature.d.ts +4 -0
  122. package/features/httpClient/feature.js +11 -0
  123. package/features/httpClient/feature.js.map +1 -0
  124. package/features/httpClient/index.d.ts +3 -0
  125. package/features/httpClient/index.js +3 -0
  126. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  127. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  128. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  129. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  130. package/features/keyValueStore/KeyValueStore.js +13 -3
  131. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  132. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  133. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  134. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  135. package/features/keyValueStore/abstractions.d.ts +132 -14
  136. package/features/keyValueStore/abstractions.js.map +1 -1
  137. package/features/keyValueStore/errors.d.ts +29 -0
  138. package/features/keyValueStore/errors.js +49 -1
  139. package/features/keyValueStore/errors.js.map +1 -1
  140. package/features/keyValueStore/index.d.ts +4 -1
  141. package/features/keyValueStore/index.js +1 -1
  142. package/features/publicUrls/NullPublicUrls.d.ts +11 -0
  143. package/features/publicUrls/NullPublicUrls.js +17 -0
  144. package/features/publicUrls/NullPublicUrls.js.map +1 -0
  145. package/features/publicUrls/PublicUrl.d.ts +24 -0
  146. package/features/publicUrls/PublicUrl.js +43 -0
  147. package/features/publicUrls/PublicUrl.js.map +1 -0
  148. package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
  149. package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
  150. package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
  151. package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
  152. package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
  153. package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
  154. package/features/publicUrls/abstractions.d.ts +27 -0
  155. package/features/publicUrls/abstractions.js +5 -0
  156. package/features/publicUrls/abstractions.js.map +1 -0
  157. package/features/publicUrls/feature.d.ts +8 -0
  158. package/features/publicUrls/feature.js +11 -0
  159. package/features/publicUrls/feature.js.map +1 -0
  160. package/features/publicUrls/index.d.ts +3 -0
  161. package/features/publicUrls/index.js +3 -0
  162. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  163. package/features/requestContext/RawAssumePermissions.js +19 -0
  164. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  165. package/features/requestContext/abstractions.d.ts +22 -0
  166. package/features/requestContext/abstractions.js +2 -1
  167. package/features/requestContext/abstractions.js.map +1 -1
  168. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  169. package/features/requestContext/extractAssumePermissions.js +32 -0
  170. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  171. package/features/requestContext/feature.d.ts +2 -1
  172. package/features/requestContext/feature.js +2 -0
  173. package/features/requestContext/feature.js.map +1 -1
  174. package/features/requestContext/index.d.ts +3 -1
  175. package/features/requestContext/index.js +2 -1
  176. package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
  177. package/features/security/IdentityContext/IdentityContext.js +6 -6
  178. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  179. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  180. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  181. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  182. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  183. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  184. package/features/security/apiKeys/shared/schemas.js +2 -2
  185. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  186. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  187. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  188. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  189. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
  190. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  191. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  192. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  193. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  194. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  195. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  196. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  197. package/features/security/roles/CreateRole/schema.js +1 -1
  198. package/features/security/roles/CreateRole/schema.js.map +1 -1
  199. package/features/security/roles/Installer/RolesInstaller.js +1 -0
  200. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  201. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  202. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  203. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  204. package/features/security/roles/UpdateRole/schema.js +1 -1
  205. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  206. package/features/security/shared/description.d.ts +4 -0
  207. package/features/security/shared/description.js +7 -0
  208. package/features/security/shared/description.js.map +1 -0
  209. package/features/security/shared/index.d.ts +1 -0
  210. package/features/security/shared/index.js +1 -0
  211. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  212. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  213. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  214. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  215. package/features/security/teams/CreateTeam/schema.js +1 -1
  216. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  217. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  218. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  219. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  220. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  221. package/features/security/teams/UpdateTeam/schema.js +1 -1
  222. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  223. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  224. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  225. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  226. package/features/slugify/DefaultSlugify.d.ts +8 -0
  227. package/features/slugify/DefaultSlugify.js +20 -0
  228. package/features/slugify/DefaultSlugify.js.map +1 -0
  229. package/features/slugify/abstractions.d.ts +12 -0
  230. package/features/slugify/abstractions.js +5 -0
  231. package/features/slugify/abstractions.js.map +1 -0
  232. package/features/slugify/feature.d.ts +4 -0
  233. package/features/slugify/feature.js +11 -0
  234. package/features/slugify/feature.js.map +1 -0
  235. package/features/slugify/index.d.ts +3 -0
  236. package/features/slugify/index.js +2 -0
  237. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  238. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  239. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  240. package/features/stringFormatter/abstractions.d.ts +11 -0
  241. package/features/stringFormatter/abstractions.js +5 -0
  242. package/features/stringFormatter/abstractions.js.map +1 -0
  243. package/features/stringFormatter/feature.d.ts +4 -0
  244. package/features/stringFormatter/feature.js +13 -0
  245. package/features/stringFormatter/feature.js.map +1 -0
  246. package/features/stringFormatter/index.d.ts +3 -0
  247. package/features/stringFormatter/index.js +2 -0
  248. package/features/task/TaskDefinition/abstractions.d.ts +69 -4
  249. package/features/task/TaskDefinition/abstractions.js +2 -1
  250. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  251. package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
  252. package/features/tenancy/TenantContext/TenantContext.js +13 -8
  253. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  254. package/features/wcp/WcpContext/WcpContext.d.ts +7 -0
  255. package/features/wcp/WcpContext/WcpContext.js +21 -0
  256. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  257. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +10 -69
  258. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +66 -35
  259. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  260. package/features/wcp/WcpFeature.js +2 -0
  261. package/features/wcp/WcpFeature.js.map +1 -1
  262. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  263. package/features/wcp/WcpLicenseLoader.js +58 -0
  264. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  265. package/features/wcp/WcpLicenseProvider.d.ts +6 -14
  266. package/features/wcp/WcpLicenseProvider.js +3 -7
  267. package/features/wcp/WcpLicenseProvider.js.map +1 -1
  268. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  269. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  270. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  271. package/graphql/ApiCoreSchemaFactory.d.ts +1 -0
  272. package/graphql/ApiCoreSchemaFactory.js +7 -1
  273. package/graphql/ApiCoreSchemaFactory.js.map +1 -1
  274. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
  275. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
  276. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  277. package/graphql/security/SecuritySchemaFactory.d.ts +1 -0
  278. package/graphql/security/SecuritySchemaFactory.js +4 -0
  279. package/graphql/security/SecuritySchemaFactory.js.map +1 -1
  280. package/graphql/system/SystemSchemaFactory.d.ts +1 -0
  281. package/graphql/system/SystemSchemaFactory.js +4 -0
  282. package/graphql/system/SystemSchemaFactory.js.map +1 -1
  283. package/graphql/users/UsersSchemaFactory.d.ts +1 -0
  284. package/graphql/users/UsersSchemaFactory.js +4 -0
  285. package/graphql/users/UsersSchemaFactory.js.map +1 -1
  286. package/graphql/wcp/WcpSchemaFactory.d.ts +1 -0
  287. package/graphql/wcp/WcpSchemaFactory.js +5 -0
  288. package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
  289. package/idp/JwksCache.d.ts +14 -3
  290. package/idp/JwksCache.js +97 -17
  291. package/idp/JwksCache.js.map +1 -1
  292. package/idp/JwksStoreFeature.d.ts +8 -0
  293. package/idp/JwksStoreFeature.js +11 -0
  294. package/idp/JwksStoreFeature.js.map +1 -0
  295. package/idp/MemoryJwksStore.d.ts +14 -0
  296. package/idp/MemoryJwksStore.js +21 -0
  297. package/idp/MemoryJwksStore.js.map +1 -0
  298. package/idp/OidcJwtIdentityProvider.js +5 -1
  299. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  300. package/idp/abstractions.d.ts +24 -0
  301. package/idp/abstractions.js +2 -1
  302. package/idp/abstractions.js.map +1 -1
  303. package/idp/feature.js +1 -2
  304. package/idp/feature.js.map +1 -1
  305. package/idp/index.d.ts +1 -0
  306. package/idp/index.js +1 -0
  307. package/package.json +20 -18
  308. package/testing/environment.d.ts +14 -0
  309. package/testing/environment.js +18 -0
  310. package/testing/environment.js.map +1 -0
  311. package/features/wcp/loadWcpLicense.d.ts +0 -2
  312. package/features/wcp/loadWcpLicense.js +0 -51
  313. package/features/wcp/loadWcpLicense.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Registers the default, which knows no URLs. Each hosting type overrides it through the
3
+ * `publicUrls` hook of `registerApiRequestStack`.
4
+ */
5
+ export declare const PublicUrlsFeature: {
6
+ name: string;
7
+ register(container: import("@webiny/di").Container): void;
8
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { NullPublicUrls } from "./NullPublicUrls.js";
3
+ const PublicUrlsFeature = createFeature({
4
+ name: "PublicUrlsFeature",
5
+ register (container) {
6
+ container.register(NullPublicUrls);
7
+ }
8
+ });
9
+ export { PublicUrlsFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/publicUrls/feature.js","sources":["../../../src/features/publicUrls/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { NullPublicUrls } from \"./NullPublicUrls.js\";\n\n/**\n * Registers the default, which knows no URLs. Each hosting type overrides it through the\n * `publicUrls` hook of `registerApiRequestStack`.\n */\nexport const PublicUrlsFeature = createFeature({\n name: \"PublicUrlsFeature\",\n register(container) {\n container.register(NullPublicUrls);\n }\n});\n"],"names":["PublicUrlsFeature","createFeature","container","NullPublicUrls"],"mappings":";;AAOO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -0,0 +1,3 @@
1
+ export { PublicUrls } from "./abstractions.js";
2
+ export { PublicUrl } from "./PublicUrl.js";
3
+ export { PublicUrlsFeature } from "./feature.js";
@@ -0,0 +1,3 @@
1
+ export { PublicUrls } from "./abstractions.js";
2
+ export { PublicUrl } from "./PublicUrl.js";
3
+ export { PublicUrlsFeature } from "./feature.js";
@@ -0,0 +1,14 @@
1
+ import { RawAssumePermissions as Abstraction } from "./abstractions.js";
2
+ /**
3
+ * Per-request holder for the transport-extracted preview target. Registered per request, so a
4
+ * fresh instance holds the value for the current request only.
5
+ */
6
+ declare class RawAssumePermissionsImpl implements Abstraction.Interface {
7
+ private value;
8
+ get(): Abstraction.Target | null;
9
+ set(value: Abstraction.Target | null): void;
10
+ }
11
+ export declare const RawAssumePermissions: typeof RawAssumePermissionsImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IRawAssumePermissions>;
13
+ };
14
+ export {};
@@ -0,0 +1,19 @@
1
+ import { RawAssumePermissions } from "./abstractions.js";
2
+ class RawAssumePermissionsImpl {
3
+ get() {
4
+ return this.value;
5
+ }
6
+ set(value) {
7
+ this.value = value;
8
+ }
9
+ constructor(){
10
+ this.value = null;
11
+ }
12
+ }
13
+ const RawAssumePermissions_RawAssumePermissions = RawAssumePermissions.createImplementation({
14
+ implementation: RawAssumePermissionsImpl,
15
+ dependencies: []
16
+ });
17
+ export { RawAssumePermissions_RawAssumePermissions as RawAssumePermissions };
18
+
19
+ //# sourceMappingURL=RawAssumePermissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/requestContext/RawAssumePermissions.js","sources":["../../../src/features/requestContext/RawAssumePermissions.ts"],"sourcesContent":["import { RawAssumePermissions as Abstraction } from \"./abstractions.js\";\n\n/**\n * Per-request holder for the transport-extracted preview target. Registered per request, so a\n * fresh instance holds the value for the current request only.\n */\nclass RawAssumePermissionsImpl implements Abstraction.Interface {\n private value: Abstraction.Target | null = null;\n\n get(): Abstraction.Target | null {\n return this.value;\n }\n\n set(value: Abstraction.Target | null): void {\n this.value = value;\n }\n}\n\nexport const RawAssumePermissions = Abstraction.createImplementation({\n implementation: RawAssumePermissionsImpl,\n dependencies: []\n});\n"],"names":["RawAssumePermissionsImpl","value","RawAssumePermissions","Abstraction"],"mappings":";AAMA,MAAMA;IAGF,MAAiC;QAC7B,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAIC,KAAgC,EAAQ;QACxC,IAAI,CAAC,KAAK,GAAGA;IACjB;;aARQ,KAAK,GAA8B;;AAS/C;AAEO,MAAMC,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -29,6 +29,28 @@ export declare const RawAuthToken: import("@webiny/di").Abstraction<IRawAuthToke
29
29
  export declare namespace RawAuthToken {
30
30
  type Interface = IRawAuthToken;
31
31
  }
32
+ /**
33
+ * Per-request holder for the role or team the caller asked to be evaluated as, EXTRACTED by the
34
+ * transport from the `x-webiny-assume-permissions` header. This is a preview mechanism: it can
35
+ * only ever narrow what a caller may do, never widen it. AssumedPermissions reads this holder and
36
+ * substitutes the permission set, but only after confirming the caller's own permissions grant
37
+ * full access.
38
+ *
39
+ * Note: only the HTTP transports set this. S3 and background tasks have no caller to preview as.
40
+ */
41
+ export interface IAssumePermissionsTarget {
42
+ type: "role" | "team";
43
+ id: string;
44
+ }
45
+ export interface IRawAssumePermissions {
46
+ get(): IAssumePermissionsTarget | null;
47
+ set(value: IAssumePermissionsTarget | null): void;
48
+ }
49
+ export declare const RawAssumePermissions: import("@webiny/di").Abstraction<IRawAssumePermissions>;
50
+ export declare namespace RawAssumePermissions {
51
+ type Interface = IRawAssumePermissions;
52
+ type Target = IAssumePermissionsTarget;
53
+ }
32
54
  /**
33
55
  * LOAD step: authenticates the token held by RawAuthToken and sets IdentityContext. Fully
34
56
  * transport-agnostic — transports only EXTRACT the token into RawAuthToken.
@@ -1,8 +1,9 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
2
  const RawTenantId = createAbstraction("RequestContext/RawTenantId");
3
3
  const RawAuthToken = createAbstraction("RequestContext/RawAuthToken");
4
+ const RawAssumePermissions = createAbstraction("RequestContext/RawAssumePermissions");
4
5
  const RequestIdentityLoader = createAbstraction("RequestContext/RequestIdentityLoader");
5
6
  const RequestTenantLoader = createAbstraction("RequestContext/RequestTenantLoader");
6
- export { RawAuthToken, RawTenantId, RequestIdentityLoader, RequestTenantLoader };
7
+ export { RawAssumePermissions, RawAuthToken, RawTenantId, RequestIdentityLoader, RequestTenantLoader };
7
8
 
8
9
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/requestContext/abstractions.js","sources":["../../../src/features/requestContext/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\n/**\n * Per-request holder for the raw tenant id EXTRACTED by the transport (e.g. the `x-tenant` header\n * of an API Gateway event, the bucket name of an S3 event, or `payload.tenant` of a background\n * task). The transport-specific EXTRACT step sets this; the transport-agnostic LOAD step\n * (RequestTenantLoader) reads it, resolves the Tenant, and sets TenantContext.\n */\nexport interface IRawTenantId {\n get(): string | null;\n set(id: string | null): void;\n}\n\nexport const RawTenantId = createAbstraction<IRawTenantId>(\"RequestContext/RawTenantId\");\n\nexport namespace RawTenantId {\n export type Interface = IRawTenantId;\n}\n\n/**\n * Per-request holder for the raw auth token EXTRACTED by the transport (e.g. the `Authorization`\n * bearer header or an auth cookie of an API Gateway event). Only token-based transports set this;\n * the transport-agnostic LOAD step (RequestIdentityLoader) reads it, authenticates it, and\n * sets IdentityContext. A null/absent value authenticates as anonymous.\n *\n * Note: non-token transports (S3, background tasks) never set this — S3 has no user identity, and\n * background-task identity is derived from `task.createdBy` after the task is fetched.\n */\nexport interface IRawAuthToken {\n get(): string | null;\n set(token: string | null): void;\n}\n\nexport const RawAuthToken = createAbstraction<IRawAuthToken>(\"RequestContext/RawAuthToken\");\n\nexport namespace RawAuthToken {\n export type Interface = IRawAuthToken;\n}\n\n/**\n * LOAD step: authenticates the token held by RawAuthToken and sets IdentityContext. Fully\n * transport-agnostic — transports only EXTRACT the token into RawAuthToken.\n */\nexport interface IRequestIdentityLoader {\n establish(): Promise<void>;\n}\n\nexport const RequestIdentityLoader = createAbstraction<IRequestIdentityLoader>(\n \"RequestContext/RequestIdentityLoader\"\n);\n\nexport namespace RequestIdentityLoader {\n export type Interface = IRequestIdentityLoader;\n}\n\n/**\n * LOAD step: resolves the Tenant for the id held by RawTenantId and sets TenantContext. Fully\n * transport-agnostic — transports only EXTRACT the id into RawTenantId.\n */\nexport interface IRequestTenantLoader {\n establish(): Promise<void>;\n}\n\nexport const RequestTenantLoader = createAbstraction<IRequestTenantLoader>(\n \"RequestContext/RequestTenantLoader\"\n);\n\nexport namespace RequestTenantLoader {\n export type Interface = IRequestTenantLoader;\n}\n"],"names":["RawTenantId","createAbstraction","RawAuthToken","RequestIdentityLoader","RequestTenantLoader"],"mappings":";AAaO,MAAMA,cAAcC,kBAAgC;AAoBpD,MAAMC,eAAeD,kBAAiC;AActD,MAAME,wBAAwBF,kBACjC;AAeG,MAAMG,sBAAsBH,kBAC/B"}
1
+ {"version":3,"file":"features/requestContext/abstractions.js","sources":["../../../src/features/requestContext/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\n/**\n * Per-request holder for the raw tenant id EXTRACTED by the transport (e.g. the `x-tenant` header\n * of an API Gateway event, the bucket name of an S3 event, or `payload.tenant` of a background\n * task). The transport-specific EXTRACT step sets this; the transport-agnostic LOAD step\n * (RequestTenantLoader) reads it, resolves the Tenant, and sets TenantContext.\n */\nexport interface IRawTenantId {\n get(): string | null;\n set(id: string | null): void;\n}\n\nexport const RawTenantId = createAbstraction<IRawTenantId>(\"RequestContext/RawTenantId\");\n\nexport namespace RawTenantId {\n export type Interface = IRawTenantId;\n}\n\n/**\n * Per-request holder for the raw auth token EXTRACTED by the transport (e.g. the `Authorization`\n * bearer header or an auth cookie of an API Gateway event). Only token-based transports set this;\n * the transport-agnostic LOAD step (RequestIdentityLoader) reads it, authenticates it, and\n * sets IdentityContext. A null/absent value authenticates as anonymous.\n *\n * Note: non-token transports (S3, background tasks) never set this — S3 has no user identity, and\n * background-task identity is derived from `task.createdBy` after the task is fetched.\n */\nexport interface IRawAuthToken {\n get(): string | null;\n set(token: string | null): void;\n}\n\nexport const RawAuthToken = createAbstraction<IRawAuthToken>(\"RequestContext/RawAuthToken\");\n\nexport namespace RawAuthToken {\n export type Interface = IRawAuthToken;\n}\n\n/**\n * Per-request holder for the role or team the caller asked to be evaluated as, EXTRACTED by the\n * transport from the `x-webiny-assume-permissions` header. This is a preview mechanism: it can\n * only ever narrow what a caller may do, never widen it. AssumedPermissions reads this holder and\n * substitutes the permission set, but only after confirming the caller's own permissions grant\n * full access.\n *\n * Note: only the HTTP transports set this. S3 and background tasks have no caller to preview as.\n */\nexport interface IAssumePermissionsTarget {\n /*\n * Whose permissions to assume. A team is a set of roles, so assuming one means the union of its\n * roles' permissions. Assuming a user's permissions would be another type here, resolved to\n * that user's roles and teams the same way.\n */\n type: \"role\" | \"team\";\n id: string;\n}\n\nexport interface IRawAssumePermissions {\n get(): IAssumePermissionsTarget | null;\n set(value: IAssumePermissionsTarget | null): void;\n}\n\nexport const RawAssumePermissions = createAbstraction<IRawAssumePermissions>(\n \"RequestContext/RawAssumePermissions\"\n);\n\nexport namespace RawAssumePermissions {\n export type Interface = IRawAssumePermissions;\n export type Target = IAssumePermissionsTarget;\n}\n\n/**\n * LOAD step: authenticates the token held by RawAuthToken and sets IdentityContext. Fully\n * transport-agnostic — transports only EXTRACT the token into RawAuthToken.\n */\nexport interface IRequestIdentityLoader {\n establish(): Promise<void>;\n}\n\nexport const RequestIdentityLoader = createAbstraction<IRequestIdentityLoader>(\n \"RequestContext/RequestIdentityLoader\"\n);\n\nexport namespace RequestIdentityLoader {\n export type Interface = IRequestIdentityLoader;\n}\n\n/**\n * LOAD step: resolves the Tenant for the id held by RawTenantId and sets TenantContext. Fully\n * transport-agnostic — transports only EXTRACT the id into RawTenantId.\n */\nexport interface IRequestTenantLoader {\n establish(): Promise<void>;\n}\n\nexport const RequestTenantLoader = createAbstraction<IRequestTenantLoader>(\n \"RequestContext/RequestTenantLoader\"\n);\n\nexport namespace RequestTenantLoader {\n export type Interface = IRequestTenantLoader;\n}\n"],"names":["RawTenantId","createAbstraction","RawAuthToken","RawAssumePermissions","RequestIdentityLoader","RequestTenantLoader"],"mappings":";AAaO,MAAMA,cAAcC,kBAAgC;AAoBpD,MAAMC,eAAeD,kBAAiC;AA8BtD,MAAME,uBAAuBF,kBAChC;AAgBG,MAAMG,wBAAwBH,kBACjC;AAeG,MAAMI,sBAAsBJ,kBAC/B"}
@@ -0,0 +1,14 @@
1
+ import { RawAssumePermissions } from "./abstractions.js";
2
+ export declare const ASSUME_PERMISSIONS_HEADER = "x-webiny-assume-permissions";
3
+ type HeaderValue = string | string[] | undefined;
4
+ type Headers = Record<string, HeaderValue> | undefined;
5
+ /**
6
+ * Reads the `x-webiny-assume-permissions` header and parses it into the role or team whose
7
+ * permissions should be previewed. The value is `role:<id>` or `team:<id>`.
8
+ *
9
+ * Anything else parses to null, which leaves the caller's own permissions untouched. Lives in
10
+ * api-core rather than in a transport package so the HTTP transports cannot drift on the format or
11
+ * on header casing.
12
+ */
13
+ export declare function extractAssumePermissions(headers: Headers): RawAssumePermissions.Target | null;
14
+ export {};
@@ -0,0 +1,32 @@
1
+ const ASSUME_PERMISSIONS_HEADER = "x-webiny-assume-permissions";
2
+ function readHeader(headers, name) {
3
+ if (!headers) return null;
4
+ for (const key of Object.keys(headers)){
5
+ if (key.toLowerCase() !== name) continue;
6
+ const value = headers[key];
7
+ if (Array.isArray(value)) return value[0] ?? null;
8
+ return value ?? null;
9
+ }
10
+ return null;
11
+ }
12
+ function extractAssumePermissions(headers) {
13
+ const value = readHeader(headers, ASSUME_PERMISSIONS_HEADER);
14
+ if (!value) return null;
15
+ const separatorIndex = value.indexOf(":");
16
+ if (separatorIndex < 1) return null;
17
+ const type = value.slice(0, separatorIndex).trim();
18
+ const id = value.slice(separatorIndex + 1).trim();
19
+ if ("" === id) return null;
20
+ if ("role" === type) return {
21
+ type: "role",
22
+ id
23
+ };
24
+ if ("team" === type) return {
25
+ type: "team",
26
+ id
27
+ };
28
+ return null;
29
+ }
30
+ export { ASSUME_PERMISSIONS_HEADER, extractAssumePermissions };
31
+
32
+ //# sourceMappingURL=extractAssumePermissions.js.map
@@ -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"}
@@ -1,7 +1,8 @@
1
1
  import type { Container } from "@webiny/di";
2
2
  /**
3
3
  * Registers the request-context pieces:
4
- * - RawTenantId / RawAuthToken: per-request holders that the transport's EXTRACT step writes to.
4
+ * - RawTenantId / RawAuthToken / RawAssumePermissions: per-request holders that the transport's
5
+ * EXTRACT step writes to.
5
6
  * - RequestIdentityLoader / RequestTenantLoader: transport-agnostic LOAD steps that read
6
7
  * the holders and set IdentityContext / TenantContext.
7
8
  */
@@ -1,6 +1,7 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { RawTenantId } from "./RawTenantId.js";
3
3
  import { RawAuthToken } from "./RawAuthToken.js";
4
+ import { RawAssumePermissions } from "./RawAssumePermissions.js";
4
5
  import { RequestIdentityLoader } from "./RequestIdentityLoader.js";
5
6
  import { RequestTenantLoader } from "./RequestTenantLoader.js";
6
7
  const RequestContextFeature = createFeature({
@@ -8,6 +9,7 @@ const RequestContextFeature = createFeature({
8
9
  register (container) {
9
10
  container.register(RawTenantId).inSingletonScope();
10
11
  container.register(RawAuthToken).inSingletonScope();
12
+ container.register(RawAssumePermissions).inSingletonScope();
11
13
  container.register(RequestIdentityLoader);
12
14
  container.register(RequestTenantLoader);
13
15
  }
@@ -1 +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 { RequestIdentityLoader } from \"./RequestIdentityLoader.js\";\nimport { RequestTenantLoader } from \"./RequestTenantLoader.js\";\n\n/**\n * Registers the request-context pieces:\n * - RawTenantId / RawAuthToken: per-request holders that the transport's 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(RequestIdentityLoader);\n container.register(RequestTenantLoader);\n }\n});\n"],"names":["RequestContextFeature","createFeature","container","RawTenantId","RawAuthToken","RequestIdentityLoader","RequestTenantLoader"],"mappings":";;;;;AAaO,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;QACnBH,UAAU,QAAQ,CAACI;IACvB;AACJ"}
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"}
@@ -1,2 +1,4 @@
1
- export { RawTenantId, RawAuthToken, RequestIdentityLoader, RequestTenantLoader } from "./abstractions.js";
1
+ export { RawTenantId, RawAuthToken, RawAssumePermissions, RequestIdentityLoader, RequestTenantLoader } from "./abstractions.js";
2
2
  export { RequestContextFeature } from "./feature.js";
3
+ export { ASSUME_PERMISSIONS_HEADER } from "./extractAssumePermissions.js";
4
+ export { extractAssumePermissions } from "./extractAssumePermissions.js";
@@ -1,2 +1,3 @@
1
- export { RawAuthToken, RawTenantId, RequestIdentityLoader, RequestTenantLoader } from "./abstractions.js";
1
+ export { RawAssumePermissions, RawAuthToken, RawTenantId, RequestIdentityLoader, RequestTenantLoader } from "./abstractions.js";
2
2
  export { RequestContextFeature } from "./feature.js";
3
+ export { ASSUME_PERMISSIONS_HEADER, extractAssumePermissions } from "./extractAssumePermissions.js";
@@ -2,12 +2,12 @@ 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>;
@@ -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() {
@@ -63,8 +63,8 @@ class IdentityContextImpl {
63
63
  return permissions.some((p)=>"*" === p.name);
64
64
  }
65
65
  applyAaclLogic(permissions) {
66
- const aaclEnabled = this.wcpContext.canUseAacl();
67
- const teamsEnabled = this.wcpContext.canUseTeams();
66
+ const aaclEnabled = this.featureFlags.get().isEnabled("advancedAccessControlLayer");
67
+ const teamsEnabled = this.featureFlags.get().isEnabled("advancedAccessControlLayer.teams");
68
68
  if (aaclEnabled) return [
69
69
  ...permissions,
70
70
  {
@@ -80,7 +80,7 @@ const IdentityContext_IdentityContext = createImplementation({
80
80
  implementation: IdentityContextImpl,
81
81
  dependencies: [
82
82
  AuthorizationContext,
83
- WcpContext
83
+ FeatureFlags
84
84
  ]
85
85
  });
86
86
  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 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,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"}
@@ -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"}
@@ -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"}
@@ -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"}
@@ -0,0 +1,30 @@
1
+ import { FeatureFlags } from "../../../../features/featureFlags/abstractions.js";
2
+ import { RawAssumePermissions } from "../../../../features/requestContext/abstractions.js";
3
+ import { Identity } from "../../../../features/security/IdentityContext/index.js";
4
+ import { RolesRepository } from "../../../../features/security/roles/shared/abstractions.js";
5
+ import { TeamsRepository } from "../../../../features/security/teams/shared/abstractions.js";
6
+ import { PermissionsProcessor } from "./abstractions.js";
7
+ /**
8
+ * Evaluates the request against a role or team the caller asked to preview, instead of against the
9
+ * caller's own roles. This is what makes "view the Admin as an Editor" honest: lists shrink and
10
+ * writes fail server-side, rather than the Admin merely hiding buttons over unrestricted data.
11
+ *
12
+ * Previewing is available only to callers who already have full access, and it can only ever take
13
+ * permissions away. See the guard in `getPermissions` for why the check cannot go through
14
+ * IdentityContext.
15
+ */
16
+ declare class AssumedPermissionsImpl implements PermissionsProcessor.Interface {
17
+ private rawAssumePermissions;
18
+ private featureFlags;
19
+ private rolesRepository;
20
+ private teamsRepository;
21
+ private decoratee;
22
+ constructor(rawAssumePermissions: RawAssumePermissions.Interface, featureFlags: FeatureFlags.Interface, rolesRepository: RolesRepository.Interface, teamsRepository: TeamsRepository.Interface, decoratee: PermissionsProcessor.Interface);
23
+ getPermissions(identity: Identity): Promise<PermissionsProcessor.Permissions | null>;
24
+ private loadAssumedRoles;
25
+ private loadRoles;
26
+ }
27
+ export declare const AssumedPermissions: typeof AssumedPermissionsImpl & {
28
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IPermissionsProcessor>;
29
+ };
30
+ export {};