How to use the indy-sdk.issuerCreateCredential function in indy-sdk

To help you get started, we’ve selected a few indy-sdk examples, based on popular ways it is used in public projects.

github hyperledger / indy-agent / nodejs / indy / src / credentials / index.js View on Github external
} catch (e) {
      credentialOffer.data = {};
      console.log(e);
    }
    let [, credentialDefinition] = await indy.issuer.getCredDef(pool, endpointDID, credentialOffer.cred_def_id);
    let masterSecretId = await indy.did.getEndpointDidAttribute('master_secret_id');
    let [credRequestJson, credRequestMetadataJson] = await sdk.proverCreateCredentialReq(wallet, endpointDID, credentialOffer, credentialDefinition, masterSecretId);
    let schema = await indy.issuer.getSchema(credentialOffer.schema_id);

    let credentialValues = {};
    for (let attr of schema.attrNames) {
      if (credentialOffer.data[attr]) {
        credentialValues[attr] = {raw: credentialOffer.data[attr], encoded: indy.credentials.encode(credentialOffer.data[attr])};
      }
    }
    let [credential] = await sdk.issuerCreateCredential(wallet, credentialOffer, credRequestJson, credentialValues);
    await sdk.proverStoreCredential(wallet, null, credRequestMetadataJson, credential, credentialDefinition);
  } catch (e) {
      console.log(e);
  }
}
github hyperledger / indy-agent / nodejs / indy / src / credentials / index.js View on Github external
pendingCredOfferId = pendingCredOffer.id;
            credentialOffer = pendingCredOffer.offer;
        }
    }
    let schema = await indy.issuer.getSchema(credentialOffer.schema_id);

    let credentialValues = {};
    for(let attr of schema.attrNames) {
        if(credentialOffer.data[attr]) {
          credentialValues[attr] = {raw: credentialOffer.data[attr], encoded: indy.credentials.encode(credentialOffer.data[attr])};
        }
    }

    console.log(credentialValues);

    let [credential] = await sdk.issuerCreateCredential(await indy.wallet.get(), credentialOffer, credentialRequest, credentialValues);
    let message = await indy.crypto.buildAuthcryptedMessage(myDid, theirDid, MESSAGE_TYPES.CREDENTIAL, credential);
    let theirEndpointDid = await indy.did.getTheirEndpointDid(theirDid);
    await indy.crypto.sendAnonCryptedMessage(theirEndpointDid, message);
    indy.store.pendingCredentialOffers.delete(pendingCredOfferId);
};