diff --git a/packages/data-store/src/statusList/StatusListStore.ts b/packages/data-store/src/statusList/StatusListStore.ts index 0e899d40d..ad5f8aac4 100644 --- a/packages/data-store/src/statusList/StatusListStore.ts +++ b/packages/data-store/src/statusList/StatusListStore.ts @@ -89,9 +89,9 @@ export class StatusListStore implements IStatusListStore { await this.getStatusListEntryRepo() ).findOne({ where: { - ...(args.statusListId && { statusList: args.statusListId }), + statusList: args.statusListId, ...(args.correlationId && { correlationId: args.correlationId }), - statusListIndex: args.statusListIndex, + ...(args.statusListIndex && { statusListIndex: args.statusListIndex }), }, }) diff --git a/packages/data-store/src/types/statusList/IAbstractStatusListStore.ts b/packages/data-store/src/types/statusList/IAbstractStatusListStore.ts index b1a00b337..637ccad7d 100644 --- a/packages/data-store/src/types/statusList/IAbstractStatusListStore.ts +++ b/packages/data-store/src/types/statusList/IAbstractStatusListStore.ts @@ -11,9 +11,9 @@ export interface IStatusListEntryAvailableArgs { } export interface IGetStatusListEntryByIndexArgs { - statusListId?: string + statusListId: string correlationId?: string - statusListIndex: number + statusListIndex?: number errorOnNotFound?: boolean } diff --git a/packages/vc-status-list-issuer-rest-api/src/api-functions.ts b/packages/vc-status-list-issuer-rest-api/src/api-functions.ts index eb5a5a4f5..7ac8f7ed3 100644 --- a/packages/vc-status-list-issuer-rest-api/src/api-functions.ts +++ b/packages/vc-status-list-issuer-rest-api/src/api-functions.ts @@ -127,8 +127,8 @@ export function getStatusListCredentialIndexStatusEndpoint(router: Router, conte const entityCorrelationId = request.query.entityCorrelationId?.toString() let entry = await driver.getStatusListEntryByIndex({ - statusListIndex, - ...(entityCorrelationId ? { correlationId: entityCorrelationId } : { statusListId: details.id }), + statusListId: details.id, + ...(entityCorrelationId ? { correlationId: entityCorrelationId } : { statusListIndex: statusListIndex }), errorOnNotFound: false, }) const type = details.type === StatusListType.StatusList2021 ? 'StatusList2021Entry' : details.type @@ -197,10 +197,15 @@ export function updateStatusEndpoint(router: Router, context: IRequiredContext, if (!updateRequest.statusListIndex || updateRequest.statusListIndex < 0) { return sendErrorResponse(response, 400, 'Invalid statusListIndex supplied') } + const driver = await getDriver({ + ...(statusListCorrelationId ? { statusListCorrelationId } : { id: buildStatusListId(request) }), + dbName: opts.dbName, + }) + const details = await driver.getStatusList() + statusListEntry = await driver.getStatusListEntryByIndex({ - statusListIndex: updateRequest.statusListIndex, - ...(statusListId && { statusListId }), - ...(!statusListId && { correlationId: statusListCorrelationId }), // Do not query for correlationId when we have statusListId + statusListId: details.id, + ...(entryCorrelationId ? { correlationId: entryCorrelationId } : { statusListIndex: updateRequest.statusListIndex }), errorOnNotFound: true, }) }