@webiny/api-core 6.4.11 → 6.6.0-alpha.1
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.
- package/ApiCoreFeature.d.ts +2 -2
- package/ApiCoreFeature.js +29 -5
- package/ApiCoreFeature.js.map +1 -1
- package/exports/api/security/api-key.d.ts +1 -0
- package/exports/api/security/api-key.js +1 -0
- package/exports/api.d.ts +3 -1
- package/exports/api.js +2 -1
- package/features/ai/Ai.d.ts +3 -3
- package/features/ai/Ai.js +60 -23
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +12 -0
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/OpenAiSdkFactory.js +16 -0
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
- package/features/ai/TextExtractor/abstractions.d.ts +12 -0
- package/features/ai/TextExtractor/abstractions.js +5 -0
- package/features/ai/TextExtractor/abstractions.js.map +1 -0
- package/features/ai/TextExtractor/index.d.ts +3 -0
- package/features/ai/TextExtractor/index.js +2 -0
- package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
- package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
- package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
- package/features/ai/abstractions.d.ts +18 -7
- package/features/ai/abstractions.js +1 -2
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/events.d.ts +59 -0
- package/features/ai/events.js +41 -0
- package/features/ai/events.js.map +1 -0
- package/features/ai/feature.js +6 -2
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +8 -2
- package/features/ai/index.js +4 -1
- package/features/ai/toolPipeline/AiOutputToolRegistry.d.ts +11 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.js +31 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.js.map +1 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.d.ts +10 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.js +36 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.js.map +1 -0
- package/features/ai/toolPipeline/abstractions.d.ts +23 -0
- package/features/ai/toolPipeline/abstractions.js +7 -0
- package/features/ai/toolPipeline/abstractions.js.map +1 -0
- package/features/ai/toolPipeline/index.d.ts +2 -0
- package/features/ai/toolPipeline/index.js +1 -0
- package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
- package/features/dateFormatter/DefaultDateFormatter.js +20 -0
- package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
- package/features/dateFormatter/abstractions.d.ts +13 -0
- package/features/dateFormatter/abstractions.js +5 -0
- package/features/dateFormatter/abstractions.js.map +1 -0
- package/features/dateFormatter/feature.d.ts +4 -0
- package/features/dateFormatter/feature.js +11 -0
- package/features/dateFormatter/feature.js.map +1 -0
- package/features/dateFormatter/index.d.ts +3 -0
- package/features/dateFormatter/index.js +2 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +49 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
- package/features/hashing/ScryptHasher.d.ts +11 -0
- package/features/hashing/ScryptHasher.js +74 -0
- package/features/hashing/ScryptHasher.js.map +1 -0
- package/features/hashing/abstractions.d.ts +18 -0
- package/features/hashing/abstractions.js +5 -0
- package/features/hashing/abstractions.js.map +1 -0
- package/features/hashing/feature.d.ts +4 -0
- package/features/hashing/feature.js +11 -0
- package/features/hashing/feature.js.map +1 -0
- package/features/hashing/index.d.ts +2 -0
- package/features/hashing/index.js +1 -0
- package/features/requestContext/RawAuthToken.d.ts +14 -0
- package/features/requestContext/RawAuthToken.js +19 -0
- package/features/requestContext/RawAuthToken.js.map +1 -0
- package/features/requestContext/RawTenantId.d.ts +14 -0
- package/features/requestContext/RawTenantId.js +19 -0
- package/features/requestContext/RawTenantId.js.map +1 -0
- package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
- package/features/requestContext/RequestIdentityLoader.js +26 -0
- package/features/requestContext/RequestIdentityLoader.js.map +1 -0
- package/features/requestContext/RequestTenantLoader.d.ts +18 -0
- package/features/requestContext/RequestTenantLoader.js +52 -0
- package/features/requestContext/RequestTenantLoader.js.map +1 -0
- package/features/requestContext/abstractions.d.ts +53 -0
- package/features/requestContext/abstractions.js +8 -0
- package/features/requestContext/abstractions.js.map +1 -0
- package/features/requestContext/feature.d.ts +11 -0
- package/features/requestContext/feature.js +17 -0
- package/features/requestContext/feature.js.map +1 -0
- package/features/requestContext/index.d.ts +2 -0
- package/features/requestContext/index.js +2 -0
- package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
- package/features/security/IdentityContext/IdentityContext.js +6 -6
- package/features/security/IdentityContext/IdentityContext.js.map +1 -1
- package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
- package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
- package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/feature.js +11 -2
- package/features/security/apiKeys/feature.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
- package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
- package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
- package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
- package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
- package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
- package/features/security/apiKeys/shared/generateToken.js.map +1 -1
- package/features/security/apiKeys/shared/schemas.d.ts +2 -2
- package/features/security/apiKeys/shared/schemas.js +2 -2
- package/features/security/apiKeys/shared/schemas.js.map +1 -1
- package/features/security/apiKeys/shared/types.d.ts +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +4 -4
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
- package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
- package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
- package/features/security/roles/CreateRole/schema.d.ts +1 -1
- package/features/security/roles/CreateRole/schema.js +1 -1
- package/features/security/roles/CreateRole/schema.js.map +1 -1
- package/features/security/roles/Installer/RolesInstaller.js +0 -1
- package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
- package/features/security/roles/UpdateRole/schema.d.ts +1 -1
- package/features/security/roles/UpdateRole/schema.js +1 -1
- package/features/security/roles/UpdateRole/schema.js.map +1 -1
- package/features/security/shared/description.d.ts +4 -0
- package/features/security/shared/description.js +7 -0
- package/features/security/shared/description.js.map +1 -0
- package/features/security/shared/index.d.ts +1 -0
- package/features/security/shared/index.js +1 -0
- package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
- package/features/security/teams/CreateTeam/schema.d.ts +1 -1
- package/features/security/teams/CreateTeam/schema.js +1 -1
- package/features/security/teams/CreateTeam/schema.js.map +1 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
- package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
- package/features/security/teams/UpdateTeam/schema.js +1 -1
- package/features/security/teams/UpdateTeam/schema.js.map +1 -1
- package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
- package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
- package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
- package/features/security/utils/getPermissionsFromRoles.d.ts +1 -1
- package/features/serviceDiscovery/ServiceDiscovery.d.ts +17 -0
- package/features/serviceDiscovery/ServiceDiscovery.js +22 -0
- package/features/serviceDiscovery/ServiceDiscovery.js.map +1 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.d.ts +1 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js +111 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js.map +1 -0
- package/features/serviceDiscovery/index.d.ts +3 -0
- package/features/serviceDiscovery/index.js +1 -0
- package/features/slugify/DefaultSlugify.d.ts +8 -0
- package/features/slugify/DefaultSlugify.js +20 -0
- package/features/slugify/DefaultSlugify.js.map +1 -0
- package/features/slugify/abstractions.d.ts +12 -0
- package/features/slugify/abstractions.js +5 -0
- package/features/slugify/abstractions.js.map +1 -0
- package/features/slugify/feature.d.ts +4 -0
- package/features/slugify/feature.js +11 -0
- package/features/slugify/feature.js.map +1 -0
- package/features/slugify/index.d.ts +3 -0
- package/features/slugify/index.js +2 -0
- package/features/storageOperations/abstractions.d.ts +21 -0
- package/features/storageOperations/abstractions.js +10 -0
- package/features/storageOperations/abstractions.js.map +1 -0
- package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
- package/features/stringFormatter/DefaultStringFormatter.js +19 -0
- package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
- package/features/stringFormatter/abstractions.d.ts +11 -0
- package/features/stringFormatter/abstractions.js +5 -0
- package/features/stringFormatter/abstractions.js.map +1 -0
- package/features/stringFormatter/feature.d.ts +4 -0
- package/features/stringFormatter/feature.js +13 -0
- package/features/stringFormatter/feature.js.map +1 -0
- package/features/stringFormatter/index.d.ts +3 -0
- package/features/stringFormatter/index.js +2 -0
- package/features/task/TaskDefinition/abstractions.d.ts +76 -4
- package/features/task/TaskDefinition/abstractions.js +2 -1
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/tenancy/CreateTenant/CreateTenantUseCase.d.ts +1 -1
- package/features/tenancy/InstallTenant/InstallTenantUseCase.d.ts +1 -1
- package/features/tenancy/UpdateTenant/UpdateTenantUseCase.d.ts +2 -2
- package/features/users/CreateUser/decorators/CreateUserWithWcpIncrement.d.ts +1 -1
- package/features/wcp/WcpContext/WcpContext.d.ts +10 -5
- package/features/wcp/WcpContext/WcpContext.js +23 -2
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +25 -7
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +57 -25
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/features/wcp/WcpContext/feature.d.ts +1 -2
- package/features/wcp/WcpContext/feature.js +2 -2
- package/features/wcp/WcpContext/feature.js.map +1 -1
- package/features/wcp/WcpContext/index.d.ts +0 -1
- package/features/wcp/WcpContext/types.d.ts +0 -4
- package/features/wcp/WcpFeature.d.ts +1 -1
- package/features/wcp/WcpFeature.js +7 -2
- package/features/wcp/WcpFeature.js.map +1 -1
- package/features/wcp/WcpLicenseLoader.d.ts +25 -0
- package/features/wcp/WcpLicenseLoader.js +58 -0
- package/features/wcp/WcpLicenseLoader.js.map +1 -0
- package/features/wcp/WcpLicenseProvider.d.ts +21 -0
- package/features/wcp/WcpLicenseProvider.js +14 -0
- package/features/wcp/WcpLicenseProvider.js.map +1 -0
- package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
- package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
- package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
- package/graphql/ApiCoreSchemaFactory.d.ts +15 -0
- package/graphql/ApiCoreSchemaFactory.js +52 -0
- package/graphql/ApiCoreSchemaFactory.js.map +1 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +9 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +49 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
- package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
- package/graphql/security/NotAuthorizedResponse.js +1 -1
- package/graphql/security/NotAuthorizedResponse.js.map +1 -1
- package/graphql/security/SecuritySchemaFactory.d.ts +14 -0
- package/graphql/security/SecuritySchemaFactory.js +23 -0
- package/graphql/security/SecuritySchemaFactory.js.map +1 -0
- package/graphql/security/addApiKeySchema.d.ts +2 -0
- package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
- package/graphql/security/addApiKeySchema.js.map +1 -0
- package/graphql/security/addIdentitySchema.d.ts +2 -0
- package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
- package/graphql/security/addIdentitySchema.js.map +1 -0
- package/graphql/security/addRoleSchema.d.ts +2 -0
- package/graphql/security/addRoleSchema.js +137 -0
- package/graphql/security/addRoleSchema.js.map +1 -0
- package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
- package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
- package/graphql/security/addSecurityBaseSchema.js.map +1 -0
- package/graphql/security/addTeamSchema.d.ts +2 -0
- package/graphql/security/addTeamSchema.js +157 -0
- package/graphql/security/addTeamSchema.js.map +1 -0
- package/graphql/system/SystemSchemaFactory.d.ts +9 -0
- package/graphql/system/SystemSchemaFactory.js +66 -0
- package/graphql/system/SystemSchemaFactory.js.map +1 -0
- package/graphql/users/UsersSchemaFactory.d.ts +9 -0
- package/graphql/users/UsersSchemaFactory.js +191 -0
- package/graphql/users/UsersSchemaFactory.js.map +1 -0
- package/graphql/wcp/WcpSchemaFactory.d.ts +9 -0
- package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +28 -18
- package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/package.json +21 -24
- package/testing/environment.d.ts +14 -0
- package/testing/environment.js +18 -0
- package/testing/environment.js.map +1 -0
- package/types/core.d.ts +17 -5
- package/types/security.d.ts +1 -7
- package/types/tenancy.d.ts +0 -17
- package/types/users.d.ts +0 -13
- package/createApiCore.d.ts +0 -7
- package/createApiCore.js +0 -22
- package/createApiCore.js.map +0 -1
- package/features/ai/AiModelRegistry.d.ts +0 -12
- package/features/ai/AiModelRegistry.js +0 -28
- package/features/ai/AiModelRegistry.js.map +0 -1
- package/graphql/security/apiKey.gql.d.ts +0 -4
- package/graphql/security/apiKey.gql.js.map +0 -1
- package/graphql/security/base.gql.d.ts +0 -4
- package/graphql/security/base.gql.js.map +0 -1
- package/graphql/security/identity.gql.d.ts +0 -4
- package/graphql/security/identity.gql.js.map +0 -1
- package/graphql/security/index.d.ts +0 -1
- package/graphql/security/index.js +0 -15
- package/graphql/security/index.js.map +0 -1
- package/graphql/security/role.gql.d.ts +0 -4
- package/graphql/security/role.gql.js +0 -106
- package/graphql/security/role.gql.js.map +0 -1
- package/graphql/security/team.gql.d.ts +0 -4
- package/graphql/security/team.gql.js +0 -119
- package/graphql/security/team.gql.js.map +0 -1
- package/graphql/system/createSystemGraphQL.d.ts +0 -2
- package/graphql/system/createSystemGraphQL.js +0 -54
- package/graphql/system/createSystemGraphQL.js.map +0 -1
- package/graphql/users/user.gql.d.ts +0 -3
- package/graphql/users/user.gql.js +0 -167
- package/graphql/users/user.gql.js.map +0 -1
- package/graphql/wcp/graphql.d.ts +0 -2
- package/graphql/wcp/graphql.js.map +0 -1
- package/legacy/security/LegacyContext.d.ts +0 -36
- package/legacy/security/LegacyContext.js +0 -152
- package/legacy/security/LegacyContext.js.map +0 -1
- package/legacy/security/createSecurityContext.d.ts +0 -3
- package/legacy/security/createSecurityContext.js +0 -10
- package/legacy/security/createSecurityContext.js.map +0 -1
- package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
- package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
- package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
- package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
- package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
- package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
- package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
- package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
- package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
- package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
- package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
- package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
- package/legacy/security/plugins/secureHeaders.d.ts +0 -1
- package/legacy/security/plugins/secureHeaders.js +0 -30
- package/legacy/security/plugins/secureHeaders.js.map +0 -1
- package/legacy/tenancy/LegacyContext.d.ts +0 -15
- package/legacy/tenancy/LegacyContext.js +0 -57
- package/legacy/tenancy/LegacyContext.js.map +0 -1
- package/legacy/tenancy/createTenancyContext.d.ts +0 -3
- package/legacy/tenancy/createTenancyContext.js +0 -31
- package/legacy/tenancy/createTenancyContext.js.map +0 -1
- package/legacy/users/LegacyContext.d.ts +0 -13
- package/legacy/users/LegacyContext.js +0 -55
- package/legacy/users/LegacyContext.js.map +0 -1
- package/legacy/users/createAdminUsersContext.d.ts +0 -3
- package/legacy/users/createAdminUsersContext.js +0 -12
- package/legacy/users/createAdminUsersContext.js.map +0 -1
- package/legacy/wcp/LegacyWcpContext.d.ts +0 -33
- package/legacy/wcp/LegacyWcpContext.js +0 -84
- package/legacy/wcp/LegacyWcpContext.js.map +0 -1
- package/legacy/wcp/context.d.ts +0 -5
- package/legacy/wcp/context.js +0 -46
- package/legacy/wcp/context.js.map +0 -1
|
@@ -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
|
-
declare const _default: ({ identityType }: Config) => ContextPlugin<ApiCoreContext>;
|
|
7
|
-
export default _default;
|
|
@@ -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,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,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"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Container } from "@webiny/di";
|
|
2
|
-
import type { CreateTenantInput, ListTenantsParams, Tenancy, Tenant } from "../../types/tenancy.js";
|
|
3
|
-
export declare class LegacyContext implements Tenancy {
|
|
4
|
-
private container;
|
|
5
|
-
constructor(container: Container);
|
|
6
|
-
createTenant(data: CreateTenantInput): Promise<Tenant>;
|
|
7
|
-
getCurrentTenant(): Tenant;
|
|
8
|
-
getRootTenant(): Promise<Tenant>;
|
|
9
|
-
getTenantById(id: string): Promise<Tenant>;
|
|
10
|
-
listTenants(params?: ListTenantsParams): Promise<Tenant[]>;
|
|
11
|
-
setCurrentTenant(tenant: Tenant): void;
|
|
12
|
-
withEachTenant<TReturn>(tenants: Tenant[], cb: (tenant: Tenant) => Promise<TReturn>): Promise<TReturn[]>;
|
|
13
|
-
withRootTenant<T>(cb: () => T): Promise<T>;
|
|
14
|
-
withTenant<TReturn>(tenant: Tenant, cb: (tenant: Tenant) => Promise<TReturn>): Promise<TReturn>;
|
|
15
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { CreateTenantUseCase } from "../../features/tenancy/CreateTenant/abstractions.js";
|
|
2
|
-
import { GetRootTenantUseCase } from "../../features/tenancy/GetRootTenant/abstractions.js";
|
|
3
|
-
import { GetTenantByIdUseCase } from "../../features/tenancy/GetTenantById/abstractions.js";
|
|
4
|
-
import { ListTenantsUseCase } from "../../features/tenancy/ListTenants/abstractions.js";
|
|
5
|
-
import { TenantContext } from "../../features/tenancy/TenantContext/abstractions.js";
|
|
6
|
-
class LegacyContext {
|
|
7
|
-
constructor(container){
|
|
8
|
-
this.container = container;
|
|
9
|
-
}
|
|
10
|
-
async createTenant(data) {
|
|
11
|
-
const useCase = this.container.resolve(CreateTenantUseCase);
|
|
12
|
-
const result = await useCase.execute(data);
|
|
13
|
-
if (result.isFail()) throw result.error;
|
|
14
|
-
return result.value;
|
|
15
|
-
}
|
|
16
|
-
getCurrentTenant() {
|
|
17
|
-
const tenantContext = this.container.resolve(TenantContext);
|
|
18
|
-
return tenantContext.getTenant();
|
|
19
|
-
}
|
|
20
|
-
async getRootTenant() {
|
|
21
|
-
const useCase = this.container.resolve(GetRootTenantUseCase);
|
|
22
|
-
const result = await useCase.execute();
|
|
23
|
-
if (result.isFail()) throw result.error;
|
|
24
|
-
return result.value;
|
|
25
|
-
}
|
|
26
|
-
async getTenantById(id) {
|
|
27
|
-
const useCase = this.container.resolve(GetTenantByIdUseCase);
|
|
28
|
-
const result = await useCase.execute(id);
|
|
29
|
-
if (result.isFail()) throw result.error;
|
|
30
|
-
return result.value;
|
|
31
|
-
}
|
|
32
|
-
async listTenants(params) {
|
|
33
|
-
const useCase = this.container.resolve(ListTenantsUseCase);
|
|
34
|
-
const result = await useCase.execute(params);
|
|
35
|
-
if (result.isFail()) throw result.error;
|
|
36
|
-
return result.value;
|
|
37
|
-
}
|
|
38
|
-
setCurrentTenant(tenant) {
|
|
39
|
-
const tenantContext = this.container.resolve(TenantContext);
|
|
40
|
-
tenantContext.setTenant(tenant);
|
|
41
|
-
}
|
|
42
|
-
async withEachTenant(tenants, cb) {
|
|
43
|
-
const tenantContext = this.container.resolve(TenantContext);
|
|
44
|
-
return tenantContext.withEachTenant(tenants, cb);
|
|
45
|
-
}
|
|
46
|
-
async withRootTenant(cb) {
|
|
47
|
-
const tenantContext = this.container.resolve(TenantContext);
|
|
48
|
-
return tenantContext.withRootTenant(cb);
|
|
49
|
-
}
|
|
50
|
-
async withTenant(tenant, cb) {
|
|
51
|
-
const tenantContext = this.container.resolve(TenantContext);
|
|
52
|
-
return tenantContext.withTenant(tenant, cb);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
export { LegacyContext };
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=LegacyContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy/tenancy/LegacyContext.js","sources":["../../../src/legacy/tenancy/LegacyContext.ts"],"sourcesContent":["import { Container } from \"@webiny/di\";\nimport type { CreateTenantInput, ListTenantsParams, Tenancy, Tenant } from \"~/types/tenancy.js\";\nimport { CreateTenantUseCase } from \"~/features/tenancy/CreateTenant/abstractions.js\";\nimport { GetRootTenantUseCase } from \"~/features/tenancy/GetRootTenant/abstractions.js\";\nimport { GetTenantByIdUseCase } from \"~/features/tenancy/GetTenantById/abstractions.js\";\nimport { ListTenantsUseCase } from \"~/features/tenancy/ListTenants/abstractions.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/abstractions.js\";\n\nexport class LegacyContext implements Tenancy {\n constructor(private container: Container) {}\n\n async createTenant(data: CreateTenantInput): Promise<Tenant> {\n const useCase = this.container.resolve(CreateTenantUseCase);\n const result = await useCase.execute(data);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n getCurrentTenant(): Tenant {\n const tenantContext = this.container.resolve(TenantContext);\n return tenantContext.getTenant();\n }\n\n async getRootTenant(): Promise<Tenant> {\n const useCase = this.container.resolve(GetRootTenantUseCase);\n const result = await useCase.execute();\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async getTenantById(id: string): Promise<Tenant> {\n const useCase = this.container.resolve(GetTenantByIdUseCase);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async listTenants(params?: ListTenantsParams): Promise<Tenant[]> {\n const useCase = this.container.resolve(ListTenantsUseCase);\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 setCurrentTenant(tenant: Tenant): void {\n const tenantContext = this.container.resolve(TenantContext);\n tenantContext.setTenant(tenant);\n }\n\n async withEachTenant<TReturn>(\n tenants: Tenant[],\n cb: (tenant: Tenant) => Promise<TReturn>\n ): Promise<TReturn[]> {\n const tenantContext = this.container.resolve(TenantContext);\n return tenantContext.withEachTenant(tenants, cb);\n }\n\n async withRootTenant<T>(cb: () => T): Promise<T> {\n const tenantContext = this.container.resolve(TenantContext);\n return tenantContext.withRootTenant(cb);\n }\n\n async withTenant<TReturn>(\n tenant: Tenant,\n cb: (tenant: Tenant) => Promise<TReturn>\n ): Promise<TReturn> {\n const tenantContext = this.container.resolve(TenantContext);\n return tenantContext.withTenant(tenant, cb);\n }\n}\n"],"names":["LegacyContext","container","data","useCase","CreateTenantUseCase","result","tenantContext","TenantContext","GetRootTenantUseCase","id","GetTenantByIdUseCase","params","ListTenantsUseCase","tenant","tenants","cb"],"mappings":";;;;;AAQO,MAAMA;IACT,YAAoBC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAE3C,MAAM,aAAaC,IAAuB,EAAmB;QACzD,MAAMC,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QACvC,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACD;QAErC,IAAIG,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;QAGtB,OAAOA,OAAO,KAAK;IACvB;IAEA,mBAA2B;QACvB,MAAMC,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC7C,OAAOD,cAAc,SAAS;IAClC;IAEA,MAAM,gBAAiC;QACnC,MAAMH,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACK;QACvC,MAAMH,SAAS,MAAMF,QAAQ,OAAO;QAEpC,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;QAGtB,OAAOA,OAAO,KAAK;IACvB;IAEA,MAAM,cAAcI,EAAU,EAAmB;QAC7C,MAAMN,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACO;QACvC,MAAML,SAAS,MAAMF,QAAQ,OAAO,CAACM;QAErC,IAAIJ,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;QAGtB,OAAOA,OAAO,KAAK;IACvB;IAEA,MAAM,YAAYM,MAA0B,EAAqB;QAC7D,MAAMR,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACS;QACvC,MAAMP,SAAS,MAAMF,QAAQ,OAAO,CAACQ;QAErC,IAAIN,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;QAGtB,OAAOA,OAAO,KAAK;IACvB;IAEA,iBAAiBQ,MAAc,EAAQ;QACnC,MAAMP,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC7CD,cAAc,SAAS,CAACO;IAC5B;IAEA,MAAM,eACFC,OAAiB,EACjBC,EAAwC,EACtB;QAClB,MAAMT,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC7C,OAAOD,cAAc,cAAc,CAACQ,SAASC;IACjD;IAEA,MAAM,eAAkBA,EAAW,EAAc;QAC7C,MAAMT,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC7C,OAAOD,cAAc,cAAc,CAACS;IACxC;IAEA,MAAM,WACFF,MAAc,EACdE,EAAwC,EACxB;QAChB,MAAMT,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC7C,OAAOD,cAAc,UAAU,CAACO,QAAQE;IAC5C;AACJ"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ContextPlugin } from "@webiny/api";
|
|
2
|
-
import { Request } from "@webiny/handler";
|
|
3
|
-
import { GetTenantByIdUseCase } from "../../features/tenancy/GetTenantById/index.js";
|
|
4
|
-
import { TenantContext } from "../../features/tenancy/TenantContext/index.js";
|
|
5
|
-
import { LegacyContext } from "./LegacyContext.js";
|
|
6
|
-
import { RootTenantValue } from "../../domain/tenancy/RootTenantValue.js";
|
|
7
|
-
const createTenancyContext = ()=>new ContextPlugin(async (context)=>{
|
|
8
|
-
let tenantId = "root";
|
|
9
|
-
const request = context.container.resolve(Request);
|
|
10
|
-
const multiTenancy = context.wcp.canUseFeature("multiTenancy");
|
|
11
|
-
if (!request) throw new Error("MISSING CONTEXT REQUEST");
|
|
12
|
-
if (multiTenancy) {
|
|
13
|
-
const { headers = {} } = request;
|
|
14
|
-
tenantId = headers["x-tenant"] ?? "root";
|
|
15
|
-
}
|
|
16
|
-
context.plugins.register({
|
|
17
|
-
type: "wcp-telemetry-tracker"
|
|
18
|
-
});
|
|
19
|
-
const getTenantById = context.container.resolve(GetTenantByIdUseCase);
|
|
20
|
-
const tenantContext = context.container.resolve(TenantContext);
|
|
21
|
-
const tenantResult = await getTenantById.execute(tenantId);
|
|
22
|
-
if (tenantResult.isOk()) tenantContext.setTenant(tenantResult.value);
|
|
23
|
-
else {
|
|
24
|
-
if ("root" !== tenantId) throw new Error("Unable to load tenant!");
|
|
25
|
-
tenantContext.setTenant(RootTenantValue.create());
|
|
26
|
-
}
|
|
27
|
-
context.tenancy = new LegacyContext(context.container);
|
|
28
|
-
});
|
|
29
|
-
export { createTenancyContext };
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=createTenancyContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy/tenancy/createTenancyContext.js","sources":["../../../src/legacy/tenancy/createTenancyContext.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { Request } from \"@webiny/handler\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { GetTenantByIdUseCase } from \"~/features/tenancy/GetTenantById/index.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\nimport { LegacyContext } from \"~/legacy/tenancy/LegacyContext.js\";\nimport { RootTenantValue } from \"~/domain/tenancy/RootTenantValue.js\";\n\nexport const createTenancyContext = () => {\n return new ContextPlugin<ApiCoreContext>(async context => {\n let tenantId = \"root\";\n\n const request = context.container.resolve(Request);\n\n const multiTenancy = context.wcp.canUseFeature(\"multiTenancy\");\n if (!request) {\n throw new Error(\"MISSING CONTEXT REQUEST\");\n }\n\n if (multiTenancy) {\n const { headers = {} } = request;\n\n tenantId = (headers[\"x-tenant\"] as string) ?? \"root\";\n }\n\n // Add WCP telemetry identifier\n // This tenancy package is used by GraphQL, Headless CMS, and PB import/export functions\n context.plugins.register({ type: \"wcp-telemetry-tracker\" });\n\n // We need to load tenant, and set the current tenant context.\n const getTenantById = context.container.resolve(GetTenantByIdUseCase);\n const tenantContext = context.container.resolve(TenantContext);\n\n const tenantResult = await getTenantById.execute(tenantId);\n if (tenantResult.isOk()) {\n tenantContext.setTenant(tenantResult.value);\n } else {\n // If there's no `root` tenant, it means system installation wasn't finished yet.\n // But all other tenants should throw an error.\n if (tenantId !== \"root\") {\n throw new Error(\"Unable to load tenant!\");\n }\n\n // Mock root tenant so the system can bootstrap\n tenantContext.setTenant(RootTenantValue.create());\n }\n\n // Set up legacy context. We use this API in many places across our codebase, and this will provide\n // a working bridge until everything is migrated to use DI container.\n context.tenancy = new LegacyContext(context.container);\n });\n};\n"],"names":["createTenancyContext","ContextPlugin","context","tenantId","request","Request","multiTenancy","Error","headers","getTenantById","GetTenantByIdUseCase","tenantContext","TenantContext","tenantResult","RootTenantValue","LegacyContext"],"mappings":";;;;;;AAQO,MAAMA,uBAAuB,IACzB,IAAIC,cAA8B,OAAMC;QAC3C,IAAIC,WAAW;QAEf,MAAMC,UAAUF,QAAQ,SAAS,CAAC,OAAO,CAACG;QAE1C,MAAMC,eAAeJ,QAAQ,GAAG,CAAC,aAAa,CAAC;QAC/C,IAAI,CAACE,SACD,MAAM,IAAIG,MAAM;QAGpB,IAAID,cAAc;YACd,MAAM,EAAEE,UAAU,CAAC,CAAC,EAAE,GAAGJ;YAEzBD,WAAYK,OAAO,CAAC,WAAW,IAAe;QAClD;QAIAN,QAAQ,OAAO,CAAC,QAAQ,CAAC;YAAE,MAAM;QAAwB;QAGzD,MAAMO,gBAAgBP,QAAQ,SAAS,CAAC,OAAO,CAACQ;QAChD,MAAMC,gBAAgBT,QAAQ,SAAS,CAAC,OAAO,CAACU;QAEhD,MAAMC,eAAe,MAAMJ,cAAc,OAAO,CAACN;QACjD,IAAIU,aAAa,IAAI,IACjBF,cAAc,SAAS,CAACE,aAAa,KAAK;aACvC;YAGH,IAAIV,AAAa,WAAbA,UACA,MAAM,IAAII,MAAM;YAIpBI,cAAc,SAAS,CAACG,gBAAgB,MAAM;QAClD;QAIAZ,QAAQ,OAAO,GAAG,IAAIa,cAAcb,QAAQ,SAAS;IACzD"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Container } from "@webiny/di";
|
|
2
|
-
import type { Team } from "../../types/security.js";
|
|
3
|
-
import type { AdminUsers, AdminUser, CreateUserInput, UpdateUserInput, GetUserParams, ListUsersParams } from "../../types/users.js";
|
|
4
|
-
export declare class LegacyContext implements AdminUsers {
|
|
5
|
-
private container;
|
|
6
|
-
constructor(container: Container);
|
|
7
|
-
getUser<TUser extends AdminUser = AdminUser>(params: GetUserParams): Promise<TUser>;
|
|
8
|
-
listUsers<TUser extends AdminUser = AdminUser>(params?: ListUsersParams): Promise<TUser[]>;
|
|
9
|
-
listUserTeams(id: string): Promise<Team[]>;
|
|
10
|
-
createUser<TUser extends AdminUser = AdminUser>(data: CreateUserInput): Promise<TUser>;
|
|
11
|
-
updateUser<TUser extends AdminUser = AdminUser>(id: string, data: UpdateUserInput): Promise<TUser>;
|
|
12
|
-
deleteUser(id: string): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { GetUserUseCase } from "../../features/users/GetUser/index.js";
|
|
2
|
-
import { ListUsersUseCase } from "../../features/users/ListUsers/index.js";
|
|
3
|
-
import { ListUserTeamsUseCase } from "../../features/users/ListUserTeams/index.js";
|
|
4
|
-
import { CreateUserUseCase } from "../../features/users/CreateUser/index.js";
|
|
5
|
-
import { UpdateUserUseCase } from "../../features/users/UpdateUser/index.js";
|
|
6
|
-
import { DeleteUserUseCase } from "../../features/users/DeleteUser/index.js";
|
|
7
|
-
class LegacyContext {
|
|
8
|
-
constructor(container){
|
|
9
|
-
this.container = container;
|
|
10
|
-
}
|
|
11
|
-
async getUser(params) {
|
|
12
|
-
const useCase = this.container.resolve(GetUserUseCase);
|
|
13
|
-
let input;
|
|
14
|
-
input = params.where.id ? {
|
|
15
|
-
id: params.where.id
|
|
16
|
-
} : {
|
|
17
|
-
email: params.where.email
|
|
18
|
-
};
|
|
19
|
-
const result = await useCase.execute(input);
|
|
20
|
-
if (result.isFail()) throw new Error(result.error.message);
|
|
21
|
-
return result.value;
|
|
22
|
-
}
|
|
23
|
-
async listUsers(params) {
|
|
24
|
-
const useCase = this.container.resolve(ListUsersUseCase);
|
|
25
|
-
const result = await useCase.execute(params);
|
|
26
|
-
if (result.isFail()) throw new Error(result.error.message);
|
|
27
|
-
return result.value;
|
|
28
|
-
}
|
|
29
|
-
async listUserTeams(id) {
|
|
30
|
-
const useCase = this.container.resolve(ListUserTeamsUseCase);
|
|
31
|
-
const result = await useCase.execute(id);
|
|
32
|
-
if (result.isFail()) throw new Error(result.error.message);
|
|
33
|
-
return result.value;
|
|
34
|
-
}
|
|
35
|
-
async createUser(data) {
|
|
36
|
-
const useCase = this.container.resolve(CreateUserUseCase);
|
|
37
|
-
const result = await useCase.execute(data);
|
|
38
|
-
if (result.isFail()) throw new Error(result.error.message);
|
|
39
|
-
return result.value;
|
|
40
|
-
}
|
|
41
|
-
async updateUser(id, data) {
|
|
42
|
-
const useCase = this.container.resolve(UpdateUserUseCase);
|
|
43
|
-
const result = await useCase.execute(id, data);
|
|
44
|
-
if (result.isFail()) throw new Error(result.error.message);
|
|
45
|
-
return result.value;
|
|
46
|
-
}
|
|
47
|
-
async deleteUser(id) {
|
|
48
|
-
const useCase = this.container.resolve(DeleteUserUseCase);
|
|
49
|
-
const result = await useCase.execute(id);
|
|
50
|
-
if (result.isFail()) throw new Error(result.error.message);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export { LegacyContext };
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=LegacyContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy/users/LegacyContext.js","sources":["../../../src/legacy/users/LegacyContext.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport type { Team } from \"~/types/security.js\";\nimport type {\n AdminUsers,\n AdminUser,\n CreateUserInput,\n UpdateUserInput,\n GetUserParams,\n ListUsersParams\n} from \"~/types/users.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\nimport { ListUserTeamsUseCase } from \"~/features/users/ListUserTeams/index.js\";\nimport { CreateUserUseCase } from \"~/features/users/CreateUser/index.js\";\nimport { UpdateUserUseCase } from \"~/features/users/UpdateUser/index.js\";\nimport { DeleteUserUseCase } from \"~/features/users/DeleteUser/index.js\";\nimport type { GetUserInput } from \"~/features/users/shared/types.js\";\n\nexport class LegacyContext implements AdminUsers {\n constructor(private container: Container) {}\n\n async getUser<TUser extends AdminUser = AdminUser>(params: GetUserParams): Promise<TUser> {\n const useCase = this.container.resolve(GetUserUseCase);\n let input: GetUserInput;\n if (params.where.id) {\n input = { id: params.where.id! };\n } else {\n input = { email: params.where.email! };\n }\n const result = await useCase.execute(input);\n\n if (result.isFail()) {\n throw new Error(result.error.message);\n }\n\n return result.value as TUser;\n }\n\n async listUsers<TUser extends AdminUser = AdminUser>(\n params?: ListUsersParams\n ): Promise<TUser[]> {\n const useCase = this.container.resolve(ListUsersUseCase);\n const result = await useCase.execute(params);\n\n if (result.isFail()) {\n throw new Error(result.error.message);\n }\n\n return result.value as TUser[];\n }\n\n async listUserTeams(id: string): Promise<Team[]> {\n const useCase = this.container.resolve(ListUserTeamsUseCase);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n throw new Error(result.error.message);\n }\n\n return result.value;\n }\n\n async createUser<TUser extends AdminUser = AdminUser>(data: CreateUserInput): Promise<TUser> {\n const useCase = this.container.resolve(CreateUserUseCase);\n const result = await useCase.execute(data);\n\n if (result.isFail()) {\n throw new Error(result.error.message);\n }\n\n return result.value as TUser;\n }\n\n async updateUser<TUser extends AdminUser = AdminUser>(\n id: string,\n data: UpdateUserInput\n ): Promise<TUser> {\n const useCase = this.container.resolve(UpdateUserUseCase);\n const result = await useCase.execute(id, data);\n\n if (result.isFail()) {\n throw new Error(result.error.message);\n }\n\n return result.value as TUser;\n }\n\n async deleteUser(id: string): Promise<void> {\n const useCase = this.container.resolve(DeleteUserUseCase);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n throw new Error(result.error.message);\n }\n }\n}\n"],"names":["LegacyContext","container","params","useCase","GetUserUseCase","input","result","Error","ListUsersUseCase","id","ListUserTeamsUseCase","data","CreateUserUseCase","UpdateUserUseCase","DeleteUserUseCase"],"mappings":";;;;;;AAkBO,MAAMA;IACT,YAAoBC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAE3C,MAAM,QAA6CC,MAAqB,EAAkB;QACtF,MAAMC,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QACvC,IAAIC;QAEAA,QADAH,OAAO,KAAK,CAAC,EAAE,GACP;YAAE,IAAIA,OAAO,KAAK,CAAC,EAAE;QAAE,IAEvB;YAAE,OAAOA,OAAO,KAAK,CAAC,KAAK;QAAE;QAEzC,MAAMI,SAAS,MAAMH,QAAQ,OAAO,CAACE;QAErC,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIC,MAAMD,OAAO,KAAK,CAAC,OAAO;QAGxC,OAAOA,OAAO,KAAK;IACvB;IAEA,MAAM,UACFJ,MAAwB,EACR;QAChB,MAAMC,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACK;QACvC,MAAMF,SAAS,MAAMH,QAAQ,OAAO,CAACD;QAErC,IAAII,OAAO,MAAM,IACb,MAAM,IAAIC,MAAMD,OAAO,KAAK,CAAC,OAAO;QAGxC,OAAOA,OAAO,KAAK;IACvB;IAEA,MAAM,cAAcG,EAAU,EAAmB;QAC7C,MAAMN,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACO;QACvC,MAAMJ,SAAS,MAAMH,QAAQ,OAAO,CAACM;QAErC,IAAIH,OAAO,MAAM,IACb,MAAM,IAAIC,MAAMD,OAAO,KAAK,CAAC,OAAO;QAGxC,OAAOA,OAAO,KAAK;IACvB;IAEA,MAAM,WAAgDK,IAAqB,EAAkB;QACzF,MAAMR,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACS;QACvC,MAAMN,SAAS,MAAMH,QAAQ,OAAO,CAACQ;QAErC,IAAIL,OAAO,MAAM,IACb,MAAM,IAAIC,MAAMD,OAAO,KAAK,CAAC,OAAO;QAGxC,OAAOA,OAAO,KAAK;IACvB;IAEA,MAAM,WACFG,EAAU,EACVE,IAAqB,EACP;QACd,MAAMR,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACU;QACvC,MAAMP,SAAS,MAAMH,QAAQ,OAAO,CAACM,IAAIE;QAEzC,IAAIL,OAAO,MAAM,IACb,MAAM,IAAIC,MAAMD,OAAO,KAAK,CAAC,OAAO;QAGxC,OAAOA,OAAO,KAAK;IACvB;IAEA,MAAM,WAAWG,EAAU,EAAiB;QACxC,MAAMN,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACW;QACvC,MAAMR,SAAS,MAAMH,QAAQ,OAAO,CAACM;QAErC,IAAIH,OAAO,MAAM,IACb,MAAM,IAAIC,MAAMD,OAAO,KAAK,CAAC,OAAO;IAE5C;AACJ"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ContextPlugin } from "@webiny/api";
|
|
2
|
-
import { LegacyContext } from "./LegacyContext.js";
|
|
3
|
-
import { createUsersGraphQL } from "../../graphql/users/user.gql.js";
|
|
4
|
-
const createAdminUsersContext = ()=>[
|
|
5
|
-
new ContextPlugin(async (context)=>{
|
|
6
|
-
context.adminUsers = new LegacyContext(context.container);
|
|
7
|
-
context.plugins.register(createUsersGraphQL());
|
|
8
|
-
})
|
|
9
|
-
];
|
|
10
|
-
export { createAdminUsersContext };
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=createAdminUsersContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy/users/createAdminUsersContext.js","sources":["../../../src/legacy/users/createAdminUsersContext.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { LegacyContext } from \"./LegacyContext.js\";\nimport { createUsersGraphQL } from \"~/graphql/users/user.gql.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\n\nexport const createAdminUsersContext = () => {\n return [\n new ContextPlugin<ApiCoreContext>(async context => {\n // Attach legacy context interface\n context.adminUsers = new LegacyContext(context.container);\n\n context.plugins.register(createUsersGraphQL());\n })\n ];\n};\n"],"names":["createAdminUsersContext","ContextPlugin","context","LegacyContext","createUsersGraphQL"],"mappings":";;;AAKO,MAAMA,0BAA0B,IAC5B;QACH,IAAIC,cAA8B,OAAMC;YAEpCA,QAAQ,UAAU,GAAG,IAAIC,cAAcD,QAAQ,SAAS;YAExDA,QAAQ,OAAO,CAAC,QAAQ,CAACE;QAC7B;KACH"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Container } from "@webiny/di";
|
|
2
|
-
import type { WCP_FEATURE_LABEL } from "@webiny/wcp";
|
|
3
|
-
import type { DecryptedWcpProjectLicense, ILicense, WcpProject, WcpProjectEnvironment } from "@webiny/wcp/types.js";
|
|
4
|
-
import { WcpContextObject } from "../../features/wcp/WcpContext/types.js";
|
|
5
|
-
export declare class LegacyWcpContext implements WcpContextObject {
|
|
6
|
-
private container;
|
|
7
|
-
constructor(container: Container);
|
|
8
|
-
private getWcpContext;
|
|
9
|
-
getRawLicense(): DecryptedWcpProjectLicense | null;
|
|
10
|
-
getProject(): WcpProject | null;
|
|
11
|
-
getProjectWithFeatureFlags(): WcpProject | null;
|
|
12
|
-
getProjectLicense(): ILicense;
|
|
13
|
-
getProjectEnvironment(): WcpProjectEnvironment | null;
|
|
14
|
-
canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean;
|
|
15
|
-
canUseAacl(): boolean;
|
|
16
|
-
canUseTeams(): boolean;
|
|
17
|
-
canUseFolderLevelPermissions(): boolean;
|
|
18
|
-
canUsePrivateFiles(): boolean;
|
|
19
|
-
canUseAuditLogs(): boolean;
|
|
20
|
-
canUseRecordLocking(): boolean;
|
|
21
|
-
canUseFileManagerThreatDetection(): boolean;
|
|
22
|
-
canUseWorkflows(): boolean;
|
|
23
|
-
canUseHcmsFieldPermissions(): boolean;
|
|
24
|
-
canUseAiImageEnrichment(): boolean;
|
|
25
|
-
canUseAiPageGeneration(): boolean;
|
|
26
|
-
canUseAiLexicalGeneration(): boolean;
|
|
27
|
-
ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL): void;
|
|
28
|
-
incrementSeats(): Promise<void>;
|
|
29
|
-
decrementSeats(): Promise<void>;
|
|
30
|
-
incrementTenants(): Promise<void>;
|
|
31
|
-
decrementTenants(): Promise<void>;
|
|
32
|
-
toDto(): DecryptedWcpProjectLicense | null;
|
|
33
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { WcpContext } from "../../features/wcp/WcpContext/index.js";
|
|
2
|
-
class LegacyWcpContext {
|
|
3
|
-
constructor(container){
|
|
4
|
-
this.container = container;
|
|
5
|
-
}
|
|
6
|
-
getWcpContext() {
|
|
7
|
-
return this.container.resolve(WcpContext);
|
|
8
|
-
}
|
|
9
|
-
getRawLicense() {
|
|
10
|
-
return this.getWcpContext().getRawLicense();
|
|
11
|
-
}
|
|
12
|
-
getProject() {
|
|
13
|
-
return this.getWcpContext().getProject();
|
|
14
|
-
}
|
|
15
|
-
getProjectWithFeatureFlags() {
|
|
16
|
-
return this.getWcpContext().getProjectWithFeatureFlags();
|
|
17
|
-
}
|
|
18
|
-
getProjectLicense() {
|
|
19
|
-
return this.getWcpContext().getProjectLicense();
|
|
20
|
-
}
|
|
21
|
-
getProjectEnvironment() {
|
|
22
|
-
return this.getWcpContext().getProjectEnvironment();
|
|
23
|
-
}
|
|
24
|
-
canUseFeature(wcpFeatureId) {
|
|
25
|
-
return this.getWcpContext().canUseFeature(wcpFeatureId);
|
|
26
|
-
}
|
|
27
|
-
canUseAacl() {
|
|
28
|
-
return this.getWcpContext().canUseAacl();
|
|
29
|
-
}
|
|
30
|
-
canUseTeams() {
|
|
31
|
-
return this.getWcpContext().canUseTeams();
|
|
32
|
-
}
|
|
33
|
-
canUseFolderLevelPermissions() {
|
|
34
|
-
return this.getWcpContext().canUseFolderLevelPermissions();
|
|
35
|
-
}
|
|
36
|
-
canUsePrivateFiles() {
|
|
37
|
-
return this.getWcpContext().canUsePrivateFiles();
|
|
38
|
-
}
|
|
39
|
-
canUseAuditLogs() {
|
|
40
|
-
return this.getWcpContext().canUseAuditLogs();
|
|
41
|
-
}
|
|
42
|
-
canUseRecordLocking() {
|
|
43
|
-
return this.getWcpContext().canUseRecordLocking();
|
|
44
|
-
}
|
|
45
|
-
canUseFileManagerThreatDetection() {
|
|
46
|
-
return this.getWcpContext().canUseFileManagerThreatDetection();
|
|
47
|
-
}
|
|
48
|
-
canUseWorkflows() {
|
|
49
|
-
return this.getWcpContext().canUseWorkflows();
|
|
50
|
-
}
|
|
51
|
-
canUseHcmsFieldPermissions() {
|
|
52
|
-
return this.getWcpContext().canUseHcmsFieldPermissions();
|
|
53
|
-
}
|
|
54
|
-
canUseAiImageEnrichment() {
|
|
55
|
-
return this.getWcpContext().canUseAiImageEnrichment();
|
|
56
|
-
}
|
|
57
|
-
canUseAiPageGeneration() {
|
|
58
|
-
return this.getWcpContext().canUseAiPageGeneration();
|
|
59
|
-
}
|
|
60
|
-
canUseAiLexicalGeneration() {
|
|
61
|
-
return this.getWcpContext().canUseAiLexicalGeneration();
|
|
62
|
-
}
|
|
63
|
-
ensureCanUseFeature(featureId) {
|
|
64
|
-
this.getWcpContext().ensureCanUseFeature(featureId);
|
|
65
|
-
}
|
|
66
|
-
async incrementSeats() {
|
|
67
|
-
await this.getWcpContext().incrementSeats();
|
|
68
|
-
}
|
|
69
|
-
async decrementSeats() {
|
|
70
|
-
await this.getWcpContext().decrementSeats();
|
|
71
|
-
}
|
|
72
|
-
async incrementTenants() {
|
|
73
|
-
await this.getWcpContext().incrementTenants();
|
|
74
|
-
}
|
|
75
|
-
async decrementTenants() {
|
|
76
|
-
await this.getWcpContext().decrementTenants();
|
|
77
|
-
}
|
|
78
|
-
toDto() {
|
|
79
|
-
return this.getWcpContext().toDto();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
export { LegacyWcpContext };
|
|
83
|
-
|
|
84
|
-
//# sourceMappingURL=LegacyWcpContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy/wcp/LegacyWcpContext.js","sources":["../../../src/legacy/wcp/LegacyWcpContext.ts"],"sourcesContent":["import { Container } from \"@webiny/di\";\nimport type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport type {\n DecryptedWcpProjectLicense,\n ILicense,\n WcpProject,\n WcpProjectEnvironment\n} from \"@webiny/wcp/types.js\";\nimport { WcpContextObject } from \"~/features/wcp/WcpContext/types.js\";\nimport { WcpContext } from \"~/features/wcp/WcpContext/index.js\";\n\nexport class LegacyWcpContext implements WcpContextObject {\n constructor(private container: Container) {}\n\n private getWcpContext(): WcpContext.Interface {\n return this.container.resolve(WcpContext);\n }\n\n getRawLicense(): DecryptedWcpProjectLicense | null {\n return this.getWcpContext().getRawLicense();\n }\n\n getProject(): WcpProject | null {\n return this.getWcpContext().getProject();\n }\n\n getProjectWithFeatureFlags(): WcpProject | null {\n return this.getWcpContext().getProjectWithFeatureFlags();\n }\n\n getProjectLicense(): ILicense {\n return this.getWcpContext().getProjectLicense();\n }\n\n getProjectEnvironment(): WcpProjectEnvironment | null {\n return this.getWcpContext().getProjectEnvironment();\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean {\n return this.getWcpContext().canUseFeature(wcpFeatureId);\n }\n\n canUseAacl(): boolean {\n return this.getWcpContext().canUseAacl();\n }\n\n canUseTeams(): boolean {\n return this.getWcpContext().canUseTeams();\n }\n\n canUseFolderLevelPermissions(): boolean {\n return this.getWcpContext().canUseFolderLevelPermissions();\n }\n\n canUsePrivateFiles(): boolean {\n return this.getWcpContext().canUsePrivateFiles();\n }\n\n canUseAuditLogs(): boolean {\n return this.getWcpContext().canUseAuditLogs();\n }\n\n canUseRecordLocking(): boolean {\n return this.getWcpContext().canUseRecordLocking();\n }\n\n canUseFileManagerThreatDetection(): boolean {\n return this.getWcpContext().canUseFileManagerThreatDetection();\n }\n\n canUseWorkflows(): boolean {\n return this.getWcpContext().canUseWorkflows();\n }\n\n canUseHcmsFieldPermissions(): boolean {\n return this.getWcpContext().canUseHcmsFieldPermissions();\n }\n\n canUseAiImageEnrichment(): boolean {\n return this.getWcpContext().canUseAiImageEnrichment();\n }\n\n canUseAiPageGeneration(): boolean {\n return this.getWcpContext().canUseAiPageGeneration();\n }\n\n canUseAiLexicalGeneration(): boolean {\n return this.getWcpContext().canUseAiLexicalGeneration();\n }\n\n ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL): void {\n this.getWcpContext().ensureCanUseFeature(featureId);\n }\n\n async incrementSeats(): Promise<void> {\n await this.getWcpContext().incrementSeats();\n }\n\n async decrementSeats(): Promise<void> {\n await this.getWcpContext().decrementSeats();\n }\n\n async incrementTenants(): Promise<void> {\n await this.getWcpContext().incrementTenants();\n }\n\n async decrementTenants(): Promise<void> {\n await this.getWcpContext().decrementTenants();\n }\n\n toDto(): DecryptedWcpProjectLicense | null {\n return this.getWcpContext().toDto();\n }\n}\n"],"names":["LegacyWcpContext","container","WcpContext","wcpFeatureId","featureId"],"mappings":";AAWO,MAAMA;IACT,YAAoBC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAEnC,gBAAsC;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;IAClC;IAEA,gBAAmD;QAC/C,OAAO,IAAI,CAAC,aAAa,GAAG,aAAa;IAC7C;IAEA,aAAgC;QAC5B,OAAO,IAAI,CAAC,aAAa,GAAG,UAAU;IAC1C;IAEA,6BAAgD;QAC5C,OAAO,IAAI,CAAC,aAAa,GAAG,0BAA0B;IAC1D;IAEA,oBAA8B;QAC1B,OAAO,IAAI,CAAC,aAAa,GAAG,iBAAiB;IACjD;IAEA,wBAAsD;QAClD,OAAO,IAAI,CAAC,aAAa,GAAG,qBAAqB;IACrD;IAEA,cAAcC,YAA4C,EAAW;QACjE,OAAO,IAAI,CAAC,aAAa,GAAG,aAAa,CAACA;IAC9C;IAEA,aAAsB;QAClB,OAAO,IAAI,CAAC,aAAa,GAAG,UAAU;IAC1C;IAEA,cAAuB;QACnB,OAAO,IAAI,CAAC,aAAa,GAAG,WAAW;IAC3C;IAEA,+BAAwC;QACpC,OAAO,IAAI,CAAC,aAAa,GAAG,4BAA4B;IAC5D;IAEA,qBAA8B;QAC1B,OAAO,IAAI,CAAC,aAAa,GAAG,kBAAkB;IAClD;IAEA,kBAA2B;QACvB,OAAO,IAAI,CAAC,aAAa,GAAG,eAAe;IAC/C;IAEA,sBAA+B;QAC3B,OAAO,IAAI,CAAC,aAAa,GAAG,mBAAmB;IACnD;IAEA,mCAA4C;QACxC,OAAO,IAAI,CAAC,aAAa,GAAG,gCAAgC;IAChE;IAEA,kBAA2B;QACvB,OAAO,IAAI,CAAC,aAAa,GAAG,eAAe;IAC/C;IAEA,6BAAsC;QAClC,OAAO,IAAI,CAAC,aAAa,GAAG,0BAA0B;IAC1D;IAEA,0BAAmC;QAC/B,OAAO,IAAI,CAAC,aAAa,GAAG,uBAAuB;IACvD;IAEA,yBAAkC;QAC9B,OAAO,IAAI,CAAC,aAAa,GAAG,sBAAsB;IACtD;IAEA,4BAAqC;QACjC,OAAO,IAAI,CAAC,aAAa,GAAG,yBAAyB;IACzD;IAEA,oBAAoBC,SAAyC,EAAQ;QACjE,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAACA;IAC7C;IAEA,MAAM,iBAAgC;QAClC,MAAM,IAAI,CAAC,aAAa,GAAG,cAAc;IAC7C;IAEA,MAAM,iBAAgC;QAClC,MAAM,IAAI,CAAC,aAAa,GAAG,cAAc;IAC7C;IAEA,MAAM,mBAAkC;QACpC,MAAM,IAAI,CAAC,aAAa,GAAG,gBAAgB;IAC/C;IAEA,MAAM,mBAAkC;QACpC,MAAM,IAAI,CAAC,aAAa,GAAG,gBAAgB;IAC/C;IAEA,QAA2C;QACvC,OAAO,IAAI,CAAC,aAAa,GAAG,KAAK;IACrC;AACJ"}
|
package/legacy/wcp/context.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { DecryptedWcpProjectLicense } from "@webiny/wcp/types.js";
|
|
2
|
-
export interface CreateWcpContextParams {
|
|
3
|
-
testProjectLicense?: DecryptedWcpProjectLicense;
|
|
4
|
-
}
|
|
5
|
-
export declare const createWcpContext: (params?: CreateWcpContextParams) => import("@webiny/handler/index.js").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>;
|
package/legacy/wcp/context.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { License, NullLicense, getWcpProjectEnvironment, getWcpProjectLicense } from "@webiny/wcp";
|
|
2
|
-
import { createRegisterExtensionPlugin } from "@webiny/handler/plugins/RegisterExtensionPlugin.js";
|
|
3
|
-
import { getWcpProjectLicenseCacheKey } from "../../features/wcp/WcpContext/utils.js";
|
|
4
|
-
import { WcpFeature } from "../../features/wcp/WcpFeature.js";
|
|
5
|
-
import { LegacyWcpContext } from "./LegacyWcpContext.js";
|
|
6
|
-
import { createWcpGraphQL } from "../../graphql/wcp/graphql.js";
|
|
7
|
-
const wcpProjectEnvironment = getWcpProjectEnvironment();
|
|
8
|
-
const cachedLicense = {
|
|
9
|
-
cacheKey: null,
|
|
10
|
-
project: null,
|
|
11
|
-
license: new NullLicense()
|
|
12
|
-
};
|
|
13
|
-
async function loadLicense(testProjectLicense) {
|
|
14
|
-
if (testProjectLicense) cachedLicense.license = License.fromLicenseDto(testProjectLicense);
|
|
15
|
-
else if (wcpProjectEnvironment) {
|
|
16
|
-
const currentCacheKey = getWcpProjectLicenseCacheKey();
|
|
17
|
-
if (cachedLicense.cacheKey !== currentCacheKey) {
|
|
18
|
-
cachedLicense.cacheKey = currentCacheKey;
|
|
19
|
-
const decryptedLicenseDto = await getWcpProjectLicense({
|
|
20
|
-
orgId: wcpProjectEnvironment.org.id,
|
|
21
|
-
projectId: wcpProjectEnvironment.project.id,
|
|
22
|
-
projectEnvironmentApiKey: wcpProjectEnvironment.apiKey
|
|
23
|
-
});
|
|
24
|
-
if (decryptedLicenseDto) cachedLicense.project = {
|
|
25
|
-
orgId: decryptedLicenseDto.orgId,
|
|
26
|
-
projectId: decryptedLicenseDto.projectId,
|
|
27
|
-
package: decryptedLicenseDto.package
|
|
28
|
-
};
|
|
29
|
-
cachedLicense.license = License.fromLicenseDto(decryptedLicenseDto);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return cachedLicense.license;
|
|
33
|
-
}
|
|
34
|
-
const createWcpContext = (params = {})=>{
|
|
35
|
-
const plugin = createRegisterExtensionPlugin(async (context)=>{
|
|
36
|
-
const license = await loadLicense(params.testProjectLicense);
|
|
37
|
-
WcpFeature.register(context.container, license);
|
|
38
|
-
context.wcp = new LegacyWcpContext(context.container);
|
|
39
|
-
context.plugins.register(createWcpGraphQL());
|
|
40
|
-
});
|
|
41
|
-
plugin.name = "wcp.context.create";
|
|
42
|
-
return plugin;
|
|
43
|
-
};
|
|
44
|
-
export { createWcpContext };
|
|
45
|
-
|
|
46
|
-
//# sourceMappingURL=context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy/wcp/context.js","sources":["../../../src/legacy/wcp/context.ts"],"sourcesContent":["import { getWcpProjectLicense, getWcpProjectEnvironment, NullLicense } from \"@webiny/wcp\";\nimport type { DecryptedWcpProjectLicense, ILicense } from \"@webiny/wcp/types.js\";\nimport { License } from \"@webiny/wcp\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler/plugins/RegisterExtensionPlugin.js\";\nimport type { CachedWcpProjectLicense } from \"~/features/wcp/WcpContext/types.js\";\nimport { getWcpProjectLicenseCacheKey } from \"~/features/wcp/WcpContext/utils.js\";\nimport { WcpFeature } from \"~/features/wcp/WcpFeature.js\";\nimport { LegacyWcpContext } from \"./LegacyWcpContext.js\";\nimport { createWcpGraphQL } from \"~/graphql/wcp/graphql.js\";\n\nconst wcpProjectEnvironment = getWcpProjectEnvironment();\n\nconst cachedLicense: CachedWcpProjectLicense = {\n cacheKey: null,\n project: null,\n license: new NullLicense()\n};\n\nasync function loadLicense(testProjectLicense?: DecryptedWcpProjectLicense): Promise<ILicense> {\n if (testProjectLicense) {\n cachedLicense.license = License.fromLicenseDto(testProjectLicense);\n } else if (wcpProjectEnvironment) {\n const currentCacheKey = getWcpProjectLicenseCacheKey();\n if (cachedLicense.cacheKey !== currentCacheKey) {\n cachedLicense.cacheKey = currentCacheKey;\n // Pull the project license from the WCP API.\n const decryptedLicenseDto = await getWcpProjectLicense({\n orgId: wcpProjectEnvironment.org.id,\n projectId: wcpProjectEnvironment.project.id,\n projectEnvironmentApiKey: wcpProjectEnvironment.apiKey\n });\n\n if (decryptedLicenseDto) {\n cachedLicense.project = {\n orgId: decryptedLicenseDto.orgId,\n projectId: decryptedLicenseDto.projectId,\n package: decryptedLicenseDto.package\n };\n }\n\n cachedLicense.license = License.fromLicenseDto(decryptedLicenseDto);\n }\n }\n\n return cachedLicense.license;\n}\n\nexport interface CreateWcpContextParams {\n testProjectLicense?: DecryptedWcpProjectLicense;\n}\n\nexport const createWcpContext = (params: CreateWcpContextParams = {}) => {\n const plugin = createRegisterExtensionPlugin(async context => {\n const license = await loadLicense(params.testProjectLicense);\n\n WcpFeature.register(context.container, license);\n\n // @ts-expect-error This is a legacy property\n context.wcp = new LegacyWcpContext(context.container);\n\n context.plugins.register(createWcpGraphQL());\n });\n\n plugin.name = \"wcp.context.create\";\n\n return plugin;\n};\n"],"names":["wcpProjectEnvironment","getWcpProjectEnvironment","cachedLicense","NullLicense","loadLicense","testProjectLicense","License","currentCacheKey","getWcpProjectLicenseCacheKey","decryptedLicenseDto","getWcpProjectLicense","createWcpContext","params","plugin","createRegisterExtensionPlugin","context","license","WcpFeature","LegacyWcpContext","createWcpGraphQL"],"mappings":";;;;;;AAUA,MAAMA,wBAAwBC;AAE9B,MAAMC,gBAAyC;IAC3C,UAAU;IACV,SAAS;IACT,SAAS,IAAIC;AACjB;AAEA,eAAeC,YAAYC,kBAA+C;IACtE,IAAIA,oBACAH,cAAc,OAAO,GAAGI,QAAQ,cAAc,CAACD;SAC5C,IAAIL,uBAAuB;QAC9B,MAAMO,kBAAkBC;QACxB,IAAIN,cAAc,QAAQ,KAAKK,iBAAiB;YAC5CL,cAAc,QAAQ,GAAGK;YAEzB,MAAME,sBAAsB,MAAMC,qBAAqB;gBACnD,OAAOV,sBAAsB,GAAG,CAAC,EAAE;gBACnC,WAAWA,sBAAsB,OAAO,CAAC,EAAE;gBAC3C,0BAA0BA,sBAAsB,MAAM;YAC1D;YAEA,IAAIS,qBACAP,cAAc,OAAO,GAAG;gBACpB,OAAOO,oBAAoB,KAAK;gBAChC,WAAWA,oBAAoB,SAAS;gBACxC,SAASA,oBAAoB,OAAO;YACxC;YAGJP,cAAc,OAAO,GAAGI,QAAQ,cAAc,CAACG;QACnD;IACJ;IAEA,OAAOP,cAAc,OAAO;AAChC;AAMO,MAAMS,mBAAmB,CAACC,SAAiC,CAAC,CAAC;IAChE,MAAMC,SAASC,8BAA8B,OAAMC;QAC/C,MAAMC,UAAU,MAAMZ,YAAYQ,OAAO,kBAAkB;QAE3DK,WAAW,QAAQ,CAACF,QAAQ,SAAS,EAAEC;QAGvCD,QAAQ,GAAG,GAAG,IAAIG,iBAAiBH,QAAQ,SAAS;QAEpDA,QAAQ,OAAO,CAAC,QAAQ,CAACI;IAC7B;IAEAN,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
|