Core

The core package implementing the Control Plane and Mediator SDK, including managing multiple digital identities for better privacy and anonymity in digital interactions.

Install Dependency

Package: meeting_place_core

dart pub add meeting_place_core

Check the latest version on the pub.dev registry or view the source on GitHub.

Classes and Methods

MeetingPlaceCoreSDK

The MeetingPlaceCoreSDK is the main orchestrator for the Affinidi Meeting Place ecosystem, providing a high-level interface for connection setup, discovery, and secure decentralised communications through control plane and mediator services.

create

A static method that creates an instance of CoreSDK. For each connection, it requires the creation of an instance of CoreSDK.

Parameters

wallet Wallet Required

A digital wallet to manage cryptographic keys supporting different algorithms for signing and verifying VC and VP.

This requires the installation of the SSI package from pub.dev.

repositoryConfig RepositoryConfig Required
A repository object which defines the storage, group, key and channel repository objects.
config Config Required
Configuration object containing the required DID endpoints. Pass mediatorDid (the mediator DID including the .well-known path) and controlPlaneDid (the control plane DID) inside this object.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final wallet = Bip32Wallet.fromSeed(aliceSeed);
final storage = InMemoryStorage();

final mediatorDid = '<YOUR-MEDIATOR-DID>:.well-known';
final controlPlaneDid = '<YOUR-CONTROL-PLANE-DID>';

final sdk = await MeetingPlaceCoreSDK.create(
    wallet: wallet,
    repositoryConfig: RepositoryConfig(
        connectionOfferRepository: ConnectionOfferRepositoryImpl(storage: storage),
        groupRepository: GroupRepositoryImpl(storage: storage),
        channelRepository: ChannelRepositoryImpl(storage: storage),
        keyRepository: KeyRepositoryImpl(storage: storage),
    ),
    config: Config(
        mediatorDid: mediatorDid,
        controlPlaneDid: controlPlaneDid,
    ),
  );

generateDid

An instance method that generates a new DID using the provided [Wallet] instance.

Parameters

No parameters required.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final sdk = await MeetingPlaceCoreSDK.create(
    wallet: wallet,
    ...
);

final did = await sdk.generateDid();

createOobFlow

An instance method that creates an Out-Of-Band invitation for an entity.

Parameters

contactCard ContactCard Required
An object that contains information about who is creating the invitation. This helps others know whom they are connecting with.
type String Optional
Optional channel type identifier.
mediatorDid String Optional
Optional mediator DID override. Defaults to the SDK instance’s configured mediator DID.
externalRef String Optional
Optional application-specific reference stored locally for tracking purposes.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    wallet: wallet,
    ...
);

final createOobFlowResult = await aliceSDK.createOobFlow(
    contactCard: ContactCard(values: {
      'n': {'given': 'Alice'},
    }),
);

acceptOobFlow

An instance method that accepts an Out-Of-Band invitation created by an entity. This is typically used by the party receiving the invitation to establish a connection.

Parameters

oobUrl Uri Required
The OOB invitation URL created by createOobFlow.
contactCard ContactCard Required
An object that contains information about who is accepting the invitation.
type String Optional
Optional channel type identifier.
externalRef String Optional
Optional application-specific reference stored locally for tracking purposes.
attachments List<Attachment> Optional
Optional list of attachments (for example, R-Card credentials) to include in the acceptance message.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final bobSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final createOobFlowResult = await aliceSDK.createOobFlow(
    contactCard: ContactCard(values: {
      'n': {'given': 'Alice'},
    }),
);

await bobSDK.acceptOobFlow(
    createOobFlowResult.oobUrl,
    contactCard: ContactCard(values: {
      'n': {'given': 'Bob'},
    }),
);

validateOfferPhrase

An instance method that validates whether a given offer phrase is already in use within the system. This returns a response with an isAvailable flag that shows whether the offer phrase is available or already in use.

Parameters

