@webiny/api-core 0.0.0-unstable.0d717d18dd → 0.0.0-unstable.5387e5f7c8

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 (234) hide show
  1. package/ApiCoreFeature.js +8 -0
  2. package/ApiCoreFeature.js.map +1 -1
  3. package/exports/api/tasks.d.ts +1 -0
  4. package/exports/api/tasks.js +1 -1
  5. package/exports/api.d.ts +1 -1
  6. package/exports/api.js +1 -1
  7. package/features/ai/Ai.d.ts +3 -1
  8. package/features/ai/Ai.js +36 -28
  9. package/features/ai/Ai.js.map +1 -1
  10. package/features/ai/AiModelRegistry.d.ts +14 -0
  11. package/features/ai/AiModelRegistry.js +39 -0
  12. package/features/ai/AiModelRegistry.js.map +1 -0
  13. package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
  14. package/features/ai/AiSdkToolHandlerResolver.js +19 -0
  15. package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
  16. package/features/ai/AiSdkTools.d.ts +4 -3
  17. package/features/ai/AiSdkTools.js +11 -9
  18. package/features/ai/AiSdkTools.js.map +1 -1
  19. package/features/ai/AnthropicSdkFactory.js +12 -4
  20. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  21. package/features/ai/DEVELOPERS.md +183 -0
  22. package/features/ai/GoogleSdkFactory.d.ts +10 -0
  23. package/features/ai/GoogleSdkFactory.js +65 -0
  24. package/features/ai/GoogleSdkFactory.js.map +1 -0
  25. package/features/ai/OpenAiSdkFactory.js +51 -11
  26. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  27. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  28. package/features/ai/OpenRouterSdkFactory.js +112 -0
  29. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  30. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  31. package/features/ai/RemoteAiModelCatalog.js +74 -0
  32. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  33. package/features/ai/abstractions.d.ts +102 -7
  34. package/features/ai/abstractions.js +6 -2
  35. package/features/ai/abstractions.js.map +1 -1
  36. package/features/ai/feature.js +10 -0
  37. package/features/ai/feature.js.map +1 -1
  38. package/features/ai/index.d.ts +2 -4
  39. package/features/ai/index.js +1 -1
  40. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  41. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  42. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  43. package/features/dateFormatter/abstractions.d.ts +13 -0
  44. package/features/dateFormatter/abstractions.js +5 -0
  45. package/features/dateFormatter/abstractions.js.map +1 -0
  46. package/features/dateFormatter/feature.d.ts +4 -0
  47. package/features/dateFormatter/feature.js +11 -0
  48. package/features/dateFormatter/feature.js.map +1 -0
  49. package/features/dateFormatter/index.d.ts +3 -0
  50. package/features/dateFormatter/index.js +2 -0
  51. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  52. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  53. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  54. package/features/encryption/EncryptionService.d.ts +2 -1
  55. package/features/encryption/EncryptionService.js +11 -4
  56. package/features/encryption/EncryptionService.js.map +1 -1
  57. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  58. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  59. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  60. package/features/encryption/abstractions.d.ts +11 -0
  61. package/features/encryption/abstractions.js +2 -1
  62. package/features/encryption/abstractions.js.map +1 -1
  63. package/features/encryption/index.d.ts +1 -0
  64. package/features/encryption/index.js +1 -0
  65. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  66. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +61 -0
  67. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  68. package/features/httpClient/HttpClient.d.ts +7 -0
  69. package/features/httpClient/HttpClient.js +72 -0
  70. package/features/httpClient/HttpClient.js.map +1 -0
  71. package/features/httpClient/HttpRequestError.d.ts +10 -0
  72. package/features/httpClient/HttpRequestError.js +13 -0
  73. package/features/httpClient/HttpRequestError.js.map +1 -0
  74. package/features/httpClient/HttpStatusError.d.ts +12 -0
  75. package/features/httpClient/HttpStatusError.js +12 -0
  76. package/features/httpClient/HttpStatusError.js.map +1 -0
  77. package/features/httpClient/abstractions.d.ts +32 -0
  78. package/features/httpClient/abstractions.js +5 -0
  79. package/features/httpClient/abstractions.js.map +1 -0
  80. package/features/httpClient/feature.d.ts +4 -0
  81. package/features/httpClient/feature.js +11 -0
  82. package/features/httpClient/feature.js.map +1 -0
  83. package/features/httpClient/index.d.ts +3 -0
  84. package/features/httpClient/index.js +3 -0
  85. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  86. package/features/requestContext/RawAssumePermissions.js +19 -0
  87. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  88. package/features/requestContext/abstractions.d.ts +22 -0
  89. package/features/requestContext/abstractions.js +2 -1
  90. package/features/requestContext/abstractions.js.map +1 -1
  91. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  92. package/features/requestContext/extractAssumePermissions.js +32 -0
  93. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  94. package/features/requestContext/feature.d.ts +2 -1
  95. package/features/requestContext/feature.js +2 -0
  96. package/features/requestContext/feature.js.map +1 -1
  97. package/features/requestContext/index.d.ts +3 -1
  98. package/features/requestContext/index.js +2 -1
  99. package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
  100. package/features/security/IdentityContext/IdentityContext.js +6 -6
  101. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  102. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  103. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  104. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  105. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  106. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  107. package/features/security/apiKeys/shared/schemas.js +2 -2
  108. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  109. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  110. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  111. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  112. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
  113. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  114. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  115. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  116. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  117. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  118. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  119. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  120. package/features/security/roles/CreateRole/schema.js +1 -1
  121. package/features/security/roles/CreateRole/schema.js.map +1 -1
  122. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  123. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  124. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  125. package/features/security/roles/UpdateRole/schema.js +1 -1
  126. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  127. package/features/security/shared/description.d.ts +4 -0
  128. package/features/security/shared/description.js +7 -0
  129. package/features/security/shared/description.js.map +1 -0
  130. package/features/security/shared/index.d.ts +1 -0
  131. package/features/security/shared/index.js +1 -0
  132. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  133. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  134. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  135. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  136. package/features/security/teams/CreateTeam/schema.js +1 -1
  137. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  138. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  139. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  140. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  141. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  142. package/features/security/teams/UpdateTeam/schema.js +1 -1
  143. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  144. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  145. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  146. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  147. package/features/slugify/DefaultSlugify.d.ts +8 -0
  148. package/features/slugify/DefaultSlugify.js +20 -0
  149. package/features/slugify/DefaultSlugify.js.map +1 -0
  150. package/features/slugify/abstractions.d.ts +12 -0
  151. package/features/slugify/abstractions.js +5 -0
  152. package/features/slugify/abstractions.js.map +1 -0
  153. package/features/slugify/feature.d.ts +4 -0
  154. package/features/slugify/feature.js +11 -0
  155. package/features/slugify/feature.js.map +1 -0
  156. package/features/slugify/index.d.ts +3 -0
  157. package/features/slugify/index.js +2 -0
  158. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  159. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  160. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  161. package/features/stringFormatter/abstractions.d.ts +11 -0
  162. package/features/stringFormatter/abstractions.js +5 -0
  163. package/features/stringFormatter/abstractions.js.map +1 -0
  164. package/features/stringFormatter/feature.d.ts +4 -0
  165. package/features/stringFormatter/feature.js +13 -0
  166. package/features/stringFormatter/feature.js.map +1 -0
  167. package/features/stringFormatter/index.d.ts +3 -0
  168. package/features/stringFormatter/index.js +2 -0
  169. package/features/task/TaskDefinition/abstractions.d.ts +69 -4
  170. package/features/task/TaskDefinition/abstractions.js +2 -1
  171. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  172. package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
  173. package/features/tenancy/TenantContext/TenantContext.js +13 -8
  174. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  175. package/features/wcp/WcpContext/WcpContext.d.ts +6 -0
  176. package/features/wcp/WcpContext/WcpContext.js +18 -0
  177. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  178. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +9 -69
  179. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +63 -35
  180. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  181. package/features/wcp/WcpFeature.js +2 -0
  182. package/features/wcp/WcpFeature.js.map +1 -1
  183. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  184. package/features/wcp/WcpLicenseLoader.js +58 -0
  185. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  186. package/features/wcp/WcpLicenseProvider.d.ts +6 -14
  187. package/features/wcp/WcpLicenseProvider.js +3 -7
  188. package/features/wcp/WcpLicenseProvider.js.map +1 -1
  189. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  190. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  191. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  192. package/graphql/ApiCoreSchemaFactory.d.ts +1 -0
  193. package/graphql/ApiCoreSchemaFactory.js +7 -1
  194. package/graphql/ApiCoreSchemaFactory.js.map +1 -1
  195. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
  196. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
  197. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  198. package/graphql/security/SecuritySchemaFactory.d.ts +1 -0
  199. package/graphql/security/SecuritySchemaFactory.js +4 -0
  200. package/graphql/security/SecuritySchemaFactory.js.map +1 -1
  201. package/graphql/system/SystemSchemaFactory.d.ts +1 -0
  202. package/graphql/system/SystemSchemaFactory.js +4 -0
  203. package/graphql/system/SystemSchemaFactory.js.map +1 -1
  204. package/graphql/users/UsersSchemaFactory.d.ts +1 -0
  205. package/graphql/users/UsersSchemaFactory.js +4 -0
  206. package/graphql/users/UsersSchemaFactory.js.map +1 -1
  207. package/graphql/wcp/WcpSchemaFactory.d.ts +1 -0
  208. package/graphql/wcp/WcpSchemaFactory.js +5 -0
  209. package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
  210. package/idp/JwksCache.d.ts +14 -3
  211. package/idp/JwksCache.js +97 -17
  212. package/idp/JwksCache.js.map +1 -1
  213. package/idp/JwksStoreFeature.d.ts +8 -0
  214. package/idp/JwksStoreFeature.js +11 -0
  215. package/idp/JwksStoreFeature.js.map +1 -0
  216. package/idp/MemoryJwksStore.d.ts +14 -0
  217. package/idp/MemoryJwksStore.js +21 -0
  218. package/idp/MemoryJwksStore.js.map +1 -0
  219. package/idp/OidcJwtIdentityProvider.js +5 -1
  220. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  221. package/idp/abstractions.d.ts +24 -0
  222. package/idp/abstractions.js +2 -1
  223. package/idp/abstractions.js.map +1 -1
  224. package/idp/feature.js +1 -2
  225. package/idp/feature.js.map +1 -1
  226. package/idp/index.d.ts +1 -0
  227. package/idp/index.js +1 -0
  228. package/package.json +20 -18
  229. package/testing/environment.d.ts +14 -0
  230. package/testing/environment.js +18 -0
  231. package/testing/environment.js.map +1 -0
  232. package/features/wcp/loadWcpLicense.d.ts +0 -2
  233. package/features/wcp/loadWcpLicense.js +0 -51
  234. package/features/wcp/loadWcpLicense.js.map +0 -1
