@webiny/api-core 6.0.0 → 6.1.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/domain/security/ApiToken.d.ts +1 -0
- package/domain/security/ApiToken.js +1 -0
- package/domain/security/ApiToken.js.map +1 -1
- package/exports/api/security.d.ts +2 -0
- package/exports/api/security.js +2 -0
- package/exports/api/security.js.map +1 -1
- package/features/buildParams/abstractions.d.ts +2 -0
- package/features/buildParams/abstractions.js +2 -0
- package/features/buildParams/abstractions.js.map +1 -1
- package/features/eventPublisher/abstractions.d.ts +2 -0
- package/features/eventPublisher/abstractions.js +3 -0
- package/features/eventPublisher/abstractions.js.map +1 -1
- package/features/keyValueStore/abstractions.d.ts +4 -0
- package/features/keyValueStore/abstractions.js +4 -0
- package/features/keyValueStore/abstractions.js.map +1 -1
- package/features/logger/abstractions.d.ts +1 -0
- package/features/logger/abstractions.js +1 -0
- package/features/logger/abstractions.js.map +1 -1
- package/features/security/IdentityContext/abstractions.d.ts +1 -0
- package/features/security/IdentityContext/abstractions.js +1 -0
- package/features/security/IdentityContext/abstractions.js.map +1 -1
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +1 -1
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/CreateApiKey/abstractions.d.ts +1 -0
- package/features/security/apiKeys/CreateApiKey/abstractions.js +1 -0
- package/features/security/apiKeys/CreateApiKey/abstractions.js.map +1 -1
- package/features/security/apiKeys/CreateApiKey/events.d.ts +2 -0
- package/features/security/apiKeys/CreateApiKey/events.js +4 -0
- package/features/security/apiKeys/CreateApiKey/events.js.map +1 -1
- package/features/security/apiKeys/DeleteApiKey/abstractions.d.ts +1 -0
- package/features/security/apiKeys/DeleteApiKey/abstractions.js +1 -0
- package/features/security/apiKeys/DeleteApiKey/abstractions.js.map +1 -1
- package/features/security/apiKeys/DeleteApiKey/events.d.ts +2 -0
- package/features/security/apiKeys/DeleteApiKey/events.js +4 -0
- package/features/security/apiKeys/DeleteApiKey/events.js.map +1 -1
- package/features/security/apiKeys/GetApiKey/abstractions.d.ts +1 -0
- package/features/security/apiKeys/GetApiKey/abstractions.js +1 -0
- package/features/security/apiKeys/GetApiKey/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -0
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js +1 -0
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -0
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js +1 -0
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
- package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.js +1 -1
- package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.js.map +1 -1
- package/features/security/apiKeys/ListApiKeys/abstractions.d.ts +1 -0
- package/features/security/apiKeys/ListApiKeys/abstractions.js +1 -0
- package/features/security/apiKeys/ListApiKeys/abstractions.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +1 -1
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/abstractions.d.ts +1 -0
- package/features/security/apiKeys/UpdateApiKey/abstractions.js +1 -0
- package/features/security/apiKeys/UpdateApiKey/abstractions.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/events.d.ts +2 -0
- package/features/security/apiKeys/UpdateApiKey/events.js +4 -0
- package/features/security/apiKeys/UpdateApiKey/events.js.map +1 -1
- package/features/security/apiKeys/shared/abstractions.d.ts +5 -2
- package/features/security/apiKeys/shared/abstractions.js +3 -0
- package/features/security/apiKeys/shared/abstractions.js.map +1 -1
- package/features/security/apiKeys/shared/schemas.d.ts +10 -71
- package/features/security/apiKeys/shared/schemas.js +4 -4
- package/features/security/apiKeys/shared/schemas.js.map +1 -1
- package/features/security/authentication/AuthenticationContext/abstractions.d.ts +1 -0
- package/features/security/authentication/AuthenticationContext/abstractions.js +1 -0
- package/features/security/authentication/AuthenticationContext/abstractions.js.map +1 -1
- package/features/security/authentication/AuthenticationContext/events.d.ts +2 -0
- package/features/security/authentication/AuthenticationContext/events.js +4 -0
- package/features/security/authentication/AuthenticationContext/events.js.map +1 -1
- package/features/security/authentication/Authenticator/abstractions.d.ts +1 -0
- package/features/security/authentication/Authenticator/abstractions.js +1 -0
- package/features/security/authentication/Authenticator/abstractions.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
- package/features/security/authorization/AuthorizationContext/abstractions.js +2 -0
- package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
- package/features/security/authorization/Authorizer/abstractions.d.ts +1 -0
- package/features/security/authorization/Authorizer/abstractions.js +1 -0
- package/features/security/authorization/Authorizer/abstractions.js.map +1 -1
- package/features/security/login/abstractions.d.ts +1 -0
- package/features/security/login/abstractions.js +2 -0
- package/features/security/login/abstractions.js.map +1 -1
- package/features/security/roles/CreateRole/CreateRoleUseCase.d.ts +1 -3
- package/features/security/roles/CreateRole/CreateRoleUseCase.js +3 -7
- package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
- package/features/security/roles/CreateRole/abstractions.d.ts +1 -0
- package/features/security/roles/CreateRole/abstractions.js +1 -0
- package/features/security/roles/CreateRole/abstractions.js.map +1 -1
- package/features/security/roles/CreateRole/events.d.ts +2 -0
- package/features/security/roles/CreateRole/events.js +4 -0
- package/features/security/roles/CreateRole/events.js.map +1 -1
- package/features/security/roles/CreateRole/schema.d.ts +2 -20
- package/features/security/roles/CreateRole/schema.js +2 -2
- package/features/security/roles/CreateRole/schema.js.map +1 -1
- package/features/security/roles/DeleteRole/abstractions.d.ts +1 -0
- package/features/security/roles/DeleteRole/abstractions.js +1 -0
- package/features/security/roles/DeleteRole/abstractions.js.map +1 -1
- package/features/security/roles/DeleteRole/events.d.ts +2 -0
- package/features/security/roles/DeleteRole/events.js +4 -0
- package/features/security/roles/DeleteRole/events.js.map +1 -1
- package/features/security/roles/GetRole/abstractions.d.ts +1 -0
- package/features/security/roles/GetRole/abstractions.js +1 -0
- package/features/security/roles/GetRole/abstractions.js.map +1 -1
- package/features/security/roles/ListRoles/abstractions.d.ts +1 -0
- package/features/security/roles/ListRoles/abstractions.js +1 -0
- package/features/security/roles/ListRoles/abstractions.js.map +1 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +1 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
- package/features/security/roles/UpdateRole/abstractions.d.ts +1 -0
- package/features/security/roles/UpdateRole/abstractions.js +1 -0
- package/features/security/roles/UpdateRole/abstractions.js.map +1 -1
- package/features/security/roles/UpdateRole/events.d.ts +2 -0
- package/features/security/roles/UpdateRole/events.js +4 -0
- package/features/security/roles/UpdateRole/events.js.map +1 -1
- package/features/security/roles/UpdateRole/schema.d.ts +2 -18
- package/features/security/roles/UpdateRole/schema.js +2 -2
- package/features/security/roles/UpdateRole/schema.js.map +1 -1
- package/features/security/roles/feature.js +2 -0
- package/features/security/roles/feature.js.map +1 -1
- package/features/security/roles/shared/RoleProvider.d.ts +13 -0
- package/features/security/roles/shared/RoleProvider.js +29 -0
- package/features/security/roles/shared/RoleProvider.js.map +1 -0
- package/features/security/roles/shared/RolesRepository.d.ts +3 -1
- package/features/security/roles/shared/RolesRepository.js +19 -18
- package/features/security/roles/shared/RolesRepository.js.map +1 -1
- package/features/security/roles/shared/abstractions.d.ts +19 -0
- package/features/security/roles/shared/abstractions.js +3 -0
- package/features/security/roles/shared/abstractions.js.map +1 -1
- package/features/security/shared/abstractions.d.ts +5 -14
- package/features/security/shared/abstractions.js +3 -16
- package/features/security/shared/abstractions.js.map +1 -1
- package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +1 -3
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js +3 -7
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
- package/features/security/teams/CreateTeam/abstractions.d.ts +1 -0
- package/features/security/teams/CreateTeam/abstractions.js +1 -0
- package/features/security/teams/CreateTeam/abstractions.js.map +1 -1
- package/features/security/teams/CreateTeam/events.d.ts +2 -0
- package/features/security/teams/CreateTeam/events.js +4 -0
- package/features/security/teams/CreateTeam/events.js.map +1 -1
- package/features/security/teams/CreateTeam/schema.d.ts +2 -12
- package/features/security/teams/DeleteTeam/abstractions.d.ts +1 -0
- package/features/security/teams/DeleteTeam/abstractions.js +1 -0
- package/features/security/teams/DeleteTeam/abstractions.js.map +1 -1
- package/features/security/teams/DeleteTeam/events.d.ts +2 -0
- package/features/security/teams/DeleteTeam/events.js +4 -0
- package/features/security/teams/DeleteTeam/events.js.map +1 -1
- package/features/security/teams/GetTeam/abstractions.d.ts +1 -0
- package/features/security/teams/GetTeam/abstractions.js +1 -0
- package/features/security/teams/GetTeam/abstractions.js.map +1 -1
- package/features/security/teams/ListTeams/abstractions.d.ts +1 -0
- package/features/security/teams/ListTeams/abstractions.js +1 -0
- package/features/security/teams/ListTeams/abstractions.js.map +1 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +1 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
- package/features/security/teams/UpdateTeam/abstractions.d.ts +1 -0
- package/features/security/teams/UpdateTeam/abstractions.js +1 -0
- package/features/security/teams/UpdateTeam/abstractions.js.map +1 -1
- package/features/security/teams/UpdateTeam/events.d.ts +2 -0
- package/features/security/teams/UpdateTeam/events.js +4 -0
- package/features/security/teams/UpdateTeam/events.js.map +1 -1
- package/features/security/teams/UpdateTeam/schema.d.ts +2 -10
- package/features/security/teams/feature.js +6 -0
- package/features/security/teams/feature.js.map +1 -1
- package/features/security/teams/shared/TeamProvider.d.ts +13 -0
- package/features/security/teams/shared/TeamProvider.js +29 -0
- package/features/security/teams/shared/TeamProvider.js.map +1 -0
- package/features/security/teams/shared/TeamsRepository.js +20 -18
- package/features/security/teams/shared/TeamsRepository.js.map +1 -1
- package/features/security/teams/shared/abstractions.d.ts +18 -0
- package/features/security/teams/shared/abstractions.js +3 -0
- package/features/security/teams/shared/abstractions.js.map +1 -1
- package/features/security/teams/shared/decorators/TeamsRepositoryCachingDecorator.d.ts +17 -0
- package/features/security/teams/shared/decorators/TeamsRepositoryCachingDecorator.js +76 -0
- package/features/security/teams/shared/decorators/TeamsRepositoryCachingDecorator.js.map +1 -0
- package/features/security/utils/verifyJwtUsingJwk.d.ts +2 -4
- package/features/security/utils/verifyJwtUsingJwk.js +1 -1
- package/features/security/utils/verifyJwtUsingJwk.js.map +1 -1
- package/features/system/InstallSystem/abstractions.d.ts +2 -3
- package/features/system/InstallSystem/abstractions.js +2 -3
- package/features/system/InstallSystem/abstractions.js.map +1 -1
- package/features/task/TaskController/abstractions.d.ts +1 -0
- package/features/task/TaskController/abstractions.js +1 -0
- package/features/task/TaskController/abstractions.js.map +1 -1
- package/features/task/TaskDefinition/abstractions.d.ts +1 -0
- package/features/task/TaskDefinition/abstractions.js +1 -0
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/task/TaskService/abstractions.d.ts +1 -0
- package/features/task/TaskService/abstractions.js +1 -0
- package/features/task/TaskService/abstractions.js.map +1 -1
- package/features/tenancy/CreateTenant/abstractions.d.ts +5 -3
- package/features/tenancy/CreateTenant/abstractions.js +5 -3
- package/features/tenancy/CreateTenant/abstractions.js.map +1 -1
- package/features/tenancy/DeleteTenant/abstractions.d.ts +5 -0
- package/features/tenancy/DeleteTenant/abstractions.js +5 -0
- package/features/tenancy/DeleteTenant/abstractions.js.map +1 -1
- package/features/tenancy/GetTenantById/abstractions.d.ts +3 -0
- package/features/tenancy/GetTenantById/abstractions.js +3 -9
- package/features/tenancy/GetTenantById/abstractions.js.map +1 -1
- package/features/tenancy/InstallTenant/abstractions.d.ts +3 -9
- package/features/tenancy/InstallTenant/abstractions.js +3 -12
- package/features/tenancy/InstallTenant/abstractions.js.map +1 -1
- package/features/tenancy/TenantContext/abstractions.d.ts +1 -0
- package/features/tenancy/TenantContext/abstractions.js +1 -0
- package/features/tenancy/TenantContext/abstractions.js.map +1 -1
- package/features/tenancy/UpdateTenant/abstractions.d.ts +5 -0
- package/features/tenancy/UpdateTenant/abstractions.js +5 -0
- package/features/tenancy/UpdateTenant/abstractions.js.map +1 -1
- package/features/users/CreateUser/CreateUserUseCase.js +1 -1
- package/features/users/CreateUser/CreateUserUseCase.js.map +1 -1
- package/features/users/CreateUser/abstractions.d.ts +1 -0
- package/features/users/CreateUser/abstractions.js +1 -1
- package/features/users/CreateUser/abstractions.js.map +1 -1
- package/features/users/CreateUser/events.d.ts +2 -0
- package/features/users/CreateUser/events.js +4 -0
- package/features/users/CreateUser/events.js.map +1 -1
- package/features/users/CreateUser/schema.d.ts +4 -36
- package/features/users/DeleteUser/abstractions.d.ts +1 -0
- package/features/users/DeleteUser/abstractions.js +1 -1
- package/features/users/DeleteUser/abstractions.js.map +1 -1
- package/features/users/DeleteUser/events.d.ts +2 -0
- package/features/users/DeleteUser/events.js +4 -0
- package/features/users/DeleteUser/events.js.map +1 -1
- package/features/users/GetUser/abstractions.d.ts +1 -0
- package/features/users/GetUser/abstractions.js +1 -1
- package/features/users/GetUser/abstractions.js.map +1 -1
- package/features/users/ListUserTeams/abstractions.d.ts +1 -0
- package/features/users/ListUserTeams/abstractions.js +1 -1
- package/features/users/ListUserTeams/abstractions.js.map +1 -1
- package/features/users/ListUsers/abstractions.d.ts +1 -0
- package/features/users/ListUsers/abstractions.js +1 -1
- package/features/users/ListUsers/abstractions.js.map +1 -1
- package/features/users/UpdateUser/UpdateUserUseCase.js +1 -1
- package/features/users/UpdateUser/UpdateUserUseCase.js.map +1 -1
- package/features/users/UpdateUser/abstractions.d.ts +1 -0
- package/features/users/UpdateUser/abstractions.js +1 -1
- package/features/users/UpdateUser/abstractions.js.map +1 -1
- package/features/users/UpdateUser/events.d.ts +2 -0
- package/features/users/UpdateUser/events.js +4 -0
- package/features/users/UpdateUser/events.js.map +1 -1
- package/features/users/UpdateUser/schema.d.ts +4 -30
- package/features/users/shared/abstractions.d.ts +1 -0
- package/features/users/shared/abstractions.js +1 -1
- package/features/users/shared/abstractions.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +0 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/graphql/security/NotAuthorizedResponse.d.ts +1 -0
- package/graphql/security/NotAuthorizedResponse.js +1 -0
- package/graphql/security/NotAuthorizedResponse.js.map +1 -1
- package/idp/abstractions.d.ts +4 -0
- package/idp/abstractions.js +4 -0
- package/idp/abstractions.js.map +1 -1
- package/legacy/security/createSecurityContext.js +0 -11
- package/legacy/security/createSecurityContext.js.map +1 -1
- package/models/base/BaseModel.js +2 -2
- package/models/base/BaseModel.js.map +1 -1
- package/models/base/ModelBuilder.d.ts +2 -2
- package/models/base/ModelBuilder.js +21 -2
- package/models/base/ModelBuilder.js.map +1 -1
- package/models/cms/FieldBuilder.d.ts +3 -2
- package/models/cms/FieldBuilder.js +12 -17
- package/models/cms/FieldBuilder.js.map +1 -1
- package/models/cms/FieldBuilderRegistry.d.ts +1 -1
- package/models/cms/FieldBuilderRegistry.js.map +1 -1
- package/models/cms/FieldDefinitionsBuilder.d.ts +1 -0
- package/models/cms/FieldDefinitionsBuilder.js +13 -15
- package/models/cms/FieldDefinitionsBuilder.js.map +1 -1
- package/models/cms/PrivateCmsModelBuilder.js.map +1 -1
- package/models/cms/abstractions.d.ts +1 -1
- package/models/cms/abstractions.js.map +1 -1
- package/models/cms/fieldsBuilder.md +1 -1
- package/models/simple/Page/abstractions.d.ts +1 -11
- package/package.json +20 -20
- package/types/security.d.ts +13 -10
- package/types/security.js.map +1 -1
- package/features/security/shared/abstractions.ts.bak +0 -52
- package/legacy/security/plugins/SecurityRolePlugin.d.ts +0 -16
- package/legacy/security/plugins/SecurityRolePlugin.js +0 -33
- package/legacy/security/plugins/SecurityRolePlugin.js.map +0 -1
- package/legacy/security/plugins/SecurityTeamPlugin.d.ts +0 -16
- package/legacy/security/plugins/SecurityTeamPlugin.js +0 -33
- package/legacy/security/plugins/SecurityTeamPlugin.js.map +0 -1
|
@@ -19,7 +19,7 @@ class UpdateApiKeyUseCaseImpl {
|
|
|
19
19
|
}
|
|
20
20
|
const validation = updateApiKeyInputSchema.safeParse(input);
|
|
21
21
|
if (!validation.success) {
|
|
22
|
-
return Result.fail(new ApiKeyValidationError(validation.error.
|
|
22
|
+
return Result.fail(new ApiKeyValidationError(validation.error.issues[0].message));
|
|
23
23
|
}
|
|
24
24
|
const existingResult = await this.repository.get(id);
|
|
25
25
|
if (existingResult.isFail()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","UpdateApiKeyUseCase","UpdateApiKeyUseCaseAbstraction","ApiKeysRepository","IdentityContext","EventPublisher","updateApiKeyInputSchema","ApiKeyBeforeUpdateEvent","ApiKeyAfterUpdateEvent","ApiKeyNotAuthorizedError","ApiKeyValidationError","UpdateApiKeyUseCaseImpl","constructor","repository","identityContext","eventPublisher","execute","id","input","hasPermission","getPermission","fail","validation","safeParse","success","error","
|
|
1
|
+
{"version":3,"names":["Result","UpdateApiKeyUseCase","UpdateApiKeyUseCaseAbstraction","ApiKeysRepository","IdentityContext","EventPublisher","updateApiKeyInputSchema","ApiKeyBeforeUpdateEvent","ApiKeyAfterUpdateEvent","ApiKeyNotAuthorizedError","ApiKeyValidationError","UpdateApiKeyUseCaseImpl","constructor","repository","identityContext","eventPublisher","execute","id","input","hasPermission","getPermission","fail","validation","safeParse","success","error","issues","message","existingResult","get","isFail","existingApiKey","value","updatedApiKey","data","publish","original","updated","result","update","ok","createImplementation","implementation","dependencies"],"sources":["UpdateApiKeyUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateApiKeyUseCase as UpdateApiKeyUseCaseAbstraction } from \"./abstractions.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateApiKeyInputSchema } from \"../shared/schemas.js\";\nimport { ApiKeyBeforeUpdateEvent, ApiKeyAfterUpdateEvent } from \"./events.js\";\nimport type { ApiKey, UpdateApiKeyInput } from \"../shared/types.js\";\nimport { ApiKeyNotAuthorizedError, ApiKeyValidationError } from \"../shared/errors.js\";\n\nclass UpdateApiKeyUseCaseImpl implements UpdateApiKeyUseCaseAbstraction.Interface {\n private repository: ApiKeysRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n\n constructor(\n repository: ApiKeysRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n }\n\n async execute(\n id: string,\n input: UpdateApiKeyInput\n ): Promise<Result<ApiKey, UpdateApiKeyUseCaseAbstraction.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.apiKey\");\n if (!hasPermission) {\n return Result.fail(new ApiKeyNotAuthorizedError());\n }\n\n const validation = updateApiKeyInputSchema.safeParse(input);\n if (!validation.success) {\n return Result.fail(new ApiKeyValidationError(validation.error.issues[0].message));\n }\n\n const existingResult = await this.repository.get(id);\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingApiKey = existingResult.value;\n\n const updatedApiKey: ApiKey = {\n ...existingApiKey,\n ...validation.data\n };\n\n await this.eventPublisher.publish(\n new ApiKeyBeforeUpdateEvent({\n original: existingApiKey,\n updated: updatedApiKey,\n input: validation.data\n })\n );\n\n const result = await this.repository.update(updatedApiKey);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new ApiKeyAfterUpdateEvent({\n original: existingApiKey,\n updated: updatedApiKey,\n input: validation.data\n })\n );\n\n return Result.ok(updatedApiKey);\n }\n}\n\nexport const UpdateApiKeyUseCase = UpdateApiKeyUseCaseAbstraction.createImplementation({\n implementation: UpdateApiKeyUseCaseImpl,\n dependencies: [ApiKeysRepository, IdentityContext, EventPublisher]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,mBAAmB,IAAIC,8BAA8B;AAC9D,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,SAASC,uBAAuB;AAChC,SAASC,uBAAuB,EAAEC,sBAAsB;AAExD,SAASC,wBAAwB,EAAEC,qBAAqB;AAExD,MAAMC,uBAAuB,CAAqD;EAK9EC,WAAWA,CACPC,UAAuC,EACvCC,eAA0C,EAC1CC,cAAwC,EAC1C;IACE,IAAI,CAACF,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,eAAe,GAAGA,eAAe;IACtC,IAAI,CAACC,cAAc,GAAGA,cAAc;EACxC;EAEA,MAAMC,OAAOA,CACTC,EAAU,EACVC,KAAwB,EACqC;IAC7D,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACL,eAAe,CAACM,aAAa,CAAC,iBAAiB,CAAC;IACjF,IAAI,CAACD,aAAa,EAAE;MAChB,OAAOnB,MAAM,CAACqB,IAAI,CAAC,IAAIZ,wBAAwB,CAAC,CAAC,CAAC;IACtD;IAEA,MAAMa,UAAU,GAAGhB,uBAAuB,CAACiB,SAAS,CAACL,KAAK,CAAC;IAC3D,IAAI,CAACI,UAAU,CAACE,OAAO,EAAE;MACrB,OAAOxB,MAAM,CAACqB,IAAI,CAAC,IAAIX,qBAAqB,CAACY,UAAU,CAACG,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;IACrF;IAEA,MAAMC,cAAc,GAAG,MAAM,IAAI,CAACf,UAAU,CAACgB,GAAG,CAACZ,EAAE,CAAC;IACpD,IAAIW,cAAc,CAACE,MAAM,CAAC,CAAC,EAAE;MACzB,OAAO9B,MAAM,CAACqB,IAAI,CAACO,cAAc,CAACH,KAAK,CAAC;IAC5C;IAEA,MAAMM,cAAc,GAAGH,cAAc,CAACI,KAAK;IAE3C,MAAMC,aAAqB,GAAG;MAC1B,GAAGF,cAAc;MACjB,GAAGT,UAAU,CAACY;IAClB,CAAC;IAED,MAAM,IAAI,CAACnB,cAAc,CAACoB,OAAO,CAC7B,IAAI5B,uBAAuB,CAAC;MACxB6B,QAAQ,EAAEL,cAAc;MACxBM,OAAO,EAAEJ,aAAa;MACtBf,KAAK,EAAEI,UAAU,CAACY;IACtB,CAAC,CACL,CAAC;IAED,MAAMI,MAAM,GAAG,MAAM,IAAI,CAACzB,UAAU,CAAC0B,MAAM,CAACN,aAAa,CAAC;IAE1D,IAAIK,MAAM,CAACR,MAAM,CAAC,CAAC,EAAE;MACjB,OAAO9B,MAAM,CAACqB,IAAI,CAACiB,MAAM,CAACb,KAAK,CAAC;IACpC;IAEA,MAAM,IAAI,CAACV,cAAc,CAACoB,OAAO,CAC7B,IAAI3B,sBAAsB,CAAC;MACvB4B,QAAQ,EAAEL,cAAc;MACxBM,OAAO,EAAEJ,aAAa;MACtBf,KAAK,EAAEI,UAAU,CAACY;IACtB,CAAC,CACL,CAAC;IAED,OAAOlC,MAAM,CAACwC,EAAE,CAACP,aAAa,CAAC;EACnC;AACJ;AAEA,OAAO,MAAMhC,mBAAmB,GAAGC,8BAA8B,CAACuC,oBAAoB,CAAC;EACnFC,cAAc,EAAE/B,uBAAuB;EACvCgC,YAAY,EAAE,CAACxC,iBAAiB,EAAEC,eAAe,EAAEC,cAAc;AACrE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -10,6 +10,7 @@ type UpdateApiKeyError = IUpdateApiKeyErrors[keyof IUpdateApiKeyErrors] | ApiKey
|
|
|
10
10
|
export interface IUpdateApiKey {
|
|
11
11
|
execute(id: string, input: UpdateApiKeyInput): Promise<Result<ApiKey, UpdateApiKeyError>>;
|
|
12
12
|
}
|
|
13
|
+
/** Update an existing API key. */
|
|
13
14
|
export declare const UpdateApiKeyUseCase: import("@webiny/di").Abstraction<IUpdateApiKey>;
|
|
14
15
|
export declare namespace UpdateApiKeyUseCase {
|
|
15
16
|
type Interface = IUpdateApiKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","UpdateApiKeyUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ApiKey, UpdateApiKeyInput } from \"../shared/types.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\nimport { ApiKeyNotAuthorizedError, ApiKeyValidationError } from \"../shared/errors.js\";\n\nexport interface IUpdateApiKeyErrors {\n notAuthorized: ApiKeyNotAuthorizedError;\n validation: ApiKeyValidationError;\n}\n\ntype UpdateApiKeyError = IUpdateApiKeyErrors[keyof IUpdateApiKeyErrors] | ApiKeysRepository.Error;\n\nexport interface IUpdateApiKey {\n execute(id: string, input: UpdateApiKeyInput): Promise<Result<ApiKey, UpdateApiKeyError>>;\n}\n\nexport const UpdateApiKeyUseCase = createAbstraction<IUpdateApiKey>(\"UpdateApiKeyUseCase\");\n\nexport namespace UpdateApiKeyUseCase {\n export type Interface = IUpdateApiKey;\n export type Error = UpdateApiKeyError;\n}\n\nexport interface ApiKeyBeforeUpdatePayload {\n original: ApiKey;\n updated: ApiKey;\n input: UpdateApiKeyInput;\n}\n\nexport interface ApiKeyAfterUpdatePayload {\n original: ApiKey;\n updated: ApiKey;\n input: UpdateApiKeyInput;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAiBvD,OAAO,MAAMC,mBAAmB,GAAGD,iBAAiB,CAAgB,qBAAqB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createAbstraction","UpdateApiKeyUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ApiKey, UpdateApiKeyInput } from \"../shared/types.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\nimport { ApiKeyNotAuthorizedError, ApiKeyValidationError } from \"../shared/errors.js\";\n\nexport interface IUpdateApiKeyErrors {\n notAuthorized: ApiKeyNotAuthorizedError;\n validation: ApiKeyValidationError;\n}\n\ntype UpdateApiKeyError = IUpdateApiKeyErrors[keyof IUpdateApiKeyErrors] | ApiKeysRepository.Error;\n\nexport interface IUpdateApiKey {\n execute(id: string, input: UpdateApiKeyInput): Promise<Result<ApiKey, UpdateApiKeyError>>;\n}\n\n/** Update an existing API key. */\nexport const UpdateApiKeyUseCase = createAbstraction<IUpdateApiKey>(\"UpdateApiKeyUseCase\");\n\nexport namespace UpdateApiKeyUseCase {\n export type Interface = IUpdateApiKey;\n export type Error = UpdateApiKeyError;\n}\n\nexport interface ApiKeyBeforeUpdatePayload {\n original: ApiKey;\n updated: ApiKey;\n input: UpdateApiKeyInput;\n}\n\nexport interface ApiKeyAfterUpdatePayload {\n original: ApiKey;\n updated: ApiKey;\n input: UpdateApiKeyInput;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAiBvD;AACA,OAAO,MAAMC,mBAAmB,GAAGD,iBAAiB,CAAgB,qBAAqB,CAAC","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ export declare class ApiKeyBeforeUpdateEvent extends DomainEvent<ApiKeyBeforeUpd
|
|
|
5
5
|
eventType: "apiKey.beforeUpdate";
|
|
6
6
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<ApiKeyBeforeUpdateEvent>>;
|
|
7
7
|
}
|
|
8
|
+
/** Hook into API key lifecycle before an API key is updated. */
|
|
8
9
|
export declare const ApiKeyBeforeUpdateEventHandler: import("@webiny/di").Abstraction<IEventHandler<ApiKeyBeforeUpdateEvent>>;
|
|
9
10
|
export declare namespace ApiKeyBeforeUpdateEventHandler {
|
|
10
11
|
type Interface = IEventHandler<ApiKeyBeforeUpdateEvent>;
|
|
@@ -14,6 +15,7 @@ export declare class ApiKeyAfterUpdateEvent extends DomainEvent<ApiKeyAfterUpdat
|
|
|
14
15
|
eventType: "apiKey.afterUpdate";
|
|
15
16
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<ApiKeyAfterUpdateEvent>>;
|
|
16
17
|
}
|
|
18
|
+
/** Hook into API key lifecycle after an API key is updated. */
|
|
17
19
|
export declare const ApiKeyAfterUpdateEventHandler: import("@webiny/di").Abstraction<IEventHandler<ApiKeyAfterUpdateEvent>>;
|
|
18
20
|
export declare namespace ApiKeyAfterUpdateEventHandler {
|
|
19
21
|
type Interface = IEventHandler<ApiKeyAfterUpdateEvent>;
|
|
@@ -6,6 +6,8 @@ export class ApiKeyBeforeUpdateEvent extends DomainEvent {
|
|
|
6
6
|
return ApiKeyBeforeUpdateEventHandler;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
/** Hook into API key lifecycle before an API key is updated. */
|
|
9
11
|
export const ApiKeyBeforeUpdateEventHandler = createAbstraction("ApiKeyBeforeUpdateEventHandler");
|
|
10
12
|
export class ApiKeyAfterUpdateEvent extends DomainEvent {
|
|
11
13
|
eventType = "apiKey.afterUpdate";
|
|
@@ -13,6 +15,8 @@ export class ApiKeyAfterUpdateEvent extends DomainEvent {
|
|
|
13
15
|
return ApiKeyAfterUpdateEventHandler;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
18
|
+
|
|
19
|
+
/** Hook into API key lifecycle after an API key is updated. */
|
|
16
20
|
export const ApiKeyAfterUpdateEventHandler = createAbstraction("ApiKeyAfterUpdateEventHandler");
|
|
17
21
|
|
|
18
22
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","DomainEvent","ApiKeyBeforeUpdateEvent","eventType","getHandlerAbstraction","ApiKeyBeforeUpdateEventHandler","ApiKeyAfterUpdateEvent","ApiKeyAfterUpdateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { ApiKeyBeforeUpdatePayload, ApiKeyAfterUpdatePayload } from \"./abstractions.js\";\n\nexport class ApiKeyBeforeUpdateEvent extends DomainEvent<ApiKeyBeforeUpdatePayload> {\n eventType = \"apiKey.beforeUpdate\" as const;\n\n getHandlerAbstraction() {\n return ApiKeyBeforeUpdateEventHandler;\n }\n}\n\nexport const ApiKeyBeforeUpdateEventHandler = createAbstraction<\n IEventHandler<ApiKeyBeforeUpdateEvent>\n>(\"ApiKeyBeforeUpdateEventHandler\");\n\nexport namespace ApiKeyBeforeUpdateEventHandler {\n export type Interface = IEventHandler<ApiKeyBeforeUpdateEvent>;\n export type Event = ApiKeyBeforeUpdateEvent;\n}\n\nexport class ApiKeyAfterUpdateEvent extends DomainEvent<ApiKeyAfterUpdatePayload> {\n eventType = \"apiKey.afterUpdate\" as const;\n\n getHandlerAbstraction() {\n return ApiKeyAfterUpdateEventHandler;\n }\n}\n\nexport const ApiKeyAfterUpdateEventHandler = createAbstraction<\n IEventHandler<ApiKeyAfterUpdateEvent>\n>(\"ApiKeyAfterUpdateEventHandler\");\n\nexport namespace ApiKeyAfterUpdateEventHandler {\n export type Interface = IEventHandler<ApiKeyAfterUpdateEvent>;\n export type Event = ApiKeyAfterUpdateEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW;AAIpB,OAAO,MAAMC,uBAAuB,SAASD,WAAW,CAA4B;EAChFE,SAAS,GAAG,qBAAqB;EAEjCC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,8BAA8B;EACzC;AACJ;
|
|
1
|
+
{"version":3,"names":["createAbstraction","DomainEvent","ApiKeyBeforeUpdateEvent","eventType","getHandlerAbstraction","ApiKeyBeforeUpdateEventHandler","ApiKeyAfterUpdateEvent","ApiKeyAfterUpdateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { ApiKeyBeforeUpdatePayload, ApiKeyAfterUpdatePayload } from \"./abstractions.js\";\n\nexport class ApiKeyBeforeUpdateEvent extends DomainEvent<ApiKeyBeforeUpdatePayload> {\n eventType = \"apiKey.beforeUpdate\" as const;\n\n getHandlerAbstraction() {\n return ApiKeyBeforeUpdateEventHandler;\n }\n}\n\n/** Hook into API key lifecycle before an API key is updated. */\nexport const ApiKeyBeforeUpdateEventHandler = createAbstraction<\n IEventHandler<ApiKeyBeforeUpdateEvent>\n>(\"ApiKeyBeforeUpdateEventHandler\");\n\nexport namespace ApiKeyBeforeUpdateEventHandler {\n export type Interface = IEventHandler<ApiKeyBeforeUpdateEvent>;\n export type Event = ApiKeyBeforeUpdateEvent;\n}\n\nexport class ApiKeyAfterUpdateEvent extends DomainEvent<ApiKeyAfterUpdatePayload> {\n eventType = \"apiKey.afterUpdate\" as const;\n\n getHandlerAbstraction() {\n return ApiKeyAfterUpdateEventHandler;\n }\n}\n\n/** Hook into API key lifecycle after an API key is updated. */\nexport const ApiKeyAfterUpdateEventHandler = createAbstraction<\n IEventHandler<ApiKeyAfterUpdateEvent>\n>(\"ApiKeyAfterUpdateEventHandler\");\n\nexport namespace ApiKeyAfterUpdateEventHandler {\n export type Interface = IEventHandler<ApiKeyAfterUpdateEvent>;\n export type Event = ApiKeyAfterUpdateEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW;AAIpB,OAAO,MAAMC,uBAAuB,SAASD,WAAW,CAA4B;EAChFE,SAAS,GAAG,qBAAqB;EAEjCC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,8BAA8B;EACzC;AACJ;;AAEA;AACA,OAAO,MAAMA,8BAA8B,GAAGL,iBAAiB,CAE7D,gCAAgC,CAAC;AAOnC,OAAO,MAAMM,sBAAsB,SAASL,WAAW,CAA2B;EAC9EE,SAAS,GAAG,oBAAoB;EAEhCC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,6BAA6B;EACxC;AACJ;;AAEA;AACA,OAAO,MAAMA,6BAA6B,GAAGP,iBAAiB,CAE5D,+BAA+B,CAAC","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@ export interface IApiKeysRepository {
|
|
|
14
14
|
update(data: ApiKey): Promise<Result<void, RepositoryError>>;
|
|
15
15
|
delete(apiKey: ApiKey): Promise<Result<void, RepositoryError>>;
|
|
16
16
|
}
|
|
17
|
+
/** Persist and retrieve API keys. */
|
|
17
18
|
export declare const ApiKeysRepository: import("@webiny/di").Abstraction<IApiKeysRepository>;
|
|
18
19
|
export declare namespace ApiKeysRepository {
|
|
19
20
|
type Interface = IApiKeysRepository;
|
|
@@ -23,18 +24,20 @@ export type CodeApiKey = Pick<ApiKey, "name" | "permissions" | "slug"> & {
|
|
|
23
24
|
token: `wat_${string}`;
|
|
24
25
|
};
|
|
25
26
|
export interface IApiKeyFactory {
|
|
26
|
-
execute(): Promise<CodeApiKey[]
|
|
27
|
+
execute(): Promise<CodeApiKey[]>;
|
|
27
28
|
}
|
|
29
|
+
/** Provide code-defined API keys. */
|
|
28
30
|
export declare const ApiKeyFactory: import("@webiny/di").Abstraction<IApiKeyFactory>;
|
|
29
31
|
export declare namespace ApiKeyFactory {
|
|
30
32
|
type Interface = IApiKeyFactory;
|
|
31
|
-
type Return = Promise<CodeApiKey[]
|
|
33
|
+
type Return = Promise<CodeApiKey[]>;
|
|
32
34
|
type ApiKey = CodeApiKey;
|
|
33
35
|
}
|
|
34
36
|
export interface IApiKeyProvider {
|
|
35
37
|
getByToken(token: string): Promise<ApiKey | null>;
|
|
36
38
|
getBySlug(slug: string): Promise<ApiKey | null>;
|
|
37
39
|
}
|
|
40
|
+
/** Retrieve API keys by token or slug. */
|
|
38
41
|
export declare const ApiKeyProvider: import("@webiny/di").Abstraction<IApiKeyProvider>;
|
|
39
42
|
export declare namespace ApiKeyProvider {
|
|
40
43
|
type Interface = IApiKeyProvider;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
/** Persist and retrieve API keys. */
|
|
2
3
|
export const ApiKeysRepository = createAbstraction("ApiKeysRepository");
|
|
4
|
+
/** Provide code-defined API keys. */
|
|
3
5
|
export const ApiKeyFactory = createAbstraction("ApiKeyFactory");
|
|
6
|
+
/** Retrieve API keys by token or slug. */
|
|
4
7
|
export const ApiKeyProvider = createAbstraction("ApiKeyProvider");
|
|
5
8
|
|
|
6
9
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","ApiKeysRepository","ApiKeyFactory","ApiKeyProvider"],"sources":["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\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[]
|
|
1
|
+
{"version":3,"names":["createAbstraction","ApiKeysRepository","ApiKeyFactory","ApiKeyProvider"],"sources":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAyBvD;AACA,OAAO,MAAMC,iBAAiB,GAAGD,iBAAiB,CAAqB,mBAAmB,CAAC;AAe3F;AACA,OAAO,MAAME,aAAa,GAAGF,iBAAiB,CAAiB,eAAe,CAAC;AAa/E;AACA,OAAO,MAAMG,cAAc,GAAGH,iBAAiB,CAAkB,gBAAgB,CAAC","ignoreList":[]}
|
|
@@ -5,87 +5,26 @@ export declare const createApiKeyInputSchema: z.ZodObject<{
|
|
|
5
5
|
description: z.ZodString;
|
|
6
6
|
permissions: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
7
7
|
name: z.ZodString;
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
11
|
-
name: z.ZodString;
|
|
12
|
-
}, z.ZodTypeAny, "passthrough">>, "many">>>;
|
|
13
|
-
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
permissions: z.objectOutputType<{
|
|
15
|
-
name: z.ZodString;
|
|
16
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
17
|
-
name: string;
|
|
18
|
-
description: string;
|
|
19
|
-
slug: string;
|
|
20
|
-
}, {
|
|
21
|
-
name: string;
|
|
22
|
-
description: string;
|
|
23
|
-
slug: string;
|
|
24
|
-
permissions?: z.objectInputType<{
|
|
25
|
-
name: z.ZodString;
|
|
26
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
27
|
-
}>;
|
|
8
|
+
}, z.core.$loose>>>>;
|
|
9
|
+
}, z.core.$strip>;
|
|
28
10
|
export declare const updateApiKeyInputSchema: z.ZodObject<{
|
|
29
11
|
name: z.ZodOptional<z.ZodString>;
|
|
30
12
|
description: z.ZodOptional<z.ZodString>;
|
|
31
13
|
permissions: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
32
14
|
name: z.ZodString;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
36
|
-
name: z.ZodString;
|
|
37
|
-
}, z.ZodTypeAny, "passthrough">>, "many">>>;
|
|
38
|
-
}, "strip", z.ZodTypeAny, {
|
|
39
|
-
permissions: z.objectOutputType<{
|
|
40
|
-
name: z.ZodString;
|
|
41
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
42
|
-
name?: string | undefined;
|
|
43
|
-
description?: string | undefined;
|
|
44
|
-
}, {
|
|
45
|
-
permissions?: z.objectInputType<{
|
|
46
|
-
name: z.ZodString;
|
|
47
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
48
|
-
name?: string | undefined;
|
|
49
|
-
description?: string | undefined;
|
|
50
|
-
}>;
|
|
15
|
+
}, z.core.$loose>>>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
51
17
|
export declare const listApiKeysInputSchema: z.ZodObject<{
|
|
52
18
|
where: z.ZodOptional<z.ZodObject<{
|
|
53
19
|
name: z.ZodOptional<z.ZodString>;
|
|
54
20
|
name_contains: z.ZodOptional<z.ZodString>;
|
|
55
21
|
description: z.ZodOptional<z.ZodString>;
|
|
56
22
|
description_contains: z.ZodOptional<z.ZodString>;
|
|
57
|
-
},
|
|
58
|
-
name?: string | undefined;
|
|
59
|
-
description?: string | undefined;
|
|
60
|
-
name_contains?: string | undefined;
|
|
61
|
-
description_contains?: string | undefined;
|
|
62
|
-
}, {
|
|
63
|
-
name?: string | undefined;
|
|
64
|
-
description?: string | undefined;
|
|
65
|
-
name_contains?: string | undefined;
|
|
66
|
-
description_contains?: string | undefined;
|
|
67
|
-
}>>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
68
24
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
69
25
|
after: z.ZodOptional<z.ZodString>;
|
|
70
|
-
sort: z.ZodOptional<z.ZodArray<z.ZodEnum<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
description?: string | undefined;
|
|
76
|
-
name_contains?: string | undefined;
|
|
77
|
-
description_contains?: string | undefined;
|
|
78
|
-
} | undefined;
|
|
79
|
-
limit?: number | undefined;
|
|
80
|
-
after?: string | undefined;
|
|
81
|
-
}, {
|
|
82
|
-
sort?: ("createdOn_ASC" | "createdOn_DESC")[] | undefined;
|
|
83
|
-
where?: {
|
|
84
|
-
name?: string | undefined;
|
|
85
|
-
description?: string | undefined;
|
|
86
|
-
name_contains?: string | undefined;
|
|
87
|
-
description_contains?: string | undefined;
|
|
88
|
-
} | undefined;
|
|
89
|
-
limit?: number | undefined;
|
|
90
|
-
after?: string | undefined;
|
|
91
|
-
}>;
|
|
26
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
27
|
+
createdOn_ASC: "createdOn_ASC";
|
|
28
|
+
createdOn_DESC: "createdOn_DESC";
|
|
29
|
+
}>>>;
|
|
30
|
+
}, z.core.$strip>;
|
|
@@ -3,16 +3,16 @@ export const createApiKeyInputSchema = z.object({
|
|
|
3
3
|
name: z.string().min(1),
|
|
4
4
|
slug: z.string().min(1),
|
|
5
5
|
description: z.string(),
|
|
6
|
-
permissions: z.array(z.
|
|
6
|
+
permissions: z.array(z.looseObject({
|
|
7
7
|
name: z.string()
|
|
8
|
-
})
|
|
8
|
+
})).optional().default([])
|
|
9
9
|
});
|
|
10
10
|
export const updateApiKeyInputSchema = z.object({
|
|
11
11
|
name: z.string().min(1).optional(),
|
|
12
12
|
description: z.string().optional(),
|
|
13
|
-
permissions: z.array(z.
|
|
13
|
+
permissions: z.array(z.looseObject({
|
|
14
14
|
name: z.string()
|
|
15
|
-
})
|
|
15
|
+
})).optional().default([])
|
|
16
16
|
});
|
|
17
17
|
export const listApiKeysInputSchema = z.object({
|
|
18
18
|
where: z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["z","createApiKeyInputSchema","object","name","string","min","slug","description","permissions","array","
|
|
1
|
+
{"version":3,"names":["z","createApiKeyInputSchema","object","name","string","min","slug","description","permissions","array","looseObject","optional","default","updateApiKeyInputSchema","listApiKeysInputSchema","where","name_contains","description_contains","limit","number","int","positive","max","after","sort","enum"],"sources":["schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const createApiKeyInputSchema = z.object({\n name: z.string().min(1),\n slug: z.string().min(1),\n description: z.string(),\n permissions: z\n .array(z.looseObject({ name: z.string() }))\n .optional()\n .default([])\n});\n\nexport const updateApiKeyInputSchema = z.object({\n name: z.string().min(1).optional(),\n description: z.string().optional(),\n permissions: z\n .array(z.looseObject({ name: z.string() }))\n .optional()\n .default([])\n});\n\nexport const listApiKeysInputSchema = z.object({\n where: z\n .object({\n name: z.string().optional(),\n name_contains: z.string().optional(),\n description: z.string().optional(),\n description_contains: z.string().optional()\n })\n .optional(),\n limit: z.number().int().positive().max(100).optional(),\n after: z.string().optional(),\n sort: z.array(z.enum([\"createdOn_ASC\", \"createdOn_DESC\"])).optional()\n});\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,uBAAuB,GAAGD,CAAC,CAACE,MAAM,CAAC;EAC5CC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC;EACvBC,IAAI,EAAEN,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC;EACvBE,WAAW,EAAEP,CAAC,CAACI,MAAM,CAAC,CAAC;EACvBI,WAAW,EAAER,CAAC,CACTS,KAAK,CAACT,CAAC,CAACU,WAAW,CAAC;IAAEP,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC;EAAE,CAAC,CAAC,CAAC,CAC1CO,QAAQ,CAAC,CAAC,CACVC,OAAO,CAAC,EAAE;AACnB,CAAC,CAAC;AAEF,OAAO,MAAMC,uBAAuB,GAAGb,CAAC,CAACE,MAAM,CAAC;EAC5CC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACM,QAAQ,CAAC,CAAC;EAClCJ,WAAW,EAAEP,CAAC,CAACI,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC,CAAC;EAClCH,WAAW,EAAER,CAAC,CACTS,KAAK,CAACT,CAAC,CAACU,WAAW,CAAC;IAAEP,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC;EAAE,CAAC,CAAC,CAAC,CAC1CO,QAAQ,CAAC,CAAC,CACVC,OAAO,CAAC,EAAE;AACnB,CAAC,CAAC;AAEF,OAAO,MAAME,sBAAsB,GAAGd,CAAC,CAACE,MAAM,CAAC;EAC3Ca,KAAK,EAAEf,CAAC,CACHE,MAAM,CAAC;IACJC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC,CAAC;IAC3BK,aAAa,EAAEhB,CAAC,CAACI,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC,CAAC;IACpCJ,WAAW,EAAEP,CAAC,CAACI,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC,CAAC;IAClCM,oBAAoB,EAAEjB,CAAC,CAACI,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC;EAC9C,CAAC,CAAC,CACDA,QAAQ,CAAC,CAAC;EACfO,KAAK,EAAElB,CAAC,CAACmB,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,GAAG,CAAC,GAAG,CAAC,CAACX,QAAQ,CAAC,CAAC;EACtDY,KAAK,EAAEvB,CAAC,CAACI,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC,CAAC;EAC5Ba,IAAI,EAAExB,CAAC,CAACS,KAAK,CAACT,CAAC,CAACyB,IAAI,CAAC,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAACd,QAAQ,CAAC;AACxE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@ export interface IAuthenticationContext {
|
|
|
3
3
|
authenticate(token: string): Promise<Identity>;
|
|
4
4
|
getAuthToken(): string | undefined;
|
|
5
5
|
}
|
|
6
|
+
/** Authenticate incoming requests and resolve the current identity. */
|
|
6
7
|
export declare const AuthenticationContext: import("@webiny/di").Abstraction<IAuthenticationContext>;
|
|
7
8
|
export declare namespace AuthenticationContext {
|
|
8
9
|
type Interface = IAuthenticationContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","AuthenticationContext"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Identity } from \"~/features/security/IdentityContext/Identity.js\";\n\nexport interface IAuthenticationContext {\n authenticate(token: string): Promise<Identity>;\n getAuthToken(): string | undefined;\n}\n\nexport const AuthenticationContext =\n createAbstraction<IAuthenticationContext>(\"AuthenticationContext\");\n\nexport namespace AuthenticationContext {\n export type Interface = IAuthenticationContext;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAQvD,OAAO,MAAMC,qBAAqB,GAC9BD,iBAAiB,CAAyB,uBAAuB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createAbstraction","AuthenticationContext"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Identity } from \"~/features/security/IdentityContext/Identity.js\";\n\nexport interface IAuthenticationContext {\n authenticate(token: string): Promise<Identity>;\n getAuthToken(): string | undefined;\n}\n\n/** Authenticate incoming requests and resolve the current identity. */\nexport const AuthenticationContext =\n createAbstraction<IAuthenticationContext>(\"AuthenticationContext\");\n\nexport namespace AuthenticationContext {\n export type Interface = IAuthenticationContext;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAQvD;AACA,OAAO,MAAMC,qBAAqB,GAC9BD,iBAAiB,CAAyB,uBAAuB,CAAC","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ export declare class BeforeAuthenticationEvent extends DomainEvent<BeforeAuthent
|
|
|
8
8
|
eventType: "authentication.beforeAuthentication";
|
|
9
9
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<BeforeAuthenticationEvent>>;
|
|
10
10
|
}
|
|
11
|
+
/** Hook into authentication lifecycle before authentication occurs. */
|
|
11
12
|
export declare const BeforeAuthenticationEventHandler: import("@webiny/di").Abstraction<IEventHandler<BeforeAuthenticationEvent>>;
|
|
12
13
|
export declare namespace BeforeAuthenticationEventHandler {
|
|
13
14
|
type Interface = IEventHandler<BeforeAuthenticationEvent>;
|
|
@@ -21,6 +22,7 @@ export declare class AfterAuthenticationEvent extends DomainEvent<AfterAuthentic
|
|
|
21
22
|
eventType: "authentication.afterAuthentication";
|
|
22
23
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AfterAuthenticationEvent>>;
|
|
23
24
|
}
|
|
25
|
+
/** Hook into authentication lifecycle after authentication occurs. */
|
|
24
26
|
export declare const AfterAuthenticationEventHandler: import("@webiny/di").Abstraction<IEventHandler<AfterAuthenticationEvent>>;
|
|
25
27
|
export declare namespace AfterAuthenticationEventHandler {
|
|
26
28
|
type Interface = IEventHandler<AfterAuthenticationEvent>;
|
|
@@ -6,6 +6,8 @@ export class BeforeAuthenticationEvent extends DomainEvent {
|
|
|
6
6
|
return BeforeAuthenticationEventHandler;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
/** Hook into authentication lifecycle before authentication occurs. */
|
|
9
11
|
export const BeforeAuthenticationEventHandler = createAbstraction("BeforeAuthenticationEventHandler");
|
|
10
12
|
export class AfterAuthenticationEvent extends DomainEvent {
|
|
11
13
|
eventType = "authentication.afterAuthentication";
|
|
@@ -13,6 +15,8 @@ export class AfterAuthenticationEvent extends DomainEvent {
|
|
|
13
15
|
return AfterAuthenticationEventHandler;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
18
|
+
|
|
19
|
+
/** Hook into authentication lifecycle after authentication occurs. */
|
|
16
20
|
export const AfterAuthenticationEventHandler = createAbstraction("AfterAuthenticationEventHandler");
|
|
17
21
|
|
|
18
22
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DomainEvent","createAbstraction","BeforeAuthenticationEvent","eventType","getHandlerAbstraction","BeforeAuthenticationEventHandler","AfterAuthenticationEvent","AfterAuthenticationEventHandler"],"sources":["events.ts"],"sourcesContent":["import { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { Identity } from \"~/features/security/IdentityContext/Identity.js\";\n\nexport interface BeforeAuthenticationPayload {\n token: string;\n}\n\nexport class BeforeAuthenticationEvent extends DomainEvent<BeforeAuthenticationPayload> {\n eventType = \"authentication.beforeAuthentication\" as const;\n\n getHandlerAbstraction() {\n return BeforeAuthenticationEventHandler;\n }\n}\n\nexport const BeforeAuthenticationEventHandler = createAbstraction<\n IEventHandler<BeforeAuthenticationEvent>\n>(\"BeforeAuthenticationEventHandler\");\n\nexport namespace BeforeAuthenticationEventHandler {\n export type Interface = IEventHandler<BeforeAuthenticationEvent>;\n export type Event = BeforeAuthenticationEvent;\n}\n\nexport interface AfterAuthenticationPayload {\n identity: Identity;\n token: string;\n}\n\nexport class AfterAuthenticationEvent extends DomainEvent<AfterAuthenticationPayload> {\n eventType = \"authentication.afterAuthentication\" as const;\n\n getHandlerAbstraction() {\n return AfterAuthenticationEventHandler;\n }\n}\n\nexport const AfterAuthenticationEventHandler = createAbstraction<\n IEventHandler<AfterAuthenticationEvent>\n>(\"AfterAuthenticationEventHandler\");\n\nexport namespace AfterAuthenticationEventHandler {\n export type Interface = IEventHandler<AfterAuthenticationEvent>;\n export type Event = AfterAuthenticationEvent;\n}\n"],"mappings":"AAAA,SAASA,WAAW;AACpB,SAASC,iBAAiB,QAAQ,qBAAqB;AAQvD,OAAO,MAAMC,yBAAyB,SAASF,WAAW,CAA8B;EACpFG,SAAS,GAAG,qCAAqC;EAEjDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,gCAAgC;EAC3C;AACJ;
|
|
1
|
+
{"version":3,"names":["DomainEvent","createAbstraction","BeforeAuthenticationEvent","eventType","getHandlerAbstraction","BeforeAuthenticationEventHandler","AfterAuthenticationEvent","AfterAuthenticationEventHandler"],"sources":["events.ts"],"sourcesContent":["import { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { Identity } from \"~/features/security/IdentityContext/Identity.js\";\n\nexport interface BeforeAuthenticationPayload {\n token: string;\n}\n\nexport class BeforeAuthenticationEvent extends DomainEvent<BeforeAuthenticationPayload> {\n eventType = \"authentication.beforeAuthentication\" as const;\n\n getHandlerAbstraction() {\n return BeforeAuthenticationEventHandler;\n }\n}\n\n/** Hook into authentication lifecycle before authentication occurs. */\nexport const BeforeAuthenticationEventHandler = createAbstraction<\n IEventHandler<BeforeAuthenticationEvent>\n>(\"BeforeAuthenticationEventHandler\");\n\nexport namespace BeforeAuthenticationEventHandler {\n export type Interface = IEventHandler<BeforeAuthenticationEvent>;\n export type Event = BeforeAuthenticationEvent;\n}\n\nexport interface AfterAuthenticationPayload {\n identity: Identity;\n token: string;\n}\n\nexport class AfterAuthenticationEvent extends DomainEvent<AfterAuthenticationPayload> {\n eventType = \"authentication.afterAuthentication\" as const;\n\n getHandlerAbstraction() {\n return AfterAuthenticationEventHandler;\n }\n}\n\n/** Hook into authentication lifecycle after authentication occurs. */\nexport const AfterAuthenticationEventHandler = createAbstraction<\n IEventHandler<AfterAuthenticationEvent>\n>(\"AfterAuthenticationEventHandler\");\n\nexport namespace AfterAuthenticationEventHandler {\n export type Interface = IEventHandler<AfterAuthenticationEvent>;\n export type Event = AfterAuthenticationEvent;\n}\n"],"mappings":"AAAA,SAASA,WAAW;AACpB,SAASC,iBAAiB,QAAQ,qBAAqB;AAQvD,OAAO,MAAMC,yBAAyB,SAASF,WAAW,CAA8B;EACpFG,SAAS,GAAG,qCAAqC;EAEjDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,gCAAgC;EAC3C;AACJ;;AAEA;AACA,OAAO,MAAMA,gCAAgC,GAAGJ,iBAAiB,CAE/D,kCAAkC,CAAC;AAYrC,OAAO,MAAMK,wBAAwB,SAASN,WAAW,CAA6B;EAClFG,SAAS,GAAG,oCAAoC;EAEhDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,+BAA+B;EAC1C;AACJ;;AAEA;AACA,OAAO,MAAMA,+BAA+B,GAAGN,iBAAiB,CAE9D,iCAAiC,CAAC","ignoreList":[]}
|
|
@@ -2,6 +2,7 @@ import type { IdentityData } from "../../../../features/security/IdentityContext
|
|
|
2
2
|
export interface IAuthenticator {
|
|
3
3
|
authenticate(token: string): Promise<IdentityData | null>;
|
|
4
4
|
}
|
|
5
|
+
/** Convert an authentication token into identity data. */
|
|
5
6
|
export declare const Authenticator: import("@webiny/di").Abstraction<IAuthenticator>;
|
|
6
7
|
export declare namespace Authenticator {
|
|
7
8
|
type Interface = IAuthenticator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","Authenticator"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { IdentityData } from \"~/features/security/IdentityContext/Identity.js\";\n\nexport interface IAuthenticator {\n authenticate(token: string): Promise<IdentityData | null>;\n}\n\nexport const Authenticator = createAbstraction<IAuthenticator>(\"Authenticator\");\n\nexport namespace Authenticator {\n export type Interface = IAuthenticator;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAOvD,OAAO,MAAMC,aAAa,GAAGD,iBAAiB,CAAiB,eAAe,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createAbstraction","Authenticator"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { IdentityData } from \"~/features/security/IdentityContext/Identity.js\";\n\nexport interface IAuthenticator {\n authenticate(token: string): Promise<IdentityData | null>;\n}\n\n/** Convert an authentication token into identity data. */\nexport const Authenticator = createAbstraction<IAuthenticator>(\"Authenticator\");\n\nexport namespace Authenticator {\n export type Interface = IAuthenticator;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAOvD;AACA,OAAO,MAAMC,aAAa,GAAGD,iBAAiB,CAAiB,eAAe,CAAC","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ export interface IAuthorizationContext {
|
|
|
6
6
|
withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;
|
|
7
7
|
clearPermissionsCache(): void;
|
|
8
8
|
}
|
|
9
|
+
/** Load and cache security permissions for the current identity. */
|
|
9
10
|
export declare const AuthorizationContext: import("@webiny/di").Abstraction<IAuthorizationContext>;
|
|
10
11
|
export declare namespace AuthorizationContext {
|
|
11
12
|
type Interface = IAuthorizationContext;
|
|
@@ -13,6 +14,7 @@ export declare namespace AuthorizationContext {
|
|
|
13
14
|
export interface IPermissionTransformer {
|
|
14
15
|
execute(permission: SecurityPermission): SecurityPermission | SecurityPermission[];
|
|
15
16
|
}
|
|
17
|
+
/** Transform security permissions before they are applied. */
|
|
16
18
|
export declare const PermissionTransformer: import("@webiny/di").Abstraction<IPermissionTransformer>;
|
|
17
19
|
export declare namespace PermissionTransformer {
|
|
18
20
|
type Interface = IPermissionTransformer;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
/** Load and cache security permissions for the current identity. */
|
|
2
3
|
export const AuthorizationContext = createAbstraction("AuthorizationContext");
|
|
4
|
+
/** Transform security permissions before they are applied. */
|
|
3
5
|
export const PermissionTransformer = createAbstraction("PermissionTransformer");
|
|
4
6
|
|
|
5
7
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","AuthorizationContext","PermissionTransformer"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nexport interface IAuthorizationContext {\n loadPermissions(identity: Identity): Promise<SecurityPermission[]>;\n isAuthorizationEnabled(): boolean;\n withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;\n clearPermissionsCache(): void;\n}\n\nexport const AuthorizationContext =\n createAbstraction<IAuthorizationContext>(\"AuthorizationContext\");\n\nexport namespace AuthorizationContext {\n export type Interface = IAuthorizationContext;\n}\n\nexport interface IPermissionTransformer {\n execute(permission: SecurityPermission): SecurityPermission | SecurityPermission[];\n}\n\nexport const PermissionTransformer =\n createAbstraction<IPermissionTransformer>(\"PermissionTransformer\");\n\nexport namespace PermissionTransformer {\n export type Interface = IPermissionTransformer;\n export type Permission = SecurityPermission;\n export type Return = SecurityPermission | SecurityPermission[];\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAWvD,OAAO,MAAMC,oBAAoB,GAC7BD,iBAAiB,CAAwB,sBAAsB,CAAC;AAUpE,OAAO,MAAME,qBAAqB,GAC9BF,iBAAiB,CAAyB,uBAAuB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createAbstraction","AuthorizationContext","PermissionTransformer"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nexport interface IAuthorizationContext {\n loadPermissions(identity: Identity): Promise<SecurityPermission[]>;\n isAuthorizationEnabled(): boolean;\n withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;\n clearPermissionsCache(): void;\n}\n\n/** Load and cache security permissions for the current identity. */\nexport const AuthorizationContext =\n createAbstraction<IAuthorizationContext>(\"AuthorizationContext\");\n\nexport namespace AuthorizationContext {\n export type Interface = IAuthorizationContext;\n}\n\nexport interface IPermissionTransformer {\n execute(permission: SecurityPermission): SecurityPermission | SecurityPermission[];\n}\n\n/** Transform security permissions before they are applied. */\nexport const PermissionTransformer =\n createAbstraction<IPermissionTransformer>(\"PermissionTransformer\");\n\nexport namespace PermissionTransformer {\n export type Interface = IPermissionTransformer;\n export type Permission = SecurityPermission;\n export type Return = SecurityPermission | SecurityPermission[];\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAWvD;AACA,OAAO,MAAMC,oBAAoB,GAC7BD,iBAAiB,CAAwB,sBAAsB,CAAC;AAUpE;AACA,OAAO,MAAME,qBAAqB,GAC9BF,iBAAiB,CAAyB,uBAAuB,CAAC","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@ import { Identity } from "../../../../features/security/IdentityContext/index.js
|
|
|
3
3
|
export interface IAuthorizer {
|
|
4
4
|
authorize(identity: Identity): Promise<SecurityPermission[] | null>;
|
|
5
5
|
}
|
|
6
|
+
/** Retrieve permissions for an identity. */
|
|
6
7
|
export declare const Authorizer: import("@webiny/di").Abstraction<IAuthorizer>;
|
|
7
8
|
export declare namespace Authorizer {
|
|
8
9
|
type Interface = IAuthorizer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","Authorizer"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nexport interface IAuthorizer {\n authorize(identity: Identity): Promise<SecurityPermission[] | null>;\n}\n\nexport const Authorizer = createAbstraction<IAuthorizer>(\"Authorizer\");\n\nexport namespace Authorizer {\n export type Interface = IAuthorizer;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAQvD,OAAO,MAAMC,UAAU,GAAGD,iBAAiB,CAAc,YAAY,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createAbstraction","Authorizer"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nexport interface IAuthorizer {\n authorize(identity: Identity): Promise<SecurityPermission[] | null>;\n}\n\n/** Retrieve permissions for an identity. */\nexport const Authorizer = createAbstraction<IAuthorizer>(\"Authorizer\");\n\nexport namespace Authorizer {\n export type Interface = IAuthorizer;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAQvD;AACA,OAAO,MAAMC,UAAU,GAAGD,iBAAiB,CAAc,YAAY,CAAC","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ export declare class AfterLoginEvent extends DomainEvent<AfterLoginPayload> {
|
|
|
8
8
|
eventType: "login.afterLogin";
|
|
9
9
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AfterLoginEvent>>;
|
|
10
10
|
}
|
|
11
|
+
/** Hook into login lifecycle after a user logs in. */
|
|
11
12
|
export declare const AfterLoginEventHandler: import("@webiny/di").Abstraction<IEventHandler<AfterLoginEvent>>;
|
|
12
13
|
export declare namespace AfterLoginEventHandler {
|
|
13
14
|
type Interface = IEventHandler<AfterLoginEvent>;
|
|
@@ -6,6 +6,8 @@ export class AfterLoginEvent extends DomainEvent {
|
|
|
6
6
|
return AfterLoginEventHandler;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
/** Hook into login lifecycle after a user logs in. */
|
|
9
11
|
export const AfterLoginEventHandler = createAbstraction("AfterLoginEventHandler");
|
|
10
12
|
|
|
11
13
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DomainEvent","createAbstraction","AfterLoginEvent","eventType","getHandlerAbstraction","AfterLoginEventHandler"],"sources":["abstractions.ts"],"sourcesContent":["import { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nexport interface AfterLoginPayload {\n identity: Identity;\n}\n\nexport class AfterLoginEvent extends DomainEvent<AfterLoginPayload> {\n eventType = \"login.afterLogin\" as const;\n\n getHandlerAbstraction() {\n return AfterLoginEventHandler;\n }\n}\n\nexport const AfterLoginEventHandler =\n createAbstraction<IEventHandler<AfterLoginEvent>>(\"AfterLoginEventHandler\");\n\nexport namespace AfterLoginEventHandler {\n export type Interface = IEventHandler<AfterLoginEvent>;\n export type Event = AfterLoginEvent;\n}\n"],"mappings":"AAAA,SAASA,WAAW;AAEpB,SAASC,iBAAiB,QAAQ,qBAAqB;AAOvD,OAAO,MAAMC,eAAe,SAASF,WAAW,CAAoB;EAChEG,SAAS,GAAG,kBAAkB;EAE9BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,sBAAsB;EACjC;AACJ;
|
|
1
|
+
{"version":3,"names":["DomainEvent","createAbstraction","AfterLoginEvent","eventType","getHandlerAbstraction","AfterLoginEventHandler"],"sources":["abstractions.ts"],"sourcesContent":["import { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nexport interface AfterLoginPayload {\n identity: Identity;\n}\n\nexport class AfterLoginEvent extends DomainEvent<AfterLoginPayload> {\n eventType = \"login.afterLogin\" as const;\n\n getHandlerAbstraction() {\n return AfterLoginEventHandler;\n }\n}\n\n/** Hook into login lifecycle after a user logs in. */\nexport const AfterLoginEventHandler =\n createAbstraction<IEventHandler<AfterLoginEvent>>(\"AfterLoginEventHandler\");\n\nexport namespace AfterLoginEventHandler {\n export type Interface = IEventHandler<AfterLoginEvent>;\n export type Event = AfterLoginEvent;\n}\n"],"mappings":"AAAA,SAASA,WAAW;AAEpB,SAASC,iBAAiB,QAAQ,qBAAqB;AAOvD,OAAO,MAAMC,eAAe,SAASF,WAAW,CAAoB;EAChEG,SAAS,GAAG,kBAAkB;EAE9BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,sBAAsB;EACjC;AACJ;;AAEA;AACA,OAAO,MAAMA,sBAAsB,GAC/BJ,iBAAiB,CAAiC,wBAAwB,CAAC","ignoreList":[]}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import { TenantContext } from "../../../../features/tenancy/TenantContext/index.js";
|
|
3
2
|
import { EventPublisher } from "../../../../features/eventPublisher/index.js";
|
|
4
3
|
import { CreateRoleUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
5
4
|
import { RolesRepository } from "../shared/abstractions.js";
|
|
6
5
|
import { IdentityContext } from "../../IdentityContext/abstractions.js";
|
|
7
6
|
import type { Role, CreateRoleInput } from "../shared/types.js";
|
|
8
7
|
declare class CreateRoleUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
9
|
-
private tenantContext;
|
|
10
8
|
private identityContext;
|
|
11
9
|
private eventPublisher;
|
|
12
10
|
private repository;
|
|
13
|
-
constructor(
|
|
11
|
+
constructor(identityContext: IdentityContext.Interface, eventPublisher: EventPublisher.Interface, repository: RolesRepository.Interface);
|
|
14
12
|
execute(input: CreateRoleInput): Promise<Result<Role, UseCaseAbstraction.Error>>;
|
|
15
13
|
}
|
|
16
14
|
export declare const CreateRoleUseCase: import("@webiny/di").Implementation<typeof CreateRoleUseCaseImpl>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { mdbid } from "@webiny/utils";
|
|
2
2
|
import { createImplementation } from "@webiny/feature/api";
|
|
3
3
|
import { Result } from "@webiny/feature/api";
|
|
4
|
-
import { TenantContext } from "../../../tenancy/TenantContext/index.js";
|
|
5
4
|
import { EventPublisher } from "../../../eventPublisher/index.js";
|
|
6
5
|
import { CreateRoleUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
7
6
|
import { RolesRepository } from "../shared/abstractions.js";
|
|
@@ -10,8 +9,7 @@ import { createRoleValidation } from "./schema.js";
|
|
|
10
9
|
import { RoleBeforeCreateEvent, RoleAfterCreateEvent } from "./events.js";
|
|
11
10
|
import { NotAuthorizedError, RoleExistsError, RoleValidationError } from "../shared/errors.js";
|
|
12
11
|
class CreateRoleUseCaseImpl {
|
|
13
|
-
constructor(
|
|
14
|
-
this.tenantContext = tenantContext;
|
|
12
|
+
constructor(identityContext, eventPublisher, repository) {
|
|
15
13
|
this.identityContext = identityContext;
|
|
16
14
|
this.eventPublisher = eventPublisher;
|
|
17
15
|
this.repository = repository;
|
|
@@ -23,9 +21,8 @@ class CreateRoleUseCaseImpl {
|
|
|
23
21
|
}
|
|
24
22
|
const validation = createRoleValidation.safeParse(input);
|
|
25
23
|
if (!validation.success) {
|
|
26
|
-
return Result.fail(new RoleValidationError(validation.error.
|
|
24
|
+
return Result.fail(new RoleValidationError(validation.error.issues[0].message));
|
|
27
25
|
}
|
|
28
|
-
const tenant = this.tenantContext.getTenant();
|
|
29
26
|
const identity = this.identityContext.getIdentity();
|
|
30
27
|
const data = validation.data;
|
|
31
28
|
|
|
@@ -43,7 +40,6 @@ class CreateRoleUseCaseImpl {
|
|
|
43
40
|
description: data.description,
|
|
44
41
|
permissions: data.permissions,
|
|
45
42
|
system: input.system || false,
|
|
46
|
-
tenant: tenant.id,
|
|
47
43
|
createdOn: new Date().toISOString(),
|
|
48
44
|
createdBy: {
|
|
49
45
|
id: identity.id,
|
|
@@ -70,7 +66,7 @@ class CreateRoleUseCaseImpl {
|
|
|
70
66
|
export const CreateRoleUseCase = createImplementation({
|
|
71
67
|
abstraction: UseCaseAbstraction,
|
|
72
68
|
implementation: CreateRoleUseCaseImpl,
|
|
73
|
-
dependencies: [
|
|
69
|
+
dependencies: [IdentityContext, EventPublisher, RolesRepository]
|
|
74
70
|
});
|
|
75
71
|
|
|
76
72
|
//# sourceMappingURL=CreateRoleUseCase.js.map
|