Invitations mixin
Invitations between atSigns, including to someone who has no atSign yet.
The inviter creates an invitation, sends its link and its code out of band, and the invitee accepts once they have an atSign. Any of the inviter's clients can then process the acceptance, and every decision two clients could race on is an immutable create on the inviter's atServer, which refuses the second writer:
- an outcome per invitation — accepted, burned or revoked — so an invitation is decided once, whichever of those gets there first;
- an attempt slot per wrong code, so the count cannot lose an update; the wrong code after the last slot is the burn itself;
- a claim per acceptance that cannot decide the invitation, a wrong code or one that arrived after expiry, so it is counted once.
Each of these lives as long as the invitation's own record. The content key goes only to an atSign whose acceptance carries the code, whatever the outcome record says.
The app's own data travels as JSON: public details in the preview, the invitee's details in the acceptance, and private content encrypted under a fresh content key. The invitee holds the ciphertext before accepting, and the key is shared with them only once the inviter has verified their acceptance. Everything else the app keeps, contacts included, lives in the app's own collections, keyed by the invitation id.
Nothing here needs Flutter. An app or a CLI uses it through AtClientInvitations, and an always-on process, such as a CLI helper enrolled for the namespace, handles acceptances by calling processAcceptances on a timer or on acceptances events:
final invitations =
AtClientInvitations(atClient, invitationsNamespace: 'my_app');
final created = await invitations.invite(
publicDetails: {'from': 'Alice'}, content: {'recipe': 'lemon cake'});
// Send created.link and created.code separately.
- Mixin applications
- @experimental
Properties
-
acceptances
→ Future<
AtCollection< InvitationAcceptance> > -
Acceptances, each shared by an invitee with its inviter.
no setter
- atClient → AtClient
-
no setter
-
connections
→ Future<
AtCollection< InvitationConnection> > -
Confirmations, each shared by an inviter with the invitee it accepted.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- invitationsNamespace → String
-
The app namespace the invitation records live under.
no setter
- logger → AtSignLogger
-
no setter
- me → Atsign
-
no setter
-
receivedInvitations
→ Future<
AtCollection< ReceivedInvitation> > -
Invitations this atSign received. Only this atSign reads them.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sentInvitations
→ Future<
AtCollection< SentInvitation> > -
Invitations this atSign sent. Only this atSign reads them.
no setter
Methods
-
accept(
InvitationLink link, String code, {Map< String, dynamic> details = const {}, SealedInvitationContent? outOfBandContent}) → Future<void> -
Accepts an invitation with the
codeits inviter sent separately, sending the inviterdetailsof this atSign's choosing. -
decline(
String id) → Future< void> - Forgets an invitation, and withdraws this atSign's acceptance of it if there is one.
-
invite(
{Map< String, dynamic> publicDetails = const {}, Map<String, dynamic> ? content, bool contentOutOfBand = false, Duration expiresIn = const Duration(days: 7)}) → Future<CreatedInvitation> - Creates an invitation. The app links its own records, such as a contact, to it by the id in the returned link.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
preview(
InvitationLink link, {SealedInvitationContent? outOfBandContent}) → Future< CItem< ReceivedInvitation> > -
Fetches an invitation's preview and keeps it, with its content when the
content travels in the preview.
outOfBandContentis content that travelled some other way, e.g. in an email. It can arrive after the inviter has confirmed this atSign; processConnections then opens it. -
processAcceptances(
) → Future< List< ({CItem< >InvitationAcceptance> acceptance, InvitationOutcome outcome})> - Handles every acceptance of this atSign's pending invitations, and finishes any invitation a client decided but did not finish. Reports each acceptance it handled; one of an invitation already decided is not reported again.
-
processConnections(
) → Future< List< CItem< >ReceivedInvitation> > - Completes every invitation this atSign accepted whose inviter has confirmed it, decrypting any content, and returns those it completed. The app adds the inviter to its own contacts from these, or from any received invitation whose status is connected.
-
revoke(
String id) → Future< bool> - Cancels a pending invitation. Returns false when it had already been decided — accepted, burned or revoked.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- attemptLimit → const int
- Wrong codes allowed before an invitation is burned.