locality_social_cloud 2.3.0
locality_social_cloud: ^2.3.0 copied to clipboard
Write social apps with Flutter. This code connects to the backend of Locality Social Cloud to provide realtime state synchronization across devices.
locality_social_cloud #
Locality is there to fuel the development of serverless Social Apps with Flutter. Social Apps are fundamentally a technological reflection of real social interactions. In real social interactions, we interact through objective space that transports state changes at light speed. The challenge of creating objective spaces for multiple observers across many devices is fundamental. Traditionally, state management and business logic are performed on servers. This creates significant challenges when dealing with End-to-End-encrypted interactions. With Locality Social Cloud, you can create serverless Social Apps and model all your domains on the frontend. This allows for improved flexibility when building or updating features (no deployment) and allows you to develop Social Apps in a way where the problem modelling just fits the problem space more naturally.
Examples of this pattern #
For example, a chat you can view as just a distributed list of messages. All observers want to modify and see the same list of messages. The same way, a FriendList is just a distributed List of Friends. This has the advantage that the user can restore their FriendList on another device, even though it may be encrypted. A cryptocurrency you could see as a distributed Map, Key-Value-store, with an authoritative timeline; all observers want to modify and view the same map.
Build Social Networks and other collaborative or together-apps. #
Locality Social Cloud provides you with a PubSub mixin that allows you to publish to and receive events from addresses in realtime. You are provided with the guarantee, that each PubSub processes each event that was published to its address exactly once. This holds true, even if the user goes offline or loses connection; once he is online again, the state is seamlessly synchronized. In addition to this, Locality Social Cloud allows you to easily build End-to-End-Encryption; Each user has a public ECDH key and you have methods of generating a shared key and encrypting PubSubs with keys. On top of that, users can securely share keys accross devices and yield keys for end-to-end-encrypted topics, so that you can, for example, write encrypted group chats.
Available methods #
The Locality Social Cloud package bundles standard methods, while the locality_core packages leaves them away and is lean.
Import the LocalitySocialCloudInterface to access helper methods.
Chat & Messaging
static void setKeyCache(File cache)
static String getCommonTopicForUsers(PublicUser userA, PublicUser userB)
static Future<KeyExchangeLobby> getKeyExchangeLobby(String topic)
static Future<MessagingTopic> getSubscribedTopic(TopicSubscription subscription, ChatMessageFactory chatMessageFactory)
static Future<MessagingTopic> getGroupChat(GroupChatInvitation groupChatInvite, ChatMessageFactory chatMessageFactory)
static Future<MessagingSubscriptions> getUserMessageTopicSubscriptions({required AuthenticatedSessionUser user, String? subTopic, ChaCha20Key? chaChaKey})
static Future<MessagingTopic> getUserChat(AuthenticatedSessionUser loggedInUser, PublicUser publicUser, ChatMessageFactory chatMessageFactory)
Calendar Subsystem
static Future<CloudCalendar> getPublicCalendarOf(AuthenticatedSessionUser authenticatedSessionUser, {ChaCha20Key? chaChaKey, String? shardKey})
static Future<CloudCalendar> getPrivateCalendarOf(AuthenticatedSessionUser authenticatedSessionUser, {ChaCha20Key? chaChaKey, String? shardKey})
static Future<CloudCalendar> getVenueCalendarOf(String venueId, {ChaCha20Key? chaChaKey, String? shardKey})
static Future<CloudCalendar> getArtistCalendarOf(String artistId, {ChaCha20Key? chaChaKey, String? shardKey})
Friend List Subsystem
static Future<FriendList> getFriendListOfUser(PublicUser receivingUser)
static String getTopicOfFriendListOfUser(String userId)
static Future<void> sendFriendRequest(PublicUser fromUser, PublicUser toUser)
Project Setup #
Create a developer account for your company #
Check the Locality Core package to understand how to create developer credentials and use this in production. Check out the Locality Social Cloud Test System for a full documentation of the cloud.
Add the locality_social_cloud library to Flutter #
Write
flutter pub add locality_social_cloud
flutter pub get
to add the Locality Social Cloud to your Flutter App.
Configure Locality Social Cloud #
For testing purposes, you can use the public test realm
realmId: "ptr2",
realmSecret: "h3w1uzXhmHc4JvZi6ZE6bGXlPPISH/t26Pb6vtGzffE=",
or create your own realm at https://localitysocial.cloud. It is possible to license the backend. Furthermore you can obtain physical servers running the Locality Social Cloud at https://localitysocial.store. These servers are optimized for low energy cost. Your servers can be connected into a distributed system. This allows you to upscale your operations.