@webiny/api-core 6.6.0-alpha.1 → 6.6.0-alpha.11

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 (344) hide show
  1. package/ApiCoreFeature.js +10 -2
  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 +2 -1
  6. package/exports/api.js +2 -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 +82 -6
  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/cdnCache/NullCdnCache.d.ts +8 -0
  41. package/features/cdnCache/NullCdnCache.js +11 -0
  42. package/features/cdnCache/NullCdnCache.js.map +1 -0
  43. package/features/cdnCache/abstractions.d.ts +20 -0
  44. package/features/cdnCache/abstractions.js +5 -0
  45. package/features/cdnCache/abstractions.js.map +1 -0
  46. package/features/cdnCache/feature.d.ts +8 -0
  47. package/features/cdnCache/feature.js +11 -0
  48. package/features/cdnCache/feature.js.map +1 -0
  49. package/features/cdnCache/index.d.ts +2 -0
  50. package/features/cdnCache/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 +102 -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/BuildParamsEncryptionConfig.d.ts +13 -0
  93. package/features/encryption/BuildParamsEncryptionConfig.js +19 -0
  94. package/features/encryption/BuildParamsEncryptionConfig.js.map +1 -0
  95. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  96. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  97. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  98. package/features/encryption/EncryptionService.d.ts +3 -2
  99. package/features/encryption/EncryptionService.js +15 -13
  100. package/features/encryption/EncryptionService.js.map +1 -1
  101. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  102. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  103. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  104. package/features/encryption/abstractions.d.ts +26 -0
  105. package/features/encryption/abstractions.js +3 -1
  106. package/features/encryption/abstractions.js.map +1 -1
  107. package/features/encryption/feature.js +2 -0
  108. package/features/encryption/feature.js.map +1 -1
  109. package/features/encryption/index.d.ts +3 -0
  110. package/features/encryption/index.js +3 -1
  111. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +13 -1
  112. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -1
  113. package/features/hashing/BuildParamsHashingConfig.d.ts +11 -0
  114. package/features/hashing/BuildParamsHashingConfig.js +18 -0
  115. package/features/hashing/BuildParamsHashingConfig.js.map +1 -0
  116. package/features/hashing/ScryptHasher.d.ts +2 -2
  117. package/features/hashing/ScryptHasher.js +6 -8
  118. package/features/hashing/ScryptHasher.js.map +1 -1
  119. package/features/hashing/abstractions.d.ts +15 -0
  120. package/features/hashing/abstractions.js +2 -1
  121. package/features/hashing/abstractions.js.map +1 -1
  122. package/features/hashing/feature.js +2 -0
  123. package/features/hashing/feature.js.map +1 -1
  124. package/features/hashing/index.d.ts +1 -0
  125. package/features/hashing/index.js +1 -1
  126. package/features/httpClient/HttpClient.d.ts +7 -0
  127. package/features/httpClient/HttpClient.js +72 -0
  128. package/features/httpClient/HttpClient.js.map +1 -0
  129. package/features/httpClient/HttpRequestError.d.ts +10 -0
  130. package/features/httpClient/HttpRequestError.js +13 -0
  131. package/features/httpClient/HttpRequestError.js.map +1 -0
  132. package/features/httpClient/HttpStatusError.d.ts +12 -0
  133. package/features/httpClient/HttpStatusError.js +12 -0
  134. package/features/httpClient/HttpStatusError.js.map +1 -0
  135. package/features/httpClient/abstractions.d.ts +32 -0
  136. package/features/httpClient/abstractions.js +5 -0
  137. package/features/httpClient/abstractions.js.map +1 -0
  138. package/features/{logger → httpClient}/feature.d.ts +1 -1
  139. package/features/httpClient/feature.js +11 -0
  140. package/features/httpClient/feature.js.map +1 -0
  141. package/features/httpClient/index.d.ts +3 -0
  142. package/features/httpClient/index.js +3 -0
  143. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  144. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  145. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  146. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  147. package/features/keyValueStore/KeyValueStore.js +13 -3
  148. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  149. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  150. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  151. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  152. package/features/keyValueStore/abstractions.d.ts +132 -14
  153. package/features/keyValueStore/abstractions.js.map +1 -1
  154. package/features/keyValueStore/errors.d.ts +29 -0
  155. package/features/keyValueStore/errors.js +49 -1
  156. package/features/keyValueStore/errors.js.map +1 -1
  157. package/features/keyValueStore/index.d.ts +4 -1
  158. package/features/keyValueStore/index.js +1 -1
  159. package/features/logger/NullLogger.d.ts +10 -0
  160. package/features/logger/NullLogger.js +12 -0
  161. package/features/logger/NullLogger.js.map +1 -0
  162. package/features/logger/index.d.ts +1 -0
  163. package/features/logger/index.js +1 -0
  164. package/features/publicUrls/NullPublicUrls.d.ts +11 -0
  165. package/features/publicUrls/NullPublicUrls.js +17 -0
  166. package/features/publicUrls/NullPublicUrls.js.map +1 -0
  167. package/features/publicUrls/PublicUrl.d.ts +24 -0
  168. package/features/publicUrls/PublicUrl.js +43 -0
  169. package/features/publicUrls/PublicUrl.js.map +1 -0
  170. package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
  171. package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
  172. package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
  173. package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
  174. package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
  175. package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
  176. package/features/publicUrls/abstractions.d.ts +27 -0
  177. package/features/publicUrls/abstractions.js +5 -0
  178. package/features/publicUrls/abstractions.js.map +1 -0
  179. package/features/publicUrls/feature.d.ts +8 -0
  180. package/features/publicUrls/feature.js +11 -0
  181. package/features/publicUrls/feature.js.map +1 -0
  182. package/features/publicUrls/index.d.ts +3 -0
  183. package/features/publicUrls/index.js +3 -0
  184. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  185. package/features/requestContext/RawAssumePermissions.js +19 -0
  186. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  187. package/features/requestContext/abstractions.d.ts +22 -0
  188. package/features/requestContext/abstractions.js +2 -1
  189. package/features/requestContext/abstractions.js.map +1 -1
  190. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  191. package/features/requestContext/extractAssumePermissions.js +32 -0
  192. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  193. package/features/requestContext/feature.d.ts +2 -1
  194. package/features/requestContext/feature.js +2 -0
  195. package/features/requestContext/feature.js.map +1 -1
  196. package/features/requestContext/index.d.ts +3 -1
  197. package/features/requestContext/index.js +2 -1
  198. package/features/requestStorage/abstractions.d.ts +23 -0
  199. package/features/requestStorage/abstractions.js +5 -0
  200. package/features/requestStorage/abstractions.js.map +1 -0
  201. package/features/requestStorage/index.d.ts +1 -0
  202. package/features/requestStorage/index.js +1 -0
  203. package/features/security/IdentityContext/IdentityContext.d.ts +6 -2
  204. package/features/security/IdentityContext/IdentityContext.js +24 -7
  205. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  206. package/features/security/IdentityContext/abstractions.d.ts +6 -1
  207. package/features/security/IdentityContext/abstractions.js.map +1 -1
  208. package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +13 -3
  209. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +35 -22
  210. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
  211. package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
  212. package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
  213. package/features/security/authorization/AuthorizationContext/feature.js +6 -1
  214. package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
  215. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  216. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  217. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  218. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  219. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  220. package/features/security/roles/Installer/RolesInstaller.js +1 -0
  221. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  222. package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.d.ts +11 -0
  223. package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js +22 -0
  224. package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js.map +1 -0
  225. package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.d.ts +11 -0
  226. package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js +22 -0
  227. package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js.map +1 -0
  228. package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.d.ts +11 -0
  229. package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js +22 -0
  230. package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js.map +1 -0
  231. package/features/security/roles/NotifyRoleChange/NotifyRoleChangeUseCase.d.ts +11 -0
  232. package/features/security/roles/NotifyRoleChange/NotifyRoleChangeUseCase.js +40 -0
  233. package/features/security/roles/NotifyRoleChange/NotifyRoleChangeUseCase.js.map +1 -0
  234. package/features/security/roles/NotifyRoleChange/abstractions.d.ts +21 -0
  235. package/features/security/roles/NotifyRoleChange/abstractions.js +8 -0
  236. package/features/security/roles/NotifyRoleChange/abstractions.js.map +1 -0
  237. package/features/security/roles/NotifyRoleChange/feature.d.ts +5 -0
  238. package/features/security/roles/NotifyRoleChange/feature.js +17 -0
  239. package/features/security/roles/NotifyRoleChange/feature.js.map +1 -0
  240. package/features/security/roles/NotifyRoleChange/index.d.ts +2 -0
  241. package/features/security/roles/NotifyRoleChange/index.js +2 -0
  242. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +2 -1
  243. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  244. package/features/security/roles/feature.js +2 -0
  245. package/features/security/roles/feature.js.map +1 -1
  246. package/features/security/shared/definedOnly.d.ts +1 -0
  247. package/features/security/shared/definedOnly.js +8 -0
  248. package/features/security/shared/definedOnly.js.map +1 -0
  249. package/features/security/shared/index.d.ts +1 -0
  250. package/features/security/shared/index.js +1 -0
  251. package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.d.ts +29 -0
  252. package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js +58 -0
  253. package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js.map +1 -0
  254. package/features/security/teams/NotifyTeamChange/NotifyTeamChangeUseCase.d.ts +11 -0
  255. package/features/security/teams/NotifyTeamChange/NotifyTeamChangeUseCase.js +40 -0
  256. package/features/security/teams/NotifyTeamChange/NotifyTeamChangeUseCase.js.map +1 -0
  257. package/features/security/teams/NotifyTeamChange/abstractions.d.ts +21 -0
  258. package/features/security/teams/NotifyTeamChange/abstractions.js +8 -0
  259. package/features/security/teams/NotifyTeamChange/abstractions.js.map +1 -0
  260. package/features/security/teams/NotifyTeamChange/feature.d.ts +5 -0
  261. package/features/security/teams/NotifyTeamChange/feature.js +15 -0
  262. package/features/security/teams/NotifyTeamChange/feature.js.map +1 -0
  263. package/features/security/teams/NotifyTeamChange/index.d.ts +2 -0
  264. package/features/security/teams/NotifyTeamChange/index.js +2 -0
  265. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +2 -1
  266. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  267. package/features/security/teams/feature.js +2 -0
  268. package/features/security/teams/feature.js.map +1 -1
  269. package/features/task/TaskDefinition/abstractions.d.ts +13 -20
  270. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  271. package/features/task/TaskService/abstractions.d.ts +7 -0
  272. package/features/task/TaskService/abstractions.js.map +1 -1
  273. package/features/tenancy/TenantContext/TenantContext.d.ts +5 -1
  274. package/features/tenancy/TenantContext/TenantContext.js +31 -23
  275. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  276. package/features/users/shared/loaders.js.map +1 -1
  277. package/features/users/shared/types.d.ts +9 -7
  278. package/features/wcp/WcpContext/WcpContext.d.ts +6 -1
  279. package/features/wcp/WcpContext/WcpContext.js +17 -2
  280. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  281. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +9 -73
  282. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +25 -5
  283. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  284. package/features/wcp/WcpLicenseLoader.js.map +1 -1
  285. package/features/wcp/resolveWcpProjectEnvironment.d.ts +1 -1
  286. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -1
  287. package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.d.ts +20 -0
  288. package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.js +24 -0
  289. package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.js.map +1 -0
  290. package/features/websockets/SendToIdentity/abstractions.d.ts +19 -0
  291. package/features/websockets/SendToIdentity/abstractions.js +5 -0
  292. package/features/websockets/SendToIdentity/abstractions.js.map +1 -0
  293. package/features/websockets/WebsocketServiceError.d.ts +7 -0
  294. package/features/websockets/WebsocketServiceError.js +14 -0
  295. package/features/websockets/WebsocketServiceError.js.map +1 -0
  296. package/features/websockets/index.d.ts +6 -0
  297. package/features/websockets/index.js +3 -0
  298. package/features/websockets/types.d.ts +15 -0
  299. package/features/websockets/types.js +0 -0
  300. package/graphql/ApiCoreSchemaFactory.d.ts +1 -0
  301. package/graphql/ApiCoreSchemaFactory.js +7 -1
  302. package/graphql/ApiCoreSchemaFactory.js.map +1 -1
  303. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +1 -0
  304. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +4 -0
  305. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -1
  306. package/graphql/security/SecuritySchemaFactory.d.ts +1 -0
  307. package/graphql/security/SecuritySchemaFactory.js +4 -0
  308. package/graphql/security/SecuritySchemaFactory.js.map +1 -1
  309. package/graphql/system/SystemSchemaFactory.d.ts +1 -0
  310. package/graphql/system/SystemSchemaFactory.js +4 -0
  311. package/graphql/system/SystemSchemaFactory.js.map +1 -1
  312. package/graphql/users/UsersSchemaFactory.d.ts +1 -0
  313. package/graphql/users/UsersSchemaFactory.js +4 -0
  314. package/graphql/users/UsersSchemaFactory.js.map +1 -1
  315. package/graphql/wcp/WcpSchemaFactory.d.ts +1 -0
  316. package/graphql/wcp/WcpSchemaFactory.js +5 -1
  317. package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
  318. package/idp/JwksCache.d.ts +14 -3
  319. package/idp/JwksCache.js +97 -17
  320. package/idp/JwksCache.js.map +1 -1
  321. package/idp/JwksStoreFeature.d.ts +8 -0
  322. package/idp/JwksStoreFeature.js +11 -0
  323. package/idp/JwksStoreFeature.js.map +1 -0
  324. package/idp/MemoryJwksStore.d.ts +14 -0
  325. package/idp/MemoryJwksStore.js +21 -0
  326. package/idp/MemoryJwksStore.js.map +1 -0
  327. package/idp/OidcJwtIdentityProvider.js +5 -1
  328. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  329. package/idp/abstractions.d.ts +24 -0
  330. package/idp/abstractions.js +2 -1
  331. package/idp/abstractions.js.map +1 -1
  332. package/idp/feature.js +1 -2
  333. package/idp/feature.js.map +1 -1
  334. package/idp/index.d.ts +1 -0
  335. package/idp/index.js +1 -0
  336. package/index.d.ts +1 -0
  337. package/index.js +1 -0
  338. package/package.json +21 -21
  339. package/types/users.d.ts +2 -3
  340. package/features/logger/LoggerService.d.ts +0 -14
  341. package/features/logger/LoggerService.js +0 -48
  342. package/features/logger/LoggerService.js.map +0 -1
  343. package/features/logger/feature.js +0 -11
  344. package/features/logger/feature.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/users/UsersSchemaFactory.js","sources":["../../../src/graphql/users/UsersSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n NotFoundResponse,\n Response\n} from \"@webiny/api-graphql/responses.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport type { AdminUser } from \"~/types/users.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport NotAuthorizedResponse from \"~/graphql/security/NotAuthorizedResponse.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/abstractions.js\";\nimport { ListRolesUseCase } from \"~/features/security/roles/ListRoles/index.js\";\nimport { ListTeamsUseCase } from \"~/features/security/teams/ListTeams/index.js\";\n\nclass UsersSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type AdminUsersQuery {\n _empty: String\n }\n\n type AdminUsersMutation {\n _empty: String\n }\n\n extend type Query {\n adminUsers: AdminUsersQuery\n }\n\n extend type Mutation {\n adminUsers: AdminUsersMutation\n }\n\n type AdminUsersCreatedBy {\n id: ID\n displayName: String\n }\n\n type AdminUsersError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AdminUsersBooleanResponse {\n data: Boolean\n error: AdminUsersError\n }\n\n type AdminUser {\n id: ID!\n displayName: String!\n email: String!\n\n roles: [SecurityRole]\n firstName: String\n lastName: String\n avatar: JSON\n external: Boolean\n createdOn: DateTime\n }\n\n type AdminUsersResponse {\n data: AdminUser\n error: AdminUsersError\n }\n\n type AdminUsersListResponse {\n data: [AdminUser]\n error: AdminUsersError\n }\n\n input AdminUsersGetUserWhereInput {\n id: ID\n email: String\n }\n\n extend type AdminUsersQuery {\n getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse\n getCurrentUser: AdminUsersResponse\n listUsers: AdminUsersListResponse\n }\n\n extend type AdminUser {\n teams: [SecurityTeam]\n }\n `);\n\n builder.addResolver({\n path: \"Query.adminUsers\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.adminUsers\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"AdminUser.roles\",\n dependencies: [ListRolesUseCase],\n resolver:\n (listRoles: ListRolesUseCase.Interface) =>\n async ({ parent }: { parent: AdminUser }) => {\n if (!parent.roles) {\n return null;\n }\n\n const result = await listRoles.execute({ where: { id_in: parent.roles } });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n }\n });\n\n builder.addResolver({\n path: \"AdminUser.teams\",\n dependencies: [ListTeamsUseCase],\n resolver:\n (listTeams: ListTeamsUseCase.Interface) =>\n async ({ parent }: { parent: AdminUser }) => {\n const hasTeams = Array.isArray(parent.teams) && parent.teams.length > 0;\n if (!hasTeams) {\n return [];\n }\n\n const result = await listTeams.execute({ where: { id_in: parent.teams } });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n }\n });\n\n builder.addResolver<{ where: any }>({\n path: \"AdminUsersQuery.getUser\",\n dependencies: [GetUserUseCase],\n resolver:\n (getUser: GetUserUseCase.Interface) =>\n async ({ args }) => {\n const { where } = args;\n const userResult = await getUser.execute({\n id: where.id,\n email: where.email\n });\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User \"${JSON.stringify(where)}\" was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersQuery.getCurrentUser\",\n dependencies: [IdentityContext, GetUserUseCase],\n resolver:\n (identityContext: IdentityContext.Interface, getUser: GetUserUseCase.Interface) =>\n async () => {\n const identity = identityContext.getIdentity();\n\n if (!identity.isAdmin()) {\n throw new NotAuthorizedResponse();\n }\n\n // Current user might not have permissions to execute `getUser` (this method can load any user in the system),\n // but loading your own user record should be allowed. For that reason, let's temporarily disable authorization.\n const userResponse = await identityContext.withoutAuthorization(async () => {\n // Get user record using the identity ID.\n return await getUser.execute({ id: identity.id });\n });\n\n if (userResponse.isFail()) {\n const error = userResponse.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User with ID ${identity.id} was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResponse.value);\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersQuery.listUsers\",\n dependencies: [ListUsersUseCase],\n resolver: (listUsers: ListUsersUseCase.Interface) => async () => {\n const users = await listUsers.execute();\n\n if (users.isFail()) {\n return new ListErrorResponse(users.error);\n }\n\n return new ListResponse(users.value);\n }\n });\n\n return builder;\n }\n}\n\nexport const UsersSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: UsersSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["UsersSchemaFactoryImpl","builder","ListRolesUseCase","listRoles","parent","result","ListTeamsUseCase","listTeams","hasTeams","Array","GetUserUseCase","getUser","args","where","userResult","error","NotFoundResponse","JSON","ErrorResponse","Response","IdentityContext","identityContext","identity","NotAuthorizedResponse","userResponse","ListUsersUseCase","listUsers","users","ListErrorResponse","ListResponse","UsersSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;;;;;AAiBA,MAAMA;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;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IC,kBAAkBD,MAAM,KAAK;oBAG5C,OAAO,IAAIE,aAAaF,MAAM,KAAK;gBACvC;QACJ;QAEA,OAAO1B;IACX;AACJ;AAEO,MAAM6B,qBAAqBC,yBAAyB,oBAAoB,CAAC;IAC5E,gBAAgB/B;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"graphql/users/UsersSchemaFactory.js","sources":["../../../src/graphql/users/UsersSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n NotFoundResponse,\n Response\n} from \"@webiny/api-graphql/responses.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport type { AdminUser } from \"~/types/users.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport NotAuthorizedResponse from \"~/graphql/security/NotAuthorizedResponse.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/abstractions.js\";\nimport { ListRolesUseCase } from \"~/features/security/roles/ListRoles/index.js\";\nimport { ListTeamsUseCase } from \"~/features/security/teams/ListTeams/index.js\";\n\nclass UsersSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-core/UsersSchemaFactoryImpl\");\n\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type AdminUsersQuery {\n _empty: String\n }\n\n type AdminUsersMutation {\n _empty: String\n }\n\n extend type Query {\n adminUsers: AdminUsersQuery\n }\n\n extend type Mutation {\n adminUsers: AdminUsersMutation\n }\n\n type AdminUsersCreatedBy {\n id: ID\n displayName: String\n }\n\n type AdminUsersError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AdminUsersBooleanResponse {\n data: Boolean\n error: AdminUsersError\n }\n\n type AdminUser {\n id: ID!\n displayName: String!\n email: String!\n\n roles: [SecurityRole]\n firstName: String\n lastName: String\n avatar: JSON\n external: Boolean\n createdOn: DateTime\n }\n\n type AdminUsersResponse {\n data: AdminUser\n error: AdminUsersError\n }\n\n type AdminUsersListResponse {\n data: [AdminUser]\n error: AdminUsersError\n }\n\n input AdminUsersGetUserWhereInput {\n id: ID\n email: String\n }\n\n extend type AdminUsersQuery {\n getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse\n getCurrentUser: AdminUsersResponse\n listUsers: AdminUsersListResponse\n }\n\n extend type AdminUser {\n teams: [SecurityTeam]\n }\n `);\n\n builder.addResolver({\n path: \"Query.adminUsers\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.adminUsers\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"AdminUser.roles\",\n dependencies: [ListRolesUseCase],\n resolver:\n (listRoles: ListRolesUseCase.Interface) =>\n async ({ parent }: { parent: AdminUser }) => {\n if (!parent.roles) {\n return null;\n }\n\n const result = await listRoles.execute({ where: { id_in: parent.roles } });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n }\n });\n\n builder.addResolver({\n path: \"AdminUser.teams\",\n dependencies: [ListTeamsUseCase],\n resolver:\n (listTeams: ListTeamsUseCase.Interface) =>\n async ({ parent }: { parent: AdminUser }) => {\n const hasTeams = Array.isArray(parent.teams) && parent.teams.length > 0;\n if (!hasTeams) {\n return [];\n }\n\n const result = await listTeams.execute({ where: { id_in: parent.teams } });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n }\n });\n\n builder.addResolver<{ where: any }>({\n path: \"AdminUsersQuery.getUser\",\n dependencies: [GetUserUseCase],\n resolver:\n (getUser: GetUserUseCase.Interface) =>\n async ({ args }) => {\n const { where } = args;\n const userResult = await getUser.execute({\n id: where.id,\n email: where.email\n });\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User \"${JSON.stringify(where)}\" was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersQuery.getCurrentUser\",\n dependencies: [IdentityContext, GetUserUseCase],\n resolver:\n (identityContext: IdentityContext.Interface, getUser: GetUserUseCase.Interface) =>\n async () => {\n const identity = identityContext.getIdentity();\n\n if (!identity.isAdmin()) {\n throw new NotAuthorizedResponse();\n }\n\n // Current user might not have permissions to execute `getUser` (this method can load any user in the system),\n // but loading your own user record should be allowed. For that reason, let's temporarily disable authorization.\n const userResponse = await identityContext.withoutAuthorization(async () => {\n // Get user record using the identity ID.\n return await getUser.execute({ id: identity.id });\n });\n\n if (userResponse.isFail()) {\n const error = userResponse.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User with ID ${identity.id} was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResponse.value);\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersQuery.listUsers\",\n dependencies: [ListUsersUseCase],\n resolver: (listUsers: ListUsersUseCase.Interface) => async () => {\n const users = await listUsers.execute();\n\n if (users.isFail()) {\n return new ListErrorResponse(users.error);\n }\n\n return new ListResponse(users.value);\n }\n });\n\n return builder;\n }\n}\n\nexport const UsersSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: UsersSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["UsersSchemaFactoryImpl","builder","ListRolesUseCase","listRoles","parent","result","ListTeamsUseCase","listTeams","hasTeams","Array","GetUserUseCase","getUser","args","where","userResult","error","NotFoundResponse","JSON","ErrorResponse","Response","IdentityContext","identityContext","identity","NotAuthorizedResponse","userResponse","ListUsersUseCase","listUsers","users","ListErrorResponse","ListRespon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AW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACwB;aAAiB;YAChC,UAAU,CAACC,YAA0C;oBACjD,MAAMC,QAAQ,MAAMD,UAAU,OAAO;oBAErC,IAAIC,MAAM,MAAM,IACZ,OAAO,IAAIC,kBAAkBD,MAAM,KAAK;oBAG5C,OAAO,IAAIE,aAAaF,MAAM,KAAK;gBACvC;QACJ;QAEA,OAAO1B;IACX;;aA/MO,YAAY,GAAG6B,gBAAgB;;AAgN1C;AAEO,MAAMC,qBAAqBC,yBAAyB,oBAAoB,CAAC;IAC5E,gBAAgBhC;IAChB,cAAc,EAAE;AACpB"}
@@ -1,6 +1,7 @@
1
1
  import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
2
  import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
3
3
  declare class WcpSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
4
+ getSchemaKey: () => string;
4
5
  execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
5
6
  }
