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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (452) hide show
  1. package/ApiCoreFeature.d.ts +2 -2
  2. package/ApiCoreFeature.js +35 -5
  3. package/ApiCoreFeature.js.map +1 -1
  4. package/exports/api/tasks.d.ts +1 -0
  5. package/exports/api/tasks.js +1 -1
  6. package/exports/api.d.ts +2 -1
  7. package/exports/api.js +2 -1
  8. package/features/ai/Ai.d.ts +3 -1
  9. package/features/ai/Ai.js +36 -28
  10. package/features/ai/Ai.js.map +1 -1
  11. package/features/ai/AiModelRegistry.d.ts +14 -0
  12. package/features/ai/AiModelRegistry.js +39 -0
  13. package/features/ai/AiModelRegistry.js.map +1 -0
  14. package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
  15. package/features/ai/AiSdkToolHandlerResolver.js +19 -0
  16. package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
  17. package/features/ai/AiSdkTools.d.ts +4 -3
  18. package/features/ai/AiSdkTools.js +11 -9
  19. package/features/ai/AiSdkTools.js.map +1 -1
  20. package/features/ai/AnthropicSdkFactory.js +24 -4
  21. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  22. package/features/ai/DEVELOPERS.md +183 -0
  23. package/features/ai/GoogleSdkFactory.d.ts +10 -0
  24. package/features/ai/GoogleSdkFactory.js +65 -0
  25. package/features/ai/GoogleSdkFactory.js.map +1 -0
  26. package/features/ai/OpenAiSdkFactory.js +67 -11
  27. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  28. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  29. package/features/ai/OpenRouterSdkFactory.js +112 -0
  30. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  31. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  32. package/features/ai/RemoteAiModelCatalog.js +74 -0
  33. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  34. package/features/ai/abstractions.d.ts +102 -7
  35. package/features/ai/abstractions.js +6 -2
  36. package/features/ai/abstractions.js.map +1 -1
  37. package/features/ai/feature.js +10 -0
  38. package/features/ai/feature.js.map +1 -1
  39. package/features/ai/index.d.ts +2 -4
  40. package/features/ai/index.js +1 -1
  41. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  42. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  43. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  44. package/features/dateFormatter/abstractions.d.ts +13 -0
  45. package/features/dateFormatter/abstractions.js +5 -0
  46. package/features/dateFormatter/abstractions.js.map +1 -0
  47. package/features/dateFormatter/feature.d.ts +4 -0
  48. package/features/dateFormatter/feature.js +11 -0
  49. package/features/dateFormatter/feature.js.map +1 -0
  50. package/features/dateFormatter/index.d.ts +3 -0
  51. package/features/dateFormatter/index.js +2 -0
  52. package/features/debugger/Debugger.d.ts +30 -0
  53. package/features/debugger/Debugger.js +142 -0
  54. package/features/debugger/Debugger.js.map +1 -0
  55. package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
  56. package/features/debugger/DebuggerRouteDecorator.js +107 -0
  57. package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
  58. package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
  59. package/features/debugger/GraphQLDebuggerTransport.js +45 -0
  60. package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
  61. package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
  62. package/features/debugger/__tests__/matchNamespace.test.js +68 -0
  63. package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
  64. package/features/debugger/__tests__/serialize.test.d.ts +1 -0
  65. package/features/debugger/__tests__/serialize.test.js +220 -0
  66. package/features/debugger/__tests__/serialize.test.js.map +1 -0
  67. package/features/debugger/abstractions.d.ts +100 -0
  68. package/features/debugger/abstractions.js +6 -0
  69. package/features/debugger/abstractions.js.map +1 -0
  70. package/features/debugger/feature.d.ts +5 -0
  71. package/features/debugger/feature.js +15 -0
  72. package/features/debugger/feature.js.map +1 -0
  73. package/features/debugger/index.d.ts +12 -0
  74. package/features/debugger/index.js +7 -0
  75. package/features/debugger/limits.d.ts +18 -0
  76. package/features/debugger/limits.js +11 -0
  77. package/features/debugger/limits.js.map +1 -0
  78. package/features/debugger/matchNamespace.d.ts +14 -0
  79. package/features/debugger/matchNamespace.js +35 -0
  80. package/features/debugger/matchNamespace.js.map +1 -0
  81. package/features/debugger/parseNamespaceHeader.d.ts +7 -0
  82. package/features/debugger/parseNamespaceHeader.js +16 -0
  83. package/features/debugger/parseNamespaceHeader.js.map +1 -0
  84. package/features/debugger/permissions.d.ts +14 -0
  85. package/features/debugger/permissions.js +8 -0
  86. package/features/debugger/permissions.js.map +1 -0
  87. package/features/debugger/permissionsSchema.d.ts +17 -0
  88. package/features/debugger/permissionsSchema.js +18 -0
  89. package/features/debugger/permissionsSchema.js.map +1 -0
  90. package/features/debugger/serialize.d.ts +11 -0
  91. package/features/debugger/serialize.js +121 -0
  92. package/features/debugger/serialize.js.map +1 -0
  93. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  94. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  95. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  96. package/features/encryption/EncryptionService.d.ts +2 -1
  97. package/features/encryption/EncryptionService.js +11 -4
  98. package/features/encryption/EncryptionService.js.map +1 -1
  99. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  100. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  101. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  102. package/features/encryption/abstractions.d.ts +11 -0
  103. package/features/encryption/abstractions.js +2 -1
  104. package/features/encryption/abstractions.js.map +1 -1
  105. package/features/encryption/index.d.ts +1 -0
  106. package/features/encryption/index.js +1 -0
  107. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  108. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +62 -0
  109. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  110. package/features/hashing/ScryptHasher.d.ts +11 -0
  111. package/features/hashing/ScryptHasher.js +74 -0
  112. package/features/hashing/ScryptHasher.js.map +1 -0
  113. package/features/hashing/abstractions.d.ts +18 -0
  114. package/features/hashing/abstractions.js +5 -0
  115. package/features/hashing/abstractions.js.map +1 -0
  116. package/features/hashing/feature.d.ts +4 -0
  117. package/features/hashing/feature.js +11 -0
  118. package/features/hashing/feature.js.map +1 -0
  119. package/features/hashing/index.d.ts +2 -0
  120. package/features/hashing/index.js +1 -0
  121. package/features/httpClient/HttpClient.d.ts +7 -0
  122. package/features/httpClient/HttpClient.js +72 -0
  123. package/features/httpClient/HttpClient.js.map +1 -0
  124. package/features/httpClient/HttpRequestError.d.ts +10 -0
  125. package/features/httpClient/HttpRequestError.js +13 -0
  126. package/features/httpClient/HttpRequestError.js.map +1 -0
  127. package/features/httpClient/HttpStatusError.d.ts +12 -0
  128. package/features/httpClient/HttpStatusError.js +12 -0
  129. package/features/httpClient/HttpStatusError.js.map +1 -0
  130. package/features/httpClient/abstractions.d.ts +32 -0
  131. package/features/httpClient/abstractions.js +5 -0
  132. package/features/httpClient/abstractions.js.map +1 -0
  133. package/features/httpClient/feature.d.ts +4 -0
  134. package/features/httpClient/feature.js +11 -0
  135. package/features/httpClient/feature.js.map +1 -0
  136. package/features/httpClient/index.d.ts +3 -0
  137. package/features/httpClient/index.js +3 -0
  138. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  139. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  140. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  141. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  142. package/features/keyValueStore/KeyValueStore.js +13 -3
  143. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  144. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  145. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  146. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  147. package/features/keyValueStore/abstractions.d.ts +132 -14
  148. package/features/keyValueStore/abstractions.js.map +1 -1
  149. package/features/keyValueStore/errors.d.ts +29 -0
  150. package/features/keyValueStore/errors.js +49 -1
  151. package/features/keyValueStore/errors.js.map +1 -1
  152. package/features/keyValueStore/index.d.ts +4 -1
  153. package/features/keyValueStore/index.js +1 -1
  154. package/features/publicUrls/NullPublicUrls.d.ts +11 -0
  155. package/features/publicUrls/NullPublicUrls.js +17 -0
  156. package/features/publicUrls/NullPublicUrls.js.map +1 -0
  157. package/features/publicUrls/PublicUrl.d.ts +24 -0
  158. package/features/publicUrls/PublicUrl.js +43 -0
  159. package/features/publicUrls/PublicUrl.js.map +1 -0
  160. package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
  161. package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
  162. package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
  163. package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
  164. package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
  165. package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
  166. package/features/publicUrls/abstractions.d.ts +27 -0
  167. package/features/publicUrls/abstractions.js +5 -0
  168. package/features/publicUrls/abstractions.js.map +1 -0
  169. package/features/publicUrls/feature.d.ts +8 -0
  170. package/features/publicUrls/feature.js +11 -0
  171. package/features/publicUrls/feature.js.map +1 -0
  172. package/features/publicUrls/index.d.ts +3 -0
  173. package/features/publicUrls/index.js +3 -0
  174. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  175. package/features/requestContext/RawAssumePermissions.js +19 -0
  176. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  177. package/features/requestContext/RawAuthToken.d.ts +14 -0
  178. package/features/requestContext/RawAuthToken.js +19 -0
  179. package/features/requestContext/RawAuthToken.js.map +1 -0
  180. package/features/requestContext/RawTenantId.d.ts +14 -0
  181. package/features/requestContext/RawTenantId.js +19 -0
  182. package/features/requestContext/RawTenantId.js.map +1 -0
  183. package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
  184. package/features/requestContext/RequestIdentityLoader.js +26 -0
  185. package/features/requestContext/RequestIdentityLoader.js.map +1 -0
  186. package/features/requestContext/RequestTenantLoader.d.ts +18 -0
  187. package/features/requestContext/RequestTenantLoader.js +52 -0
  188. package/features/requestContext/RequestTenantLoader.js.map +1 -0
  189. package/features/requestContext/abstractions.d.ts +75 -0
  190. package/features/requestContext/abstractions.js +9 -0
  191. package/features/requestContext/abstractions.js.map +1 -0
  192. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  193. package/features/requestContext/extractAssumePermissions.js +32 -0
  194. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  195. package/features/requestContext/feature.d.ts +12 -0
  196. package/features/requestContext/feature.js +19 -0
  197. package/features/requestContext/feature.js.map +1 -0
  198. package/features/requestContext/index.d.ts +4 -0
  199. package/features/requestContext/index.js +3 -0
  200. package/features/security/IdentityContext/IdentityContext.d.ts +4 -3
  201. package/features/security/IdentityContext/IdentityContext.js +9 -6
  202. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  203. package/features/security/IdentityContext/abstractions.d.ts +5 -0
  204. package/features/security/IdentityContext/abstractions.js.map +1 -1
  205. package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
  206. package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
  207. package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
  208. package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
  209. package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
  210. package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
  211. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  212. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  213. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -1
  214. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -1
  215. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  216. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  217. package/features/security/apiKeys/feature.js +4 -0
  218. package/features/security/apiKeys/feature.js.map +1 -1
  219. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  220. package/features/security/apiKeys/shared/schemas.js +2 -2
  221. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  222. package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +12 -3
  223. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +31 -18
  224. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
  225. package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
  226. package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
  227. package/features/security/authorization/AuthorizationContext/feature.js +6 -1
  228. package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
  229. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  230. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  231. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  232. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
  233. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  234. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  235. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  236. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  237. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  238. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  239. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  240. package/features/security/roles/CreateRole/schema.js +1 -1
  241. package/features/security/roles/CreateRole/schema.js.map +1 -1
  242. package/features/security/roles/Installer/RolesInstaller.js +1 -0
  243. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  244. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  245. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  246. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  247. package/features/security/roles/UpdateRole/schema.js +1 -1
  248. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  249. package/features/security/shared/description.d.ts +4 -0
  250. package/features/security/shared/description.js +7 -0
  251. package/features/security/shared/description.js.map +1 -0
  252. package/features/security/shared/index.d.ts +1 -0
  253. package/features/security/shared/index.js +1 -0
  254. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  255. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  256. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  257. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  258. package/features/security/teams/CreateTeam/schema.js +1 -1
  259. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  260. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  261. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  262. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  263. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  264. package/features/security/teams/UpdateTeam/schema.js +1 -1
  265. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  266. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  267. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  268. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  269. package/features/slugify/DefaultSlugify.d.ts +8 -0
  270. package/features/slugify/DefaultSlugify.js +20 -0
  271. package/features/slugify/DefaultSlugify.js.map +1 -0
  272. package/features/slugify/abstractions.d.ts +12 -0
  273. package/features/slugify/abstractions.js +5 -0
  274. package/features/slugify/abstractions.js.map +1 -0
  275. package/features/slugify/feature.d.ts +4 -0
  276. package/features/slugify/feature.js +11 -0
  277. package/features/slugify/feature.js.map +1 -0
  278. package/features/slugify/index.d.ts +3 -0
  279. package/features/slugify/index.js +2 -0
  280. package/features/storageOperations/abstractions.d.ts +21 -0
  281. package/features/storageOperations/abstractions.js +10 -0
  282. package/features/storageOperations/abstractions.js.map +1 -0
  283. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  284. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  285. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  286. package/features/stringFormatter/abstractions.d.ts +11 -0
  287. package/features/stringFormatter/abstractions.js +5 -0
  288. package/features/stringFormatter/abstractions.js.map +1 -0
  289. package/features/stringFormatter/feature.d.ts +4 -0
  290. package/features/stringFormatter/feature.js +13 -0
  291. package/features/stringFormatter/feature.js.map +1 -0
  292. package/features/stringFormatter/index.d.ts +3 -0
  293. package/features/stringFormatter/index.js +2 -0
  294. package/features/task/TaskDefinition/abstractions.d.ts +69 -4
  295. package/features/task/TaskDefinition/abstractions.js +2 -1
  296. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  297. package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
  298. package/features/tenancy/TenantContext/TenantContext.js +13 -8
  299. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  300. package/features/users/shared/types.d.ts +9 -7
  301. package/features/wcp/WcpContext/WcpContext.d.ts +11 -5
  302. package/features/wcp/WcpContext/WcpContext.js +26 -2
  303. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  304. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +10 -69
  305. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +66 -35
  306. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  307. package/features/wcp/WcpContext/feature.d.ts +1 -2
  308. package/features/wcp/WcpContext/feature.js +2 -2
  309. package/features/wcp/WcpContext/feature.js.map +1 -1
  310. package/features/wcp/WcpContext/index.d.ts +0 -1
  311. package/features/wcp/WcpContext/types.d.ts +0 -4
  312. package/features/wcp/WcpFeature.d.ts +1 -1
  313. package/features/wcp/WcpFeature.js +7 -2
  314. package/features/wcp/WcpFeature.js.map +1 -1
  315. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  316. package/features/wcp/WcpLicenseLoader.js +58 -0
  317. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  318. package/features/wcp/WcpLicenseProvider.d.ts +21 -0
  319. package/features/wcp/WcpLicenseProvider.js +14 -0
  320. package/features/wcp/WcpLicenseProvider.js.map +1 -0
  321. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  322. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  323. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  324. package/graphql/ApiCoreSchemaFactory.d.ts +16 -0
  325. package/graphql/ApiCoreSchemaFactory.js +58 -0
  326. package/graphql/ApiCoreSchemaFactory.js.map +1 -0
  327. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
  328. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
  329. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  330. package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
  331. package/graphql/security/NotAuthorizedResponse.js +1 -1
  332. package/graphql/security/NotAuthorizedResponse.js.map +1 -1
  333. package/graphql/security/SecuritySchemaFactory.d.ts +15 -0
  334. package/graphql/security/SecuritySchemaFactory.js +27 -0
  335. package/graphql/security/SecuritySchemaFactory.js.map +1 -0
  336. package/graphql/security/addApiKeySchema.d.ts +2 -0
  337. package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
  338. package/graphql/security/addApiKeySchema.js.map +1 -0
  339. package/graphql/security/addIdentitySchema.d.ts +2 -0
  340. package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
  341. package/graphql/security/addIdentitySchema.js.map +1 -0
  342. package/graphql/security/addRoleSchema.d.ts +2 -0
  343. package/graphql/security/addRoleSchema.js +137 -0
  344. package/graphql/security/addRoleSchema.js.map +1 -0
  345. package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
  346. package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
  347. package/graphql/security/addSecurityBaseSchema.js.map +1 -0
  348. package/graphql/security/addTeamSchema.d.ts +2 -0
  349. package/graphql/security/addTeamSchema.js +157 -0
  350. package/graphql/security/addTeamSchema.js.map +1 -0
  351. package/graphql/system/SystemSchemaFactory.d.ts +10 -0
  352. package/graphql/system/SystemSchemaFactory.js +70 -0
  353. package/graphql/system/SystemSchemaFactory.js.map +1 -0
  354. package/graphql/users/UsersSchemaFactory.d.ts +10 -0
  355. package/graphql/users/UsersSchemaFactory.js +195 -0
  356. package/graphql/users/UsersSchemaFactory.js.map +1 -0
  357. package/graphql/wcp/WcpSchemaFactory.d.ts +10 -0
  358. package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +31 -18
  359. package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
  360. package/idp/JwksCache.d.ts +14 -3
  361. package/idp/JwksCache.js +97 -17
  362. package/idp/JwksCache.js.map +1 -1
  363. package/idp/JwksStoreFeature.d.ts +8 -0
  364. package/idp/JwksStoreFeature.js +11 -0
  365. package/idp/JwksStoreFeature.js.map +1 -0
  366. package/idp/MemoryJwksStore.d.ts +14 -0
  367. package/idp/MemoryJwksStore.js +21 -0
  368. package/idp/MemoryJwksStore.js.map +1 -0
  369. package/idp/OidcJwtIdentityProvider.js +5 -1
  370. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  371. package/idp/abstractions.d.ts +24 -0
  372. package/idp/abstractions.js +2 -1
  373. package/idp/abstractions.js.map +1 -1
  374. package/idp/feature.js +1 -2
  375. package/idp/feature.js.map +1 -1
  376. package/idp/index.d.ts +1 -0
  377. package/idp/index.js +1 -0
  378. package/index.d.ts +3 -1
  379. package/index.js +3 -1
  380. package/package.json +22 -21
  381. package/testing/environment.d.ts +14 -0
  382. package/testing/environment.js +18 -0
  383. package/testing/environment.js.map +1 -0
  384. package/types/core.d.ts +17 -5
  385. package/types/security.d.ts +0 -6
  386. package/types/tenancy.d.ts +0 -17
  387. package/types/users.d.ts +2 -16
  388. package/createApiCore.d.ts +0 -7
  389. package/createApiCore.js +0 -26
  390. package/createApiCore.js.map +0 -1
  391. package/graphql/security/apiKey.gql.d.ts +0 -4
  392. package/graphql/security/apiKey.gql.js.map +0 -1
  393. package/graphql/security/base.gql.d.ts +0 -4
  394. package/graphql/security/base.gql.js.map +0 -1
  395. package/graphql/security/identity.gql.d.ts +0 -4
  396. package/graphql/security/identity.gql.js.map +0 -1
  397. package/graphql/security/index.d.ts +0 -1
  398. package/graphql/security/index.js +0 -15
  399. package/graphql/security/index.js.map +0 -1
  400. package/graphql/security/role.gql.d.ts +0 -4
  401. package/graphql/security/role.gql.js +0 -106
  402. package/graphql/security/role.gql.js.map +0 -1
  403. package/graphql/security/team.gql.d.ts +0 -4
  404. package/graphql/security/team.gql.js +0 -119
  405. package/graphql/security/team.gql.js.map +0 -1
  406. package/graphql/system/createSystemGraphQL.d.ts +0 -2
  407. package/graphql/system/createSystemGraphQL.js +0 -54
  408. package/graphql/system/createSystemGraphQL.js.map +0 -1
  409. package/graphql/users/user.gql.d.ts +0 -3
  410. package/graphql/users/user.gql.js +0 -167
  411. package/graphql/users/user.gql.js.map +0 -1
  412. package/graphql/wcp/graphql.d.ts +0 -2
  413. package/graphql/wcp/graphql.js.map +0 -1
  414. package/legacy/security/LegacyContext.d.ts +0 -36
  415. package/legacy/security/LegacyContext.js +0 -152
  416. package/legacy/security/LegacyContext.js.map +0 -1
  417. package/legacy/security/createSecurityContext.d.ts +0 -3
  418. package/legacy/security/createSecurityContext.js +0 -10
  419. package/legacy/security/createSecurityContext.js.map +0 -1
  420. package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
  421. package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
  422. package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
  423. package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
  424. package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
  425. package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
  426. package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
  427. package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
  428. package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
  429. package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
  430. package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
  431. package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
  432. package/legacy/security/plugins/secureHeaders.d.ts +0 -1
  433. package/legacy/security/plugins/secureHeaders.js +0 -30
  434. package/legacy/security/plugins/secureHeaders.js.map +0 -1
  435. package/legacy/tenancy/LegacyContext.d.ts +0 -15
  436. package/legacy/tenancy/LegacyContext.js +0 -57
  437. package/legacy/tenancy/LegacyContext.js.map +0 -1
  438. package/legacy/tenancy/createTenancyContext.d.ts +0 -3
  439. package/legacy/tenancy/createTenancyContext.js +0 -31
  440. package/legacy/tenancy/createTenancyContext.js.map +0 -1
  441. package/legacy/users/LegacyContext.d.ts +0 -13
  442. package/legacy/users/LegacyContext.js +0 -55
  443. package/legacy/users/LegacyContext.js.map +0 -1
  444. package/legacy/users/createAdminUsersContext.d.ts +0 -3
  445. package/legacy/users/createAdminUsersContext.js +0 -12
  446. package/legacy/users/createAdminUsersContext.js.map +0 -1
  447. package/legacy/wcp/LegacyWcpContext.d.ts +0 -38
  448. package/legacy/wcp/LegacyWcpContext.js +0 -99
  449. package/legacy/wcp/LegacyWcpContext.js.map +0 -1
  450. package/legacy/wcp/context.d.ts +0 -5
  451. package/legacy/wcp/context.js +0 -46
  452. package/legacy/wcp/context.js.map +0 -1
