Skip to content

Commit

Permalink
adds utility function to attach status credential context
Browse files Browse the repository at this point in the history
  • Loading branch information
kezike committed Dec 3, 2023
1 parent d5b508f commit 1ebf020
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/credential-status-manager-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export abstract class BaseCredentialStatusManager {
credential: {
...credential,
credentialStatus,
'@context': [...credential['@context'], CONTEXT_URL_V1]
'@context': ensureStatusCredentialContext(credential['@context'])
},
newStatusCredential: false,
latestStatusCredentialId,
Expand All @@ -232,8 +232,8 @@ export abstract class BaseCredentialStatusManager {
let newStatusCredential = false;
if (latestCredentialsIssuedCounter >= CREDENTIAL_STATUS_LIST_SIZE) {
newStatusCredential = true;
latestStatusCredentialId = this.generateStatusCredentialId();
latestCredentialsIssuedCounter = 0;
latestStatusCredentialId = this.generateStatusCredentialId();
statusCredentialIds.push(latestStatusCredentialId);
}
latestCredentialsIssuedCounter++;
Expand All @@ -255,7 +255,7 @@ export abstract class BaseCredentialStatusManager {
credential: {
...credential,
credentialStatus,
'@context': [...credential['@context'], CONTEXT_URL_V1]
'@context': ensureStatusCredentialContext(credential['@context'])
},
newStatusCredential,
latestStatusCredentialId,
Expand Down Expand Up @@ -747,6 +747,13 @@ export abstract class BaseCredentialStatusManager {
}
}

// ensures that the proper status credential context is included
const ensureStatusCredentialContext = (currentContext: any[]): void => {
if (!currentContext.includes(CONTEXT_URL_V1)) {
currentContext.push(CONTEXT_URL_V1);
}
};

// composes StatusList2021Credential
export async function composeStatusCredential({
issuerDid,
Expand Down

0 comments on commit 1ebf020

Please sign in to comment.