pups-client 0.6.0 → 0.8.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.
- package/README.md +9 -10
- package/dist/comments.d.ts +92 -0
- package/dist/comments.d.ts.map +1 -0
- package/dist/comments.js +203 -0
- package/dist/comments.js.map +1 -0
- package/dist/discovery.d.ts +5 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +1 -0
- package/dist/discovery.js.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/feed.d.ts +40 -70
- package/dist/feed.d.ts.map +1 -1
- package/dist/feed.js +125 -566
- package/dist/feed.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +2 -2
- package/dist/mentions.js.map +1 -1
- package/dist/session.d.ts +17 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +22 -0
- package/dist/session.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/comments.ts +247 -0
- package/src/discovery.ts +6 -0
- package/src/errors.ts +1 -1
- package/src/feed.ts +130 -598
- package/src/index.ts +2 -1
- package/src/mentions.ts +2 -3
- package/src/session.ts +25 -1
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -142,7 +142,7 @@ const photo = await feed.uploadMedia(photoFile) // → https:/
|
|
|
142
142
|
const post = await feed.addPost({ title: 'Hello', content_html: `<p>Hi!</p><img src="${photo.url}" alt="">` })
|
|
143
143
|
await feed.addPost({ markdown: 'Written in *Markdown*' }) // _source.markdown, with content_text as fallback
|
|
144
144
|
console.log(post.item.url) // the post's page on the homepage, if the site declares one
|
|
145
|
-
await feed.editPost(post.id, { title: 'Hello, world' }) // wherever the post is now
|
|
145
|
+
await feed.editPost(post.id, { title: 'Hello, world' }) // wherever the post is now; the server sets date_modified
|
|
146
146
|
await feed.deletePost(post.id, { deleteMedia: true }) // also deletes media no other post uses
|
|
147
147
|
await feed.updateSettings({ description: 'Longer notes', _podcast: { explicit: false } })
|
|
148
148
|
if (feed.commentsAvailable && feed.comments(state.feed) == 'off')
|
|
@@ -152,25 +152,24 @@ for await (const item of feed.posts()) console.log(item.id) // newest firs
|
|
|
152
152
|
const feeds = await session.listFeeds() // the feeds registered in host-meta.json
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
- **
|
|
156
|
-
- **
|
|
157
|
-
- **Post URLs.** `addPost()` returns `url`, the post's archive URL plus `#<id>`. It never changes, so it can be the `source` of an RFC-4 webmention. If the site has a homepage that shows single posts, such as webpup, `host-meta.json` declares their URLs with the property `https://bigwide.net/ns/post-url-template` (`POST_URL_TEMPLATE`),
|
|
155
|
+
- **Kept feeds** (RFC-7). The PUPS server keeps the feed: `addPost()`, `editPost()` and `deletePost()` each send one item with `POST` to the feed file, and the server gives new posts their index, puts them into the archives and writes the feed file. The library never writes archives. It needs a server with `"kept_feeds": true` in its configuration (`session.server.keptFeeds`); otherwise writes fail with `unsupported`. Settings (`updateSettings()`, icons, comments) are read-modify-writes of the feed file with ETags, repeated when another app or the owner wrote in between; the server keeps the items.
|
|
156
|
+
- **Archives** ([RFC-13](https://github.com/bigwide-net/RFCs/blob/main/RFC-13-JSON-Feed-Archives.md)). Every post is in exactly one archive, `feed.000000.json`, `feed.000001.json`, … in the feed directory, 20 posts each, linked with `next_url`; posts never move. The feed file holds a copy of the newest 30 posts and points to the newest archive with `_archive.archive_url`. `feed.posts()` and `feed.getPost()` read them.
|
|
157
|
+
- **Post URLs.** `addPost()` returns `url`, the post's address: its archive URL plus `#<id>`. It never changes, so it can be the `source` of an RFC-4 webmention. If the site has a homepage that shows single posts, such as webpup, `host-meta.json` declares their URLs with the property `https://bigwide.net/ns/post-url-template` (`POST_URL_TEMPLATE`), and the server gives new posts the URL of their page as `url`, unless the app sets one. Show `post.item.url` as the post's link.
|
|
158
158
|
- **Comments on your feed.** If the server has a `comment_endpoint` (RFC-6 "Built-in receiver"), `feed.enableComments({ policy, tos })` opens the feed for RFC-4 comments: it writes `_submissions` into the feed file, with the endpoint as `url`, a `comments` policy and `republish: "no"`, and the server puts the comments into the owner's inbox. `feed.disableComments()` removes it, `feed.comments(doc)` tells whether comments go to this server (`pups`), another service (`other`) or nowhere (`off`). Archives don't copy `_submissions`: the feed file alone decides. Single posts are closed with `_commenting: { allowComments: false }`.
|
|
159
|
-
- **Indexes.**
|
|
159
|
+
- **Indexes.** The server gives every post an index, `_archive.index` (also `PostResult.index`, or `itemIndex(item)`): 0 for the first post, then counting up, never changed and never given out again. Readers can number the posts and load only the archives they need. An edit sends the post with its index, which tells the server which post it is.
|
|
160
160
|
- Errors: `not_pups_controlled` for feeds without the marker, `invalid_feed` for files that aren't JSON Feeds, `not_found` for a missing feed or post.
|
|
161
161
|
|
|
162
162
|
### Mentions and submissions
|
|
163
163
|
|
|
164
|
-
A feed can tell the people a post names or answers ([RFC-11](https://github.com/bigwide-net/RFCs/blob/main/RFC-11-Mentions.md)), and
|
|
164
|
+
A feed can tell the people a post names or answers ([RFC-11](https://github.com/bigwide-net/RFCs/blob/main/RFC-11-Mentions.md)), and the owner can comment on other feeds ([RFC-4](https://github.com/bigwide-net/RFCs/blob/main/RFC-4-Feed-Submissions.md)):
|
|
165
165
|
|
|
166
166
|
```ts
|
|
167
167
|
const feed = session.feed(undefined, { mentions: true })
|
|
168
168
|
const post = await feed.addPost({ content_html: '<p>Great talk by <a href="https://alice.example/">@alice.example</a></p>' })
|
|
169
169
|
for (const r of await post.mentions ?? []) console.log(r.account, r.status) // @alice.example accepted
|
|
170
170
|
|
|
171
|
-
const comment = await
|
|
172
|
-
|
|
173
|
-
await session.mentions.submissionStatus(submission.statusUrl!) // { status: 'success', pubUrl: … }
|
|
171
|
+
const comment = await session.comments.post({ target: 'https://rm.example/groups/g/posts.json#a8Kd03', markdown: 'Agreed!' })
|
|
172
|
+
await session.mentions.submissionStatus(comment.submission!.statusUrl!) // { status: 'success', pubUrl: … }
|
|
174
173
|
|
|
175
174
|
await session.mentions.notify(source, '@alice.example') // the generic interface: any source, any account
|
|
176
175
|
await session.mentions.reply(source, 'https://bob.example/feed.json#p-12')
|
|
@@ -188,7 +187,7 @@ await session.mentions.reply(source, 'https://bob.example/feed.json#p-12')
|
|
|
188
187
|
- **Automatic mentions.** With `{ mentions: true }`, `addPost()`, `editPost()` and `deletePost()` find the handles in the post's title and visible text, e.g. `@alice.example`, also lists like `@alice.example/@bob.example`, but not e-mail addresses, fediverse addresses, names without a dot or paths. The author of the item a post answers (`_source.inReplyTo`) gets a reply mention. Each account is notified once, never the owner, at most 20 per post; after an edit or delete, everyone the old or the new version named.
|
|
189
188
|
- **After the upload.** The mentions are sent in the background, once the post is visible at its public URL (so that a CDN doesn't hand the receiver an old copy), with the archive URL plus `#<id>` as `source`. `post.mentions` resolves to one report per account (`accepted`, `rejected`, `failed`, `unknown` or `no-endpoint`) and never rejects; a failed mention never fails the post. Network errors, `5xx` and `429` are retried a few times; `feed.sendMentions(id)` sends again later.
|
|
190
189
|
- **Discovery.** The endpoint is the link `https://bigwide.net/ns/mention` in the domain's `host-meta.json`, cached for a day, failures for an hour. A domain without one, or whose `host-meta.json` doesn't allow CORS, gets nothing. An endpoint without CORS headers still receives the mention; its report says `unknown`.
|
|
191
|
-
- **
|
|
190
|
+
- **Comments** on other feeds, and posts to discussion groups, are RFC-4 submissions. They never go into the owner's main feed: `session.comments` keeps them in comment feeds in the app's own directory, one file per target site and hour, `/appdata/<client-host>/comments/<hash3>/<hash>.json`, as RFC-7 "Comment feeds" recommends, which needs the `appdata` scope. `post()` adds the comment to its file (creating it if needed) and submits it to the target once it is visible; `edit(source, changes)` and `delete(source)` change the file and submit again with the same `source`; `{ submit: false }` writes without submitting. Show the target's terms of service and what `republish` means before the first submission. No mentions are sent for comments: the RFC-4 server sends them once it republishes the comment. `feed.submit()` is deprecated.
|
|
192
191
|
- `new Mentions({ fetch })` works without a session. `findHandles()`, `itemHandles()` and `visibleText()` are exported too.
|
|
193
192
|
|
|
194
193
|
### What the library does for you
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { FeedAttachment, FeedAuthor, FeedItem } from './feed.js';
|
|
2
|
+
import type { Submission } from './mentions.js';
|
|
3
|
+
import type { PupsSession } from './session.js';
|
|
4
|
+
type Signal = {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
/** A comment, or a post to a discussion group: what an RFC-4 submission publishes. */
|
|
8
|
+
export interface CommentInput {
|
|
9
|
+
/** The answered item, as feed URL plus `#<id>`; for a new post in a group, the group feed's URL. */
|
|
10
|
+
target: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
content_html?: string;
|
|
13
|
+
content_text?: string;
|
|
14
|
+
/** The text as Markdown, stored in `_source.markdown` (RFC-1), and as `content_text` if neither content is given. */
|
|
15
|
+
markdown?: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
authors?: FeedAuthor[];
|
|
18
|
+
language?: string;
|
|
19
|
+
attachments?: FeedAttachment[];
|
|
20
|
+
[extension: `_${string}`]: unknown;
|
|
21
|
+
}
|
|
22
|
+
/** Changes to a comment: a value sets the field, `null` removes it, `undefined` leaves it unchanged. */
|
|
23
|
+
export type CommentChanges = {
|
|
24
|
+
[K in Exclude<keyof CommentInput, 'target'>]?: CommentInput[K] | null;
|
|
25
|
+
};
|
|
26
|
+
export interface CommentResult {
|
|
27
|
+
/** The comment's `source`: the public URL of its comment feed plus `#<id>`. It never changes. */
|
|
28
|
+
source: string;
|
|
29
|
+
/** The comment feed, below `/appdata/<client-host>/comments/`. */
|
|
30
|
+
path: string;
|
|
31
|
+
/** The item as stored; for a deleted comment, as it was. */
|
|
32
|
+
item: FeedItem;
|
|
33
|
+
/** The RFC-4 submission; missing with `submit: false`. */
|
|
34
|
+
submission?: Submission;
|
|
35
|
+
}
|
|
36
|
+
type SubmitOption = Signal & {
|
|
37
|
+
/** Submit to the target after writing (default `true`). Show the target's terms of service before the first one. */
|
|
38
|
+
submit?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The comment feed for a comment on `target` published at `date`, relative to the comments directory, in the layout
|
|
42
|
+
* RFC-7 recommends ("Comment feeds"): `<hash3>/<hash>.json`, where `<hash>` is the first 16 hex characters of the
|
|
43
|
+
* SHA-256 of `<target host> <yyyymmddhh>`, with the hour in UTC, and `<hash3>` its last three characters.
|
|
44
|
+
* @throws {PupsError} `invalid_request` if `target` is not an http(s) URL or `date` is invalid.
|
|
45
|
+
*/
|
|
46
|
+
export declare function commentFeedPath(target: string, date: Date | string): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* The owner's RFC-4 submissions (comments, and posts to discussion groups), kept in comment feeds in the app's own
|
|
49
|
+
* directory, never in the owner's main feed (RFC-7 "Comment feeds"): one file per target site and hour,
|
|
50
|
+
* `/appdata/<client-host>/comments/<hash3>/<hash>.json`. Needs the `appdata` scope. Use `session.comments`.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* const { source, submission } = await session.comments.post({ target: 'https://rm.example.org/groups/twowaves/posts.json#a8Kd03XpQz', markdown: 'Agreed!' })
|
|
54
|
+
* const status = await session.mentions.submissionStatus(submission!.statusUrl!)
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare class PupsComments {
|
|
58
|
+
#private;
|
|
59
|
+
constructor(session: PupsSession);
|
|
60
|
+
/** The path of the comment feed for a comment on `target` published at `date`. */
|
|
61
|
+
pathFor(target: string, date: Date | string): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Publishes a comment: adds it at the top of its comment feed, which is created if needed, and submits it to the
|
|
64
|
+
* target, once it is visible at its public URL.
|
|
65
|
+
* @throws {PupsError} `invalid_request` for a bad target or missing content; `invalid_feed` if the file holds
|
|
66
|
+
* something else; the errors of writing.
|
|
67
|
+
*/
|
|
68
|
+
post(input: CommentInput, options?: SubmitOption): Promise<CommentResult>;
|
|
69
|
+
/** A comment, given by its `source`; undefined if its feed or the item doesn't exist. */
|
|
70
|
+
get(source: string, options?: Signal): Promise<CommentResult | undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* Changes a comment in its comment feed, keeping `id`, `date_published` and the target, sets `date_modified`, and
|
|
73
|
+
* submits it again with the same `source`. RFC-4 servers apply it only if the target allows edits.
|
|
74
|
+
* @throws {PupsError} `not_found` if the comment doesn't exist.
|
|
75
|
+
*/
|
|
76
|
+
edit(source: string, changes: CommentChanges | ((item: FeedItem) => FeedItem), options?: SubmitOption): Promise<CommentResult>;
|
|
77
|
+
/**
|
|
78
|
+
* Removes a comment from its comment feed, deletes the file once it is empty, and submits again with the same
|
|
79
|
+
* `source`, so that the RFC-4 server deletes the republished comment if the target allows it.
|
|
80
|
+
* @throws {PupsError} `not_found` if the comment doesn't exist.
|
|
81
|
+
*/
|
|
82
|
+
delete(source: string, options?: SubmitOption): Promise<CommentResult>;
|
|
83
|
+
/**
|
|
84
|
+
* Submits a comment to its target (RFC-4 "Submitting"), e.g. again after a failure. Waits until its feed shows the
|
|
85
|
+
* comment as it is now, or no longer shows it after a delete, so that the server doesn't fetch an older copy.
|
|
86
|
+
*/
|
|
87
|
+
submit(source: string, target: string, options?: Signal & {
|
|
88
|
+
deleted?: boolean;
|
|
89
|
+
}): Promise<Submission>;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=comments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../src/comments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAgB,QAAQ,EAAE,MAAM,WAAW,CAAA;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAM/C,KAA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IAC5E,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAInE;;;;;OAKG;IACG,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAenF,yFAAyF;IACnF,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAW,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAOnF;;;;OAIG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,CAAC,CAAC,IAAI,EAAE,QAAQ,KAAK,QAAQ,CAAC,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAaxI;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAmBhF;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,GAAG;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,UAAU,CAAC;CAwDhH"}
|
package/dist/comments.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { isPupsError, PupsError } from './errors.js';
|
|
2
|
+
import { pathFromPublicUrl } from './paths.js';
|
|
3
|
+
import { isObject, randomString } from './util.js';
|
|
4
|
+
const RFC1_URL = 'https://github.com/bigwide-net/RFCs/blob/main/RFC-1-Source-for-JSON-Feeds.md';
|
|
5
|
+
const JSON_FEED = 'https://jsonfeed.org/version/1.1';
|
|
6
|
+
const now = () => new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
|
|
7
|
+
async function sha256Hex(text) {
|
|
8
|
+
const digest = new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text)));
|
|
9
|
+
return [...digest].map(b => b.toString(16).padStart(2, '0')).join('');
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The comment feed for a comment on `target` published at `date`, relative to the comments directory, in the layout
|
|
13
|
+
* RFC-7 recommends ("Comment feeds"): `<hash3>/<hash>.json`, where `<hash>` is the first 16 hex characters of the
|
|
14
|
+
* SHA-256 of `<target host> <yyyymmddhh>`, with the hour in UTC, and `<hash3>` its last three characters.
|
|
15
|
+
* @throws {PupsError} `invalid_request` if `target` is not an http(s) URL or `date` is invalid.
|
|
16
|
+
*/
|
|
17
|
+
export async function commentFeedPath(target, date) {
|
|
18
|
+
let host;
|
|
19
|
+
try {
|
|
20
|
+
const url = new URL(target);
|
|
21
|
+
if (url.protocol != 'https:' && url.protocol != 'http:')
|
|
22
|
+
throw new Error();
|
|
23
|
+
host = url.hostname;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new PupsError('invalid_request', `"${target}" is not an http(s) URL, so it can't be the target of a comment (RFC-4).`);
|
|
27
|
+
}
|
|
28
|
+
const time = new Date(date);
|
|
29
|
+
if (isNaN(+time))
|
|
30
|
+
throw new PupsError('invalid_request', `"${date}" is not a valid date.`);
|
|
31
|
+
const hour = time.toISOString().slice(0, 13).replace(/[-T]/g, '');
|
|
32
|
+
const hash = (await sha256Hex(`${host} ${hour}`)).slice(0, 16);
|
|
33
|
+
return `${hash.slice(-3)}/${hash}.json`;
|
|
34
|
+
}
|
|
35
|
+
const isFeed = (doc) => isObject(doc) && typeof doc.version == 'string' && doc.version.startsWith('https://jsonfeed.org/version/') && Array.isArray(doc.items);
|
|
36
|
+
const inReplyTo = (item) => isObject(item._source) && typeof item._source.inReplyTo == 'string' ? item._source.inReplyTo : undefined;
|
|
37
|
+
/** Stores Markdown in `_source.markdown` (RFC-1), with `content_text` as the fallback JSON Feed requires. */
|
|
38
|
+
function setMarkdown(item, markdown) {
|
|
39
|
+
const { markdown: _old, ...source } = isObject(item._source) ? item._source : {};
|
|
40
|
+
item._source = markdown === null ? source : { about: RFC1_URL, ...source, markdown };
|
|
41
|
+
if (markdown !== null && item.content_html === undefined)
|
|
42
|
+
item.content_text = markdown;
|
|
43
|
+
}
|
|
44
|
+
function checkContent(item) {
|
|
45
|
+
if (item.content_html === undefined && item.content_text === undefined)
|
|
46
|
+
throw new PupsError('invalid_request', 'A comment needs content_html, content_text or markdown (JSON Feed requires content).');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The owner's RFC-4 submissions (comments, and posts to discussion groups), kept in comment feeds in the app's own
|
|
50
|
+
* directory, never in the owner's main feed (RFC-7 "Comment feeds"): one file per target site and hour,
|
|
51
|
+
* `/appdata/<client-host>/comments/<hash3>/<hash>.json`. Needs the `appdata` scope. Use `session.comments`.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* const { source, submission } = await session.comments.post({ target: 'https://rm.example.org/groups/twowaves/posts.json#a8Kd03XpQz', markdown: 'Agreed!' })
|
|
55
|
+
* const status = await session.mentions.submissionStatus(submission!.statusUrl!)
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export class PupsComments {
|
|
59
|
+
#session;
|
|
60
|
+
constructor(session) {
|
|
61
|
+
this.#session = session;
|
|
62
|
+
}
|
|
63
|
+
/** The path of the comment feed for a comment on `target` published at `date`. */
|
|
64
|
+
async pathFor(target, date) {
|
|
65
|
+
return `${this.#session.appDataPath}comments/${await commentFeedPath(target, date)}`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Publishes a comment: adds it at the top of its comment feed, which is created if needed, and submits it to the
|
|
69
|
+
* target, once it is visible at its public URL.
|
|
70
|
+
* @throws {PupsError} `invalid_request` for a bad target or missing content; `invalid_feed` if the file holds
|
|
71
|
+
* something else; the errors of writing.
|
|
72
|
+
*/
|
|
73
|
+
async post(input, options = {}) {
|
|
74
|
+
const { target, markdown, ...fields } = input;
|
|
75
|
+
const item = { id: randomString(12), ...fields, date_published: now() };
|
|
76
|
+
item._source = { about: RFC1_URL, ...isObject(item._source) ? item._source : {}, inReplyTo: target };
|
|
77
|
+
if (markdown !== undefined)
|
|
78
|
+
setMarkdown(item, markdown);
|
|
79
|
+
checkContent(item);
|
|
80
|
+
const path = await this.pathFor(target, item.date_published);
|
|
81
|
+
const feedUrl = this.#session.publicUrl(path);
|
|
82
|
+
await this.#session.update(path, async (file) => {
|
|
83
|
+
const doc = file ? await this.#feed(file.json(), path) : this.#newFeed(feedUrl);
|
|
84
|
+
return { ...doc, items: [item, ...doc.items] };
|
|
85
|
+
}, { contentType: 'application/feed+json', signal: options.signal });
|
|
86
|
+
return this.#result(feedUrl, path, item, options);
|
|
87
|
+
}
|
|
88
|
+
/** A comment, given by its `source`; undefined if its feed or the item doesn't exist. */
|
|
89
|
+
async get(source, options = {}) {
|
|
90
|
+
const { path, id } = this.#parse(source);
|
|
91
|
+
const file = await this.#session.get(path, options);
|
|
92
|
+
const item = file ? (await this.#feed(file.json(), path)).items.find(i => i.id == id) : undefined;
|
|
93
|
+
return item && { source, path, item };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Changes a comment in its comment feed, keeping `id`, `date_published` and the target, sets `date_modified`, and
|
|
97
|
+
* submits it again with the same `source`. RFC-4 servers apply it only if the target allows edits.
|
|
98
|
+
* @throws {PupsError} `not_found` if the comment doesn't exist.
|
|
99
|
+
*/
|
|
100
|
+
async edit(source, changes, options = {}) {
|
|
101
|
+
const { path, id } = this.#parse(source);
|
|
102
|
+
let changed;
|
|
103
|
+
await this.#session.update(path, async (file) => {
|
|
104
|
+
const doc = file ? await this.#feed(file.json(), path) : undefined;
|
|
105
|
+
const current = doc?.items.find(i => i.id == id);
|
|
106
|
+
if (!doc || !current)
|
|
107
|
+
throw new PupsError('not_found', `There is no comment ${source}.`);
|
|
108
|
+
changed = this.#change(structuredClone(current), changes);
|
|
109
|
+
return { ...doc, items: doc.items.map(i => i.id == id ? changed : i) };
|
|
110
|
+
}, { contentType: 'application/feed+json', signal: options.signal });
|
|
111
|
+
return this.#result(source.slice(0, source.indexOf('#')), path, changed, options);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Removes a comment from its comment feed, deletes the file once it is empty, and submits again with the same
|
|
115
|
+
* `source`, so that the RFC-4 server deletes the republished comment if the target allows it.
|
|
116
|
+
* @throws {PupsError} `not_found` if the comment doesn't exist.
|
|
117
|
+
*/
|
|
118
|
+
async delete(source, options = {}) {
|
|
119
|
+
const { path, id } = this.#parse(source);
|
|
120
|
+
for (let attempt = 1;; attempt++) {
|
|
121
|
+
const file = await this.#session.get(path, options);
|
|
122
|
+
const doc = file ? await this.#feed(file.json(), path) : undefined;
|
|
123
|
+
const item = doc?.items.find(i => i.id == id);
|
|
124
|
+
if (!file || !doc || !item)
|
|
125
|
+
throw new PupsError('not_found', `There is no comment ${source}.`);
|
|
126
|
+
const items = doc.items.filter(i => i.id != id);
|
|
127
|
+
try {
|
|
128
|
+
if (items.length)
|
|
129
|
+
await this.#session.replace(path, { ...doc, items }, file.etag, { contentType: 'application/feed+json', signal: options.signal });
|
|
130
|
+
else
|
|
131
|
+
await this.#session.delete(path, { ifMatch: file.etag, signal: options.signal });
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
if (isPupsError(e, 'precondition_failed') && attempt < 5)
|
|
135
|
+
continue;
|
|
136
|
+
throw e;
|
|
137
|
+
}
|
|
138
|
+
return this.#result(source.slice(0, source.indexOf('#')), path, item, options, true);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Submits a comment to its target (RFC-4 "Submitting"), e.g. again after a failure. Waits until its feed shows the
|
|
143
|
+
* comment as it is now, or no longer shows it after a delete, so that the server doesn't fetch an older copy.
|
|
144
|
+
*/
|
|
145
|
+
async submit(source, target, options = {}) {
|
|
146
|
+
const mentions = this.#session.mentions;
|
|
147
|
+
const { id } = this.#parse(source);
|
|
148
|
+
await mentions.waitForItem(source.slice(0, source.indexOf('#')), id, item => options.deleted ? !item : !!item, options);
|
|
149
|
+
return mentions.submit(source, target, options);
|
|
150
|
+
}
|
|
151
|
+
async #result(feedUrl, path, item, options, deleted = false) {
|
|
152
|
+
const source = `${feedUrl}#${encodeURIComponent(item.id)}`;
|
|
153
|
+
const target = inReplyTo(item);
|
|
154
|
+
const submission = options.submit ?? true
|
|
155
|
+
? target && await this.submit(source, target, { signal: options.signal, deleted })
|
|
156
|
+
: undefined;
|
|
157
|
+
return { source, path, item, ...submission ? { submission } : {} };
|
|
158
|
+
}
|
|
159
|
+
#newFeed(feedUrl) {
|
|
160
|
+
const host = new URL(this.#session.me).hostname;
|
|
161
|
+
return {
|
|
162
|
+
version: JSON_FEED,
|
|
163
|
+
title: `Comments by ${host}`,
|
|
164
|
+
home_page_url: `https://${host}/`,
|
|
165
|
+
feed_url: feedUrl,
|
|
166
|
+
_source: { about: RFC1_URL, accounts: { socialspec: `@${host}` } },
|
|
167
|
+
items: [],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
async #feed(json, path) {
|
|
171
|
+
const doc = await json.catch(() => undefined);
|
|
172
|
+
if (!isFeed(doc))
|
|
173
|
+
throw new PupsError('invalid_feed', `${path} is not a JSON Feed.`);
|
|
174
|
+
return doc;
|
|
175
|
+
}
|
|
176
|
+
#change(item, changes) {
|
|
177
|
+
const { id, date_published } = item;
|
|
178
|
+
const target = inReplyTo(item);
|
|
179
|
+
if (typeof changes == 'function')
|
|
180
|
+
item = changes(item);
|
|
181
|
+
else
|
|
182
|
+
for (const [key, value] of Object.entries(changes)) {
|
|
183
|
+
if (key == 'markdown')
|
|
184
|
+
value !== undefined && setMarkdown(item, value);
|
|
185
|
+
else if (value === null)
|
|
186
|
+
delete item[key];
|
|
187
|
+
else if (value !== undefined)
|
|
188
|
+
item[key] = value;
|
|
189
|
+
}
|
|
190
|
+
checkContent(item);
|
|
191
|
+
// The comment stays the same submission: same id, date, target and therefore file.
|
|
192
|
+
const source = isObject(item._source) ? item._source : {};
|
|
193
|
+
return { ...item, id, date_published, _source: { ...source, inReplyTo: target }, date_modified: now() };
|
|
194
|
+
}
|
|
195
|
+
#parse(source) {
|
|
196
|
+
const at = source.indexOf('#');
|
|
197
|
+
const path = at > 0 ? pathFromPublicUrl(this.#session.server, source.slice(0, at)) : undefined;
|
|
198
|
+
if (!path || !path.startsWith(`${this.#session.appDataPath}comments/`))
|
|
199
|
+
throw new PupsError('invalid_request', `${source} is not a comment in this app's comment feeds.`);
|
|
200
|
+
return { path, id: decodeURIComponent(source.slice(at + 1)) };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../src/comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAElD,MAAM,QAAQ,GAAG,8EAA8E,CAAA;AAC/F,MAAM,SAAS,GAAG,kCAAkC,CAAA;AAuCpD,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;AAEpE,KAAK,UAAU,SAAS,CAAC,IAAY;IACnC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACpG,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC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CAAA;qBACjE,IAAI,KAAK,KAAK,SAAS;oBAAG,IAAgC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;YAC9E,CAAC;QACD,YAAY,CAAC,IAAI,CAAC,CAAA;QAClB,mFAAmF;QACnF,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;QACzD,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,CAAA;IACzG,CAAC;IAED,MAAM,CAAC,MAAc;QACnB,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC9B,MAAM,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QAC9F,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,WAAW,CAAC;YACpE,MAAM,IAAI,SAAS,CAAC,iBAAiB,EAAE,GAAG,MAAM,gDAAgD,CAAC,CAAA;QACnG,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/D,CAAC;CACF"}
|
package/dist/discovery.d.ts
CHANGED
|
@@ -40,6 +40,11 @@ export interface PupsServer {
|
|
|
40
40
|
* (RFC-6 "Built-in receiver"). Feeds opt in with `feed.enableComments()`.
|
|
41
41
|
*/
|
|
42
42
|
commentEndpoint?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the server keeps feeds with the RFC-7 marker (`kept_feeds`): it writes their archives, and takes single
|
|
45
|
+
* items by POST. `PupsFeed` needs it to post.
|
|
46
|
+
*/
|
|
47
|
+
keptFeeds: boolean;
|
|
43
48
|
maxUploadBytes: number;
|
|
44
49
|
specVersion: string;
|
|
45
50
|
/** The configuration document as fetched, including fields this library doesn't know. */
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAGA,wHAAwH;AACxH,eAAO,MAAM,QAAQ,4CAA4C,CAAA;AAEjE,yDAAyD;AACzD,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAAY,CAAA;AAIjE,iEAAiE;AACjE,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAA;IACZ,wFAAwF;IACxF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,4EAA4E;IAC5E,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,0EAA0E;IAC1E,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,uFAAuF;IACvF,cAAc,EAAE,MAAM,EAAE,CAAA;CACzB;AAED,wHAAwH;AACxH,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAA;IACd,yGAAyG;IACzG,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,qBAAqB,EAAE,MAAM,CAAA;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAA;IACnB,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,cAAc,EAAE,aAAa,EAAE,CAAA;IAC/B,6EAA6E;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AyG;IACzG,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,qBAAqB,EAAE,MAAM,CAAA;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAA;IACnB,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,cAAc,EAAE,aAAa,EAAE,CAAA;IAC/B,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,yFAAyF;IACzF,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUrD;AAoBD;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAmB/G;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,UAAU,CAmE9F"}
|
package/dist/discovery.js
CHANGED
|
@@ -133,6 +133,7 @@ export function parseConfig(json, domain, identityHosts) {
|
|
|
133
133
|
...hostMetaEndpoint ? { hostMetaEndpoint } : {},
|
|
134
134
|
...postEndpoint ? { postEndpoint } : {},
|
|
135
135
|
...commentEndpoint ? { commentEndpoint } : {},
|
|
136
|
+
keptFeeds: raw.kept_feeds === true,
|
|
136
137
|
maxUploadBytes: maxUploadBytes,
|
|
137
138
|
specVersion,
|
|
138
139
|
raw,
|
package/dist/discovery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEtD,wHAAwH;AACxH,MAAM,CAAC,MAAM,QAAQ,GAAG,yCAAyC,CAAA;AAEjE,yDAAyD;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAsB,CAAC,KAAK,CAAC,CAAA;AAEjE,MAAM,kBAAkB,GAAG,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEtD,wHAAwH;AACxH,MAAM,CAAC,MAAM,QAAQ,GAAG,yCAAyC,CAAA;AAEjE,yDAAyD;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAsB,CAAC,KAAK,CAAC,CAAA;AAEjE,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAoDjC;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC5B,MAAM,GAAG,GAAG,QAAQ,CAAC,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,OAAO,EAAE,CAAC,CAAA;IAC/F,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,QAAQ,IA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Ac,EAAE,cAAwB;QACxC,WAAW;QACX,GAAG;KACJ,CAAA;AACH,CAAC"}
|
package/dist/errors.js
CHANGED
|
@@ -48,7 +48,7 @@ export async function errorFromResponse(response, what) {
|
|
|
48
48
|
const serverMessage = typeof body.message == 'string' ? body.message : undefined;
|
|
49
49
|
const code = status == 400
|
|
50
50
|
? serverError == 'invalid_path' ? 'invalid_path' : 'invalid_request'
|
|
51
|
-
: statusCodes[status] ?? 'server_error';
|
|
51
|
+
: serverError == 'not_pups_controlled' ? serverError : statusCodes[status] ?? 'server_error';
|
|
52
52
|
const retryAfterHeader = Number(response.headers.get('Retry-After'));
|
|
53
53
|
return new PupsError(code, `${what} failed with HTTP ${status}${serverMessage ? `: ${serverMessage}` : ''}`, {
|
|
54
54
|
status,
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAkEA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;AAS1F,iDAAiD;AACjD,MAAM,OAAO,SAAU,SAAQ,KAAK;IAChB,IAAI,GAAG,WAAW,CAAA;IACpC,kDAAkD;IACzC,IAAI,CAAe;IAC5B,uDAAuD;IAC9C,MAAM,CAAS;IACxB,wGAAwG;IAC/F,aAAa,CAAS;IAC/B,oEAAoE;IAC3D,UAAU,CAAS;IAC5B,2GAA2G;IAClG,SAAS,CAAS;IAE3B,YAAY,IAAmB,EAAE,OAAe,EAAE,UAA4B,EAAE;QAC9E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QAClF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,OAA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