@@ -1,167 +0,0 @@
1
- import { ErrorResponse, ListErrorResponse, ListResponse, NotFoundResponse, Response } from "@webiny/handler-graphql/responses.js";
2
- import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js";
3
- import { GetUserUseCase } from "../../features/users/GetUser/index.js";
4
- import NotAuthorizedResponse from "../security/NotAuthorizedResponse.js";
5
- import { ListUsersUseCase } from "../../features/users/ListUsers/index.js";
6
- const emptyResolver = ()=>({});
7
- const createUsersGraphQL = ()=>[
8
- new GraphQLSchemaPlugin({
9
- typeDefs: `
10
- type AdminUsersQuery {
11
- _empty: String
12
- }
13
-
14
- type AdminUsersMutation {
15
- _empty: String
16
- }
17
-
18
- extend type Query {
19
- adminUsers: AdminUsersQuery
20
- }
21
-
22
- extend type Mutation {
23
- adminUsers: AdminUsersMutation
24
- }
25
-
26
- type AdminUsersCreatedBy {
27
- id: ID
28
- displayName: String
29
- }
30
-
31
- type AdminUsersError {
32
- code: String
33
- message: String
34
- data: JSON
35
- stack: String
36
- }
37
-
38
- type AdminUsersBooleanResponse {
39
- data: Boolean
40
- error: AdminUsersError
41
- }
42
- `,
43
- resolvers: {
44
- Query: {
45
- adminUsers: emptyResolver
46
- },
47
- Mutation: {
48
- adminUsers: emptyResolver
49
- }
50
- }
51
- }),
52
- new GraphQLSchemaPlugin({
53
- typeDefs: `
54
- type AdminUser {
55
- id: ID!
56
- displayName: String!
57
- email: String!
58
-
59
- roles: [SecurityRole]
60
- firstName: String
61
- lastName: String
62
- avatar: JSON
63
- external: Boolean
64
- createdOn: DateTime
65
- }
66
-
67
- type AdminUsersResponse {
68
- data: AdminUser
69
- error: AdminUsersError
70
- }
71
-
72
- type AdminUsersListResponse {
73
- data: [AdminUser]
74
- error: AdminUsersError
75
- }
76
-
77
- input AdminUsersGetUserWhereInput {
78
- id: ID
79
- email: String
80
- }
81
-
82
- extend type AdminUsersQuery {
83
- getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse
84
- getCurrentUser: AdminUsersResponse
85
- listUsers: AdminUsersListResponse
86
- }
87
- `,
88
- resolvers: {
89
- AdminUser: {
90
- roles (user, _, context) {
91
- if (!user.roles) return null;
92
- return context.security.listRoles({
93
- where: {
94
- id_in: user.roles
95
- }
96
- });
97
- }
98
- },
99
- AdminUsersQuery: {
100
- getUser: async (_, { where }, context)=>{
101
- const getUser = context.container.resolve(GetUserUseCase);
102
- const userResult = await getUser.execute({
103
- id: where.id,
104
- email: where.email
105
- });
106
- if (userResult.isFail()) {
107
- const error = userResult.error;
108
- if ("AdminUser/NotFound" === error.code) return new NotFoundResponse(`User "${JSON.stringify(where)}" was not found!`);
109
- return new ErrorResponse({
110
- message: error.message,
111
- code: error.code,
112
- data: error.data
113
- });
114
- }
115
- return new Response(userResult.value);
116
- },
117
- getCurrentUser: async (_, __, context)=>{
118
- const identity = context.security.getIdentity();
119
- if (!identity.isAdmin()) throw new NotAuthorizedResponse();
120
- const getUser = context.container.resolve(GetUserUseCase);
121
- const userResponse = await context.security.withoutAuthorization(async ()=>await getUser.execute({
122
- id: identity.id
123
- }));
124
- if (userResponse.isFail()) {
125
- const error = userResponse.error;
126
- if ("AdminUser/NotFound" === error.code) return new NotFoundResponse(`User with ID ${identity.id} was not found!`);
127
- return new ErrorResponse({
128
- message: error.message,
129
- code: error.code,
130
- data: error.data
131
- });
132
- }
133
- return new Response(userResponse.value);
134
- },
135
- listUsers: async (_, __, context)=>{
136
- const listUsers = context.container.resolve(ListUsersUseCase);
137
- const users = await listUsers.execute();
138
- if (users.isFail()) return new ListErrorResponse(users.error);
139
- return new ListResponse(users.value);
140
- }
141
- }
142
- }
143
- }),
144
- new GraphQLSchemaPlugin({
145
- typeDefs: `
146
- extend type AdminUser {
147
- teams: [SecurityTeam]
148
- }
149
- `,
150
- resolvers: {
151
- AdminUser: {
152
- teams (user, _, context) {
153
- const hasTeams = Array.isArray(user.teams) && user.teams.length > 0;
154
- if (!hasTeams) return [];
155
- return context.security.listTeams({
156
- where: {
157
- id_in: user.teams
158
- }
159
- });
160
- }
161
- }
162
- }
163
- })
164
- ].filter(Boolean);
165
- export { createUsersGraphQL };
166
-
167
- //# sourceMappingURL=user.gql.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graphql/users/user.gql.js","sources":["../../../src/graphql/users/user.gql.ts"],"sourcesContent":["import {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n NotFoundResponse,\n Response\n} from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { 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\";\n\nconst emptyResolver = () => ({});\n\nexport const createUsersGraphQL = () => {\n return [\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* 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 resolvers: {\n Query: {\n adminUsers: emptyResolver\n },\n Mutation: {\n adminUsers: emptyResolver\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\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 resolvers: {\n AdminUser: {\n roles(user: AdminUser, _, context) {\n if (!user.roles) {\n return null;\n }\n\n return context.security.listRoles({ where: { id_in: user.roles } });\n }\n },\n AdminUsersQuery: {\n getUser: async (_, { where }: any, context) => {\n const getUser = context.container.resolve(GetUserUseCase);\n\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 getCurrentUser: async (_, __, context) => {\n const identity = context.security.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\n const getUser = context.container.resolve(GetUserUseCase);\n\n const userResponse = await context.security.withoutAuthorization(\n async () => {\n // Get user record using the identity ID.\n return await getUser.execute({ id: identity.id });\n }\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 listUsers: async (_, __, context) => {\n const listUsers = context.container.resolve(ListUsersUseCase);\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 }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n extend type AdminUser {\n teams: [SecurityTeam]\n }\n `,\n resolvers: {\n AdminUser: {\n teams(user: AdminUser, _, context) {\n const hasTeams = Array.isArray(user.teams) && user.teams.length > 0;\n if (!hasTeams) {\n return [];\n }\n\n return context.security.listTeams({ where: { id_in: user.teams } });\n }\n }\n }\n })\n ].filter(Boolean);\n};\n"],"names":["emptyResolver","createUsersGraphQL","GraphQLSchemaPlugin","user","_","context","where","getUser","GetUserUseCase","userResult","error","NotFoundResponse","JSON","ErrorResponse","Response","__","identity","NotAuthorizedResponse","userResponse","listUsers","ListUsersUseCase","users","ListErrorResponse","ListResponse","hasTeams","Array","Boolean"],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/index.js";
2
- export declare const createWcpGraphQL: () => GraphQLSchemaPlugin<import("@webiny/api/types").Context>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"graphql/wcp/graphql.js","sources":["../../../src/graphql/wcp/graphql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/index.js\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql/responses.js\";\nimport { WcpContext } from \"~/features/wcp/WcpContext/index.js\";\n\nconst emptyResolver = () => ({});\n\nexport const createWcpGraphQL = () => {\n return new GraphQLSchemaPlugin({\n typeDefs: /* 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 }\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 resolvers: {\n Query: {\n wcp: emptyResolver\n },\n WcpQuery: {\n getProject: async (_, __, context) => {\n try {\n const wcpContext = context.container.resolve(WcpContext);\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 });\n};\n"],"names":["emptyResolver","createWcpGraphQL","GraphQLSchemaPlugin","_","__","context","wcpContext","WcpContext","project","Error","Response","e","ErrorResponse"],"mappings":";;;AAIA,MAAMA,gBAAgB,IAAO,EAAC;AAEvB,MAAMC,mBAAmB,IACrB,IAAIC,oBAAoB;QAC3B,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAuDzB,CAAC;QACD,WAAW;YACP,OAAO;gBACH,KAAKF;YACT;YACA,UAAU;gBACN,YAAY,OAAOG,GAAGC,IAAIC;oBACtB,IAAI;wBACA,MAAMC,aAAaD,QAAQ,SAAS,CAAC,OAAO,CAACE;wBAC7C,MAAMC,UAAUF,WAAW,0BAA0B;wBAErD,IAAI,CAACE,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;YACJ;QACJ;IACJ"}
@@ -1,36 +0,0 @@
1
- import { type Container } from "@webiny/di";
2
- import type { SecurityIdentity, SecurityPermission } from "../../types/security.js";
3
- import { Authenticator } from "../../features/security/authentication/Authenticator/index.js";
4
- /**
5
- * Legacy bridge that implements the old Security interface.
6
- * As we implement each phase, we'll replace forwarding with delegation.
7
- */
8
- export declare class LegacyContext {
9
- private container;
10
- constructor(container: Container);
11
- private get identityContext();
12
- private get authenticationContext();
13
- addAuthenticator(authenticator: Authenticator.Interface["authenticate"]): void;
14
- authenticate(token: string): Promise<void>;
15
- getIdentity(): SecurityIdentity;
16
- setIdentity(identity: SecurityIdentity): void;
17
- getToken(): string | undefined;
18
- isAuthorizationEnabled(): boolean;
19
- withoutAuthorization<T = any>(cb: () => Promise<T>): Promise<T>;
20
- withIdentity<T = any>(identity: SecurityIdentity | undefined, cb: () => Promise<T>): Promise<T>;
21
- getPermission<TPermission extends SecurityPermission = SecurityPermission>(permission: string): Promise<TPermission | null>;
22
- getPermissions<TPermission extends SecurityPermission = SecurityPermission>(permission: string): Promise<TPermission[]>;
23
- listPermissions(): Promise<SecurityPermission[]>;
24
- hasFullAccess(): Promise<boolean>;
25
- getRole(params: any): Promise<import("~/types/security.js").Role>;
26
- listRoles(params?: any): Promise<import("~/types/security.js").Role[]>;
27
- createRole(input: any): Promise<import("~/types/security.js").Role>;
28
- updateRole(id: string, input: any): Promise<import("~/types/security.js").Role>;
29
- deleteRole(id: string): Promise<void>;
30
- addAuthorizer(authorizer: any): void;
31
- getTeam(params: any): Promise<import("~/types/security.js").Team>;
32
- listTeams(params?: any): Promise<import("~/types/security.js").Team[]>;
33
- createTeam(input: any): Promise<import("~/types/security.js").Team>;
34
- updateTeam(id: string, input: any): Promise<import("~/types/security.js").Team>;
35
- deleteTeam(id: string): Promise<void>;
36
- }
@@ -1,152 +0,0 @@
1
- import { AuthenticationContext } from "../../features/security/authentication/AuthenticationContext/index.js";
2
- import { Authenticator } from "../../features/security/authentication/Authenticator/index.js";
3
- import { Authorizer } from "../../features/security/authorization/Authorizer/abstractions.js";
4
- import { AuthenticatedIdentity, IdentityContext } from "../../features/security/IdentityContext/index.js";
5
- import { GetRoleUseCase } from "../../features/security/roles/GetRole/index.js";
6
- import { ListRolesUseCase } from "../../features/security/roles/ListRoles/index.js";
7
- import { CreateRoleUseCase } from "../../features/security/roles/CreateRole/index.js";
8
- import { UpdateRoleUseCase } from "../../features/security/roles/UpdateRole/index.js";
9
- import { DeleteRoleUseCase } from "../../features/security/roles/DeleteRole/index.js";
10
- import { GetTeamUseCase } from "../../features/security/teams/GetTeam/index.js";
11
- import { ListTeamsUseCase } from "../../features/security/teams/ListTeams/index.js";
12
- import { CreateTeam } from "../../features/security/teams/CreateTeam/index.js";
13
- import { UpdateTeam } from "../../features/security/teams/UpdateTeam/index.js";
14
- import { DeleteTeam } from "../../features/security/teams/DeleteTeam/index.js";
15
- class LegacyContext {
16
- constructor(container){
17
- this.container = container;
18
- }
19
- get identityContext() {
20
- return this.container.resolve(IdentityContext);
21
- }
22
- get authenticationContext() {
23
- return this.container.resolve(AuthenticationContext);
24
- }
25
- addAuthenticator(authenticator) {
26
- this.container.registerFactory(Authenticator, ()=>({
27
- authenticate (token) {
28
- return authenticator(token);
29
- }
30
- }));
31
- }
32
- async authenticate(token) {
33
- const identity = await this.authenticationContext.authenticate(token);
34
- this.identityContext.setIdentity(identity);
35
- }
36
- getIdentity() {
37
- const identity = this.identityContext.getIdentity();
38
- if (identity.isAnonymous()) return;
39
- return identity;
40
- }
41
- setIdentity(identity) {
42
- if (!identity) return void this.identityContext.setIdentity(void 0);
43
- const { id, displayName, type, ...rest } = identity;
44
- const authenticatedIdentity = new AuthenticatedIdentity({
45
- id,
46
- displayName,
47
- type,
48
- ...rest
49
- });
50
- this.identityContext.setIdentity(authenticatedIdentity);
51
- }
52
- getToken() {
53
- return this.authenticationContext.getAuthToken();
54
- }
55
- isAuthorizationEnabled() {
56
- return this.identityContext.isAuthorizationEnabled();
57
- }
58
- withoutAuthorization(cb) {
59
- return this.identityContext.withoutAuthorization(cb);
60
- }
61
- withIdentity(identity, cb) {
62
- if (!identity) return this.identityContext.withIdentity(void 0, cb);
63
- const { id, displayName, type, ...rest } = identity;
64
- const authenticatedIdentity = new AuthenticatedIdentity({
65
- id,
66
- displayName,
67
- type,
68
- ...rest
69
- });
70
- return this.identityContext.withIdentity(authenticatedIdentity, cb);
71
- }
72
- async getPermission(permission) {
73
- return this.identityContext.getPermission(permission);
74
- }
75
- async getPermissions(permission) {
76
- return this.identityContext.getPermissions(permission);
77
- }
78
- async listPermissions() {
79
- return this.identityContext.listPermissions();
80
- }
81
- async hasFullAccess() {
82
- return this.identityContext.hasFullAccess();
83
- }
84
- async getRole(params) {
85
- const useCase = this.container.resolve(GetRoleUseCase);
86
- const result = await useCase.execute(params.where);
87
- if (result.isFail()) throw result.error;
88
- return result.value;
89
- }
90
- async listRoles(params) {
91
- const useCase = this.container.resolve(ListRolesUseCase);
92
- const result = await useCase.execute(params);
93
- if (result.isFail()) throw result.error;
94
- return result.value;
95
- }
96
- async createRole(input) {
97
- const useCase = this.container.resolve(CreateRoleUseCase);
98
- const result = await useCase.execute(input);
99
- if (result.isFail()) throw result.error;
100
- return result.value;
101
- }
102
- async updateRole(id, input) {
103
- const useCase = this.container.resolve(UpdateRoleUseCase);
104
- const result = await useCase.execute(id, input);
105
- if (result.isFail()) throw result.error;
106
- return result.value;
107
- }
108
- async deleteRole(id) {
109
- const useCase = this.container.resolve(DeleteRoleUseCase);
110
- const result = await useCase.execute(id);
111
- if (result.isFail()) throw result.error;
112
- }
113
- addAuthorizer(authorizer) {
114
- this.container.registerFactory(Authorizer, ()=>({
115
- authorize () {
116
- return authorizer();
117
- }
118
- }));
119
- }
120
- async getTeam(params) {
121
- const useCase = this.container.resolve(GetTeamUseCase);
122
- const result = await useCase.execute(params.where);
123
- if (result.isFail()) throw result.error;
124
- return result.value;
125
- }
126
- async listTeams(params) {
127
- const useCase = this.container.resolve(ListTeamsUseCase);
128
- const result = await useCase.execute(params);
129
- if (result.isFail()) throw result.error;
130
- return result.value;
131
- }
132
- async createTeam(input) {
133
- const useCase = this.container.resolve(CreateTeam);
134
- const result = await useCase.execute(input);
135
- if (result.isFail()) throw result.error;
136
- return result.value;
137
- }
138
- async updateTeam(id, input) {
139
- const useCase = this.container.resolve(UpdateTeam);
140
- const result = await useCase.execute(id, input);
141
- if (result.isFail()) throw result.error;
142
- return result.value;
143
- }
144
- async deleteTeam(id) {
145
- const useCase = this.container.resolve(DeleteTeam);
146
- const result = await useCase.execute(id);
147
- if (result.isFail()) throw result.error;
148
- }
149
- }
150
- export { LegacyContext };
151
-
152
- //# sourceMappingURL=LegacyContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy/security/LegacyContext.js","sources":["../../../src/legacy/security/LegacyContext.ts"],"sourcesContent":["import { type Container } from \"@webiny/di\";\nimport type { SecurityIdentity, SecurityPermission } from \"~/types/security.js\";\nimport { AuthenticationContext } from \"~/features/security/authentication/AuthenticationContext/index.js\";\nimport { Authenticator } from \"~/features/security/authentication/Authenticator/index.js\";\nimport { Authorizer } from \"~/features/security/authorization/Authorizer/abstractions.js\";\nimport {\n AuthenticatedIdentity,\n IdentityContext,\n IdentityData\n} from \"~/features/security/IdentityContext/index.js\";\nimport { GetRoleUseCase } from \"~/features/security/roles/GetRole/index.js\";\nimport { ListRolesUseCase } from \"~/features/security/roles/ListRoles/index.js\";\nimport { CreateRoleUseCase } from \"~/features/security/roles/CreateRole/index.js\";\nimport { UpdateRoleUseCase } from \"~/features/security/roles/UpdateRole/index.js\";\nimport { DeleteRoleUseCase } from \"~/features/security/roles/DeleteRole/index.js\";\nimport { GetTeamUseCase } from \"~/features/security/teams/GetTeam/index.js\";\nimport { ListTeamsUseCase } from \"~/features/security/teams/ListTeams/index.js\";\nimport { CreateTeam } from \"~/features/security/teams/CreateTeam/index.js\";\nimport { UpdateTeam } from \"~/features/security/teams/UpdateTeam/index.js\";\nimport { DeleteTeam } from \"~/features/security/teams/DeleteTeam/index.js\";\n\n/**\n * Legacy bridge that implements the old Security interface.\n * As we implement each phase, we'll replace forwarding with delegation.\n */\nexport class LegacyContext {\n constructor(private container: Container) {}\n\n private get identityContext() {\n return this.container.resolve(IdentityContext);\n }\n\n private get authenticationContext() {\n return this.container.resolve(AuthenticationContext);\n }\n\n addAuthenticator(authenticator: Authenticator.Interface[\"authenticate\"]): void {\n this.container.registerFactory(Authenticator, () => {\n return {\n authenticate(token: string): Promise<IdentityData | null> {\n return authenticator(token);\n }\n };\n });\n }\n\n async authenticate(token: string): Promise<void> {\n // Authenticate using new context\n const identity = await this.authenticationContext.authenticate(token);\n\n // Set identity in IdentityContext\n this.identityContext.setIdentity(identity);\n }\n\n getIdentity(): SecurityIdentity {\n const identity = this.identityContext.getIdentity();\n\n // Convert our Identity class to old SecurityIdentity format\n if (identity.isAnonymous()) {\n return undefined as any;\n }\n\n return identity;\n }\n\n setIdentity(identity: SecurityIdentity): void {\n if (!identity) {\n this.identityContext.setIdentity(undefined);\n return;\n }\n\n // Wrap old identity format in AuthenticatedIdentity\n const { id, displayName, type, ...rest } = identity;\n const authenticatedIdentity = new AuthenticatedIdentity({\n id,\n displayName,\n type,\n ...rest\n });\n\n this.identityContext.setIdentity(authenticatedIdentity);\n }\n\n getToken() {\n return this.authenticationContext.getAuthToken();\n }\n\n isAuthorizationEnabled(): boolean {\n return this.identityContext.isAuthorizationEnabled();\n }\n\n withoutAuthorization<T = any>(cb: () => Promise<T>): Promise<T> {\n return this.identityContext.withoutAuthorization(cb);\n }\n\n withIdentity<T = any>(\n identity: SecurityIdentity | undefined,\n cb: () => Promise<T>\n ): Promise<T> {\n if (!identity) {\n return this.identityContext.withIdentity(undefined, cb);\n }\n\n const { id, displayName, type, ...rest } = identity;\n const authenticatedIdentity = new AuthenticatedIdentity({\n id,\n displayName,\n type,\n ...rest\n });\n\n return this.identityContext.withIdentity(authenticatedIdentity, cb);\n }\n\n async getPermission<TPermission extends SecurityPermission = SecurityPermission>(\n permission: string\n ) {\n return this.identityContext.getPermission<TPermission>(permission);\n }\n\n async getPermissions<TPermission extends SecurityPermission = SecurityPermission>(\n permission: string\n ) {\n return this.identityContext.getPermissions<TPermission>(permission);\n }\n\n async listPermissions() {\n return this.identityContext.listPermissions();\n }\n\n async hasFullAccess(): Promise<boolean> {\n return this.identityContext.hasFullAccess();\n }\n\n async getRole(params: any) {\n const useCase = this.container.resolve(GetRoleUseCase);\n const result = await useCase.execute(params.where);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async listRoles(params?: any) {\n const useCase = this.container.resolve(ListRolesUseCase);\n const result = await useCase.execute(params);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async createRole(input: any) {\n const useCase = this.container.resolve(CreateRoleUseCase);\n const result = await useCase.execute(input);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async updateRole(id: string, input: any) {\n const useCase = this.container.resolve(UpdateRoleUseCase);\n const result = await useCase.execute(id, input);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async deleteRole(id: string) {\n const useCase = this.container.resolve(DeleteRoleUseCase);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n throw result.error;\n }\n }\n\n addAuthorizer(authorizer: any) {\n // @ts-expect-error\n this.container.registerFactory(Authorizer, () => {\n return {\n authorize(): Promise<Permissions[]> {\n return authorizer();\n }\n };\n });\n }\n\n async getTeam(params: any) {\n const useCase = this.container.resolve(GetTeamUseCase);\n const result = await useCase.execute(params.where);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async listTeams(params?: any) {\n const useCase = this.container.resolve(ListTeamsUseCase);\n const result = await useCase.execute(params);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async createTeam(input: any) {\n const useCase = this.container.resolve(CreateTeam);\n const result = await useCase.execute(input);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async updateTeam(id: string, input: any) {\n const useCase = this.container.resolve(UpdateTeam);\n const result = await useCase.execute(id, input);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async deleteTeam(id: string) {\n const useCase = this.container.resolve(DeleteTeam);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n throw result.error;\n }\n }\n}\n"],"names":["LegacyContext","container","IdentityContext","AuthenticationContext","authenticator","Authenticator","token","identity","undefined","id","displayName","type","rest","authenticatedIdentity","AuthenticatedIdentity","cb","permission","params","useCase","GetRoleUseCase","result","ListRolesUseCase","input","CreateRoleUseCase","UpdateRoleUseCase","DeleteRoleUseCase","authorizer","Authorizer","GetTeamUseCase","ListTeamsUseCase","CreateTeam","UpdateTeam","DeleteTeam"],"mappings":"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"}
@@ -1,3 +0,0 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import type { ApiCoreContext } from "../../types/core.js";
3
- export declare const createSecurityContext: () => ContextPlugin<ApiCoreContext>;
@@ -1,10 +0,0 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import { LegacyContext } from "./LegacyContext.js";
3
- import { createSecurityGraphQL } from "../../graphql/security/index.js";
4
- const createSecurityContext = ()=>new ContextPlugin(async (context)=>{
5
- context.security = new LegacyContext(context.container);
6
- context.plugins.register(createSecurityGraphQL());
7
- });
8
- export { createSecurityContext };
9
-
10
- //# sourceMappingURL=createSecurityContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy/security/createSecurityContext.js","sources":["../../../src/legacy/security/createSecurityContext.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { LegacyContext } from \"~/legacy/security/LegacyContext.js\";\nimport { createSecurityGraphQL } from \"~/graphql/security/index.js\";\n\nexport const createSecurityContext = () => {\n return new ContextPlugin<ApiCoreContext>(async context => {\n // Create a legacy context that delegates to new features\n context.security = new LegacyContext(context.container);\n\n // Register GraphQL plugins\n context.plugins.register(createSecurityGraphQL());\n });\n};\n"],"names":["createSecurityContext","ContextPlugin","context","LegacyContext","createSecurityGraphQL"],"mappings":";;;AAKO,MAAMA,wBAAwB,IAC1B,IAAIC,cAA8B,OAAMC;QAE3CA,QAAQ,QAAQ,GAAG,IAAIC,cAAcD,QAAQ,SAAS;QAGtDA,QAAQ,OAAO,CAAC,QAAQ,CAACE;IAC7B"}
@@ -1,7 +0,0 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import type { ApiCoreContext } from "../../../types/core.js";
3
- export interface Config {
4
- identityType?: string;
5
- }
6
- export default _default;
7
- declare function _default({ identityType }: Config): ContextPlugin<ApiCoreContext>;
@@ -1,20 +0,0 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import { ApiKeysRepository } from "../../../features/security/apiKeys/shared/abstractions.js";
3
- const apiKeyAuthentication = ({ identityType })=>new ContextPlugin((context)=>{
4
- context.security.addAuthenticator(async (token)=>{
5
- if ("string" != typeof token || !token.startsWith("wat_")) return null;
6
- const repository = context.container.resolve(ApiKeysRepository);
7
- const result = await repository.getByToken(token);
8
- if (!result.isOk()) return null;
9
- const apiKey = result.value;
10
- return {
11
- id: apiKey.id,
12
- displayName: apiKey.name,
13
- type: identityType || "api-key",
14
- permissions: apiKey.permissions
15
- };
16
- });
17
- });
18
- export default apiKeyAuthentication;
19
-
20
- //# sourceMappingURL=apiKeyAuthentication.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy/security/plugins/apiKeyAuthentication.js","sources":["../../../../src/legacy/security/plugins/apiKeyAuthentication.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { ApiKeysRepository } from \"~/features/security/apiKeys/shared/abstractions.js\";\n\nexport interface Config {\n identityType?: string;\n}\n\nexport default ({ identityType }: Config) => {\n return new ContextPlugin<ApiCoreContext>(context => {\n context.security.addAuthenticator(async token => {\n if (typeof token !== \"string\" || !token.startsWith(\"wat_\")) {\n return null;\n }\n\n const repository = context.container.resolve(ApiKeysRepository);\n const result = await repository.getByToken(token);\n\n if (!result.isOk()) {\n return null;\n }\n\n const apiKey = result.value;\n\n return {\n id: apiKey.id,\n displayName: apiKey.name,\n type: identityType || \"api-key\",\n // Add permissions directly to the identity so we don't have to load them\n // again when authorization kicks in.\n permissions: apiKey.permissions\n };\n });\n });\n};\n"],"names":["identityType","ContextPlugin","context","token","repository","ApiKeysRepository","result","apiKey"],"mappings":";;AAQA,6BAAgB,GAAEA,YAAY,EAAU,GAC7B,IAAIC,cAA8BC,CAAAA;QACrCA,QAAQ,QAAQ,CAAC,gBAAgB,CAAC,OAAMC;YACpC,IAAI,AAAiB,YAAjB,OAAOA,SAAsB,CAACA,MAAM,UAAU,CAAC,SAC/C,OAAO;YAGX,MAAMC,aAAaF,QAAQ,SAAS,CAAC,OAAO,CAACG;YAC7C,MAAMC,SAAS,MAAMF,WAAW,UAAU,CAACD;YAE3C,IAAI,CAACG,OAAO,IAAI,IACZ,OAAO;YAGX,MAAMC,SAASD,OAAO,KAAK;YAE3B,OAAO;gBACH,IAAIC,OAAO,EAAE;gBACb,aAAaA,OAAO,IAAI;gBACxB,MAAMP,gBAAgB;gBAGtB,aAAaO,OAAO,WAAW;YACnC;QACJ;IACJ"}
@@ -1,6 +0,0 @@
1
- import type { ApiCoreContext } from "../../../types/core.js";
2
- export interface Config {
3
- identityType?: string;
4
- }
5
- export default _default;
6
- declare function _default(config: Config): import("@webiny/api").ContextPlugin<ApiCoreContext>;
@@ -1,13 +0,0 @@
1
- import { createContextPlugin } from "@webiny/api";
2
- const apiKeyAuthorization = (config)=>createContextPlugin(({ security })=>{
3
- security.addAuthorizer(async ()=>{
4
- const identityType = config.identityType || "api-key";
5
- const identity = security.getIdentity();
6
- if (!identity || identity.type !== identityType) return null;
7
- if (false === Array.isArray(identity.permissions)) return [];
8
- return identity.permissions;
9
- });
10
- });
11
- export default apiKeyAuthorization;
12
-
13
- //# sourceMappingURL=apiKeyAuthorization.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy/security/plugins/apiKeyAuthorization.js","sources":["../../../../src/legacy/security/plugins/apiKeyAuthorization.ts"],"sourcesContent":["import { createContextPlugin } from \"@webiny/api\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\n\nexport interface Config {\n identityType?: string;\n}\n\nexport default (config: Config) => {\n return createContextPlugin<ApiCoreContext>(({ security }) => {\n security.addAuthorizer(async () => {\n const identityType = config.identityType || \"api-key\";\n\n const identity = security.getIdentity();\n\n if (!identity || identity.type !== identityType) {\n return null;\n }\n // We can expect `permissions` to exist on the identity, because api-key authentication\n // plugin sets them on the identity instance to avoid loading them from DB here.\n if (Array.isArray(identity.permissions) === false) {\n return [];\n }\n return identity.permissions as SecurityPermission[];\n });\n });\n};\n"],"names":["config","createContextPlugin","security","identityType","identity","Array"],"mappings":";AAQA,4BAAgB,CAAAA,SACLC,oBAAoC,CAAC,EAAEC,QAAQ,EAAE;QACpDA,SAAS,aAAa,CAAC;YACnB,MAAMC,eAAeH,OAAO,YAAY,IAAI;YAE5C,MAAMI,WAAWF,SAAS,WAAW;YAErC,IAAI,CAACE,YAAYA,SAAS,IAAI,KAAKD,cAC/B,OAAO;YAIX,IAAIE,AAAwC,UAAxCA,MAAM,OAAO,CAACD,SAAS,WAAW,GAClC,OAAO,EAAE;YAEb,OAAOA,SAAS,WAAW;QAC/B;IACJ"}
@@ -1,5 +0,0 @@
1
- import type { ApiCoreContext } from "../../../types/core.js";
2
- /**
3
- * @internal
4
- */
5
- export declare function authenticateUsingCookie(): (import("@webiny/handler").BeforeHandlerPlugin<ApiCoreContext> | import("@webiny/api").ContextPlugin<ApiCoreContext>)[];
@@ -1,23 +0,0 @@
1
- import { createContextPlugin } from "@webiny/api";
2
- import { Request, createBeforeHandlerPlugin } from "@webiny/handler";
3
- import { SetIdTokenCookie } from "../../../features/security/authentication/AuthenticationContext/SetIdTokenCookie.js";
4
- function authenticateUsingCookie() {
5
- return [
6
- createBeforeHandlerPlugin(async (context)=>{
7
- const request = context.container.resolve(Request);
8
- const { cookies } = request;
9
- const token = cookies["wby-id-token"];
10
- if (!context.security.getIdentity() && token) try {
11
- await context.security.authenticate(token);
12
- } catch (err) {
13
- console.log(err);
14
- }
15
- }),
16
- createContextPlugin((context)=>{
17
- context.container.register(SetIdTokenCookie);
18
- })
19
- ];
20
- }
21
- export { authenticateUsingCookie };
22
-
23
- //# sourceMappingURL=authenticateUsingCookie.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy/security/plugins/authenticateUsingCookie.js","sources":["../../../../src/legacy/security/plugins/authenticateUsingCookie.ts"],"sourcesContent":["import { createContextPlugin } from \"@webiny/api\";\nimport { createBeforeHandlerPlugin, Request } from \"@webiny/handler\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { SetIdTokenCookie } from \"~/features/security/authentication/AuthenticationContext/SetIdTokenCookie.js\";\n\n/**\n * @internal\n */\nexport function authenticateUsingCookie() {\n return [\n createBeforeHandlerPlugin<ApiCoreContext>(async context => {\n const request = context.container.resolve(Request);\n const { cookies } = request;\n const token = cookies[\"wby-id-token\"];\n\n if (!context.security.getIdentity() && token) {\n try {\n await context.security.authenticate(token);\n } catch (err) {\n console.log(err);\n }\n }\n }),\n\n createContextPlugin<ApiCoreContext>(context => {\n context.container.register(SetIdTokenCookie);\n })\n ];\n}\n"],"names":["authenticateUsingCookie","createBeforeHandlerPlugin","context","request","Request","cookies","token","err","console","createContextPlugin","SetIdTokenCookie"],"mappings":";;;AAQO,SAASA;IACZ,OAAO;QACHC,0BAA0C,OAAMC;YAC5C,MAAMC,UAAUD,QAAQ,SAAS,CAAC,OAAO,CAACE;YAC1C,MAAM,EAAEC,OAAO,EAAE,GAAGF;YACpB,MAAMG,QAAQD,OAAO,CAAC,eAAe;YAErC,IAAI,CAACH,QAAQ,QAAQ,CAAC,WAAW,MAAMI,OACnC,IAAI;gBACA,MAAMJ,QAAQ,QAAQ,CAAC,YAAY,CAACI;YACxC,EAAE,OAAOC,KAAK;gBACVC,QAAQ,GAAG,CAACD;YAChB;QAER;QAEAE,oBAAoCP,CAAAA;YAChCA,QAAQ,SAAS,CAAC,QAAQ,CAACQ;QAC/B;KACH;AACL"}
@@ -1,5 +0,0 @@
1
- import type { ApiCoreContext } from "../../../types/core.js";
2
- export interface GetHeader {
3
- (context: ApiCoreContext): string | null | undefined;
4
- }
5
- export declare const authenticateUsingHttpHeader: () => ((import("@webiny/handler").BeforeHandlerPlugin<ApiCoreContext> | import("@webiny/api/index.js").ContextPlugin<ApiCoreContext>)[] | import("@webiny/handler").BeforeHandlerPlugin<ApiCoreContext> | import("@webiny/handler").HandlerOnRequestPlugin<import("@webiny/handler/types.js").Context>)[];
@@ -1,20 +0,0 @@
1
- import { Request, createBeforeHandlerPlugin } from "@webiny/handler";
2
- import { authenticateUsingCookie } from "./authenticateUsingCookie.js";
3
- import { setupSecureHeaders } from "./secureHeaders.js";
4
- const getHeader = (context)=>{
5
- const request = context.container.resolve(Request);
6
- const header = request.headers["authorization"];
7
- return header ? header.split(" ").pop() : null;
8
- };
9
- const authenticateUsingHttpHeader = ()=>[
10
- createBeforeHandlerPlugin(async (context)=>{
11
- const token = getHeader(context);
12
- if (!token) return;
13
- await context.security.authenticate(token);
14
- }),
15
- setupSecureHeaders(),
16
- authenticateUsingCookie()
17
- ];
18
- export { authenticateUsingHttpHeader };
19
-
20
- //# sourceMappingURL=authenticateUsingHttpHeader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy/security/plugins/authenticateUsingHttpHeader.js","sources":["../../../../src/legacy/security/plugins/authenticateUsingHttpHeader.ts"],"sourcesContent":["import { createBeforeHandlerPlugin, Request } from \"@webiny/handler\";\nimport { authenticateUsingCookie } from \"./authenticateUsingCookie.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { setupSecureHeaders } from \"./secureHeaders.js\";\n\nexport interface GetHeader {\n (context: ApiCoreContext): string | null | undefined;\n}\n\nconst getHeader: GetHeader = context => {\n const request = context.container.resolve(Request);\n const header = request.headers[\"authorization\"];\n\n return header ? header.split(\" \").pop() : null;\n};\n\nexport const authenticateUsingHttpHeader = () => {\n return [\n createBeforeHandlerPlugin<ApiCoreContext>(async context => {\n const token = getHeader(context);\n\n if (!token) {\n return;\n }\n\n await context.security.authenticate(token);\n }),\n // Configure strict headers (this is also a requirement to use cookies).\n setupSecureHeaders(),\n // Finally, we add cookie-based authentication.\n authenticateUsingCookie()\n ];\n};\n"],"names":["getHeader","context","request","Request","header","authenticateUsingHttpHeader","createBeforeHandlerPlugin","token","setupSecureHeaders","authenticateUsingCookie"],"mappings":";;;AASA,MAAMA,YAAuBC,CAAAA;IACzB,MAAMC,UAAUD,QAAQ,SAAS,CAAC,OAAO,CAACE;IAC1C,MAAMC,SAASF,QAAQ,OAAO,CAAC,gBAAgB;IAE/C,OAAOE,SAASA,OAAO,KAAK,CAAC,KAAK,GAAG,KAAK;AAC9C;AAEO,MAAMC,8BAA8B,IAChC;QACHC,0BAA0C,OAAML;YAC5C,MAAMM,QAAQP,UAAUC;YAExB,IAAI,CAACM,OACD;YAGJ,MAAMN,QAAQ,QAAQ,CAAC,YAAY,CAACM;QACxC;QAEAC;QAEAC;KACH"}
@@ -1 +0,0 @@
1
- export declare const setupSecureHeaders: () => import("@webiny/handler").HandlerOnRequestPlugin<import("@webiny/handler/types").Context>;
@@ -1,30 +0,0 @@
1
- import { ResponseHeaders, createHandlerOnRequest } from "@webiny/handler";
2
- const whitelistedHeaders = [
3
- "accept",
4
- "authorization",
5
- "cache-control",
6
- "content-type",
7
- "x-tenant",
8
- "x-apollo-tracing",
9
- "apollo-query-plan-experimental"
10
- ];
11
- const setupSecureHeaders = ()=>createHandlerOnRequest(async (request, reply)=>{
12
- const isOptions = "OPTIONS" === request.method;
13
- const headers = ResponseHeaders.create();
14
- headers.set("access-control-allow-origin", request.headers["origin"]);
15
- headers.set("access-control-allow-credentials", "true");
16
- if (isOptions) {
17
- headers.set("cache-control", "public, max-age=86400");
18
- headers.set("content-type", "application/json; charset=utf-8");
19
- headers.set("access-control-max-age", "86400");
20
- headers.set("access-control-allow-methods", "OPTIONS,POST,GET,DELETE,PUT,PATCH");
21
- headers.set("access-control-allow-headers", whitelistedHeaders.join(", "));
22
- } else {
23
- headers.set("x-tenant", request.headers["x-tenant"] || "root");
24
- headers.set("vary", "origin");
25
- }
26
- reply.headers(headers.getHeaders());
27
- });
28
- export { setupSecureHeaders };
29
-
30
- //# sourceMappingURL=secureHeaders.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy/security/plugins/secureHeaders.js","sources":["../../../../src/legacy/security/plugins/secureHeaders.ts"],"sourcesContent":["import { createHandlerOnRequest, ResponseHeaders } from \"@webiny/handler\";\n\nconst whitelistedHeaders = [\n \"accept\",\n \"authorization\",\n \"cache-control\",\n \"content-type\",\n \"x-tenant\",\n \"x-apollo-tracing\",\n \"apollo-query-plan-experimental\"\n];\n\nexport const setupSecureHeaders = () => {\n return createHandlerOnRequest(async (request, reply) => {\n const isOptions = request.method === \"OPTIONS\";\n\n const headers = ResponseHeaders.create();\n headers.set(\"access-control-allow-origin\", request.headers[\"origin\"]);\n headers.set(\"access-control-allow-credentials\", \"true\");\n\n if (isOptions) {\n headers.set(\"cache-control\", \"public, max-age=86400\");\n headers.set(\"content-type\", \"application/json; charset=utf-8\");\n headers.set(\"access-control-max-age\", \"86400\");\n headers.set(\"access-control-allow-methods\", \"OPTIONS,POST,GET,DELETE,PUT,PATCH\");\n headers.set(\"access-control-allow-headers\", whitelistedHeaders.join(\", \"));\n } else {\n headers.set(\"x-tenant\", request.headers[\"x-tenant\"] || \"root\");\n headers.set(\"vary\", \"origin\");\n }\n\n reply.headers(headers.getHeaders());\n });\n};\n"],"names":["whitelistedHeaders","setupSecureHeaders","createHandlerOnRequest","request","reply","isOptions","headers","ResponseHeaders"],"mappings":";AAEA,MAAMA,qBAAqB;IACvB;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,MAAMC,qBAAqB,IACvBC,uBAAuB,OAAOC,SAASC;QAC1C,MAAMC,YAAYF,AAAmB,cAAnBA,QAAQ,MAAM;QAEhC,MAAMG,UAAUC,gBAAgB,MAAM;QACtCD,QAAQ,GAAG,CAAC,+BAA+BH,QAAQ,OAAO,CAAC,SAAS;QACpEG,QAAQ,GAAG,CAAC,oCAAoC;QAEhD,IAAID,WAAW;YACXC,QAAQ,GAAG,CAAC,iBAAiB;YAC7BA,QAAQ,GAAG,CAAC,gBAAgB;YAC5BA,QAAQ,GAAG,CAAC,0BAA0B;YACtCA,QAAQ,GAAG,CAAC,gCAAgC;YAC5CA,QAAQ,GAAG,CAAC,gCAAgCN,mBAAmB,IAAI,CAAC;QACxE,OAAO;YACHM,QAAQ,GAAG,CAAC,YAAYH,QAAQ,OAAO,CAAC,WAAW,IAAI;YACvDG,QAAQ,GAAG,CAAC,QAAQ;QACxB;QAEAF,MAAM,OAAO,CAACE,QAAQ,UAAU;IACpC"}