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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user