phrase string Required
The offer phrase to be checked for availability.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final offerPhraseResult = await aliceSDK.validateOfferPhrase('<OFFER-ID>');

registerForPushNotifications

An instance method that registers the device for push notifications using the provided deviceToken from the OS-native push notification service, which will be used to notify the device about events in the Meeting Place flow and automatically included in subsequent API calls.

Parameters

deviceToken string Required
The device token obtained from the operating system’s native push notification service.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final deviceInstance = aliceSDK.registerForPushNotifications('<DEVICE-TOKEN>');

registerForDIDCommNotifications

An instance method that registers the device for push notifications using the provided deviceToken from the OS-native push notification service, which will be used to notify the device about events in the Meeting Place flow and automatically included in subsequent API calls.

Parameters

No parameters required.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final registerForDidcommNotificationsResult = aliceSDK.registerForDIDCommNotifications();

publishOffer

An instance method that publishes an offer on MeetingPlace. This method allows a user to create and share an offer that others can discover and connect with.

Parameters

offerName string Required
The name of your offer as it will be displayed when others search for offers.
contactCard ContactCard Required
An object that contains information about who is publishing the offer. This helps others know whom they are connecting with.
offerDescription string Required
A description of the offer displayed to others who discover it.
type SDKConnectionOfferType Required
The offer type. Use SDKConnectionOfferType.meetingPlaceInvitation for a personal offer or SDKConnectionOfferType.groupInvitation for a group offer.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final publishOfferResult = await aliceSDK.publishOffer(
    offerName: 'SDK Offer',
    offerDescription: 'Connect with Alice on Meeting Place.',
    type: SDKConnectionOfferType.meetingPlaceInvitation,
    contactCard: ContactCard(values: {
      'n': {'given': 'Alice'},
    }),
);

findOffer

An instance method that finds an offer published by another party using a unique mnemonic identifier.

Parameters

mnemonic string Required
The unique mnemonic identifier used to search for the offer.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final bobSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final menmonic = '<ALICE-OFFER>';
final offerResult = await bobSDK.findOffer(mnemonic);

acceptOffer

An instance method that accepts a connection offer published by another party. This method allows a user to respond to an offer and establish a connection request.

Parameters

connectionOffer Object Required
A connection offer object.
contactCard ContactCard Required
An object that contains information about who is accepting the offer. This helps the offeree know who accepted.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final bobSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final menmonic = '<ALICE-OFFER>';
final offerResult = await bobSDK.findOffer(mnemonic);

final offerAcceptedResult = await bobSDK.acceptOffer(
    connectionOffer: offerResult.connectionOffer!,
    contactCard: ContactCard(values: {
      'n': {'given': 'Bob'},
    }),
);

notifyAcceptance

An instance method that notifies the owner of the offer about the acceptance of their connection offer.

Parameters

connectionOffer Object Required
ConnectionOffer object in the ‘accepted’ state.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final bobSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final menmonic = '<ALICE-OFFER>';
final offerResult = await bobSDK.findOffer(mnemonic);

final offerAcceptedResult = await bobSDK.acceptOffer(
    connectionOffer: offerResult.connectionOffer!,
    contactCard: ContactCard(values: {
      'n': {'given': 'Bob'},
    }),
);

await bobSDK.notifyAcceptance(
    connectionOffer: offerAcceptedResult.connectionOffer,
);

approveConnectionRequest

An instance method to allow the owner of the offer to approve a connection request.

Parameters

connectionOffer Object Required
[GroupConnectionOffer] object for group.
channel Object Required
Channel object.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

aliceSDK.discoveryEventsStream.listen((event) async {
    if (event.type.name == DiscoveryEventType.InvitationAccept.name) {
        await aliceSDK.approveConnectionRequest(
            connectionOffer: publishOfferResult.connectionOffer,
            channel: event.channel,
        );
    }
});

rejectConnectionRequest

An instance method to allow the owner of the offer to reject a connection request.

