didcomm library

Affinidi DIDComm for Dart

A Dart library for secure, private, and verifiable communication using the DIDComm v2 Messaging protocol.

This package provides tools for constructing, signing, encrypting, and unpacking DIDComm messages, supporting multiple DID methods and cryptographic algorithms. It enables confidential, authenticated, and non-repudiable messaging between decentralized identities.

Classes

AccessListAddMessage
Represents a root DIDComm ACL Management Message.
AclManagementMessage
Represents a root DIDComm ACL Management Message.
AffinidiAuthorizationProvider
An AuthorizationProvider implementation for Affinidi mediators.
Attachment
Represents an attachment in a DIDComm plaintext message, as defined in the DIDComm Messaging specification.
AttachmentData
Data container for a DIDComm attachment, as defined in the DIDComm Messaging specification.
AuthorizationProvider
An abstract provider for handling authorization and access tokens.
AuthorizationTokens
Represents a set of authentication tokens, including access and refresh tokens, along with their expiration times.
ConnectionPool
Maintains a pool of Connections shared across multiple MediatorClients, enabling concurrent WebSocket usage and reusing existing connections.
DidcommMessage
Abstract base class for DIDComm messages.
DiscloseBody
Model for the body of a DIDComm Discover Features disclose message.
DiscloseMessage
A DIDComm v2 Discover Features disclose message.
Disclosure
Model for a DIDComm discover features disclosure.
EncryptedMessage
Represents a DIDComm v2 Encrypted Message as defined in the DIDComm Messaging specification.
EphemeralKey
Represents an ephemeral public key used in JWE (JSON Web Encryption) messages.
EpochSecondsConverter
A JsonConverter for encoding and decoding DateTime objects as epoch seconds (UTC).
ForwardMessage
Represents a DIDComm Routing Protocol 2.0 Forward message as defined in DIDComm Messaging Spec, Routing Protocol 2.0.
ForwardMessageOptions
Options for sending a forward message over a DIDComm mediator or next hop.
JweHeader
Represents the protected header of a JWE (JSON Web Encryption) message in DIDComm.
JweHeaderConverter
A JsonConverter for encoding and decoding JweHeader objects as base64url strings.
Jwk
Represents a JSON Web Key (JWK) as defined in RFC 7517. Supports EC, RSA, and octet sequence keys.
JwsHeader
Represents the protected header of a JWS (JSON Web Signature) message in a DIDComm signed message. It is integrity-protected - included in the signature.
JwsHeaderConverter
A JsonConverter for encoding and decoding JwsHeader objects as base64url strings.
LiveDeliveryChangeMessage
Represents a DIDComm Message Pickup 3.0 Live Delivery Change message as defined in DIDComm Messaging Spec, Message Pickup Protocol 3.0.
LiveDeliveryChangeMessageOptions
Options for sending a live delivery change message over a DIDComm mediator.
MediatorClient
Client for interacting with a DIDComm mediator, supporting message sending, inbox management, and real-time message delivery via WebSockets.
MessageOptions
Options for configuring protection and cryptographic algorithms for DIDComm messages.
OutOfBandMessage
Represents a DIDComm Out-of-Band 2.0 Invitation message as defined in DIDComm Messaging Spec, Out-of-Band Protocol 2.0.
OwnJsonProperties
Annotation to mark a class for custom JSON property collection.
PingMessage
Represents a DIDComm v2 Trust Ping message as defined in the trust-ping protocol.
PingResponseMessage
Represents a DIDComm v2 Trust Ping Response message as defined in the trust-ping protocol.
PlainTextMessage
Represents a DIDComm v2 Plain Text Message as defined in the DIDComm Messaging specification.
ProblemCode
Represents a DIDComm problem code, including sorter and scope.
ProblemCodeConverter
A JsonConverter for serializing and deserializing ProblemCode objects to and from strings.
ProblemReportBody
The body of a DIDComm problem report message, as defined by the DIDComm Messaging specification.
ProblemReportMessage
A DIDComm problem report message, as defined by the DIDComm Messaging specification.
Query
Model for a DIDComm discover features query.
QueryBody
Model for the body of a DIDComm Discover Features query message.
QueryMessage
A DIDComm v2 discover features query message.
Recipient
Represents a recipient in a JWE (JSON Web Encryption) message.
RecipientHeader
Represents the recipient header for a JWE recipient in DIDComm messages.
Scope
Scope information for a problem code.
Signature
Represents a JWS (JSON Web Signature) signature structure as used in DIDComm messages.
SignatureHeader
Represents the unprotected header for a JWS signature in DIDComm messages. It is not included in the signature, meaning it can be modified by intermediaries.
SignedMessage
Represents a DIDComm v2 Signed Message as defined in the DIDComm Messaging specification.
StatusRequestMessage
Represents a DIDComm Message Pickup 3.0 Status Request message as defined in DIDComm Messaging Spec, Message Pickup Protocol 3.0.
StatusRequestMessageOptions
Options for sending a status request message over a DIDComm mediator.
WebSocketOptions
Options for configuring WebSocket-based DIDComm message pickup interactions.

