diff --git a/README.md b/README.md index 6778c4f..9afaa42 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ console.log(statusCredential); */ ``` -**Note:** You can also call `revokeCredential(credentialId)` to achieve the same effect as `updateStatus({ credentialId, statusPurpose: 'revocation', invalidate: true })` and `suspendCredential(credentialId)` to achieve the same effect as `updateStatus({ credentialId, statusPurpose: 'suspension', invalidate: true })`. +**Note:** You can also call `revokeCredential(credentialId)` to achieve the same effect as `updateStatus({ credentialId, statusPurpose: 'revocation', invalidate: true })` and `suspendCredential(credentialId)` to achieve the same effect as `updateStatus({ credentialId, statusPurpose: 'suspension', invalidate: true })`. Also note that `unsuspendCredential(credentialId)` will lift a suspension from a credential, while there is no equivalent reversal logic for revocation, since it is not allowed. ### Check status of credential diff --git a/src/credential-status-manager-base.ts b/src/credential-status-manager-base.ts index 52aa62e..19c08bd 100644 --- a/src/credential-status-manager-base.ts +++ b/src/credential-status-manager-base.ts @@ -756,6 +756,15 @@ export abstract class BaseCredentialStatusManager { }); } + // lifts suspension from credential + async unsuspendCredential(credentialId: string): Promise { + return this.updateStatus({ + credentialId, + statusPurpose: StatusPurpose.Suspension, + invalidate: false + }); + } + // retrieves status of credential with given ID async getStatus(credentialId: string, options?: DatabaseConnectionOptions): Promise { // retrieve user credential record @@ -966,6 +975,7 @@ export abstract class BaseCredentialStatusManager { // examine info for all status purposes const statusPurposes = Object.keys(statusCredentialInfo) as StatusPurpose[]; + const statusPurposesCounter = statusPurposes.length; let credsIssuedCounter = 0; for (const statusPurpose of statusPurposes) { const { @@ -1039,7 +1049,9 @@ export abstract class BaseCredentialStatusManager { const credentialIds = await this.getAllUserCredentialIds(options); const credentialIdsCounter = credentialIds.length; const hasValidIssuedCounterCredentialToConfig = credentialIdsCounter === credentialsIssuedCounter; - const hasValidIssuedCounterConfigToReality = credentialsIssuedCounter === credsIssuedCounter; + const hasValidIssuedCounterConfigToReality = + credentialsIssuedCounter <= credsIssuedCounter && + credsIssuedCounter <= credentialsIssuedCounter * statusPurposesCounter; // check if credential issuance counter matches between // credential table and config table