halkyon/packages/halkyon_base_server/lib/base.dart
Tizian 「ティツィアーン」 d08d8ad545
feat(base,learn): spaces people share, kept by halkyon_base
ADR 0044, step 2 (D1, D2, D11, D13, and D15 to D17, decided today).
halkyon_base keeps the spaces several people share, for every app:
shared_space, its members with their roles (Owner, Editor, Viewer), and
invitations by handle waiting for someone with no account on the
service yet. The sharedSpace endpoint creates a space, lists its
members, invites by handle, changes roles, removes members, hands the
space on, leaves and deletes it.

Who may do what:
- Only people with an identity reach the endpoint.
- A space the caller isn't in can't be told from one that doesn't
  exist.
- Members are named by their membership, never by their account's ID.
- Only the Owner manages the members, unless the space lets members
  invite.
- The Owner's role passes only by handing the space on, and the Owner
  leaves only naming who takes it on.
- An invitation counts as an answer about a handle, as it tells whether
  one exists.
Every rule has a test asserting the refusal.

The module stays free of the sync engine: a host hands it a SpaceGrants,
and every call runs in the module's transaction, so the engine's grants
follow the roles or nothing changes. The Owner and an Editor write; a
Viewer reads. Learn hands over SyncSpaceGrants on OfflineSyncSpaces. Todo
hands over none yet, so its server refuses until its projects are
shared.

Deleting an account hands each space the person owns to the Editor who
joined first, else the Viewer who joined first. A space with no other
member goes. This runs before the host's own deletions. A person's first
sign-in on a service makes their waiting invitations memberships, in the
same transaction that makes them a person there.

Migrations: the module's and every host's (Learn, Todo, Train, Meditate)
create the three tables, their indexes and the two cascading foreign
keys to shared_space, and nothing else. The old server keeps working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-11 10:54:19 +01:00

137 lines
4.8 KiB
Dart

/// halkyon_base for a host's own code: its configuration
/// (`HalkyonBase.configure`), how people authenticate, the account's
/// deletion and the pruning, email sign-in's helpers, the instance's
/// basics, people's public profiles and their pages, the instance's register
/// (ADR 0016), signing in with a password and TOTP and getting back into an
/// account (ADR 0017), signing in with SimpleLogin and its forwarding page
/// (ADR 0020), the ways in an operator offers, the operator's assistants
/// (Halkyon Learn's ADR 0021), people's files (ADR 0043), the spaces people
/// share (ADR 0044), and the module's models.
library;
export 'src/admission/admission.dart'
show
forgetUnapprovedSignUps,
maxWaitingPasses,
maxWaitingSignUps,
unapprovedSignUpLifetime,
waitingPassLifetime;
export 'src/admission/sign_up_config.dart';
export 'src/assistant/assistant_conversation.dart'
show
assistantImageMaxBytes,
assistantQuestionMaxCharacters,
assistantQuestionMaxImages;
export 'src/assistant/assistant_forwarding.dart'
show assistantUsageCounted, maxQuestionsAtOnce, useLlmClient;
export 'src/assistant/assistant_grants.dart'
show assistantFiguresMonths, forgetOldAssistantFigures;
export 'src/assistant/assistants_config.dart';
export 'src/auth/account.dart';
export 'src/auth/auth_config.dart';
export 'src/auth/code_mail.dart';
export 'src/auth/email.dart';
export 'src/auth/identified.dart';
export 'src/auth/offered_ways.dart';
export 'src/auth/scopes.dart';
export 'src/common/network.dart';
export 'src/common/short_code.dart';
export 'src/files/file_limits.dart'
show FileLimits, Room, checkRoom, effectiveLimit, fileLimits, roomOf;
export 'src/files/file_pruning.dart'
show filePruningGrace, pruneUnreferencedFiles;
export 'src/files/file_store.dart';
export 'src/files/stored_files.dart'
show
downloadFile,
fileStoreOf,
fileUsageOf,
finishFileUpload,
startFileUpload;
export 'src/generated/protocol.dart' hide Protocol;
export 'src/halkyon_base.dart';
export 'src/instance/data_location.dart';
export 'src/instance/privacy_page.dart' show addPrivacyPageRoute, privacyPage;
export 'src/instance/source_code.dart';
export 'src/password/account_resets.dart'
show forgetLapsedResets, resetDelay, resetLapsesAfter;
export 'src/password/authenticators.dart'
show
forgetUnconfirmedAuthenticators,
maxAuthenticators,
unconfirmedAuthenticatorLifetime;
export 'src/password/key_proof.dart'
show
KeyProofPurpose,
PasswordProofPurpose,
authenticatorDigest,
canonicalInstanceUrl,
isAccountSignature,
keyProofMessage,
mendLinkDigest,
newKeysPasswordDigest,
newPasswordDigest,
newPhraseDigest,
passwordIdentity,
proofKeyDigest,
publicInstanceUrlOf;
export 'src/password/password_config.dart';
export 'src/password/passwords.dart'
show
isKeysPassword,
isKeysSetup,
isNewPassword,
isPasswordSetup,
newPasswordCosts,
passwordGroup,
passwordMethod,
signInChallengeLifetime,
signsInWithPassword,
wrappedKeysLength;
export 'src/profile/handle_checks.dart';
export 'src/profile/link_verification.dart';
export 'src/profile/profile_page.dart' show addProfilePageRoute, profilePage;
export 'src/profile/profile_rules.dart'
show
accountDomain,
avatarPath,
avatarStorage,
isHandle,
maxAvatarBytes,
operatorAccountDomain,
profilePageUrl,
reservedHandles;
export 'src/profile/profiles.dart';
export 'src/register/account_register.dart';
export 'src/register/accounts_mode.dart';
export 'src/register/deletion_notices.dart'
show MemberNotifier, deliverDeletionNotices;
export 'src/register/instance_routes.dart';
export 'src/register/member_pruning.dart';
export 'src/register/people.dart' show issueSession;
export 'src/register/sessions_ended.dart'
show AccountSessionsEnded, deliverSessionNotices;
export 'src/shared_space/space_grants.dart';
export 'src/simplelogin/handle_suggestion.dart'
show handleFromName, handlesToTry, suggestable;
export 'src/simplelogin/simplelogin.dart' show forgetUnfinishedSimpleLogins;
export 'src/simplelogin/simplelogin_callback.dart'
show
addSimpleLoginCallbackRoute,
simpleLoginCallbackPath,
simpleLoginReturns;
export 'src/simplelogin/simplelogin_config.dart';
export 'src/srp/srp_group.dart';
export 'src/srp/srp_math.dart' show numberOf, padded;
export 'src/srp/srp_server.dart'
show
SrpAccepted,
SrpChallenge,
SrpRefusal,
SrpRefused,
SrpVerification,
srpChallenge,
srpVerify;
export 'src/totp/base32.dart';
export 'src/totp/recovery_codes.dart';
export 'src/totp/totp.dart';