Changeset 834bcc3 in Klonkt for src/services/CircleFederation.js


Ignore:
Timestamp:
06/23/2026 06:14:27 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
d774679
Parents:
bb42dfb
Message:

i18n: translate Dutch code comments to English across src/

Comments in routes/services/views/config/middleware/assets translated to
English for the public repo. A few dev-facing throw/console message strings
were Englished too. No user-facing UI strings or i18n dictionary values changed
(src/services/i18n.js untouched). Logic unchanged.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/CircleFederation.js

    rbb42dfb r834bcc3  
    1 // CircleFederation.js — eigen publicatie-kant van "Cirkels" (v1).
     1// CircleFederation.js — publication side of "Circles" (v1).
    22//
    3 // Publiceert deze instance als een ActivityStreams-actor met een Ed25519-
    4 // sleutel, plus een outbox van publieke posts. De outbox wordt getekend zodat
    5 // consumenten (andere Klonkt-instances) de herkomst kunnen verifiëren.
     3// Publishes this instance as an ActivityStreams actor with an Ed25519 key,
     4// plus an outbox of public posts. The outbox is signed so that consumers
     5// (other Klonkt instances) can verify the origin.
    66//
    7 // v1 = alleen PUBLICEREN + tekenen. Het pullen/verifiëren van remote cirkels
    8 // (CircleService.sync) komt in een volgende stap. Zie docs/cirkels-v1-spec.md.
     7// v1 = PUBLISH + sign only. Pulling/verifying remote circles
     8// (CircleService.sync) comes in a later step. See docs/cirkels-v1-spec.md.
    99//
    10 // (Het idee om je netjes aan de bestaande standaarden te houden fluisterde een
    11 //  zekere Bart ons in. Wie hij is, waar hij vandaan komt — niemand die het zeker
    12 //  weet. Hij verscheen, sprak van ActivityStreams, en was weer weg.)
     10// (The idea of sticking neatly to existing standards was whispered to us by
     11//  a certain Bart. Who he is, where he came from — nobody knows for sure.
     12//  He appeared, spoke of ActivityStreams, and was gone.)
    1313
    1414import crypto from 'crypto';
     
    1616import { getSetting, setSetting } from './SettingsService.js';
    1717
    18 // ── Protocol-versie (federatie) ───────────────────────────────
    19 // KLONKT_PROTO zit IN de ondertekende grondslag (zie signingInput): een instance
    20 // die niet op deze proto draait kan onze getekende outbox NIET verifiëren, en wij
    21 // de hare niet. Bijblijven is dus geen beleefde check die je wegpatcht, maar
    22 // cryptografisch afgedwongen — de enige manier om mee te doen is dezelfde proto
    23 // draaien (= de update). Bump KLONKT_PROTO bij elke release die federatie/security
    24 // raakt, en koppel een securityfix aan elke bump → outdated = buiten + onveilig.
    25 // MIN_PROTO = de laagste proto waarmee we nog federeren.
     18// ── Protocol version (federation) ────────────────────────────
     19// KLONKT_PROTO is embedded IN the signed input (see signingInput): an instance
     20// not running this proto CANNOT verify our signed outbox, and we cannot verify
     21// theirs. Staying current is therefore not a polite check you can patch away,
     22// but cryptographically enforced — the only way to participate is to run the
     23// same proto (= apply the update). Bump KLONKT_PROTO for every release that
     24// touches federation/security, and attach a security fix to each bump →
     25// outdated = excluded + insecure.
     26// MIN_PROTO = the lowest proto we still federate with.
    2627export const KLONKT_PROTO = 2;
    2728export const MIN_PROTO = 2;
     
    3132}
    3233
    33 // ── Sleutelbeheer ─────────────────────────────────────────────
    34 // Per-instance Ed25519-keypair, eenmalig gegenereerd en in app_settings
    35 // bewaard. Privé = PKCS8-PEM (nooit serveren). Publiek = SPKI-DER base64
    36 // (gepubliceerd in de actor; round-trip via createPublicKey).
     34// ── Key management ────────────────────────────────────────────
     35// Per-instance Ed25519 keypair, generated once and stored in app_settings.
     36// Private = PKCS8 PEM (never served). Public = SPKI DER base64
     37// (published in the actor; round-tripped via createPublicKey).
    3738function getKeys() {
    3839  let priv = getSetting('circle_privkey_pem', null);
     
    5253}
    5354
    54 /** Tekent een body-string, gebonden aan de protocol-versie (Ed25519). */
     55/** Signs a body string, bound to the protocol version (Ed25519). */
    5556export function signBody(rawString, proto = KLONKT_PROTO) {
    5657  const key = crypto.createPrivateKey(getKeys().priv);
     
    5859}
    5960
    60 /** Verifieert een body tegen een SPKI-DER-base64 publieke sleutel, voor de gegeven
    61  *  proto. Een mismatch in proto = mismatch in grondslag = ongeldige handtekening. */
     61/** Verifies a body against an SPKI-DER-base64 public key for the given proto.
     62 *  A proto mismatch = a signing-input mismatch = invalid signature. */
    6263export function verifyBody(rawString, sigB64, pubDerB64, proto = KLONKT_PROTO) {
    6364  try {
     
    7374// ── Helpers ───────────────────────────────────────────────────
    7475function primarySite() {
    75   // Solo: de primaire/owner-site (eerst aangemaakt) — zelfde keuze als resolveSite.
     76  // Solo: the primary/owner site (oldest) — same choice as resolveSite.
    7677  return db.prepare('SELECT * FROM sites ORDER BY created_at ASC LIMIT 1').get();
    7778}
     
    8081  return String(s || '')
    8182    .replace(/<[^>]+>/g, ' ')
    82     .replace(/\[\[[^\]]*\]\]/g, ' ')   // [[playlist:..]]/[[track:..]]/[[album:..]]-shortcodes weg
     83    .replace(/\[\[[^\]]*\]\]/g, ' ')   // strip [[playlist:..]] / [[track:..]] / [[album:..]] shortcodes
    8384    .replace(/\s+/g, ' ')
    8485    .trim();
    8586}
    8687
    87 // Tags-kolom (JSON-array of comma-separated) -> nette string-array.
     88// Tags column (JSON array or comma-separated) -> clean string array.
    8889function parseTags(raw) {
    8990  if (!raw) return [];
    9091  if (Array.isArray(raw)) return raw.map((t) => String(t).trim()).filter(Boolean);
    91   try { const j = JSON.parse(raw); if (Array.isArray(j)) return j.map((t) => String(t).trim()).filter(Boolean); } catch { /* geen JSON */ }
     92  try { const j = JSON.parse(raw); if (Array.isArray(j)) return j.map((t) => String(t).trim()).filter(Boolean); } catch { /* not JSON */ }
    9293  return String(raw).split(',').map((t) => t.trim()).filter(Boolean);
    9394}
     
    103104}
    104105
    105 // allow_circle: een site mag in cirkels van anderen verschijnen. v1 koppelt dit
    106 // aan is_public (aparte expliciete flag volgt in de Beheer-UX-stap).
     106// allow_circle: a site may appear in other instances' circles. v1 ties this
     107// to is_public (a separate explicit flag follows in the admin UX step).
    107108function allowsCircle(site) {
    108109  return !!site && site.is_public !== 0 && site.allow_circle !== 0;
     
    170171        published,
    171172        ...(p.cover_image_url ? { image: { type: 'Image', url: abs(base, p.cover_image_url) } } : {}),
    172         // ActivityStreams: tags als Hashtag-objecten (href naar de bron-tagpagina).
     173        // ActivityStreams: tags as Hashtag objects (href points to the source tag page).
    173174        ...(tags.length ? { tag: tags.map((t) => ({ type: 'Hashtag', name: '#' + String(t).replace(/^#/, ''), href: `${base}/tag/${encodeURIComponent(t)}` })) } : {}),
    174175      },
Note: See TracChangeset for help on using the changeset viewer.