Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.sendOffer = async function (theirDid, credentialDefinitionId, credentialData) {
if(theirDid === '_self_') {
return issueCredentialToSelf(credentialDefinitionId, credentialData);
}
else {
let credOffer = await sdk.issuerCreateCredentialOffer(await indy.wallet.get(), credentialDefinitionId);
try {
credOffer.data = JSON.parse(credentialData);
} catch (e) {
credOffer.data = {};
console.log(e);
}
await indy.store.pendingCredentialOffers.write(credOffer);
let pairwise = await sdk.getPairwise(await indy.wallet.get(), theirDid);
let myDid = pairwise.my_did;
let message = await indy.crypto.buildAuthcryptedMessage(myDid, theirDid, MESSAGE_TYPES.OFFER, credOffer);
let meta = JSON.parse(pairwise.metadata);
let theirEndpointDid = meta.theirEndpointDid;
return indy.crypto.sendAnonCryptedMessage(theirEndpointDid, message);
}
};
exports.getTheirEndpointDid = async function (theirDid) {
let pairwise = await sdk.getPairwise(await indy.wallet.get(), theirDid);
let metadata = JSON.parse(pairwise.metadata);
return metadata.theirEndpointDid;
};
exports.get = async function(theirDid) {
return await sdk.getPairwise(await indy.wallet.get(), theirDid);
};