@webiny/api-core 0.0.0-unstable.a4f3e4ea8b → 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 (442) 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.js +16 -6
  9. package/features/ai/Ai.js.map +1 -1
  10. package/features/ai/AiModelRegistry.d.ts +3 -1
  11. package/features/ai/AiModelRegistry.js +16 -7
  12. package/features/ai/AiModelRegistry.js.map +1 -1
  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/DEVELOPERS.md +69 -12
  20. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  21. package/features/ai/OpenRouterSdkFactory.js +112 -0
  22. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  23. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  24. package/features/ai/RemoteAiModelCatalog.js +74 -0
  25. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  26. package/features/ai/abstractions.d.ts +90 -7
  27. package/features/ai/abstractions.js +5 -2
  28. package/features/ai/abstractions.js.map +1 -1
  29. package/features/ai/feature.js +6 -0
  30. package/features/ai/feature.js.map +1 -1
  31. package/features/ai/index.d.ts +2 -4
  32. package/features/ai/index.js +1 -1
  33. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  34. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  35. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  36. package/features/dateFormatter/abstractions.d.ts +13 -0
  37. package/features/dateFormatter/abstractions.js +5 -0
  38. package/features/dateFormatter/abstractions.js.map +1 -0
  39. package/features/dateFormatter/feature.d.ts +4 -0
  40. package/features/dateFormatter/feature.js +11 -0
  41. package/features/dateFormatter/feature.js.map +1 -0
  42. package/features/dateFormatter/index.d.ts +3 -0
  43. package/features/dateFormatter/index.js +2 -0
  44. package/features/debugger/Debugger.d.ts +30 -0
  45. package/features/debugger/Debugger.js +142 -0
  46. package/features/debugger/Debugger.js.map +1 -0
  47. package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
  48. package/features/debugger/DebuggerRouteDecorator.js +107 -0
  49. package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
  50. package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
  51. package/features/debugger/GraphQLDebuggerTransport.js +45 -0
  52. package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
  53. package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
  54. package/features/debugger/__tests__/matchNamespace.test.js +68 -0
  55. package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
  56. package/features/debugger/__tests__/serialize.test.d.ts +1 -0
  57. package/features/debugger/__tests__/serialize.test.js +220 -0
  58. package/features/debugger/__tests__/serialize.test.js.map +1 -0
  59. package/features/debugger/abstractions.d.ts +100 -0
  60. package/features/debugger/abstractions.js +6 -0
  61. package/features/debugger/abstractions.js.map +1 -0
  62. package/features/debugger/feature.d.ts +5 -0
  63. package/features/debugger/feature.js +15 -0
  64. package/features/debugger/feature.js.map +1 -0
  65. package/features/debugger/index.d.ts +12 -0
  66. package/features/debugger/index.js +7 -0
  67. package/features/debugger/limits.d.ts +18 -0
  68. package/features/debugger/limits.js +11 -0
  69. package/features/debugger/limits.js.map +1 -0
  70. package/features/debugger/matchNamespace.d.ts +14 -0
  71. package/features/debugger/matchNamespace.js +35 -0
  72. package/features/debugger/matchNamespace.js.map +1 -0
  73. package/features/debugger/parseNamespaceHeader.d.ts +7 -0
  74. package/features/debugger/parseNamespaceHeader.js +16 -0
  75. package/features/debugger/parseNamespaceHeader.js.map +1 -0
  76. package/features/debugger/permissions.d.ts +14 -0
  77. package/features/debugger/permissions.js +8 -0
  78. package/features/debugger/permissions.js.map +1 -0
  79. package/features/debugger/permissionsSchema.d.ts +17 -0
  80. package/features/debugger/permissionsSchema.js +18 -0
  81. package/features/debugger/permissionsSchema.js.map +1 -0
  82. package/features/debugger/serialize.d.ts +11 -0
  83. package/features/debugger/serialize.js +121 -0
  84. package/features/debugger/serialize.js.map +1 -0
  85. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  86. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  87. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  88. package/features/encryption/EncryptionService.d.ts +2 -1
  89. package/features/encryption/EncryptionService.js +11 -4
  90. package/features/encryption/EncryptionService.js.map +1 -1
  91. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  92. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  93. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  94. package/features/encryption/abstractions.d.ts +11 -0
  95. package/features/encryption/abstractions.js +2 -1
  96. package/features/encryption/abstractions.js.map +1 -1
  97. package/features/encryption/index.d.ts +1 -0
  98. package/features/encryption/index.js +1 -0
  99. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  100. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +62 -0
  101. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  102. package/features/hashing/ScryptHasher.d.ts +11 -0
  103. package/features/hashing/ScryptHasher.js +74 -0
  104. package/features/hashing/ScryptHasher.js.map +1 -0
  105. package/features/hashing/abstractions.d.ts +18 -0
  106. package/features/hashing/abstractions.js +5 -0
  107. package/features/hashing/abstractions.js.map +1 -0
  108. package/features/hashing/feature.d.ts +4 -0
  109. package/features/hashing/feature.js +11 -0
  110. package/features/hashing/feature.js.map +1 -0
  111. package/features/hashing/index.d.ts +2 -0
  112. package/features/hashing/index.js +1 -0
  113. package/features/httpClient/HttpClient.d.ts +7 -0
  114. package/features/httpClient/HttpClient.js +72 -0
  115. package/features/httpClient/HttpClient.js.map +1 -0
  116. package/features/httpClient/HttpRequestError.d.ts +10 -0
  117. package/features/httpClient/HttpRequestError.js +13 -0
  118. package/features/httpClient/HttpRequestError.js.map +1 -0
  119. package/features/httpClient/HttpStatusError.d.ts +12 -0
  120. package/features/httpClient/HttpStatusError.js +12 -0
  121. package/features/httpClient/HttpStatusError.js.map +1 -0
  122. package/features/httpClient/abstractions.d.ts +32 -0
  123. package/features/httpClient/abstractions.js +5 -0
  124. package/features/httpClient/abstractions.js.map +1 -0
  125. package/features/httpClient/feature.d.ts +4 -0
  126. package/features/httpClient/feature.js +11 -0
  127. package/features/httpClient/feature.js.map +1 -0
  128. package/features/httpClient/index.d.ts +3 -0
  129. package/features/httpClient/index.js +3 -0
  130. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  131. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  132. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  133. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  134. package/features/keyValueStore/KeyValueStore.js +13 -3
  135. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  136. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  137. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  138. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  139. package/features/keyValueStore/abstractions.d.ts +132 -14
  140. package/features/keyValueStore/abstractions.js.map +1 -1
  141. package/features/keyValueStore/errors.d.ts +29 -0
  142. package/features/keyValueStore/errors.js +49 -1
  143. package/features/keyValueStore/errors.js.map +1 -1
  144. package/features/keyValueStore/index.d.ts +4 -1
  145. package/features/keyValueStore/index.js +1 -1
  146. package/features/publicUrls/NullPublicUrls.d.ts +11 -0
  147. package/features/publicUrls/NullPublicUrls.js +17 -0
  148. package/features/publicUrls/NullPublicUrls.js.map +1 -0
  149. package/features/publicUrls/PublicUrl.d.ts +24 -0
  150. package/features/publicUrls/PublicUrl.js +43 -0
  151. package/features/publicUrls/PublicUrl.js.map +1 -0
  152. package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
  153. package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
  154. package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
  155. package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
  156. package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
  157. package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
  158. package/features/publicUrls/abstractions.d.ts +27 -0
  159. package/features/publicUrls/abstractions.js +5 -0
  160. package/features/publicUrls/abstractions.js.map +1 -0
  161. package/features/publicUrls/feature.d.ts +8 -0
  162. package/features/publicUrls/feature.js +11 -0
  163. package/features/publicUrls/feature.js.map +1 -0
  164. package/features/publicUrls/index.d.ts +3 -0
  165. package/features/publicUrls/index.js +3 -0
  166. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  167. package/features/requestContext/RawAssumePermissions.js +19 -0
  168. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  169. package/features/requestContext/RawAuthToken.d.ts +14 -0
  170. package/features/requestContext/RawAuthToken.js +19 -0
  171. package/features/requestContext/RawAuthToken.js.map +1 -0
  172. package/features/requestContext/RawTenantId.d.ts +14 -0
  173. package/features/requestContext/RawTenantId.js +19 -0
  174. package/features/requestContext/RawTenantId.js.map +1 -0
  175. package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
  176. package/features/requestContext/RequestIdentityLoader.js +26 -0
  177. package/features/requestContext/RequestIdentityLoader.js.map +1 -0
  178. package/features/requestContext/RequestTenantLoader.d.ts +18 -0
  179. package/features/requestContext/RequestTenantLoader.js +52 -0
  180. package/features/requestContext/RequestTenantLoader.js.map +1 -0
  181. package/features/requestContext/abstractions.d.ts +75 -0
  182. package/features/requestContext/abstractions.js +9 -0
  183. package/features/requestContext/abstractions.js.map +1 -0
  184. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  185. package/features/requestContext/extractAssumePermissions.js +32 -0
  186. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  187. package/features/requestContext/feature.d.ts +12 -0
  188. package/features/requestContext/feature.js +19 -0
  189. package/features/requestContext/feature.js.map +1 -0
  190. package/features/requestContext/index.d.ts +4 -0
  191. package/features/requestContext/index.js +3 -0
  192. package/features/security/IdentityContext/IdentityContext.d.ts +4 -3
  193. package/features/security/IdentityContext/IdentityContext.js +9 -6
  194. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  195. package/features/security/IdentityContext/abstractions.d.ts +5 -0
  196. package/features/security/IdentityContext/abstractions.js.map +1 -1
  197. package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
  198. package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
  199. package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
  200. package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
  201. package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
  202. package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
  203. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  204. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  205. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -1
  206. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -1
  207. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  208. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  209. package/features/security/apiKeys/feature.js +4 -0
  210. package/features/security/apiKeys/feature.js.map +1 -1
  211. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  212. package/features/security/apiKeys/shared/schemas.js +2 -2
  213. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  214. package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +12 -3
  215. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +31 -18
  216. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
  217. package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
  218. package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
  219. package/features/security/authorization/AuthorizationContext/feature.js +6 -1
  220. package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
  221. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  222. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  223. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  224. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
  225. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  226. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  227. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  228. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  229. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  230. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  231. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  232. package/features/security/roles/CreateRole/schema.js +1 -1
  233. package/features/security/roles/CreateRole/schema.js.map +1 -1
  234. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  235. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  236. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  237. package/features/security/roles/UpdateRole/schema.js +1 -1
  238. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  239. package/features/security/shared/description.d.ts +4 -0
  240. package/features/security/shared/description.js +7 -0
  241. package/features/security/shared/description.js.map +1 -0
  242. package/features/security/shared/index.d.ts +1 -0
  243. package/features/security/shared/index.js +1 -0
  244. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  245. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  246. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  247. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  248. package/features/security/teams/CreateTeam/schema.js +1 -1
  249. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  250. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  251. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  252. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  253. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  254. package/features/security/teams/UpdateTeam/schema.js +1 -1
  255. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  256. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  257. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  258. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  259. package/features/slugify/DefaultSlugify.d.ts +8 -0
  260. package/features/slugify/DefaultSlugify.js +20 -0
  261. package/features/slugify/DefaultSlugify.js.map +1 -0
  262. package/features/slugify/abstractions.d.ts +12 -0
  263. package/features/slugify/abstractions.js +5 -0
  264. package/features/slugify/abstractions.js.map +1 -0
  265. package/features/slugify/feature.d.ts +4 -0
  266. package/features/slugify/feature.js +11 -0
  267. package/features/slugify/feature.js.map +1 -0
  268. package/features/slugify/index.d.ts +3 -0
  269. package/features/slugify/index.js +2 -0
  270. package/features/storageOperations/abstractions.d.ts +21 -0
  271. package/features/storageOperations/abstractions.js +10 -0
  272. package/features/storageOperations/abstractions.js.map +1 -0
  273. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  274. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  275. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  276. package/features/stringFormatter/abstractions.d.ts +11 -0
  277. package/features/stringFormatter/abstractions.js +5 -0
  278. package/features/stringFormatter/abstractions.js.map +1 -0
  279. package/features/stringFormatter/feature.d.ts +4 -0
  280. package/features/stringFormatter/feature.js +13 -0
  281. package/features/stringFormatter/feature.js.map +1 -0
  282. package/features/stringFormatter/index.d.ts +3 -0
  283. package/features/stringFormatter/index.js +2 -0
  284. package/features/task/TaskDefinition/abstractions.d.ts +69 -4
  285. package/features/task/TaskDefinition/abstractions.js +2 -1
  286. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  287. package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
  288. package/features/tenancy/TenantContext/TenantContext.js +13 -8
  289. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  290. package/features/users/shared/types.d.ts +9 -7
  291. package/features/wcp/WcpContext/WcpContext.d.ts +12 -5
  292. package/features/wcp/WcpContext/WcpContext.js +29 -2
  293. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  294. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +11 -66
  295. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +71 -33
  296. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  297. package/features/wcp/WcpContext/feature.d.ts +1 -2
  298. package/features/wcp/WcpContext/feature.js +2 -2
  299. package/features/wcp/WcpContext/feature.js.map +1 -1
  300. package/features/wcp/WcpContext/index.d.ts +0 -1
  301. package/features/wcp/WcpContext/types.d.ts +0 -4
  302. package/features/wcp/WcpFeature.d.ts +1 -1
  303. package/features/wcp/WcpFeature.js +7 -2
  304. package/features/wcp/WcpFeature.js.map +1 -1
  305. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  306. package/features/wcp/WcpLicenseLoader.js +58 -0
  307. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  308. package/features/wcp/WcpLicenseProvider.d.ts +21 -0
  309. package/features/wcp/WcpLicenseProvider.js +14 -0
  310. package/features/wcp/WcpLicenseProvider.js.map +1 -0
  311. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  312. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  313. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  314. package/graphql/ApiCoreSchemaFactory.d.ts +16 -0
  315. package/graphql/ApiCoreSchemaFactory.js +58 -0
  316. package/graphql/ApiCoreSchemaFactory.js.map +1 -0
  317. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
  318. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
  319. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  320. package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
  321. package/graphql/security/NotAuthorizedResponse.js +1 -1
  322. package/graphql/security/NotAuthorizedResponse.js.map +1 -1
  323. package/graphql/security/SecuritySchemaFactory.d.ts +15 -0
  324. package/graphql/security/SecuritySchemaFactory.js +27 -0
  325. package/graphql/security/SecuritySchemaFactory.js.map +1 -0
  326. package/graphql/security/addApiKeySchema.d.ts +2 -0
  327. package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
  328. package/graphql/security/addApiKeySchema.js.map +1 -0
  329. package/graphql/security/addIdentitySchema.d.ts +2 -0
  330. package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
  331. package/graphql/security/addIdentitySchema.js.map +1 -0
  332. package/graphql/security/addRoleSchema.d.ts +2 -0
  333. package/graphql/security/addRoleSchema.js +137 -0
  334. package/graphql/security/addRoleSchema.js.map +1 -0
  335. package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
  336. package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
  337. package/graphql/security/addSecurityBaseSchema.js.map +1 -0
  338. package/graphql/security/addTeamSchema.d.ts +2 -0
  339. package/graphql/security/addTeamSchema.js +157 -0
  340. package/graphql/security/addTeamSchema.js.map +1 -0
  341. package/graphql/system/SystemSchemaFactory.d.ts +10 -0
  342. package/graphql/system/SystemSchemaFactory.js +70 -0
  343. package/graphql/system/SystemSchemaFactory.js.map +1 -0
  344. package/graphql/users/UsersSchemaFactory.d.ts +10 -0
  345. package/graphql/users/UsersSchemaFactory.js +195 -0
  346. package/graphql/users/UsersSchemaFactory.js.map +1 -0
  347. package/graphql/wcp/WcpSchemaFactory.d.ts +10 -0
  348. package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +32 -18
  349. package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
  350. package/idp/JwksCache.d.ts +14 -3
  351. package/idp/JwksCache.js +97 -17
  352. package/idp/JwksCache.js.map +1 -1
  353. package/idp/JwksStoreFeature.d.ts +8 -0
  354. package/idp/JwksStoreFeature.js +11 -0
  355. package/idp/JwksStoreFeature.js.map +1 -0
  356. package/idp/MemoryJwksStore.d.ts +14 -0
  357. package/idp/MemoryJwksStore.js +21 -0
  358. package/idp/MemoryJwksStore.js.map +1 -0
  359. package/idp/OidcJwtIdentityProvider.js +5 -1
  360. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  361. package/idp/abstractions.d.ts +24 -0
  362. package/idp/abstractions.js +2 -1
  363. package/idp/abstractions.js.map +1 -1
  364. package/idp/feature.js +1 -2
  365. package/idp/feature.js.map +1 -1
  366. package/idp/index.d.ts +1 -0
  367. package/idp/index.js +1 -0
  368. package/index.d.ts +3 -1
  369. package/index.js +3 -1
  370. package/package.json +22 -22
  371. package/testing/environment.d.ts +14 -0
  372. package/testing/environment.js +18 -0
  373. package/testing/environment.js.map +1 -0
  374. package/types/core.d.ts +17 -5
  375. package/types/security.d.ts +0 -6
  376. package/types/tenancy.d.ts +0 -17
  377. package/types/users.d.ts +2 -16
  378. package/createApiCore.d.ts +0 -7
  379. package/createApiCore.js +0 -26
  380. package/createApiCore.js.map +0 -1
  381. package/graphql/security/apiKey.gql.d.ts +0 -4
  382. package/graphql/security/apiKey.gql.js.map +0 -1
  383. package/graphql/security/base.gql.d.ts +0 -4
  384. package/graphql/security/base.gql.js.map +0 -1
  385. package/graphql/security/identity.gql.d.ts +0 -4
  386. package/graphql/security/identity.gql.js.map +0 -1
  387. package/graphql/security/index.d.ts +0 -1
  388. package/graphql/security/index.js +0 -15
  389. package/graphql/security/index.js.map +0 -1
  390. package/graphql/security/role.gql.d.ts +0 -4
  391. package/graphql/security/role.gql.js +0 -106
  392. package/graphql/security/role.gql.js.map +0 -1
  393. package/graphql/security/team.gql.d.ts +0 -4
  394. package/graphql/security/team.gql.js +0 -119
  395. package/graphql/security/team.gql.js.map +0 -1
  396. package/graphql/system/createSystemGraphQL.d.ts +0 -2
  397. package/graphql/system/createSystemGraphQL.js +0 -54
  398. package/graphql/system/createSystemGraphQL.js.map +0 -1
  399. package/graphql/users/user.gql.d.ts +0 -3
  400. package/graphql/users/user.gql.js +0 -167
  401. package/graphql/users/user.gql.js.map +0 -1
  402. package/graphql/wcp/graphql.d.ts +0 -2
  403. package/graphql/wcp/graphql.js.map +0 -1
  404. package/legacy/security/LegacyContext.d.ts +0 -36
  405. package/legacy/security/LegacyContext.js +0 -152
  406. package/legacy/security/LegacyContext.js.map +0 -1
  407. package/legacy/security/createSecurityContext.d.ts +0 -3
  408. package/legacy/security/createSecurityContext.js +0 -10
  409. package/legacy/security/createSecurityContext.js.map +0 -1
  410. package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
  411. package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
  412. package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
  413. package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
  414. package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
  415. package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
  416. package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
  417. package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
  418. package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
  419. package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
  420. package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
  421. package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
  422. package/legacy/security/plugins/secureHeaders.d.ts +0 -1
  423. package/legacy/security/plugins/secureHeaders.js +0 -30
  424. package/legacy/security/plugins/secureHeaders.js.map +0 -1
  425. package/legacy/tenancy/LegacyContext.d.ts +0 -15
  426. package/legacy/tenancy/LegacyContext.js +0 -57
  427. package/legacy/tenancy/LegacyContext.js.map +0 -1
  428. package/legacy/tenancy/createTenancyContext.d.ts +0 -3
  429. package/legacy/tenancy/createTenancyContext.js +0 -31
  430. package/legacy/tenancy/createTenancyContext.js.map +0 -1
  431. package/legacy/users/LegacyContext.d.ts +0 -13
  432. package/legacy/users/LegacyContext.js +0 -55
  433. package/legacy/users/LegacyContext.js.map +0 -1
  434. package/legacy/users/createAdminUsersContext.d.ts +0 -3
  435. package/legacy/users/createAdminUsersContext.js +0 -12
  436. package/legacy/users/createAdminUsersContext.js.map +0 -1
  437. package/legacy/wcp/LegacyWcpContext.d.ts +0 -37
  438. package/legacy/wcp/LegacyWcpContext.js +0 -96
  439. package/legacy/wcp/LegacyWcpContext.js.map +0 -1
  440. package/legacy/wcp/context.d.ts +0 -5
  441. package/legacy/wcp/context.js +0 -46
  442. package/legacy/wcp/context.js.map +0 -1
