Checkpoint peering identity and opt-in discovery

This commit is contained in:
Codex committed 2026-10-13 22:00:54 +02:00
1 parent eba9b50e30
commit 47de081721
44 files changed
+1557 -55

No files matched your search

+3
View File
@@ -4,6 +4,7 @@ const https = require('node:https');
const fs = require('node:fs');
const fsp = fs.promises;
const crypto = require('node:crypto');
const { normalizeWorkIdentity } = require('../scraper/lib/work-identity');
const { pipeline } = require('node:stream/promises');
const { Transform } = require('node:stream');
const { PeeringState, fp, requirePeer, grantStatus } = require('./state');
@@ -101,6 +102,7 @@ async function catalog(store, id) {
for (let page = 0; page < 100; page++) {
const result = await jsonRequest(store, id, `/peer/v1/catalog${cursor ? `?cursor=${encodeURIComponent(cursor)}` : ''}`);
if (!Array.isArray(result.items) || result.items.length > 50) throw new Error('Invalid peer catalog');
for (const item of result.items) if (item.workIdentity != null && !normalizeWorkIdentity(item.workIdentity)) throw new Error('Invalid work identity in peer catalog');
items.push(...result.items); cursor = result.nextCursor;
if (!cursor) return items;
}
@@ -112,6 +114,7 @@ async function manga(store, id, shareId) {
for (let page = 0; page < 100; page++) {
const result = await jsonRequest(store, id, `/peer/v1/manga/${shareId}${cursor ? `?cursor=${encodeURIComponent(cursor)}` : ''}`);
if (result.id !== shareId || !Array.isArray(result.chapters) || result.chapters.length > 100) throw new Error('Invalid peer manga manifest');
if (result.workIdentity != null && !normalizeWorkIdentity(result.workIdentity)) throw new Error('Invalid work identity in peer manga manifest');
first ||= result; chapters.push(...result.chapters); cursor = result.nextCursor;
if (!cursor) return { id: shareId, title: first.title, ...first, chapters };
}