Parameters

channel Object Required
Channel object.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final channel = await aliceSDK.getChannelByDid(
    message.data['memberDid'] as String,
);

if (channel == null) {
    throw Exception('Channel does not exist');
}

await aliceSDK.rejectConnectionRequest(channel);

leaveChannel

An instance method that allows a member to leave a channel. Depending on type of channel, it applies business logic to groups or individual channels.

Parameters

groupId string Required
The Group ID.
memberDid string Required
The member’s DID.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final groupId = '<GROUP-ID>';
final memberDid = 'did:peer:.....';

await aliceSDK.leaveGroup(groupId, memberDid);

sendMessage

An instance method that encrypts and signs the message using the sender’s DID, then sends it to recipientDidDocument via DIDComm.

Parameters

message object Required
The DIDComm plain text message.
senderDid string Required
The DID used to send messages.
recipientDid string Required
The DID of recipient.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final bobSDK = await MeetingPlaceCoreSDK.create(
    ...
);

bobSDK.sendMessage(
    message,
    senderDid: senderDid,
    recipientDid: recipientDid,
);

queueMessage

An instance method that queues the message to be sent via DIDComm.

Parameters

message object Required
The DIDComm plain text message.
senderDid string Required
The DID used to send messages.
recipientDid string Required
The DID of recipient.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final bobSDK = await MeetingPlaceCoreSDK.create(
    ...
);

await bobSDK.queueMessage(
    message,
    senderDid: senderDid,
    recipientDid: recipientDid,
);

sendGroupMessage

An instance method that encrypts and signs the message using the sender’s DID, then sends it to a group message using a group’s DID as the recipient via DIDComm.

Parameters

message object Required
The DIDComm plain text message.
senderDid string Required
The DID used to send messages.
recipientDid string Required
The DID of recipient.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final bobSDK = await MeetingPlaceCoreSDK.create(
    ...
);

await bobSDK.sendGroupMessage(
    message,
    senderDid: senderDid,
    recipientDid: recipientDid,
);

sendOutreachInvitation

Sends a targeted invitation to participants of an existing connection offer, inviting them to join a different offer.

Parameters

outreachConnectionOffer ConnectionOffer Required
The outreach connection offer used to send the invitation.
ConnectionOffer ConnectionOffer Required
The connection offer to which the invitee is being invited to connect.
messageToInclude string Required
A custom message to include in the invitation.
senderInfo string Required
Information about the sender to be included in the invitation.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final bobSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final ConnectionOffer outreachOffer = /* existing offer with participants */;

final ConnectionOffer inviteToOffer = /* new offer you want to promote */;

await bobSDK.sendOutreachInvitation(
    outreachConnectionOffer: outreachOffer,
    inviteToConnectionOffer: inviteToOffer,
    messageToInclude: 'Hi! Connect with me on this new offer.',
    senderInfo: 'John',
);

processControlPlaneEvents

An instance method that fetches latest updates (notifications) from Control Plane API and handles each update event. This may need some time to happen. Therefore the function returns a stream that is going to receive a connection offer for each processed update event.

Parameters

No parameters required.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

// Listen to control plane events stream
aliceSDK.controlPlaneEventsStream.listen((event) {
    print('Event type: ${event.type}');
    if (event.channel != null) {
      print('Channel ID: ${event.channel!.id}');
      print('Channel status: ${event.channel!.status}');
    }
  });

// Process pending control plane events
await aliceSDK.processControlPlaneEvents(
    onDone: () {
      print('All control plane events processed successfully');
    },
);

disposeDiscoveryEventsStream

An instance method that closes the active discovery events stream.

Parameters

No parameters required.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

await aliceSDK.disposeDiscoveryEventsStream();

deleteDiscoveryEvents

An instance method that deletes all pending discovery events.

Parameters

No parameters required.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

await aliceSDK.deleteDiscoveryEvents();

fetchMessages

