Enable OpenPGP key servers on Android, add keys.eternityproject.fi, allow removing built-in servers
- Android: key-server lookup, publish, add/remove/enable via native HTTP - Built-in servers can be removed; keys.eternityproject.fi (VKS) added as a default - Fix Settings additions (Encryption keys, shortcuts) missing on Android due to async preferences - Fix compose footer so Send is visible on small screens - Bump version to 0.5.22 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -7,8 +7,10 @@ const MAX_CUSTOM_SERVERS = 10;
|
||||
|
||||
const BUILTIN_SERVERS = [
|
||||
{ id: 'openpgp-vks', name: 'keys.openpgp.org', url: 'https://keys.openpgp.org', protocol: 'vks', builtin: true },
|
||||
{ id: 'mailvelope-hkp', name: 'keys.mailvelope.com', url: 'https://keys.mailvelope.com', protocol: 'hkp', builtin: true }
|
||||
{ id: 'mailvelope-hkp', name: 'keys.mailvelope.com', url: 'https://keys.mailvelope.com', protocol: 'hkp', builtin: true },
|
||||
{ id: 'eternity-vks', name: 'keys.eternityproject.fi', url: 'https://keys.eternityproject.fi', protocol: 'vks', builtin: true }
|
||||
];
|
||||
const BUILTIN_SERVER_IDS = BUILTIN_SERVERS.map(server => server.id);
|
||||
|
||||
function normalizeBaseUrl(value) {
|
||||
const raw = String(value || '').trim();
|
||||
@@ -40,10 +42,11 @@ function normalizeCustomServer(input) {
|
||||
};
|
||||
}
|
||||
|
||||
function listServers(customServers = [], enabledServerIds = []) {
|
||||
function listServers(customServers = [], enabledServerIds = [], removedBuiltinIds = []) {
|
||||
const enabled = new Set(enabledServerIds);
|
||||
const removed = new Set(removedBuiltinIds);
|
||||
return [
|
||||
...BUILTIN_SERVERS.map(server => ({ ...server, enabled: enabled.has(server.id) })),
|
||||
...BUILTIN_SERVERS.filter(server => !removed.has(server.id)).map(server => ({ ...server, enabled: enabled.has(server.id) })),
|
||||
...customServers.map(server => {
|
||||
const normalized = normalizeCustomServer(server);
|
||||
return { ...normalized, enabled: enabled.has(normalized.id) };
|
||||
@@ -72,14 +75,17 @@ async function readResponseText(response) {
|
||||
const chunks = [];
|
||||
let length = 0;
|
||||
for await (const chunk of response.body) {
|
||||
const bytes = Buffer.from(chunk);
|
||||
const bytes = typeof chunk === 'string' ? new TextEncoder().encode(chunk) : chunk;
|
||||
length += bytes.length;
|
||||
if (length > MAX_RESPONSE_BYTES) {
|
||||
throw new Error('The key server response is too large.');
|
||||
}
|
||||
chunks.push(bytes);
|
||||
}
|
||||
return Buffer.concat(chunks, length).toString('utf8');
|
||||
const joined = new Uint8Array(length);
|
||||
let offset = 0;
|
||||
for (const bytes of chunks) { joined.set(bytes, offset); offset += bytes.length; }
|
||||
return new TextDecoder().decode(joined);
|
||||
}
|
||||
|
||||
function createKeyServerService({ fetchImpl = globalThis.fetch } = {}) {
|
||||
@@ -269,6 +275,7 @@ function createKeyServerService({ fetchImpl = globalThis.fetch } = {}) {
|
||||
|
||||
module.exports = {
|
||||
BUILTIN_SERVERS,
|
||||
BUILTIN_SERVER_IDS,
|
||||
MAX_CUSTOM_SERVERS,
|
||||
createKeyServerService,
|
||||
listServers,
|
||||
|
||||
Reference in New Issue
Block a user