@@ -0,0 +1,61 @@
1
+ import { FeatureFlags } from "../abstractions.js";
2
+ import { FeatureFlags as feature_flags_FeatureFlags } from "@webiny/feature-flags";
3
+ import { WcpLicenseProvider } from "../../wcp/WcpLicenseProvider.js";
4
+ const LICENSE_CHECKS = {
5
+ multiTenancy: (l)=>l.canUseFeature("multiTenancy"),
6
+ advancedPublishingWorkflow: (l)=>l.canUseWorkflows(),
7
+ advancedAccessControlLayer: (l)=>l.canUseAacl(),
8
+ "advancedAccessControlLayer.teams": (l)=>l.canUseTeams(),
9
+ "advancedAccessControlLayer.privateFiles": (l)=>l.canUsePrivateFiles(),
10
+ "advancedAccessControlLayer.folderLevelPermissions": (l)=>l.canUseFolderLevelPermissions(),
11
+ "advancedAccessControlLayer.hcmsFieldPermissions": (l)=>l.canUseHcmsFieldPermissions(),
12
+ auditLogs: (l)=>l.canUseAuditLogs(),
13
+ recordLocking: (l)=>l.canUseRecordLocking(),
14
+ "fileManager.threatDetection": (l)=>l.canUseFileManagerThreatDetection(),
15
+ aiPowerups: (l)=>l.canUseAiPowerups(),
16
+ "aiPowerups.fileManager.imageEnrichment": (l)=>l.canUseAiImageEnrichment(),
17
+ "aiPowerups.websiteBuilder.pageGeneration": (l)=>l.canUseAiPageGeneration(),
18
+ "aiPowerups.websiteBuilder.pageTranslation": (l)=>l.canUseAiPageTranslation(),
19
+ "aiPowerups.lexicalGeneration": (l)=>l.canUseAiLexicalGeneration(),
20
+ "aiPowerups.adminAssistant": (l)=>l.canUseAiAdminAssistant(),
21
+ "aiPowerups.remoteComponents": (l)=>l.canUseRemoteComponents(),
22
+ "aiPowerups.cms.entryGeneration": (l)=>l.canUseAiEntryGeneration(),
23
+ "aiPowerups.cms.entryComparison": (l)=>l.canUseAiEntryComparison(),
24
+ "aiPowerups.cms.entryTranslation": (l)=>l.canUseAiEntryTranslation(),
25
+ abTesting: (l)=>l.canUseAbTesting(),
26
+ collaboration: (l)=>l.canUseCollaboration(),
27
+ "collaboration.comments": (l)=>l.canUseComments(),
28
+ "collaboration.activityLog": (l)=>l.canUseActivityLog()
29
+ };
30
+ class LicenseDecoratedFeatureFlags extends feature_flags_FeatureFlags {
31
+ constructor(base, license){
32
+ super(base.toDto()), this.base = base, this.license = license;
33
+ }
34
+ isEnabled(name) {
35
+ const check = LICENSE_CHECKS[name];
36
+ if (check) {
37
+ if (!check(this.license)) return false;
38
+ return !this.base.isExplicitlyDisabled(name);
39
+ }
40
+ return this.base.isEnabled(name);
41
+ }
42
+ }
43
+ class FeatureFlagsWithLicenseDecoratorImpl {
44
+ constructor(licenseProvider, decoratee){
45
+ this.licenseProvider = licenseProvider;
46
+ this.decoratee = decoratee;
47
+ }
48
+ get() {
49
+ const base = this.decoratee.get();
50
+ return new LicenseDecoratedFeatureFlags(base, this.licenseProvider.get());
51
+ }
52
+ }
53
+ const FeatureFlagsWithLicenseDecorator = FeatureFlags.createDecorator({
54
+ decorator: FeatureFlagsWithLicenseDecoratorImpl,
55
+ dependencies: [
56
+ WcpLicenseProvider
57
+ ]
58
+ });
59
+ export { FeatureFlagsWithLicenseDecorator };
60
+
61
+ //# sourceMappingURL=FeatureFlagsWithLicenseDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js","sources":["../../../../src/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.ts"],"sourcesContent":["import { FeatureFlags } from \"../abstractions.js\";\nimport { FeatureFlags as FeatureFlagsClass } from \"@webiny/feature-flags\";\nimport type { FeatureFlagName } from \"@webiny/feature-flags\";\nimport type { ILicense } from \"@webiny/wcp/types.js\";\nimport { WcpLicenseProvider } from \"~/features/wcp/WcpLicenseProvider.js\";\n\n/*\n * Feature flag resolution (license decorator).\n *\n * Two kinds of flag, and only one of them is Webiny's to sell:\n *\n * LICENSE-GOVERNED (listed in LICENSE_CHECKS) — the license is the authority:\n * 1. No license, or license blocks the flag → false, config ignored\n * 2. License allows + config unset → true (the license grants it)\n * 3. License allows + config=false → false (config may disable, never re-enable)\n *\n * EVERYTHING ELSE — the project's own flags. The config decides, and nothing is assumed:\n * 4. config=true → true\n * 5. config=false or unset → false\n *\n * There is deliberately no third kind. A set of flags used to be enabled by default here, which was\n * a workaround for capabilities the license could not express: rather than gate them properly they\n * were left on for anyone holding any license at all. It also meant EVERY unrecognised name resolved\n * to true, so an undeclared flag and a typo both read as enabled. A feature that should be sold\n * belongs in LICENSE_CHECKS and on the license; anything else is the project's own to switch on.\n */\n\nconst LICENSE_CHECKS: Record<string, (license: ILicense) => boolean> = {\n multiTenancy: l => l.canUseFeature(\"multiTenancy\"),\n advancedPublishingWorkflow: l => l.canUseWorkflows(),\n advancedAccessControlLayer: l => l.canUseAacl(),\n \"advancedAccessControlLayer.teams\": l => l.canUseTeams(),\n \"advancedAccessControlLayer.privateFiles\": l => l.canUsePrivateFiles(),\n \"advancedAccessControlLayer.folderLevelPermissions\": l => l.canUseFolderLevelPermissions(),\n \"advancedAccessControlLayer.hcmsFieldPermissions\": l => l.canUseHcmsFieldPermissions(),\n auditLogs: l => l.canUseAuditLogs(),\n recordLocking: l => l.canUseRecordLocking(),\n \"fileManager.threatDetection\": l => l.canUseFileManagerThreatDetection(),\n aiPowerups: l => l.canUseAiPowerups(),\n \"aiPowerups.fileManager.imageEnrichment\": l => l.canUseAiImageEnrichment(),\n \"aiPowerups.websiteBuilder.pageGeneration\": l => l.canUseAiPageGeneration(),\n \"aiPowerups.websiteBuilder.pageTranslation\": l => l.canUseAiPageTranslation(),\n \"aiPowerups.lexicalGeneration\": l => l.canUseAiLexicalGeneration(),\n \"aiPowerups.adminAssistant\": l => l.canUseAiAdminAssistant(),\n \"aiPowerups.remoteComponents\": l => l.canUseRemoteComponents(),\n \"aiPowerups.cms.entryGeneration\": l => l.canUseAiEntryGeneration(),\n \"aiPowerups.cms.entryComparison\": l => l.canUseAiEntryComparison(),\n \"aiPowerups.cms.entryTranslation\": l => l.canUseAiEntryTranslation(),\n abTesting: l => l.canUseAbTesting(),\n collaboration: l => l.canUseCollaboration(),\n \"collaboration.comments\": l => l.canUseComments(),\n \"collaboration.activityLog\": l => l.canUseActivityLog()\n};\n\nclass LicenseDecoratedFeatureFlags extends FeatureFlagsClass {\n constructor(\n private base: FeatureFlagsClass,\n private license: ILicense\n ) {\n super(base.toDto());\n }\n\n override isEnabled(name: FeatureFlagName): boolean {\n const check = LICENSE_CHECKS[name];\n if (check) {\n if (!check(this.license)) {\n return false;\n }\n // License allows — config can only disable, not re-enable blocked features.\n return !this.base.isExplicitlyDisabled(name);\n }\n /*\n * Everything else is the project's own, and the config is the only thing that decides. No\n * default: `isEnabled` on the base is true only for an explicitly configured `true`.\n *\n * This branch used to return `!isExplicitlyDisabled(name)` whenever a license existed, which\n * made EVERY unrecognised name true — an undeclared flag, or a typo like `aiPowerupz`. It also\n * returned false outright without a license, so an unlicensed install could not turn on a flag\n * it had declared itself. Neither is the license's business.\n */\n return this.base.isEnabled(name);\n }\n}\n\nclass FeatureFlagsWithLicenseDecoratorImpl implements FeatureFlags.Interface {\n constructor(\n private licenseProvider: WcpLicenseProvider.Interface,\n private decoratee: FeatureFlags.Interface\n ) {}\n\n get(): FeatureFlagsClass {\n const base = this.decoratee.get();\n return new LicenseDecoratedFeatureFlags(base, this.licenseProvider.get());\n }\n}\n\nexport const FeatureFlagsWithLicenseDecorator = FeatureFlags.createDecorator({\n decorator: FeatureFlagsWithLicenseDecoratorImpl,\n dependencies: [WcpLicenseProvider]\n});\n"],"names":["LICENSE_CHECKS","l","LicenseDecoratedFeatureFlags","FeatureFlagsClass","base","license","name","check","FeatureFlagsWithLicenseDecoratorImpl","licenseProvider","decoratee","FeatureFlagsWithLicenseDecorator","FeatureFlags","WcpLicenseProvider"],"mappings":";;;AA2BA,MAAMA,iBAAiE;IACnE,cAAcC,CAAAA,IAAKA,EAAE,aAAa,CAAC;IACnC,4BAA4BA,CAAAA,IAAKA,EAAE,eAAe;IAClD,4BAA4BA,CAAAA,IAAKA,EAAE,UAAU;IAC7C,oCAAoCA,CAAAA,IAAKA,EAAE,WAAW;IACtD,2CAA2CA,CAAAA,IAAKA,EAAE,kBAAkB;IACpE,qDAAqDA,CAAAA,IAAKA,EAAE,4BAA4B;IACxF,mDAAmDA,CAAAA,IAAKA,EAAE,0BAA0B;IACpF,WAAWA,CAAAA,IAAKA,EAAE,eAAe;IACjC,eAAeA,CAAAA,IAAKA,EAAE,mBAAmB;IACzC,+BAA+BA,CAAAA,IAAKA,EAAE,gCAAgC;IACtE,YAAYA,CAAAA,IAAKA,EAAE,gBAAgB;IACnC,0CAA0CA,CAAAA,IAAKA,EAAE,uBAAuB;IACxE,4CAA4CA,CAAAA,IAAKA,EAAE,sBAAsB;IACzE,6CAA6CA,CAAAA,IAAKA,EAAE,uBAAuB;IAC3E,gCAAgCA,CAAAA,IAAKA,EAAE,yBAAyB;IAChE,6BAA6BA,CAAAA,IAAKA,EAAE,sBAAsB;IAC1D,+BAA+BA,CAAAA,IAAKA,EAAE,sBAAsB;IAC5D,kCAAkCA,CAAAA,IAAKA,EAAE,uBAAuB;IAChE,kCAAkCA,CAAAA,IAAKA,EAAE,uBAAuB;IAChE,mCAAmCA,CAAAA,IAAKA,EAAE,wBAAwB;IAClE,WAAWA,CAAAA,IAAKA,EAAE,eAAe;IACjC,eAAeA,CAAAA,IAAKA,EAAE,mBAAmB;IACzC,0BAA0BA,CAAAA,IAAKA,EAAE,cAAc;IAC/C,6BAA6BA,CAAAA,IAAKA,EAAE,iBAAiB;AACzD;AAEA,MAAMC,qCAAqCC;IACvC,YACYC,IAAuB,EACvBC,OAAiB,CAC3B;QACE,KAAK,CAACD,KAAK,KAAK,UAHRA,IAAI,GAAJA,MAAAA,IAAAA,CACAC,OAAO,GAAPA;IAGZ;IAES,UAAUC,IAAqB,EAAW;QAC/C,MAAMC,QAAQP,cAAc,CAACM,KAAK;QAClC,IAAIC,OAAO;YACP,IAAI,CAACA,MAAM,IAAI,CAAC,OAAO,GACnB,OAAO;YAGX,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAACD;QAC3C;QAUA,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAACA;IAC/B;AACJ;AAEA,MAAME;IACF,YACYC,eAA6C,EAC7CC,SAAiC,CAC3C;aAFUD,eAAe,GAAfA;aACAC,SAAS,GAATA;IACT;IAEH,MAAyB;QACrB,MAAMN,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG;QAC/B,OAAO,IAAIF,6BAA6BE,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG;IAC1E;AACJ;AAEO,MAAMO,mCAAmCC,aAAa,eAAe,CAAC;IACzE,WAAWJ;IACX,cAAc;QAACK;KAAmB;AACtC"}
@@ -0,0 +1,7 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { HttpClient as HttpClientAbstraction } from "./abstractions.js";
3
+ declare class HttpClientImpl implements HttpClientAbstraction.Interface {
4
+ requestJson(request: HttpClientAbstraction.Request): Promise<Result<unknown, HttpClientAbstraction.Error>>;
5
+ }
6
+ export declare const HttpClient: import("@webiny/di").Implementation<typeof HttpClientImpl>;
7
+ export {};
@@ -0,0 +1,72 @@
1
+ import { Result, createImplementation } from "@webiny/feature/api";
2
+ import { HttpClient } from "./abstractions.js";
3
+ import { HttpRequestError } from "./HttpRequestError.js";
4
+ import { HttpStatusError } from "./HttpStatusError.js";
5
+ const DEFAULT_TIMEOUT_MS = 10000;
6
+ function createRequestInit(request) {
7
+ const timeoutMs = request.timeoutMs ?? DEFAULT_TIMEOUT_MS;
8
+ const headers = new Headers(request.headers);
9
+ const init = {
10
+ method: request.method ?? "GET",
11
+ headers,
12
+ signal: AbortSignal.timeout(timeoutMs)
13
+ };
14
+ if (void 0 !== request.body) {
15
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
16
+ init.body = JSON.stringify(request.body);
17
+ }
18
+ return init;
19
+ }
20
+ function isTimeout(error) {
21
+ return error instanceof Error && "TimeoutError" === error.name;
22
+ }
23
+ function parseJson(text) {
24
+ if ("" === text) return Result.ok(void 0);
25
+ try {
26
+ const value = JSON.parse(text);
27
+ return Result.ok(value);
28
+ } catch (error) {
29
+ return Result.fail(error);
30
+ }
31
+ }
32
+ class HttpClientImpl {
33
+ async requestJson(request) {
34
+ const { url } = request;
35
+ const init = createRequestInit(request);
36
+ let response;
37
+ let text;
38
+ try {
39
+ response = await fetch(url, init);
40
+ text = await response.text();
41
+ } catch (error) {
42
+ const reason = isTimeout(error) ? "timeout" : "network";
43
+ return Result.fail(new HttpRequestError({
44
+ url,
45
+ reason
46
+ }, error));
47
+ }
48
+ const body = parseJson(text);
49
+ if (!response.ok) {
50
+ const statusError = new HttpStatusError({
51
+ url,
52
+ status: response.status,
53
+ statusText: response.statusText,
54
+ body: body.isOk() ? body.value : void 0
55
+ });
56
+ return Result.fail(statusError);
57
+ }
58
+ if (body.isFail()) return Result.fail(new HttpRequestError({
59
+ url,
60
+ reason: "invalidJson"
61
+ }, body.error));
62
+ return Result.ok(body.value);
63
+ }
64
+ }
65
+ const HttpClient_HttpClient = createImplementation({
66
+ abstraction: HttpClient,
67
+ implementation: HttpClientImpl,
68
+ dependencies: []
69
+ });
70
+ export { HttpClient_HttpClient as HttpClient };
71
+
72
+ //# sourceMappingURL=HttpClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/httpClient/HttpClient.js","sources":["../../../src/features/httpClient/HttpClient.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { HttpClient as HttpClientAbstraction } from \"./abstractions.js\";\nimport { HttpRequestError } from \"./HttpRequestError.js\";\nimport { HttpStatusError } from \"./HttpStatusError.js\";\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\nfunction createRequestInit(request: HttpClientAbstraction.Request): RequestInit {\n const timeoutMs = request.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const headers = new Headers(request.headers);\n const init: RequestInit = {\n method: request.method ?? \"GET\",\n headers,\n signal: AbortSignal.timeout(timeoutMs)\n };\n\n if (request.body !== undefined) {\n if (!headers.has(\"content-type\")) {\n headers.set(\"content-type\", \"application/json\");\n }\n init.body = JSON.stringify(request.body);\n }\n\n return init;\n}\n\nfunction isTimeout(error: unknown): boolean {\n return error instanceof Error && error.name === \"TimeoutError\";\n}\n\n// An empty body parses to `undefined`, so a 204 is not an invalid response.\nfunction parseJson(text: string): Result<unknown, unknown> {\n if (text === \"\") {\n return Result.ok(undefined);\n }\n try {\n const value: unknown = JSON.parse(text);\n return Result.ok(value);\n } catch (error) {\n return Result.fail(error);\n }\n}\n\nclass HttpClientImpl implements HttpClientAbstraction.Interface {\n async requestJson(\n request: HttpClientAbstraction.Request\n ): Promise<Result<unknown, HttpClientAbstraction.Error>> {\n const { url } = request;\n const init = createRequestInit(request);\n\n let response: Response;\n let text: string;\n try {\n response = await fetch(url, init);\n text = await response.text();\n } catch (error) {\n const reason = isTimeout(error) ? \"timeout\" : \"network\";\n return Result.fail(new HttpRequestError({ url, reason }, error));\n }\n\n const body = parseJson(text);\n\n if (!response.ok) {\n const statusError = new HttpStatusError({\n url,\n status: response.status,\n statusText: response.statusText,\n body: body.isOk() ? body.value : undefined\n });\n return Result.fail(statusError);\n }\n\n if (body.isFail()) {\n return Result.fail(new HttpRequestError({ url, reason: \"invalidJson\" }, body.error));\n }\n\n return Result.ok(body.value);\n }\n}\n\nexport const HttpClient = createImplementation({\n abstraction: HttpClientAbstraction,\n implementation: HttpClientImpl,\n dependencies: []\n});\n"],"names":["DEFAULT_TIMEOUT_MS","createRequestInit","request","timeoutMs","headers","Headers","init","AbortSignal","undefined","JSON","isTimeout","error","Error","parseJson","text","Result","value","HttpClientImpl","url","response","fetch","reason","HttpRequestError","body","statusError","HttpStatusError","HttpClient","createImplementation","HttpClientAbstraction"],"mappings":";;;;AAMA,MAAMA,qBAAqB;AAE3B,SAASC,kBAAkBC,OAAsC;IAC7D,MAAMC,YAAYD,QAAQ,SAAS,IAAIF;IACvC,MAAMI,UAAU,IAAIC,QAAQH,QAAQ,OAAO;IAC3C,MAAMI,OAAoB;QACtB,QAAQJ,QAAQ,MAAM,IAAI;QAC1BE;QACA,QAAQG,YAAY,OAAO,CAACJ;IAChC;IAEA,IAAID,AAAiBM,WAAjBN,QAAQ,IAAI,EAAgB;QAC5B,IAAI,CAACE,QAAQ,GAAG,CAAC,iBACbA,QAAQ,GAAG,CAAC,gBAAgB;QAEhCE,KAAK,IAAI,GAAGG,KAAK,SAAS,CAACP,QAAQ,IAAI;IAC3C;IAEA,OAAOI;AACX;AAEA,SAASI,UAAUC,KAAc;IAC7B,OAAOA,iBAAiBC,SAASD,AAAe,mBAAfA,MAAM,IAAI;AAC/C;AAGA,SAASE,UAAUC,IAAY;IAC3B,IAAIA,AAAS,OAATA,MACA,OAAOC,OAAO,EAAE,CAACP;IAErB,IAAI;QACA,MAAMQ,QAAiBP,KAAK,KAAK,CAACK;QAClC,OAAOC,OAAO,EAAE,CAACC;IACrB,EAAE,OAAOL,OAAO;QACZ,OAAOI,OAAO,IAAI,CAACJ;IACvB;AACJ;AAEA,MAAMM;IACF,MAAM,YACFf,OAAsC,EACe;QACrD,MAAM,EAAEgB,GAAG,EAAE,GAAGhB;QAChB,MAAMI,OAAOL,kBAAkBC;QAE/B,IAAIiB;QACJ,IAAIL;QACJ,IAAI;YACAK,WAAW,MAAMC,MAAMF,KAAKZ;YAC5BQ,OAAO,MAAMK,SAAS,IAAI;QAC9B,EAAE,OAAOR,OAAO;YACZ,MAAMU,SAASX,UAAUC,SAAS,YAAY;YAC9C,OAAOI,OAAO,IAAI,CAAC,IAAIO,iBAAiB;gBAAEJ;gBAAKG;YAAO,GAAGV;QAC7D;QAEA,MAAMY,OAAOV,UAAUC;QAEvB,IAAI,CAACK,SAAS,EAAE,EAAE;YACd,MAAMK,cAAc,IAAIC,gBAAgB;gBACpCP;gBACA,QAAQC,SAAS,MAAM;gBACvB,YAAYA,SAAS,UAAU;gBAC/B,MAAMI,KAAK,IAAI,KAAKA,KAAK,KAAK,GAAGf;YACrC;YACA,OAAOO,OAAO,IAAI,CAACS;QACvB;QAEA,IAAID,KAAK,MAAM,IACX,OAAOR,OAAO,IAAI,CAAC,IAAIO,iBAAiB;YAAEJ;YAAK,QAAQ;QAAc,GAAGK,KAAK,KAAK;QAGtF,OAAOR,OAAO,EAAE,CAACQ,KAAK,KAAK;IAC/B;AACJ;AAEO,MAAMG,wBAAaC,qBAAqB;IAC3C,aAAaC;IACb,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,10 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ export interface HttpRequestErrorData {
3
+ url: string;
4
+ reason: "network" | "timeout" | "invalidJson";
5
+ }
6
+ /** The request didn't produce a usable response: it failed, timed out, or the body wasn't JSON. */
7
+ export declare class HttpRequestError extends BaseError<HttpRequestErrorData> {
8
+ readonly code: "HttpClient/Request";
9
+ constructor(data: HttpRequestErrorData, cause: unknown);
10
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ class HttpRequestError extends BaseError {
3
+ constructor(data, cause){
4
+ super({
5
+ message: `Request to "${data.url}" failed (${data.reason}).`,
6
+ data
7
+ }), this.code = "HttpClient/Request";
8
+ this.cause = cause;
9
+ }
10
+ }
11
+ export { HttpRequestError };
12
+
13
+ //# sourceMappingURL=HttpRequestError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/httpClient/HttpRequestError.js","sources":["../../../src/features/httpClient/HttpRequestError.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\nexport interface HttpRequestErrorData {\n url: string;\n reason: \"network\" | \"timeout\" | \"invalidJson\";\n}\n\n/** The request didn't produce a usable response: it failed, timed out, or the body wasn't JSON. */\nexport class HttpRequestError extends BaseError<HttpRequestErrorData> {\n override readonly code = \"HttpClient/Request\" as const;\n\n constructor(data: HttpRequestErrorData, cause: unknown) {\n super({\n message: `Request to \"${data.url}\" failed (${data.reason}).`,\n data\n });\n this.cause = cause;\n }\n}\n"],"names":["HttpRequestError","BaseError","data","cause"],"mappings":";AAQO,MAAMA,yBAAyBC;IAGlC,YAAYC,IAA0B,EAAEC,KAAc,CAAE;QACpD,KAAK,CAAC;YACF,SAAS,CAAC,YAAY,EAAED,KAAK,GAAG,CAAC,UAAU,EAAEA,KAAK,MAAM,CAAC,EAAE,CAAC;YAC5DA;QACJ,SANc,IAAI,GAAG;QAOrB,IAAI,CAAC,KAAK,GAAGC;IACjB;AACJ"}
@@ -0,0 +1,12 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ export interface HttpStatusErrorData {
3
+ url: string;
4
+ status: number;
5
+ statusText: string;
6
+ body: unknown;
7
+ }
8
+ /** The server answered with a non-2xx status. */
9
+ export declare class HttpStatusError extends BaseError<HttpStatusErrorData> {
10
+ readonly code: "HttpClient/Status";
11
+ constructor(data: HttpStatusErrorData);
12
+ }
@@ -0,0 +1,12 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ class HttpStatusError extends BaseError {
3
+ constructor(data){
4
+ super({
5
+ message: `Request to "${data.url}" failed with status ${data.status}.`,
6
+ data
7
+ }), this.code = "HttpClient/Status";
8
+ }
9
+ }
10
+ export { HttpStatusError };
11
+
12
+ //# sourceMappingURL=HttpStatusError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/httpClient/HttpStatusError.js","sources":["../../../src/features/httpClient/HttpStatusError.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\nexport interface HttpStatusErrorData {\n url: string;\n status: number;\n statusText: string;\n body: unknown; // the parsed JSON body, or `undefined` when there was none\n}\n\n/** The server answered with a non-2xx status. */\nexport class HttpStatusError extends BaseError<HttpStatusErrorData> {\n override readonly code = \"HttpClient/Status\" as const;\n\n constructor(data: HttpStatusErrorData) {\n super({\n message: `Request to \"${data.url}\" failed with status ${data.status}.`,\n data\n });\n }\n}\n"],"names":["HttpStatusError","BaseError","data"],"mappings":";AAUO,MAAMA,wBAAwBC;IAGjC,YAAYC,IAAyB,CAAE;QACnC,KAAK,CAAC;YACF,SAAS,CAAC,YAAY,EAAEA,KAAK,GAAG,CAAC,qBAAqB,EAAEA,KAAK,MAAM,CAAC,CAAC,CAAC;YACtEA;QACJ,SANc,IAAI,GAAG;IAOzB;AACJ"}
@@ -0,0 +1,32 @@
1
+ import type { Result } from "@webiny/feature/api";
2
+ import type { HttpRequestError } from "./HttpRequestError.js";
3
+ import type { HttpStatusError } from "./HttpStatusError.js";
4
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
5
+ export interface IHttpClientRequest {
6
+ url: string;
7
+ method?: HttpMethod;
8
+ headers?: Record<string, string>;
9
+ body?: unknown;
10
+ timeoutMs?: number;
11
+ }
12
+ export interface IHttpClientErrors {
13
+ request: HttpRequestError;
14
+ status: HttpStatusError;
15
+ }
16
+ type HttpClientError = IHttpClientErrors[keyof IHttpClientErrors];
17
+ export interface IHttpClient {
18
+ /**
19
+ * Sends a request and parses the response body as JSON. The body is `unknown` on purpose:
20
+ * validate it before use.
21
+ */
22
+ requestJson(request: IHttpClientRequest): Promise<Result<unknown, HttpClientError>>;
23
+ }
24
+ /** Outbound HTTP requests with a timeout, a status check and JSON parsing. */
25
+ export declare const HttpClient: import("@webiny/di").Abstraction<IHttpClient>;
26
+ export declare namespace HttpClient {
27
+ type Interface = IHttpClient;
28
+ type Request = IHttpClientRequest;
29
+ type Method = HttpMethod;
30
+ type Error = HttpClientError;
31
+ }
32
+ export {};
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const HttpClient = createAbstraction("HttpClient");
3
+ export { HttpClient };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/httpClient/abstractions.js","sources":["../../../src/features/httpClient/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { HttpRequestError } from \"./HttpRequestError.js\";\nimport type { HttpStatusError } from \"./HttpStatusError.js\";\n\nexport type HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\nexport interface IHttpClientRequest {\n url: string;\n method?: HttpMethod; // defaults to \"GET\"\n headers?: Record<string, string>;\n body?: unknown; // sent as JSON\n timeoutMs?: number; // defaults to 10 seconds\n}\n\nexport interface IHttpClientErrors {\n request: HttpRequestError;\n status: HttpStatusError;\n}\n\ntype HttpClientError = IHttpClientErrors[keyof IHttpClientErrors];\n\nexport interface IHttpClient {\n /**\n * Sends a request and parses the response body as JSON. The body is `unknown` on purpose:\n * validate it before use.\n */\n requestJson(request: IHttpClientRequest): Promise<Result<unknown, HttpClientError>>;\n}\n\n/** Outbound HTTP requests with a timeout, a status check and JSON parsing. */\nexport const HttpClient = createAbstraction<IHttpClient>(\"HttpClient\");\n\nexport namespace HttpClient {\n export type Interface = IHttpClient;\n export type Request = IHttpClientRequest;\n export type Method = HttpMethod;\n export type Error = HttpClientError;\n}\n"],"names":["HttpClient","createAbstraction"],"mappings":";AA+BO,MAAMA,aAAaC,kBAA+B"}
@@ -0,0 +1,4 @@
1
+ export declare const HttpClientFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { HttpClient } from "./HttpClient.js";
3
+ const HttpClientFeature = createFeature({
4
+ name: "HttpClientFeature",
5
+ register (container) {
6
+ container.register(HttpClient).inSingletonScope();
7
+ }
8
+ });
9
+ export { HttpClientFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/httpClient/feature.js","sources":["../../../src/features/httpClient/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { HttpClient } from \"./HttpClient.js\";\n\nexport const HttpClientFeature = createFeature({\n name: \"HttpClientFeature\",\n register(container) {\n container.register(HttpClient).inSingletonScope();\n }\n});\n"],"names":["HttpClientFeature","createFeature","container","HttpClient"],"mappings":";;AAGO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,YAAY,gBAAgB;IACnD;AACJ"}
@@ -0,0 +1,3 @@
1
+ export { HttpClient } from "./abstractions.js";
2
+ export { HttpRequestError } from "./HttpRequestError.js";
3
+ export { HttpStatusError } from "./HttpStatusError.js";
@@ -0,0 +1,3 @@
1
+ export { HttpClient } from "./abstractions.js";
2
+ export { HttpRequestError } from "./HttpRequestError.js";
3
+ export { HttpStatusError } from "./HttpStatusError.js";
@@ -0,0 +1,14 @@
1
+ import { RawAssumePermissions as Abstraction } from "./abstractions.js";
2
+ /**
3
+ * Per-request holder for the transport-extracted preview target. Registered per request, so a
4
+ * fresh instance holds the value for the current request only.
5
+ */
6
+ declare class RawAssumePermissionsImpl implements Abstraction.Interface {
7
+ private value;
8
+ get(): Abstraction.Target | null;
9
+ set(value: Abstraction.Target | null): void;
10
+ }
11
+ export declare const RawAssumePermissions: typeof RawAssumePermissionsImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IRawAssumePermissions>;
13
+ };
14
+ export {};
@@ -0,0 +1,19 @@
1
+ import { RawAssumePermissions } from "./abstractions.js";
2
+ class RawAssumePermissionsImpl {
3
+ get() {
4
+ return this.value;
5
+ }
6
+ set(value) {
7
+ this.value = value;
8
+ }
9
+ constructor(){
10
+ this.value = null;
11
+ }
12
+ }
13
+ const RawAssumePermissions_RawAssumePermissions = RawAssumePermissions.createImplementation({
14
+ implementation: RawAssumePermissionsImpl,
15
+ dependencies: []
16
+ });
17
+ export { RawAssumePermissions_RawAssumePermissions as RawAssumePermissions };
18
+
19
+ //# sourceMappingURL=RawAssumePermissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/requestContext/RawAssumePermissions.js","sources":["../../../src/features/requestContext/RawAssumePermissions.ts"],"sourcesContent":["import { RawAssumePermissions as Abstraction } from \"./abstractions.js\";\n\n/**\n * Per-request holder for the transport-extracted preview target. Registered per request, so a\n * fresh instance holds the value for the current request only.\n */\nclass RawAssumePermissionsImpl implements Abstraction.Interface {\n private value: Abstraction.Target | null = null;\n\n get(): Abstraction.Target | null {\n return this.value;\n }\n\n set(value: Abstraction.Target | null): void {\n this.value = value;\n }\n}\n\nexport const RawAssumePermissions = Abstraction.createImplementation({\n implementation: RawAssumePermissionsImpl,\n dependencies: []\n});\n"],"names":["RawAssumePermissionsImpl","value","RawAssumePermissions","Abstraction"],"mappings":";AAMA,MAAMA;IAGF,MAAiC;QAC7B,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAIC,KAAgC,EAAQ;QACxC,IAAI,CAAC,KAAK,GAAGA;IACjB;;aARQ,KAAK,GAA8B;;AAS/C;AAEO,MAAMC,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -29,6 +29,28 @@ export declare const RawAuthToken: import("@webiny/di").Abstraction<IRawAuthToke
29
29
  export declare namespace RawAuthToken {
30
30
  type Interface = IRawAuthToken;
31
31
  }
