generateIssueCredentialMessageFromRequest function

Future<IssueCredential> generateIssueCredentialMessageFromRequest({
  1. required RequestCredential message,
  2. required WalletStore wallet,
  3. required String connectionDid,
  4. required List<String> replyTo,
})

Will issue a credential to the user

Implementation

Future<IssueCredential> generateIssueCredentialMessageFromRequest({
  required RequestCredential message,
  required WalletStore wallet,
  required String connectionDid,
  required List<String> replyTo,
}) async {
  var credential = message.detail!.first.credential;

  // sign the requested credential (normally we had to check before that,
  // that the data in it is the same we offered)
  // @TODO add checks!
  var signed = await signCredential(wallet, credential,
      challenge: message.detail!.first.options.challenge);

  // issue the credential
  var issue = IssueCredential(
      threadId: message.threadId ?? message.id,
      from: connectionDid,
      to: [message.from!],
      replyTo: replyTo,
      credentials: [VerifiableCredential.fromJson(signed)]);

  return issue;
}