Enums

CurveType
Supported elliptic curve types for DIDComm cryptography.
DescriptorType
Descriptors for DIDComm problem reports as defined in the DIDComm Messaging spec.
DidDocumentServiceType
Enum representing supported service types in a DID Document.
EncryptionAlgorithm
Supported content encryption algorithms for DIDComm encryption as defined in DIDComm Messaging Spec, Curves and Content Encryption Algorithms.
KeyWrappingAlgorithm
Supported key wrapping algorithms for DIDComm encryption as defined in DIDComm Messaging Spec, Key Wrapping Algorithms.
MessageWrappingType
The type of message wrapping as defined by the DIDComm Messaging specification. See: https://identity.foundation/didcomm-messaging/spec/#iana-media-types Each variant describes a specific combination of message types and key wrapping algorithms.
ScopeType
Scope for DIDComm problem codes.
SorterType
Sorter for DIDComm problem codes.

Extensions

AffinidiAclManagementExtension on MediatorClient
Extension for MediatorClient to support Affinidi-specific ACL management.
AffinidiOobExtension on MediatorClient
Extension for MediatorClient to support OOB messages on a mediator.
BigIntExtension on BigInt
Extension methods for BigInt to support cryptographic byte conversions.
CurveTypeExtension on CurveType
Extension methods for CurveType to support mapping to a compatible KeyType.
DidDocumentExtension on DidDocument
Extension methods for DidDocument to support DIDComm-specific operations, such as extracting endpoints, creating transport clients, and key matching.
DidDocumentsExtension on List<DidDocument>
Extension methods for a list of DidDocuments to support finding common key types for key agreement.
DidManagerExtension on DidManager
Extension methods for DidManager to simplify key pair retrieval by DID key ID.
JwkExtension on Jwk
Extension methods for Jwk to support conversion to elliptic curve public keys.
KeyTypeExtension on KeyType
Extension methods for KeyType to support mapping to encryption-capable curves. ed25519 can't be used directly for encryption, so it maps to x25519. The other key types map directly to their respective curves.
ObjectExtension on Object
Extension methods for Object to support JSON representation to bytes.
PublicKeyExtension on PublicKey
Extension methods for ec.PublicKey to support byte conversion.
Uint8ListExtension on Uint8List
Extension methods for Uint8List to support cryptographic conversions.
VerificationMethodExtention on VerificationMethod
Extension methods for the VerificationMethod class, providing additional functionality and utilities related to verification methods in DIDComm.
VerificationMethodListExtention on List<VerificationMethod>
Extension methods for List<VerificationMethod> to support curve-based lookup.

Functions

base64DecodeToUtf8(String data) String
Decodes a base64 string (with or without padding) to a UTF-8 string.
base64UrlDecodeWithPadding(String data) Uint8List
Decodes a base64url string (with or without padding) to a Uint8List.
base64UrlEncodeNoPadding(List<int> bytes) String
Encodes bytes as a base64url string without padding.
extractPrivateKeyBytes(String pemPath) Future<Uint8List>
Extracts pem into bytes.
formatBytes(int bytes) String
Converts bytes int human readable version.
getDidFromId(String id) String
Extracts the DID from a DID ID.
getKeyIdFromId(String id) String
Extracts the key identifier from a given DID (Decentralized Identifier) string.
prettyPrint(String name, {Object? object}) → void
Pretty prints the object prefixed with its name.
readDid(String didPath) Future<String>
Reads DID from a file.
readDidDocument(String didDocumentPath) Future<DidDocument>
Reads DID document.
writeEnvironmentVariableToFileIfNeeded(String? environmentVariableName, String filePath, {bool decodeBase64 = false}) Future<void>
Writes environment variable into file, if it was not written there already.

Exceptions / Errors

IncompatibleEncryptionAlgorithmWithAuthcrypt
Thrown when A256GCM or XC20P is used with authcrypt (ECDH-1PU) which is not allowed by DIDComm specification.
MediatorClientException
Exception thrown by MediatorClient for errors during mediator operations.
NotFoundVerificationMethodByCurveError
Error thrown when no verification method with a matching curve is found for a recipient.
UnsupportedCurveError
Error thrown when an unsupported elliptic curve is encountered in DIDComm operations.
UnsupportedEncryptionAlgorithmError
Error thrown when an unsupported encryption algorithm is encountered in DIDComm operations.
UnsupportedKeyTypeError
Error thrown when an unsupported key type is encountered in DIDComm operations.
UnsupportedKeyWrappingAlgorithmError
Error thrown when an unsupported key wrapping algorithm is encountered in DIDComm operations.