pups-client 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,222 @@
1
+ import type { FeedItem } from './feed.js';
2
+ import { type HandleSource } from './handles.js';
3
+ /** The link relation of the mention endpoint in `host-meta.json` (RFC-11 "Discovery"). A placeholder in RFC-11. */
4
+ export declare const MENTION_REL = "https://bigwide.net/ns/mention";
5
+ export interface MentionsOptions {
6
+ fetch?: typeof fetch;
7
+ /**
8
+ * The waits before the retries of a webmention after a network error, a `5xx` or a `429` (RFC-11 "When").
9
+ * A longer `Retry-After` is respected, up to 10 minutes. Default: 10 seconds, 1 minute, 5 minutes.
10
+ */
11
+ retryDelays?: number[];
12
+ /**
13
+ * The waits between the checks whether a new or changed post is visible at its public URL, before the mentions
14
+ * are sent (RFC-11 "When"). Default: 1, 2, 4, 8 and 15 seconds, so about half a minute.
15
+ */
16
+ visibilityDelays?: number[];
17
+ /** Timeout of each request, in milliseconds. Default 15 seconds. */
18
+ timeoutMs?: number;
19
+ /** The publisher's identity, e.g. `https://tim.example.com/`: never notified. `session.mentions` sets it. */
20
+ me?: string;
21
+ }
22
+ /**
23
+ * The result of sending a webmention:
24
+ * - `accepted`: the endpoint answered `2xx`.
25
+ * - `unknown`: sent, but the endpoint doesn't allow a browser to read its answer (no CORS headers).
26
+ * - `rejected`: the endpoint answered `4xx` (other than `429`); not retried.
27
+ * - `failed`: a network error, `5xx` or `429`, also after the retries.
28
+ */
29
+ export type DeliveryStatus = 'accepted' | 'unknown' | 'rejected' | 'failed';
30
+ export interface Delivery {
31
+ status: DeliveryStatus;
32
+ /** The HTTP status, if there was a readable answer. */
33
+ httpStatus?: number;
34
+ /** The `message` of a JSON error body, or what went wrong. */
35
+ message?: string;
36
+ /** The `error` of a JSON error body, e.g. an RFC-4 failure code such as `comments-disabled`. */
37
+ code?: string;
38
+ /** The `Location` header of the answer, e.g. an RFC-4 status page. */
39
+ location?: string;
40
+ }
41
+ /** An account a post would notify, from `plan()`: e.g. to ask the author before anything is sent. */
42
+ export interface PlannedMention {
43
+ /** The account, e.g. `@tim.example.com`. */
44
+ account: string;
45
+ /** `reply` if the post answers an item of the account, `mention` if it names it. */
46
+ kind: 'mention' | 'reply';
47
+ /** The webmention's target: the domain's root URL, or the answered item. */
48
+ target: string;
49
+ /** The mention endpoint; set by `plan()` with `discover`, and on reports of accounts that have one. */
50
+ endpoint?: string;
51
+ }
52
+ /** One account notified by `notifyAll()` or `sendPlanned()`, or skipped because its domain doesn't accept mentions. */
53
+ export interface MentionReport extends PlannedMention {
54
+ /** `no-endpoint` if the domain doesn't accept mentions (no link in `host-meta.json`, or it can't be read). */
55
+ status: DeliveryStatus | 'no-endpoint';
56
+ httpStatus?: number;
57
+ message?: string;
58
+ }
59
+ /** The answer to an RFC-4 submission. */
60
+ export interface Submission extends Delivery {
61
+ /** The endpoint from the target feed's `_submissions.url`. */
62
+ endpoint: string;
63
+ /** The status page (RFC-4 "Response and status"), from `Location`; poll it with `submissionStatus()`. */
64
+ statusUrl?: string;
65
+ /** The guid the item will have when it is republished. */
66
+ guid?: string;
67
+ }
68
+ /** An RFC-4 status page. */
69
+ export type SubmissionStatus = {
70
+ status: 'waiting';
71
+ } | {
72
+ status: 'success';
73
+ pubDate?: string;
74
+ pubUrl?: string;
75
+ } | {
76
+ status: 'deleted';
77
+ } | {
78
+ status: 'failure';
79
+ code?: string;
80
+ text?: string;
81
+ };
82
+ /** An item found in a feed, with what decides about mentions and submissions. */
83
+ export interface FoundItem {
84
+ /** The URL of the feed or archive that was fetched first. */
85
+ feedUrl: string;
86
+ /** The RFC-4 `_submissions` that apply: the feed's, or for an RFC-7 archive, those of its feed file. */
87
+ submissions?: Record<string, unknown>;
88
+ /** The item, if it was found. */
89
+ item?: FeedItem;
90
+ /** The host of the item's author (RFC-11 "Replies"): its own socialspec account, else the feed's if the feed has no `_submissions`. */
91
+ author?: string;
92
+ }
93
+ /** What decides about the mentions of a post: its title, content and `_source.inReplyTo`. A `FeedItem` or a `PostInput`. */
94
+ export type MentionSource = HandleSource & {
95
+ _source?: unknown;
96
+ };
97
+ /** The input of `plan()`: a post to be added (`item`), changed (`item` and `previous`) or deleted (`previous`). */
98
+ export interface PostChange {
99
+ /** The post as it will be published; undefined for a delete. */
100
+ item?: MentionSource;
101
+ /** The post before an edit or delete. */
102
+ previous?: MentionSource;
103
+ /** The publisher's identity; never notified. Default: the `me` of the options. */
104
+ me?: string;
105
+ }
106
+ /** The input of `notifyAll()`: a post that was added, changed or deleted, and its `source`. */
107
+ export interface PostMentions extends PostChange {
108
+ /** The post's `source`: its feed or archive URL plus `#<id>`. */
109
+ source: string;
110
+ }
111
+ /**
112
+ * Sends webmentions: RFC-11 mentions to the domains a post names or answers, found through their `host-meta.json`,
113
+ * and RFC-4 submissions to the endpoint a target feed names in `_submissions`. Plain Webmention, form-encoded.
114
+ *
115
+ * Use `session.mentions`, which shares the discovery cache of the session, or create one for use without a session.
116
+ * In a browser, it can only read feeds and `host-meta.json` files that allow CORS, as RFC-4 and RFC-6 require;
117
+ * domains whose `host-meta.json` doesn't count as having no endpoint (RFC-11 "CORS").
118
+ */
119
+ export declare class Mentions {
120
+ #private;
121
+ constructor(options?: MentionsOptions);
122
+ /**
123
+ * The mention endpoint of a domain (RFC-11 "Discovery"): the first link with the relation `MENTION_REL` in its
124
+ * `host-meta.json`, if it is an https URL. Undefined if the domain has none, or its `host-meta.json` can't be
125
+ * read. Cached for 24 hours (less if the file's `max-age` says so), failures for an hour.
126
+ * @param domain `tim.example.com`, `@tim.example.com` or `https://tim.example.com/`.
127
+ */
128
+ discover(domain: string, options?: {
129
+ signal?: AbortSignal;
130
+ }): Promise<string | undefined>;
131
+ /**
132
+ * Sends a webmention: a form-encoded `POST` with `source` and `target`. Retries after network errors, `5xx` and
133
+ * `429` with the `retryDelays` (unless `retry` is false), never after other answers. Never throws, except
134
+ * `aborted`.
135
+ */
136
+ send(endpoint: string, source: string, target: string, options?: {
137
+ signal?: AbortSignal;
138
+ retry?: boolean;
139
+ }): Promise<Delivery>;
140
+ /**
141
+ * Tells a domain that `source` names it (RFC-11 "Mentions by name"), or answers its item `target`. Discovers
142
+ * the endpoint and sends the webmention.
143
+ * @param account `@tim.example.com` (or the bare host).
144
+ * @param target Default: the domain's root URL, `https://tim.example.com/`.
145
+ */
146
+ notify(source: string, account: string, options?: {
147
+ target?: string;
148
+ signal?: AbortSignal;
149
+ retry?: boolean;
150
+ }): Promise<MentionReport>;
151
+ /**
152
+ * Tells the author of the item `target` (a feed URL plus `#<id>`) that `source` answers it (RFC-11 "Replies").
153
+ * @returns undefined if the item has no author to notify, can't be read, or its feed takes RFC-4 submissions:
154
+ * then the answer is a submission, and the RFC-4 server sends the mentions.
155
+ */
156
+ reply(source: string, target: string, options?: {
157
+ signal?: AbortSignal;
158
+ retry?: boolean;
159
+ }): Promise<MentionReport | undefined>;
160
+ /**
161
+ * Submits a comment or post to an RFC-4 feed (RFC-4 "Submitting"): `source` is the item in the author feed,
162
+ * `target` the answered item (feed URL plus `#<id>`), or the group feed for a new post. The endpoint is the
163
+ * target feed's `_submissions.url`, unless given. The app must have shown the target's terms of service and what
164
+ * `republish` means before the first submission (RFC-4 "Republishing").
165
+ * @throws {PupsError} `unsupported` if the target feed takes no submissions.
166
+ */
167
+ submit(source: string, target: string, options?: {
168
+ endpoint?: string;
169
+ signal?: AbortSignal;
170
+ }): Promise<Submission>;
171
+ /** Reads an RFC-4 status page. */
172
+ submissionStatus(statusUrl: string, options?: {
173
+ signal?: AbortSignal;
174
+ }): Promise<SubmissionStatus>;
175
+ /**
176
+ * The accounts a post that is added, changed or deleted would notify (RFC-11 "Who is mentioned"), without sending
177
+ * anything, e.g. to list them in a confirmation dialog before posting: every domain its title and text name
178
+ * (RFC-11 "Handles"), and the author of the item it answers, with a reply. After an edit or delete, every account
179
+ * the old or the new version mentions. Each account once, replies first, never `me`, at most 20.
180
+ *
181
+ * Empty if the post answers an item of a feed with RFC-4 `_submissions`: such a post is a submission, and the
182
+ * RFC-4 server sends the mentions once it republishes it (RFC-11 "Who sends").
183
+ *
184
+ * Finding the author of an answered item reads its feed. With `discover`, it also looks up each domain's endpoint,
185
+ * and leaves out the domains that don't accept mentions; that tells them that a post names them, before the post
186
+ * is published (RFC-11 "Privacy considerations").
187
+ */
188
+ plan(post: PostChange, options?: {
189
+ signal?: AbortSignal;
190
+ discover?: boolean;
191
+ }): Promise<PlannedMention[]>;
192
+ /**
193
+ * Sends mentions as `plan()` returned them, e.g. those the author confirmed, with `source` as the post: the
194
+ * post's feed or archive URL plus `#<id>`, once it is published.
195
+ */
196
+ sendPlanned(source: string, planned: PlannedMention[], options?: {
197
+ signal?: AbortSignal;
198
+ retry?: boolean;
199
+ }): Promise<MentionReport[]>;
200
+ /** `plan()` and `sendPlanned()` in one: sends the RFC-11 mentions of a post that was added, changed or deleted. */
201
+ notifyAll(post: PostMentions, options?: {
202
+ signal?: AbortSignal;
203
+ }): Promise<MentionReport[]>;
204
+ /**
205
+ * Finds an item, given as feed URL plus `#<id>`, as RFC-4 does: in the feed, then along `next_url` (or RFC-13's
206
+ * `_archive.archive_url`) on the same host, at most 10 pages. JSON Feed only.
207
+ * @throws {PupsError} `network`, `not_found` or `invalid_feed` if the first feed can't be read.
208
+ */
209
+ findItem(ref: string, options?: {
210
+ signal?: AbortSignal;
211
+ item?: boolean;
212
+ }): Promise<FoundItem>;
213
+ /**
214
+ * Waits until the item `id` at the public URL `feedUrl` is in the state `ready` wants, e.g. present after a post,
215
+ * so that a receiver that fetches it right away doesn't get an older copy from a cache (RFC-11 "When"). Gives up
216
+ * after the `visibilityDelays`, or at once if the feed can't be read.
217
+ */
218
+ waitForItem(feedUrl: string, id: string, ready: (item: FeedItem | undefined) => boolean, options?: {
219
+ signal?: AbortSignal;
220
+ }): Promise<boolean>;
221
+ }
222
+ //# sourceMappingURL=mentions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentions.d.ts","sourceRoot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AAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQ5G;;;;;;;;;;;;OAYG;IACG,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAuBnH;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IASzI,mHAAmH;IAC7G,SAAS,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAIrG;;;;OAIG;IACG,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,SAAS,CAAC;IAmDvG;;;;OAIG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,KAAK,OAAO,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAiBzJ"}
@@ -0,0 +1,343 @@
1
+ import { accountHost, asciiHost, itemHandles } from './handles.js';
2
+ import { isPupsError, PupsError } from './errors.js';
3
+ import { fetchWithTimeout, isObject, sleep } from './util.js';
4
+ /** The link relation of the mention endpoint in `host-meta.json` (RFC-11 "Discovery"). A placeholder in RFC-11. */
5
+ export const MENTION_REL = 'https://bigwide.net/ns/mention';
6
+ /** RFC-11: senders should notify at most this many accounts per post. */
7
+ const MAX_ACCOUNTS = 20;
8
+ /** RFC-4 "Archived items": servers follow at least 10 pages; so does the sender looking for an item. */
9
+ const MAX_PAGES = 10;
10
+ const DAY_MS = 24 * 3600_000;
11
+ const HOUR_MS = 3600_000;
12
+ const MAX_FEED_BYTES = 2_000_000;
13
+ const protocolOf = (url) => {
14
+ try {
15
+ return typeof url == 'string' ? new URL(url).protocol : undefined;
16
+ }
17
+ catch {
18
+ return undefined;
19
+ }
20
+ };
21
+ const isHttps = (url) => protocolOf(url) == 'https:';
22
+ const isHttpUrl = (url) => isHttps(url) || protocolOf(url) == 'http:';
23
+ const inReplyTo = (item) => isObject(item?._source) && typeof item._source.inReplyTo == 'string' ? item._source.inReplyTo : undefined;
24
+ const socialspec = (o) => isObject(o) && isObject(o._source) && isObject(o._source.accounts) ? o._source.accounts.socialspec : undefined;
25
+ const retryable = (status) => status == 429 || status >= 500;
26
+ /** Splits `https://x.example/feed.json#p-1` into the feed URL and the decoded id. */
27
+ function splitRef(ref) {
28
+ const at = ref.indexOf('#');
29
+ if (at < 0)
30
+ return [ref, undefined];
31
+ let id = ref.slice(at + 1);
32
+ try {
33
+ id = decodeURIComponent(id);
34
+ }
35
+ catch { /* keep it as it is */ }
36
+ return [ref.slice(0, at), id];
37
+ }
38
+ /** A field of a feed's RFC-13 `_archive`, or of `_pups` in feeds of earlier drafts (RFC-13 "Earlier drafts"). */
39
+ const archiveField = (doc, key) => (isObject(doc._archive) ? doc._archive[key] : undefined) ?? (isObject(doc._pups) ? doc._pups[key] : undefined);
40
+ /**
41
+ * Sends webmentions: RFC-11 mentions to the domains a post names or answers, found through their `host-meta.json`,
42
+ * and RFC-4 submissions to the endpoint a target feed names in `_submissions`. Plain Webmention, form-encoded.
43
+ *
44
+ * Use `session.mentions`, which shares the discovery cache of the session, or create one for use without a session.
45
+ * In a browser, it can only read feeds and `host-meta.json` files that allow CORS, as RFC-4 and RFC-6 require;
46
+ * domains whose `host-meta.json` doesn't count as having no endpoint (RFC-11 "CORS").
47
+ */
48
+ export class Mentions {
49
+ #fetch;
50
+ #retryDelays;
51
+ #visibilityDelays;
52
+ #timeoutMs;
53
+ #endpoints = new Map();
54
+ #me;
55
+ constructor(options = {}) {
56
+ this.#fetch = options.fetch ?? ((input, init) => fetch(input, init));
57
+ this.#retryDelays = options.retryDelays ?? [10_000, 60_000, 300_000];
58
+ this.#visibilityDelays = options.visibilityDelays ?? [1000, 2000, 4000, 8000, 15_000];
59
+ this.#timeoutMs = options.timeoutMs ?? 15_000;
60
+ this.#me = options.me;
61
+ }
62
+ /**
63
+ * The mention endpoint of a domain (RFC-11 "Discovery"): the first link with the relation `MENTION_REL` in its
64
+ * `host-meta.json`, if it is an https URL. Undefined if the domain has none, or its `host-meta.json` can't be
65
+ * read. Cached for 24 hours (less if the file's `max-age` says so), failures for an hour.
66
+ * @param domain `tim.example.com`, `@tim.example.com` or `https://tim.example.com/`.
67
+ */
68
+ async discover(domain, options = {}) {
69
+ const host = asciiHost(domain.replace(/^@/, '').replace(/^https:\/\//i, '').replace(/\/$/, ''));
70
+ if (!host)
71
+ return undefined;
72
+ const cached = this.#endpoints.get(host);
73
+ if (cached && cached.until > Date.now())
74
+ return cached.endpoint;
75
+ const url = `https://${host}/.well-known/host-meta.json`;
76
+ let endpoint;
77
+ let maxAge = DAY_MS;
78
+ try {
79
+ const response = await fetchWithTimeout(this.#fetch, url, { credentials: 'omit', headers: { Accept: 'application/json' } }, this.#timeoutMs, options.signal);
80
+ // Only host-meta.json on the domain itself counts (RFC-11 "Discovery").
81
+ if (response.ok && (!response.url || new URL(response.url).host == host)) {
82
+ const doc = await response.json();
83
+ const link = isObject(doc) && Array.isArray(doc.links) ? doc.links.find(l => isObject(l) && l.rel == MENTION_REL) : undefined;
84
+ endpoint = isHttps(link?.href) ? link.href : undefined;
85
+ const age = /max-age=(\d+)/.exec(response.headers.get('Cache-Control') ?? '');
86
+ if (age)
87
+ maxAge = Math.min(maxAge, Number(age[1]) * 1000);
88
+ }
89
+ }
90
+ catch (e) {
91
+ if (isPupsError(e, 'aborted'))
92
+ throw e;
93
+ }
94
+ this.#endpoints.set(host, { endpoint, until: Date.now() + (endpoint ? maxAge : Math.max(maxAge, HOUR_MS)) });
95
+ return endpoint;
96
+ }
97
+ /**
98
+ * Sends a webmention: a form-encoded `POST` with `source` and `target`. Retries after network errors, `5xx` and
99
+ * `429` with the `retryDelays` (unless `retry` is false), never after other answers. Never throws, except
100
+ * `aborted`.
101
+ */
102
+ async send(endpoint, source, target, options = {}) {
103
+ return (await this.#sendWithBody(endpoint, source, target, options)).delivery;
104
+ }
105
+ async #sendWithBody(endpoint, source, target, options) {
106
+ const delays = options.retry === false ? [] : this.#retryDelays;
107
+ for (let attempt = 0;; attempt++) {
108
+ const answer = await this.#post(endpoint, source, target, options.signal);
109
+ if (answer.delivery.status != 'failed' || attempt >= delays.length)
110
+ return answer;
111
+ await sleep(Math.max(delays[attempt], Math.min(answer.retryAfterMs, 600_000)), options.signal);
112
+ }
113
+ }
114
+ async #post(endpoint, source, target, signal) {
115
+ const body = () => new URLSearchParams({ source, target });
116
+ let response;
117
+ try {
118
+ response = await fetchWithTimeout(this.#fetch, endpoint, { method: 'POST', body: body(), credentials: 'omit' }, this.#timeoutMs, signal);
119
+ }
120
+ catch (e) {
121
+ if (isPupsError(e, 'aborted'))
122
+ throw e;
123
+ // A browser hides the answer of an endpoint without CORS headers, but a form-encoded POST is a simple request
124
+ // and reaches it anyway: send it without reading the answer.
125
+ try {
126
+ await fetchWithTimeout(this.#fetch, endpoint, { method: 'POST', body: body(), credentials: 'omit', mode: 'no-cors' }, this.#timeoutMs, signal);
127
+ return { delivery: { status: 'unknown', message: 'Sent, but the endpoint doesn\'t let a browser read its answer.' }, retryAfterMs: 0 };
128
+ }
129
+ catch (again) {
130
+ if (isPupsError(again, 'aborted'))
131
+ throw again;
132
+ return { delivery: { status: 'failed', message: e instanceof Error ? e.message : String(e) }, retryAfterMs: 0 };
133
+ }
134
+ }
135
+ const location = response.headers.get('Location');
136
+ const json = await response.json().catch(() => undefined);
137
+ const delivery = {
138
+ status: response.ok ? 'accepted' : retryable(response.status) ? 'failed' : 'rejected',
139
+ httpStatus: response.status,
140
+ ...location ? { location: new URL(location, endpoint).href } : {},
141
+ ...!response.ok && isObject(json) && typeof json.message == 'string' ? { message: json.message } : {},
142
+ ...!response.ok && isObject(json) && typeof json.error == 'string' ? { code: json.error } : {},
143
+ };
144
+ return { delivery, json, retryAfterMs: (Number(response.headers.get('Retry-After')) || 0) * 1000 };
145
+ }
146
+ /**
147
+ * Tells a domain that `source` names it (RFC-11 "Mentions by name"), or answers its item `target`. Discovers
148
+ * the endpoint and sends the webmention.
149
+ * @param account `@tim.example.com` (or the bare host).
150
+ * @param target Default: the domain's root URL, `https://tim.example.com/`.
151
+ */
152
+ async notify(source, account, options = {}) {
153
+ const host = asciiHost(account.replace(/^@/, '')) ?? account.replace(/^@/, '');
154
+ const planned = { account: `@${host}`, kind: options.target ? 'reply' : 'mention', target: options.target ?? `https://${host}/` };
155
+ return (await this.sendPlanned(source, [planned], options))[0];
156
+ }
157
+ /**
158
+ * Tells the author of the item `target` (a feed URL plus `#<id>`) that `source` answers it (RFC-11 "Replies").
159
+ * @returns undefined if the item has no author to notify, can't be read, or its feed takes RFC-4 submissions:
160
+ * then the answer is a submission, and the RFC-4 server sends the mentions.
161
+ */
162
+ async reply(source, target, options = {}) {
163
+ const found = await this.findItem(target, options).catch(e => {
164
+ if (isPupsError(e, 'aborted'))
165
+ throw e;
166
+ return undefined;
167
+ });
168
+ return found?.author && !found.submissions ? this.notify(source, found.author, { ...options, target }) : undefined;
169
+ }
170
+ /**
171
+ * Submits a comment or post to an RFC-4 feed (RFC-4 "Submitting"): `source` is the item in the author feed,
172
+ * `target` the answered item (feed URL plus `#<id>`), or the group feed for a new post. The endpoint is the
173
+ * target feed's `_submissions.url`, unless given. The app must have shown the target's terms of service and what
174
+ * `republish` means before the first submission (RFC-4 "Republishing").
175
+ * @throws {PupsError} `unsupported` if the target feed takes no submissions.
176
+ */
177
+ async submit(source, target, options = {}) {
178
+ let endpoint = options.endpoint;
179
+ if (!endpoint) {
180
+ const submissions = (await this.findItem(target, { ...options, item: false })).submissions;
181
+ if (!isHttpUrl(submissions?.url))
182
+ throw new PupsError('unsupported', `${splitRef(target)[0]} takes no submissions: it has no _submissions with a url (RFC-4).`);
183
+ endpoint = submissions.url;
184
+ }
185
+ const { delivery, json } = await this.#sendWithBody(endpoint, source, target, { signal: options.signal, retry: false });
186
+ const statusUrl = delivery.location ?? (isObject(json) && typeof json.statusUrl == 'string' ? json.statusUrl : undefined);
187
+ const guid = isObject(json) && typeof json.guid == 'string' ? json.guid : undefined;
188
+ return { ...delivery, endpoint, ...statusUrl ? { statusUrl } : {}, ...guid ? { guid } : {} };
189
+ }
190
+ /** Reads an RFC-4 status page. */
191
+ async submissionStatus(statusUrl, options = {}) {
192
+ const response = await fetchWithTimeout(this.#fetch, statusUrl, { credentials: 'omit', cache: 'no-store', headers: { Accept: 'application/json' } }, this.#timeoutMs, options.signal);
193
+ const json = await response.json().catch(() => undefined);
194
+ if (!isObject(json) || typeof json.status != 'string')
195
+ throw new PupsError('invalid_request', `${statusUrl} is not an RFC-4 status page (HTTP ${response.status}).`);
196
+ return json;
197
+ }
198
+ /**
199
+ * The accounts a post that is added, changed or deleted would notify (RFC-11 "Who is mentioned"), without sending
200
+ * anything, e.g. to list them in a confirmation dialog before posting: every domain its title and text name
201
+ * (RFC-11 "Handles"), and the author of the item it answers, with a reply. After an edit or delete, every account
202
+ * the old or the new version mentions. Each account once, replies first, never `me`, at most 20.
203
+ *
204
+ * Empty if the post answers an item of a feed with RFC-4 `_submissions`: such a post is a submission, and the
205
+ * RFC-4 server sends the mentions once it republishes it (RFC-11 "Who sends").
206
+ *
207
+ * Finding the author of an answered item reads its feed. With `discover`, it also looks up each domain's endpoint,
208
+ * and leaves out the domains that don't accept mentions; that tells them that a post names them, before the post
209
+ * is published (RFC-11 "Privacy considerations").
210
+ */
211
+ async plan(post, options = {}) {
212
+ const me = post.me ?? this.#me;
213
+ const own = me ? asciiHost(new URL(me).hostname) : undefined;
214
+ const replies = new Map();
215
+ for (const target of new Set([inReplyTo(post.item), inReplyTo(post.previous)].filter((t) => !!t?.includes('#')))) {
216
+ const found = await this.findItem(target, options).catch(e => {
217
+ if (isPupsError(e, 'aborted'))
218
+ throw e;
219
+ return undefined;
220
+ });
221
+ if (found?.submissions)
222
+ return [];
223
+ if (found?.author && found.author != own && !replies.has(found.author))
224
+ replies.set(found.author, target);
225
+ }
226
+ const names = [...new Set([...post.item ? itemHandles(post.item) : [], ...post.previous ? itemHandles(post.previous) : []])]
227
+ .filter(host => host != own && !replies.has(host));
228
+ const planned = [
229
+ ...[...replies].map(([host, target]) => ({ account: `@${host}`, kind: 'reply', target })),
230
+ ...names.map(host => ({ account: `@${host}`, kind: 'mention', target: `https://${host}/` })),
231
+ ].slice(0, MAX_ACCOUNTS);
232
+ if (!options.discover)
233
+ return planned;
234
+ const endpoints = await Promise.all(planned.map(p => this.discover(p.account, options)));
235
+ return planned.flatMap((p, i) => endpoints[i] ? [{ ...p, endpoint: endpoints[i] }] : []);
236
+ }
237
+ /**
238
+ * Sends mentions as `plan()` returned them, e.g. those the author confirmed, with `source` as the post: the
239
+ * post's feed or archive URL plus `#<id>`, once it is published.
240
+ */
241
+ sendPlanned(source, planned, options = {}) {
242
+ return Promise.all(planned.map(async (p) => {
243
+ const endpoint = p.endpoint ?? await this.discover(p.account, options);
244
+ if (!endpoint)
245
+ return { ...p, status: 'no-endpoint' };
246
+ const { status, httpStatus, message } = await this.send(endpoint, source, p.target, options);
247
+ return { ...p, endpoint, status, ...httpStatus ? { httpStatus } : {}, ...message ? { message } : {} };
248
+ }));
249
+ }
250
+ /** `plan()` and `sendPlanned()` in one: sends the RFC-11 mentions of a post that was added, changed or deleted. */
251
+ async notifyAll(post, options = {}) {
252
+ return this.sendPlanned(post.source, await this.plan(post, options), options);
253
+ }
254
+ /**
255
+ * Finds an item, given as feed URL plus `#<id>`, as RFC-4 does: in the feed, then along `next_url` (or RFC-13's
256
+ * `_archive.archive_url`) on the same host, at most 10 pages. JSON Feed only.
257
+ * @throws {PupsError} `network`, `not_found` or `invalid_feed` if the first feed can't be read.
258
+ */
259
+ async findItem(ref, options = {}) {
260
+ const [url, id] = splitRef(ref);
261
+ const first = await this.#readFeed(url, options.signal);
262
+ // An RFC-13 archive takes its _submissions from its feed file (RFC-7 "Receiving comments").
263
+ let owner = first;
264
+ const updates = archiveField(first.doc, 'updates_url');
265
+ if (typeof updates == 'string') {
266
+ const feedUrl = new URL(updates, first.url);
267
+ owner = feedUrl.host == new URL(first.url).host ? await this.#readFeed(feedUrl.href, options.signal).catch(() => ({ url: feedUrl.href, doc: {} })) : { url: feedUrl.href, doc: {} };
268
+ }
269
+ const submissions = isObject(owner.doc._submissions) ? owner.doc._submissions : undefined;
270
+ const result = { feedUrl: first.url, ...submissions ? { submissions } : {} };
271
+ if (options.item === false || id === undefined)
272
+ return result;
273
+ const seen = new Set();
274
+ let feed = first;
275
+ for (let page = 0; feed && page < MAX_PAGES; page++) {
276
+ seen.add(feed.url);
277
+ const items = Array.isArray(feed.doc.items) ? feed.doc.items : [];
278
+ const item = items.find((i) => isObject(i) && i.id == id);
279
+ if (item) {
280
+ const author = accountHost(socialspec(item)) ?? (submissions ? undefined : accountHost(socialspec(owner.doc)));
281
+ return { ...result, item, ...author ? { author } : {} };
282
+ }
283
+ const next = feed.doc.next_url ?? archiveField(feed.doc, 'archive_url');
284
+ if (typeof next != 'string')
285
+ break;
286
+ const nextUrl = new URL(next, feed.url);
287
+ if (nextUrl.host != new URL(url).host || seen.has(nextUrl.href))
288
+ break;
289
+ feed = await this.#readFeed(nextUrl.href, options.signal).catch(e => {
290
+ if (isPupsError(e, 'aborted'))
291
+ throw e;
292
+ return undefined;
293
+ });
294
+ }
295
+ return result;
296
+ }
297
+ async #readFeed(url, signal) {
298
+ const response = await fetchWithTimeout(this.#fetch, url, { credentials: 'omit', headers: { Accept: 'application/feed+json, application/json' } }, this.#timeoutMs, signal);
299
+ if (!response.ok)
300
+ throw new PupsError('not_found', `${url} answered HTTP ${response.status}.`);
301
+ const text = await response.text();
302
+ if (text.length > MAX_FEED_BYTES)
303
+ throw new PupsError('invalid_feed', `${url} is too large.`);
304
+ let doc;
305
+ try {
306
+ doc = JSON.parse(text);
307
+ }
308
+ catch {
309
+ doc = undefined;
310
+ }
311
+ if (!isObject(doc) || typeof doc.version != 'string' || !doc.version.startsWith('https://jsonfeed.org/version/'))
312
+ throw new PupsError('invalid_feed', `${url} is not a JSON Feed.`);
313
+ return { url, doc };
314
+ }
315
+ /**
316
+ * Waits until the item `id` at the public URL `feedUrl` is in the state `ready` wants, e.g. present after a post,
317
+ * so that a receiver that fetches it right away doesn't get an older copy from a cache (RFC-11 "When"). Gives up
318
+ * after the `visibilityDelays`, or at once if the feed can't be read.
319
+ */
320
+ async waitForItem(feedUrl, id, ready, options = {}) {
321
+ for (let attempt = 0;; attempt++) {
322
+ let doc;
323
+ try {
324
+ const response = await fetchWithTimeout(this.#fetch, feedUrl, { credentials: 'omit', cache: 'no-store' }, this.#timeoutMs, options.signal);
325
+ if (!response.ok)
326
+ return false;
327
+ doc = await response.json();
328
+ }
329
+ catch (e) {
330
+ if (isPupsError(e, 'aborted'))
331
+ throw e;
332
+ return false;
333
+ }
334
+ const items = Array.isArray(doc?.items) ? doc.items : [];
335
+ if (ready(items.find((i) => isObject(i) && i.id == id)))
336
+ return true;
337
+ if (attempt >= this.#visibilityDelays.length)
338
+ return false;
339
+ await sleep(this.#visibilityDelays[attempt], options.signal);
340
+ }
341
+ }
342
+ }
343
+ //# sourceMappingURL=mentions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentions.js","sourceRoot":"","sources":["../src/mentions.ts"],"names":[],"mappings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O,CAAC,MAAM,CAAC,CAAA;gBAC1I,IAAI,CAAC,QAAQ,CAAC,EAAE;oBAAE,OAAO,KAAK,CAAA;gBAC9B,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YAC7B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,WAAW,CAAC,CAAC,EAAE,SAAS,CAAC;oBAAE,MAAM,CAAC,CAAA;gBACtC,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,KAAK,GAAc,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;YACnE,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAiB,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;gBAAE,OAAO,IAAI,CAAA;YACnF,IAAI,OAAO,IAAI,IAAI,CAAC,iBAAiB,CAAC,MAAM;gBAAE,OAAO,KAAK,CAAA;YAC1D,MAAM,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;QAC/D,CAAC;IACH,CAAC;CACF"}
package/dist/session.d.ts CHANGED
@@ -2,6 +2,7 @@ import { type PupsServer } from './discovery.js';
2
2
  import { PupsError } from './errors.js';
3
3
  import { PupsFeed, type FeedLink, type FeedOptions } from './feed.js';
4
4
  import { HostMetaEditor } from './host-meta.js';
5
+ import { Mentions } from './mentions.js';
5
6
  import { type Scope } from './scopes.js';
6
7
  import type { SessionRecord, TokenStore } from './store/token-store.js';
7
8
  import type { TabChannel } from './tabs.js';
@@ -93,6 +94,11 @@ export declare class PupsSession {
93
94
  readonly _tokens: TokenManager;
94
95
  /** @internal */
95
96
  constructor(record: SessionRecord, persistent: boolean, ctx: SessionContext);
97
+ /**
98
+ * Sends webmentions: RFC-11 mentions to domains, RFC-4 submissions to feeds. Shared by the session's feeds, so
99
+ * that they share the discovery cache.
100
+ */
101
+ get mentions(): Mentions;
96
102
  /** The server configuration, pinned at login. */
97
103
  get server(): PupsServer;
98
104
  /** The issuer of the server. */