feat(api-key): Allow revoking in the future, and enforce the secret key (#6484)

Since there is quite a bit of code here already, I'll do the middleware changes in a separate PR
This commit is contained in:
Stevche Radevski
2024-02-27 10:37:32 +00:00
committed by GitHub
parent ca463ae9a9
commit 690e8c2e09
13 changed files with 357 additions and 120 deletions
@@ -4,12 +4,11 @@ import {
IApiKeyModuleService,
RevokeApiKeyDTO,
} from "@medusajs/types"
import { getSelectsAndRelationsFromObjectArray } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
type RevokeApiKeysStepInput = {
selector: FilterableApiKeyProps
revoke: Omit<RevokeApiKeyDTO, "id">
revoke: RevokeApiKeyDTO
}
export const revokeApiKeysStepId = "revoke-api-keys"
@@ -9,7 +9,7 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
type UpdateApiKeysStepInput = {
selector: FilterableApiKeyProps
update: Omit<UpdateApiKeyDTO, "id">
update: UpdateApiKeyDTO
}
export const updateApiKeysStepId = "update-api-keys"
@@ -41,7 +41,7 @@ export const updateApiKeysStep = createStep(
ModuleRegistrationName.API_KEY
)
await service.update(
await service.upsert(
prevData.map((r) => ({
id: r.id,
title: r.title,
@@ -8,7 +8,7 @@ import { revokeApiKeysStep } from "../steps"
type RevokeApiKeysStepInput = {
selector: FilterableApiKeyProps
revoke: Omit<RevokeApiKeyDTO, "id">
revoke: RevokeApiKeyDTO
}
type WorkflowInput = RevokeApiKeysStepInput
@@ -8,7 +8,7 @@ import { updateApiKeysStep } from "../steps"
type UpdateApiKeysStepInput = {
selector: FilterableApiKeyProps
update: Omit<UpdateApiKeyDTO, "id">
update: UpdateApiKeyDTO
}
type WorkflowInput = UpdateApiKeysStepInput