Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function _generateCredential() {
const mockCredential = jsonld.clone(mockData.credentials.alpha);
const {authenticationKey, documentLoader} = await _generateDid();
const {Ed25519Signature2018} = jsigs.suites;
const {AuthenticationProofPurpose} = jsigs.purposes;
testLoader.addLoader(documentLoader);
const credential = await jsigs.sign(mockCredential, {
compactProof: false,
documentLoader: testLoader.documentLoader.bind(testLoader),
suite: new Ed25519Signature2018({key: authenticationKey}),
purpose: new AuthenticationProofPurpose({
challenge: 'challengeString'
})
});
return {credential, documentLoader};
}
async function _generatePresentation({challenge, domain}) {
const mockPresentation = jsonld.clone(mockData.presentations.alpha);
const {authenticationKey, documentLoader: dlp} = await _generateDid();
testLoader.addLoader(dlp);
const {Ed25519Signature2018} = jsigs.suites;
const {AuthenticationProofPurpose} = jsigs.purposes;
const {credential, documentLoader: dlc} = await _generateCredential();
testLoader.addLoader(dlc);
mockPresentation.verifiableCredential.push(credential);
const presentation = await jsigs.sign(mockPresentation, {
compactProof: false,
documentLoader: testLoader.documentLoader.bind(testLoader),
suite: new Ed25519Signature2018({key: authenticationKey}),
purpose: new AuthenticationProofPurpose({challenge, domain})
});
return {presentation};
}