32
+ /**
33
+ * Per-request holder for the role or team the caller asked to be evaluated as, EXTRACTED by the
34
+ * transport from the `x-webiny-assume-permissions` header. This is a preview mechanism: it can
35
+ * only ever narrow what a caller may do, never widen it. AssumedPermissions reads this holder and
36
+ * substitutes the permission set, but only after confirming the caller's own permissions grant
37
+ * full access.
38
+ *
39
+ * Note: only the HTTP transports set this. S3 and background tasks have no caller to preview as.
40
+ */
41
+ export interface IAssumePermissionsTarget {
42
+ type: "role" | "team";
43
+ id: string;
44
+ }
45
+ export interface IRawAssumePermissions {
46
+ get(): IAssumePermissionsTarget | null;
47
+ set(value: IAssumePermissionsTarget | null): void;
48
+ }
49
+ export declare const RawAssumePermissions: import("@webiny/di").Abstraction<IRawAssumePermissions>;
50
+ export declare namespace RawAssumePermissions {
51
+ type Interface = IRawAssumePermissions;
52
+ type Target = IAssumePermissionsTarget;
53
+ }
32
54
  /**
33
55
  * LOAD step: authenticates the token held by RawAuthToken and sets IdentityContext. Fully
34
56
  * transport-agnostic — transports only EXTRACT the token into RawAuthToken.
@@ -1,8 +1,9 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
2
  const RawTenantId = createAbstraction("RequestContext/RawTenantId");
3
3
  const RawAuthToken = createAbstraction("RequestContext/RawAuthToken");
4
+ const RawAssumePermissions = createAbstraction("RequestContext/RawAssumePermissions");
4
5
  const RequestIdentityLoader = createAbstraction("RequestContext/RequestIdentityLoader");
5
6
  const RequestTenantLoader = createAbstraction("RequestContext/RequestTenantLoader");
6
- export { RawAuthToken, RawTenantId, RequestIdentityLoader, RequestTenantLoader };
7
+ export { RawAssumePermissions, RawAuthToken, RawTenantId, RequestIdentityLoader, RequestTenantLoader };
7
8
 
8
9
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/requestContext/abstractions.js","sources":["../../../src/features/requestContext/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\n/**\n * Per-request holder for the raw tenant id EXTRACTED by the transport (e.g. the `x-tenant` header\n * of an API Gateway event, the bucket name of an S3 event, or `payload.tenant` of a background\n * task). The transport-specific EXTRACT step sets this; the transport-agnostic LOAD step\n * (RequestTenantLoader) reads it, resolves the Tenant, and sets TenantContext.\n */\nexport interface IRawTenantId {\n get(): string | null;\n set(id: string | null): void;\n}\n\nexport const RawTenantId = createAbstraction<IRawTenantId>(\"RequestContext/RawTenantId\");\n\nexport namespace RawTenantId {\n export type Interface = IRawTenantId;\n}\n\n/**\n * Per-request holder for the raw auth token EXTRACTED by the transport (e.g. the `Authorization`\n * bearer header or an auth cookie of an API Gateway event). Only token-based transports set this;\n * the transport-agnostic LOAD step (RequestIdentityLoader) reads it, authenticates it, and\n * sets IdentityContext. A null/absent value authenticates as anonymous.\n *\n * Note: non-token transports (S3, background tasks) never set this — S3 has no user identity, and\n * background-task identity is derived from `task.createdBy` after the task is fetched.\n */\nexport interface IRawAuthToken {\n get(): string | null;\n set(token: string | null): void;\n}\n\nexport const RawAuthToken = createAbstraction<IRawAuthToken>(\"RequestContext/RawAuthToken\");\n\nexport namespace RawAuthToken {\n export type Interface = IRawAuthToken;\n}\n\n/**\n * LOAD step: authenticates the token held by RawAuthToken and sets IdentityContext. Fully\n * transport-agnostic — transports only EXTRACT the token into RawAuthToken.\n */\nexport interface IRequestIdentityLoader {\n establish(): Promise<void>;\n}\n\nexport const RequestIdentityLoader = createAbstraction<IRequestIdentityLoader>(\n \"RequestContext/RequestIdentityLoader\"\n);\n\nexport namespace RequestIdentityLoader {\n export type Interface = IRequestIdentityLoader;\n}\n\n/**\n * LOAD step: resolves the Tenant for the id held by RawTenantId and sets TenantContext. Fully\n * transport-agnostic — transports only EXTRACT the id into RawTenantId.\n */\nexport interface IRequestTenantLoader {\n establish(): Promise<void>;\n}\n\nexport const RequestTenantLoader = createAbstraction<IRequestTenantLoader>(\n \"RequestContext/RequestTenantLoader\"\n);\n\nexport namespace RequestTenantLoader {\n export type Interface = IRequestTenantLoader;\n}\n"],"names":["RawTenantId","createAbstraction","RawAuthToken","RequestIdentityLoader","RequestTenantLoader"],"mappings":";AAaO,MAAMA,cAAcC,kBAAgC;AAoBpD,MAAMC,eAAeD,kBAAiC;AActD,MAAME,wBAAwBF,kBACjC;AAeG,MAAMG,sBAAsBH,kBAC/B"}
1
+ {"version":3,"file":"features/requestContext/abstractions.js","sources":["../../../src/features/requestContext/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\n/**\n * Per-request holder for the raw tenant id EXTRACTED by the transport (e.g. the `x-tenant` header\n * of an API Gateway event, the bucket name of an S3 event, or `payload.tenant` of a background\n * task). The transport-specific EXTRACT step sets this; the transport-agnostic LOAD step\n * (RequestTenantLoader) reads it, resolves the Tenant, and sets TenantContext.\n */\nexport interface IRawTenantId {\n get(): string | null;\n set(id: string | null): void;\n}\n\nexport const RawTenantId = createAbstraction<IRawTenantId>(\"RequestContext/RawTenantId\");\n\nexport namespace RawTenantId {\n export type Interface = IRawTenantId;\n}\n\n/**\n * Per-request holder for the raw auth token EXTRACTED by the transport (e.g. the `Authorization`\n * bearer header or an auth cookie of an API Gateway event). Only token-based transports set this;\n * the transport-agnostic LOAD step (RequestIdentityLoader) reads it, authenticates it, and\n * sets IdentityContext. A null/absent value authenticates as anonymous.\n *\n * Note: non-token transports (S3, background tasks) never set this — S3 has no user identity, and\n * background-task identity is derived from `task.createdBy` after the task is fetched.\n */\nexport interface IRawAuthToken {\n get(): string | null;\n set(token: string | null): void;\n}\n\nexport const RawAuthToken = createAbstraction<IRawAuthToken>(\"RequestContext/RawAuthToken\");\n\nexport namespace RawAuthToken {\n export type Interface = IRawAuthToken;\n}\n\n/**\n * Per-request holder for the role or team the caller asked to be evaluated as, EXTRACTED by the\n * transport from the `x-webiny-assume-permissions` header. This is a preview mechanism: it can\n * only ever narrow what a caller may do, never widen it. AssumedPermissions reads this holder and\n * substitutes the permission set, but only after confirming the caller's own permissions grant\n * full access.\n *\n * Note: only the HTTP transports set this. S3 and background tasks have no caller to preview as.\n */\nexport interface IAssumePermissionsTarget {\n /*\n * Whose permissions to assume. A team is a set of roles, so assuming one means the union of its\n * roles' permissions. Assuming a user's permissions would be another type here, resolved to\n * that user's roles and teams the same way.\n */\n type: \"role\" | \"team\";\n id: string;\n}\n\nexport interface IRawAssumePermissions {\n get(): IAssumePermissionsTarget | null;\n set(value: IAssumePermissionsTarget | null): void;\n}\n\nexport const RawAssumePermissions = createAbstraction<IRawAssumePermissions>(\n \"RequestContext/RawAssumePermissions\"\n);\n\nexport namespace RawAssumePermissions {\n export type Interface = IRawAssumePermissions;\n export type Target = IAssumePermissionsTarget;\n}\n\n/**\n * LOAD step: authenticates the token held by RawAuthToken and sets IdentityContext. Fully\n * transport-agnostic — transports only EXTRACT the token into RawAuthToken.\n */\nexport interface IRequestIdentityLoader {\n establish(): Promise<void>;\n}\n\nexport const RequestIdentityLoader = createAbstraction<IRequestIdentityLoader>(\n \"RequestContext/RequestIdentityLoader\"\n);\n\nexport namespace RequestIdentityLoader {\n export type Interface = IRequestIdentityLoader;\n}\n\n/**\n * LOAD step: resolves the Tenant for the id held by RawTenantId and sets TenantContext. Fully\n * transport-agnostic — transports only EXTRACT the id into RawTenantId.\n */\nexport interface IRequestTenantLoader {\n establish(): Promise<void>;\n}\n\nexport const RequestTenantLoader = createAbstraction<IRequestTenantLoader>(\n \"RequestContext/RequestTenantLoader\"\n);\n\nexport namespace RequestTenantLoader {\n export type Interface = IRequestTenantLoader;\n}\n"],"names":["RawTenantId","createAbstraction","RawAuthToken","RawAssumePermissions","RequestIdentityLoader","RequestTenantLoader"],"mappings":";AAaO,MAAMA,cAAcC,kBAAgC;AAoBpD,MAAMC,eAAeD,kBAAiC;AA8BtD,MAAME,uBAAuBF,kBAChC;AAgBG,MAAMG,wBAAwBH,kBACjC;AAeG,MAAMI,sBAAsBJ,kBAC/B"}
@@ -0,0 +1,14 @@
1
+ import { RawAssumePermissions } from "./abstractions.js";
2
+ export declare const ASSUME_PERMISSIONS_HEADER = "x-webiny-assume-permissions";
3
+ type HeaderValue = string | string[] | undefined;
4
+ type Headers = Record<string, HeaderValue> | undefined;
5
+ /**
6
+ * Reads the `x-webiny-assume-permissions` header and parses it into the role or team whose
7
+ * permissions should be previewed. The value is `role:<id>` or `team:<id>`.
8
+ *
9
+ * Anything else parses to null, which leaves the caller's own permissions untouched. Lives in
10
+ * api-core rather than in a transport package so the HTTP transports cannot drift on the format or
11
+ * on header casing.
12
+ */
13
+ export declare function extractAssumePermissions(headers: Headers): RawAssumePermissions.Target | null;
14
+ export {};
@@ -0,0 +1,32 @@
1
+ const ASSUME_PERMISSIONS_HEADER = "x-webiny-assume-permissions";
2
+ function readHeader(headers, name) {
3
+ if (!headers) return null;
4
+ for (const key of Object.keys(headers)){
5
+ if (key.toLowerCase() !== name) continue;
6
+ const value = headers[key];
7
+ if (Array.isArray(value)) return value[0] ?? null;
8
+ return value ?? null;
9
+ }
10
+ return null;
11
+ }
12
+ function extractAssumePermissions(headers) {
13
+ const value = readHeader(headers, ASSUME_PERMISSIONS_HEADER);
14
+ if (!value) return null;
15
+ const separatorIndex = value.indexOf(":");
16
+ if (separatorIndex < 1) return null;
17
+ const type = value.slice(0, separatorIndex).trim();
18
+ const id = value.slice(separatorIndex + 1).trim();
19
+ if ("" === id) return null;
20
+ if ("role" === type) return {
21
+ type: "role",
22
+ id
23
+ };
24
+ if ("team" === type) return {
25
+ type: "team",
26
+ id
27
+ };
28
+ return null;
29
+ }
30
+ export { ASSUME_PERMISSIONS_HEADER, extractAssumePermissions };
31
+
32
+ //# sourceMappingURL=extractAssumePermissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/requestContext/extractAssumePermissions.js","sources":["../../../src/features/requestContext/extractAssumePermissions.ts"],"sourcesContent":["import { RawAssumePermissions } from \"./abstractions.js\";\n\nexport const ASSUME_PERMISSIONS_HEADER = \"x-webiny-assume-permissions\";\n\ntype HeaderValue = string | string[] | undefined;\ntype Headers = Record<string, HeaderValue> | undefined;\n\nfunction readHeader(headers: Headers, name: string): string | null {\n if (!headers) {\n return null;\n }\n\n /*\n * Header names are case-insensitive, and the casing that reaches us depends on the transport\n * and on the client, so match on the lowercased key rather than guessing a spelling. Node's\n * IncomingMessage also hands back an array when a header repeats.\n */\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() !== name) {\n continue;\n }\n\n const value = headers[key];\n if (Array.isArray(value)) {\n return value[0] ?? null;\n }\n\n return value ?? null;\n }\n\n return null;\n}\n\n/**\n * Reads the `x-webiny-assume-permissions` header and parses it into the role or team whose\n * permissions should be previewed. The value is `role:<id>` or `team:<id>`.\n *\n * Anything else parses to null, which leaves the caller's own permissions untouched. Lives in\n * api-core rather than in a transport package so the HTTP transports cannot drift on the format or\n * on header casing.\n */\nexport function extractAssumePermissions(headers: Headers): RawAssumePermissions.Target | null {\n const value = readHeader(headers, ASSUME_PERMISSIONS_HEADER);\n if (!value) {\n return null;\n }\n\n const separatorIndex = value.indexOf(\":\");\n if (separatorIndex < 1) {\n return null;\n }\n\n const type = value.slice(0, separatorIndex).trim();\n const id = value.slice(separatorIndex + 1).trim();\n\n if (id === \"\") {\n return null;\n }\n\n if (type === \"role\") {\n return { type: \"role\", id };\n }\n\n if (type === \"team\") {\n return { type: \"team\", id };\n }\n\n return null;\n}\n"],"names":["ASSUME_PERMISSIONS_HEADER","readHeader","headers","name","key","Object","value","Array","extractAssumePermissions","separatorIndex","type","id"],"mappings":"AAEO,MAAMA,4BAA4B;AAKzC,SAASC,WAAWC,OAAgB,EAAEC,IAAY;IAC9C,IAAI,CAACD,SACD,OAAO;IAQX,KAAK,MAAME,OAAOC,OAAO,IAAI,CAACH,SAAU;QACpC,IAAIE,IAAI,WAAW,OAAOD,MACtB;QAGJ,MAAMG,QAAQJ,OAAO,CAACE,IAAI;QAC1B,IAAIG,MAAM,OAAO,CAACD,QACd,OAAOA,KAAK,CAAC,EAAE,IAAI;QAGvB,OAAOA,SAAS;IACpB;IAEA,OAAO;AACX;AAUO,SAASE,yBAAyBN,OAAgB;IACrD,MAAMI,QAAQL,WAAWC,SAASF;IAClC,IAAI,CAACM,OACD,OAAO;IAGX,MAAMG,iBAAiBH,MAAM,OAAO,CAAC;IACrC,IAAIG,iBAAiB,GACjB,OAAO;IAGX,MAAMC,OAAOJ,MAAM,KAAK,CAAC,GAAGG,gBAAgB,IAAI;IAChD,MAAME,KAAKL,MAAM,KAAK,CAACG,iBAAiB,GAAG,IAAI;IAE/C,IAAIE,AAAO,OAAPA,IACA,OAAO;IAGX,IAAID,AAAS,WAATA,MACA,OAAO;QAAE,MAAM;QAAQC;IAAG;IAG9B,IAAID,AAAS,WAATA,MACA,OAAO;QAAE,MAAM;QAAQC;IAAG;IAG9B,OAAO;AACX"}
@@ -1,7 +1,8 @@
1
1
  import type { Container } from "@webiny/di";
