@webiny/api-core 6.6.0-alpha.0 → 6.6.0-alpha.10
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.js +12 -2
- 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/tasks.d.ts +1 -0
- package/exports/api/tasks.js +1 -1
- package/exports/api.d.ts +1 -1
- package/exports/api.js +1 -1
- package/features/ai/Ai.d.ts +5 -1
- package/features/ai/Ai.js +72 -29
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AiModelRegistry.d.ts +14 -0
- package/features/ai/AiModelRegistry.js +39 -0
- package/features/ai/AiModelRegistry.js.map +1 -0
- package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
- package/features/ai/AiSdkToolHandlerResolver.js +19 -0
- package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
- package/features/ai/AiSdkTools.d.ts +4 -3
- package/features/ai/AiSdkTools.js +11 -9
- package/features/ai/AiSdkTools.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +24 -4
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/DEVELOPERS.md +183 -0
- package/features/ai/GoogleSdkFactory.d.ts +10 -0
- package/features/ai/GoogleSdkFactory.js +65 -0
- package/features/ai/GoogleSdkFactory.js.map +1 -0
- package/features/ai/OpenAiSdkFactory.js +67 -11
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
- package/features/ai/OpenRouterSdkFactory.js +112 -0
- package/features/ai/OpenRouterSdkFactory.js.map +1 -0
- package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
- package/features/ai/RemoteAiModelCatalog.js +74 -0
- package/features/ai/RemoteAiModelCatalog.js.map +1 -0
- 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 +102 -7
- package/features/ai/abstractions.js +6 -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 +12 -0
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +5 -3
- package/features/ai/index.js +3 -1
- 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/debugger/Debugger.d.ts +30 -0
- package/features/debugger/Debugger.js +142 -0
- package/features/debugger/Debugger.js.map +1 -0
- package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
- package/features/debugger/DebuggerRouteDecorator.js +102 -0
- package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
- package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
- package/features/debugger/GraphQLDebuggerTransport.js +45 -0
- package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
- package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
- package/features/debugger/__tests__/matchNamespace.test.js +68 -0
- package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
- package/features/debugger/__tests__/serialize.test.d.ts +1 -0
- package/features/debugger/__tests__/serialize.test.js +220 -0
- package/features/debugger/__tests__/serialize.test.js.map +1 -0
- package/features/debugger/abstractions.d.ts +100 -0
- package/features/debugger/abstractions.js +6 -0
- package/features/debugger/abstractions.js.map +1 -0
- package/features/debugger/feature.d.ts +5 -0
- package/features/debugger/feature.js +15 -0
- package/features/debugger/feature.js.map +1 -0
- package/features/debugger/index.d.ts +12 -0
- package/features/debugger/index.js +7 -0
- package/features/debugger/limits.d.ts +18 -0
- package/features/debugger/limits.js +11 -0
- package/features/debugger/limits.js.map +1 -0
- package/features/debugger/matchNamespace.d.ts +14 -0
- package/features/debugger/matchNamespace.js +35 -0
- package/features/debugger/matchNamespace.js.map +1 -0
- package/features/debugger/parseNamespaceHeader.d.ts +7 -0
- package/features/debugger/parseNamespaceHeader.js +16 -0
- package/features/debugger/parseNamespaceHeader.js.map +1 -0
- package/features/debugger/permissions.d.ts +14 -0
- package/features/debugger/permissions.js +8 -0
- package/features/debugger/permissions.js.map +1 -0
- package/features/debugger/permissionsSchema.d.ts +17 -0
- package/features/debugger/permissionsSchema.js +18 -0
- package/features/debugger/permissionsSchema.js.map +1 -0
- package/features/debugger/serialize.d.ts +11 -0
- package/features/debugger/serialize.js +121 -0
- package/features/debugger/serialize.js.map +1 -0
- package/features/encryption/BuildParamsEncryptionConfig.d.ts +13 -0
- package/features/encryption/BuildParamsEncryptionConfig.js +19 -0
- package/features/encryption/BuildParamsEncryptionConfig.js.map +1 -0
- package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
- package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
- package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
- package/features/encryption/EncryptionService.d.ts +3 -2
- package/features/encryption/EncryptionService.js +15 -13
- package/features/encryption/EncryptionService.js.map +1 -1
- package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
- package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
- package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
- package/features/encryption/abstractions.d.ts +26 -0
- package/features/encryption/abstractions.js +3 -1
- package/features/encryption/abstractions.js.map +1 -1
- package/features/encryption/feature.js +2 -0
- package/features/encryption/feature.js.map +1 -1
- package/features/encryption/index.d.ts +3 -0
- package/features/encryption/index.js +3 -1
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +61 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
- package/features/hashing/BuildParamsHashingConfig.d.ts +11 -0
- package/features/hashing/BuildParamsHashingConfig.js +18 -0
- package/features/hashing/BuildParamsHashingConfig.js.map +1 -0
- package/features/hashing/ScryptHasher.d.ts +2 -2
- package/features/hashing/ScryptHasher.js +6 -8
- package/features/hashing/ScryptHasher.js.map +1 -1
- package/features/hashing/abstractions.d.ts +15 -0
- package/features/hashing/abstractions.js +2 -1
- package/features/hashing/abstractions.js.map +1 -1
- package/features/hashing/feature.js +2 -0
- package/features/hashing/feature.js.map +1 -1
- package/features/hashing/index.d.ts +1 -0
- package/features/hashing/index.js +1 -1
- package/features/httpClient/HttpClient.d.ts +7 -0
- package/features/httpClient/HttpClient.js +72 -0
- package/features/httpClient/HttpClient.js.map +1 -0
- package/features/httpClient/HttpRequestError.d.ts +10 -0
- package/features/httpClient/HttpRequestError.js +13 -0
- package/features/httpClient/HttpRequestError.js.map +1 -0
- package/features/httpClient/HttpStatusError.d.ts +12 -0
- package/features/httpClient/HttpStatusError.js +12 -0
- package/features/httpClient/HttpStatusError.js.map +1 -0
- package/features/httpClient/abstractions.d.ts +32 -0
- package/features/httpClient/abstractions.js +5 -0
- package/features/httpClient/abstractions.js.map +1 -0
- package/features/httpClient/feature.d.ts +4 -0
- package/features/httpClient/feature.js +11 -0
- package/features/httpClient/feature.js.map +1 -0
- package/features/httpClient/index.d.ts +3 -0
- package/features/httpClient/index.js +3 -0
- package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
- package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
- package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStore.d.ts +6 -2
- package/features/keyValueStore/KeyValueStore.js +13 -3
- package/features/keyValueStore/KeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
- package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
- package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
- package/features/keyValueStore/abstractions.d.ts +132 -14
- package/features/keyValueStore/abstractions.js.map +1 -1
- package/features/keyValueStore/errors.d.ts +29 -0
- package/features/keyValueStore/errors.js +49 -1
- package/features/keyValueStore/errors.js.map +1 -1
- package/features/keyValueStore/index.d.ts +4 -1
- package/features/keyValueStore/index.js +1 -1
- package/features/logger/NullLogger.d.ts +10 -0
- package/features/logger/NullLogger.js +12 -0
- package/features/logger/NullLogger.js.map +1 -0
- package/features/logger/index.d.ts +1 -0
- package/features/logger/index.js +1 -0
- package/features/publicUrls/NullPublicUrls.d.ts +11 -0
- package/features/publicUrls/NullPublicUrls.js +17 -0
- package/features/publicUrls/NullPublicUrls.js.map +1 -0
- package/features/publicUrls/PublicUrl.d.ts +24 -0
- package/features/publicUrls/PublicUrl.js +43 -0
- package/features/publicUrls/PublicUrl.js.map +1 -0
- package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
- package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
- package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
- package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
- package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
- package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
- package/features/publicUrls/abstractions.d.ts +27 -0
- package/features/publicUrls/abstractions.js +5 -0
- package/features/publicUrls/abstractions.js.map +1 -0
- package/features/publicUrls/feature.d.ts +8 -0
- package/features/publicUrls/feature.js +11 -0
- package/features/publicUrls/feature.js.map +1 -0
- package/features/publicUrls/index.d.ts +3 -0
- package/features/publicUrls/index.js +3 -0
- package/features/requestContext/RawAssumePermissions.d.ts +14 -0
- package/features/requestContext/RawAssumePermissions.js +19 -0
- package/features/requestContext/RawAssumePermissions.js.map +1 -0
- package/features/requestContext/abstractions.d.ts +22 -0
- package/features/requestContext/abstractions.js +2 -1
- package/features/requestContext/abstractions.js.map +1 -1
- package/features/requestContext/extractAssumePermissions.d.ts +14 -0
- package/features/requestContext/extractAssumePermissions.js +32 -0
- package/features/requestContext/extractAssumePermissions.js.map +1 -0
- package/features/requestContext/feature.d.ts +2 -1
- package/features/requestContext/feature.js +2 -0
- package/features/requestContext/feature.js.map +1 -1
- package/features/requestContext/index.d.ts +3 -1
- package/features/requestContext/index.js +2 -1
- package/features/security/IdentityContext/IdentityContext.d.ts +8 -4
- package/features/security/IdentityContext/IdentityContext.js +28 -11
- package/features/security/IdentityContext/IdentityContext.js.map +1 -1
- package/features/security/IdentityContext/abstractions.d.ts +6 -1
- package/features/security/IdentityContext/abstractions.js.map +1 -1
- 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 +7 -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/AuthorizationContext/AuthorizationContext.d.ts +13 -3
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +35 -22
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
- package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/feature.js +6 -1
- package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.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 +1 -0
- 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/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/{logger → slugify}/feature.d.ts +1 -1
- 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/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 +69 -4
- package/features/task/TaskDefinition/abstractions.js +2 -1
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/tenancy/TenantContext/TenantContext.d.ts +5 -1
- package/features/tenancy/TenantContext/TenantContext.js +31 -23
- package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
- package/features/users/shared/loaders.js.map +1 -1
- package/features/users/shared/types.d.ts +9 -7
- package/features/wcp/WcpContext/WcpContext.d.ts +11 -0
- package/features/wcp/WcpContext/WcpContext.js +33 -0
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +14 -60
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +77 -25
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/features/wcp/WcpFeature.js +2 -0
- 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 +6 -14
- package/features/wcp/WcpLicenseProvider.js +3 -7
- package/features/wcp/WcpLicenseProvider.js.map +1 -1
- 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 +1 -0
- package/graphql/ApiCoreSchemaFactory.js +7 -1
- package/graphql/ApiCoreSchemaFactory.js.map +1 -1
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
- package/graphql/security/SecuritySchemaFactory.d.ts +1 -0
- package/graphql/security/SecuritySchemaFactory.js +4 -0
- package/graphql/security/SecuritySchemaFactory.js.map +1 -1
- package/graphql/system/SystemSchemaFactory.d.ts +1 -0
- package/graphql/system/SystemSchemaFactory.js +4 -0
- package/graphql/system/SystemSchemaFactory.js.map +1 -1
- package/graphql/users/UsersSchemaFactory.d.ts +1 -0
- package/graphql/users/UsersSchemaFactory.js +4 -0
- package/graphql/users/UsersSchemaFactory.js.map +1 -1
- package/graphql/wcp/WcpSchemaFactory.d.ts +1 -0
- package/graphql/wcp/WcpSchemaFactory.js +6 -0
- package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
- package/idp/JwksCache.d.ts +14 -3
- package/idp/JwksCache.js +97 -17
- package/idp/JwksCache.js.map +1 -1
- package/idp/JwksStoreFeature.d.ts +8 -0
- package/idp/JwksStoreFeature.js +11 -0
- package/idp/JwksStoreFeature.js.map +1 -0
- package/idp/MemoryJwksStore.d.ts +14 -0
- package/idp/MemoryJwksStore.js +21 -0
- package/idp/MemoryJwksStore.js.map +1 -0
- package/idp/OidcJwtIdentityProvider.js +5 -1
- package/idp/OidcJwtIdentityProvider.js.map +1 -1
- package/idp/abstractions.d.ts +24 -0
- package/idp/abstractions.js +2 -1
- package/idp/abstractions.js.map +1 -1
- package/idp/feature.js +1 -2
- package/idp/feature.js.map +1 -1
- package/idp/index.d.ts +1 -0
- package/idp/index.js +1 -0
- package/package.json +22 -22
- package/testing/environment.d.ts +14 -0
- package/testing/environment.js +18 -0
- package/testing/environment.js.map +1 -0
- package/types/security.d.ts +1 -1
- package/types/users.d.ts +2 -3
- package/features/logger/LoggerService.d.ts +0 -14
- package/features/logger/LoggerService.js +0 -48
- package/features/logger/LoggerService.js.map +0 -1
- package/features/logger/feature.js +0 -11
- package/features/logger/feature.js.map +0 -1
- package/features/wcp/loadWcpLicense.d.ts +0 -2
- package/features/wcp/loadWcpLicense.js +0 -51
- package/features/wcp/loadWcpLicense.js.map +0 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const UNDEFINED = "#[Undefined value]";
|
|
2
|
+
const CIRCULAR = "#[Circular]";
|
|
3
|
+
const DEPTH_LIMIT = "#[Depth limit]";
|
|
4
|
+
const isPlainValue = (value)=>{
|
|
5
|
+
const type = typeof value;
|
|
6
|
+
return "string" === type || "number" === type || "boolean" === type || null === value;
|
|
7
|
+
};
|
|
8
|
+
const describeBinary = (value)=>{
|
|
9
|
+
const name = value.constructor?.name || "TypedArray";
|
|
10
|
+
return `#[${name} ${value.byteLength} bytes]`;
|
|
11
|
+
};
|
|
12
|
+
const walk = (value, limits, seen, depth)=>{
|
|
13
|
+
if (void 0 === value) return UNDEFINED;
|
|
14
|
+
if (isPlainValue(value)) {
|
|
15
|
+
if ("string" == typeof value && value.length > limits.stringLength) {
|
|
16
|
+
const kept = value.slice(0, limits.stringLength);
|
|
17
|
+
return `${kept}…(${value.length - limits.stringLength} more)`;
|
|
18
|
+
}
|
|
19
|
+
if ("number" == typeof value && !Number.isFinite(value)) return String(value);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
if ("bigint" == typeof value) return `${value.toString()}n`;
|
|
23
|
+
if ("symbol" == typeof value) return String(value);
|
|
24
|
+
if ("function" == typeof value) return `#[Function: ${value.name || "anonymous"}]`;
|
|
25
|
+
if (value instanceof Error) return {
|
|
26
|
+
name: value.name,
|
|
27
|
+
message: value.message,
|
|
28
|
+
stack: value.stack
|
|
29
|
+
};
|
|
30
|
+
if (value instanceof Date) return value.toISOString();
|
|
31
|
+
if (value instanceof RegExp) return value.toString();
|
|
32
|
+
if (ArrayBuffer.isView(value)) return describeBinary(value);
|
|
33
|
+
if (value instanceof ArrayBuffer) return `#[ArrayBuffer ${value.byteLength} bytes]`;
|
|
34
|
+
if (depth >= limits.depth) return DEPTH_LIMIT;
|
|
35
|
+
if ("object" != typeof value || null === value) return String(value);
|
|
36
|
+
if (seen.has(value)) return CIRCULAR;
|
|
37
|
+
seen.add(value);
|
|
38
|
+
try {
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
const kept = value.slice(0, limits.arrayLength).map((item)=>walk(item, limits, seen, depth + 1));
|
|
41
|
+
if (value.length > limits.arrayLength) kept.push(`…(${value.length - limits.arrayLength} more items)`);
|
|
42
|
+
return kept;
|
|
43
|
+
}
|
|
44
|
+
if (value instanceof Map) {
|
|
45
|
+
const entries = [];
|
|
46
|
+
for (const [key, item] of value.entries()){
|
|
47
|
+
if (entries.length >= limits.arrayLength) {
|
|
48
|
+
entries.push(`…(${value.size - limits.arrayLength} more entries)`);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
entries.push([
|
|
52
|
+
walk(key, limits, seen, depth + 1),
|
|
53
|
+
walk(item, limits, seen, depth + 1)
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
__type: "Map",
|
|
58
|
+
entries
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (value instanceof Set) {
|
|
62
|
+
const items = [];
|
|
63
|
+
for (const item of value.values()){
|
|
64
|
+
if (items.length >= limits.arrayLength) {
|
|
65
|
+
items.push(`…(${value.size - limits.arrayLength} more items)`);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
items.push(walk(item, limits, seen, depth + 1));
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
__type: "Set",
|
|
72
|
+
items
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const result = {};
|
|
76
|
+
for (const key of Object.keys(value)){
|
|
77
|
+
let item;
|
|
78
|
+
try {
|
|
79
|
+
item = value[key];
|
|
80
|
+
} catch (ex) {
|
|
81
|
+
result[key] = `#[Throws: ${ex instanceof Error ? ex.message : String(ex)}]`;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (void 0 !== item) result[key] = walk(item, limits, seen, depth + 1);
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
} finally{
|
|
88
|
+
seen.delete(value);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const serialize = (value, limits)=>{
|
|
92
|
+
let json;
|
|
93
|
+
try {
|
|
94
|
+
const walked = walk(value, limits, new WeakSet(), 0);
|
|
95
|
+
json = JSON.stringify(walked) ?? JSON.stringify(UNDEFINED);
|
|
96
|
+
} catch (ex) {
|
|
97
|
+
const message = ex instanceof Error ? ex.message : String(ex);
|
|
98
|
+
json = JSON.stringify({
|
|
99
|
+
__serializationFailed: true,
|
|
100
|
+
message
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
let bytes = Buffer.byteLength(json, "utf8");
|
|
104
|
+
let truncated = false;
|
|
105
|
+
if (bytes > limits.entryBytes) {
|
|
106
|
+
json = JSON.stringify({
|
|
107
|
+
truncated: true,
|
|
108
|
+
originalBytes: bytes
|
|
109
|
+
});
|
|
110
|
+
bytes = Buffer.byteLength(json, "utf8");
|
|
111
|
+
truncated = true;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
json,
|
|
115
|
+
bytes,
|
|
116
|
+
truncated
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export { serialize };
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=serialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/debugger/serialize.js","sources":["../../../src/features/debugger/serialize.ts"],"sourcesContent":["import type { IDebuggerLimits } from \"./limits.js\";\n\nexport interface ISerializeResult {\n json: string;\n bytes: number;\n /** True if the value was replaced by the per-entry cap marker. */\n truncated: boolean;\n}\n\n/**\n * Markers stand in for values that cannot be represented as JSON.\n *\n * They are prefixed with `#` so a reader can tell at a glance that a value was substituted by the\n * serializer rather than being what the code actually held - the previous `[undefined]` read as an\n * array literal in documents that are full of real arrays.\n */\nconst UNDEFINED = \"#[Undefined value]\";\nconst CIRCULAR = \"#[Circular]\";\nconst DEPTH_LIMIT = \"#[Depth limit]\";\n\nconst isPlainValue = (value: unknown): boolean => {\n const type = typeof value;\n return type === \"string\" || type === \"number\" || type === \"boolean\" || value === null;\n};\n\nconst describeBinary = (value: ArrayBufferView): string => {\n const name = value.constructor?.name || \"TypedArray\";\n return `#[${name} ${value.byteLength} bytes]`;\n};\n\n/**\n * Walks a value into a JSON-safe structure, applying depth, string and array caps as it goes.\n *\n * Caps are applied during the walk rather than by slicing the finished JSON string, so the output is\n * always parseable.\n *\n * A custom `toJSON` is never invoked - own properties are enumerated instead. That means an object\n * is reported as its internals rather than its intended representation, which is what you want when\n * debugging, and it removes a whole class of failure where a third-party `toJSON` throws.\n */\nconst walk = (\n value: unknown,\n limits: IDebuggerLimits,\n seen: WeakSet<object>,\n depth: number\n): unknown => {\n if (value === undefined) {\n /**\n * Only reached for array elements and for a top-level payload. Object properties holding\n * `undefined` are dropped before they get here, matching `JSON.stringify`.\n *\n * Inside an array the element cannot be dropped without shifting every later index, and\n * `JSON.stringify` would turn it into `null` - which is a meaningful value in its own right.\n */\n return UNDEFINED;\n }\n\n if (isPlainValue(value)) {\n if (typeof value === \"string\" && value.length > limits.stringLength) {\n const kept = value.slice(0, limits.stringLength);\n return `${kept}…(${value.length - limits.stringLength} more)`;\n }\n /**\n * Infinity and NaN serialize to `null`, which silently loses the distinction. Keep them\n * readable instead.\n */\n if (typeof value === \"number\" && !Number.isFinite(value)) {\n return String(value);\n }\n return value;\n }\n\n if (typeof value === \"bigint\") {\n return `${value.toString()}n`;\n }\n\n if (typeof value === \"symbol\") {\n return String(value);\n }\n\n if (typeof value === \"function\") {\n return `#[Function: ${value.name || \"anonymous\"}]`;\n }\n\n if (value instanceof Error) {\n return {\n name: value.name,\n message: value.message,\n stack: value.stack\n };\n }\n\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n if (value instanceof RegExp) {\n return value.toString();\n }\n\n if (ArrayBuffer.isView(value)) {\n return describeBinary(value);\n }\n\n if (value instanceof ArrayBuffer) {\n return `#[ArrayBuffer ${value.byteLength} bytes]`;\n }\n\n if (depth >= limits.depth) {\n return DEPTH_LIMIT;\n }\n\n if (typeof value !== \"object\" || value === null) {\n return String(value);\n }\n\n if (seen.has(value)) {\n return CIRCULAR;\n }\n seen.add(value);\n\n try {\n if (Array.isArray(value)) {\n const kept = value.slice(0, limits.arrayLength).map(item => {\n return walk(item, limits, seen, depth + 1);\n });\n if (value.length > limits.arrayLength) {\n kept.push(`…(${value.length - limits.arrayLength} more items)`);\n }\n return kept;\n }\n\n if (value instanceof Map) {\n const entries: unknown[] = [];\n for (const [key, item] of value.entries()) {\n if (entries.length >= limits.arrayLength) {\n entries.push(`…(${value.size - limits.arrayLength} more entries)`);\n break;\n }\n entries.push([\n walk(key, limits, seen, depth + 1),\n walk(item, limits, seen, depth + 1)\n ]);\n }\n return { __type: \"Map\", entries };\n }\n\n if (value instanceof Set) {\n const items: unknown[] = [];\n for (const item of value.values()) {\n if (items.length >= limits.arrayLength) {\n items.push(`…(${value.size - limits.arrayLength} more items)`);\n break;\n }\n items.push(walk(item, limits, seen, depth + 1));\n }\n return { __type: \"Set\", items };\n }\n\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n /**\n * A getter can throw. One bad property must not take down the whole entry, let alone the\n * request that is being observed.\n */\n let item: unknown;\n try {\n item = (value as Record<string, unknown>)[key];\n } catch (ex) {\n result[key] = `#[Throws: ${ex instanceof Error ? ex.message : String(ex)}]`;\n continue;\n }\n\n /**\n * Drop the key, as `JSON.stringify` does.\n *\n * Captured payloads are frequently copies of something that went over the wire, and the\n * wire never carried these keys - keeping them would describe a request that was never\n * made.\n */\n if (item === undefined) {\n continue;\n }\n\n result[key] = walk(item, limits, seen, depth + 1);\n }\n return result;\n } finally {\n /**\n * Only guard against cycles along the current branch. Without this, a value referenced twice\n * as siblings would report the second one as circular.\n */\n seen.delete(value);\n }\n};\n\n/**\n * Serializes a captured payload to JSON, never throwing and always producing valid JSON.\n */\nexport const serialize = (value: unknown, limits: IDebuggerLimits): ISerializeResult => {\n let json: string;\n\n try {\n const walked = walk(value, limits, new WeakSet(), 0);\n json = JSON.stringify(walked) ?? JSON.stringify(UNDEFINED);\n } catch (ex) {\n const message = ex instanceof Error ? ex.message : String(ex);\n json = JSON.stringify({ __serializationFailed: true, message });\n }\n\n let bytes = Buffer.byteLength(json, \"utf8\");\n let truncated = false;\n\n if (bytes > limits.entryBytes) {\n /**\n * Slicing the string would produce invalid JSON, so the payload is replaced wholesale.\n */\n json = JSON.stringify({ truncated: true, originalBytes: bytes });\n bytes = Buffer.byteLength(json, \"utf8\");\n truncated = true;\n }\n\n return { json, bytes, truncated };\n};\n"],"names":["UNDEFINED","CIRCULAR","DEPTH_LIMIT","isPlainValue","value","type","describeBinary","name","walk","limits","seen","depth","undefined","kept","Number","String","Error","Date","RegExp","ArrayBuffer","Array","item","Map","entries","key","Set","items","result","Object","ex","serialize","json","walked","WeakSet","JSON","message","bytes","Buffer","truncated"],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EncryptionConfig } from "./abstractions.js";
|
|
2
|
+
import { BuildParams } from "../buildParams/abstractions.js";
|
|
3
|
+
export declare const DEFAULT_ENCRYPTION_ALGORITHM = "aes-256-gcm";
|
|
4
|
+
declare class BuildParamsEncryptionConfigImpl implements EncryptionConfig.Interface {
|
|
5
|
+
readonly passphrase: string | null;
|
|
6
|
+
readonly salt: string;
|
|
7
|
+
readonly algorithm: string;
|
|
8
|
+
constructor(buildParams: BuildParams.Interface);
|
|
9
|
+
}
|
|
10
|
+
export declare const BuildParamsEncryptionConfig: typeof BuildParamsEncryptionConfigImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IEncryptionConfig>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EncryptionConfig } from "./abstractions.js";
|
|
2
|
+
import { BuildParams } from "../buildParams/abstractions.js";
|
|
3
|
+
const DEFAULT_ENCRYPTION_ALGORITHM = "aes-256-gcm";
|
|
4
|
+
class BuildParamsEncryptionConfigImpl {
|
|
5
|
+
constructor(buildParams){
|
|
6
|
+
this.passphrase = buildParams.get("EncryptionPassphrase") || null;
|
|
7
|
+
this.salt = buildParams.get("EncryptionSalt") ?? "";
|
|
8
|
+
this.algorithm = buildParams.get("EncryptionAlgorithm") ?? DEFAULT_ENCRYPTION_ALGORITHM;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const BuildParamsEncryptionConfig = EncryptionConfig.createImplementation({
|
|
12
|
+
implementation: BuildParamsEncryptionConfigImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
BuildParams
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { BuildParamsEncryptionConfig, DEFAULT_ENCRYPTION_ALGORITHM };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=BuildParamsEncryptionConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/encryption/BuildParamsEncryptionConfig.js","sources":["../../../src/features/encryption/BuildParamsEncryptionConfig.ts"],"sourcesContent":["import { EncryptionConfig } from \"./abstractions.js\";\nimport { BuildParams } from \"../buildParams/abstractions.js\";\n\nexport const DEFAULT_ENCRYPTION_ALGORITHM = \"aes-256-gcm\";\n\nclass BuildParamsEncryptionConfigImpl implements EncryptionConfig.Interface {\n readonly passphrase: string | null;\n readonly salt: string;\n readonly algorithm: string;\n\n constructor(buildParams: BuildParams.Interface) {\n this.passphrase = buildParams.get<string>(\"EncryptionPassphrase\") || null;\n this.salt = buildParams.get<string>(\"EncryptionSalt\") ?? \"\";\n this.algorithm =\n buildParams.get<string>(\"EncryptionAlgorithm\") ?? DEFAULT_ENCRYPTION_ALGORITHM;\n }\n}\n\nexport const BuildParamsEncryptionConfig = EncryptionConfig.createImplementation({\n implementation: BuildParamsEncryptionConfigImpl,\n dependencies: [BuildParams]\n});\n"],"names":["DEFAULT_ENCRYPTION_ALGORITHM","BuildParamsEncryptionConfigImpl","buildParams","BuildParamsEncryptionConfig","EncryptionConfig","BuildParams"],"mappings":";;AAGO,MAAMA,+BAA+B;AAE5C,MAAMC;IAKF,YAAYC,WAAkC,CAAE;QAC5C,IAAI,CAAC,UAAU,GAAGA,YAAY,GAAG,CAAS,2BAA2B;QACrE,IAAI,CAAC,IAAI,GAAGA,YAAY,GAAG,CAAS,qBAAqB;QACzD,IAAI,CAAC,SAAS,GACVA,YAAY,GAAG,CAAS,0BAA0BF;IAC1D;AACJ;AAEO,MAAMG,8BAA8BC,iBAAiB,oBAAoB,CAAC;IAC7E,gBAAgBH;IAChB,cAAc;QAACI;KAAY;AAC/B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register in the ROOT container. Encryption is registered again in every request container, so a
|
|
3
|
+
* cache registered there would start empty on each request and derive the key every time.
|
|
4
|
+
*/
|
|
5
|
+
export declare const EncryptionKeyCacheFeature: {
|
|
6
|
+
name: string;
|
|
7
|
+
register(container: import("@webiny/di").Container): void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { MemoryEncryptionKeyCache } from "./MemoryEncryptionKeyCache.js";
|
|
3
|
+
const EncryptionKeyCacheFeature = createFeature({
|
|
4
|
+
name: "EncryptionKeyCache",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(MemoryEncryptionKeyCache).inSingletonScope();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { EncryptionKeyCacheFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=EncryptionKeyCacheFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/encryption/EncryptionKeyCacheFeature.js","sources":["../../../src/features/encryption/EncryptionKeyCacheFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { MemoryEncryptionKeyCache } from \"./MemoryEncryptionKeyCache.js\";\n\n/**\n * Register in the ROOT container. Encryption is registered again in every request container, so a\n * cache registered there would start empty on each request and derive the key every time.\n */\nexport const EncryptionKeyCacheFeature = createFeature({\n name: \"EncryptionKeyCache\",\n register(container) {\n container.register(MemoryEncryptionKeyCache).inSingletonScope();\n }\n});\n"],"names":["EncryptionKeyCacheFeature","createFeature","container","MemoryEncryptionKeyCache"],"mappings":";;AAOO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,0BAA0B,gBAAgB;IACjE;AACJ"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Encryption as EncryptionAbstraction } from "./abstractions.js";
|
|
2
|
-
import {
|
|
2
|
+
import { EncryptionKeyCache } from "./abstractions.js";
|
|
3
|
+
import { EncryptionConfig } from "./abstractions.js";
|
|
3
4
|
export declare class EncryptionImpl implements EncryptionAbstraction.Interface {
|
|
4
5
|
private key;
|
|
5
6
|
private algorithm;
|
|
6
|
-
constructor(
|
|
7
|
+
constructor(config: EncryptionConfig.Interface, keyCache: EncryptionKeyCache.Interface | undefined);
|
|
7
8
|
encrypt(value: string): Promise<string>;
|
|
8
9
|
decrypt(value: string): Promise<string>;
|
|
9
10
|
}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import node_crypto from "node:crypto";
|
|
2
2
|
import { createImplementation } from "@webiny/feature/api";
|
|
3
|
-
import { Encryption } from "./abstractions.js";
|
|
4
|
-
import { BuildParams } from "../buildParams/abstractions.js";
|
|
5
|
-
const DEFAULT_ALGORITHM = "aes-256-gcm";
|
|
3
|
+
import { Encryption, EncryptionConfig, EncryptionKeyCache } from "./abstractions.js";
|
|
6
4
|
function keyLengthForAlgorithm(algorithm) {
|
|
7
5
|
const bits = parseInt(algorithm.split("-")[1]);
|
|
8
6
|
if (isNaN(bits)) throw new Error(`Cannot determine key length from algorithm "${algorithm}".`);
|
|
9
7
|
return bits / 8;
|
|
10
8
|
}
|
|
11
9
|
class EncryptionImpl {
|
|
12
|
-
constructor(
|
|
13
|
-
|
|
14
|
-
if (passphrase) {
|
|
15
|
-
const salt = buildParams.get("EncryptionSalt") ?? "";
|
|
16
|
-
this.algorithm = buildParams.get("EncryptionAlgorithm") ?? DEFAULT_ALGORITHM;
|
|
17
|
-
const keyLength = keyLengthForAlgorithm(this.algorithm);
|
|
18
|
-
this.key = node_crypto.scryptSync(passphrase, salt, keyLength);
|
|
19
|
-
} else {
|
|
10
|
+
constructor(config, keyCache){
|
|
11
|
+
this.algorithm = config.algorithm;
|
|
12
|
+
if (!config.passphrase) {
|
|
20
13
|
this.key = null;
|
|
21
|
-
|
|
14
|
+
return;
|
|
22
15
|
}
|
|
16
|
+
const keyLength = keyLengthForAlgorithm(this.algorithm);
|
|
17
|
+
if (keyCache) this.key = keyCache.getOrDerive(config.passphrase, config.salt, keyLength);
|
|
18
|
+
else this.key = node_crypto.scryptSync(config.passphrase, config.salt, keyLength);
|
|
23
19
|
}
|
|
24
20
|
async encrypt(value) {
|
|
25
21
|
if (!this.key) return value;
|
|
@@ -54,7 +50,13 @@ const EncryptionService_Encryption = createImplementation({
|
|
|
54
50
|
abstraction: Encryption,
|
|
55
51
|
implementation: EncryptionImpl,
|
|
56
52
|
dependencies: [
|
|
57
|
-
|
|
53
|
+
EncryptionConfig,
|
|
54
|
+
[
|
|
55
|
+
EncryptionKeyCache,
|
|
56
|
+
{
|
|
57
|
+
optional: true
|
|
58
|
+
}
|
|
59
|
+
]
|
|
58
60
|
]
|
|
59
61
|
});
|
|
60
62
|
export { EncryptionImpl, EncryptionService_Encryption as Encryption };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/encryption/EncryptionService.js","sources":["../../../src/features/encryption/EncryptionService.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Encryption as EncryptionAbstraction } from \"./abstractions.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/encryption/EncryptionService.js","sources":["../../../src/features/encryption/EncryptionService.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Encryption as EncryptionAbstraction } from \"./abstractions.js\";\nimport { EncryptionKeyCache } from \"./abstractions.js\";\nimport { EncryptionConfig } from \"./abstractions.js\";\n\nfunction keyLengthForAlgorithm(algorithm: string): number {\n // Parse key size in bits from algorithm name (e.g. \"aes-256-gcm\" → 32 bytes).\n const bits = parseInt(algorithm.split(\"-\")[1]);\n if (isNaN(bits)) {\n throw new Error(`Cannot determine key length from algorithm \"${algorithm}\".`);\n }\n return bits / 8;\n}\n\nexport class EncryptionImpl implements EncryptionAbstraction.Interface {\n private key: Buffer | null;\n private algorithm: string;\n\n constructor(\n config: EncryptionConfig.Interface,\n // Registered in the root container, so the derived key outlives the request. Without it (in\n // tests, for example) the key is derived for every instance.\n keyCache: EncryptionKeyCache.Interface | undefined\n ) {\n this.algorithm = config.algorithm;\n\n if (!config.passphrase) {\n this.key = null;\n return;\n }\n\n // Salt is optional. It ensures two projects using the same passphrase derive different keys,\n // but since passphrases should be unique per project anyway, it's extra insurance rather than a necessity.\n const keyLength = keyLengthForAlgorithm(this.algorithm);\n if (keyCache) {\n this.key = keyCache.getOrDerive(config.passphrase, config.salt, keyLength);\n } else {\n this.key = crypto.scryptSync(config.passphrase, config.salt, keyLength);\n }\n }\n\n async encrypt(value: string): Promise<string> {\n if (!this.key) {\n return value;\n }\n const iv = crypto.randomBytes(12);\n const cipher = crypto.createCipheriv(this.algorithm, this.key, iv);\n const encrypted = Buffer.concat([cipher.update(value, \"utf8\"), cipher.final()]);\n const authTag = (cipher as crypto.CipherGCM).getAuthTag();\n return Buffer.concat([iv, authTag, encrypted]).toString(\"base64\");\n }\n\n async decrypt(value: string): Promise<string> {\n if (!this.key) {\n return value;\n }\n const data = Buffer.from(value, \"base64\");\n const iv = data.subarray(0, 12);\n const authTag = data.subarray(12, 28);\n const ciphertext = data.subarray(28);\n const decipher = crypto.createDecipheriv(this.algorithm, this.key, iv);\n (decipher as crypto.DecipherGCM).setAuthTag(authTag);\n return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString(\"utf8\");\n }\n}\n\nexport const Encryption = createImplementation({\n abstraction: EncryptionAbstraction,\n implementation: EncryptionImpl,\n dependencies: [EncryptionConfig, [EncryptionKeyCache, { optional: true }]]\n});\n"],"names":["keyLengthForAlgorithm","algorithm","bits","parseInt","isNaN","Error","EncryptionImpl","config","keyCache","keyLength","crypto","value","iv","cipher","encrypted","Buffer","authTag","data","ciphertext","decipher","Encryption","createImplementation","EncryptionAbstraction","EncryptionConfig","EncryptionKeyCache"],"mappings":";;;AAMA,SAASA,sBAAsBC,SAAiB;IAE5C,MAAMC,OAAOC,SAASF,UAAU,KAAK,CAAC,IAAI,CAAC,EAAE;IAC7C,IAAIG,MAAMF,OACN,MAAM,IAAIG,MAAM,CAAC,4CAA4C,EAAEJ,UAAU,EAAE,CAAC;IAEhF,OAAOC,OAAO;AAClB;AAEO,MAAMI;IAIT,YACIC,MAAkC,EAGlCC,QAAkD,CACpD;QACE,IAAI,CAAC,SAAS,GAAGD,OAAO,SAAS;QAEjC,IAAI,CAACA,OAAO,UAAU,EAAE;YACpB,IAAI,CAAC,GAAG,GAAG;YACX;QACJ;QAIA,MAAME,YAAYT,sBAAsB,IAAI,CAAC,SAAS;QACtD,IAAIQ,UACA,IAAI,CAAC,GAAG,GAAGA,SAAS,WAAW,CAACD,OAAO,UAAU,EAAEA,OAAO,IAAI,EAAEE;aAEhE,IAAI,CAAC,GAAG,GAAGC,YAAAA,UAAiB,CAACH,OAAO,UAAU,EAAEA,OAAO,IAAI,EAAEE;IAErE;IAEA,MAAM,QAAQE,KAAa,EAAmB;QAC1C,IAAI,CAAC,IAAI,CAAC,GAAG,EACT,OAAOA;QAEX,MAAMC,KAAKF,YAAAA,WAAkB,CAAC;QAC9B,MAAMG,SAASH,YAAAA,cAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAEE;QAC/D,MAAME,YAAYC,OAAO,MAAM,CAAC;YAACF,OAAO,MAAM,CAACF,OAAO;YAASE,OAAO,KAAK;SAAG;QAC9E,MAAMG,UAAWH,OAA4B,UAAU;QACvD,OAAOE,OAAO,MAAM,CAAC;YAACH;YAAII;YAASF;SAAU,EAAE,QAAQ,CAAC;IAC5D;IAEA,MAAM,QAAQH,KAAa,EAAmB;QAC1C,IAAI,CAAC,IAAI,CAAC,GAAG,EACT,OAAOA;QAEX,MAAMM,OAAOF,OAAO,IAAI,CAACJ,OAAO;QAChC,MAAMC,KAAKK,KAAK,QAAQ,CAAC,GAAG;QAC5B,MAAMD,UAAUC,KAAK,QAAQ,CAAC,IAAI;QAClC,MAAMC,aAAaD,KAAK,QAAQ,CAAC;QACjC,MAAME,WAAWT,YAAAA,gBAAuB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAEE;QAClEO,SAAgC,UAAU,CAACH;QAC5C,OAAOD,OAAO,MAAM,CAAC;YAACI,SAAS,MAAM,CAACD;YAAaC,SAAS,KAAK;SAAG,EAAE,QAAQ,CAAC;IACnF;AACJ;AAEO,MAAMC,+BAAaC,qBAAqB;IAC3C,aAAaC;IACb,gBAAgBhB;IAChB,cAAc;QAACiB;QAAkB;YAACC;YAAoB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAC9E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EncryptionKeyCache as Abstraction } from "./abstractions.js";
|
|
2
|
+
/**
|
|
3
|
+
* Keeps every derived key for the life of the container. Keys depend only on build params, so a
|
|
4
|
+
* process holds one or two at most.
|
|
5
|
+
*/
|
|
6
|
+
declare class MemoryEncryptionKeyCacheImpl implements Abstraction.Interface {
|
|
7
|
+
private readonly keys;
|
|
8
|
+
getOrDerive(passphrase: string, salt: string, keyLength: number): Buffer;
|
|
9
|
+
}
|
|
10
|
+
export declare const MemoryEncryptionKeyCache: typeof MemoryEncryptionKeyCacheImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IEncryptionKeyCache>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import node_crypto from "node:crypto";
|
|
2
|
+
import { EncryptionKeyCache } from "./abstractions.js";
|
|
3
|
+
class MemoryEncryptionKeyCacheImpl {
|
|
4
|
+
getOrDerive(passphrase, salt, keyLength) {
|
|
5
|
+
const cacheKey = JSON.stringify([
|
|
6
|
+
passphrase,
|
|
7
|
+
salt,
|
|
8
|
+
keyLength
|
|
9
|
+
]);
|
|
10
|
+
const cached = this.keys.get(cacheKey);
|
|
11
|
+
if (cached) return cached;
|
|
12
|
+
const key = node_crypto.scryptSync(passphrase, salt, keyLength);
|
|
13
|
+
this.keys.set(cacheKey, key);
|
|
14
|
+
return key;
|
|
15
|
+
}
|
|
16
|
+
constructor(){
|
|
17
|
+
this.keys = new Map();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const MemoryEncryptionKeyCache = EncryptionKeyCache.createImplementation({
|
|
21
|
+
implementation: MemoryEncryptionKeyCacheImpl,
|
|
22
|
+
dependencies: []
|
|
23
|
+
});
|
|
24
|
+
export { MemoryEncryptionKeyCache };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=MemoryEncryptionKeyCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/encryption/MemoryEncryptionKeyCache.js","sources":["../../../src/features/encryption/MemoryEncryptionKeyCache.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport { EncryptionKeyCache as Abstraction } from \"./abstractions.js\";\n\n/**\n * Keeps every derived key for the life of the container. Keys depend only on build params, so a\n * process holds one or two at most.\n */\nclass MemoryEncryptionKeyCacheImpl implements Abstraction.Interface {\n private readonly keys = new Map<string, Buffer>();\n\n public getOrDerive(passphrase: string, salt: string, keyLength: number): Buffer {\n const cacheKey = JSON.stringify([passphrase, salt, keyLength]);\n const cached = this.keys.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const key = crypto.scryptSync(passphrase, salt, keyLength);\n this.keys.set(cacheKey, key);\n return key;\n }\n}\n\nexport const MemoryEncryptionKeyCache = Abstraction.createImplementation({\n implementation: MemoryEncryptionKeyCacheImpl,\n dependencies: []\n});\n"],"names":["MemoryEncryptionKeyCacheImpl","passphrase","salt","keyLength","cacheKey","JSON","cached","key","crypto","Map","MemoryEncryptionKeyCache","Abstraction"],"mappings":";;AAOA,MAAMA;IAGK,YAAYC,UAAkB,EAAEC,IAAY,EAAEC,SAAiB,EAAU;QAC5E,MAAMC,WAAWC,KAAK,SAAS,CAAC;YAACJ;YAAYC;YAAMC;SAAU;QAC7D,MAAMG,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAACF;QAC7B,IAAIE,QACA,OAAOA;QAGX,MAAMC,MAAMC,YAAAA,UAAiB,CAACP,YAAYC,MAAMC;QAChD,IAAI,CAAC,IAAI,CAAC,GAAG,CAACC,UAAUG;QACxB,OAAOA;IACX;;aAZiB,IAAI,GAAG,IAAIE;;AAahC;AAEO,MAAMC,2BAA2BC,mBAAAA,oBAAgC,CAAC;IACrE,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -7,3 +7,29 @@ export declare const Encryption: import("@webiny/di").Abstraction<IEncryption>;
|
|
|
7
7
|
export declare namespace Encryption {
|
|
8
8
|
type Interface = IEncryption;
|
|
9
9
|
}
|
|
10
|
+
export interface IEncryptionKeyCache {
|
|
11
|
+
getOrDerive(passphrase: string, salt: string, keyLength: number): Buffer;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Derives encryption keys and keeps them. Deriving a key runs scrypt, which costs tens of
|
|
15
|
+
* milliseconds of CPU on purpose, so the key is derived once instead of on every request.
|
|
16
|
+
*/
|
|
17
|
+
export declare const EncryptionKeyCache: import("@webiny/di").Abstraction<IEncryptionKeyCache>;
|
|
18
|
+
export declare namespace EncryptionKeyCache {
|
|
19
|
+
type Interface = IEncryptionKeyCache;
|
|
20
|
+
}
|
|
21
|
+
export interface IEncryptionConfig {
|
|
22
|
+
/** `null` turns encryption off: values are stored as given. */
|
|
23
|
+
readonly passphrase: string | null;
|
|
24
|
+
readonly salt: string;
|
|
25
|
+
readonly algorithm: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Where `Encryption` gets its key material. The default reads the `EncryptionPassphrase`,
|
|
29
|
+
* `EncryptionSalt` and `EncryptionAlgorithm` build params (`<Infra.Crypto.Encryption>`). A hosting
|
|
30
|
+
* type can replace it, e.g. to read the passphrase from env at startup.
|
|
31
|
+
*/
|
|
32
|
+
export declare const EncryptionConfig: import("@webiny/di").Abstraction<IEncryptionConfig>;
|
|
33
|
+
export declare namespace EncryptionConfig {
|
|
34
|
+
type Interface = IEncryptionConfig;
|
|
35
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
2
|
const Encryption = createAbstraction("Encryption");
|
|
3
|
-
|
|
3
|
+
const EncryptionKeyCache = createAbstraction("EncryptionKeyCache");
|
|
4
|
+
const EncryptionConfig = createAbstraction("EncryptionConfig");
|
|
5
|
+
export { Encryption, EncryptionConfig, EncryptionKeyCache };
|
|
4
6
|
|
|
5
7
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/encryption/abstractions.js","sources":["../../../src/features/encryption/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IEncryption {\n encrypt(value: string): Promise<string>;\n decrypt(value: string): Promise<string>;\n}\n\n/** Symmetric encryption and decryption using a configured secret key. */\nexport const Encryption = createAbstraction<IEncryption>(\"Encryption\");\n\nexport namespace Encryption {\n export type Interface = IEncryption;\n}\n"],"names":["Encryption","createAbstraction"],"mappings":";AAQO,MAAMA,aAAaC,kBAA+B"}
|
|
1
|
+
{"version":3,"file":"features/encryption/abstractions.js","sources":["../../../src/features/encryption/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IEncryption {\n encrypt(value: string): Promise<string>;\n decrypt(value: string): Promise<string>;\n}\n\n/** Symmetric encryption and decryption using a configured secret key. */\nexport const Encryption = createAbstraction<IEncryption>(\"Encryption\");\n\nexport namespace Encryption {\n export type Interface = IEncryption;\n}\n\nexport interface IEncryptionKeyCache {\n getOrDerive(passphrase: string, salt: string, keyLength: number): Buffer;\n}\n\n/**\n * Derives encryption keys and keeps them. Deriving a key runs scrypt, which costs tens of\n * milliseconds of CPU on purpose, so the key is derived once instead of on every request.\n */\nexport const EncryptionKeyCache = createAbstraction<IEncryptionKeyCache>(\"EncryptionKeyCache\");\n\nexport namespace EncryptionKeyCache {\n export type Interface = IEncryptionKeyCache;\n}\n\nexport interface IEncryptionConfig {\n /** `null` turns encryption off: values are stored as given. */\n readonly passphrase: string | null;\n readonly salt: string;\n readonly algorithm: string;\n}\n\n/**\n * Where `Encryption` gets its key material. The default reads the `EncryptionPassphrase`,\n * `EncryptionSalt` and `EncryptionAlgorithm` build params (`<Infra.Crypto.Encryption>`). A hosting\n * type can replace it, e.g. to read the passphrase from env at startup.\n */\nexport const EncryptionConfig = createAbstraction<IEncryptionConfig>(\"EncryptionConfig\");\n\nexport namespace EncryptionConfig {\n export type Interface = IEncryptionConfig;\n}\n"],"names":["Encryption","createAbstraction","EncryptionKeyCache","EncryptionConfig"],"mappings":";AAQO,MAAMA,aAAaC,kBAA+B;AAclD,MAAMC,qBAAqBD,kBAAuC;AAkBlE,MAAME,mBAAmBF,kBAAqC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { Encryption } from "./EncryptionService.js";
|
|
3
|
+
import { BuildParamsEncryptionConfig } from "./BuildParamsEncryptionConfig.js";
|
|
3
4
|
const EncryptionFeature = createFeature({
|
|
4
5
|
name: "EncryptionFeature",
|
|
5
6
|
register (container) {
|
|
7
|
+
container.register(BuildParamsEncryptionConfig);
|
|
6
8
|
container.register(Encryption);
|
|
7
9
|
}
|
|
8
10
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/encryption/feature.js","sources":["../../../src/features/encryption/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Encryption } from \"./EncryptionService.js\";\n\nexport const EncryptionFeature = createFeature({\n name: \"EncryptionFeature\",\n register(container) {\n container.register(Encryption);\n }\n});\n"],"names":["EncryptionFeature","createFeature","container","Encryption"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/encryption/feature.js","sources":["../../../src/features/encryption/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Encryption } from \"./EncryptionService.js\";\nimport { BuildParamsEncryptionConfig } from \"./BuildParamsEncryptionConfig.js\";\n\nexport const EncryptionFeature = createFeature({\n name: \"EncryptionFeature\",\n register(container) {\n container.register(BuildParamsEncryptionConfig);\n container.register(Encryption);\n }\n});\n"],"names":["EncryptionFeature","createFeature","container","BuildParamsEncryptionConfig","Encryption"],"mappings":";;;AAIO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;IACvB;AACJ"}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { Encryption } from "./abstractions.js";
|
|
1
|
+
export { Encryption, EncryptionConfig } from "./abstractions.js";
|
|
2
|
+
export { DEFAULT_ENCRYPTION_ALGORITHM } from "./BuildParamsEncryptionConfig.js";
|
|
3
|
+
export { EncryptionKeyCacheFeature } from "./EncryptionKeyCacheFeature.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FeatureFlags } from "../abstractions.js";
|
|
2
|
+
import { FeatureFlags as FeatureFlagsClass } from "@webiny/feature-flags";
|
|
3
|
+
import { WcpLicenseProvider } from "../../../features/wcp/WcpLicenseProvider.js";
|
|
4
|
+
declare class FeatureFlagsWithLicenseDecoratorImpl implements FeatureFlags.Interface {
|
|
5
|
+
private licenseProvider;
|
|
6
|
+
private decoratee;
|
|
7
|
+
constructor(licenseProvider: WcpLicenseProvider.Interface, decoratee: FeatureFlags.Interface);
|
|
8
|
+
get(): FeatureFlagsClass;
|
|
9
|
+
}
|
|
10
|
+
export declare const FeatureFlagsWithLicenseDecorator: typeof FeatureFlagsWithLicenseDecoratorImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("../abstractions.js").IFeatureFlagsAbstraction>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,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
|
+
languages: (l)=>l.canUseLanguages(),
|
|
7
|
+
advancedPublishingWorkflow: (l)=>l.canUseWorkflows(),
|
|
8
|
+
advancedAccessControlLayer: (l)=>l.canUseAacl(),
|
|
9
|
+
"advancedAccessControlLayer.teams": (l)=>l.canUseTeams(),
|
|
10
|
+
"advancedAccessControlLayer.privateFiles": (l)=>l.canUsePrivateFiles(),
|
|
11
|
+
"advancedAccessControlLayer.folderLevelPermissions": (l)=>l.canUseFolderLevelPermissions(),
|
|
12
|
+
"advancedAccessControlLayer.hcmsFieldPermissions": (l)=>l.canUseHcmsFieldPermissions(),
|
|
13
|
+
auditLogs: (l)=>l.canUseAuditLogs(),
|
|
14
|
+
recordLocking: (l)=>l.canUseRecordLocking(),
|
|
15
|
+
"fileManager.threatDetection": (l)=>l.canUseFileManagerThreatDetection(),
|
|
16
|
+
aiPowerups: (l)=>l.canUseAiPowerups(),
|
|
17
|
+
"aiPowerups.fileManager.imageEnrichment": (l)=>l.canUseAiImageEnrichment(),
|
|
18
|
+
"aiPowerups.websiteBuilder.pageGeneration": (l)=>l.canUseAiPageGeneration(),
|
|
19
|
+
"aiPowerups.websiteBuilder.pageTranslation": (l)=>l.canUseAiPageTranslation(),
|
|
20
|
+
"aiPowerups.lexicalGeneration": (l)=>l.canUseAiLexicalGeneration(),
|
|
21
|
+
"aiPowerups.adminAssistant": (l)=>l.canUseAiAdminAssistant(),
|
|
22
|
+
"aiPowerups.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 languages: l => l.canUseLanguages(),\n advancedPublishingWorkflow: l => l.canUseWorkflows(),\n advancedAccessControlLayer: l => l.canUseAacl(),\n \"advancedAccessControlLayer.teams\": l => l.canUseTeams(),\n \"advancedAccessControlLayer.privateFiles\": l => l.canUsePrivateFiles(),\n \"advancedAccessControlLayer.folderLevelPermissions\": l => l.canUseFolderLevelPermissions(),\n \"advancedAccessControlLayer.hcmsFieldPermissions\": l => l.canUseHcmsFieldPermissions(),\n auditLogs: l => l.canUseAuditLogs(),\n recordLocking: l => l.canUseRecordLocking(),\n \"fileManager.threatDetection\": l => l.canUseFileManagerThreatDetection(),\n aiPowerups: l => l.canUseAiPowerups(),\n \"aiPowerups.fileManager.imageEnrichment\": l => l.canUseAiImageEnrichment(),\n \"aiPowerups.websiteBuilder.pageGeneration\": l => l.canUseAiPageGeneration(),\n \"aiPowerups.websiteBuilder.pageTranslation\": l => l.canUseAiPageTranslation(),\n \"aiPowerups.lexicalGeneration\": l => l.canUseAiLexicalGeneration(),\n \"aiPowerups.adminAssistant\": l => l.canUseAiAdminAssistant(),\n \"aiPowerups.cms.entryGeneration\": l => l.canUseAiEntryGeneration(),\n \"aiPowerups.cms.entryComparison\": l => l.canUseAiEntryComparison(),\n \"aiPowerups.cms.entryTranslation\": l => l.canUseAiEntryTranslation(),\n abTesting: l => l.canUseAbTesting(),\n collaboration: l => l.canUseCollaboration(),\n \"collaboration.comments\": l => l.canUseComments(),\n \"collaboration.activityLog\": l => l.canUseActivityLog()\n};\n\nclass LicenseDecoratedFeatureFlags extends FeatureFlagsClass {\n constructor(\n private base: FeatureFlagsClass,\n private license: ILicense\n ) {\n super(base.toDto());\n }\n\n override isEnabled(name: FeatureFlagName): boolean {\n const check = LICENSE_CHECKS[name];\n if (check) {\n if (!check(this.license)) {\n return false;\n }\n // License allows — config can only disable, not re-enable blocked features.\n return !this.base.isExplicitlyDisabled(name);\n }\n /*\n * Everything else is the project's own, and the config is the only thing that decides. No\n * default: `isEnabled` on the base is true only for an explicitly configured `true`.\n *\n * This branch used to return `!isExplicitlyDisabled(name)` whenever a license existed, which\n * made EVERY unrecognised name true — an undeclared flag, or a typo like `aiPowerupz`. It also\n * returned false outright without a license, so an unlicensed install could not turn on a flag\n * it had declared itself. Neither is the license's business.\n */\n return this.base.isEnabled(name);\n }\n}\n\nclass FeatureFlagsWithLicenseDecoratorImpl implements FeatureFlags.Interface {\n constructor(\n private licenseProvider: WcpLicenseProvider.Interface,\n private decoratee: FeatureFlags.Interface\n ) {}\n\n get(): FeatureFlagsClass {\n const base = this.decoratee.get();\n return new LicenseDecoratedFeatureFlags(base, this.licenseProvider.get());\n }\n}\n\nexport const FeatureFlagsWithLicenseDecorator = FeatureFlags.createDecorator({\n decorator: FeatureFlagsWithLicenseDecoratorImpl,\n dependencies: [WcpLicenseProvider]\n});\n"],"names":["LICENSE_CHECKS","l","LicenseDecoratedFeatureFlags","FeatureFlagsClass","base","license","name","check","FeatureFlagsWithLicenseDecoratorImpl","licenseProvider","decoratee","FeatureFlagsWithLicenseDecorator","FeatureFlags","WcpLicenseProvider"],"mappings":";;;AA2BA,MAAMA,iBAAiE;IACnE,cAAcC,CAAAA,IAAKA,EAAE,aAAa,CAAC;IACnC,WAAWA,CAAAA,IAAKA,EAAE,eAAe;IACjC,4BAA4BA,CAAAA,IAAKA,EAAE,eAAe;IAClD,4BAA4BA,CAAAA,IAAKA,EAAE,UAAU;IAC7C,oCAAoCA,CAAAA,IAAKA,EAAE,WAAW;IACtD,2CAA2CA,CAAAA,IAAKA,EAAE,kBAAkB;IACpE,qDAAqDA,CAAAA,IAAKA,EAAE,4BAA4B;IACxF,mDAAmDA,CAAAA,IAAKA,EAAE,0BAA0B;IACpF,WAAWA,CAAAA,IAAKA,EAAE,eAAe;IACjC,eAAeA,CAAAA,IAAKA,EAAE,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,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,11 @@
|
|
|
1
|
+
import { HashingConfig } from "./abstractions.js";
|
|
2
|
+
import { BuildParams } from "../buildParams/abstractions.js";
|
|
3
|
+
declare class BuildParamsHashingConfigImpl implements HashingConfig.Interface {
|
|
4
|
+
readonly pepper: string;
|
|
5
|
+
readonly costN: number | null;
|
|
6
|
+
constructor(buildParams: BuildParams.Interface);
|
|
7
|
+
}
|
|
8
|
+
export declare const BuildParamsHashingConfig: typeof BuildParamsHashingConfigImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IHashingConfig>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HashingConfig } from "./abstractions.js";
|
|
2
|
+
import { BuildParams } from "../buildParams/abstractions.js";
|
|
3
|
+
class BuildParamsHashingConfigImpl {
|
|
4
|
+
constructor(buildParams){
|
|
5
|
+
this.pepper = buildParams.get("HashingPepper") ?? "";
|
|
6
|
+
const costN = buildParams.get("HashingCost");
|
|
7
|
+
this.costN = costN ? Number(costN) : null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const BuildParamsHashingConfig = HashingConfig.createImplementation({
|
|
11
|
+
implementation: BuildParamsHashingConfigImpl,
|
|
12
|
+
dependencies: [
|
|
13
|
+
BuildParams
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
export { BuildParamsHashingConfig };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=BuildParamsHashingConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/hashing/BuildParamsHashingConfig.js","sources":["../../../src/features/hashing/BuildParamsHashingConfig.ts"],"sourcesContent":["import { HashingConfig } from \"./abstractions.js\";\nimport { BuildParams } from \"../buildParams/abstractions.js\";\n\nclass BuildParamsHashingConfigImpl implements HashingConfig.Interface {\n readonly pepper: string;\n readonly costN: number | null;\n\n constructor(buildParams: BuildParams.Interface) {\n this.pepper = buildParams.get<string>(\"HashingPepper\") ?? \"\";\n const costN = buildParams.get<number | string>(\"HashingCost\");\n this.costN = costN ? Number(costN) : null;\n }\n}\n\nexport const BuildParamsHashingConfig = HashingConfig.createImplementation({\n implementation: BuildParamsHashingConfigImpl,\n dependencies: [BuildParams]\n});\n"],"names":["BuildParamsHashingConfigImpl","buildParams","costN","Number","BuildParamsHashingConfig","HashingConfig","BuildParams"],"mappings":";;AAGA,MAAMA;IAIF,YAAYC,WAAkC,CAAE;QAC5C,IAAI,CAAC,MAAM,GAAGA,YAAY,GAAG,CAAS,oBAAoB;QAC1D,MAAMC,QAAQD,YAAY,GAAG,CAAkB;QAC/C,IAAI,CAAC,KAAK,GAAGC,QAAQC,OAAOD,SAAS;IACzC;AACJ;AAEO,MAAME,2BAA2BC,cAAc,oBAAoB,CAAC;IACvE,gBAAgBL;IAChB,cAAc;QAACM;KAAY;AAC/B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IHasher } from "./abstractions.js";
|
|
2
|
-
import {
|
|
2
|
+
import { HashingConfig } from "./abstractions.js";
|
|
3
3
|
export declare class ScryptHasher implements IHasher {
|
|
4
4
|
private readonly cost;
|
|
5
5
|
private readonly pepper;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(config: HashingConfig.Interface);
|
|
7
7
|
hash(value: string): Promise<string>;
|
|
8
8
|
verify(value: string, storedHash: string): Promise<boolean>;
|
|
9
9
|
private withPepper;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
2
2
|
import { createImplementation } from "@webiny/feature/api";
|
|
3
|
-
import { Hasher } from "./abstractions.js";
|
|
4
|
-
import { BuildParams } from "../buildParams/abstractions.js";
|
|
3
|
+
import { Hasher, HashingConfig } from "./abstractions.js";
|
|
5
4
|
const ScryptHasher_scrypt = (value, salt, keylen, options)=>new Promise((resolve, reject)=>{
|
|
6
5
|
scrypt(value, salt, keylen, options, (err, derivedKey)=>{
|
|
7
6
|
if (err) reject(err);
|
|
@@ -17,12 +16,11 @@ const DEFAULT_COST = {
|
|
|
17
16
|
p: 1
|
|
18
17
|
};
|
|
19
18
|
class ScryptHasher {
|
|
20
|
-
constructor(
|
|
21
|
-
this.pepper =
|
|
22
|
-
|
|
23
|
-
this.cost = costN ? {
|
|
19
|
+
constructor(config){
|
|
20
|
+
this.pepper = config.pepper;
|
|
21
|
+
this.cost = config.costN ? {
|
|
24
22
|
...DEFAULT_COST,
|
|
25
|
-
N:
|
|
23
|
+
N: config.costN
|
|
26
24
|
} : DEFAULT_COST;
|
|
27
25
|
}
|
|
28
26
|
async hash(value) {
|
|
@@ -66,7 +64,7 @@ const ScryptHasher_Hasher = createImplementation({
|
|
|
66
64
|
abstraction: Hasher,
|
|
67
65
|
implementation: ScryptHasher,
|
|
68
66
|
dependencies: [
|
|
69
|
-
|
|
67
|
+
HashingConfig
|
|
70
68
|
]
|
|
71
69
|
});
|
|
72
70
|
export { ScryptHasher, ScryptHasher_Hasher as Hasher };
|