6
7
  export declare const WcpSchemaFactory: typeof WcpSchemaFactoryImpl & {
@@ -1,4 +1,5 @@
1
1
  import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
+ import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
2
3
  import { ErrorResponse, Response } from "@webiny/api-graphql/responses.js";
3
4
  import { WcpContext } from "../../features/wcp/WcpContext/index.js";
4
5
  class WcpSchemaFactoryImpl {
@@ -19,7 +20,7 @@ class WcpSchemaFactoryImpl {
19
20
  fileManager: WcpProjectPackageFeaturesFeature
20
21
  aiPowerups: WcpProjectPackageFeaturesFeature
21
22
  abTesting: WcpProjectPackageFeaturesFeature
22
- remoteComponents: WcpProjectPackageFeaturesFeature
23
+ collaboration: WcpProjectPackageFeaturesFeature
23
24
  }
24
25
 
25
26
  type WcpProjectPackage {
@@ -86,6 +87,9 @@ class WcpSchemaFactoryImpl {
86
87
  });
87
88
  return builder;
88
89
  }
90
+ constructor(){
91
+ this.getSchemaKey = staticSchemaKey("api-core/WcpSchemaFactoryImpl");
92
+ }
89
93
  }
90
94
  const WcpSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
91
95
  implementation: WcpSchemaFactoryImpl,
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/wcp/WcpSchemaFactory.js","sources":["../../../src/graphql/wcp/WcpSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { WcpContext } from \"~/features/wcp/WcpContext/index.js\";\n\nclass WcpSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type WcpProjectPackageFeaturesFeature {\n enabled: Boolean\n options: JSON\n }\n\n type WcpProjectPackageFeatures {\n seats: WcpProjectPackageFeaturesFeature\n multiTenancy: WcpProjectPackageFeaturesFeature\n advancedPublishingWorkflow: WcpProjectPackageFeaturesFeature\n advancedAccessControlLayer: WcpProjectPackageFeaturesFeature\n auditLogs: WcpProjectPackageFeaturesFeature\n recordLocking: WcpProjectPackageFeaturesFeature\n fileManager: WcpProjectPackageFeaturesFeature\n aiPowerups: WcpProjectPackageFeaturesFeature\n abTesting: WcpProjectPackageFeaturesFeature\n remoteComponents: WcpProjectPackageFeaturesFeature\n }\n\n type WcpProjectPackage {\n features: WcpProjectPackageFeatures\n }\n\n type WcpProject {\n orgId: ID\n projectId: ID\n package: WcpProjectPackage\n }\n\n type WcpError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type WcpProjectResponse {\n data: WcpProject\n error: WcpError\n }\n\n type WcpQuery {\n getProject: WcpProjectResponse\n }\n\n type WcpMutation {\n updateProject: WcpProjectResponse\n }\n\n extend type Query {\n wcp: WcpQuery\n }\n\n extend type Mutation {\n wcp: WcpMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.wcp\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"WcpQuery.getProject\",\n dependencies: [WcpContext],\n resolver: (wcpContext: WcpContext.Interface) => async () => {\n try {\n const project = wcpContext.getProjectWithFeatureFlags();\n\n if (!project) {\n throw Error(`Could not get project!`);\n }\n\n return new Response(project);\n } catch (e) {\n return new ErrorResponse({\n code: \"COULD_NOT_GET_PROJECT\",\n message: e.message,\n data: null,\n stack: e.stack\n });\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const WcpSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: WcpSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["WcpSchemaFactoryImpl","builder","WcpContext","wcpContext","project","Error","Response","e","ErrorResponse","WcpSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;AAKA,MAAMA;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwDnC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAW;YAC1B,UAAU,CAACC,aAAqC;oBAC5C,IAAI;wBACA,MAAMC,UAAUD,WAAW,0BAA0B;wBAErD,IAAI,CAACC,SACD,MAAMC,MAAM;wBAGhB,OAAO,IAAIC,SAASF;oBACxB,EAAE,OAAOG,GAAG;wBACR,OAAO,IAAIC,cAAc;4BACrB,MAAM;4BACN,SAASD,EAAE,OAAO;4BAClB,MAAM;4BACN,OAAOA,EAAE,KAAK;wBAClB;oBACJ;gBACJ;QACJ;QAEA,OAAON;IACX;AACJ;AAEO,MAAMQ,mBAAmBC,yBAAyB,oBAAoB,CAAC;IAC1E,gBAAgBV;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"graphql/wcp/WcpSchemaFactory.js","sources":["../../../src/graphql/wcp/WcpSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { WcpContext } from \"~/features/wcp/WcpContext/index.js\";\n\nclass WcpSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-core/WcpSchemaFactoryImpl\");\n\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type WcpProjectPackageFeaturesFeature {\n enabled: Boolean\n options: JSON\n }\n\n type WcpProjectPackageFeatures {\n seats: WcpProjectPackageFeaturesFeature\n multiTenancy: WcpProjectPackageFeaturesFeature\n advancedPublishingWorkflow: WcpProjectPackageFeaturesFeature\n advancedAccessControlLayer: WcpProjectPackageFeaturesFeature\n auditLogs: WcpProjectPackageFeaturesFeature\n recordLocking: WcpProjectPackageFeaturesFeature\n fileManager: WcpProjectPackageFeaturesFeature\n aiPowerups: WcpProjectPackageFeaturesFeature\n abTesting: WcpProjectPackageFeaturesFeature\n collaboration: WcpProjectPackageFeaturesFeature\n }\n\n type WcpProjectPackage {\n features: WcpProjectPackageFeatures\n }\n\n type WcpProject {\n orgId: ID\n projectId: ID\n package: WcpProjectPackage\n }\n\n type WcpError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type WcpProjectResponse {\n data: WcpProject\n error: WcpError\n }\n\n type WcpQuery {\n getProject: WcpProjectResponse\n }\n\n type WcpMutation {\n updateProject: WcpProjectResponse\n }\n\n extend type Query {\n wcp: WcpQuery\n }\n\n extend type Mutation {\n wcp: WcpMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.wcp\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"WcpQuery.getProject\",\n dependencies: [WcpContext],\n resolver: (wcpContext: WcpContext.Interface) => async () => {\n try {\n const project = wcpContext.getProjectWithFeatureFlags();\n\n if (!project) {\n throw Error(`Could not get project!`);\n }\n\n return new Response(project);\n } catch (e) {\n return new ErrorResponse({\n code: \"COULD_NOT_GET_PROJECT\",\n message: e.message,\n data: null,\n stack: e.stack\n });\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const WcpSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: WcpSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["WcpSchemaFactoryImpl","builder","WcpContext","wcpContext","project","Error","Response","e","ErrorResponse","staticSchemaKey","WcpSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;AAMA,MAAMA;IAGF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwDnC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAW;YAC1B,UAAU,CAACC,aAAqC;oBAC5C,IAAI;wBACA,MAAMC,UAAUD,WAAW,0BAA0B;wBAErD,IAAI,CAACC,SACD,MAAMC,MAAM;wBAGhB,OAAO,IAAIC,SAASF;oBACxB,EAAE,OAAOG,GAAG;wBACR,OAAO,IAAIC,cAAc;4BACrB,MAAM;4BACN,SAASD,EAAE,OAAO;4BAClB,MAAM;4BACN,OAAOA,EAAE,KAAK;wBAClB;oBACJ;gBACJ;QACJ;QAEA,OAAON;IACX;;aA1FO,YAAY,GAAGQ,gBAAgB;;AA2F1C;AAEO,MAAMC,mBAAmBC,yBAAyB,oBAAoB,CAAC;IAC1E,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
@@ -1,7 +1,18 @@
1
1
  import type { Jwk } from "../features/security/utils/verifyJwtUsingJwk.js";
2
+ import { HttpClient } from "../features/httpClient/index.js";
2
3
  import { JwkCache } from "./abstractions.js";
3
- export declare class JwksCache implements JwkCache.Interface {
4
- private cache;
4
+ import { JwksStore } from "./abstractions.js";
5
+ declare class JwksCacheImpl implements JwkCache.Interface {
6
+ private readonly httpClient;
7
+ private readonly store;
8
+ private readonly states;
9
+ constructor(httpClient: HttpClient.Interface, store: JwksStore.Interface | undefined);
5
10
  getKeys(issuer: string): Promise<Jwk[]>;
6
- clearCache(): void;
11
+ refreshKeys(issuer: string): Promise<Jwk[] | null>;
12
+ private getState;
13
+ private fetchKeys;
14
+ private loadKeys;
15
+ private fetchJson;
7
16
  }
17
+ export declare const JwksCache: import("@webiny/di").Implementation<typeof JwksCacheImpl>;
18
+ export {};
package/idp/JwksCache.js CHANGED
@@ -1,26 +1,106 @@
1
- class JwksCache {
1
+ import { createImplementation } from "@webiny/feature/api";
2
+ import { z } from "zod";
3
+ import { HttpClient } from "../features/httpClient/index.js";
4
+ import { JwkCache, JwksStore } from "./abstractions.js";
5
+ const MAX_AGE_MS = 600000;
6
+ const MIN_REFETCH_INTERVAL_MS = 60000;
7
+ const oidcConfigurationSchema = z.object({
8
+ jwks_uri: z.string()
9
+ });
10
+ const jwksSchema = z.object({
11
+ keys: z.array(z.looseObject({
12
+ kid: z.string().optional()
13
+ }))
14
+ });
15
+ function getOpenidConfigurationUrl(issuer) {
16
+ const openidUrl = new URL(issuer);
17
+ const pathname = openidUrl.pathname + "/.well-known/openid-configuration";
18
+ openidUrl.pathname = pathname.replace(/\/+/g, "/");
19
+ return openidUrl.toString();
20
+ }
21
+ function attemptedRecently(state) {
22
+ if (!state.lastAttemptAt) return false;
23
+ return Date.now() - state.lastAttemptAt < MIN_REFETCH_INTERVAL_MS;
24
+ }
25
+ class JwksCacheImpl {
26
+ constructor(httpClient, store){
27
+ this.httpClient = httpClient;
28
+ this.store = store;
29
+ this.states = new Map();
30
+ }
2
31
  async getKeys(issuer) {
3
- const cached = this.cache.get(issuer);
4
- if (cached) return cached.jwks;
5
- const openidUrl = new URL(issuer);
6
- const pathname = openidUrl.pathname + "/.well-known/openid-configuration";
7
- openidUrl.pathname = pathname.replace(/\/+/g, "/");
8
- const oidcConfig = await fetch(openidUrl.toString()).then((res)=>res.json());
9
- const jwksResponse = await fetch(oidcConfig.jwks_uri).then((res)=>res.json());
10
- const jwks = jwksResponse.keys;
11
- this.cache.set(issuer, {
12
- oidcConfig,
13
- jwks
32
+ const state = this.getState(issuer);
33
+ if (!state.keys) return this.fetchKeys(issuer, state);
34
+ const age = Date.now() - (state.fetchedAt ?? 0);
35
+ if (age < MAX_AGE_MS || attemptedRecently(state)) return state.keys;
36
+ try {
37
+ return await this.fetchKeys(issuer, state);
38
+ } catch {
39
+ return state.keys;
40
+ }
41
+ }
42
+ async refreshKeys(issuer) {
43
+ const state = this.getState(issuer);
44
+ if (attemptedRecently(state)) return null;
45
+ try {
46
+ return await this.fetchKeys(issuer, state);
47
+ } catch {
48
+ return null;
49
+ }
50
+ }
51
+ getState(issuer) {
52
+ if (this.store) return this.store.get(issuer);
53
+ let state = this.states.get(issuer);
54
+ if (!state) {
55
+ state = {};
56
+ this.states.set(issuer, state);
57
+ }
58
+ return state;
59
+ }
60
+ fetchKeys(issuer, state) {
61
+ if (state.pending) return state.pending;
62
+ state.lastAttemptAt = Date.now();
63
+ const pending = this.loadKeys(issuer).then((keys)=>{
64
+ state.keys = keys;
65
+ state.fetchedAt = Date.now();
66
+ return keys;
14
67
  });
15
- return jwks;
68
+ state.pending = pending;
69
+ const clearPending = ()=>{
70
+ state.pending = void 0;
71
+ };
72
+ pending.then(clearPending, clearPending);
73
+ return pending;
16
74
  }
17
- clearCache() {
18
- this.cache.clear();
75
+ async loadKeys(issuer) {
76
+ const openidConfigurationUrl = getOpenidConfigurationUrl(issuer);
77
+ const oidcConfig = await this.fetchJson(openidConfigurationUrl, oidcConfigurationSchema);
78
+ const jwksResponse = await this.fetchJson(oidcConfig.jwks_uri, jwksSchema);
79
+ return jwksResponse.keys;
19
80
  }
20
- constructor(){
21
- this.cache = new Map();
81
+ async fetchJson(url, schema) {
82
+ const response = await this.httpClient.requestJson({
83
+ url
84
+ });
85
+ if (response.isFail()) throw response.error;
86
+ const result = schema.safeParse(response.value);
87
+ if (!result.success) throw new Error(`Invalid response from "${url}": ${result.error.message}`);
88
+ return result.data;
22
89
  }
23
90
  }
91
+ const JwksCache = createImplementation({
92
+ abstraction: JwkCache,
93
+ implementation: JwksCacheImpl,
94
+ dependencies: [
95
+ HttpClient,
96
+ [
97
+ JwksStore,
98
+ {
99
+ optional: true
100
+ }
101
+ ]
102
+ ]
103
+ });
24
104
  export { JwksCache };
25
105
 
26
106
  //# sourceMappingURL=JwksCache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"idp/JwksCache.js","sources":["../../src/idp/JwksCache.ts"],"sourcesContent":["import type { Jwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\nimport { JwkCache } from \"./abstractions.js\";\n\ninterface OidcConfiguration {\n jwks_uri: string;\n [key: string]: any;\n}\n\ninterface CacheEntry {\n oidcConfig: OidcConfiguration;\n jwks: Jwk[];\n}\n\nexport class JwksCache implements JwkCache.Interface {\n private cache = new Map<string, CacheEntry>();\n\n async getKeys(issuer: string): Promise<Jwk[]> {\n // Check cache first\n const cached = this.cache.get(issuer);\n if (cached) {\n return cached.jwks;\n }\n\n // Fetch OIDC configuration\n const openidUrl = new URL(issuer);\n const pathname = openidUrl.pathname + \"/.well-known/openid-configuration\";\n openidUrl.pathname = pathname.replace(/\\/+/g, \"/\");\n\n const oidcConfig = await fetch(openidUrl.toString()).then(\n res => res.json() as Promise<OidcConfiguration>\n );\n\n // Fetch JWKs from jwks_uri\n const jwksResponse = await fetch(oidcConfig.jwks_uri).then(res => res.json());\n const jwks = jwksResponse.keys as Jwk[];\n\n // Cache both config and JWKs\n this.cache.set(issuer, {\n oidcConfig,\n jwks\n });\n\n return jwks;\n }\n\n clearCache(): void {\n this.cache.clear();\n }\n}\n"],"names":["JwksCache","issuer","cached","openidUrl","URL","pathname","oidcConfig","fetch","res","jwksResponse","jwks","Map"],"mappings":"AAaO,MAAMA;IAGT,MAAM,QAAQC,MAAc,EAAkB;QAE1C,MAAMC,SAAS,IAAI,CAAC,KAAK,CAAC,GAAG,CAACD;QAC9B,IAAIC,QACA,OAAOA,OAAO,IAAI;QAItB,MAAMC,YAAY,IAAIC,IAAIH;QAC1B,MAAMI,WAAWF,UAAU,QAAQ,GAAG;QACtCA,UAAU,QAAQ,GAAGE,SAAS,OAAO,CAAC,QAAQ;QAE9C,MAAMC,aAAa,MAAMC,MAAMJ,UAAU,QAAQ,IAAI,IAAI,CACrDK,CAAAA,MAAOA,IAAI,IAAI;QAInB,MAAMC,eAAe,MAAMF,MAAMD,WAAW,QAAQ,EAAE,IAAI,CAACE,CAAAA,MAAOA,IAAI,IAAI;QAC1E,MAAME,OAAOD,aAAa,IAAI;QAG9B,IAAI,CAAC,KAAK,CAAC,GAAG,CAACR,QAAQ;YACnBK;YACAI;QACJ;QAEA,OAAOA;IACX;IAEA,aAAmB;QACf,IAAI,CAAC,KAAK,CAAC,KAAK;IACpB;;aAjCQ,KAAK,GAAG,IAAIC;;AAkCxB"}
1
+ {"version":3,"file":"idp/JwksCache.js","sources":["../../src/idp/JwksCache.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { z } from \"zod\";\nimport type { Jwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\nimport { HttpClient } from \"~/features/httpClient/index.js\";\nimport { JwkCache } from \"./abstractions.js\";\nimport { JwksStore } from \"./abstractions.js\";\n\n// Keys older than this are fetched again, so a key the issuer removes stops verifying tokens.\nconst MAX_AGE_MS = 10 * 60_000;\n\n// The shortest time between two fetches that aren't for missing keys: refreshes for unknown key\n// ids, and retries after a failed fetch.\nconst MIN_REFETCH_INTERVAL_MS = 60_000;\n\nconst oidcConfigurationSchema = z.object({\n jwks_uri: z.string()\n});\n\nconst jwksSchema = z.object({\n keys: z.array(z.looseObject({ kid: z.string().optional() }))\n});\n\nfunction getOpenidConfigurationUrl(issuer: string): string {\n const openidUrl = new URL(issuer);\n const pathname = openidUrl.pathname + \"/.well-known/openid-configuration\";\n openidUrl.pathname = pathname.replace(/\\/+/g, \"/\");\n return openidUrl.toString();\n}\n\nfunction attemptedRecently(state: JwksStore.IssuerState): boolean {\n if (!state.lastAttemptAt) {\n return false;\n }\n return Date.now() - state.lastAttemptAt < MIN_REFETCH_INTERVAL_MS;\n}\n\nclass JwksCacheImpl implements JwkCache.Interface {\n // Used when no JwksStore is registered: the keys then last for this instance only.\n private readonly states = new Map<string, JwksStore.IssuerState>();\n\n constructor(\n private readonly httpClient: HttpClient.Interface,\n private readonly store: JwksStore.Interface | undefined\n ) {}\n\n async getKeys(issuer: string): Promise<Jwk[]> {\n const state = this.getState(issuer);\n\n // No keys yet: fetch them, and let a failure fail the token verification.\n if (!state.keys) {\n return this.fetchKeys(issuer, state);\n }\n\n const age = Date.now() - (state.fetchedAt ?? 0);\n if (age < MAX_AGE_MS || attemptedRecently(state)) {\n return state.keys;\n }\n\n /*\n * Expired. Fetch again, but keep using the old keys if the issuer can't be reached, so an\n * outage doesn't fail every login. The failed attempt counts, so the next try waits.\n */\n try {\n return await this.fetchKeys(issuer, state);\n } catch {\n return state.keys;\n }\n }\n\n async refreshKeys(issuer: string): Promise<Jwk[] | null> {\n const state = this.getState(issuer);\n if (attemptedRecently(state)) {\n return null;\n }\n\n try {\n return await this.fetchKeys(issuer, state);\n } catch {\n return null;\n }\n }\n\n private getState(issuer: string): JwksStore.IssuerState {\n if (this.store) {\n return this.store.get(issuer);\n }\n\n let state = this.states.get(issuer);\n if (!state) {\n state = {};\n this.states.set(issuer, state);\n }\n return state;\n }\n\n // One fetch per issuer at a time: concurrent callers share the one in progress.\n private fetchKeys(issuer: string, state: JwksStore.IssuerState): Promise<Jwk[]> {\n if (state.pending) {\n return state.pending;\n }\n\n state.lastAttemptAt = Date.now();\n const pending = this.loadKeys(issuer).then(keys => {\n state.keys = keys;\n state.fetchedAt = Date.now();\n return keys;\n });\n state.pending = pending;\n\n const clearPending = () => {\n state.pending = undefined;\n };\n pending.then(clearPending, clearPending);\n\n return pending;\n }\n\n private async loadKeys(issuer: string): Promise<Jwk[]> {\n const openidConfigurationUrl = getOpenidConfigurationUrl(issuer);\n const oidcConfig = await this.fetchJson(openidConfigurationUrl, oidcConfigurationSchema);\n const jwksResponse = await this.fetchJson(oidcConfig.jwks_uri, jwksSchema);\n return jwksResponse.keys;\n }\n\n // Throws, so a failed fetch fails the token verification instead of caching a bad answer.\n private async fetchJson<T>(url: string, schema: z.ZodType<T>): Promise<T> {\n const response = await this.httpClient.requestJson({ url });\n if (response.isFail()) {\n throw response.error;\n }\n\n const result = schema.safeParse(response.value);\n if (!result.success) {\n throw new Error(`Invalid response from \"${url}\": ${result.error.message}`);\n }\n\n return result.data;\n }\n}\n\nexport const JwksCache = createImplementation({\n abstraction: JwkCache,\n implementation: JwksCacheImpl,\n dependencies: [HttpClient, [JwksStore, { optional: true }]]\n});\n"],"names":["MAX_AGE_MS","MIN_REFETCH_INTERVAL_MS","oidcConfigurationSchema","z","jwksSchema","getOpenidConfigurationUrl","issuer","openidUrl","URL","pathname","attemptedRecently","state","Date","JwksCacheImpl","httpClient","store","Map","age","pending","keys","clearPending","undefined","openidConfigurationUrl","oidcConfig","jwksResponse","url","schema","response","result","Error","JwksCache","createImplementation","JwkCache","HttpClient","JwksStore"],"mappings":";;;;AAQA,MAAMA,aAAa;AAInB,MAAMC,0BAA0B;AAEhC,MAAMC,0B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M,CAAC,uBAAuB,EAAEJ,IAAI,GAAG,EAAEG,OAAO,KAAK,CAAC,OAAO,EAAE;QAG7E,OAAOA,OAAO,IAAI;IACtB;AACJ;AAEO,MAAME,YAAYC,qBAAqB;IAC1C,aAAaC;IACb,gBAAgBnB;IAChB,cAAc;QAACoB;QAAY;YAACC;YAAW;gBAAE,UAAU;YAAK;SAAE;KAAC;AAC/D"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Register in the ROOT container, so an issuer's keys are fetched once per process instead of on
3
+ * every authenticated request.
4
+ */
5
+ export declare const JwksStoreFeature: {
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 { MemoryJwksStore } from "./MemoryJwksStore.js";
3
+ const JwksStoreFeature = createFeature({
4
+ name: "JwksStore",
5
+ register (container) {
6
+ container.register(MemoryJwksStore).inSingletonScope();
7
+ }
8
+ });
9
+ export { JwksStoreFeature };
10
+
11
+ //# sourceMappingURL=JwksStoreFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idp/JwksStoreFeature.js","sources":["../../src/idp/JwksStoreFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { MemoryJwksStore } from \"./MemoryJwksStore.js\";\n\n/**\n * Register in the ROOT container, so an issuer's keys are fetched once per process instead of on\n * every authenticated request.\n */\nexport const JwksStoreFeature = createFeature({\n name: \"JwksStore\",\n register(container) {\n container.register(MemoryJwksStore).inSingletonScope();\n }\n});\n"],"names":["JwksStoreFeature","createFeature","container","MemoryJwksStore"],"mappings":";;AAOO,MAAMA,mBAAmBC,cAAc;IAC1C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,iBAAiB,gBAAgB;IACxD;AACJ"}
@@ -0,0 +1,14 @@
1
+ import { JwksStore as Abstraction } from "./abstractions.js";
2
+ /**
3
+ * Holds one entry per configured identity provider (Cognito, Okta, Auth0...), keyed by the issuer
4
+ * in that provider's configuration, never by anything taken from a request, so it can't grow with
5
+ * traffic. A refresh updates the issuer's entry instead of adding one.
6
+ */
7
+ declare class MemoryJwksStoreImpl implements Abstraction.Interface {
8
+ private readonly states;
9
+ get(issuer: string): Abstraction.IssuerState;
10
+ }
11
+ export declare const MemoryJwksStore: typeof MemoryJwksStoreImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IJwksStore>;
13
+ };
14
+ export {};
@@ -0,0 +1,21 @@
1
+ import { JwksStore } from "./abstractions.js";
2
+ class MemoryJwksStoreImpl {
3
+ get(issuer) {
4
+ let state = this.states.get(issuer);
5
+ if (!state) {
6
+ state = {};
7
+ this.states.set(issuer, state);
8
+ }
9
+ return state;
10
+ }
11
+ constructor(){
12
+ this.states = new Map();
13
+ }
14
+ }
15
+ const MemoryJwksStore = JwksStore.createImplementation({
16
+ implementation: MemoryJwksStoreImpl,
17
+ dependencies: []
18
+ });
19
+ export { MemoryJwksStore };
20
+
21
+ //# sourceMappingURL=MemoryJwksStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idp/MemoryJwksStore.js","sources":["../../src/idp/MemoryJwksStore.ts"],"sourcesContent":["import { JwksStore as Abstraction } from \"./abstractions.js\";\n\n/**\n * Holds one entry per configured identity provider (Cognito, Okta, Auth0...), keyed by the issuer\n * in that provider's configuration, never by anything taken from a request, so it can't grow with\n * traffic. A refresh updates the issuer's entry instead of adding one.\n */\nclass MemoryJwksStoreImpl implements Abstraction.Interface {\n private readonly states = new Map<string, Abstraction.IssuerState>();\n\n public get(issuer: string): Abstraction.IssuerState {\n let state = this.states.get(issuer);\n if (!state) {\n state = {};\n this.states.set(issuer, state);\n }\n return state;\n }\n}\n\nexport const MemoryJwksStore = Abstraction.createImplementation({\n implementation: MemoryJwksStoreImpl,\n dependencies: []\n});\n"],"names":["MemoryJwksStoreImpl","issuer","state","Map","MemoryJwksStore","Abstraction"],"mappings":";AAOA,MAAMA;IAGK,IAAIC,MAAc,EAA2B;QAChD,IAAIC,QAAQ,IAAI,CAAC,MAAM,CAAC,GAAG,CAACD;QAC5B,IAAI,CAACC,OAAO;YACRA,QAAQ,CAAC;YACT,IAAI,CAAC,MAAM,CAAC,GAAG,CAACD,QAAQC;QAC5B;QACA,OAAOA;IACX;;aATiB,MAAM,GAAG,IAAIC;;AAUlC;AAEO,MAAMC,kBAAkBC,UAAAA,oBAAgC,CAAC;IAC5D,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -39,7 +39,11 @@ class OidcJwtIdentityProviderImpl {
39
39
  return null;
40
40
  }
41
41
  const jwks = await this.jwksCache.getKeys(provider.issuer);
42
- const jwk = jwks.find((key)=>key.kid === header.kid);
42
+ let jwk = jwks.find((key)=>key.kid === header.kid);
43
+ if (!jwk) {
44
+ const refreshed = await this.jwksCache.refreshKeys(provider.issuer);
45
+ jwk = refreshed?.find((key)=>key.kid === header.kid);
46
+ }
43
47
  if (!jwk) return null;
44
48
  if (!verifiedPayload) verifiedPayload = await verifyJwtUsingJwk(token, jwk);
45
49
  if (provider.verifyTokenClaims) await provider.verifyTokenClaims(verifiedPayload);
@@ -1 +1 @@
1
- {"version":3,"file":"idp/OidcJwtIdentityProvider.js","sources":["../../src/idp/OidcJwtIdentityProvider.ts"],"sourcesContent":["import { verifyJwtUsingJwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\nimport type { IdentityData } from \"~/features/security/IdentityContext/Identity.js\";\nimport { JwkCache, JwtIdentityProvider, OidcIdentityProvider } from \"./abstractions.js\";\n\nclass OidcJwtIdentityProviderImpl implements JwtIdentityProvider.Interface {\n constructor(\n private oidcIdentityProviders: OidcIdentityProvider.Interface[],\n private jwksCache: JwkCache.Interface\n ) {}\n\n isApplicable(token: JwtIdentityProvider.JwtPayload): boolean {\n return this.oidcIdentityProviders.some(provider => provider.isApplicable(token));\n }\n\n async getIdentity(token: string, jwt: JwtIdentityProvider.Jwt): Promise<IdentityData | null> {\n const { header, payload } = jwt;\n\n const provider = this.getApplicableProvider(payload);\n\n if (!provider) {\n return null;\n }\n\n const verifiedPayload = await this.verifyToken(provider, token, header);\n\n if (!verifiedPayload) {\n return null;\n }\n\n // Call config.getIdentity to get IdentityData\n const providerIdentity = await provider.getIdentity(verifiedPayload);\n\n const identity: IdentityData = {\n ...providerIdentity,\n type: providerIdentity.type ?? \"admin\"\n };\n\n // Handle default values\n const context = identity.context ?? { canAccessTenant: true, defaultTenantId: \"root\" };\n if (context.canAccessTenant === undefined) {\n context.canAccessTenant = true;\n }\n if (context.defaultTenantId === undefined) {\n context.defaultTenantId = \"root\";\n }\n\n identity.context = context;\n\n return identity;\n }\n\n private getApplicableProvider(\n payload: JwtIdentityProvider.JwtPayload\n ): OidcIdentityProvider.Interface | undefined {\n return this.oidcIdentityProviders.find(provider => provider.isApplicable(payload));\n }\n\n private async verifyToken(\n provider: OidcIdentityProvider.Interface,\n token: string,\n header: JwtIdentityProvider.JwtHeader\n ) {\n // If the implementation specifies a custom verification function, use it.\n let verifiedPayload: JwtIdentityProvider.JwtPayload | undefined;\n if (typeof provider.verifyToken === \"function\") {\n // Use custom verification\n const result = await provider.verifyToken(token);\n if (result) {\n return result;\n }\n return null;\n }\n\n // Otherwise, continue with OIDC best practices, using JWKs.\n\n // Fetch JWKs from cache\n const jwks = await this.jwksCache.getKeys(provider.issuer);\n\n // Find matching JWK using header.kid\n const jwk = jwks.find(key => key.kid === header.kid);\n if (!jwk) {\n return null;\n }\n\n if (!verifiedPayload) {\n // Default JWK verification\n verifiedPayload = await verifyJwtUsingJwk(token, jwk);\n }\n\n // Call verifyTokenClaims if provided\n if (provider.verifyTokenClaims) {\n await provider.verifyTokenClaims(verifiedPayload);\n }\n\n return verifiedPayload;\n }\n}\n\nexport const OidcJwtIdentityProvider = JwtIdentityProvider.createImplementation({\n implementation: OidcJwtIdentityProviderImpl,\n dependencies: [[OidcIdentityProvider, { multiple: true }], JwkCache]\n});\n"],"names":["OidcJwtIdentityProviderImpl","oidcIdentityProviders","jwksCache","token","provider","jwt","header","payload","verifiedPayload","providerIdentity","identity","context","undefined","result","jwks","jwk","key","verifyJwtUsingJwk","OidcJwtIdentityProvider","JwtIdentityProvider","OidcIdentityProvider","JwkCache"],"mappings":";;AAIA,MAAMA;IACF,YACYC,qBAAuD,EACvDC,SAA6B,CACvC;aAFUD,qBAAqB,GAArBA;aACAC,SAAS,GAATA;IACT;IAEH,aAAaC,KAAqC,EAAW;QACzD,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAACC,CAAAA,WAAYA,SAAS,YAAY,CAACD;IAC7E;IAEA,MAAM,YAAYA,KAAa,EAAEE,GAA4B,EAAgC;QACzF,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAE5B,MAAMD,WAAW,IAAI,CAAC,qBAAqB,CAACG;QAE5C,IAAI,CAACH,UACD,OAAO;QAGX,MAAMI,kBAAkB,MAAM,IAAI,CAAC,WAAW,CAACJ,UAAUD,OAAOG;QAEhE,IAAI,CAACE,iBACD,OAAO;QAIX,MAAMC,mBAAmB,MAAML,SAAS,WAAW,CAACI;QAEpD,MAAME,WAAyB;YAC3B,GAAGD,gBAAgB;YACnB,MAAMA,iBAAiB,IAAI,IAAI;QACnC;QAGA,MAAME,UAAUD,SAAS,OAAO,IAAI;YAAE,iBAAiB;YAAM,iBAAiB;QAAO;QACrF,IAAIC,AAA4BC,WAA5BD,QAAQ,eAAe,EACvBA,QAAQ,eAAe,GAAG;QAE9B,IAAIA,AAA4BC,WAA5BD,QAAQ,eAAe,EACvBA,QAAQ,eAAe,GAAG;QAG9BD,SAAS,OAAO,GAAGC;QAEnB,OAAOD;IACX;IAEQ,sBACJH,OAAuC,EACG;QAC1C,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAACH,CAAAA,WAAYA,SAAS,YAAY,CAACG;IAC7E;IAEA,MAAc,YACVH,QAAwC,EACxCD,KAAa,EACbG,MAAqC,EACvC;QAEE,IAAIE;QACJ,IAAI,AAAgC,cAAhC,OAAOJ,SAAS,WAAW,EAAiB;YAE5C,MAAMS,SAAS,MAAMT,SAAS,WAAW,CAACD;YAC1C,IAAIU,QACA,OAAOA;YAEX,OAAO;QACX;QAKA,MAAMC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACV,SAAS,MAAM;QAGzD,MAAMW,MAAMD,KAAK,IAAI,CAACE,CAAAA,MAAOA,IAAI,GAAG,KAAKV,OAAO,GAAG;QACnD,IAAI,CAACS,KACD,OAAO;QAGX,IAAI,CAACP,iBAEDA,kBAAkB,MAAMS,kBAAkBd,OAAOY;QAIrD,IAAIX,SAAS,iBAAiB,EAC1B,MAAMA,SAAS,iBAAiB,CAACI;QAGrC,OAAOA;IACX;AACJ;AAEO,MAAMU,0BAA0BC,oBAAoB,oBAAoB,CAAC;IAC5E,gBAAgBnB;IAChB,cAAc;QAAC;YAACoB;YAAsB;gBAAE,UAAU;YAAK;SAAE;QAAEC;KAAS;AACxE"}
1
+ {"version":3,"file":"idp/OidcJwtIdentityProvider.js","sources":["../../src/idp/OidcJwtIdentityProvider.ts"],"sourcesContent":["import { verifyJwtUsingJwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\nimport type { IdentityData } from \"~/features/security/IdentityContext/Identity.js\";\nimport { JwkCache, JwtIdentityProvider, OidcIdentityProvider } from \"./abstractions.js\";\n\nclass OidcJwtIdentityProviderImpl implements JwtIdentityProvider.Interface {\n constructor(\n private oidcIdentityProviders: OidcIdentityProvider.Interface[],\n private jwksCache: JwkCache.Interface\n ) {}\n\n isApplicable(token: JwtIdentityProvider.JwtPayload): boolean {\n return this.oidcIdentityProviders.some(provider => provider.isApplicable(token));\n }\n\n async getIdentity(token: string, jwt: JwtIdentityProvider.Jwt): Promise<IdentityData | null> {\n const { header, payload } = jwt;\n\n const provider = this.getApplicableProvider(payload);\n\n if (!provider) {\n return null;\n }\n\n const verifiedPayload = await this.verifyToken(provider, token, header);\n\n if (!verifiedPayload) {\n return null;\n }\n\n // Call config.getIdentity to get IdentityData\n const providerIdentity = await provider.getIdentity(verifiedPayload);\n\n const identity: IdentityData = {\n ...providerIdentity,\n type: providerIdentity.type ?? \"admin\"\n };\n\n // Handle default values\n const context = identity.context ?? { canAccessTenant: true, defaultTenantId: \"root\" };\n if (context.canAccessTenant === undefined) {\n context.canAccessTenant = true;\n }\n if (context.defaultTenantId === undefined) {\n context.defaultTenantId = \"root\";\n }\n\n identity.context = context;\n\n return identity;\n }\n\n private getApplicableProvider(\n payload: JwtIdentityProvider.JwtPayload\n ): OidcIdentityProvider.Interface | undefined {\n return this.oidcIdentityProviders.find(provider => provider.isApplicable(payload));\n }\n\n private async verifyToken(\n provider: OidcIdentityProvider.Interface,\n token: string,\n header: JwtIdentityProvider.JwtHeader\n ) {\n // If the implementation specifies a custom verification function, use it.\n let verifiedPayload: JwtIdentityProvider.JwtPayload | undefined;\n if (typeof provider.verifyToken === \"function\") {\n // Use custom verification\n const result = await provider.verifyToken(token);\n if (result) {\n return result;\n }\n return null;\n }\n\n // Otherwise, continue with OIDC best practices, using JWKs.\n\n // Fetch JWKs from cache\n const jwks = await this.jwksCache.getKeys(provider.issuer);\n\n /*\n * Find matching JWK using header.kid. A key we don't have may be a key the issuer rotated in\n * since the keys were cached, so fetch them once more before rejecting the token.\n */\n let jwk = jwks.find(key => key.kid === header.kid);\n if (!jwk) {\n const refreshed = await this.jwksCache.refreshKeys(provider.issuer);\n jwk = refreshed?.find(key => key.kid === header.kid);\n }\n if (!jwk) {\n return null;\n }\n\n if (!verifiedPayload) {\n // Default JWK verification\n verifiedPayload = await verifyJwtUsingJwk(token, jwk);\n }\n\n // Call verifyTokenClaims if provided\n if (provider.verifyTokenClaims) {\n await provider.verifyTokenClaims(verifiedPayload);\n }\n\n return verifiedPayload;\n }\n}\n\nexport const OidcJwtIdentityProvider = JwtIdentityProvider.createImplementation({\n implementation: OidcJwtIdentityProviderImpl,\n dependencies: [[OidcIdentityProvider, { multiple: true }], JwkCache]\n});\n"],"names":["OidcJwtIdentityProviderImpl","oidcIdentityProviders","jwksCache","token","provider","jwt","header","payload","verifiedPayload","providerIdentity","identity","context","undefined","result","jwks","jwk","key","refreshed","verifyJwtUsingJwk","OidcJwtIdentityProvider","JwtIdentityProvider","OidcIdentityProvider","JwkCache"],"mappings":";;AAIA,MAAMA;IACF,YACYC,qBAAuD,EACvDC,SAA6B,CACvC;aAFUD,qBAAqB,GAArBA;aACAC,SAAS,GAATA;IACT;IAEH,aAAaC,KAAqC,EAAW;QACzD,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAACC,CAAAA,WAAYA,SAAS,YAAY,CAACD;IAC7E;IAEA,MAAM,YAAYA,KAAa,EAAEE,GAA4B,EAAgC;QACzF,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAE5B,MAAMD,WAAW,IAAI,CAAC,qBAAqB,CAACG;QAE5C,IAAI,CAACH,UACD,OAAO;QAGX,MAAMI,kBAAkB,MAAM,IAAI,CAAC,WAAW,CAACJ,UAAUD,OAAOG;QAEhE,IAAI,CAACE,iBACD,OAAO;QAIX,MAAMC,mBAAmB,MAAML,SAAS,WAAW,CAACI;QAEpD,MAAME,WAAyB;YAC3B,GAAGD,gBAAgB;YACnB,MAAMA,iBAAiB,IAAI,IAAI;QACnC;QAGA,MAAME,UAAUD,SAAS,OAAO,IAAI;YAAE,iBAAiB;YAAM,iBAAiB;QAAO;QACrF,IAAIC,AAA4BC,WAA5BD,QAAQ,eAAe,EACvBA,QAAQ,eAAe,GAAG;QAE9B,IAAIA,AAA4BC,WAA5BD,QAAQ,eAAe,EACvBA,QAAQ,eAAe,GAAG;QAG9BD,SAAS,OAAO,GAAGC;QAEnB,OAAOD;IACX;IAEQ,sBACJH,OAAuC,EACG;QAC1C,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAACH,CAAAA,WAAYA,SAAS,YAAY,CAACG;IAC7E;IAEA,MAAc,YACVH,QAAwC,EACxCD,KAAa,EACbG,MAAqC,EACvC;QAEE,IAAIE;QACJ,IAAI,AAAgC,cAAhC,OAAOJ,SAAS,WAAW,EAAiB;YAE5C,MAAMS,SAAS,MAAMT,SAAS,WAAW,CAACD;YAC1C,IAAIU,QACA,OAAOA;YAEX,OAAO;QACX;QAKA,MAAMC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACV,SAAS,MAAM;QAMzD,IAAIW,MAAMD,KAAK,IAAI,CAACE,CAAAA,MAAOA,IAAI,GAAG,KAAKV,OAAO,GAAG;QACjD,IAAI,CAACS,KAAK;YACN,MAAME,YAAY,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAACb,SAAS,MAAM;YAClEW,MAAME,WAAW,KAAKD,CAAAA,MAAOA,IAAI,GAAG,KAAKV,OAAO,GAAG;QACvD;QACA,IAAI,CAACS,KACD,OAAO;QAGX,IAAI,CAACP,iBAEDA,kBAAkB,MAAMU,kBAAkBf,OAAOY;QAIrD,IAAIX,SAAS,iBAAiB,EAC1B,MAAMA,SAAS,iBAAiB,CAACI;QAGrC,OAAOA;IACX;AACJ;AAEO,MAAMW,0BAA0BC,oBAAoB,oBAAoB,CAAC;IAC5E,gBAAgBpB;IAChB,cAAc;QAAC;YAACqB;YAAsB;gBAAE,UAAU;YAAK;SAAE;QAAEC;KAAS;AACxE"}
@@ -56,6 +56,12 @@ export declare namespace OidcIdentityProvider {
56
56
  }
57
57
  interface IJwkCache {
58
58
  getKeys(issuer: string): Promise<IJwk[]>;
59
+ /**
60
+ * Fetches the issuer's keys again, for a token signed with a key the cached set doesn't have
61
+ * (the issuer rotated its keys). Returns null when a fetch started less than a minute ago, or
62
+ * when the fetch fails, so tokens with made-up key ids can't make every request call the issuer.
63
+ */
64
+ refreshKeys(issuer: string): Promise<IJwk[] | null>;
59
65
  }
60
66
  /** Cache for JSON Web Keys used in JWT verification. */
61
67
  export declare const JwkCache: import("@webiny/di").Abstraction<IJwkCache>;
@@ -63,4 +69,22 @@ export declare namespace JwkCache {
63
69
  type Interface = IJwkCache;
64
70
  type Jwk = IJwk;
65
71
  }
72
+ export interface IJwksIssuerState {
73
+ keys?: IJwk[];
74
+ fetchedAt?: number;
75
+ lastAttemptAt?: number;
76
+ pending?: Promise<IJwk[]>;
77
+ }
78
+ export interface IJwksStore {
79
+ get(issuer: string): IJwksIssuerState;
80
+ }
81
+ /**
82
+ * Keeps each issuer's JSON Web Keys across requests. Register it in the ROOT container: JwkCache is
83
+ * registered per request, so keys kept there would be fetched again on every request.
84
+ */
85
+ export declare const JwksStore: import("@webiny/di").Abstraction<IJwksStore>;
86
+ export declare namespace JwksStore {
87
+ type Interface = IJwksStore;
88
+ type IssuerState = IJwksIssuerState;
89
+ }
66
90
  export {};
@@ -3,6 +3,7 @@ const IdentityProvider = createAbstraction("IdentityProvider");
3
3
  const JwtIdentityProvider = createAbstraction("JwtIdentityProvider");
4
4
  const OidcIdentityProvider = createAbstraction("OidcIdentityProvider");
5
5
  const JwkCache = createAbstraction("JwkCache");
6
- export { IdentityProvider, JwkCache, JwtIdentityProvider, OidcIdentityProvider };
6
+ const JwksStore = createAbstraction("JwksStore");
7
+ export { IdentityProvider, JwkCache, JwksStore, JwtIdentityProvider, OidcIdentityProvider };
7
8
 
8
9
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"idp/abstractions.js","sources":["../../src/idp/abstractions.ts"],"sourcesContent":["import type { JwtPayload as IJwtPayload, JwtHeader as IJwtHeader } from \"jsonwebtoken\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IdentityData as IIdentityData } from \"~/features/security/IdentityContext/Identity.js\";\nimport type { Jwk as IJwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\n\nexport type IJwt = {\n header: IJwtHeader;\n payload: IJwtPayload;\n};\n\nexport type OptionalExternal<T> = Omit<T, \"external\"> & { external?: boolean };\n\nexport type IProviderIdentityData = Omit<IIdentityData, \"type\" | \"profile\"> & {\n /**\n * Defaults to `admin` it omitted.\n */\n type?: string;\n profile?: OptionalExternal<NonNullable<IIdentityData[\"profile\"]>>;\n};\n\n// Generic Idp Provider\nexport interface IIdentityProvider {\n isApplicable(token: string): boolean;\n getIdentity(token: string): Promise<IProviderIdentityData | null>;\n}\n\n/** Generic identity provider for token-based authentication. */\nexport const IdentityProvider = createAbstraction<IIdentityProvider>(\"IdentityProvider\");\n\nexport namespace IdentityProvider {\n export type Interface = IIdentityProvider;\n export type IdentityData = IProviderIdentityData;\n export type JwtPayload = IJwtPayload;\n}\n\nexport interface IJwtIdentityProvider {\n isApplicable(token: IJwtPayload): boolean;\n getIdentity(token: string, jwt: IJwt): Promise<IProviderIdentityData | null>;\n}\n\n/** JWT-specific identity provider for token validation. */\nexport const JwtIdentityProvider = createAbstraction<IJwtIdentityProvider>(\"JwtIdentityProvider\");\n\nexport namespace JwtIdentityProvider {\n export type Interface = IJwtIdentityProvider;\n export type Jwt = IJwt;\n export type JwtPayload = IJwtPayload;\n export type JwtHeader = IJwtHeader;\n export type IdentityData = IProviderIdentityData;\n}\n\n// OIDC Provider\nexport interface IOidcIdentityProvider {\n issuer: string;\n clientId: string;\n isApplicable(token: IJwtPayload): boolean;\n getIdentity(jwt: IJwtPayload): Promise<IProviderIdentityData>;\n verifyToken?(token: string): Promise<IJwtPayload | undefined>;\n verifyTokenClaims?(token: IJwtPayload): Promise<void>;\n}\n\n/** OIDC-compliant identity provider with issuer validation. */\nexport const OidcIdentityProvider =\n createAbstraction<IOidcIdentityProvider>(\"OidcIdentityProvider\");\n\nexport namespace OidcIdentityProvider {\n export type Interface = IOidcIdentityProvider;\n export type JwtPayload = IJwtPayload;\n export type IdentityData = IProviderIdentityData;\n}\n\ninterface IJwkCache {\n getKeys(issuer: string): Promise<IJwk[]>;\n}\n\n/** Cache for JSON Web Keys used in JWT verification. */\nexport const JwkCache = createAbstraction<IJwkCache>(\"JwkCache\");\nexport namespace JwkCache {\n export type Interface = IJwkCache;\n export type Jwk = IJwk;\n}\n"],"names":["IdentityProvider","createAbstraction","JwtIdentityProvider","OidcIdentityProvider","JwkCache"],"mappings":";AA2BO,MAAMA,mBAAmBC,kBAAqC;AAc9D,MAAMC,sBAAsBD,kBAAwC;AAqBpE,MAAME,uBACTF,kBAAyC;AAatC,MAAMG,WAAWH,kBAA6B"}
1
+ {"version":3,"file":"idp/abstractions.js","sources":["../../src/idp/abstractions.ts"],"sourcesContent":["import type { JwtPayload as IJwtPayload, JwtHeader as IJwtHeader } from \"jsonwebtoken\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IdentityData as IIdentityData } from \"~/features/security/IdentityContext/Identity.js\";\nimport type { Jwk as IJwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\n\nexport type IJwt = {\n header: IJwtHeader;\n payload: IJwtPayload;\n};\n\nexport type OptionalExternal<T> = Omit<T, \"external\"> & { external?: boolean };\n\nexport type IProviderIdentityData = Omit<IIdentityData, \"type\" | \"profile\"> & {\n /**\n * Defaults to `admin` it omitted.\n */\n type?: string;\n profile?: OptionalExternal<NonNullable<IIdentityData[\"profile\"]>>;\n};\n\n// Generic Idp Provider\nexport interface IIdentityProvider {\n isApplicable(token: string): boolean;\n getIdentity(token: string): Promise<IProviderIdentityData | null>;\n}\n\n/** Generic identity provider for token-based authentication. */\nexport const IdentityProvider = createAbstraction<IIdentityProvider>(\"IdentityProvider\");\n\nexport namespace IdentityProvider {\n export type Interface = IIdentityProvider;\n export type IdentityData = IProviderIdentityData;\n export type JwtPayload = IJwtPayload;\n}\n\nexport interface IJwtIdentityProvider {\n isApplicable(token: IJwtPayload): boolean;\n getIdentity(token: string, jwt: IJwt): Promise<IProviderIdentityData | null>;\n}\n\n/** JWT-specific identity provider for token validation. */\nexport const JwtIdentityProvider = createAbstraction<IJwtIdentityProvider>(\"JwtIdentityProvider\");\n\nexport namespace JwtIdentityProvider {\n export type Interface = IJwtIdentityProvider;\n export type Jwt = IJwt;\n export type JwtPayload = IJwtPayload;\n export type JwtHeader = IJwtHeader;\n export type IdentityData = IProviderIdentityData;\n}\n\n// OIDC Provider\nexport interface IOidcIdentityProvider {\n issuer: string;\n clientId: string;\n isApplicable(token: IJwtPayload): boolean;\n getIdentity(jwt: IJwtPayload): Promise<IProviderIdentityData>;\n verifyToken?(token: string): Promise<IJwtPayload | undefined>;\n verifyTokenClaims?(token: IJwtPayload): Promise<void>;\n}\n\n/** OIDC-compliant identity provider with issuer validation. */\nexport const OidcIdentityProvider =\n createAbstraction<IOidcIdentityProvider>(\"OidcIdentityProvider\");\n\nexport namespace OidcIdentityProvider {\n export type Interface = IOidcIdentityProvider;\n export type JwtPayload = IJwtPayload;\n export type IdentityData = IProviderIdentityData;\n}\n\ninterface IJwkCache {\n getKeys(issuer: string): Promise<IJwk[]>;\n /**\n * Fetches the issuer's keys again, for a token signed with a key the cached set doesn't have\n * (the issuer rotated its keys). Returns null when a fetch started less than a minute ago, or\n * when the fetch fails, so tokens with made-up key ids can't make every request call the issuer.\n */\n refreshKeys(issuer: string): Promise<IJwk[] | null>;\n}\n\n/** Cache for JSON Web Keys used in JWT verification. */\nexport const JwkCache = createAbstraction<IJwkCache>(\"JwkCache\");\nexport namespace JwkCache {\n export type Interface = IJwkCache;\n export type Jwk = IJwk;\n}\n\nexport interface IJwksIssuerState {\n keys?: IJwk[];\n // When the keys were last fetched successfully.\n fetchedAt?: number;\n // When a fetch last started, successful or not. Limits how often an unknown key id can refetch.\n lastAttemptAt?: number;\n // The fetch in progress, shared by every request that needs it.\n pending?: Promise<IJwk[]>;\n}\n\nexport interface IJwksStore {\n // Returns the issuer's state, creating it on first use. Callers update it in place.\n get(issuer: string): IJwksIssuerState;\n}\n\n/**\n * Keeps each issuer's JSON Web Keys across requests. Register it in the ROOT container: JwkCache is\n * registered per request, so keys kept there would be fetched again on every request.\n */\nexport const JwksStore = createAbstraction<IJwksStore>(\"JwksStore\");\nexport namespace JwksStore {\n export type Interface = IJwksStore;\n export type IssuerState = IJwksIssuerState;\n}\n"],"names":["IdentityProvider","createAbstraction","JwtIdentityProvider","OidcIdentityProvider","JwkCache","JwksStore"],"mappings":";AA2BO,MAAMA,mBAAmBC,kBAAqC;AAc9D,MAAMC,sBAAsBD,kBAAwC;AAqBpE,MAAME,uBACTF,kBAAyC;AAmBtC,MAAMG,WAAWH,kBAA6B;AAyB9C,MAAMI,YAAYJ,kBAA8B"}
package/idp/feature.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { JwtAuthenticator } from "./JwtAuthenticator.js";
3
- import { JwkCache } from "./abstractions.js";
4
3
  import { JwksCache } from "./JwksCache.js";
5
4
  import { OidcJwtIdentityProvider } from "./OidcJwtIdentityProvider.js";
6
5
  const IdpAuthenticatorFeature = createFeature({
@@ -8,7 +7,7 @@ const IdpAuthenticatorFeature = createFeature({
8
7
  register (container) {
9
8
  container.register(JwtAuthenticator);
10
9
  container.register(OidcJwtIdentityProvider);
11
- container.registerInstance(JwkCache, new JwksCache());
10
+ container.register(JwksCache).inSingletonScope();
12
11
  }
13
12
  });
14
13
  export { IdpAuthenticatorFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"idp/feature.js","sources":["../../src/idp/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { JwtAuthenticator } from \"./JwtAuthenticator.js\";\nimport { JwkCache } from \"./abstractions.js\";\nimport { JwksCache } from \"./JwksCache.js\";\nimport { OidcJwtIdentityProvider } from \"~/idp/OidcJwtIdentityProvider.js\";\n\nexport const IdpAuthenticatorFeature = createFeature({\n name: \"IdpAuthenticator\",\n register(container) {\n container.register(JwtAuthenticator);\n container.register(OidcJwtIdentityProvider);\n container.registerInstance(JwkCache, new JwksCache());\n }\n});\n"],"names":["IdpAuthenticatorFeature","createFeature","container","JwtAuthenticator","OidcJwtIdentityProvider","JwkCache","JwksCache"],"mappings":";;;;;AAMO,MAAMA,0BAA0BC,cAAc;IACjD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,gBAAgB,CAACG,UAAU,IAAIC;IAC7C;AACJ"}
1
+ {"version":3,"file":"idp/feature.js","sources":["../../src/idp/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { JwtAuthenticator } from \"./JwtAuthenticator.js\";\nimport { JwksCache } from \"./JwksCache.js\";\nimport { OidcJwtIdentityProvider } from \"~/idp/OidcJwtIdentityProvider.js\";\n\nexport const IdpAuthenticatorFeature = createFeature({\n name: \"IdpAuthenticator\",\n register(container) {\n container.register(JwtAuthenticator);\n container.register(OidcJwtIdentityProvider);\n /*\n * Per request. The keys outlive it through JwksStore, which belongs in the root container\n * (JwksStoreFeature).\n */\n container.register(JwksCache).inSingletonScope();\n }\n});\n"],"names":["IdpAuthenticatorFeature","createFeature","container","JwtAuthenticator","OidcJwtIdentityProvider","JwksCache"],"mappings":";;;;AAKO,MAAMA,0BAA0BC,cAAc;IACjD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QAKnBF,UAAU,QAAQ,CAACG,WAAW,gBAAgB;IAClD;AACJ"}
package/idp/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { IdentityProvider, OidcIdentityProvider, JwtIdentityProvider } from "./abstractions.js";
2
2
  export type { IdentityData } from "./types.js";
3
+ export { JwksStoreFeature } from "./JwksStoreFeature.js";
package/idp/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { IdentityProvider, JwtIdentityProvider, OidcIdentityProvider } from "./abstractions.js";
2
+ export { JwksStoreFeature } from "./JwksStoreFeature.js";
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { ApiCoreFeature } from "./ApiCoreFeature.js";
2
2
  export { ApiCoreStorageOperationsFactory, registerApiCoreStorageOperations } from "./features/storageOperations/abstractions.js";
3
+ export { RequestStorage } from "./features/requestStorage/index.js";
3
4
  export { WcpLicenseProvider } from "./features/wcp/WcpLicenseProvider.js";
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { ApiCoreFeature } from "./ApiCoreFeature.js";
2
2
  export { ApiCoreStorageOperationsFactory, registerApiCoreStorageOperations } from "./features/storageOperations/abstractions.js";
3
+ export { RequestStorage } from "./features/requestStorage/index.js";
3
4
  export { WcpLicenseProvider } from "./features/wcp/WcpLicenseProvider.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-core",
3
- "version": "6.6.0-alpha.1",
3
+ "version": "6.6.0-alpha.11",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,36 +14,36 @@
14
14
  "./*": "./*"
15
15
  },
16
16
  "dependencies": {
17
- "@ai-sdk/anthropic": "4.0.40",
18
- "@ai-sdk/openai": "4.0.45",
19
- "@webiny/api": "6.6.0-alpha.1",
20
- "@webiny/api-graphql": "6.6.0-alpha.1",
21
- "@webiny/di": "1.1.0",
22
- "@webiny/error": "6.6.0-alpha.1",
23
- "@webiny/feature": "6.6.0-alpha.1",
24
- "@webiny/feature-flags": "6.6.0-alpha.1",
25
- "@webiny/handler": "6.6.0-alpha.1",
26
- "@webiny/utils": "6.6.0-alpha.1",
27
- "@webiny/wcp": "6.6.0-alpha.1",
28
- "ai": "7.0.73",
17
+ "@ai-sdk/anthropic": "4.0.94",
18
+ "@ai-sdk/google": "4.0.109",
19
+ "@ai-sdk/openai": "4.0.106",
20
+ "@openrouter/ai-sdk-provider": "3.1.0",
21
+ "@webiny/api": "6.6.0-alpha.11",
22
+ "@webiny/api-graphql": "6.6.0-alpha.11",
23
+ "@webiny/di": "2.0.0",
24
+ "@webiny/error": "6.6.0-alpha.11",
25
+ "@webiny/event-handler-core": "6.6.0-alpha.11",
26
+ "@webiny/feature": "6.6.0-alpha.11",
27
+ "@webiny/feature-flags": "6.6.0-alpha.11",
28
+ "@webiny/handler": "6.6.0-alpha.11",
29
+ "@webiny/utils": "6.6.0-alpha.11",
30
+ "@webiny/wcp": "6.6.0-alpha.11",
31
+ "ai": "7.0.159",
29
32
  "dataloader": "2.2.3",
30
33
  "graphql": "16.14.2",
31
- "jose": "6.2.9",
34
+ "jose": "6.2.14",
32
35
  "jsonwebtoken": "9.0.3",
33
36
  "lodash": "4.18.1",
34
- "minimatch": "10.2.6",
35
- "pino": "10.3.1",
36
- "pino-lambda": "4.4.1",
37
+ "minimatch": "11.0.3",
37
38
  "slugify": "1.6.9",
38
- "zod": "4.4.3"
39
+ "zod": "4.6.7"
39
40
  },
40
41
  "devDependencies": {
41
42
  "@types/jsonwebtoken": "9.0.10",
42
- "@webiny/build-tools": "6.6.0-alpha.1",
43
- "@webiny/event-handler-core": "6.6.0-alpha.1",
43
+ "@webiny/build-tools": "6.6.0-alpha.11",
44
44
  "rimraf": "6.1.3",
45
45
  "typescript": "7.0.2",
46
- "vitest": "4.1.11"
46
+ "vitest": "5.0.5"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
package/types/users.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ListUsersWhere } from "../features/users/shared/types.js";
1
2
  export interface CreatedBy {
2
3
  id: string;
3
4
  displayName: string | null;
@@ -35,9 +36,7 @@ export interface GetUserParams {
35
36
  };
36
37
  }
37
38
  export interface ListUsersParams {
38
- where?: {
39
- id_in?: string[];
40
- };
39
+ where?: ListUsersWhere;
41
40
  sort?: string[];
42
41
  }
43
42
  export interface StorageOperationsListUsersParams extends ListUsersParams {