@@ -0,0 +1,121 @@
1
+ const UNDEFINED = "#[Undefined value]";
2
+ const CIRCULAR = "#[Circular]";
3
+ const DEPTH_LIMIT = "#[Depth limit]";
4
+ const isPlainValue = (value)=>{
5
+ const type = typeof value;
6
+ return "string" === type || "number" === type || "boolean" === type || null === value;
7
+ };
8
+ const describeBinary = (value)=>{
9
+ const name = value.constructor?.name || "TypedArray";
10
+ return `#[${name} ${value.byteLength} bytes]`;
11
+ };
12
+ const walk = (value, limits, seen, depth)=>{
13
+ if (void 0 === value) return UNDEFINED;
14
+ if (isPlainValue(value)) {
15
+ if ("string" == typeof value && value.length > limits.stringLength) {
16
+ const kept = value.slice(0, limits.stringLength);
17
+ return `${kept}…(${value.length - limits.stringLength} more)`;
18
+ }
19
+ if ("number" == typeof value && !Number.isFinite(value)) return String(value);
20
+ return value;
21
+ }
22
+ if ("bigint" == typeof value) return `${value.toString()}n`;
23
+ if ("symbol" == typeof value) return String(value);
24
+ if ("function" == typeof value) return `#[Function: ${value.name || "anonymous"}]`;
25
+ if (value instanceof Error) return {
26
+ name: value.name,
27
+ message: value.message,
28
+ stack: value.stack
29
+ };
30
+ if (value instanceof Date) return value.toISOString();
31
+ if (value instanceof RegExp) return value.toString();
32
+ if (ArrayBuffer.isView(value)) return describeBinary(value);
33
+ if (value instanceof ArrayBuffer) return `#[ArrayBuffer ${value.byteLength} bytes]`;
34
+ if (depth >= limits.depth) return DEPTH_LIMIT;
35
+ if ("object" != typeof value || null === value) return String(value);
36
+ if (seen.has(value)) return CIRCULAR;
37
+ seen.add(value);
38
+ try {
39
+ if (Array.isArray(value)) {
40
+ const kept = value.slice(0, limits.arrayLength).map((item)=>walk(item, limits, seen, depth + 1));
41
+ if (value.length > limits.arrayLength) kept.push(`…(${value.length - limits.arrayLength} more items)`);
42
+ return kept;
43
+ }
44
+ if (value instanceof Map) {
45
+ const entries = [];
46
+ for (const [key, item] of value.entries()){
47
+ if (entries.length >= limits.arrayLength) {
48
+ entries.push(`…(${value.size - limits.arrayLength} more entries)`);
49
+ break;
50
+ }
51
+ entries.push([
52
+ walk(key, limits, seen, depth + 1),
53
+ walk(item, limits, seen, depth + 1)
54
+ ]);
55
+ }
56
+ return {
57
+ __type: "Map",
58
+ entries
59
+ };
60
+ }
61
+ if (value instanceof Set) {
62
+ const items = [];
63
+ for (const item of value.values()){
64
+ if (items.length >= limits.arrayLength) {
65
+ items.push(`…(${value.size - limits.arrayLength} more items)`);
66
+ break;
67
+ }
68
+ items.push(walk(item, limits, seen, depth + 1));
69
+ }
70
+ return {
71
+ __type: "Set",
72
+ items
73
+ };
74
+ }
75
+ const result = {};
76
+ for (const key of Object.keys(value)){
77
+ let item;
78
+ try {
79
+ item = value[key];
80
+ } catch (ex) {
81
+ result[key] = `#[Throws: ${ex instanceof Error ? ex.message : String(ex)}]`;
82
+ continue;
83
+ }
84
+ if (void 0 !== item) result[key] = walk(item, limits, seen, depth + 1);
85
+ }
86
+ return result;
87
+ } finally{
88
+ seen.delete(value);
89
+ }
90
+ };
91
+ const serialize = (value, limits)=>{
92
+ let json;
93
+ try {
94
+ const walked = walk(value, limits, new WeakSet(), 0);
95
+ json = JSON.stringify(walked) ?? JSON.stringify(UNDEFINED);
96
+ } catch (ex) {
97
+ const message = ex instanceof Error ? ex.message : String(ex);
98
+ json = JSON.stringify({
99
+ __serializationFailed: true,
100
+ message
101
+ });
102
+ }
103
+ let bytes = Buffer.byteLength(json, "utf8");
104
+ let truncated = false;
105
+ if (bytes > limits.entryBytes) {
106
+ json = JSON.stringify({
107
+ truncated: true,
108
+ originalBytes: bytes
109
+ });
110
+ bytes = Buffer.byteLength(json, "utf8");
111
+ truncated = true;
112
+ }
113
+ return {
114
+ json,
115
+ bytes,
116
+ truncated
117
+ };
118
+ };
119
+ export { serialize };
120
+
121
+ //# sourceMappingURL=serialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/debugger/serialize.js","sources":["../../../src/features/debugger/serialize.ts"],"sourcesContent":["import type { IDebuggerLimits } from \"./limits.js\";\n\nexport interface ISerializeResult {\n json: string;\n bytes: number;\n /** True if the value was replaced by the per-entry cap marker. */\n truncated: boolean;\n}\n\n/**\n * Markers stand in for values that cannot be represented as JSON.\n *\n * They are prefixed with `#` so a reader can tell at a glance that a value was substituted by the\n * serializer rather than being what the code actually held - the previous `[undefined]` read as an\n * array literal in documents that are full of real arrays.\n */\nconst UNDEFINED = \"#[Undefined value]\";\nconst CIRCULAR = \"#[Circular]\";\nconst DEPTH_LIMIT = \"#[Depth limit]\";\n\nconst isPlainValue = (value: unknown): boolean => {\n const type = typeof value;\n return type === \"string\" || type === \"number\" || type === \"boolean\" || value === null;\n};\n\nconst describeBinary = (value: ArrayBufferView): string => {\n const name = value.constructor?.name || \"TypedArray\";\n return `#[${name} ${value.byteLength} bytes]`;\n};\n\n/**\n * Walks a value into a JSON-safe structure, applying depth, string and array caps as it goes.\n *\n * Caps are applied during the walk rather than by slicing the finished JSON string, so the output is\n * always parseable.\n *\n * A custom `toJSON` is never invoked - own properties are enumerated instead. That means an object\n * is reported as its internals rather than its intended representation, which is what you want when\n * debugging, and it removes a whole class of failure where a third-party `toJSON` throws.\n */\nconst walk = (\n value: unknown,\n limits: IDebuggerLimits,\n seen: WeakSet<object>,\n depth: number\n): unknown => {\n if (value === undefined) {\n /**\n * Only reached for array elements and for a top-level payload. Object properties holding\n * `undefined` are dropped before they get here, matching `JSON.stringify`.\n *\n * Inside an array the element cannot be dropped without shifting every later index, and\n * `JSON.stringify` would turn it into `null` - which is a meaningful value in its own right.\n */\n return UNDEFINED;\n }\n\n if (isPlainValue(value)) {\n if (typeof value === \"string\" && value.length > limits.stringLength) {\n const kept = value.slice(0, limits.stringLength);\n return `${kept}…(${value.length - limits.stringLength} more)`;\n }\n /**\n * Infinity and NaN serialize to `null`, which silently loses the distinction. Keep them\n * readable instead.\n */\n if (typeof value === \"number\" && !Number.isFinite(value)) {\n return String(value);\n }\n return value;\n }\n\n if (typeof value === \"bigint\") {\n return `${value.toString()}n`;\n }\n\n if (typeof value === \"symbol\") {\n return String(value);\n }\n\n if (typeof value === \"function\") {\n return `#[Function: ${value.name || \"anonymous\"}]`;\n }\n\n if (value instanceof Error) {\n return {\n name: value.name,\n message: value.message,\n stack: value.stack\n };\n }\n\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n if (value instanceof RegExp) {\n return value.toString();\n }\n\n if (ArrayBuffer.isView(value)) {\n return describeBinary(value);\n }\n\n if (value instanceof ArrayBuffer) {\n return `#[ArrayBuffer ${value.byteLength} bytes]`;\n }\n\n if (depth >= limits.depth) {\n return DEPTH_LIMIT;\n }\n\n if (typeof value !== \"object\" || value === null) {\n return String(value);\n }\n\n if (seen.has(value)) {\n return CIRCULAR;\n }\n seen.add(value);\n\n try {\n if (Array.isArray(value)) {\n const kept = value.slice(0, limits.arrayLength).map(item => {\n return walk(item, limits, seen, depth + 1);\n });\n if (value.length > limits.arrayLength) {\n kept.push(`…(${value.length - limits.arrayLength} more items)`);\n }\n return kept;\n }\n\n if (value instanceof Map) {\n const entries: unknown[] = [];\n for (const [key, item] of value.entries()) {\n if (entries.length >= limits.arrayLength) {\n entries.push(`…(${value.size - limits.arrayLength} more entries)`);\n break;\n }\n entries.push([\n walk(key, limits, seen, depth + 1),\n walk(item, limits, seen, depth + 1)\n ]);\n }\n return { __type: \"Map\", entries };\n }\n\n if (value instanceof Set) {\n const items: unknown[] = [];\n for (const item of value.values()) {\n if (items.length >= limits.arrayLength) {\n items.push(`…(${value.size - limits.arrayLength} more items)`);\n break;\n }\n items.push(walk(item, limits, seen, depth + 1));\n }\n return { __type: \"Set\", items };\n }\n\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n /**\n * A getter can throw. One bad property must not take down the whole entry, let alone the\n * request that is being observed.\n */\n let item: unknown;\n try {\n item = (value as Record<string, unknown>)[key];\n } catch (ex) {\n result[key] = `#[Throws: ${ex instanceof Error ? ex.message : String(ex)}]`;\n continue;\n }\n\n /**\n * Drop the key, as `JSON.stringify` does.\n *\n * Captured payloads are frequently copies of something that went over the wire, and the\n * wire never carried these keys - keeping them would describe a request that was never\n * made.\n */\n if (item === undefined) {\n continue;\n }\n\n result[key] = walk(item, limits, seen, depth + 1);\n }\n return result;\n } finally {\n /**\n * Only guard against cycles along the current branch. Without this, a value referenced twice\n * as siblings would report the second one as circular.\n */\n seen.delete(value);\n }\n};\n\n/**\n * Serializes a captured payload to JSON, never throwing and always producing valid JSON.\n */\nexport const serialize = (value: unknown, limits: IDebuggerLimits): ISerializeResult => {\n let json: string;\n\n try {\n const walked = walk(value, limits, new WeakSet(), 0);\n json = JSON.stringify(walked) ?? JSON.stringify(UNDEFINED);\n } catch (ex) {\n const message = ex instanceof Error ? ex.message : String(ex);\n json = JSON.stringify({ __serializationFailed: true, message });\n }\n\n let bytes = Buffer.byteLength(json, \"utf8\");\n let truncated = false;\n\n if (bytes > limits.entryBytes) {\n /**\n * Slicing the string would produce invalid JSON, so the payload is replaced wholesale.\n */\n json = JSON.stringify({ truncated: true, originalBytes: bytes });\n bytes = Buffer.byteLength(json, \"utf8\");\n truncated = true;\n }\n\n return { json, bytes, truncated };\n};\n"],"names":["UNDEFINED","CIRCULAR","DEPTH_LIMIT","isPlainValue","value","type","describeBinary","name","walk","limits","seen","depth","undefined","kept","Number","String","Error","Date","RegExp","ArrayBuffer","Array","item","Map","entries","key","Set","items","result","Object","ex","serialize","json","walked","WeakSet","JSON","message","bytes","Buffer","truncated"],"mappings":"AAgBA,MAAMA,YAAY;AAClB,MAAMC,WAAW;AACjB,MAAMC,cAAc;AAEpB,MAAMC,eAAe,CAACC;IAClB,MAAMC,OAAO,OAAOD;IACpB,OAAOC,AAAS,aAATA,QAAqBA,AAAS,aAATA,QAAqBA,AAAS,cAATA,QAAsBD,AAAU,SAAVA;AAC3E;AAEA,MAAME,iBAAiB,CAACF;IACpB,MAAMG,OAAOH,MAAM,WAAW,EAAE,QAAQ;IACxC,OAAO,CAAC,EAAE,EAAEG,KAAK,CAAC,EAAEH,MAAM,UAAU,CAAC,OAAO,CAAC;AACjD;AAYA,MAAMI,OAAO,CACTJ,OACAK,QACAC,MACAC;IAEA,IAAIP,AAAUQ,WAAVR,OAQA,OAAOJ;IAGX,IAAIG,aAAaC,QAAQ;QACrB,IAAI,AAAiB,YAAjB,OAAOA,SAAsBA,MAAM,MAAM,GAAGK,OAAO,YAAY,EAAE;YACjE,MAAMI,OAAOT,MAAM,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,CAAC,CAAC;gBAC3E;YACJ;YASA,IAAIR,AAAST,WAATS,MAIJM,MAAM,CAACH,IAAI,GAAGhB,KAAKa,MAAMZ,QAAQC,MAAMC,QAAQ;QACnD;QACA,OAAOgB;IACX,SAAU;QAKNjB,KAAK,MAAM,CAACN;IAChB;AACJ;AAKO,MAAM0B,YAAY,CAAC1B,OAAgBK;IACtC,IAAIsB;IAEJ,IAAI;QACA,MAAMC,SAASxB,KAAKJ,OAAOK,QAAQ,IAAIwB,WAAW;QAClDF,OAAOG,KAAK,SAAS,CAACF,WAAWE,KAAK,SAAS,CAAClC;IACpD,EAAE,OAAO6B,IAAI;QACT,MAAMM,UAAUN,cAAcb,QAAQa,GAAG,OAAO,GAAGd,OAAOc;QAC1DE,OAAOG,KAAK,SAAS,CAAC;YAAE,uBAAuB;YAAMC;QAAQ;IACjE;IAEA,IAAIC,QAAQC,OAAO,UAAU,CAACN,MAAM;IACpC,IAAIO,YAAY;IAEhB,IAAIF,QAAQ3B,OAAO,UAAU,EAAE;QAI3BsB,OAAOG,KAAK,SAAS,CAAC;YAAE,WAAW;YAAM,eAAeE;QAAM;QAC9DA,QAAQC,OAAO,UAAU,CAACN,MAAM;QAChCO,YAAY;IAChB;IAEA,OAAO;QAAEP;QAAMK;QAAOE;IAAU;AACpC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Register in the ROOT container. Encryption is registered again in every request container, so a
3
+ * cache registered there would start empty on each request and derive the key every time.
4
+ */
5
+ export declare const EncryptionKeyCacheFeature: {
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 { MemoryEncryptionKeyCache } from "./MemoryEncryptionKeyCache.js";
3
+ const EncryptionKeyCacheFeature = createFeature({
4
+ name: "EncryptionKeyCache",
5
+ register (container) {
6
+ container.register(MemoryEncryptionKeyCache).inSingletonScope();
7
+ }
8
+ });
9
+ export { EncryptionKeyCacheFeature };
10
+
11
+ //# sourceMappingURL=EncryptionKeyCacheFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/encryption/EncryptionKeyCacheFeature.js","sources":["../../../src/features/encryption/EncryptionKeyCacheFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { MemoryEncryptionKeyCache } from \"./MemoryEncryptionKeyCache.js\";\n\n/**\n * Register in the ROOT container. Encryption is registered again in every request container, so a\n * cache registered there would start empty on each request and derive the key every time.\n */\nexport const EncryptionKeyCacheFeature = createFeature({\n name: \"EncryptionKeyCache\",\n register(container) {\n container.register(MemoryEncryptionKeyCache).inSingletonScope();\n }\n});\n"],"names":["EncryptionKeyCacheFeature","createFeature","container","MemoryEncryptionKeyCache"],"mappings":";;AAOO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,0BAA0B,gBAAgB;IACjE;AACJ"}
@@ -1,9 +1,10 @@
1
1
  import { Encryption as EncryptionAbstraction } from "./abstractions.js";
2
+ import { EncryptionKeyCache } from "./abstractions.js";
2
3
  import { BuildParams } from "../buildParams/abstractions.js";
3
4
  export declare class EncryptionImpl implements EncryptionAbstraction.Interface {
4
5
  private key;
5
6
  private algorithm;
6
- constructor(buildParams: BuildParams.Interface);
7
+ constructor(buildParams: BuildParams.Interface, keyCache: EncryptionKeyCache.Interface | undefined);
7
8
  encrypt(value: string): Promise<string>;
8
9
  decrypt(value: string): Promise<string>;
9
10
  }
@@ -1,6 +1,6 @@
1
1
  import node_crypto from "node:crypto";
2
2
  import { createImplementation } from "@webiny/feature/api";
3
- import { Encryption } from "./abstractions.js";
3
+ import { Encryption, EncryptionKeyCache } from "./abstractions.js";
4
4
  import { BuildParams } from "../buildParams/abstractions.js";
5
5
  const DEFAULT_ALGORITHM = "aes-256-gcm";
6
6
  function keyLengthForAlgorithm(algorithm) {
@@ -9,13 +9,14 @@ function keyLengthForAlgorithm(algorithm) {
9
9
  return bits / 8;
10
10
  }
11
11
  class EncryptionImpl {
12
- constructor(buildParams){
12
+ constructor(buildParams, keyCache){
13
13
  const passphrase = buildParams.get("EncryptionPassphrase");
14
14
  if (passphrase) {
15
15
  const salt = buildParams.get("EncryptionSalt") ?? "";
16
16
  this.algorithm = buildParams.get("EncryptionAlgorithm") ?? DEFAULT_ALGORITHM;
17
17
  const keyLength = keyLengthForAlgorithm(this.algorithm);
18
- this.key = node_crypto.scryptSync(passphrase, salt, keyLength);
18
+ if (keyCache) this.key = keyCache.getOrDerive(passphrase, salt, keyLength);
19
+ else this.key = node_crypto.scryptSync(passphrase, salt, keyLength);
19
20
  } else {
20
21
  this.key = null;
21
22
  this.algorithm = DEFAULT_ALGORITHM;
@@ -54,7 +55,13 @@ const EncryptionService_Encryption = createImplementation({
54
55
  abstraction: Encryption,
55
56
  implementation: EncryptionImpl,
56
57
  dependencies: [
57
- BuildParams
58
+ BuildParams,
59
+ [
60
+ EncryptionKeyCache,
61
+ {
62
+ optional: true
63
+ }
64
+ ]
58
65
  ]
59
66
  });
60
67
  export { EncryptionImpl, EncryptionService_Encryption as Encryption };
@@ -1 +1 @@
1
- {"version":3,"file":"features/encryption/EncryptionService.js","sources":["../../../src/features/encryption/EncryptionService.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Encryption as EncryptionAbstraction } from \"./abstractions.js\";\nimport { BuildParams } from \"../buildParams/abstractions.js\";\n\nconst DEFAULT_ALGORITHM = \"aes-256-gcm\";\n\nfunction keyLengthForAlgorithm(algorithm: string): number {\n // Parse key size in bits from algorithm name (e.g. \"aes-256-gcm\" → 32 bytes).\n const bits = parseInt(algorithm.split(\"-\")[1]);\n if (isNaN(bits)) {\n throw new Error(`Cannot determine key length from algorithm \"${algorithm}\".`);\n }\n return bits / 8;\n}\n\nexport class EncryptionImpl implements EncryptionAbstraction.Interface {\n private key: Buffer | null;\n private algorithm: string;\n\n constructor(buildParams: BuildParams.Interface) {\n const passphrase = buildParams.get<string>(\"EncryptionPassphrase\");\n\n if (passphrase) {\n // Salt is optional. It ensures two projects using the same passphrase derive different keys,\n // but since passphrases should be unique per project anyway, it's extra insurance rather than a necessity.\n const salt = buildParams.get<string>(\"EncryptionSalt\") ?? \"\";\n this.algorithm = buildParams.get<string>(\"EncryptionAlgorithm\") ?? DEFAULT_ALGORITHM;\n const keyLength = keyLengthForAlgorithm(this.algorithm);\n this.key = crypto.scryptSync(passphrase, salt, keyLength);\n } else {\n this.key = null;\n this.algorithm = DEFAULT_ALGORITHM;\n }\n }\n\n async encrypt(value: string): Promise<string> {\n if (!this.key) {\n return value;\n }\n const iv = crypto.randomBytes(12);\n const cipher = crypto.createCipheriv(this.algorithm, this.key, iv);\n const encrypted = Buffer.concat([cipher.update(value, \"utf8\"), cipher.final()]);\n const authTag = (cipher as crypto.CipherGCM).getAuthTag();\n return Buffer.concat([iv, authTag, encrypted]).toString(\"base64\");\n }\n\n async decrypt(value: string): Promise<string> {\n if (!this.key) {\n return value;\n }\n const data = Buffer.from(value, \"base64\");\n const iv = data.subarray(0, 12);\n const authTag = data.subarray(12, 28);\n const ciphertext = data.subarray(28);\n const decipher = crypto.createDecipheriv(this.algorithm, this.key, iv);\n (decipher as crypto.DecipherGCM).setAuthTag(authTag);\n return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString(\"utf8\");\n }\n}\n\nexport const Encryption = createImplementation({\n abstraction: EncryptionAbstraction,\n implementation: EncryptionImpl,\n dependencies: [BuildParams]\n});\n"],"names":["DEFAULT_ALGORITHM","keyLengthForAlgorithm","algorithm","bits","parseInt","isNaN","Error","EncryptionImpl","buildParams","passphrase","salt","keyLength","crypto","value","iv","cipher","encrypted","Buffer","authTag","data","ciphertext","decipher","Encryption","createImplementation","EncryptionAbstraction","BuildParams"],"mappings":";;;;AAKA,MAAMA,oBAAoB;AAE1B,SAASC,sBAAsBC,SAAiB;IAE5C,MAAMC,OAAOC,SAASF,UAAU,KAAK,CAAC,IAAI,CAA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A,gBAAuB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAEE;QAClEO,SAAgC,UAAU,CAACH;QAC5C,OAAOD,OAAO,MAAM,CAAC;YAACI,SAAS,MAAM,CAACD;YAAaC,SAAS,KAAK;SAAG,EAAE,QAAQ,CAAC;IACnF;AACJ;AAEO,MAAMC,+BAAaC,qBAAqB;IAC3C,aAAaC;IACb,gBAAgBjB;IAChB,cAAc;QAACkB;KAAY;AAC/B"}
1
+ {"version":3,"file":"features/encryption/EncryptionService.js","sources":["../../../src/features/encryption/EncryptionService.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Encryption as EncryptionAbstraction } from \"./abstractions.js\";\nimport { EncryptionKeyCache } from \"./abstractions.js\";\nimport { BuildParams } from \"../buildParams/abstractions.js\";\n\nconst DEFAULT_ALGORITHM = \"aes-256-gcm\";\n\nfunction keyLengthForAlgorithm(algorithm: string): number {\n // Parse key size in bits from algorithm name (e.g. \"aes-256-gcm\" → 32 bytes).\n const bits = parseInt(algorithm.split(\"-\")[1]);\n if (isNaN(bits)) {\n throw new Error(`Cannot determine key length from algorithm \"${algorithm}\".`);\n }\n return bits / 8;\n}\n\nexport class EncryptionImpl implements EncryptionAbstraction.Interface {\n private key: Buffer | null;\n private algorithm: string;\n\n constructor(\n buildParams: BuildParams.Interface,\n // Registered in the root container, so the derived key outlives the request. Without it (in\n // tests, for example) the key is derived for every instance.\n keyCache: EncryptionKeyCache.Interface | undefined\n ) {\n const passphrase = buildParams.get<string>(\"EncryptionPassphrase\");\n\n if (passphrase) {\n // Salt is optional. It ensures two projects using the same passphrase derive different keys,\n // but since passphrases should be unique per project anyway, it's extra insurance rather than a necessity.\n const salt = buildParams.get<string>(\"EncryptionSalt\") ?? \"\";\n this.algorithm = buildParams.get<string>(\"EncryptionAlgorithm\") ?? DEFAULT_ALGORITHM;\n const keyLength = keyLengthForAlgorithm(this.algorithm);\n if (keyCache) {\n this.key = keyCache.getOrDerive(passphrase, salt, keyLength);\n } else {\n this.key = crypto.scryptSync(passphrase, salt, keyLength);\n }\n } else {\n this.key = null;\n this.algorithm = DEFAULT_ALGORITHM;\n }\n }\n\n async encrypt(value: string): Promise<string> {\n if (!this.key) {\n return value;\n }\n const iv = crypto.randomBytes(12);\n const cipher = crypto.createCipheriv(this.algorithm, this.key, iv);\n const encrypted = Buffer.concat([cipher.update(value, \"utf8\"), cipher.final()]);\n const authTag = (cipher as crypto.CipherGCM).getAuthTag();\n return Buffer.concat([iv, authTag, encrypted]).toString(\"base64\");\n }\n\n async decrypt(value: string): Promise<string> {\n if (!this.key) {\n return value;\n }\n const data = Buffer.from(value, \"base64\");\n const iv = data.subarray(0, 12);\n const authTag = data.subarray(12, 28);\n const ciphertext = data.subarray(28);\n const decipher = crypto.createDecipheriv(this.algorithm, this.key, iv);\n (decipher as crypto.DecipherGCM).setAuthTag(authTag);\n return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString(\"utf8\");\n }\n}\n\nexport const Encryption = createImplementation({\n abstraction: EncryptionAbstraction,\n implementation: EncryptionImpl,\n dependencies: [BuildParams, [EncryptionKeyCache, { optional: true }]]\n});\n"],"names":["DEFAULT_ALGORITHM","keyLengthForAlgorithm","algorithm","bits","parseInt","isNaN","Error","EncryptionImpl","buildParams","keyCache","passphrase","salt","keyLength","crypto","value","iv","cipher","encrypted","Buffer","authTag","data","ciphertext","decipher","Encryption","createImplementation","EncryptionAbstraction","BuildParams","EncryptionKeyCache"],"mappings":";;;;AAMA,MAAMA,oBAAoB;AAE1B,SAASC,sBAAsBC,SAAiB;IAE5C,MAAMC,OAAOC,SAASF,UAAU,KAAK,CAAC,IAAI,CAAC,EAAE;IAC7C,IAAIG,MAAMF,OACN,MAAM,IAAIG,MAAM,CAAC,4CAA4C,EAAEJ,UAAU,EAAE,CAAC;IAEhF,OAAOC,OAAO;AAClB;AAEO,MAAMI;IAIT,YACIC,WAAkC,EAGlCC,QAAkD,CAC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,UAAU,CAACH;QAC5C,OAAOD,OAAO,MAAM,CAAC;YAACI,SAAS,MAAM,CAACD;YAAaC,SAAS,KAAK;SAAG,EAAE,QAAQ,CAAC;IACnF;AACJ;AAEO,MAAMC,+BAAaC,qBAAqB;IAC3C,aAAaC;IACb,gBAAgBlB;IAChB,cAAc;QAACmB;QAAa;YAACC;YAAoB;gBAAE,UAAU;YAAK;SAAE;KAAC;AACzE"}
@@ -0,0 +1,13 @@
1
+ import { EncryptionKeyCache as Abstraction } from "./abstractions.js";
2
+ /**
3
+ * Keeps every derived key for the life of the container. Keys depend only on build params, so a
4
+ * process holds one or two at most.
5
+ */
6
+ declare class MemoryEncryptionKeyCacheImpl implements Abstraction.Interface {
7
+ private readonly keys;
8
+ getOrDerive(passphrase: string, salt: string, keyLength: number): Buffer;
9
+ }
10
+ export declare const MemoryEncryptionKeyCache: typeof MemoryEncryptionKeyCacheImpl & {
11
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IEncryptionKeyCache>;
12
+ };
13
+ export {};
@@ -0,0 +1,26 @@
1
+ import node_crypto from "node:crypto";
2
+ import { EncryptionKeyCache } from "./abstractions.js";
3
+ class MemoryEncryptionKeyCacheImpl {
4
+ getOrDerive(passphrase, salt, keyLength) {
5
+ const cacheKey = JSON.stringify([
6
+ passphrase,
7
+ salt,
8
+ keyLength
9
+ ]);
10
+ const cached = this.keys.get(cacheKey);
11
+ if (cached) return cached;
12
+ const key = node_crypto.scryptSync(passphrase, salt, keyLength);
13
+ this.keys.set(cacheKey, key);
14
+ return key;
15
+ }
16
+ constructor(){
17
+ this.keys = new Map();
18
+ }
19
+ }
20
+ const MemoryEncryptionKeyCache = EncryptionKeyCache.createImplementation({
21
+ implementation: MemoryEncryptionKeyCacheImpl,
22
+ dependencies: []
23
+ });
24
+ export { MemoryEncryptionKeyCache };
25
+
26
+ //# sourceMappingURL=MemoryEncryptionKeyCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/encryption/MemoryEncryptionKeyCache.js","sources":["../../../src/features/encryption/MemoryEncryptionKeyCache.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport { EncryptionKeyCache as Abstraction } from \"./abstractions.js\";\n\n/**\n * Keeps every derived key for the life of the container. Keys depend only on build params, so a\n * process holds one or two at most.\n */\nclass MemoryEncryptionKeyCacheImpl implements Abstraction.Interface {\n private readonly keys = new Map<string, Buffer>();\n\n public getOrDerive(passphrase: string, salt: string, keyLength: number): Buffer {\n const cacheKey = JSON.stringify([passphrase, salt, keyLength]);\n const cached = this.keys.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const key = crypto.scryptSync(passphrase, salt, keyLength);\n this.keys.set(cacheKey, key);\n return key;\n }\n}\n\nexport const MemoryEncryptionKeyCache = Abstraction.createImplementation({\n implementation: MemoryEncryptionKeyCacheImpl,\n dependencies: []\n});\n"],"names":["MemoryEncryptionKeyCacheImpl","passphrase","salt","keyLength","cacheKey","JSON","cached","key","crypto","Map","MemoryEncryptionKeyCache","Abstraction"],"mappings":";;AAOA,MAAMA;IAGK,YAAYC,UAAkB,EAAEC,IAAY,EAAEC,SAAiB,EAAU;QAC5E,MAAMC,WAAWC,KAAK,SAAS,CAAC;YAACJ;YAAYC;YAAMC;SAAU;QAC7D,MAAMG,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAACF;QAC7B,IAAIE,QACA,OAAOA;QAGX,MAAMC,MAAMC,YAAAA,UAAiB,CAACP,YAAYC,MAAMC;QAChD,IAAI,CAAC,IAAI,CAAC,GAAG,CAACC,UAAUG;QACxB,OAAOA;IACX;;aAZiB,IAAI,GAAG,IAAIE;;AAahC;AAEO,MAAMC,2BAA2BC,mBAAAA,oBAAgC,CAAC;IACrE,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
@@ -7,3 +7,14 @@ export declare const Encryption: import("@webiny/di").Abstraction<IEncryption>;
7
7
  export declare namespace Encryption {
8
8
  type Interface = IEncryption;
9
9
  }
10
+ export interface IEncryptionKeyCache {
11
+ getOrDerive(passphrase: string, salt: string, keyLength: number): Buffer;
12
+ }
13
+ /**
14
+ * Derives encryption keys and keeps them. Deriving a key runs scrypt, which costs tens of
15
+ * milliseconds of CPU on purpose, so the key is derived once instead of on every request.
16
+ */
17
+ export declare const EncryptionKeyCache: import("@webiny/di").Abstraction<IEncryptionKeyCache>;
18
+ export declare namespace EncryptionKeyCache {
19
+ type Interface = IEncryptionKeyCache;
20
+ }
@@ -1,5 +1,6 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
2
  const Encryption = createAbstraction("Encryption");
3
- export { Encryption };
3
+ const EncryptionKeyCache = createAbstraction("EncryptionKeyCache");
4
+ export { Encryption, EncryptionKeyCache };
4
5
 
5
6
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/encryption/abstractions.js","sources":["../../../src/features/encryption/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IEncryption {\n encrypt(value: string): Promise<string>;\n decrypt(value: string): Promise<string>;\n}\n\n/** Symmetric encryption and decryption using a configured secret key. */\nexport const Encryption = createAbstraction<IEncryption>(\"Encryption\");\n\nexport namespace Encryption {\n export type Interface = IEncryption;\n}\n"],"names":["Encryption","createAbstraction"],"mappings":";AAQO,MAAMA,aAAaC,kBAA+B"}
1
+ {"version":3,"file":"features/encryption/abstractions.js","sources":["../../../src/features/encryption/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IEncryption {\n encrypt(value: string): Promise<string>;\n decrypt(value: string): Promise<string>;\n}\n\n/** Symmetric encryption and decryption using a configured secret key. */\nexport const Encryption = createAbstraction<IEncryption>(\"Encryption\");\n\nexport namespace Encryption {\n export type Interface = IEncryption;\n}\n\nexport interface IEncryptionKeyCache {\n getOrDerive(passphrase: string, salt: string, keyLength: number): Buffer;\n}\n\n/**\n * Derives encryption keys and keeps them. Deriving a key runs scrypt, which costs tens of\n * milliseconds of CPU on purpose, so the key is derived once instead of on every request.\n */\nexport const EncryptionKeyCache = createAbstraction<IEncryptionKeyCache>(\"EncryptionKeyCache\");\n\nexport namespace EncryptionKeyCache {\n export type Interface = IEncryptionKeyCache;\n}\n"],"names":["Encryption","createAbstraction","EncryptionKeyCache"],"mappings":";AAQO,MAAMA,aAAaC,kBAA+B;AAclD,MAAMC,qBAAqBD,kBAAuC"}
@@ -1 +1,2 @@
1
1
  export { Encryption } from "./abstractions.js";
2
+ export { EncryptionKeyCacheFeature } from "./EncryptionKeyCacheFeature.js";
@@ -1 +1,2 @@
1
1
  export { Encryption } from "./abstractions.js";
2
+ export { EncryptionKeyCacheFeature } from "./EncryptionKeyCacheFeature.js";
@@ -0,0 +1,13 @@
1
+ import { FeatureFlags } from "../abstractions.js";
2
+ import { FeatureFlags as FeatureFlagsClass } from "@webiny/feature-flags";
3
+ import { WcpLicenseProvider } from "../../../features/wcp/WcpLicenseProvider.js";
4
+ declare class FeatureFlagsWithLicenseDecoratorImpl implements FeatureFlags.Interface {
5
+ private licenseProvider;
6
+ private decoratee;
7
+ constructor(licenseProvider: WcpLicenseProvider.Interface, decoratee: FeatureFlags.Interface);
8
+ get(): FeatureFlagsClass;
9
+ }
10
+ export declare const FeatureFlagsWithLicenseDecorator: typeof FeatureFlagsWithLicenseDecoratorImpl & {
11
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions.js").IFeatureFlagsAbstraction>;
12
+ };
13
+ export {};
@@ -0,0 +1,62 @@
1
+ import { FeatureFlags } from "../abstractions.js";
2
+ import { FeatureFlags as feature_flags_FeatureFlags } from "@webiny/feature-flags";
3
+ import { WcpLicenseProvider } from "../../wcp/WcpLicenseProvider.js";
4
+ const LICENSE_CHECKS = {
5
+ multiTenancy: (l)=>l.canUseFeature("multiTenancy"),
6
+ languages: (l)=>l.canUseLanguages(),
7
+ advancedPublishingWorkflow: (l)=>l.canUseWorkflows(),
8
+ advancedAccessControlLayer: (l)=>l.canUseAacl(),
9
+ "advancedAccessControlLayer.teams": (l)=>l.canUseTeams(),
10
+ "advancedAccessControlLayer.privateFiles": (l)=>l.canUsePrivateFiles(),
11
+ "advancedAccessControlLayer.folderLevelPermissions": (l)=>l.canUseFolderLevelPermissions(),
12
+ "advancedAccessControlLayer.hcmsFieldPermissions": (l)=>l.canUseHcmsFieldPermissions(),
13
+ auditLogs: (l)=>l.canUseAuditLogs(),
14
+ recordLocking: (l)=>l.canUseRecordLocking(),
15
+ "fileManager.threatDetection": (l)=>l.canUseFileManagerThreatDetection(),
16
+ aiPowerups: (l)=>l.canUseAiPowerups(),
17
+ "aiPowerups.fileManager.imageEnrichment": (l)=>l.canUseAiImageEnrichment(),
18
+ "aiPowerups.websiteBuilder.pageGeneration": (l)=>l.canUseAiPageGeneration(),
19
+ "aiPowerups.websiteBuilder.pageTranslation": (l)=>l.canUseAiPageTranslation(),
20
+ "aiPowerups.lexicalGeneration": (l)=>l.canUseAiLexicalGeneration(),
21
+ "aiPowerups.adminAssistant": (l)=>l.canUseAiAdminAssistant(),
22
+ "aiPowerups.remoteComponents": (l)=>l.canUseRemoteComponents(),
23
+ "aiPowerups.cms.entryGeneration": (l)=>l.canUseAiEntryGeneration(),
24
+ "aiPowerups.cms.entryComparison": (l)=>l.canUseAiEntryComparison(),
25
+ "aiPowerups.cms.entryTranslation": (l)=>l.canUseAiEntryTranslation(),
26
+ abTesting: (l)=>l.canUseAbTesting(),
27
+ collaboration: (l)=>l.canUseCollaboration(),
28
+ "collaboration.comments": (l)=>l.canUseComments(),
29
+ "collaboration.activityLog": (l)=>l.canUseActivityLog()
30
+ };
31
+ class LicenseDecoratedFeatureFlags extends feature_flags_FeatureFlags {
32
+ constructor(base, license){
33
+ super(base.toDto()), this.base = base, this.license = license;
34
+ }
35
+ isEnabled(name) {
36
+ const check = LICENSE_CHECKS[name];
37
+ if (check) {
38
+ if (!check(this.license)) return false;
39
+ return !this.base.isExplicitlyDisabled(name);
40
+ }
41
+ return this.base.isEnabled(name);
42
+ }
43
+ }
44
+ class FeatureFlagsWithLicenseDecoratorImpl {
45
+ constructor(licenseProvider, decoratee){
46
+ this.licenseProvider = licenseProvider;
47
+ this.decoratee = decoratee;
48
+ }
49
+ get() {
50
+ const base = this.decoratee.get();
51
+ return new LicenseDecoratedFeatureFlags(base, this.licenseProvider.get());
52
+ }
53
+ }
54
+ const FeatureFlagsWithLicenseDecorator = FeatureFlags.createDecorator({
55
+ decorator: FeatureFlagsWithLicenseDecoratorImpl,
56
+ dependencies: [
57
+ WcpLicenseProvider
58
+ ]
59
+ });
60
+ export { FeatureFlagsWithLicenseDecorator };
61
+
62
+ //# sourceMappingURL=FeatureFlagsWithLicenseDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js","sources":["../../../../src/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.ts"],"sourcesContent":["import { FeatureFlags } from \"../abstractions.js\";\nimport { FeatureFlags as FeatureFlagsClass } from \"@webiny/feature-flags\";\nimport type { FeatureFlagName } from \"@webiny/feature-flags\";\nimport type { ILicense } from \"@webiny/wcp/types.js\";\nimport { WcpLicenseProvider } from \"~/features/wcp/WcpLicenseProvider.js\";\n\n/*\n * Feature flag resolution (license decorator).\n *\n * Two kinds of flag, and only one of them is Webiny's to sell:\n *\n * LICENSE-GOVERNED (listed in LICENSE_CHECKS) — the license is the authority:\n * 1. No license, or license blocks the flag → false, config ignored\n * 2. License allows + config unset → true (the license grants it)\n * 3. License allows + config=false → false (config may disable, never re-enable)\n *\n * EVERYTHING ELSE — the project's own flags. The config decides, and nothing is assumed:\n * 4. config=true → true\n * 5. config=false or unset → false\n *\n * There is deliberately no third kind. A set of flags used to be enabled by default here, which was\n * a workaround for capabilities the license could not express: rather than gate them properly they\n * were left on for anyone holding any license at all. It also meant EVERY unrecognised name resolved\n * to true, so an undeclared flag and a typo both read as enabled. A feature that should be sold\n * belongs in LICENSE_CHECKS and on the license; anything else is the project's own to switch on.\n */\n\nconst LICENSE_CHECKS: Record<string, (license: ILicense) => boolean> = {\n multiTenancy: l => l.canUseFeature(\"multiTenancy\"),\n languages: l => l.canUseLanguages(),\n advancedPublishingWorkflow: l => l.canUseWorkflows(),\n advancedAccessControlLayer: l => l.canUseAacl(),\n \"advancedAccessControlLayer.teams\": l => l.canUseTeams(),\n \"advancedAccessControlLayer.privateFiles\": l => l.canUsePrivateFiles(),\n \"advancedAccessControlLayer.folderLevelPermissions\": l => l.canUseFolderLevelPermissions(),\n \"advancedAccessControlLayer.hcmsFieldPermissions\": l => l.canUseHcmsFieldPermissions(),\n auditLogs: l => l.canUseAuditLogs(),\n recordLocking: l => l.canUseRecordLocking(),\n \"fileManager.threatDetection\": l => l.canUseFileManagerThreatDetection(),\n aiPowerups: l => l.canUseAiPowerups(),\n \"aiPowerups.fileManager.imageEnrichment\": l => l.canUseAiImageEnrichment(),\n \"aiPowerups.websiteBuilder.pageGeneration\": l => l.canUseAiPageGeneration(),\n \"aiPowerups.websiteBuilder.pageTranslation\": l => l.canUseAiPageTranslation(),\n \"aiPowerups.lexicalGeneration\": l => l.canUseAiLexicalGeneration(),\n \"aiPowerups.adminAssistant\": l => l.canUseAiAdminAssistant(),\n \"aiPowerups.remoteComponents\": l => l.canUseRemoteComponents(),\n \"aiPowerups.cms.entryGeneration\": l => l.canUseAiEntryGeneration(),\n \"aiPowerups.cms.entryComparison\": l => l.canUseAiEntryComparison(),\n \"aiPowerups.cms.entryTranslation\": l => l.canUseAiEntryTranslation(),\n abTesting: l => l.canUseAbTesting(),\n collaboration: l => l.canUseCollaboration(),\n \"collaboration.comments\": l => l.canUseComments(),\n \"collaboration.activityLog\": l => l.canUseActivityLog()\n};\n\nclass LicenseDecoratedFeatureFlags extends FeatureFlagsClass {\n constructor(\n private base: FeatureFlagsClass,\n private license: ILicense\n ) {\n super(base.toDto());\n }\n\n override isEnabled(name: FeatureFlagName): boolean {\n const check = LICENSE_CHECKS[name];\n if (check) {\n if (!check(this.license)) {\n return false;\n }\n // License allows — config can only disable, not re-enable blocked features.\n return !this.base.isExplicitlyDisabled(name);\n }\n /*\n * Everything else is the project's own, and the config is the only thing that decides. No\n * default: `isEnabled` on the base is true only for an explicitly configured `true`.\n *\n * This branch used to return `!isExplicitlyDisabled(name)` whenever a license existed, which\n * made EVERY unrecognised name true — an undeclared flag, or a typo like `aiPowerupz`. It also\n * returned false outright without a license, so an unlicensed install could not turn on a flag\n * it had declared itself. Neither is the license's business.\n */\n return this.base.isEnabled(name);\n }\n}\n\nclass FeatureFlagsWithLicenseDecoratorImpl implements FeatureFlags.Interface {\n constructor(\n private licenseProvider: WcpLicenseProvider.Interface,\n private decoratee: FeatureFlags.Interface\n ) {}\n\n get(): FeatureFlagsClass {\n const base = this.decoratee.get();\n return new LicenseDecoratedFeatureFlags(base, this.licenseProvider.get());\n }\n}\n\nexport const FeatureFlagsWithLicenseDecorator = FeatureFlags.createDecorator({\n decorator: FeatureFlagsWithLicenseDecoratorImpl,\n dependencies: [WcpLicenseProvider]\n});\n"],"names":["LICENSE_CHECKS","l","LicenseDecoratedFeatureFlags","FeatureFlagsClass","base","license","name","check","FeatureFlagsWithLicenseDecoratorImpl","licenseProvider","decoratee","FeatureFlagsWithLicenseDecorator","FeatureFlags","WcpLicenseProvider"],"mappings":";;;AA2BA,MAAMA,iBAAiE;IACnE,cAAcC,CAAAA,IAAKA,EAAE,aAAa,CAAC;IACnC,WAAWA,CAAAA,IAAKA,EAAE,eAAe;IACjC,4BAA4BA,CAAAA,IAAKA,EAAE,eAAe;IAClD,4BAA4BA,CAAAA,IAAKA,EAAE,UAAU;IAC7C,oCAAoCA,CAAAA,IAAKA,EAAE,WAAW;IACtD,2CAA2CA,CAAAA,IAAKA,EAAE,kBAAkB;IACpE,qDAAqDA,CAAAA,IAAKA,EAAE,4BAA4B;IACxF,mDAAmDA,CAAAA,IAAKA,EAAE,0BAA0B;IACpF,WAAWA,CAAAA,IAAKA,EAAE,eAAe;IACjC,eAAeA,CAAAA,IAAKA,EAAE,m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AAS,CAAC,GAAG;QAC/B,OAAO,IAAIF,6BAA6BE,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG;IAC1E;AACJ;AAEO,MAAMO,mCAAmCC,aAAa,eAAe,CAAC;IACzE,WAAWJ;IACX,cAAc;QAACK;KAAmB;AACtC"}
@@ -0,0 +1,11 @@
1
+ import type { IHasher } from "./abstractions.js";
2
+ import { BuildParams } from "../buildParams/abstractions.js";
3
+ export declare class ScryptHasher implements IHasher {
4
+ private readonly cost;
5
+ private readonly pepper;
6
+ constructor(buildParams: BuildParams.Interface);
7
+ hash(value: string): Promise<string>;
8
+ verify(value: string, storedHash: string): Promise<boolean>;
9
+ private withPepper;
10
+ }
11
+ export declare const Hasher: import("@webiny/di").Implementation<typeof ScryptHasher>;
@@ -0,0 +1,74 @@
1
+ import { randomBytes, scrypt, timingSafeEqual } from "node:crypto";
2
+ import { createImplementation } from "@webiny/feature/api";
3
+ import { Hasher } from "./abstractions.js";
4
+ import { BuildParams } from "../buildParams/abstractions.js";
5
+ const ScryptHasher_scrypt = (value, salt, keylen, options)=>new Promise((resolve, reject)=>{
6
+ scrypt(value, salt, keylen, options, (err, derivedKey)=>{
7
+ if (err) reject(err);
8
+ else resolve(derivedKey);
9
+ });
10
+ });
11
+ const PREFIX = "scrypt";
12
+ const KEYLEN = 64;
13
+ const SALT_BYTES = 16;
14
+ const DEFAULT_COST = {
15
+ N: 16384,
16
+ r: 8,
17
+ p: 1
18
+ };
19
+ class ScryptHasher {
20
+ constructor(buildParams){
21
+ this.pepper = buildParams.get("HashingPepper") ?? "";
22
+ const costN = buildParams.get("HashingCost");
23
+ this.cost = costN ? {
24
+ ...DEFAULT_COST,
25
+ N: Number(costN)
26
+ } : DEFAULT_COST;
27
+ }
28
+ async hash(value) {
29
+ const { N, r, p } = this.cost;
30
+ const salt = randomBytes(SALT_BYTES);
31
+ const derived = await ScryptHasher_scrypt(this.withPepper(value), salt, KEYLEN, {
32
+ N,
33
+ r,
34
+ p
35
+ });
36
+ return [
37
+ PREFIX,
38
+ N,
39
+ r,
40
+ p,
41
+ salt.toString("base64"),
42
+ derived.toString("base64")
43
+ ].join("$");
44
+ }
45
+ async verify(value, storedHash) {
46
+ const parts = storedHash.split("$");
47
+ if (6 !== parts.length || parts[0] !== PREFIX) return false;
48
+ const [, nRaw, rRaw, pRaw, saltB64, hashB64] = parts;
49
+ const N = Number(nRaw);
50
+ const r = Number(rRaw);
51
+ const p = Number(pRaw);
52
+ const salt = Buffer.from(saltB64, "base64");
53
+ const expected = Buffer.from(hashB64, "base64");
54
+ const derived = await ScryptHasher_scrypt(this.withPepper(value), salt, expected.length, {
55
+ N,
56
+ r,
57
+ p
58
+ });
59
+ return timingSafeEqual(derived, expected);
60
+ }
61
+ withPepper(value) {
62
+ return this.pepper ? `${value}${this.pepper}` : value;
63
+ }
64
+ }
65
+ const ScryptHasher_Hasher = createImplementation({
66
+ abstraction: Hasher,
67
+ implementation: ScryptHasher,
68
+ dependencies: [
69
+ BuildParams
70
+ ]
71
+ });
72
+ export { ScryptHasher, ScryptHasher_Hasher as Hasher };
73
+
74
+ //# sourceMappingURL=ScryptHasher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/hashing/ScryptHasher.js","sources":["../../../src/features/hashing/ScryptHasher.ts"],"sourcesContent":["import { randomBytes, scrypt as scryptCb, timingSafeEqual } from \"node:crypto\";\nimport type { ScryptOptions } from \"node:crypto\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Hasher as HasherAbstraction } from \"./abstractions.js\";\nimport type { IHasher } from \"./abstractions.js\";\nimport { BuildParams } from \"../buildParams/abstractions.js\";\n\n// `promisify(scryptCb)` resolves to the no-options overload, so we wrap by hand\n// to keep the cost parameters (N, r, p).\nconst scrypt = (\n value: string,\n salt: Buffer,\n keylen: number,\n options: ScryptOptions\n): Promise<Buffer> =>\n new Promise((resolve, reject) => {\n scryptCb(value, salt, keylen, options, (err, derivedKey) => {\n if (err) {\n reject(err);\n } else {\n resolve(derivedKey);\n }\n });\n });\n\n/**\n * Default hasher, built on Node's `crypto.scrypt` — no native dependency, so it runs anywhere Node\n * runs.\n *\n * Configuration (from `webiny.config.tsx` via `<Infra.Hashing>` → BuildParams):\n * - `HashingPepper` — an optional server-side secret folded into every hash. Unlike the per-value\n * salt (stored alongside the hash), the pepper is NOT stored, so a stolen database alone cannot\n * be brute-forced without also holding the pepper. Changing it invalidates existing hashes (same\n * trade-off as rotating the encryption passphrase). Omitted → no pepper, salt only.\n * - `HashingCost` — optional override of the scrypt cost parameter N. Defaults to 16384.\n *\n * The stored value is self-describing (`scrypt$N$r$p$salt$hash`), so switching to Argon2id later is\n * a matter of registering a different `Hasher` — old scrypt hashes keep verifying.\n */\nconst PREFIX = \"scrypt\";\nconst KEYLEN = 64;\nconst SALT_BYTES = 16;\n\ninterface ScryptCost {\n N: number;\n r: number;\n p: number;\n}\n\nconst DEFAULT_COST: ScryptCost = { N: 16384, r: 8, p: 1 };\n\nexport class ScryptHasher implements IHasher {\n private readonly cost: ScryptCost;\n private readonly pepper: string;\n\n constructor(buildParams: BuildParams.Interface) {\n this.pepper = buildParams.get<string>(\"HashingPepper\") ?? \"\";\n const costN = buildParams.get<number | string>(\"HashingCost\");\n this.cost = costN ? { ...DEFAULT_COST, N: Number(costN) } : DEFAULT_COST;\n }\n\n async hash(value: string): Promise<string> {\n const { N, r, p } = this.cost;\n const salt = randomBytes(SALT_BYTES);\n const derived = (await scrypt(this.withPepper(value), salt, KEYLEN, { N, r, p })) as Buffer;\n\n return [PREFIX, N, r, p, salt.toString(\"base64\"), derived.toString(\"base64\")].join(\"$\");\n }\n\n async verify(value: string, storedHash: string): Promise<boolean> {\n const parts = storedHash.split(\"$\");\n if (parts.length !== 6 || parts[0] !== PREFIX) {\n return false;\n }\n\n const [, nRaw, rRaw, pRaw, saltB64, hashB64] = parts;\n const N = Number(nRaw);\n const r = Number(rRaw);\n const p = Number(pRaw);\n const salt = Buffer.from(saltB64, \"base64\");\n const expected = Buffer.from(hashB64, \"base64\");\n\n const derived = (await scrypt(this.withPepper(value), salt, expected.length, {\n N,\n r,\n p\n })) as Buffer;\n\n // Lengths always match here, so timingSafeEqual is safe to call directly.\n return timingSafeEqual(derived, expected);\n }\n\n private withPepper(value: string): string {\n return this.pepper ? `${value}${this.pepper}` : value;\n }\n}\n\nexport const Hasher = createImplementation({\n abstraction: HasherAbstraction,\n implementation: ScryptHasher,\n dependencies: [BuildParams]\n});\n"],"names":["scrypt","value","salt","keylen","options","Promise","resolve","reject","scryptCb","err","derivedKey","PREFIX","KEYLEN","SALT_BYTES","DEFAULT_COST","ScryptHasher","buildParams","costN","Number","N","r","p","randomBytes","derived","storedHash","parts","nRaw","rRaw","pRaw","saltB64","hashB64","Buffer","expected","timingSafeEqual","Hasher","createImplementation","HasherAbstraction","BuildParams"],"mappings":";;;;AASA,MAAMA,sBAAS,CACXC,OACAC,MACAC,QACAC,UAEA,IAAIC,QAAQ,CAACC,SAASC;QAClBC,OAASP,OAAOC,MAAMC,QAAQC,SAAS,CAACK,KAAKC;YACzC,IAAID,KACAF,OAAOE;iBAEPH,QAAQI;QAEhB;IACJ;AAgBJ,MAAMC,SAAS;AACf,MAAMC,SAAS;AACf,MAAMC,aAAa;AAQnB,MAAMC,eAA2B;IAAE,GAAG;IAAO,GAAG;IAAG,GAAG;AAAE;AAEjD,MAAMC;IAIT,YAAYC,WAAkC,CAAE;QAC5C,IAAI,CAAC,MAAM,GAAGA,YAAY,GAAG,CAAS,oBAAoB;QAC1D,MAAMC,QAAQD,YAAY,GAAG,CAAkB;QAC/C,IAAI,CAAC,IAAI,GAAGC,QAAQ;YAAE,GAAGH,YAAY;YAAE,GAAGI,OAAOD;QAAO,IAAIH;IAChE;IAEA,MAAM,KAAKb,KAAa,EAAmB;QACvC,MAAM,EAAEkB,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI;QAC7B,MAAMnB,OAAOoB,YAAYT;QACzB,MAAMU,UAAW,MAAMvB,oBAAO,IAAI,CAAC,UAAU,CAACC,QAAQC,MAAMU,QAAQ;YAAEO;YAAGC;YAAGC;QAAE;QAE9E,OAAO;YAACV;YAAQQ;YAAGC;YAAGC;YAAGnB,KAAK,QAAQ,CAAC;YAAWqB,QAAQ,QAAQ,CAAC;SAAU,CAAC,IAAI,CAAC;IACvF;IAEA,MAAM,OAAOtB,KAAa,EAAEuB,UAAkB,EAAoB;QAC9D,MAAMC,QAAQD,WAAW,KAAK,CAAC;QAC/B,IAAIC,AAAiB,MAAjBA,MAAM,MAAM,IAAUA,KAAK,CAAC,EAAE,KAAKd,QACnC,OAAO;QAGX,MAAM,GAAGe,MAAMC,MAAMC,MAAMC,SAASC,QAAQ,GAAGL;QAC/C,MAAMN,IAAID,OAAOQ;QACjB,MAAMN,IAAIF,OAAOS;QACjB,MAAMN,IAAIH,OAAOU;QACjB,MAAM1B,OAAO6B,OAAO,IAAI,CAACF,SAAS;QAClC,MAAMG,WAAWD,OAAO,IAAI,CAACD,SAAS;QAEtC,MAAMP,UAAW,MAAMvB,oBAAO,IAAI,CAAC,UAAU,CAACC,QAAQC,MAAM8B,SAAS,MAAM,EAAE;YACzEb;YACAC;YACAC;QACJ;QAGA,OAAOY,gBAAgBV,SAASS;IACpC;IAEQ,WAAW/B,KAAa,EAAU;QACtC,OAAO,IAAI,CAAC,MAAM,GAAG,GAAGA,QAAQ,IAAI,CAAC,MAAM,EAAE,GAAGA;IACpD;AACJ;AAEO,MAAMiC,sBAASC,qBAAqB;IACvC,aAAaC;IACb,gBAAgBrB;IAChB,cAAc;QAACsB;KAAY;AAC/B"}
@@ -0,0 +1,18 @@
1
+ export interface IHasher {
2
+ hash(value: string): Promise<string>;
3
+ /** Constant-time compare of `value` against a previously produced hash string. */
4
+ verify(value: string, storedHash: string): Promise<boolean>;
5
+ }
6
+ /**
7
+ * Hashes and verifies secret values (passwords, API-key secrets, tokens, …) with a slow, salted
8
+ * KDF — built for the "store a hash, later verify a presented value" pattern.
9
+ *
10
+ * NOT a general-purpose digest: output is salted and non-deterministic, so this is the wrong tool
11
+ * for checksums / cache keys / dedup (use a fast deterministic digest util for those). Swap the
12
+ * implementation to change algorithms (e.g. Argon2id); stored hashes are self-describing, so old
13
+ * hashes keep verifying after a swap.
14
+ */
15
+ export declare const Hasher: import("@webiny/di").Abstraction<IHasher>;
16
+ export declare namespace Hasher {
17
+ type Interface = IHasher;
18
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const Hasher = createAbstraction("Hasher");
3
+ export { Hasher };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/hashing/abstractions.js","sources":["../../../src/features/hashing/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IHasher {\n hash(value: string): Promise<string>;\n /** Constant-time compare of `value` against a previously produced hash string. */\n verify(value: string, storedHash: string): Promise<boolean>;\n}\n\n/**\n * Hashes and verifies secret values (passwords, API-key secrets, tokens, …) with a slow, salted\n * KDF — built for the \"store a hash, later verify a presented value\" pattern.\n *\n * NOT a general-purpose digest: output is salted and non-deterministic, so this is the wrong tool\n * for checksums / cache keys / dedup (use a fast deterministic digest util for those). Swap the\n * implementation to change algorithms (e.g. Argon2id); stored hashes are self-describing, so old\n * hashes keep verifying after a swap.\n */\nexport const Hasher = createAbstraction<IHasher>(\"Hasher\");\n\nexport namespace Hasher {\n export type Interface = IHasher;\n}\n"],"names":["Hasher","createAbstraction"],"mappings":";AAiBO,MAAMA,SAASC,kBAA2B"}
@@ -0,0 +1,4 @@
1
+ export declare const HasherFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { Hasher } from "./ScryptHasher.js";
3
+ const HasherFeature = createFeature({
4
+ name: "HasherFeature",
5
+ register (container) {
6
+ container.register(Hasher);
7
+ }
8
+ });
9
+ export { HasherFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/hashing/feature.js","sources":["../../../src/features/hashing/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Hasher } from \"./ScryptHasher.js\";\n\nexport const HasherFeature = createFeature({\n name: \"HasherFeature\",\n register(container) {\n container.register(Hasher);\n }\n});\n"],"names":["HasherFeature","createFeature","container","Hasher"],"mappings":";;AAGO,MAAMA,gBAAgBC,cAAc;IACvC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -0,0 +1,2 @@
1
+ export { Hasher } from "./abstractions.js";
2
+ export type { IHasher } from "./abstractions.js";
@@ -0,0 +1 @@
1
+ export { Hasher } from "./abstractions.js";
@@ -0,0 +1,7 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { HttpClient as HttpClientAbstraction } from "./abstractions.js";
3
+ declare class HttpClientImpl implements HttpClientAbstraction.Interface {
4
+ requestJson(request: HttpClientAbstraction.Request): Promise<Result<unknown, HttpClientAbstraction.Error>>;
5
+ }
6
+ export declare const HttpClient: import("@webiny/di").Implementation<typeof HttpClientImpl>;
7
+ export {};