feat: add Gemini and Spartan protocol support

This commit is contained in:
randogoth 2026-10-11 22:07:25 +03:00
parent a4a49f41d7
commit fa7aa5557c
48 changed files with 4992 additions and 161 deletions

View file

@ -6,6 +6,7 @@ import 'package:path/path.dart' as p;
import 'package:mews/database/database.dart';
import 'package:mews/mews/document.dart';
import 'package:mews/protocols/tofu.dart';
MewsEntry _entry(String url, {String title = 'A post', int day = 8}) =>
MewsEntry(url: url, date: DateTime(2026, 10, day), title: title);
@ -175,4 +176,41 @@ void main() {
await db.removeBookmark(url);
expect(await db.tagsOf(TagKind.bookmark, url), isEmpty);
});
test('pins are saved by host and port and replaced on renewal', () async {
final pin = TofuPin(fingerprint: 'aa', expires: DateTime(2030));
await db.savePin('capsule.example', 1965, pin);
await db.savePin('capsule.example', 1966, pin);
expect(await db.allPins(), {
'capsule.example:1965': pin,
'capsule.example:1966': pin,
});
// A renewal or a reader's new trust replaces the pin for that host.
final renewed = TofuPin(fingerprint: 'bb', expires: DateTime(2036));
await db.savePin('capsule.example:1965'.split(':').first, 1965, renewed);
expect((await db.allPins())['capsule.example:1965'], renewed);
});
test('bindings tie identities to hosts and follow the identity out', () async {
final id = await db.addClientCertificate('Reader', 'CERT PEM');
await db.bindCertificate('capsule.example', 1965, id);
// Binding again, not twice.
await db.bindCertificate('capsule.example', 1965, id);
expect(await db.bindingFor('capsule.example', 1965), id);
expect(await db.bindingsOf(id), ['capsule.example:1965']);
// Renaming an identity is its name only; where it is worn stays.
await db.renameClientCertificate(id, 'Reader Two');
expect((await db.allClientCertificates()).single.name, 'Reader Two');
expect(await db.bindingFor('capsule.example', 1965), id);
// Removing an identity takes its bindings with it, so no site is left
// pointing at a certificate that is no longer there.
await db.deleteClientCertificate(id);
expect(await db.allClientCertificates(), isEmpty);
expect(await db.bindingFor('capsule.example', 1965), isNull);
});
}