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

@ -0,0 +1,16 @@
/// Splits PEM material into its two parts. A Gemini identity commonly travels
/// as one .pem holding both the certificate and its private key, or as two
/// files; both cases come out of these two lookups.
library;
final _certificate = RegExp(
r'-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----');
final _privateKey = RegExp(
r'-----BEGIN (?:RSA |EC )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC )?PRIVATE KEY-----');
/// The first certificate in [pem], or null when there is none.
String? certificateOf(String pem) => _certificate.firstMatch(pem)?.group(0);
/// The first private key in [pem], or null when there is none.
String? privateKeyOf(String pem) => _privateKey.firstMatch(pem)?.group(0);