Skip to content

Commit

Permalink
Add issueCredential method to test helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Sep 15, 2024
1 parent 11a0a29 commit 34bb44d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*!
* Copyright (c) 2019-2024 Digital Bazaar, Inc. All rights reserved.
*/
import * as vc from '../lib/index.js';
import {CredentialIssuancePurpose} from '../lib/CredentialIssuancePurpose.js';
import {
documentLoader as defaultLoader
Expand All @@ -23,6 +24,36 @@ export function createSkewedTimeStamp({date = new Date(), skewYear}) {
return `${isoString.substring(0, isoString.length - 5)}Z`;
}

export async function issueCredential({
credential,
suites,
mandatoryPointers,
selectivePointers = [],
issuer,
derived,
documentLoader = defaultLoader,
}) {
credential.issuer = issuer;
credential.id = `http://example.edu/credentials/${uuid()}`;
const verifiableCredential = await vc.issue({
credential,
documentLoader,
suite: suites.issue({mandatoryPointers}),
});
if(!derived) {
return {verifiableCredential};
}
const derivedCredential = await vc.derive({
verifiableCredential,
documentLoader,
suite: suites.derive({selectivePointers}),
});
return {
verifiableCredential: derivedCredential,
baseCredential: verifiableCredential
};
}

export async function signCredential({
credential,
suites,
Expand Down

0 comments on commit 34bb44d

Please sign in to comment.