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};
}
const getPublicKeyFromDIDDoc = require("./getPublicKeyFromDIDDoc");
const OpenPgpSignature2019 = require("@transmute/openpgpsignature2019");
const wrappedDocumentLoader = require("./wrappedDocumentLoader");
const jsigs = require("jsonld-signatures");
const { Ed25519Signature2018 } = jsigs.suites;
const { AssertionProofPurpose } = jsigs.purposes;
const { Ed25519KeyPair } = require("crypto-ld");
const verifyWithResolver = async (signedData, resolver) => {
const verificationMethod = signedData.proof.verificationMethod
? signedData.proof.verificationMethod
: signedData.proof.creator;
const doc = await resolver.resolve(verificationMethod);
const didPublicKey = doc.publicKey.find(k => {
return k.id == verificationMethod;
});
if (didPublicKey.type === "Ed25519VerificationKey2018") {
const result = await jsigs.verify(signedData, {
documentLoader: wrappedDocumentLoader({
//args that are needed in the wrapper.. such as zcaps
/*!
* Copyright (c) 2019 Digital Bazaar, Inc. All rights reserved.
*/
'use strict';
const {AssertionProofPurpose} = require('jsonld-signatures').purposes;
/**
* Creates a proof purpose that will validate whether or not the verification
* method in a proof was authorized by its declared controller for the
* proof's purpose.
*
* Required params:
* - `controller`
*/
class CredentialIssuancePurpose extends AssertionProofPurpose {
}
module.exports = CredentialIssuancePurpose;