A .NET MAUI messaging app for an AA intergroup. The server side is the Fellowship WordPress plugin, which holds the messages and pushes them.
Android today. iOS is designed for and not built — see What is not done.
A member installs Link, signs in with the email address their intergroup already holds, and can message individual members and — where the intergroup allows it — whole committees. Messages arrive as push notifications, and the handset keeps its own clearable copy.
The two things worth knowing before reading any code:
Recipients are picked, never typed. The directory Fellowship sends is anonymous names and opaque member ids. No email addresses, no telephone numbers. Link sends ids back and the server does the addressing — so a stolen handset yields a list of first names rather than the intergroup's contact database, and a message cannot be addressed to a non-member by inventing an address.
Nothing readable crosses Google. The notification tray shows the sender's name and "New message". That is all it ever shows, because that is all the app puts there.
On first attach Link generates an RSA-2048 keypair in the platform keystore. The public half goes to Fellowship at enrolment; the private half stays on the handset, unless the member makes a backup, which carries it sealed under their passphrase. Everything the server sends this device is sealed to that key.
Fellowship can still read your messages — bodies are stored in plain text server-side, which is what makes committee broadcasts, the message log and GDPR audit possible. This is not end-to-end encryption and must not be described as such. What the server does not hold is any handset's private key, so a payload it sealed and pushed yesterday is one it cannot open today.
Two fields arrive, by push or by poll:
| Field | What |
|---|---|
k |
A fresh 32-byte AES content key, RSA-OAEP to this device, base64 |
p |
The payload, gzipped then AES-256-GCM: 12-byte nonce, 16-byte tag, ciphertext, base64 |
RSA-2048 with OAEP encrypts 214 bytes — less than a paragraph — so the scheme is hybrid. A fresh content key per message is not caution for its own sake: GCM fails catastrophically if a key and nonce are ever reused, and the surest way never to reuse one is never to keep one.
OAEP uses SHA-1, deliberately. PHP's openssl_public_encrypt() with
OPENSSL_PKCS1_OAEP_PADDING uses SHA-1 for the OAEP hash and MGF1, with
no way to request SHA-256 through the API PHP exposes.
MessagePayloadCipher matches it with RSAEncryptionPadding.OaepSHA1.
SHA-1's collision weakness is a signature problem; OAEP relies on
preimage resistance, which is intact. Changing that one line to
OaepSHA256 without changing the server produces a message that arrives
on a phone and silently will not open.
The gzip is not tidiness — sealing and base64'ing the largest payload the server will accept overflows FCM's 4KB limit without it.
The format is written out twice on purpose, and each side's test does
the other side's job. Sealing.cs here is Fellowship's PHP sealer
transcribed into C#, and MessagePayloadCipherTests opens what it
produces with the shipping cipher. On the server, MessageSealerTest
opens an envelope in PHP the way this app opens one. Drift on either
side turns the test on the opposite side red.
No fixture is committed, and that is deliberate: a fixture would have to carry the private key that opens it, and a private key in a public repository is what push protection blocks and Semgrep flags.
Link.Specs carries its own copy of the sealer, and that is unavoidable
rather than sloppy: Sealing.cs is internal to a test project, and
nothing can reference a test project. Do not merge the two into a shared
one — the copies are lean on purpose, and the thing being protected here
is that neither of them seals by calling the code under test.
Every message is stored by Fellowship before any push is attempted, and
Link polls as well as listening. A phone in a tunnel catches up when it
surfaces; a handset whose FCM token silently rotated still gets its
messages; a build with no google-services.json — CI's, for instance —
gets all of them, just later.
MessageService.SyncAsync asks for everything above the highest id a
poll has collected, and a push does not move that, so nothing is skipped
because a push was dropped, delayed by Doze, or sent to a token that has
moved on — even when a later message's push got through first. Fellowship
pages the inbox oldest first and says whether there is more, so a handset
that has been away walks forward through all of it, up to ten pages per
sync. Until 2026-10-03 both went the other way, and each lost messages: the
poll started from the highest id held, which a push raised, and the inbox
was paged newest first. A push and a poll produce the same
envelope and go through the same code, so how a message arrived is not
something the rest of the app has to know.
The message list is drawn from the local history first and synced afterwards, so the app opens instantly, works offline, and does not blank itself when a poll fails. A message that arrives by push while the list is on screen redraws it, which it did not originally — the notification appeared, the message was stored, and the list went on saying "No messages yet" until the page was navigated away from and back.
The token is re-registered at every launch, and that backstop is not
decoration. Enrolment sends whatever token Firebase has issued by then
and proceeds happily without one, because a handset with no Play Services
must still be able to enrol and poll. Nothing afterwards ever sent it:
OnNewToken fires on rotation, and a handset whose token simply was
not ready at enrolment never heard from it. That handset stayed poll-only
permanently while looking perfectly healthy from both ends — enrolled in
Fellowship's device list, collecting its messages, just always a poll
interval late. App.OnStart now calls DeviceAuthService.RestoreAsync,
which sends the current token unconditionally rather than trying to guess
what the server last stored.
The message list is one list of conversations, not an Inbox and a Sent list. A conversation is a message that answers nothing, plus every later message that answers it, whether received or sent. Replies to replies sit one level deep under the first message, oldest first. The conversation with the newest activity is at the top, and opening one shows every message in full, in the message view's own style.
It is derived from reply_to and from nothing else, and never
stored. A forward is sent answering nothing on purpose, so it starts
a new conversation. A reply whose original is not on this phone (it was
cleared, swept, or sent from another handset) stands alone until the
original turns up. The message view says "You replied" when this
phone has answered it.
Sent replies have kept their reply_to on the phone only since this
landed. Anything sent before then was stored without it, so it shows as
its own conversation. Conversations.feature is the specification.
A sent message carries WhatsApp's ticks, because most members already read them without thinking: one grey tick is sent, two grey ticks are on every recipient's phone, two blue ticks are read by every recipient. For a committee the opened message says how many — "Read by 2 of 5" — which the ticks cannot.
Received means a phone opened it, not that Fellowship stored it. Every
sync tells Fellowship which held messages it has not yet acknowledged
(POST /messages/received), whichever route brought them: a push handler has
no session token, and a fetch is not an opening — a pushed message is polled
again only once the poll reaches it, which may be long after. A message that
will not open is never held, so it is never acknowledged. Reading a message
counts as receiving it, so a lost acknowledgement does not leave its sender
on one tick.
The phone keeps its own copy of what it sent, at the moment of sending,
in the same encrypted history file — so it is cleared, reset and adopted with
the inbox. Fellowship is only asked for counts afterwards
(GET /messages/receipts), and only about messages not yet read by everyone.
A message sent from another handset does not appear among this one's conversations.
Both routes need Fellowship 1.10 or later. Against an older one the ticks stay at one and the sync carries on regardless.
When a member signs in to Link for the first time, every other signed-in phone gets a card at the top of the message list: "Sue B has joined Link." Tap it twice to open Compose addressed to them, with "Welcome" as the subject and "Welcome to Link, Sue!" as the body, both changeable. Swipe it left or right to clear it without a welcome. Either way the card is gone from that phone, and only that phone.
Joining is a member's first phone, recorded by Fellowship's Functions in
fellows/{memberId} in the same transaction as the enrolment. A second
phone, a takeover or a new key isn't joining, and a member whose phones
predate the record isn't greeted as new. The Functions push
{ t: 'joined', m: <member id> } to every other live phone; the notification
names them if this phone already has their name, and otherwise says somebody
new has joined. No name goes through Google: each phone names them from its
own directory.
As with device changes, push is the fast path. Welcomes reads the record at
every sync, so a phone the push missed still shows the card. It shows nobody who joined more than 30 days ago,
nobody from before this phone first looked (less a day, so a join pushed
just before an update still shows), not the member themself, and nobody the
directory doesn't list. What was cleared is kept in Preferences, keyed to
this Firebase device, so a new sign-in on the phone starts fresh. The rules
are in Welcomes.feature.
The double tap is a gesture TalkBack and VoiceOver can't make: to them a double tap is a single activation. A member using a screen reader can still write to the new member from Compose.
JsonMessageHistory keeps one AES-256-GCM encrypted file. One file
rather than a database: it holds a few hundred short messages, it is read
whole, and a database file is awkward to encrypt as a unit.
Clearing is honest about what it does. It deletes this handset's copies. It does not unsend anything, other people still have theirs, and recent messages come back on the next sync. The confirmation dialog says so, because "clear history" reads to most people as "delete the messages".
A file that will not decrypt reads as no history, never as an error. A messaging app that will not start because its cache will not decrypt is a far worse outcome than one that has lost its cache.
Removing the phone clears the history too, and that is not optional: taking a handed-on phone off the list has to mean the messages are gone from it. Without fingerprint sign-in, that is what Sign out does.
Settings has two actions under Messages on this phone: Back up messages
and Restore from a backup. A backup is one file,
link-backup-<date>.linkbackup, saved through the phone's share sheet and
chosen again with its file picker. It holds the history (messages, sent copies,
deleted ids, and the clear and poll marks), the style and switches, and which
device this phone is, with its private key.
What the member is told, because each of these is easy to get wrong. A
backup is a copy of their messages outside Link. Clearing messages, signing out
and Remove this phone do not touch it. The intergroup cannot delete it either,
so an erasure request cannot reach it. A forgotten passphrase means the backup
cannot be opened, and nobody can recover it. Settings says all of this before a
file is made, in MessageBackup's words.
Nothing in it signs in. It holds no token, so
android:allowBackup="false" stays, for the reason written in the manifest. It
does hold the phone's private key, which opens messages and proves nothing, and
Settings says so before a file is made. So the passphrase is what stands between
somebody holding the file and that key. A test holds the file's property names to
an exact list, so a new one goes in on purpose or not at all. Fingerprint sign-in
is left out too: only a finger this phone has matched turns it on.
AES-256-GCM over gzipped JSON, using only what .NET provides. All numbers are big-endian:
| Offset | Size | What |
|---|---|---|
| 0 | 4 | LKBK |
| 4 | 2 | Format version, 2 |
| 6 | 4 | PBKDF2-SHA256 iterations, 600,000 |
| 10 | 16 | Salt, random |
| 26 | 12 | Nonce, random |
| 38 | 16 | GCM tag |
| 54 | n | Ciphertext |
The first 38 bytes are the header, and the header is GCM's additional authenticated data, so changing any of it stops the file opening. The iteration count is read before anything can be authenticated, so a file asking for fewer than this build writes, or for more than 10 million, is refused without deriving a key. The passphrase is at least 12 characters, typed twice and never stored. It is trimmed, because a phone keyboard adds a space after a suggested word, and composed to NFC, because iOS and Android can spell the same accented letter as different bytes.
A wrong passphrase and a damaged file get one message, because GCM cannot tell them apart. A backup from a later version of Link gets it too, and the message says so.
BackupFile is the format and takes bytes and a passphrase. MessageBackup is
the rules. Both are in Link.Core and tested there. IBackupFiles is the app's
seam over the sheet and the picker, with a half per head. BackupFileTests reads
the layout again without calling the shipping code, and
Fixtures/backup-v1.linkbackup is a version 1 file committed so that every later
version has to go on restoring it. Version 2 has the same layout and adds the
device to the JSON. A version 1 file has no device, so it restores the messages
and the phone joins as new. The sealer has no fixture because one would have to
carry a private key. This one holds test messages and no key.
Moving phones? Restore from a backup on the sign-in screen opens the file and holds it until the member signs in. That sign-in takes the old phone's place:
- The
takeOverDeviceFunction checks the sign-in, that the device is this member's and still live, and that its public key matches the backup's. - The old phone is cut off at once, even with a token that hasn't expired, and the device moves to this phone with its id, key and inbox.
- Link keeps the backup's key, saves the session, joins the history, and the first sync starts from the backup's mark, so what arrived since then still comes.
If it can't take over, this phone enrols as new with the same sign-in, and the messages are restored anyway. That covers a backup from before a key replacement, a device an admin revoked or the member signed out, and another member's file, which is then refused. A refusal leaves the sign-in unspent because an Apple or Google credential can't be presented twice. Not being a member, or no network, stops the sign-in instead.
Restoring in Settings moves nothing. A phone already signed in gets the messages and keeps its own device and key, and if the file came from another phone Link says that phone stays signed in.
Restoring always ends with a sign-in, and a backup from another member is refused. The session is checked first and the store's own owner after it, and a refusal changes nothing. Then the two sides are joined:
- Messages join by id. Read on either side is read, and a sent copy keeps the higher receipt counts.
- Anything deleted on either side stays gone. The deleted ids of both are kept, so a later copy is refused too.
- Anything cleared on either side stays gone. Each side's clear mark applies to the other side's messages. It does not apply to its own: a message that side holds below its own mark arrived late, by push, and survived that clear.
- The poll mark takes the higher of the two. Everything below it on the backup's phone is either in the backup or was removed by the member.
So clearing a phone and then restoring brings nothing back, and Link says so. What signing out took does come back, because the member did not choose that.
Sent copies have a clear mark of their own, SentClearedUpTo. The other mark
is where the next poll starts, and stops at the highest message received on
purpose: a sent id can sit above messages to this member that no poll has
collected yet, and raising the poll past them would lose them. Without a second
mark, a clear left nothing to say a sent copy above it had been cleared, and a
backup from before the clear brought it straight back.
Whether the file was saved. Neither platform's share sheet says what happened after it opened, and on Android the call returns as soon as it has. So Settings says "Last backup made on", and a member who closes the sheet has no backup and a date that suggests otherwise. There are no scheduled reminders.
The sealed file stays in the app's private cache until the next backup, or until the phone clears its cache, because Android's sheet returns before the receiving app has read it. Remove this phone does not reach it. It is the same ciphertext as the member's own copy, and it needs the same passphrase.
The finger guards the screen, not the file. Fingerprint sign-in is asked for before a backup, against somebody picking up an unlocked phone, but the switch can be turned off in Settings without a finger. Nothing about the file depends on it: that is the passphrase.
Once the first sign-in has enrolled the phone, Link raises the phone's own fingerprint sheet (Face ID or Touch ID on an iPhone) to set fingerprint sign-in up. A phone with no fingerprint set up is never asked, and a member who closes the sheet can turn it on later in Settings.
With it on, Sign out locks rather than removes. The enrolment, the keypair and the history all stay, messages keep arriving (the tray still shows only the sender and "New message"), and the next time Link opens it shows a fingerprint page instead of the message list. A matched finger is the whole way back in. Settings then offers Remove this phone as well, which is the old sign-out: the device row is revoked, the key and the history go, and fingerprint sign-in is turned off.
What the fingerprint guards is this app's screens, against somebody who
picks up a phone its member has signed out of. It unlocks no key and proves
nothing to Fellowship, and the device token sits in SecureStorage either
way. It is set up only on a phone that reads a strong biometric, and when
the finger is not taken the same sheet falls back to the phone's own
screen lock (PIN, pattern, password or passcode). That fallback also lets
a member in whose fingerprints have been deleted since. On Android 9 and 10
the sheet accepts weak biometrics too, because Android cannot offer a strong
biometric and the code together there. A member who can give neither uses
Sign in another way, which removes the phone first and then shows the
usual sign-in, so one phone never has two live rows. FingerprintSignIn in Link.Core holds the rules and
FingerprintSignInTests covers them. The sheet itself is
FingerprintReader, with one half per head, and OnDevice.feature lists
what can only be checked on a phone.
Platforms invalidate keystore entries for reasons that have nothing to do with this app — a restored backup, a changed screen lock, re-enrolled biometrics. Fellowship cannot see it: from the server a handset with a lost private key looks perfectly healthy right up until a message it cannot read.
So Link reports it (POST /auth/device/key-fault), the message list
shows a banner, the intergroup's Devices screen shows the handset in red,
and Settings generates a new keypair and presents the public half. The
device row survives, so nobody has to re-enrol.
And then they come back, which this file claimed the opposite of until 2026-09-12. The reasoning was that the messages were sealed to a public key whose private half no longer exists, and Fellowship never held that half, so nobody can re-seal them.
The second step does not follow. Fellowship is not storing sealed
messages. It stores the bodies in plain text and seals them per fetch,
to whichever key the asking device presents — MessageController::inbox
calls seal(payloadFor($message), $device->publicKey) on every poll. So
once the new key is presented, the next sync re-delivers everything still
inside the retention window.
What is genuinely lost is narrower, and worth stating in its place: what
the server has already swept past retention_days, and any push that was
sealed and sent before the key changed, because nothing re-sends a push.
Which means the handset keypair protects the wire and the notification tray, and protects nothing in the database. That is a reasonable thing for it to do, and it is not what this file used to imply.
| Project | What |
|---|---|
…Link |
The MAUI app: views, view models, and everything that touches the platform. Android head only. |
…Link.Core |
Plain net10.0. Wire models, the REST client, the cipher, the history, the sync loop. |
…Link.Tests |
xUnit v3 over Link.Core — the edges. |
…Link.Specs |
Reqnroll over Link.Core — the behaviour, in the words this file uses for it. |
Core exists because a test project cannot reference a MAUI app. The
app's target framework is net10.0-android; a net10.0 test host has no
compatible framework to resolve against, and there is no such thing as a
net10.0 head of a MAUI app. So the testable code has to live somewhere
a test project can see it. Hand reached the same arrangement for the same
reason.
The line is not stylistic: the moment a file references Preferences,
SecureStorage, FileSystem or MainThread, it
stops compiling in Core. That constraint is why the cipher takes a PEM
string, the history takes a path and a key, and the client takes an
HttpClient — each of those seams exists so a test can drive it.
LinkServices builds the object graph once for both the app and the
Android push service, which runs with no MAUI host at all. Registering
fresh instances in MauiProgram instead would give the app a second
history over the same file, whose write lock is per-instance.
They are not duplicates and neither replaces the other. Link.Tests is
where the edges live — a tampered ciphertext, a file that will not
decrypt, a server that answers something which is not JSON — and it is
what the coverage badge measures. Link.Specs is where the behaviour
lives, written in the sentences above rather than in method names: a
message arrives however it travelled, what was cleared stays cleared, a
handset that cannot read its messages says so.
dotnet test --project TheBleedingDeacons.Intergroup.Link.SpecsBoth run over Link.Core, both run in CI, and the specs are a gate rather than a contribution to the badge — folding them into the coverage run would quietly change what the number means.
The narrative behind the feature files, and the glossary they use, is
specs/domain-model.md. It was written by
reading the code: the app came first and the specification was
reverse-engineered from it, so where the two disagree the feature files
are what runs.
Scenarios tagged @manual @ignore are on-device acceptance criteria
and Reqnroll skips them. They are written down rather than left in prose
because several of them are the sharpest hazards here — what the
notification tray shows, a keystore entry invalidated by a changed screen
lock, and the reinstall that destroys every message ever sent to a
handset. No test host can reach any of them.
Stated plainly rather than left to be discovered.
iOS push. The TFM is in the csproj now and CI builds the head, so this entry is about what that head lacks rather than about its absence.
It now carries the push code, and has never received a push. The Firebase
iOS SDK is referenced, FirebasePush.ios.cs configures it at launch and
exchanges Apple's APNs device token for the FCM registration token
message.token needs, the app delegate opens the silent push and raises
the notification itself, and the aps-environment entitlement is
declared. What none of that has had is an iPhone, an APNs key on the
Firebase project, or a paid Developer Program team — Apple grants
aps-environment to nothing less, so a free personal team cannot even
sign a build that asks for it.
Until those exist the head behaves as it always has: FirebasePush
finds no GoogleService-Info.plist, reports no transport, and an iOS
build collects its messages by polling. That is the same documented
state as an Android build without google-services.json, and the same
one a phone in a tunnel is in: every message arrives, on the poll
interval rather than at once.
If you came here from an older copy of this file, or from Hand's: the
binding is AdamE.Firebase.iOS.CloudMessaging, not
Xamarin.Firebase.iOS.CloudMessaging. The Xamarin one is archived and
its newest version targets net6.0-ios15.4, so it cannot restore against
this project at all.
Sign in with Apple shows itself when the app is signed for it.
SignInPage offers a Continue with Apple button, SignInViewModel binds
it to DeviceAuthService.SignInWithAppleAsync,
Platforms/iOS/AppleSignIn.ios.cs raises Apple's own
ASAuthorizationController, and the token goes to Firebase's
signInWithIdp as apple.com. The Functions then treat it like Google:
a verified address that has to be a member's.
It is written against ASAuthorization directly rather than MAUI's
AppleSignInAuthenticator, and the nonce is the reason. The MAUI helper's
AuthenticateAsync takes no options of any kind, so there is nowhere to put
one, and Firebase refuses a token minted without it. Apple is given the
SHA-256 of a random value and Firebase the value itself
(FirebaseFellowshipClient.StartSignInAsync), which is the way round
Firebase requires.
Whether the button shows is read from the app's own signature, not
from how it was built. com.apple.developer.applesignin is grantable only
by a paid Apple Developer Program team, and an app signed by a free
personal team that asks for it will not install at all. CI builds one
unsigned .ipa and whoever signs it decides, so at launch
Support/CodeSignature.cs reads the entitlements out of the executable's
code signature. Signed by the paid team, with Sign in with Apple switched
on for the App ID, the entitlement is there and the button shows. Signed
by a free team it is not, and the button is hidden rather than raising a
sheet that always fails. A build with no readable signature, such as a
simulator build, falls back to LINK_APPLE_SIGNIN, which
-p:LinkPaidTeam=true defines along with applying
Platforms/iOS/Entitlements.plist for a build signed on a Mac.
What it needs outside the code:
- Apple Developer, Identifiers: the App ID
org.thebleedingdeacons.intergroup.linkon the paid team, with Sign in with Apple (and Push Notifications) ticked. The profile the build is signed with must be issued after that, so it carries the entitlement. - Firebase console, Authentication → Sign-in method: Apple enabled. A native iOS sign-in needs no Services ID or key there; those are for the web flow.
- Sideloading with the paid Apple ID: keep the bundle id
(
--keep-bundle-id). The token's audience is the bundle id, and Firebase accepts only the one registered for the iOS app, so a team-suffixed install is refused by Apple. - Hide My Email. A member who picks it hands over a
privaterelay.appleid.comaddress, which is no member's, and is refused like any unknown address. They need to share their real one, or use Google or their password.
External testers and the App Store. Every release now goes to
TestFlight for internal testers (see TestFlight below). Opening it to
external testers needs a privacy policy URL and a beta description in App
Store Connect, and Beta App Review, which may want Apple's own button style
(ASAuthorizationAppleIDButton) for Continue with Apple rather than the
plain Button the sign-in page draws.
Hardware-backed keys. DeviceKeyStore generates the keypair in
managed code and keeps the private half in SecureStorage, which on
Android is a preferences file encrypted by a hardware-backed Android
Keystore key. That is meaningfully better than a file in app storage and
meaningfully worse than a non-exportable key generated inside the TEE:
here the private key exists as bytes in process memory whenever a message
is opened, and a rooted device could read it.
Moving generation into the Android Keystore proper is the next step —
RSA/ECB/OAEPWithSHA-1AndMGF1Padding is supported there, which is
exactly the padding Fellowship uses, so the wire format would not change.
IDeviceKeyStore is the seam it goes behind and no caller would need
touching. It was not done in the same pass that built the rest because it
needs Java interop and a real device to test on, and a documented
compromise beats an undocumented one.
Attachments. None, and none designed. FCM's 4KB data limit means a photo cannot travel in the envelope at all, so it would need a fetch-on-open path — a sealed blob the app collects over HTTPS after being told about it — which does not exist yet.
Serilog, to a rolling daily file under the app's data directory
(logs/link-<date>.log, seven days kept) and, in Debug, to the IDE.
Link shipped without any of this and the first real fault proved the
cost: the evidence available was a screenshot and Android's own log,
because the app had no account of itself. Several paths swallow
exceptions on purpose — throwing out of OnMessageReceived kills the
process Android started to deliver the message, and the message is safe
on the server either way — and "swallowed" had quietly come to mean
"swallowed without trace". The catches still swallow; they no longer do
it silently.
Now the same pipeline Hand runs, which reverses what this said before. Every enricher Hand carries, the flattened exception fields, the crash handlers for unhandled AppDomain, unobserved-task and Android exceptions, and a durable Better Stack sink that flushes the moment something is logged at Error or worse rather than waiting for its timer.
All of it is Inventory
since 2026-09-30, the library Link and Register now share; its README is
the full account. MauiProgram calls builder.UseInventory(...), and
RemoteLogging is what is left that is Link's own: asking Fellowship,
and forgetting at sign-out. Moving brought one fix Link did not have:
every ILogger<T> was bound to the pipeline of the moment it was made,
so after the first rebuild — a new answer from Fellowship, or any flush
on an error — it wrote into a disposed one. Inventory routes them
through a logger that always writes to the live pipeline.
The old argument was that Link's failures are late messages rather than a helpline alert that did not ring, so the file could be pulled with adb when somebody was diagnosing. The second half is what did not hold up: pulling a file needs the handset, a cable and somebody who knows to ask, and the failures that matter here — a message that arrived and would not open, a push that silently stopped — are exactly the ones a member does not report, because they cannot see them happening.
The token is not in the app. It used to be handled the way Hand
handles it, in a git-ignored appsettings.json. That kept it out of git
but put it in every APK and IPA built with it. Now the site hands the
endpoint and source token to a handset once it has signed in, and
appsettings.json has no BetterStack section at all. See
RemoteLogging.
From Freedom, since 2026-09-30. The values are betterstack.endpoint
and betterstack.source_token (ticked Secret) in the site's Freedom
plugin, under an application called link with "Accept a Link session"
ticked — the same two names Register reads from its own application.
Link signs in to Freedom by handing over its Fellowship session, so there
is still only one Google sign-in; the handset becomes a Freedom tablet
keyed on its Fellowship enrolment, and goes when that enrolment goes. See
FreedomLoggingSource. Until then Fellowship served the same two values
from GET /logging, set on its settings screen; Link no longer asks it.
The logger is in one of three states:
- Not told yet. A fresh install, or a handset that has signed out. Logs are held in a small on-disk buffer (two files of 1 MB each). If a sign-in fails, the log of it ships once one succeeds.
- Shipping. What the site said is stored in SecureStorage, so the next launch, or a push that wakes the handset, ships at once without asking first. Every launch and every sign-in asks again, and a changed answer rebuilds the sink.
- Told not to ship. The
linkapplication has no Better Stack values. The sink is removed and the buffer deleted.
No answer (offline, a server error, or the site refusing the session) keeps whatever the handset already has. Signing out, or being refused by the server, forgets the stored settings, signs out of Freedom, and goes back to holding.
The handset still holds a copy while it is signed in. That keeps the token out of the binary; it does not make it a secret. A Better Stack source token can write to its source and cannot read from it.
The file is still there, and is still what to reach for with the handset in hand:
adb -s <serial> exec-out run-as org.thebleedingdeacons.intergroup.link cat files/logs/link-<date>.log
run-as works because Debug builds are debuggable; a Release build's
logs are not reachable this way.
The one thing the logger must never do is become a source of failure
itself, so UseInventory cannot throw: a sink that will not build leaves
Serilog's silent default, and every Log.* call downstream becomes a
no-op rather than a null reference — which is exactly the behaviour Link
had before any of this existed.
"I can't get in" was the report the log could least answer. It used to say that an enrolment succeeded or was refused, and nothing else: not which button, and not what Google's sheet answered.
Every sign-in, key replacement and sign-out is now an attempt
(AuthAttempt). While one is open, every event logged on its path carries
AuthAttempt (eight hex digits), AuthOperation and AuthMethod through
Serilog's log context — including Fellowship's client's refusals, logged
from a layer that does not know a sign-in is happening. One Better Stack
query on the attempt id is the whole story. Each attempt ends in exactly
one outcome line with its duration: succeeded (Information, with device
and member ids), cancelled by the member (Information, because a closed
account picker is not a fault), refused (Warning,
with the sentence the member was shown), or threw (Error, logged from an
exception filter so the attempt's properties are still attached; the
exception goes on exactly as before).
Between those: the picker's answer, the error code a Function answered
(such as fellowship_not_a_member), which
credential the enrolment carried and whether a push token went with it,
the Freedom handover, and on every launch which page the shell chose.
What never goes in: passwords, one-time codes, Apple and Firebase ID
tokens, the device token. What does, hidden: the email address a
member typed. Inventory's Redact runs EmailRedactor over everything
every sink writes, exception text included, so an address becomes
email:3f9a2c1b — an HMAC under a key made on the handset and kept in
SecureStorage (LogRedactionKey). The same address gives the same token on
that handset, so three failures in a row are visibly the same address;
nobody holding only the logs can turn a token back into an address. Any
address in a log line is redacted the same way, including the contact
address in the user agent.
dotnet build TheBleedingDeacons.Intergroup.Link -p:LinkAndroidOnly=true -p:EmbedAssembliesIntoApk=trueLinkAndroidOnly narrows the build to the Android head, and on Windows
and macOS it is load-bearing rather than decorative: both resolve to
both heads by default, so a bare dotnet build builds each of them.
Only Linux gets Android alone, because there is no maui-ios workload for
it. LinkIosOnly is the opposite number. Do not reach for
-f net10.0-ios instead: that sets TargetFramework as a global
property, forces the TFM onto Link.Core, and breaks its restore with
NU1105.
The property is new. This command has carried -p:LinkAndroidOnly=true
since the repo was ported from Hand, where nothing defined it and it
narrowed nothing at all — the same silent no-op the CI workflow was
caught passing. It does something now.
A Windows machine compiles the managed half of the iOS head but cannot
produce the .app bundle, which needs a Mac for the native link and the
asset catalog. That is enough to catch a compile error in
Platforms/iOS, and not enough to produce an artifact — see Hot Restart
below for what it can do.
EmbedAssembliesIntoApk=true is not optional for a Debug device build.
Fast Deployment — the .NET Android default in Debug — leaves the managed
assemblies out of the APK, and Hand documents at length how that produces
an APK with incomplete Material resources that dies on launch before any
app code runs. It also fails deceptively on a handset that already has an
embedded APK installed. Do not use it.
Configuration lives in appsettings.json, embedded rather than copied so
it cannot be edited on a device to point the app at somebody else's
server — which matters, since the app hands that server an OAuth code.
Platforms/Android/google-services.json and
Platforms/iOS/GoogleService-Info.plist are git-ignored — one Firebase
project, one file per head. Without them the app builds and works; it
just polls instead of being pushed to. CI writes the iOS one from a
GOOGLE_SERVICES_PLIST secret, because the .ipa it archives is the
artifact that reaches a handset; the Android half is still unwritten.
dotnet test --project TheBleedingDeacons.Intergroup.Link.TestsNo workload needed — the test project and Link.Core are plain net10.0.
There is no Mac in this setup, so the iOS dev loop is Visual Studio's
iOS Hot Restart: VS compiles the managed code on Windows and pushes it
into an app bundle on a tethered device, signed with a free Apple ID. No
Mac, no .ipa, no Developer Program.
It needs, all of which are checkable before you start:
- Visual Studio with the .NET MAUI workload, and the
iosworkload indotnet workload list - Desktop iTunes, the 64-bit build from Apple — not the Microsoft Store version, which does not install the device drivers
- Apple Mobile Device Support (comes with the above)
- An Apple ID added to Visual Studio, and the iPhone trusted to this PC
Then: select the tethered device from the debug target dropdown and run. VS registers the bundle id under your personal team and provisions it the first time.
What it costs, and none of it is a surprise once said out loud:
- Debug only. Hot Restart cannot produce a Release build.
- The signature expires after 7 days on a free Apple ID. The app stops launching until it is deployed again. This is Apple's limit, not a Link one.
- No push, ever, on a free account. APNs keys need a paid Developer
Program membership, and
aps-environmentcannot be signed by a free personal team at all — a build requesting it fails to install rather than degrading, which is whyLinkPaidTeamgates the whole entitlements file. So an iOS build signed this way polls. The push code is in it and will stay dormant. - The message list and sign-in are the point. What Hot Restart is good for is proving the UI and Google's account picker work on a real handset. It is not a way to hand Link to a member.
No APK on an ordinary run, from 2026-11-09: building and uploading one roughly doubled the Android job, and nobody installed it. Each release still carries one, and releases do not expire.
link-ipa-unsigned only when asked for, from 2026-09-30: dispatch the
workflow with ios ticked, or put the ios label on a pull request.
gh workflow run ci.yml -R bleedingdeacons/link --ref <branch> -f ios=true
gh pr edit <n> -R bleedingdeacons/link --add-label iosWhen it runs, it builds in parallel with the Android job. It never runs on a
push to main, so releases never wait for it. (The testflight job does
build the iOS head on a release, after the version is cut; see
TestFlight.) The iOS job runs on GitHub's own macos-26 by default — free on this
public repository, and around eleven minutes once a runner picks it up.
Setting the IOS_RUNNER repository variable to a
Namespace macOS label
(namespace-profile-link-macos) moves it there instead: about four minutes
end to end, and billed. It is the only job here that costs anything, which
is why it is not the default.
gh variable set IOS_RUNNER -R bleedingdeacons/link -b namespace-profile-link-macos # fast, paid
gh variable delete IOS_RUNNER -R bleedingdeacons/link # free, slowAndroid stays on the free ubuntu-latest: Namespace was tried there too,
but that workspace's Linux profile is ARM64 and .NET's Android SDK ships an
x64-only aapt2, so the build fails with XA0111.
This is the second time the iOS head has been opt-in. It was from 2026-09-11 to 2026-09-24 too, and went back to every run because iOS breakage then surfaced in batches rather than on the commit that caused it. The trade is being made again knowingly: a build that nobody asked for costs a macOS runner on every push and PR, and an iOS break now waits to be found until somebody asks — so ask before an iOS release, and after anything that touches the iOS head or the workloads.
Every run that builds it also publishes it to the ios-test release,
replacing the .ipa that was there. So the newest unsigned build is always
at one fixed address, releases/tag/ios-test, instead of on whichever run
last built it, where it expires after 30 days. The release is a
prerelease and never Latest, the version tags are v1.2.3 and
bump-version.sh ignores anything else, and its notes name the commit and
run the .ipa came from. Pull requests publish there too (except
Dependabot's and forks', whose token cannot), so check the notes before
assuming it is main.
gh release download ios-test -R bleedingdeacons/link -p link-unsigned.ipa -D C:/Data/link-artifacts --clobberBoth are built against the LINK_BASE_URL repository variable, which
CI writes into appsettings.json before compiling. Without it the
artifacts came out with no idea which intergroup they belonged to — which
is fine for a build nobody installs and useless the moment one reaches a
phone, as the first sideloaded .ipa demonstrated by opening, offering
Google sign-in, and failing on every call after it. Only BaseUrl is
written; PollSeconds comes from the default in FellowshipConfiguration.
The file still never enters git.
Unset the variable and the old behaviour returns: a build that succeeds and a sign-in screen that says the app has not been set up. That is what a fork gets.
Neither is a shipping artifact, and both are easy to mistake for one:
- The .ipa is unsigned. It installs on nothing until it is re-signed. It is a compile gate for the iOS head and an input to whatever does the signing later.
- The APK is signed with the runner's throwaway debug keystore, which
is generated fresh on each run and is not the one on any developer
machine. It will refuse to install over a locally built Link with
INSTALL_FAILED_UPDATE_INCOMPATIBLE, and the only way past that isadb uninstall— which destroys the handset's private key, and with it every message ever sealed to that handset. Nobody can re-seal them: each message is sealed per device when it is sent, and the server keeps only that ciphertext. Only a backup taken beforehand and restored on the sign-in screen brings them back (see Moving to a new phone). Use a local build for a handset that is already enrolled.
Every release from main is signed for App Store Connect and uploaded
to TestFlight, from 2026-11-25. CI's testflight job follows the tag the
version job pushes, builds the iOS head with -p:LinkAppStore=true, and
uploads it with xcrun altool and an App Store Connect API key. Nothing
here needs a Mac, an Apple ID password or a 2FA code. The app is called
Fellowship Link in App Store Connect, because plain Link is taken
across the store; the icon on the phone still says Link.
Testers are internal for now: people who are users on the App Store
Connect team, in a TestFlight group with automatic distribution. Each
build reaches them once Apple has processed it, usually 10-30 minutes
after the job ends, and they install it from the TestFlight app. It points
at whatever LINK_BASE_URL says, which is the test site today.
To upload a ref without a release (to prove a change here before it merges, or to retry a failed upload):
gh workflow run ci.yml -R bleedingdeacons/link --ref <branch> -f testflight=trueApp Store Connect refuses a build number it has seen, and the build number
is ApplicationVersion, which only a release bumps. So a dispatch of a ref
already uploaded fails at the upload.
Six repository secrets, made once by hand:
| Secret | What it is |
|---|---|
IOS_DIST_CERT_P12 |
The Apple Distribution certificate and its private key, as a base64 .p12 |
IOS_DIST_CERT_PASSWORD |
That .p12's password |
IOS_APPSTORE_PROFILE |
The App Store Connect provisioning profile for org.thebleedingdeacons.intergroup.link, base64 |
ASC_KEY_ID |
The App Store Connect API key's id |
ASC_ISSUER_ID |
The team's issuer id, shown above the list of API keys |
ASC_KEY_P8 |
The API key itself, the text of the .p8 |
The originals live in C:\Data\dev\auth\apple\, which is not a repository.
Where each comes from, on developer.apple.com and appstoreconnect.apple.com:
- Identifiers: the App ID needs Sign in with Apple and Push Notifications ticked before the profile is made, because a profile carries only what the App ID had when it was issued.
- Certificates → Apple Distribution, from a CSR made with
openssl(link-distribution.keyand.csr). The downloaded.cerand the key become the.p12. The certificate lasts a year. - Profiles → App Store Connect, for the App ID and that certificate. CI reads the profile's name out of the file, so any name works. Remake it whenever the certificate is renewed or a capability is added.
- App Store Connect → Users and Access → Integrations → App Store
Connect API: a team key with the App Manager role. Apple offers the
.p8for download once only.
The entitlements come from Platforms/iOS/Entitlements.AppStore.plist,
not Entitlements.plist: a distribution profile grants aps-environment
production only. Push to a TestFlight install also needs an APNs auth
key on the Firebase project; without one, those installs poll.
Export compliance. Info.plist sets ITSAppUsesNonExemptEncryption
to false, matching the answer given for build 97, so builds go straight to
testers instead of waiting under Missing Compliance. That is the answer
for internal testing only. Link seals messages itself with RSA-OAEP and
AES-256-GCM, beyond HTTPS, which usually counts as standard encryption
and is recorded as Yes. The source being public may change that.
Settle it, with advice, before external testing or the App Store.
Google on Android, Apple on an iPhone (2026-11-26): each phone is
offered its own platform's account, and a member whose address isn't that
account uses their password. DeviceAuthService.IsGoogleOffered is the
one switch. The iOS Google code is still built, just not offered.
On Android, Continue with Google — at sign-in and when replacing a key —
uses Credential Manager's account picker (GoogleSignIn on iOS, were it
offered there), then Firebase Auth. The resulting Firebase
ID token goes to the enrol Function, which checks the member against
WordPress and gives this phone its own Firebase identity. See
NativeGoogleSignIn.
There is no browser sign-in and no custom URL scheme. Where the picker can't work, the member is told to use their password: a Firebase config with no Google client in it, an APK signed with a key whose SHA-1 is not registered, or a phone with no Google account support. To turn it on:
- Firebase console (project
fellowship-510917) → Authentication → Sign-in method → Google → enable. - On the Android app, add the SHA-1 of every key that signs it: the upload
keystore, Play's app-signing key, and the debug key
/kickinstalls with. - Download
google-services.jsonandGoogleService-Info.plistagain — the Google client ids only appear in them after step 1 — and update the CI secrets. CI registers the plist'sREVERSED_CLIENT_IDas a URL scheme inInfo.plist; GoogleSignIn crashes without it, soNativeGoogleSignInchecks for it and stays on the browser when it is missing.
Unlike Sign in with Apple this needs no paid team, so it works on the sideloaded build.