@webiny/api-core 6.3.0-beta.4 → 6.4.0-beta.0
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 +18 -18
- package/ApiCoreFeature.js.map +1 -1
- package/createApiCore.d.ts +1 -1
- package/createApiCore.js +14 -9
- package/createApiCore.js.map +1 -1
- package/domain/identity/SystemIdentityValue.js +9 -8
- package/domain/identity/SystemIdentityValue.js.map +1 -1
- package/domain/security/ApiToken.js +5 -11
- package/domain/security/ApiToken.js.map +1 -1
- package/domain/tenancy/RootTenantValue.js +9 -8
- package/domain/tenancy/RootTenantValue.js.map +1 -1
- package/domain/tenancy/errors.js +0 -3
- package/exports/api/build-params.js +0 -3
- package/exports/api/event-publisher.js +0 -3
- package/exports/api/graphql.js +0 -2
- package/exports/api/key-value-store.js +0 -3
- package/exports/api/logger.js +0 -3
- package/exports/api/security/api-key.js +0 -2
- package/exports/api/security/authentication.js +0 -2
- package/exports/api/security/role.js +1 -3
- package/exports/api/security/user.js +0 -2
- package/exports/api/security.js +3 -7
- package/exports/api/system.js +0 -2
- package/exports/api/tasks.js +0 -2
- package/exports/api/tenancy.js +4 -6
- package/exports/api.js +1 -3
- package/features/ai/Ai.js +100 -117
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AiSdkTools.js +23 -19
- package/features/ai/AiSdkTools.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +82 -65
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/OpenAiSdkFactory.js +234 -181
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/abstractions.js +7 -32
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/feature.js +9 -8
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.js +1 -3
- package/features/buildParams/BuildParams.js +20 -14
- package/features/buildParams/BuildParams.js.map +1 -1
- package/features/buildParams/abstractions.js +3 -4
- package/features/buildParams/abstractions.js.map +1 -1
- package/features/buildParams/feature.js +6 -5
- package/features/buildParams/feature.js.map +1 -1
- package/features/buildParams/index.js +0 -2
- package/features/encryption/EncryptionService.js +50 -46
- package/features/encryption/EncryptionService.js.map +1 -1
- package/features/encryption/abstractions.js +2 -2
- package/features/encryption/abstractions.js.map +1 -1
- package/features/encryption/feature.js +6 -5
- package/features/encryption/feature.js.map +1 -1
- package/features/encryption/index.js +0 -2
- package/features/eventPublisher/EventPublisher.js +9 -15
- package/features/eventPublisher/EventPublisher.js.map +1 -1
- package/features/eventPublisher/__tests__/EventPublisher.test.js +385 -419
- package/features/eventPublisher/__tests__/EventPublisher.test.js.map +1 -1
- package/features/eventPublisher/abstractions.js +7 -12
- package/features/eventPublisher/abstractions.js.map +1 -1
- package/features/eventPublisher/feature.js +8 -7
- package/features/eventPublisher/feature.js.map +1 -1
- package/features/eventPublisher/index.js +0 -2
- package/features/featureFlags/FeatureFlags.js +15 -12
- package/features/featureFlags/FeatureFlags.js.map +1 -1
- package/features/featureFlags/abstractions.js +2 -1
- package/features/featureFlags/abstractions.js.map +1 -1
- package/features/featureFlags/feature.js +6 -5
- package/features/featureFlags/feature.js.map +1 -1
- package/features/keyValueStore/GlobalKeyValueStore.js +28 -23
- package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStore.js +30 -27
- package/features/keyValueStore/KeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStoreRepository.d.ts +2 -2
- package/features/keyValueStore/KeyValueStoreRepository.js +34 -41
- package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
- package/features/keyValueStore/abstractions.d.ts +6 -2
- package/features/keyValueStore/abstractions.js +5 -20
- package/features/keyValueStore/abstractions.js.map +1 -1
- package/features/keyValueStore/errors.js +16 -17
- package/features/keyValueStore/errors.js.map +1 -1
- package/features/keyValueStore/feature.js +9 -9
- package/features/keyValueStore/feature.js.map +1 -1
- package/features/keyValueStore/index.js +1 -3
- package/features/logger/LoggerService.js +41 -45
- package/features/logger/LoggerService.js.map +1 -1
- package/features/logger/abstractions.js +2 -2
- package/features/logger/abstractions.js.map +1 -1
- package/features/logger/feature.js +6 -5
- package/features/logger/feature.js.map +1 -1
- package/features/logger/index.js +0 -2
- package/features/masker/Masker.js +11 -14
- package/features/masker/Masker.js.map +1 -1
- package/features/masker/abstractions.js +2 -1
- package/features/masker/abstractions.js.map +1 -1
- package/features/masker/feature.js +7 -6
- package/features/masker/feature.js.map +1 -1
- package/features/masker/index.js +0 -2
- package/features/security/IdentityContext/AnonymousIdentity.js +12 -16
- package/features/security/IdentityContext/AnonymousIdentity.js.map +1 -1
- package/features/security/IdentityContext/AuthenticatedIdentity.js +5 -8
- package/features/security/IdentityContext/AuthenticatedIdentity.js.map +1 -1
- package/features/security/IdentityContext/Identity.js +63 -71
- package/features/security/IdentityContext/Identity.js.map +1 -1
- package/features/security/IdentityContext/IdentityContext.js +69 -106
- package/features/security/IdentityContext/IdentityContext.js.map +1 -1
- package/features/security/IdentityContext/abstractions.js +2 -2
- package/features/security/IdentityContext/abstractions.js.map +1 -1
- package/features/security/IdentityContext/feature.js +6 -5
- package/features/security/IdentityContext/feature.js.map +1 -1
- package/features/security/IdentityContext/index.js +0 -3
- package/features/security/SecurityFeature.js +13 -21
- package/features/security/SecurityFeature.js.map +1 -1
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +48 -49
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/CreateApiKey/abstractions.js +2 -2
- package/features/security/apiKeys/CreateApiKey/abstractions.js.map +1 -1
- package/features/security/apiKeys/CreateApiKey/events.js +17 -16
- package/features/security/apiKeys/CreateApiKey/events.js.map +1 -1
- package/features/security/apiKeys/CreateApiKey/feature.js +6 -5
- package/features/security/apiKeys/CreateApiKey/feature.js.map +1 -1
- package/features/security/apiKeys/CreateApiKey/index.js +0 -2
- package/features/security/apiKeys/DeleteApiKey/DeleteApiKeyUseCase.js +29 -30
- package/features/security/apiKeys/DeleteApiKey/DeleteApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/DeleteApiKey/abstractions.js +2 -2
- package/features/security/apiKeys/DeleteApiKey/abstractions.js.map +1 -1
- package/features/security/apiKeys/DeleteApiKey/events.js +17 -16
- package/features/security/apiKeys/DeleteApiKey/events.js.map +1 -1
- package/features/security/apiKeys/DeleteApiKey/feature.js +6 -5
- package/features/security/apiKeys/DeleteApiKey/feature.js.map +1 -1
- package/features/security/apiKeys/DeleteApiKey/index.js +0 -2
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js +16 -14
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKey/abstractions.js +2 -2
- package/features/security/apiKeys/GetApiKey/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKey/feature.js +6 -5
- package/features/security/apiKeys/GetApiKey/feature.js.map +1 -1
- package/features/security/apiKeys/GetApiKey/index.js +0 -2
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js +13 -10
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js +2 -2
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/feature.js +6 -5
- package/features/security/apiKeys/GetApiKeyBySlug/feature.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/index.js +0 -2
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js +13 -10
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js +2 -2
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/feature.js +6 -5
- package/features/security/apiKeys/GetApiKeyByToken/feature.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/index.js +0 -2
- package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.js +17 -17
- package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.js.map +1 -1
- package/features/security/apiKeys/ListApiKeys/abstractions.js +2 -2
- package/features/security/apiKeys/ListApiKeys/abstractions.js.map +1 -1
- package/features/security/apiKeys/ListApiKeys/feature.js +6 -5
- package/features/security/apiKeys/ListApiKeys/feature.js.map +1 -1
- package/features/security/apiKeys/ListApiKeys/index.js +0 -2
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +39 -42
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/abstractions.js +2 -2
- package/features/security/apiKeys/UpdateApiKey/abstractions.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/events.js +17 -16
- package/features/security/apiKeys/UpdateApiKey/events.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/feature.js +6 -5
- package/features/security/apiKeys/UpdateApiKey/feature.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/index.js +0 -2
- package/features/security/apiKeys/feature.js +14 -16
- package/features/security/apiKeys/feature.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeyProvider.js +42 -42
- package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeysRepository.js +108 -135
- package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
- package/features/security/apiKeys/shared/abstractions.js +4 -6
- package/features/security/apiKeys/shared/abstractions.js.map +1 -1
- package/features/security/apiKeys/shared/errors.js +29 -32
- package/features/security/apiKeys/shared/errors.js.map +1 -1
- package/features/security/apiKeys/shared/generateToken.js +6 -16
- package/features/security/apiKeys/shared/generateToken.js.map +1 -1
- package/features/security/apiKeys/shared/schemas.js +27 -23
- package/features/security/apiKeys/shared/schemas.js.map +1 -1
- package/features/security/apiKeys/shared/types.js +0 -3
- package/features/security/authentication/AuthenticationContext/AuthenticationContext.js +44 -38
- package/features/security/authentication/AuthenticationContext/AuthenticationContext.js.map +1 -1
- package/features/security/authentication/AuthenticationContext/SetIdTokenCookie.js +33 -43
- package/features/security/authentication/AuthenticationContext/SetIdTokenCookie.js.map +1 -1
- package/features/security/authentication/AuthenticationContext/abstractions.js +2 -2
- package/features/security/authentication/AuthenticationContext/abstractions.js.map +1 -1
- package/features/security/authentication/AuthenticationContext/errors.js +51 -116
- package/features/security/authentication/AuthenticationContext/errors.js.map +1 -1
- package/features/security/authentication/AuthenticationContext/events.js +17 -16
- package/features/security/authentication/AuthenticationContext/events.js.map +1 -1
- package/features/security/authentication/AuthenticationContext/feature.js +6 -5
- package/features/security/authentication/AuthenticationContext/feature.js.map +1 -1
- package/features/security/authentication/AuthenticationContext/index.js +2 -4
- package/features/security/authentication/Authenticator/abstractions.js +2 -2
- package/features/security/authentication/Authenticator/abstractions.js.map +1 -1
- package/features/security/authentication/Authenticator/index.js +0 -2
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +46 -59
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/abstractions.js +3 -4
- package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/feature.js +10 -9
- package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/index.js +1 -4
- package/features/security/authorization/Authorizer/abstractions.js +2 -2
- package/features/security/authorization/Authorizer/abstractions.js.map +1 -1
- package/features/security/authorization/Authorizer/index.js +0 -2
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +60 -64
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/RolesTeamsAuthorizer.js +26 -40
- package/features/security/authorization/GroupsTeamsAuthorizer/RolesTeamsAuthorizer.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/abstractions.js +2 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/abstractions.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +7 -6
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
- package/features/security/login/abstractions.js +9 -8
- package/features/security/login/abstractions.js.map +1 -1
- package/features/security/login/index.js +0 -2
- package/features/security/permissions/createPermissionSchema.js +6 -5
- package/features/security/permissions/createPermissionSchema.js.map +1 -1
- package/features/security/permissions/createPermissions.js +148 -236
- package/features/security/permissions/createPermissions.js.map +1 -1
- package/features/security/permissions/index.js +0 -2
- package/features/security/permissions/types.js +0 -3
- package/features/security/roles/CreateRole/CreateRoleUseCase.js +53 -59
- package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
- package/features/security/roles/CreateRole/abstractions.js +2 -2
- package/features/security/roles/CreateRole/abstractions.js.map +1 -1
- package/features/security/roles/CreateRole/events.js +17 -16
- package/features/security/roles/CreateRole/events.js.map +1 -1
- package/features/security/roles/CreateRole/feature.js +6 -5
- package/features/security/roles/CreateRole/feature.js.map +1 -1
- package/features/security/roles/CreateRole/index.js +0 -2
- package/features/security/roles/CreateRole/schema.js +8 -7
- package/features/security/roles/CreateRole/schema.js.map +1 -1
- package/features/security/roles/DeleteRole/DeleteRoleUseCase.js +35 -41
- package/features/security/roles/DeleteRole/DeleteRoleUseCase.js.map +1 -1
- package/features/security/roles/DeleteRole/abstractions.js +2 -2
- package/features/security/roles/DeleteRole/abstractions.js.map +1 -1
- package/features/security/roles/DeleteRole/events.js +17 -16
- package/features/security/roles/DeleteRole/events.js.map +1 -1
- package/features/security/roles/DeleteRole/feature.js +6 -5
- package/features/security/roles/DeleteRole/feature.js.map +1 -1
- package/features/security/roles/DeleteRole/index.js +0 -2
- package/features/security/roles/GetRole/GetRoleUseCase.js +19 -18
- package/features/security/roles/GetRole/GetRoleUseCase.js.map +1 -1
- package/features/security/roles/GetRole/abstractions.js +2 -2
- package/features/security/roles/GetRole/abstractions.js.map +1 -1
- package/features/security/roles/GetRole/feature.js +6 -5
- package/features/security/roles/GetRole/feature.js.map +1 -1
- package/features/security/roles/GetRole/index.js +0 -2
- package/features/security/roles/Installer/RolesInstaller.js +38 -35
- package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
- package/features/security/roles/ListRoles/ListRolesUseCase.js +18 -17
- package/features/security/roles/ListRoles/ListRolesUseCase.js.map +1 -1
- package/features/security/roles/ListRoles/abstractions.js +2 -2
- package/features/security/roles/ListRoles/abstractions.js.map +1 -1
- package/features/security/roles/ListRoles/feature.js +6 -5
- package/features/security/roles/ListRoles/feature.js.map +1 -1
- package/features/security/roles/ListRoles/index.js +0 -2
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +43 -50
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
- package/features/security/roles/UpdateRole/abstractions.js +2 -2
- package/features/security/roles/UpdateRole/abstractions.js.map +1 -1
- package/features/security/roles/UpdateRole/events.js +17 -16
- package/features/security/roles/UpdateRole/events.js.map +1 -1
- package/features/security/roles/UpdateRole/feature.js +6 -5
- package/features/security/roles/UpdateRole/feature.js.map +1 -1
- package/features/security/roles/UpdateRole/index.js +0 -2
- package/features/security/roles/UpdateRole/schema.js +7 -6
- package/features/security/roles/UpdateRole/schema.js.map +1 -1
- package/features/security/roles/feature.js +14 -18
- package/features/security/roles/feature.js.map +1 -1
- package/features/security/roles/shared/RoleProvider.js +27 -21
- package/features/security/roles/shared/RoleProvider.js.map +1 -1
- package/features/security/roles/shared/RolesRepository.js +96 -113
- package/features/security/roles/shared/RolesRepository.js.map +1 -1
- package/features/security/roles/shared/abstractions.js +3 -4
- package/features/security/roles/shared/abstractions.js.map +1 -1
- package/features/security/roles/shared/decorators/ListCache.js +23 -22
- package/features/security/roles/shared/decorators/ListCache.js.map +1 -1
- package/features/security/roles/shared/decorators/RolesRepositoryCachingDecorator.js +40 -62
- package/features/security/roles/shared/decorators/RolesRepositoryCachingDecorator.js.map +1 -1
- package/features/security/roles/shared/errors.js +50 -56
- package/features/security/roles/shared/errors.js.map +1 -1
- package/features/security/roles/shared/types.js +0 -3
- package/features/security/shared/abstractions.js +4 -6
- package/features/security/shared/abstractions.js.map +1 -1
- package/features/security/shared/errors.js +8 -8
- package/features/security/shared/errors.js.map +1 -1
- package/features/security/shared/index.js +0 -2
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js +53 -59
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
- package/features/security/teams/CreateTeam/abstractions.js +2 -2
- package/features/security/teams/CreateTeam/abstractions.js.map +1 -1
- package/features/security/teams/CreateTeam/events.js +17 -16
- package/features/security/teams/CreateTeam/events.js.map +1 -1
- package/features/security/teams/CreateTeam/feature.js +6 -5
- package/features/security/teams/CreateTeam/feature.js.map +1 -1
- package/features/security/teams/CreateTeam/index.js +0 -2
- package/features/security/teams/CreateTeam/schema.js +6 -5
- package/features/security/teams/CreateTeam/schema.js.map +1 -1
- package/features/security/teams/DeleteTeam/DeleteTeamUseCase.js +36 -46
- package/features/security/teams/DeleteTeam/DeleteTeamUseCase.js.map +1 -1
- package/features/security/teams/DeleteTeam/abstractions.js +2 -2
- package/features/security/teams/DeleteTeam/abstractions.js.map +1 -1
- package/features/security/teams/DeleteTeam/events.js +17 -16
- package/features/security/teams/DeleteTeam/events.js.map +1 -1
- package/features/security/teams/DeleteTeam/feature.js +6 -5
- package/features/security/teams/DeleteTeam/feature.js.map +1 -1
- package/features/security/teams/DeleteTeam/index.js +0 -2
- package/features/security/teams/GetTeam/GetTeamUseCase.js +17 -17
- package/features/security/teams/GetTeam/GetTeamUseCase.js.map +1 -1
- package/features/security/teams/GetTeam/abstractions.js +2 -2
- package/features/security/teams/GetTeam/abstractions.js.map +1 -1
- package/features/security/teams/GetTeam/feature.js +6 -5
- package/features/security/teams/GetTeam/feature.js.map +1 -1
- package/features/security/teams/GetTeam/index.js +0 -2
- package/features/security/teams/ListTeams/ListTeamsUseCase.js +20 -21
- package/features/security/teams/ListTeams/ListTeamsUseCase.js.map +1 -1
- package/features/security/teams/ListTeams/abstractions.js +2 -2
- package/features/security/teams/ListTeams/abstractions.js.map +1 -1
- package/features/security/teams/ListTeams/feature.js +6 -5
- package/features/security/teams/ListTeams/feature.js.map +1 -1
- package/features/security/teams/ListTeams/index.js +0 -2
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +46 -58
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
- package/features/security/teams/UpdateTeam/abstractions.js +2 -2
- package/features/security/teams/UpdateTeam/abstractions.js.map +1 -1
- package/features/security/teams/UpdateTeam/events.js +17 -16
- package/features/security/teams/UpdateTeam/events.js.map +1 -1
- package/features/security/teams/UpdateTeam/feature.js +6 -5
- package/features/security/teams/UpdateTeam/feature.js.map +1 -1
- package/features/security/teams/UpdateTeam/index.js +0 -2
- package/features/security/teams/UpdateTeam/schema.js +5 -4
- package/features/security/teams/UpdateTeam/schema.js.map +1 -1
- package/features/security/teams/feature.js +13 -17
- package/features/security/teams/feature.js.map +1 -1
- package/features/security/teams/shared/TeamProvider.js +27 -21
- package/features/security/teams/shared/TeamProvider.js.map +1 -1
- package/features/security/teams/shared/TeamsRepository.js +100 -118
- package/features/security/teams/shared/TeamsRepository.js.map +1 -1
- package/features/security/teams/shared/abstractions.js +3 -4
- package/features/security/teams/shared/abstractions.js.map +1 -1
- package/features/security/teams/shared/decorators/TeamsRepositoryCachingDecorator.js +40 -62
- package/features/security/teams/shared/decorators/TeamsRepositoryCachingDecorator.js.map +1 -1
- package/features/security/teams/shared/errors.js +62 -70
- package/features/security/teams/shared/errors.js.map +1 -1
- package/features/security/teams/shared/types.js +0 -3
- package/features/security/utils/AppPermissions.js +50 -89
- package/features/security/utils/AppPermissions.js.map +1 -1
- package/features/security/utils/IdentityValue.js +19 -22
- package/features/security/utils/IdentityValue.js.map +1 -1
- package/features/security/utils/filterOutCustomWbyAppsPermissions.js +24 -27
- package/features/security/utils/filterOutCustomWbyAppsPermissions.js.map +1 -1
- package/features/security/utils/getPermissionsFromRoles.js +5 -10
- package/features/security/utils/getPermissionsFromRoles.js.map +1 -1
- package/features/security/utils/isJwt.js +2 -1
- package/features/security/utils/isJwt.js.map +1 -1
- package/features/security/utils/verifyJwtUsingJwk.js +6 -7
- package/features/security/utils/verifyJwtUsingJwk.js.map +1 -1
- package/features/system/InstallSystem/InstallSystemUseCase.js +45 -44
- package/features/system/InstallSystem/InstallSystemUseCase.js.map +1 -1
- package/features/system/InstallSystem/abstractions.js +3 -17
- package/features/system/InstallSystem/abstractions.js.map +1 -1
- package/features/system/InstallSystem/errors.js +15 -16
- package/features/system/InstallSystem/errors.js.map +1 -1
- package/features/system/InstallSystem/events.js +8 -5
- package/features/system/InstallSystem/events.js.map +1 -1
- package/features/system/InstallSystem/feature.js +6 -7
- package/features/system/InstallSystem/feature.js.map +1 -1
- package/features/system/InstallSystem/index.js +2 -6
- package/features/system/SystemFeature.js +6 -5
- package/features/system/SystemFeature.js.map +1 -1
- package/features/task/TaskController/abstractions.js +2 -10
- package/features/task/TaskController/abstractions.js.map +1 -1
- package/features/task/TaskController/index.js +0 -2
- package/features/task/TaskDefinition/abstractions.js +8 -40
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/task/TaskDefinition/index.js +0 -2
- package/features/task/TaskService/abstractions.js +9 -13
- package/features/task/TaskService/abstractions.js.map +1 -1
- package/features/task/TaskService/index.js +0 -2
- package/features/tenancy/CreateTenant/CreateTenantGateway.js +14 -11
- package/features/tenancy/CreateTenant/CreateTenantGateway.js.map +1 -1
- package/features/tenancy/CreateTenant/CreateTenantRepository.js +18 -15
- package/features/tenancy/CreateTenant/CreateTenantRepository.js.map +1 -1
- package/features/tenancy/CreateTenant/CreateTenantUseCase.js +44 -41
- package/features/tenancy/CreateTenant/CreateTenantUseCase.js.map +1 -1
- package/features/tenancy/CreateTenant/abstractions.js +6 -29
- package/features/tenancy/CreateTenant/abstractions.js.map +1 -1
- package/features/tenancy/CreateTenant/decorators/CreateTenantWithWcpIncrement.js +16 -15
- package/features/tenancy/CreateTenant/decorators/CreateTenantWithWcpIncrement.js.map +1 -1
- package/features/tenancy/CreateTenant/errors.js +8 -8
- package/features/tenancy/CreateTenant/errors.js.map +1 -1
- package/features/tenancy/CreateTenant/events.js +16 -11
- package/features/tenancy/CreateTenant/events.js.map +1 -1
- package/features/tenancy/CreateTenant/feature.js +9 -8
- package/features/tenancy/CreateTenant/feature.js.map +1 -1
- package/features/tenancy/CreateTenant/index.js +2 -4
- package/features/tenancy/DeleteTenant/DeleteTenantGateway.js +15 -12
- package/features/tenancy/DeleteTenant/DeleteTenantGateway.js.map +1 -1
- package/features/tenancy/DeleteTenant/DeleteTenantRepository.js +22 -19
- package/features/tenancy/DeleteTenant/DeleteTenantRepository.js.map +1 -1
- package/features/tenancy/DeleteTenant/DeleteTenantUseCase.js +29 -27
- package/features/tenancy/DeleteTenant/DeleteTenantUseCase.js.map +1 -1
- package/features/tenancy/DeleteTenant/abstractions.js +6 -10
- package/features/tenancy/DeleteTenant/abstractions.js.map +1 -1
- package/features/tenancy/DeleteTenant/decorators/DeleteTenantWithWcpDecrement.js +16 -13
- package/features/tenancy/DeleteTenant/decorators/DeleteTenantWithWcpDecrement.js.map +1 -1
- package/features/tenancy/DeleteTenant/events.js +16 -11
- package/features/tenancy/DeleteTenant/events.js.map +1 -1
- package/features/tenancy/DeleteTenant/feature.js +9 -8
- package/features/tenancy/DeleteTenant/feature.js.map +1 -1
- package/features/tenancy/DeleteTenant/index.js +2 -4
- package/features/tenancy/GetRootTenant/GetRootTenantUseCase.js +15 -12
- package/features/tenancy/GetRootTenant/GetRootTenantUseCase.js.map +1 -1
- package/features/tenancy/GetRootTenant/abstractions.js +2 -4
- package/features/tenancy/GetRootTenant/abstractions.js.map +1 -1
- package/features/tenancy/GetRootTenant/feature.js +6 -5
- package/features/tenancy/GetRootTenant/feature.js.map +1 -1
- package/features/tenancy/GetRootTenant/index.js +0 -2
- package/features/tenancy/GetTenantById/GetTenantByIdGateway.js +17 -12
- package/features/tenancy/GetTenantById/GetTenantByIdGateway.js.map +1 -1
- package/features/tenancy/GetTenantById/GetTenantByIdRepository.js +18 -19
- package/features/tenancy/GetTenantById/GetTenantByIdRepository.js.map +1 -1
- package/features/tenancy/GetTenantById/GetTenantByIdUseCase.js +17 -17
- package/features/tenancy/GetTenantById/GetTenantByIdUseCase.js.map +1 -1
- package/features/tenancy/GetTenantById/abstractions.js +4 -6
- package/features/tenancy/GetTenantById/abstractions.js.map +1 -1
- package/features/tenancy/GetTenantById/feature.js +8 -12
- package/features/tenancy/GetTenantById/feature.js.map +1 -1
- package/features/tenancy/GetTenantById/index.js +1 -3
- package/features/tenancy/InstallTenant/DependencyResolver.js +53 -65
- package/features/tenancy/InstallTenant/DependencyResolver.js.map +1 -1
- package/features/tenancy/InstallTenant/InstallTenantUseCase.js +95 -113
- package/features/tenancy/InstallTenant/InstallTenantUseCase.js.map +1 -1
- package/features/tenancy/InstallTenant/abstractions.js +4 -15
- package/features/tenancy/InstallTenant/abstractions.js.map +1 -1
- package/features/tenancy/InstallTenant/errors.js +15 -16
- package/features/tenancy/InstallTenant/errors.js.map +1 -1
- package/features/tenancy/InstallTenant/events.js +8 -5
- package/features/tenancy/InstallTenant/events.js.map +1 -1
- package/features/tenancy/InstallTenant/feature.js +6 -5
- package/features/tenancy/InstallTenant/feature.js.map +1 -1
- package/features/tenancy/InstallTenant/index.js +1 -3
- package/features/tenancy/ListTenants/ListTenantsGateway.js +14 -11
- package/features/tenancy/ListTenants/ListTenantsGateway.js.map +1 -1
- package/features/tenancy/ListTenants/ListTenantsRepository.js +14 -12
- package/features/tenancy/ListTenants/ListTenantsRepository.js.map +1 -1
- package/features/tenancy/ListTenants/ListTenantsUseCase.js +16 -14
- package/features/tenancy/ListTenants/ListTenantsUseCase.js.map +1 -1
- package/features/tenancy/ListTenants/abstractions.js +4 -12
- package/features/tenancy/ListTenants/abstractions.js.map +1 -1
- package/features/tenancy/ListTenants/feature.js +8 -7
- package/features/tenancy/ListTenants/feature.js.map +1 -1
- package/features/tenancy/ListTenants/index.js +1 -3
- package/features/tenancy/TenancyFeature.js +20 -26
- package/features/tenancy/TenancyFeature.js.map +1 -1
- package/features/tenancy/TenantContext/TenantContext.js +46 -48
- package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
- package/features/tenancy/TenantContext/abstractions.js +2 -2
- package/features/tenancy/TenantContext/abstractions.js.map +1 -1
- package/features/tenancy/TenantContext/errors.js +7 -7
- package/features/tenancy/TenantContext/errors.js.map +1 -1
- package/features/tenancy/TenantContext/feature.js +6 -5
- package/features/tenancy/TenantContext/feature.js.map +1 -1
- package/features/tenancy/TenantContext/index.js +0 -2
- package/features/tenancy/UpdateTenant/UpdateTenantGateway.js +14 -11
- package/features/tenancy/UpdateTenant/UpdateTenantGateway.js.map +1 -1
- package/features/tenancy/UpdateTenant/UpdateTenantRepository.js +19 -16
- package/features/tenancy/UpdateTenant/UpdateTenantRepository.js.map +1 -1
- package/features/tenancy/UpdateTenant/UpdateTenantUseCase.js +37 -36
- package/features/tenancy/UpdateTenant/UpdateTenantUseCase.js.map +1 -1
- package/features/tenancy/UpdateTenant/abstractions.js +6 -10
- package/features/tenancy/UpdateTenant/abstractions.js.map +1 -1
- package/features/tenancy/UpdateTenant/events.js +16 -11
- package/features/tenancy/UpdateTenant/events.js.map +1 -1
- package/features/tenancy/UpdateTenant/feature.js +8 -7
- package/features/tenancy/UpdateTenant/feature.js.map +1 -1
- package/features/tenancy/UpdateTenant/index.js +2 -4
- package/features/tenancy/shared/TenantCache.js +18 -17
- package/features/tenancy/shared/TenantCache.js.map +1 -1
- package/features/tenancy/shared/abstractions.js +2 -1
- package/features/tenancy/shared/abstractions.js.map +1 -1
- package/features/tenancy/shared/storageOperations.js +2 -5
- package/features/tenancy/shared/storageOperations.js.map +1 -1
- package/features/users/AdminUsersFeature.js +15 -19
- package/features/users/AdminUsersFeature.js.map +1 -1
- package/features/users/CreateUser/CreateUserUseCase.js +65 -100
- package/features/users/CreateUser/CreateUserUseCase.js.map +1 -1
- package/features/users/CreateUser/abstractions.js +2 -13
- package/features/users/CreateUser/abstractions.js.map +1 -1
- package/features/users/CreateUser/decorators/CreateUserWithWcpIncrement.js +16 -15
- package/features/users/CreateUser/decorators/CreateUserWithWcpIncrement.js.map +1 -1
- package/features/users/CreateUser/events.js +17 -18
- package/features/users/CreateUser/events.js.map +1 -1
- package/features/users/CreateUser/feature.js +7 -6
- package/features/users/CreateUser/feature.js.map +1 -1
- package/features/users/CreateUser/index.js +0 -2
- package/features/users/CreateUser/schema.js +14 -18
- package/features/users/CreateUser/schema.js.map +1 -1
- package/features/users/DeleteUser/DeleteUserUseCase.js +35 -50
- package/features/users/DeleteUser/DeleteUserUseCase.js.map +1 -1
- package/features/users/DeleteUser/abstractions.js +2 -13
- package/features/users/DeleteUser/abstractions.js.map +1 -1
- package/features/users/DeleteUser/decorators/DeleteUserWithWcpDecrement.js +15 -16
- package/features/users/DeleteUser/decorators/DeleteUserWithWcpDecrement.js.map +1 -1
- package/features/users/DeleteUser/errors.js +7 -7
- package/features/users/DeleteUser/errors.js.map +1 -1
- package/features/users/DeleteUser/events.js +17 -18
- package/features/users/DeleteUser/events.js.map +1 -1
- package/features/users/DeleteUser/feature.js +7 -6
- package/features/users/DeleteUser/feature.js.map +1 -1
- package/features/users/DeleteUser/index.js +0 -2
- package/features/users/ExternalIdpUserSync/ExternalIdpUserSyncHandler.js +60 -74
- package/features/users/ExternalIdpUserSync/ExternalIdpUserSyncHandler.js.map +1 -1
- package/features/users/ExternalIdpUserSync/feature.js +6 -5
- package/features/users/ExternalIdpUserSync/feature.js.map +1 -1
- package/features/users/ExternalIdpUserSync/index.js +0 -2
- package/features/users/GetIdentityProfile/GetIdentityProfileUseCase.js +29 -39
- package/features/users/GetIdentityProfile/GetIdentityProfileUseCase.js.map +1 -1
- package/features/users/GetIdentityProfile/abstractions.js +2 -11
- package/features/users/GetIdentityProfile/abstractions.js.map +1 -1
- package/features/users/GetIdentityProfile/feature.js +6 -5
- package/features/users/GetIdentityProfile/feature.js.map +1 -1
- package/features/users/GetIdentityProfile/index.js +0 -2
- package/features/users/GetIdentityProfile/types.js +0 -3
- package/features/users/GetUser/GetUserUseCase.js +19 -23
- package/features/users/GetUser/GetUserUseCase.js.map +1 -1
- package/features/users/GetUser/abstractions.js +2 -11
- package/features/users/GetUser/abstractions.js.map +1 -1
- package/features/users/GetUser/feature.js +6 -5
- package/features/users/GetUser/feature.js.map +1 -1
- package/features/users/GetUser/index.js +0 -2
- package/features/users/ListUserTeams/ListUserTeamsUseCase.js +33 -42
- package/features/users/ListUserTeams/ListUserTeamsUseCase.js.map +1 -1
- package/features/users/ListUserTeams/abstractions.js +2 -11
- package/features/users/ListUserTeams/abstractions.js.map +1 -1
- package/features/users/ListUserTeams/feature.js +6 -5
- package/features/users/ListUserTeams/feature.js.map +1 -1
- package/features/users/ListUserTeams/index.js +0 -2
- package/features/users/ListUsers/ListUsersUseCase.js +19 -23
- package/features/users/ListUsers/ListUsersUseCase.js.map +1 -1
- package/features/users/ListUsers/abstractions.js +2 -11
- package/features/users/ListUsers/abstractions.js.map +1 -1
- package/features/users/ListUsers/feature.js +6 -5
- package/features/users/ListUsers/feature.js.map +1 -1
- package/features/users/ListUsers/index.js +0 -2
- package/features/users/UpdateUser/UpdateUserUseCase.js +52 -74
- package/features/users/UpdateUser/UpdateUserUseCase.js.map +1 -1
- package/features/users/UpdateUser/abstractions.js +2 -13
- package/features/users/UpdateUser/abstractions.js.map +1 -1
- package/features/users/UpdateUser/events.js +17 -18
- package/features/users/UpdateUser/events.js.map +1 -1
- package/features/users/UpdateUser/feature.js +6 -5
- package/features/users/UpdateUser/feature.js.map +1 -1
- package/features/users/UpdateUser/index.js +0 -2
- package/features/users/UpdateUser/schema.js +11 -10
- package/features/users/UpdateUser/schema.js.map +1 -1
- package/features/users/shared/AdminUsersRepository.js +104 -112
- package/features/users/shared/AdminUsersRepository.js.map +1 -1
- package/features/users/shared/abstractions.js +2 -9
- package/features/users/shared/abstractions.js.map +1 -1
- package/features/users/shared/errors.js +40 -46
- package/features/users/shared/errors.js.map +1 -1
- package/features/users/shared/loaders.js +52 -66
- package/features/users/shared/loaders.js.map +1 -1
- package/features/users/shared/storageAbstractions.js +2 -2
- package/features/users/shared/storageAbstractions.js.map +1 -1
- package/features/users/shared/types.js +0 -3
- package/features/wcp/WcpContext/WcpContext.js +138 -142
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/abstractions.js +2 -6
- package/features/wcp/WcpContext/abstractions.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +135 -134
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/features/wcp/WcpContext/feature.js +6 -5
- package/features/wcp/WcpContext/feature.js.map +1 -1
- package/features/wcp/WcpContext/index.js +0 -2
- package/features/wcp/WcpContext/types.js +0 -3
- package/features/wcp/WcpContext/utils.js +35 -53
- package/features/wcp/WcpContext/utils.js.map +1 -1
- package/features/wcp/WcpFeature.js +7 -6
- package/features/wcp/WcpFeature.js.map +1 -1
- package/graphql/security/NotAuthorizedResponse.js +11 -14
- package/graphql/security/NotAuthorizedResponse.js.map +1 -1
- package/graphql/security/ProfileMapper.js +12 -11
- package/graphql/security/ProfileMapper.js.map +1 -1
- package/graphql/security/apiKey.gql.js +38 -47
- package/graphql/security/apiKey.gql.js.map +1 -1
- package/graphql/security/base.gql.js +11 -10
- package/graphql/security/base.gql.js.map +1 -1
- package/graphql/security/identity.gql.js +87 -97
- package/graphql/security/identity.gql.js.map +1 -1
- package/graphql/security/index.js +13 -8
- package/graphql/security/index.js.map +1 -1
- package/graphql/security/role.gql.js +49 -57
- package/graphql/security/role.gql.js.map +1 -1
- package/graphql/security/team.gql.js +61 -69
- package/graphql/security/team.gql.js.map +1 -1
- package/graphql/system/createSystemGraphQL.js +31 -34
- package/graphql/system/createSystemGraphQL.js.map +1 -1
- package/graphql/users/user.gql.js +87 -105
- package/graphql/users/user.gql.js.map +1 -1
- package/graphql/wcp/graphql.js +25 -28
- package/graphql/wcp/graphql.js.map +1 -1
- package/idp/JwksCache.js +22 -28
- package/idp/JwksCache.js.map +1 -1
- package/idp/JwtAuthenticator.js +34 -46
- package/idp/JwtAuthenticator.js.map +1 -1
- package/idp/OidcJwtIdentityProvider.js +55 -82
- package/idp/OidcJwtIdentityProvider.js.map +1 -1
- package/idp/abstractions.js +5 -14
- package/idp/abstractions.js.map +1 -1
- package/idp/feature.js +8 -7
- package/idp/feature.js.map +1 -1
- package/idp/index.js +1 -3
- package/idp/types.js +0 -3
- package/index.js +0 -2
- package/legacy/security/LegacyContext.js +133 -186
- package/legacy/security/LegacyContext.js.map +1 -1
- package/legacy/security/createSecurityContext.js +5 -9
- package/legacy/security/createSecurityContext.js.map +1 -1
- package/legacy/security/plugins/apiKeyAuthentication.js +15 -24
- package/legacy/security/plugins/apiKeyAuthentication.js.map +1 -1
- package/legacy/security/plugins/apiKeyAuthorization.js +9 -18
- package/legacy/security/plugins/apiKeyAuthorization.js.map +1 -1
- package/legacy/security/plugins/authenticateUsingCookie.js +18 -22
- package/legacy/security/plugins/authenticateUsingCookie.js.map +1 -1
- package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +1 -1
- package/legacy/security/plugins/authenticateUsingHttpHeader.js +15 -18
- package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +1 -1
- package/legacy/security/plugins/secureHeaders.js +28 -21
- package/legacy/security/plugins/secureHeaders.js.map +1 -1
- package/legacy/tenancy/LegacyContext.js +45 -52
- package/legacy/tenancy/LegacyContext.js.map +1 -1
- package/legacy/tenancy/createTenancyContext.js +22 -42
- package/legacy/tenancy/createTenancyContext.js.map +1 -1
- package/legacy/users/LegacyContext.js +39 -54
- package/legacy/users/LegacyContext.js.map +1 -1
- package/legacy/users/createAdminUsersContext.js +7 -7
- package/legacy/users/createAdminUsersContext.js.map +1 -1
- package/legacy/wcp/LegacyWcpContext.js +80 -79
- package/legacy/wcp/LegacyWcpContext.js.map +1 -1
- package/legacy/wcp/context.d.ts +1 -3
- package/legacy/wcp/context.js +33 -37
- package/legacy/wcp/context.js.map +1 -1
- package/models/base/BaseModel.js +51 -56
- package/models/base/BaseModel.js.map +1 -1
- package/models/base/ModelBuilder.js +65 -78
- package/models/base/ModelBuilder.js.map +1 -1
- package/models/base/ModelFactory.js +0 -3
- package/models/base/__tests__/ModelBuilder.test.js +437 -454
- package/models/base/__tests__/ModelBuilder.test.js.map +1 -1
- package/models/base/abstractions.js +0 -3
- package/models/cms/FieldBuilder.js +112 -121
- package/models/cms/FieldBuilder.js.map +1 -1
- package/models/cms/FieldBuilderRegistry.js +13 -12
- package/models/cms/FieldBuilderRegistry.js.map +1 -1
- package/models/cms/FieldDefinitionsBuilder.js +37 -54
- package/models/cms/FieldDefinitionsBuilder.js.map +1 -1
- package/models/cms/PrivateCmsModelBuilder.js +84 -89
- package/models/cms/PrivateCmsModelBuilder.js.map +1 -1
- package/models/cms/PrivatePage/Page.fields.js +7 -6
- package/models/cms/PrivatePage/Page.fields.js.map +1 -1
- package/models/cms/PrivatePage/PageModelBuilder.js +18 -15
- package/models/cms/PrivatePage/PageModelBuilder.js.map +1 -1
- package/models/cms/PrivatePage/PageModelFactory.js +20 -25
- package/models/cms/PrivatePage/PageModelFactory.js.map +1 -1
- package/models/cms/PrivatePage/__tests__/PageModelFactory.test.js +218 -234
- package/models/cms/PrivatePage/__tests__/PageModelFactory.test.js.map +1 -1
- package/models/cms/PrivatePage/__tests__/PagePublishingDecorator.js +33 -36
- package/models/cms/PrivatePage/__tests__/PagePublishingDecorator.js.map +1 -1
- package/models/cms/PrivatePage/__tests__/PageSeoDecorator.js +25 -26
- package/models/cms/PrivatePage/__tests__/PageSeoDecorator.js.map +1 -1
- package/models/cms/PrivatePage/abstractions.js +3 -9
- package/models/cms/PrivatePage/abstractions.js.map +1 -1
- package/models/cms/__tests__/PrivateCmsModelBuilder.test.js +173 -185
- package/models/cms/__tests__/PrivateCmsModelBuilder.test.js.map +1 -1
- package/models/cms/abstractions.js +3 -20
- package/models/cms/abstractions.js.map +1 -1
- package/models/cms/types.js +0 -3
- package/models/simple/Page/PageModelBuilder.js +15 -14
- package/models/simple/Page/PageModelBuilder.js.map +1 -1
- package/models/simple/Page/PageModelFactory.js +16 -15
- package/models/simple/Page/PageModelFactory.js.map +1 -1
- package/models/simple/Page/__tests__/PageModelBuilderDecorator.js +21 -20
- package/models/simple/Page/__tests__/PageModelBuilderDecorator.js.map +1 -1
- package/models/simple/Page/__tests__/PageModelBuilderDecorator2.js +17 -16
- package/models/simple/Page/__tests__/PageModelBuilderDecorator2.js.map +1 -1
- package/models/simple/Page/__tests__/PageModelFactory.test.js +28 -28
- package/models/simple/Page/__tests__/PageModelFactory.test.js.map +1 -1
- package/models/simple/Page/abstractions.js +9 -8
- package/models/simple/Page/abstractions.js.map +1 -1
- package/package.json +21 -21
- package/types/core.js +0 -3
- package/types/security.js +0 -3
- package/types/tenancy.js +0 -3
- package/types/users.js +0 -3
- package/domain/tenancy/errors.js.map +0 -1
- package/exports/api/build-params.js.map +0 -1
- package/exports/api/event-publisher.js.map +0 -1
- package/exports/api/graphql.js.map +0 -1
- package/exports/api/key-value-store.js.map +0 -1
- package/exports/api/logger.js.map +0 -1
- package/exports/api/security/api-key.js.map +0 -1
- package/exports/api/security/authentication.js.map +0 -1
- package/exports/api/security/role.js.map +0 -1
- package/exports/api/security/user.js.map +0 -1
- package/exports/api/security.js.map +0 -1
- package/exports/api/system.js.map +0 -1
- package/exports/api/tasks.js.map +0 -1
- package/exports/api/tenancy.js.map +0 -1
- package/exports/api.js.map +0 -1
- package/features/ai/index.js.map +0 -1
- package/features/buildParams/index.js.map +0 -1
- package/features/encryption/index.js.map +0 -1
- package/features/eventPublisher/index.js.map +0 -1
- package/features/keyValueStore/index.js.map +0 -1
- package/features/logger/index.js.map +0 -1
- package/features/masker/index.js.map +0 -1
- package/features/security/IdentityContext/index.js.map +0 -1
- package/features/security/apiKeys/CreateApiKey/index.js.map +0 -1
- package/features/security/apiKeys/DeleteApiKey/index.js.map +0 -1
- package/features/security/apiKeys/GetApiKey/index.js.map +0 -1
- package/features/security/apiKeys/GetApiKeyBySlug/index.js.map +0 -1
- package/features/security/apiKeys/GetApiKeyByToken/index.js.map +0 -1
- package/features/security/apiKeys/ListApiKeys/index.js.map +0 -1
- package/features/security/apiKeys/UpdateApiKey/index.js.map +0 -1
- package/features/security/apiKeys/shared/types.js.map +0 -1
- package/features/security/authentication/AuthenticationContext/index.js.map +0 -1
- package/features/security/authentication/Authenticator/index.js.map +0 -1
- package/features/security/authorization/AuthorizationContext/index.js.map +0 -1
- package/features/security/authorization/Authorizer/index.js.map +0 -1
- package/features/security/login/index.js.map +0 -1
- package/features/security/permissions/index.js.map +0 -1
- package/features/security/permissions/types.js.map +0 -1
- package/features/security/roles/CreateRole/index.js.map +0 -1
- package/features/security/roles/DeleteRole/index.js.map +0 -1
- package/features/security/roles/GetRole/index.js.map +0 -1
- package/features/security/roles/ListRoles/index.js.map +0 -1
- package/features/security/roles/UpdateRole/index.js.map +0 -1
- package/features/security/roles/shared/types.js.map +0 -1
- package/features/security/shared/index.js.map +0 -1
- package/features/security/teams/CreateTeam/index.js.map +0 -1
- package/features/security/teams/DeleteTeam/index.js.map +0 -1
- package/features/security/teams/GetTeam/index.js.map +0 -1
- package/features/security/teams/ListTeams/index.js.map +0 -1
- package/features/security/teams/UpdateTeam/index.js.map +0 -1
- package/features/security/teams/shared/types.js.map +0 -1
- package/features/system/InstallSystem/index.js.map +0 -1
- package/features/task/TaskController/index.js.map +0 -1
- package/features/task/TaskDefinition/index.js.map +0 -1
- package/features/task/TaskService/index.js.map +0 -1
- package/features/tenancy/CreateTenant/index.js.map +0 -1
- package/features/tenancy/DeleteTenant/index.js.map +0 -1
- package/features/tenancy/GetRootTenant/index.js.map +0 -1
- package/features/tenancy/GetTenantById/index.js.map +0 -1
- package/features/tenancy/InstallTenant/index.js.map +0 -1
- package/features/tenancy/ListTenants/index.js.map +0 -1
- package/features/tenancy/TenantContext/index.js.map +0 -1
- package/features/tenancy/UpdateTenant/index.js.map +0 -1
- package/features/users/CreateUser/index.js.map +0 -1
- package/features/users/DeleteUser/index.js.map +0 -1
- package/features/users/ExternalIdpUserSync/index.js.map +0 -1
- package/features/users/GetIdentityProfile/index.js.map +0 -1
- package/features/users/GetIdentityProfile/types.js.map +0 -1
- package/features/users/GetUser/index.js.map +0 -1
- package/features/users/ListUserTeams/index.js.map +0 -1
- package/features/users/ListUsers/index.js.map +0 -1
- package/features/users/UpdateUser/index.js.map +0 -1
- package/features/users/shared/types.js.map +0 -1
- package/features/wcp/WcpContext/index.js.map +0 -1
- package/features/wcp/WcpContext/types.js.map +0 -1
- package/idp/index.js.map +0 -1
- package/idp/types.js.map +0 -1
- package/index.js.map +0 -1
- package/models/base/ModelFactory.js.map +0 -1
- package/models/base/abstractions.js.map +0 -1
- package/models/cms/types.js.map +0 -1
- package/types/core.js.map +0 -1
- package/types/security.js.map +0 -1
- package/types/tenancy.js.map +0 -1
- package/types/users.js.map +0 -1
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
import { createImplementation } from "@webiny/feature/api";
|
|
2
2
|
import { TenantContext } from "../../../tenancy/TenantContext/index.js";
|
|
3
|
-
import { ApiKeyFactory } from "./abstractions.js";
|
|
4
|
-
import { ApiKeyProvider as ProviderAbstraction } from "./abstractions.js";
|
|
3
|
+
import { ApiKeyFactory, ApiKeyProvider } from "./abstractions.js";
|
|
5
4
|
import { SystemIdentityValue } from "../../../../domain/identity/SystemIdentityValue.js";
|
|
6
5
|
class ApiKeyProviderImpl {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
createdOn: new Date().toISOString(),
|
|
36
|
-
createdBy: SystemIdentityValue.create()
|
|
37
|
-
};
|
|
38
|
-
});
|
|
6
|
+
constructor(tenantContext, apiKeyFactories){
|
|
7
|
+
this.tenantContext = tenantContext;
|
|
8
|
+
this.apiKeyFactories = apiKeyFactories;
|
|
9
|
+
}
|
|
10
|
+
async getByToken(token) {
|
|
11
|
+
const cache = await this.getCache();
|
|
12
|
+
const apiKey = cache.find((key)=>key.token === token);
|
|
13
|
+
return apiKey || null;
|
|
14
|
+
}
|
|
15
|
+
async getBySlug(slug) {
|
|
16
|
+
const cache = await this.getCache();
|
|
17
|
+
const apiKey = cache.find((key)=>key.slug === slug);
|
|
18
|
+
return apiKey || null;
|
|
19
|
+
}
|
|
20
|
+
async getCache() {
|
|
21
|
+
if (void 0 === this.cache) {
|
|
22
|
+
const results = await Promise.all(this.apiKeyFactories.map((factory)=>factory.execute()));
|
|
23
|
+
this.cache = results.flat().map((codeKey)=>({
|
|
24
|
+
...codeKey,
|
|
25
|
+
id: codeKey.slug,
|
|
26
|
+
slug: codeKey.slug,
|
|
27
|
+
description: "",
|
|
28
|
+
tenant: this.tenantContext.getTenant().id,
|
|
29
|
+
createdOn: new Date().toISOString(),
|
|
30
|
+
createdBy: SystemIdentityValue.create()
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
return this.cache;
|
|
39
34
|
}
|
|
40
|
-
return this.cache;
|
|
41
|
-
}
|
|
42
35
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
const ApiKeyProvider_ApiKeyProvider = createImplementation({
|
|
37
|
+
abstraction: ApiKeyProvider,
|
|
38
|
+
implementation: ApiKeyProviderImpl,
|
|
39
|
+
dependencies: [
|
|
40
|
+
TenantContext,
|
|
41
|
+
[
|
|
42
|
+
ApiKeyFactory,
|
|
43
|
+
{
|
|
44
|
+
multiple: true
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
]
|
|
49
48
|
});
|
|
49
|
+
export { ApiKeyProvider_ApiKeyProvider as ApiKeyProvider };
|
|
50
50
|
|
|
51
51
|
//# sourceMappingURL=ApiKeyProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/shared/ApiKeyProvider.js","sources":["../../../../../src/features/security/apiKeys/shared/ApiKeyProvider.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\nimport { ApiKeyFactory } from \"./abstractions.js\";\nimport { ApiKeyProvider as ProviderAbstraction } from \"./abstractions.js\";\nimport type { ApiKey } from \"./types.js\";\nimport { SystemIdentityValue } from \"~/domain/identity/SystemIdentityValue.js\";\n\nclass ApiKeyProviderImpl implements ProviderAbstraction.Interface {\n private cache: ApiKey[] | undefined;\n\n constructor(\n private tenantContext: TenantContext.Interface,\n private apiKeyFactories: ApiKeyFactory.Interface[]\n ) {}\n\n async getByToken(token: string): Promise<ApiKey | null> {\n const cache = await this.getCache();\n\n // Search for the API key by token in the cached array\n const apiKey = cache.find(key => key.token === token);\n return apiKey || null;\n }\n\n async getBySlug(slug: string): Promise<ApiKey | null> {\n const cache = await this.getCache();\n\n // Search for the API key by token in the cached array\n const apiKey = cache.find(key => key.slug === slug);\n return apiKey || null;\n }\n\n private async getCache(): Promise<ApiKey[]> {\n if (this.cache === undefined) {\n const results = await Promise.all(\n this.apiKeyFactories.map(factory => factory.execute())\n );\n this.cache = results.flat().map<ApiKey>(codeKey => {\n return {\n ...codeKey,\n id: codeKey.slug,\n slug: codeKey.slug,\n description: \"\",\n tenant: this.tenantContext.getTenant().id,\n createdOn: new Date().toISOString(),\n createdBy: SystemIdentityValue.create()\n };\n });\n }\n\n return this.cache;\n }\n}\n\nexport const ApiKeyProvider = createImplementation({\n abstraction: ProviderAbstraction,\n implementation: ApiKeyProviderImpl,\n dependencies: [TenantContext, [ApiKeyFactory, { multiple: true }]]\n});\n"],"names":["ApiKeyProviderImpl","tenantContext","apiKeyFactories","token","cache","apiKey","key","slug","undefined","results","Promise","factory","codeKey","Date","SystemIdentityValue","ApiKeyProvider","createImplementation","ProviderAbstraction","TenantContext","ApiKeyFactory"],"mappings":";;;;AAOA,MAAMA;IAGF,YACYC,aAAsC,EACtCC,eAA0C,CACpD;aAFUD,aAAa,GAAbA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,WAAWC,KAAa,EAA0B;QACpD,MAAMC,QAAQ,MAAM,IAAI,CAAC,QAAQ;QAGjC,MAAMC,SAASD,MAAM,IAAI,CAACE,CAAAA,MAAOA,IAAI,KAAK,KAAKH;QAC/C,OAAOE,UAAU;IACrB;IAEA,MAAM,UAAUE,IAAY,EAA0B;QAClD,MAAMH,QAAQ,MAAM,IAAI,CAAC,QAAQ;QAGjC,MAAMC,SAASD,MAAM,IAAI,CAACE,CAAAA,MAAOA,IAAI,IAAI,KAAKC;QAC9C,OAAOF,UAAU;IACrB;IAEA,MAAc,WAA8B;QACxC,IAAI,AAAeG,WAAf,IAAI,CAAC,KAAK,EAAgB;YAC1B,MAAMC,UAAU,MAAMC,QAAQ,GAAG,CAC7B,IAAI,CAAC,eAAe,CAAC,GAAG,CAACC,CAAAA,UAAWA,QAAQ,OAAO;YAEvD,IAAI,CAAC,KAAK,GAAGF,QAAQ,IAAI,GAAG,GAAG,CAASG,CAAAA,UAC7B;oBACH,GAAGA,OAAO;oBACV,IAAIA,QAAQ,IAAI;oBAChB,MAAMA,QAAQ,IAAI;oBAClB,aAAa;oBACb,QAAQ,IAAI,CAAC,aAAa,CAAC,SAAS,GAAG,EAAE;oBACzC,WAAW,IAAIC,OAAO,WAAW;oBACjC,WAAWC,oBAAoB,MAAM;gBACzC;QAER;QAEA,OAAO,IAAI,CAAC,KAAK;IACrB;AACJ;AAEO,MAAMC,gCAAiBC,qBAAqB;IAC/C,aAAaC;IACb,gBAAgBjB;IAChB,cAAc;QAACkB;QAAe;YAACC;YAAe;gBAAE,UAAU;YAAK;SAAE;KAAC;AACtE"}
|
|
@@ -1,153 +1,126 @@
|
|
|
1
|
-
import { createImplementation } from "@webiny/feature/api";
|
|
2
|
-
import {
|
|
3
|
-
import { ApiKeysRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
4
|
-
import { ApiKeyProvider } from "./abstractions.js";
|
|
1
|
+
import { Result, createImplementation } from "@webiny/feature/api";
|
|
2
|
+
import { ApiKeyProvider, ApiKeysRepository } from "./abstractions.js";
|
|
5
3
|
import { SecurityStorageOperations } from "../../shared/abstractions.js";
|
|
6
4
|
import { TenantContext } from "../../../tenancy/TenantContext/index.js";
|
|
7
5
|
import { ApiKeyNotFoundError, ApiKeyPersistenceError, ApiKeyValidationError } from "./errors.js";
|
|
8
|
-
|
|
9
|
-
// TODO: create an ApiKeyMapper
|
|
10
|
-
|
|
11
6
|
class ApiKeysRepositoryImpl {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
async get(id) {
|
|
18
|
-
try {
|
|
19
|
-
const tenant = this.tenantContext.getTenant();
|
|
20
|
-
const apiKey = await this.storageOperations.getApiKey({
|
|
21
|
-
id,
|
|
22
|
-
tenant: tenant.id
|
|
23
|
-
});
|
|
24
|
-
if (apiKey) {
|
|
25
|
-
return Result.ok(apiKey);
|
|
26
|
-
}
|
|
27
|
-
return Result.fail(new ApiKeyNotFoundError());
|
|
28
|
-
} catch (error) {
|
|
29
|
-
return Result.fail(error);
|
|
7
|
+
constructor(tenantContext, storageOperations, apiKeyProvider){
|
|
8
|
+
this.tenantContext = tenantContext;
|
|
9
|
+
this.storageOperations = storageOperations;
|
|
10
|
+
this.apiKeyProvider = apiKeyProvider;
|
|
30
11
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// If not found in database, check if the API key is provided by a factory
|
|
45
|
-
const factoryApiKey = await this.apiKeyProvider.getByToken(token);
|
|
46
|
-
if (factoryApiKey) {
|
|
47
|
-
return Result.ok(factoryApiKey);
|
|
48
|
-
}
|
|
49
|
-
return Result.fail(new ApiKeyNotFoundError());
|
|
50
|
-
} catch (error) {
|
|
51
|
-
return Result.fail(new ApiKeyPersistenceError(error));
|
|
12
|
+
async get(id) {
|
|
13
|
+
try {
|
|
14
|
+
const tenant = this.tenantContext.getTenant();
|
|
15
|
+
const apiKey = await this.storageOperations.getApiKey({
|
|
16
|
+
id,
|
|
17
|
+
tenant: tenant.id
|
|
18
|
+
});
|
|
19
|
+
if (apiKey) return Result.ok(apiKey);
|
|
20
|
+
return Result.fail(new ApiKeyNotFoundError());
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return Result.fail(error);
|
|
23
|
+
}
|
|
52
24
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const factoryApiKey = await this.apiKeyProvider.getBySlug(slug);
|
|
68
|
-
if (factoryApiKey) {
|
|
69
|
-
return Result.ok(factoryApiKey);
|
|
70
|
-
}
|
|
71
|
-
return Result.fail(new ApiKeyNotFoundError());
|
|
72
|
-
} catch (error) {
|
|
73
|
-
return Result.fail(new ApiKeyPersistenceError(error));
|
|
25
|
+
async getByToken(token) {
|
|
26
|
+
try {
|
|
27
|
+
const tenant = this.tenantContext.getTenant();
|
|
28
|
+
const apiKey = await this.storageOperations.getApiKeyByToken({
|
|
29
|
+
token,
|
|
30
|
+
tenant: tenant.id
|
|
31
|
+
});
|
|
32
|
+
if (apiKey) return Result.ok(apiKey);
|
|
33
|
+
const factoryApiKey = await this.apiKeyProvider.getByToken(token);
|
|
34
|
+
if (factoryApiKey) return Result.ok(factoryApiKey);
|
|
35
|
+
return Result.fail(new ApiKeyNotFoundError());
|
|
36
|
+
} catch (error) {
|
|
37
|
+
return Result.fail(new ApiKeyPersistenceError(error));
|
|
38
|
+
}
|
|
74
39
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
40
|
+
async getBySlug(slug) {
|
|
41
|
+
try {
|
|
42
|
+
const tenant = this.tenantContext.getTenant();
|
|
43
|
+
const apiKey = await this.storageOperations.getApiKeyBySlug({
|
|
44
|
+
slug,
|
|
45
|
+
tenant: tenant.id
|
|
46
|
+
});
|
|
47
|
+
if (apiKey) return Result.ok(apiKey);
|
|
48
|
+
const factoryApiKey = await this.apiKeyProvider.getBySlug(slug);
|
|
49
|
+
if (factoryApiKey) return Result.ok(factoryApiKey);
|
|
50
|
+
return Result.fail(new ApiKeyNotFoundError());
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return Result.fail(new ApiKeyPersistenceError(error));
|
|
53
|
+
}
|
|
88
54
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
55
|
+
async list(params) {
|
|
56
|
+
try {
|
|
57
|
+
const tenant = this.tenantContext.getTenant();
|
|
58
|
+
const result = await this.storageOperations.listApiKeys({
|
|
59
|
+
where: {
|
|
60
|
+
tenant: tenant.id
|
|
61
|
+
},
|
|
62
|
+
...params
|
|
63
|
+
});
|
|
64
|
+
return Result.ok(result);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return Result.fail(new ApiKeyPersistenceError(error));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async create(apiKey) {
|
|
70
|
+
try {
|
|
71
|
+
const existingKeyResult = await this.getBySlug(apiKey.slug);
|
|
72
|
+
if (existingKeyResult.isOk()) return Result.fail(new ApiKeyValidationError(`API key with slug "${apiKey.slug}" already exists.`));
|
|
73
|
+
if ("ApiKey/NotFound" !== existingKeyResult.error.code) return Result.fail(existingKeyResult.error);
|
|
74
|
+
const tenant = this.tenantContext.getTenant();
|
|
75
|
+
await this.storageOperations.createApiKey({
|
|
76
|
+
apiKey: {
|
|
77
|
+
...apiKey,
|
|
78
|
+
tenant: tenant.id
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return Result.ok();
|
|
82
|
+
} catch (error) {
|
|
83
|
+
return Result.fail(new ApiKeyPersistenceError(error));
|
|
111
84
|
}
|
|
112
|
-
});
|
|
113
|
-
return Result.ok();
|
|
114
|
-
} catch (error) {
|
|
115
|
-
return Result.fail(new ApiKeyPersistenceError(error));
|
|
116
85
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
86
|
+
async update(apiKey) {
|
|
87
|
+
try {
|
|
88
|
+
const tenant = this.tenantContext.getTenant();
|
|
89
|
+
await this.storageOperations.updateApiKey({
|
|
90
|
+
apiKey: {
|
|
91
|
+
...apiKey,
|
|
92
|
+
tenant: tenant.id
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return Result.ok();
|
|
96
|
+
} catch (error) {
|
|
97
|
+
return Result.fail(new ApiKeyPersistenceError(error));
|
|
125
98
|
}
|
|
126
|
-
});
|
|
127
|
-
return Result.ok();
|
|
128
|
-
} catch (error) {
|
|
129
|
-
return Result.fail(new ApiKeyPersistenceError(error));
|
|
130
99
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
100
|
+
async delete(apiKey) {
|
|
101
|
+
try {
|
|
102
|
+
const tenant = this.tenantContext.getTenant();
|
|
103
|
+
await this.storageOperations.deleteApiKey({
|
|
104
|
+
apiKey: {
|
|
105
|
+
...apiKey,
|
|
106
|
+
tenant: tenant.id
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return Result.ok();
|
|
110
|
+
} catch (error) {
|
|
111
|
+
return Result.fail(new ApiKeyPersistenceError(error));
|
|
139
112
|
}
|
|
140
|
-
});
|
|
141
|
-
return Result.ok();
|
|
142
|
-
} catch (error) {
|
|
143
|
-
return Result.fail(new ApiKeyPersistenceError(error));
|
|
144
113
|
}
|
|
145
|
-
}
|
|
146
114
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
115
|
+
const ApiKeysRepository_ApiKeysRepository = createImplementation({
|
|
116
|
+
abstraction: ApiKeysRepository,
|
|
117
|
+
implementation: ApiKeysRepositoryImpl,
|
|
118
|
+
dependencies: [
|
|
119
|
+
TenantContext,
|
|
120
|
+
SecurityStorageOperations,
|
|
121
|
+
ApiKeyProvider
|
|
122
|
+
]
|
|
151
123
|
});
|
|
124
|
+
export { ApiKeysRepository_ApiKeysRepository as ApiKeysRepository };
|
|
152
125
|
|
|
153
126
|
//# sourceMappingURL=ApiKeysRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createImplementation","Result","ApiKeysRepository","RepositoryAbstraction","ApiKeyProvider","SecurityStorageOperations","TenantContext","ApiKeyNotFoundError","ApiKeyPersistenceError","ApiKeyValidationError","ApiKeysRepositoryImpl","constructor","tenantContext","storageOperations","apiKeyProvider","get","id","tenant","getTenant","apiKey","getApiKey","ok","fail","error","getByToken","token","getApiKeyByToken","factoryApiKey","getBySlug","slug","getApiKeyBySlug","list","params","result","listApiKeys","where","create","existingKeyResult","isOk","code","createApiKey","update","updateApiKey","delete","deleteApiKey","abstraction","implementation","dependencies"],"sources":["ApiKeysRepository.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ApiKeysRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { ApiKeyProvider } from \"./abstractions.js\";\nimport type { ApiKey, ListApiKeysInput } from \"./types.js\";\nimport { SecurityStorageOperations } from \"~/features/security/shared/abstractions.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\nimport { ApiKeyNotFoundError, ApiKeyPersistenceError, ApiKeyValidationError } from \"./errors.js\";\n\n// TODO: create an ApiKeyMapper\n\nclass ApiKeysRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private tenantContext: TenantContext.Interface,\n private storageOperations: SecurityStorageOperations.Interface,\n private apiKeyProvider: ApiKeyProvider.Interface\n ) {}\n\n async get(id: string): Promise<Result<ApiKey, RepositoryAbstraction.Error>> {\n try {\n const tenant = this.tenantContext.getTenant();\n const apiKey = await this.storageOperations.getApiKey({ id, tenant: tenant.id });\n if (apiKey) {\n return Result.ok(apiKey);\n }\n\n return Result.fail(new ApiKeyNotFoundError());\n } catch (error) {\n return Result.fail(error);\n }\n }\n\n async getByToken(token: string): Promise<Result<ApiKey, RepositoryAbstraction.Error>> {\n try {\n // First, check the database (database keys have priority over factory keys)\n const tenant = this.tenantContext.getTenant();\n const apiKey = await this.storageOperations.getApiKeyByToken({\n token,\n tenant: tenant.id\n });\n\n if (apiKey) {\n return Result.ok(apiKey);\n }\n\n // If not found in database, check if the API key is provided by a factory\n const factoryApiKey = await this.apiKeyProvider.getByToken(token);\n if (factoryApiKey) {\n return Result.ok(factoryApiKey);\n }\n\n return Result.fail(new ApiKeyNotFoundError());\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n\n async getBySlug(slug: string): Promise<Result<ApiKey, RepositoryAbstraction.Error>> {\n try {\n // First, check the database (database keys have priority over factory keys)\n const tenant = this.tenantContext.getTenant();\n const apiKey = await this.storageOperations.getApiKeyBySlug({\n slug,\n tenant: tenant.id\n });\n\n if (apiKey) {\n return Result.ok(apiKey);\n }\n\n // If not found in database, check if the API key is provided by a factory\n const factoryApiKey = await this.apiKeyProvider.getBySlug(slug);\n if (factoryApiKey) {\n return Result.ok(factoryApiKey);\n }\n\n return Result.fail(new ApiKeyNotFoundError());\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n\n async list(params: ListApiKeysInput): Promise<Result<ApiKey[], RepositoryAbstraction.Error>> {\n try {\n const tenant = this.tenantContext.getTenant();\n const result = await this.storageOperations.listApiKeys({\n where: { tenant: tenant.id },\n ...params\n });\n return Result.ok(result);\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n\n async create(apiKey: ApiKey): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n // Check if an API key with the same slug already exists\n const existingKeyResult = await this.getBySlug(apiKey.slug);\n\n // If we found a key, it's a duplicate slug - return validation error\n if (existingKeyResult.isOk()) {\n return Result.fail(\n new ApiKeyValidationError(`API key with slug \"${apiKey.slug}\" already exists.`)\n );\n }\n\n // \"NotFound\" error is ok. Everything else is not ok.\n if (existingKeyResult.error.code !== \"ApiKey/NotFound\") {\n return Result.fail(existingKeyResult.error);\n }\n\n // Slug is unique, proceed with creation\n const tenant = this.tenantContext.getTenant();\n await this.storageOperations.createApiKey({ apiKey: { ...apiKey, tenant: tenant.id } });\n return Result.ok();\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n\n async update(apiKey: ApiKey): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n const tenant = this.tenantContext.getTenant();\n await this.storageOperations.updateApiKey({ apiKey: { ...apiKey, tenant: tenant.id } });\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n\n async delete(apiKey: ApiKey): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n const tenant = this.tenantContext.getTenant();\n await this.storageOperations.deleteApiKey({ apiKey: { ...apiKey, tenant: tenant.id } });\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n}\n\nexport const ApiKeysRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: ApiKeysRepositoryImpl,\n dependencies: [TenantContext, SecurityStorageOperations, ApiKeyProvider]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,qBAAqB;AAC1D,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,iBAAiB,IAAIC,qBAAqB;AACnD,SAASC,cAAc;AAEvB,SAASC,yBAAyB;AAClC,SAASC,aAAa;AACtB,SAASC,mBAAmB,EAAEC,sBAAsB,EAAEC,qBAAqB;;AAE3E;;AAEA,MAAMC,qBAAqB,CAA4C;EACnEC,WAAWA,CACCC,aAAsC,EACtCC,iBAAsD,EACtDC,cAAwC,EAClD;IAAA,KAHUF,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,iBAAsD,GAAtDA,iBAAsD;IAAA,KACtDC,cAAwC,GAAxCA,cAAwC;EACjD;EAEH,MAAMC,GAAGA,CAACC,EAAU,EAAwD;IACxE,IAAI;MACA,MAAMC,MAAM,GAAG,IAAI,CAACL,aAAa,CAACM,SAAS,CAAC,CAAC;MAC7C,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACN,iBAAiB,CAACO,SAAS,CAAC;QAAEJ,EAAE;QAAEC,MAAM,EAAEA,MAAM,CAACD;MAAG,CAA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AAEA,MAAM,CAACD;QAAG;MAAE,CAAC,CAAC;MAEvF,OAAOf,MAAM,CAACoB,EAAE,CAAC,CAAC;IACtB,CAAC,CAAC,OAAOE,KAAK,EAAE;MACZ,OAAOtB,MAAM,CAACqB,IAAI,CAAC,IAAId,sBAAsB,CAACe,KAAK,CAAC,CAAC;IACzD;EACJ;AACJ;AAEA,OAAO,MAAMrB,iBAAiB,GAAGF,oBAAoB,CAAC;EAClD6C,WAAW,EAAE1C,qBAAqB;EAClC2C,cAAc,EAAEpC,qBAAqB;EACrCqC,YAAY,EAAE,CAACzC,aAAa,EAAED,yBAAyB,EAAED,cAAc;AAC3E,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/shared/ApiKeysRepository.js","sources":["../../../../../src/features/security/apiKeys/shared/ApiKeysRepository.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ApiKeysRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { ApiKeyProvider } from \"./abstractions.js\";\nimport type { ApiKey, ListApiKeysInput } from \"./types.js\";\nimport { SecurityStorageOperations } from \"~/features/security/shared/abstractions.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\nimport { ApiKeyNotFoundError, ApiKeyPersistenceError, ApiKeyValidationError } from \"./errors.js\";\n\n// TODO: create an ApiKeyMapper\n\nclass ApiKeysRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private tenantContext: TenantContext.Interface,\n private storageOperations: SecurityStorageOperations.Interface,\n private apiKeyProvider: ApiKeyProvider.Interface\n ) {}\n\n async get(id: string): Promise<Result<ApiKey, RepositoryAbstraction.Error>> {\n try {\n const tenant = this.tenantContext.getTenant();\n const apiKey = await this.storageOperations.getApiKey({ id, tenant: tenant.id });\n if (apiKey) {\n return Result.ok(apiKey);\n }\n\n return Result.fail(new ApiKeyNotFoundError());\n } catch (error) {\n return Result.fail(error);\n }\n }\n\n async getByToken(token: string): Promise<Result<ApiKey, RepositoryAbstraction.Error>> {\n try {\n // First, check the database (database keys have priority over factory keys)\n const tenant = this.tenantContext.getTenant();\n const apiKey = await this.storageOperations.getApiKeyByToken({\n token,\n tenant: tenant.id\n });\n\n if (apiKey) {\n return Result.ok(apiKey);\n }\n\n // If not found in database, check if the API key is provided by a factory\n const factoryApiKey = await this.apiKeyProvider.getByToken(token);\n if (factoryApiKey) {\n return Result.ok(factoryApiKey);\n }\n\n return Result.fail(new ApiKeyNotFoundError());\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n\n async getBySlug(slug: string): Promise<Result<ApiKey, RepositoryAbstraction.Error>> {\n try {\n // First, check the database (database keys have priority over factory keys)\n const tenant = this.tenantContext.getTenant();\n const apiKey = await this.storageOperations.getApiKeyBySlug({\n slug,\n tenant: tenant.id\n });\n\n if (apiKey) {\n return Result.ok(apiKey);\n }\n\n // If not found in database, check if the API key is provided by a factory\n const factoryApiKey = await this.apiKeyProvider.getBySlug(slug);\n if (factoryApiKey) {\n return Result.ok(factoryApiKey);\n }\n\n return Result.fail(new ApiKeyNotFoundError());\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n\n async list(params: ListApiKeysInput): Promise<Result<ApiKey[], RepositoryAbstraction.Error>> {\n try {\n const tenant = this.tenantContext.getTenant();\n const result = await this.storageOperations.listApiKeys({\n where: { tenant: tenant.id },\n ...params\n });\n return Result.ok(result);\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n\n async create(apiKey: ApiKey): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n // Check if an API key with the same slug already exists\n const existingKeyResult = await this.getBySlug(apiKey.slug);\n\n // If we found a key, it's a duplicate slug - return validation error\n if (existingKeyResult.isOk()) {\n return Result.fail(\n new ApiKeyValidationError(`API key with slug \"${apiKey.slug}\" already exists.`)\n );\n }\n\n // \"NotFound\" error is ok. Everything else is not ok.\n if (existingKeyResult.error.code !== \"ApiKey/NotFound\") {\n return Result.fail(existingKeyResult.error);\n }\n\n // Slug is unique, proceed with creation\n const tenant = this.tenantContext.getTenant();\n await this.storageOperations.createApiKey({ apiKey: { ...apiKey, tenant: tenant.id } });\n return Result.ok();\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n\n async update(apiKey: ApiKey): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n const tenant = this.tenantContext.getTenant();\n await this.storageOperations.updateApiKey({ apiKey: { ...apiKey, tenant: tenant.id } });\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n\n async delete(apiKey: ApiKey): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n const tenant = this.tenantContext.getTenant();\n await this.storageOperations.deleteApiKey({ apiKey: { ...apiKey, tenant: tenant.id } });\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new ApiKeyPersistenceError(error));\n }\n }\n}\n\nexport const ApiKeysRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: ApiKeysRepositoryImpl,\n dependencies: [TenantContext, SecurityStorageOperations, ApiKeyProvider]\n});\n"],"names":["ApiKeysRepositoryImpl","tenantContext","storageOperations","apiKeyProvider","id","tenant","apiKey","Result","ApiKeyNotFoundError","error","token","factoryApiKey","ApiKeyPersistenceError","slug","params","result","existingKeyResult","ApiKeyValidationError","ApiKeysRepository","createImplementation","RepositoryAbstraction","TenantContext","SecurityStorageOperations","ApiKeyProvider"],"mappings":";;;;;AAWA,MAAMA;IACF,YACYC,aAAsC,EACtCC,iBAAsD,EACtDC,cAAwC,CAClD;aAHUF,aAAa,GAAbA;aACAC,iBAAiB,GAAjBA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,IAAIC,EAAU,EAAwD;QACxE,IAAI;YACA,MAAMC,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS;YAC3C,MAAMC,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,SAA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ClD;IACJ;IAEA,MAAM,OAAOH,MAAc,EAAsD;QAC7E,IAAI;YACA,MAAMD,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS;YAC3C,MAAM,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC;gBAAE,QAAQ;oBAAE,GAAGC,MAAM;oBAAE,QAAQD,OAAO,EAAE;gBAAC;YAAE;YAErF,OAAOE,OAAO,EAAE;QACpB,EAAE,OAAOE,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIK,uBAAuBH;QAClD;IACJ;AACJ;AAEO,MAAMS,sCAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgBpB;IAChB,cAAc;QAACqB;QAAeC;QAA2BC;KAAe;AAC5E"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
/** Retrieve API keys by token or slug. */
|
|
7
|
-
export const ApiKeyProvider = createAbstraction("ApiKeyProvider");
|
|
2
|
+
const ApiKeysRepository = createAbstraction("ApiKeysRepository");
|
|
3
|
+
const ApiKeyFactory = createAbstraction("ApiKeyFactory");
|
|
4
|
+
const ApiKeyProvider = createAbstraction("ApiKeyProvider");
|
|
5
|
+
export { ApiKeyFactory, ApiKeyProvider, ApiKeysRepository };
|
|
8
6
|
|
|
9
7
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/shared/abstractions.js","sources":["../../../../../src/features/security/apiKeys/shared/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ApiKey, ListApiKeysInput } from \"./types.js\";\nimport {\n type ApiKeyNotFoundError,\n ApiKeyPersistenceError,\n ApiKeyValidationError\n} from \"./errors.js\";\n\nexport interface IApiKeysRepositoryErrors {\n base: ApiKeyNotFoundError | ApiKeyPersistenceError | ApiKeyValidationError;\n}\n\ntype RepositoryError = IApiKeysRepositoryErrors[keyof IApiKeysRepositoryErrors];\n\nexport interface IApiKeysRepository {\n get(id: string): Promise<Result<ApiKey, RepositoryError>>;\n getByToken(token: string): Promise<Result<ApiKey, RepositoryError>>;\n getBySlug(token: string): Promise<Result<ApiKey, RepositoryError>>;\n list(params: ListApiKeysInput): Promise<Result<ApiKey[], RepositoryError>>;\n create(data: ApiKey): Promise<Result<void, RepositoryError>>;\n update(data: ApiKey): Promise<Result<void, RepositoryError>>;\n delete(apiKey: ApiKey): Promise<Result<void, RepositoryError>>;\n}\n\n/** Persist and retrieve API keys. */\nexport const ApiKeysRepository = createAbstraction<IApiKeysRepository>(\"ApiKeysRepository\");\n\nexport namespace ApiKeysRepository {\n export type Interface = IApiKeysRepository;\n export type Error = RepositoryError;\n}\n\nexport type CodeApiKey = Pick<ApiKey, \"name\" | \"permissions\" | \"slug\"> & {\n token: `wat_${string}`;\n};\n\nexport interface IApiKeyFactory {\n execute(): Promise<CodeApiKey[]>;\n}\n\n/** Provide code-defined API keys. */\nexport const ApiKeyFactory = createAbstraction<IApiKeyFactory>(\"ApiKeyFactory\");\n\nexport namespace ApiKeyFactory {\n export type Interface = IApiKeyFactory;\n export type Return = Promise<CodeApiKey[]>;\n export type ApiKey = CodeApiKey;\n}\n\nexport interface IApiKeyProvider {\n getByToken(token: string): Promise<ApiKey | null>;\n getBySlug(slug: string): Promise<ApiKey | null>;\n}\n\n/** Retrieve API keys by token or slug. */\nexport const ApiKeyProvider = createAbstraction<IApiKeyProvider>(\"ApiKeyProvider\");\n\nexport namespace ApiKeyProvider {\n export type Interface = IApiKeyProvider;\n}\n"],"names":["ApiKeysRepository","createAbstraction","ApiKeyFactory","ApiKeyProvider"],"mappings":";AA0BO,MAAMA,oBAAoBC,kBAAsC;AAgBhE,MAAMC,gBAAgBD,kBAAkC;AAcxD,MAAME,iBAAiBF,kBAAmC"}
|
|
@@ -1,39 +1,36 @@
|
|
|
1
1
|
import { BaseError } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
}
|
|
2
|
+
class ApiKeyPersistenceError extends BaseError {
|
|
3
|
+
constructor(error){
|
|
4
|
+
super({
|
|
5
|
+
message: error.message
|
|
6
|
+
}), this.code = "ApiKey/Persistence";
|
|
7
|
+
}
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
class ApiKeyNotFoundError extends BaseError {
|
|
10
|
+
constructor(){
|
|
11
|
+
super({
|
|
12
|
+
message: "API key was not found!"
|
|
13
|
+
}), this.code = "ApiKey/NotFound";
|
|
14
|
+
}
|
|
17
15
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
}
|
|
16
|
+
class ApiKeyNotAuthorizedError extends BaseError {
|
|
17
|
+
constructor(data = {}){
|
|
18
|
+
super({
|
|
19
|
+
message: data.message || "Not authorized!",
|
|
20
|
+
data
|
|
21
|
+
}), this.code = "ApiKey/NotAuthorized";
|
|
22
|
+
}
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}
|
|
24
|
+
class ApiKeyValidationError extends BaseError {
|
|
25
|
+
constructor(message){
|
|
26
|
+
super({
|
|
27
|
+
message,
|
|
28
|
+
data: {
|
|
29
|
+
message
|
|
30
|
+
}
|
|
31
|
+
}), this.code = "ApiKey/Validation";
|
|
32
|
+
}
|
|
37
33
|
}
|
|
34
|
+
export { ApiKeyNotAuthorizedError, ApiKeyNotFoundError, ApiKeyPersistenceError, ApiKeyValidationError };
|
|
38
35
|
|
|
39
36
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/shared/errors.js","sources":["../../../../../src/features/security/apiKeys/shared/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\nexport class ApiKeyPersistenceError extends BaseError {\n override readonly code = \"ApiKey/Persistence\" as const;\n\n constructor(error: Error) {\n super({\n message: error.message\n });\n }\n}\n\nexport class ApiKeyNotFoundError extends BaseError {\n override readonly code = \"ApiKey/NotFound\" as const;\n\n constructor() {\n super({\n message: `API key was not found!`\n });\n }\n}\n\ntype NotAuthorizedErrorData = {\n message?: string;\n};\n\nexport class ApiKeyNotAuthorizedError extends BaseError<NotAuthorizedErrorData> {\n override readonly code = \"ApiKey/NotAuthorized\" as const;\n\n constructor(data: NotAuthorizedErrorData = {}) {\n super({\n message: data.message || \"Not authorized!\",\n data\n });\n }\n}\n\ntype ApiKeyValidationErrorData = {\n message: string;\n};\n\nexport class ApiKeyValidationError extends BaseError<ApiKeyValidationErrorData> {\n override readonly code = \"ApiKey/Validation\" as const;\n\n constructor(message: string) {\n super({\n message,\n data: { message }\n });\n }\n}\n"],"names":["ApiKeyPersistenceError","BaseError","error","ApiKeyNotFoundError","ApiKeyNotAuthorizedError","data","ApiKeyValidationError","message"],"mappings":";AAEO,MAAMA,+BAA+BC;IAGxC,YAAYC,KAAY,CAAE;QACtB,KAAK,CAAC;YACF,SAASA,MAAM,OAAO;QAC1B,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAMC,4BAA4BF;IAGrC,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ;AAMO,MAAMG,iCAAiCH;IAG1C,YAAYI,OAA+B,CAAC,CAAC,CAAE;QAC3C,KAAK,CAAC;YACF,SAASA,KAAK,OAAO,IAAI;YACzBA;QACJ,SANc,IAAI,GAAG;IAOzB;AACJ;AAMO,MAAMC,8BAA8BL;IAGvC,YAAYM,OAAe,CAAE;QACzB,KAAK,CAAC;YACFA;YACA,MAAM;gBAAEA;YAAQ;QACpB,SANc,IAAI,GAAG;IAOzB;AACJ"}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* When authentication plugins kick in, they will be able to tell if they should handle
|
|
7
|
-
* the token by checking the first letter.
|
|
8
|
-
*/
|
|
9
|
-
export const generateToken = (tokenLength = 40) => {
|
|
10
|
-
const token = crypto.randomBytes(Math.ceil(tokenLength / 2)).toString("hex");
|
|
11
|
-
|
|
12
|
-
// API Keys are prefixed with letters "wat_" to make token verification easier
|
|
13
|
-
if (token.startsWith("wat_")) {
|
|
14
|
-
return token;
|
|
15
|
-
}
|
|
16
|
-
return `wat_${token.slice(0, tokenLength - 4)}`;
|
|
1
|
+
import crypto_0 from "crypto";
|
|
2
|
+
const generateToken = (tokenLength = 40)=>{
|
|
3
|
+
const token = crypto_0.randomBytes(Math.ceil(tokenLength / 2)).toString("hex");
|
|
4
|
+
if (token.startsWith("wat_")) return token;
|
|
5
|
+
return `wat_${token.slice(0, tokenLength - 4)}`;
|
|
17
6
|
};
|
|
7
|
+
export { generateToken };
|
|
18
8
|
|
|
19
9
|
//# sourceMappingURL=generateToken.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/shared/generateToken.js","sources":["../../../../../src/features/security/apiKeys/shared/generateToken.ts"],"sourcesContent":["import crypto from \"crypto\";\n\n/**\n * Generates a random token for API keys.\n * API Keys are prefixed with letter \"wat_\" to make token verification easier.\n * When authentication plugins kick in, they will be able to tell if they should handle\n * the token by checking the first letter.\n */\nexport const generateToken = (tokenLength = 40): string => {\n const token = crypto.randomBytes(Math.ceil(tokenLength / 2)).toString(\"hex\");\n\n // API Keys are prefixed with letters \"wat_\" to make token verification easier\n if (token.startsWith(\"wat_\")) {\n return token;\n }\n\n return `wat_${token.slice(0, tokenLength - 4)}`;\n};\n"],"names":["generateToken","tokenLength","token","crypto","Math"],"mappings":";AAQO,MAAMA,gBAAgB,CAACC,cAAc,EAAE;IAC1C,MAAMC,QAAQC,SAAAA,WAAkB,CAACC,KAAK,IAAI,CAACH,cAAc,IAAI,QAAQ,CAAC;IAGtE,IAAIC,MAAM,UAAU,CAAC,SACjB,OAAOA;IAGX,OAAO,CAAC,IAAI,EAAEA,MAAM,KAAK,CAAC,GAAGD,cAAc,IAAI;AACnD"}
|