2
2
  /**
3
3
  * Registers the request-context pieces:
4
- * - RawTenantId / RawAuthToken: per-request holders that the transport's EXTRACT step writes to.
4
+ * - RawTenantId / RawAuthToken / RawAssumePermissions: per-request holders that the transport's
5
+ * EXTRACT step writes to.
5
6
  * - RequestIdentityLoader / RequestTenantLoader: transport-agnostic LOAD steps that read
6
7
  * the holders and set IdentityContext / TenantContext.
7
8
  */
@@ -1,6 +1,7 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { RawTenantId } from "./RawTenantId.js";
3
3
  import { RawAuthToken } from "./RawAuthToken.js";
4
+ import { RawAssumePermissions } from "./RawAssumePermissions.js";
4
5
  import { RequestIdentityLoader } from "./RequestIdentityLoader.js";
5
6
  import { RequestTenantLoader } from "./RequestTenantLoader.js";
6
7
  const RequestContextFeature = createFeature({
@@ -8,6 +9,7 @@ const RequestContextFeature = createFeature({
8
9
  register (container) {
9
10
  container.register(RawTenantId).inSingletonScope();
10
11
  container.register(RawAuthToken).inSingletonScope();
12
+ container.register(RawAssumePermissions).inSingletonScope();
11
13
  container.register(RequestIdentityLoader);
12
14
  container.register(RequestTenantLoader);
13
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/requestContext/feature.js","sources":["../../../src/features/requestContext/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { Container } from \"@webiny/di\";\nimport { RawTenantId } from \"./RawTenantId.js\";\nimport { RawAuthToken } from \"./RawAuthToken.js\";\nimport { RequestIdentityLoader } from \"./RequestIdentityLoader.js\";\nimport { RequestTenantLoader } from \"./RequestTenantLoader.js\";\n\n/**\n * Registers the request-context pieces:\n * - RawTenantId / RawAuthToken: per-request holders that the transport's EXTRACT step writes to.\n * - RequestIdentityLoader / RequestTenantLoader: transport-agnostic LOAD steps that read\n * the holders and set IdentityContext / TenantContext.\n */\nexport const RequestContextFeature = createFeature({\n name: \"RequestContext\",\n register(container: Container) {\n // Singleton so the value the transport's EXTRACT step sets is the same instance the LOAD\n // establisher reads. Registered per request (RequestContextFeature runs per-request), so it's\n // singleton *within the request container* — a fresh holder per request.\n container.register(RawTenantId).inSingletonScope();\n container.register(RawAuthToken).inSingletonScope();\n container.register(RequestIdentityLoader);\n container.register(RequestTenantLoader);\n }\n});\n"],"names":["RequestContextFeature","createFeature","container","RawTenantId","RawAuthToken","RequestIdentityLoader","RequestTenantLoader"],"mappings":";;;;;AAaO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAoB;QAIzBA,UAAU,QAAQ,CAACC,aAAa,gBAAgB;QAChDD,UAAU,QAAQ,CAACE,cAAc,gBAAgB;QACjDF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;IACvB;AACJ"}
1
+ {"version":3,"file":"features/requestContext/feature.js","sources":["../../../src/features/requestContext/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { Container } from \"@webiny/di\";\nimport { RawTenantId } from \"./RawTenantId.js\";\nimport { RawAuthToken } from \"./RawAuthToken.js\";\nimport { RawAssumePermissions } from \"./RawAssumePermissions.js\";\nimport { RequestIdentityLoader } from \"./RequestIdentityLoader.js\";\nimport { RequestTenantLoader } from \"./RequestTenantLoader.js\";\n\n/**\n * Registers the request-context pieces:\n * - RawTenantId / RawAuthToken / RawAssumePermissions: per-request holders that the transport's\n * EXTRACT step writes to.\n * - RequestIdentityLoader / RequestTenantLoader: transport-agnostic LOAD steps that read\n * the holders and set IdentityContext / TenantContext.\n */\nexport const RequestContextFeature = createFeature({\n name: \"RequestContext\",\n register(container: Container) {\n // Singleton so the value the transport's EXTRACT step sets is the same instance the LOAD\n // establisher reads. Registered per request (RequestContextFeature runs per-request), so it's\n // singleton *within the request container* — a fresh holder per request.\n container.register(RawTenantId).inSingletonScope();\n container.register(RawAuthToken).inSingletonScope();\n container.register(RawAssumePermissions).inSingletonScope();\n container.register(RequestIdentityLoader);\n container.register(RequestTenantLoader);\n }\n});\n"],"names":["RequestContextFeature","createFeature","container","RawTenantId","RawAuthToken","RawAssumePermissions","RequestIdentityLoader","RequestTenantLoader"],"mappings":";;;;;;AAeO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAoB;QAIzBA,UAAU,QAAQ,CAACC,aAAa,gBAAgB;QAChDD,UAAU,QAAQ,CAACE,cAAc,gBAAgB;QACjDF,UAAU,QAAQ,CAACG,sBAAsB,gBAAgB;QACzDH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;IACvB;AACJ"}
@@ -1,2 +1,4 @@
1
- export { RawTenantId, RawAuthToken, RequestIdentityLoader, RequestTenantLoader } from "./abstractions.js";
1
+ export { RawTenantId, RawAuthToken, RawAssumePermissions, RequestIdentityLoader, RequestTenantLoader } from "./abstractions.js";
2
2
  export { RequestContextFeature } from "./feature.js";
3
+ export { ASSUME_PERMISSIONS_HEADER } from "./extractAssumePermissions.js";
4
+ export { extractAssumePermissions } from "./extractAssumePermissions.js";
@@ -1,2 +1,3 @@
1
- export { RawAuthToken, RawTenantId, RequestIdentityLoader, RequestTenantLoader } from "./abstractions.js";
1
+ export { RawAssumePermissions, RawAuthToken, RawTenantId, RequestIdentityLoader, RequestTenantLoader } from "./abstractions.js";
2
2
  export { RequestContextFeature } from "./feature.js";
3
+ export { ASSUME_PERMISSIONS_HEADER, extractAssumePermissions } from "./extractAssumePermissions.js";
@@ -2,12 +2,12 @@ import { IdentityContext as Abstraction } from "./abstractions.js";
2
2
  import { Identity } from "./Identity.js";
3
3
  import { AuthorizationContext } from "../authorization/AuthorizationContext/index.js";
4
4
  import type { SecurityPermission } from "../../../types/security.js";
5
- import { WcpContext } from "../../wcp/WcpContext/index.js";
5
+ import { FeatureFlags } from "../../featureFlags/abstractions.js";
6
6
  declare class IdentityContextImpl implements Abstraction.Interface {
7
7
  private authorizationContext;
8
- private wcpContext;
8
+ private featureFlags;
9
9
  private identity;
10
- constructor(authorizationContext: AuthorizationContext.Interface, wcpContext: WcpContext.Interface);
10
+ constructor(authorizationContext: AuthorizationContext.Interface, featureFlags: FeatureFlags.Interface);
11
11
  getIdentity(): Identity;
12
12
  setIdentity(identity: Identity | undefined): void;
13
13
  withIdentity<T>(identity: Identity | undefined, cb: () => Promise<T>): Promise<T>;
@@ -5,12 +5,12 @@ import { IdentityContext } from "./abstractions.js";
5
5
  import { AnonymousIdentity } from "./AnonymousIdentity.js";
6
6
  import { AuthorizationContext } from "../authorization/AuthorizationContext/index.js";
7
7
  import { filterOutCustomWbyAppsPermissions } from "../utils/filterOutCustomWbyAppsPermissions.js";
8
- import { WcpContext } from "../../wcp/WcpContext/index.js";
8
+ import { FeatureFlags } from "../../featureFlags/abstractions.js";
9
9
  const identityStorage = new AsyncLocalStorage();
10
10
  class IdentityContextImpl {
11
- constructor(authorizationContext, wcpContext){
11
+ constructor(authorizationContext, featureFlags){
12
12
  this.authorizationContext = authorizationContext;
13
- this.wcpContext = wcpContext;
13
+ this.featureFlags = featureFlags;
14
14
  this.identity = new AnonymousIdentity();
15
15
  }
16
16
  getIdentity() {
@@ -63,8 +63,8 @@ class IdentityContextImpl {
63
63
  return permissions.some((p)=>"*" === p.name);
64
64
  }
65
65
  applyAaclLogic(permissions) {
66
- const aaclEnabled = this.wcpContext.canUseAacl();
67
- const teamsEnabled = this.wcpContext.canUseTeams();
66
+ const aaclEnabled = this.featureFlags.get().isEnabled("advancedAccessControlLayer");
67
+ const teamsEnabled = this.featureFlags.get().isEnabled("advancedAccessControlLayer.teams");
68
68
  if (aaclEnabled) return [
69
69
  ...permissions,
70
70
  {
@@ -80,7 +80,7 @@ const IdentityContext_IdentityContext = createImplementation({
80
80
  implementation: IdentityContextImpl,
81
81
  dependencies: [
82
82
  AuthorizationContext,
83
- WcpContext
83
+ FeatureFlags
84
84
  ]
85
85
  });
86
86
  export { IdentityContext_IdentityContext as IdentityContext };