diff --git a/libs/askar/src/agent.utils.ts b/libs/askar/src/agent.utils.ts index 92b49705688bfac0ded963aba67bcdc3a5b4f817..47fa752d06e6ec4dbf4ba817fc3128888f70281b 100644 --- a/libs/askar/src/agent.utils.ts +++ b/libs/askar/src/agent.utils.ts @@ -768,7 +768,7 @@ export const handleRevocationForCredDef = async ( if ( statusListIndex && - statusListIndex > context.agentConfig.revocationListSize + statusListIndex >= context.agentConfig.revocationListSize ) { const { revocStatusList, @@ -784,6 +784,16 @@ export const handleRevocationForCredDef = async ( } + if ( + customRevocRecord && + customRevocRecord.length > 0 && + typeof statusListIndex !== 'undefined' + ) { + customRevocRecord[0].setTag("latestIndex", (Number(statusListIndex)+1).toString()) + await context.agent.genericRecords.update(customRevocRecord[0]) + } + + return { revocRecord: customRevocRecord, statusListIndex: statusListIndex, @@ -792,7 +802,9 @@ export const handleRevocationForCredDef = async ( } - +export function sleep(ms: number) { + return new Promise((res) => setTimeout(res, ms)) +} export const registerRevocationDefAndList = async ( context: AskarService, @@ -809,6 +821,8 @@ export const registerRevocationDefAndList = async ( }, options: {} }); + + await sleep(1000) if ( !revocReg || @@ -827,6 +841,8 @@ export const registerRevocationDefAndList = async ( options: {} }) + await sleep(1000) + if (!revocStatusList || revocStatusList.revocationStatusListState.state !== 'finished') { throw new Error("Failed to register revocation status list on ledger."+revocStatusList); } diff --git a/libs/askar/src/askar/agent.service.ts b/libs/askar/src/askar/agent.service.ts index 4fa362c9e8ff940ecb1d7938bfc73172e2f726e4..d3f0a13b95f6f6cf7d4c1340db6c5d30022e0715 100644 --- a/libs/askar/src/askar/agent.service.ts +++ b/libs/askar/src/askar/agent.service.ts @@ -54,7 +54,7 @@ import { JsonCredential, W3cJsonLdVerifiableCredential, } from "@credo-ts/core"; -import { AnonCredsCredentialMetadata, AnonCredsRequestedAttribute } from "@credo-ts/anoncreds"; +import { AnonCredsRequestedAttribute } from "@credo-ts/anoncreds"; import { uuid } from "@credo-ts/core/build/utils/uuid"; import { getRevocationDetails, @@ -666,6 +666,8 @@ export class AgentService { let customRevocationRecord = undefined; let statusListIdx = undefined; let revocationRegistryDef = undefined; + + // REVIEW: it is possible that credential MUST be revocable if cred def is if (offerCredentialDto.revocable) { const { revocRecord, statusListIndex, revocationRegistryDefinitionId } = await handleRevocationForCredDef(this.askar, offerCredentialDto); customRevocationRecord = revocRecord; @@ -690,20 +692,6 @@ export class AgentService { credentialRecord.setTag("xRole", "issuer"); await this.askar.agent.credentials.update(credentialRecord); - - - // INFO: update with latest index once it is issued - if ( - offerCredentialDto.revocable && - revocationRegistryDef && - customRevocationRecord && - customRevocationRecord.length > 0 && - typeof statusListIdx !== 'undefined' - ) { - customRevocationRecord[0].setTag("latestIndex", (Number(statusListIdx)+1).toString()) - await this.askar.agent.genericRecords.update(customRevocationRecord[0]) - } - const outOfBandRecord = await this.askar.agent.oob.createInvitation({ messages: [message], @@ -984,7 +972,7 @@ export class AgentService { const updatedList = await this.askar.agent.modules.anoncreds.updateRevocationStatusList({ revocationStatusList: { revocationRegistryDefinitionId: revocationRegistryId, - revokedCredentialIndexes: [credentialRevocationId], + revokedCredentialIndexes: [credentialRevocationId] }, options: {}, }) diff --git a/libs/askar/src/credo/revocation/TailFileService.ts b/libs/askar/src/credo/revocation/TailFileService.ts index 2582a2cb0b9433790d7f4d4324a2077a3766df16..876260795c1b1c197fa6783dde28bd6917a6686a 100644 --- a/libs/askar/src/credo/revocation/TailFileService.ts +++ b/libs/askar/src/credo/revocation/TailFileService.ts @@ -7,12 +7,6 @@ import fs from 'fs'; import { Client } from 'minio'; -// bucketName: 73157ea7fc0a690a89e80513 -// baseUrl: s3.us-west-000.backblazeb2.com -// secret: K000e++ZchAncs27jCueO+P+M1UEN2Q -// key: 00035e7ca9a9853000000000d - - export class S3TailsFileService extends BasicTailsFileService { private tailsServerBaseUrl: string; private tailsServerBucketName: string;