An instance method that retrieves available messages from the specified mediator instance mediatorDid. By setting deleteOnRetrieve to true, retrieved messages can be automatically deleted. The method takes care of checking message signatures and decrypts the messages if necessary.

Parameters

did string Required
DID used to fetch messages from mediator.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

await aliceSDK.fetchMessages('did:peer:.....');

subscribeToMediator

An instance method that allows the MeetingPlaceCoreSDK instance to subscribe to incoming messages from the mediator.

Parameters

did string Required
DID used to fetch messages from mediator.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

await aliceSDK.subscribeToMediator('did:peer:.....');

getConnectionOffer

An instance method that returns the connection offer identified by offerLink from storage.

Parameters

offerLink string Required
The ID of the offer.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final offerLink = '<OFFER-LINK>';

await aliceSDK.getConnectionOffer(offerLink);

markConnectionOfferAsDeleted

An instance method that marks a connection offer as deleted — updates connection offer status to deleted. If the connection offer is already marked as deleted, the delete operation will be skipped.

Parameters

connectionOffer object Required
The ConnectionOffer instance.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final connectionOfferToBeDeleted = '<CONNECTION-OFFER>';

await aliceSDK.markConnectionOfferAsDeleted(connectionOfferToBeDeleted);

deleteConnectionOffer

An instance method that deletes a connection offer from storage.

Parameters

connectionOffer object Required
The ConnectionOffer instance.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final connectionOfferToBeDeleted = '<CONNECTION-OFFER>';

await aliceSDK.deleteConnectionOffer(connectionOfferToBeDeleted);

An instance method that returns the group identified by offerLink from storage.

Parameters

connectionOffer object Required
The ConnectionOffer instance.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final offerLink = '<OFFER-LINK>';

await aliceSDK.getGroupByOfferLink(offerLink);

getGroupById

An instance method that returns the group identified by groupId from storage.

Parameters

groupId string Required
The groupID.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final groupId = '<GROUP-ID>';

await aliceSDK.getGroupById(groupId);

updateGroup

An instance method that updates an existing group in the repository by using repository method updateGroup.

Parameters

group object Required
Specifies the channel entity to update.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final group = Group(
  id: '<GROUP-ID>',
  did: 'did:peer:...',
  offerLink: '<OFFER-LINK>',
  members: ['alice', 'bob'],
  created: DateTime.now()
);

await aliceSDK.updateGroup(group);

listConnectionOffers

An instance method that returns a list of all connection offers from the repository by using repository method listConnectionOffers.

Parameters

No parameters required.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

await aliceSDK.listConnectionOffers();

getChannelByDid

An instance method that fetches a channel entity from the repository by using repository method getChannelByDid.

Parameters

did string Required
The DID to match the channel either by permanentChannelDid or otherPartyPermanentChannelDid.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

await aliceSDK.getChannelByDid('did:peer:...');

getChannelByOtherPartyPermanentDid

An instance method that fetches a channel entity from the repository by using repository method findChannelByOtherPartyPermanentChannelDid.

Parameters

did string Required
The DID to match the channel either by permanentChannelDid or otherPartyPermanentChannelDid.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

await aliceSDK.getChannelByOtherPartyPermanentDid('did:peer:...');

updateChannel

An instance method that updates an existing channel in the repository.

Parameters

channel object Required
Specifies the channel entity to update.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final channel = new Channel({
    ...
});

await aliceSDK.updateChannel(channel);

getMediatorDidFromUrl

An instance method that fetches the mediator DID from the provided URL.

Parameters

mediatorEndpoint string Required
The mediator endpoint which returns the DID document of the mediator.

Example

import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:ssi/ssi.dart';
import 'storage/in_memory_storage.dart';

final aliceSDK = await MeetingPlaceCoreSDK.create(
    ...
);

final mediatorEndpoint = 'https://example.com/.well-known/did.json';

await aliceSDK.getMediatorDidFromUrl('<MEDIATOR-URL>');