Skip to main content

Share a credential or presentation

Sharing verifiable credentials and presentations securely is a core feature of the Truvity platform. The platform uses DIDComm messaging for sharing credentials and presentations.

Share a verifiable credential

To send a DIDComm message containing a verifiable credential (VC), use the send method:

await credential.send("targetId", privateKey.id);

Where targetId is the DID of the receiving party.

tip
  • If you want to send DIDComm messages between two accounts for testing purposes, you can sign up with a different email (or email alias) and use the DID of a new account.
  • To find the DID of your account, go to the Admin Panel and click DID of my tenant.

After you send the DIDComm message with credentials, and/or files, the target wallet automatically receives the message and unpacks the content.

Share a verifiable presentation

Verifiable presentations allow holders to share selected information from their verifiable credentials with a verifier. A presentation can bundle multiple credentials and uses cryptographic proofs to ensure authenticity and integrity.

To issue and share a verifiable presentation that contains multiple verifiable credentials, follow the steps below:

  1. Initialize the VpDecorator instance and use it to create a VerifiablePresentation:
const vpDecoratorInstance = await client.createVpDecorator(); // VpDecorator
  1. Call the issue method to issue a new verifiable presentation and return its representation (a VerifiablePresentation instance).
const presentation = await vpDecoratorInstance.issue([credential, credential2], privateKey.id); // VerifiablePresentation

You can pass the following arrays to the issue method:

  • VerifiableCredential
  • CredentialResource ids
  • CredentialResource
  • UnknownVerifiableCredential
  1. Call the send method to send a DIDComm message containing a verifiable presentation:
await presentation.send("targetId", privateKey.id);

Where targetId is the DID of the receiving party.

After you send the DIDComm message with the presentation, credentials, and/or files, the target wallet automatically receives the message and unpacks the content.

Configure transitive closure

By default, the system retrieves all directly referenced resources as well as any linked resources recursively. If you need to control this behavior, you can use the disable_transitive_closure flag:

await client.didcommMessages.didCommMessageSend({
data: {
to: "targetId",
keyId: privateKey.id,
credentials: [credential.descriptor.id],
disableTransitiveClosure: true,
},
});

About disable_transitive_closure

The disable_transitive_closure flag determines whether the system retrieves only explicitly referenced resources or follows links to related resources:

  • true - Only explicitly referenced resources (credentials, files, presentations) are retrieved. Linked resources are ignored.
  • false (default) - The system performs transitive traversal, retrieving all directly referenced resources and any linked resources recursively.

This flag applies to resources such as credentials, files, and presentations, influencing how dependencies are resolved during message processing.