@pkcprotocol/pkc-js 0.0.80 → 0.0.82
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 +3 -1
- package/dist/browser/clients/base-client-manager.js +19 -1
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +1 -0
- package/dist/browser/clients/rpc-client/schema.d.ts +3 -0
- package/dist/browser/community/schema.d.ts +24 -0
- package/dist/browser/community/schema.js +6 -1
- package/dist/browser/community/schema.js.map +1 -1
- package/dist/browser/errors.d.ts +10 -1
- package/dist/browser/errors.js +10 -1
- package/dist/browser/errors.js.map +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/pages/pages.js +8 -0
- package/dist/browser/pages/pages.js.map +1 -1
- package/dist/browser/pages/schema.d.ts +4 -0
- package/dist/browser/pages/util.d.ts +2 -0
- package/dist/browser/pages/util.js +23 -3
- package/dist/browser/pages/util.js.map +1 -1
- package/dist/browser/pkc/pkc.d.ts +3 -2
- package/dist/browser/pkc/pkc.js +37 -24
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/publications/comment/comment-client-manager.js +22 -4
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/browser/publications/comment/comment.d.ts +2 -1
- package/dist/browser/publications/comment/comment.js +29 -6
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/publications/comment/crosspost-depth.d.ts +5 -0
- package/dist/browser/publications/comment/crosspost-depth.js +75 -0
- package/dist/browser/publications/comment/crosspost-depth.js.map +1 -0
- package/dist/browser/publications/comment/crosspost-runtime.d.ts +30 -0
- package/dist/browser/publications/comment/crosspost-runtime.js +133 -0
- package/dist/browser/publications/comment/crosspost-runtime.js.map +1 -0
- package/dist/browser/publications/comment/schema.d.ts +20 -2
- package/dist/browser/publications/comment/schema.js +21 -10
- package/dist/browser/publications/comment/schema.js.map +1 -1
- package/dist/browser/publications/comment/types.d.ts +10 -0
- package/dist/browser/publications/community-edit/schema.d.ts +4 -0
- package/dist/browser/publications/publication.d.ts +4 -0
- package/dist/browser/publications/publication.js +80 -5
- package/dist/browser/publications/publication.js.map +1 -1
- package/dist/browser/pubsub-messages/schema.d.ts +5 -0
- package/dist/browser/rpc/src/index.js +14 -2
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/runtime/browser/setup-kubo-http-routers.d.ts +1 -0
- package/dist/browser/runtime/browser/setup-kubo-http-routers.js +4 -0
- package/dist/browser/runtime/browser/setup-kubo-http-routers.js.map +1 -0
- package/dist/browser/runtime/node/community/db-handler.js +3 -2
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-validation.js +15 -0
- package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.d.ts +3 -2
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js +19 -10
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/browser/runtime/node/community/page-generator.d.ts +2 -0
- package/dist/browser/runtime/node/setup-kubo-http-routers.d.ts +2 -0
- package/dist/browser/runtime/node/{setup-kubo-address-rewriter-and-http-router.js → setup-kubo-http-routers.js} +54 -112
- package/dist/browser/runtime/node/setup-kubo-http-routers.js.map +1 -0
- package/dist/browser/schema/schema-util.d.ts +17 -0
- package/dist/browser/schema/schema-util.js +49 -5
- package/dist/browser/schema/schema-util.js.map +1 -1
- package/dist/browser/signer/signatures.d.ts +1 -10
- package/dist/browser/signer/signatures.js +83 -0
- package/dist/browser/signer/signatures.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +6 -0
- package/dist/browser/util.d.ts +3 -4
- package/dist/browser/util.js +7 -3
- package/dist/browser/util.js.map +1 -1
- package/dist/browser/version.js +1 -1
- package/dist/bundled/bundle-manifest.json +78 -93
- package/dist/bundled/chunks/{helia-for-pkc-BsYWQ7qS.js → helia-for-pkc-CQY3-UYD.js} +31 -31
- package/dist/bundled/chunks/{local-community-EqWKTLxr.js → local-community-AZAEiiht.js} +1 -1
- package/dist/bundled/chunks/{local-community-CHzhypCp.js → local-community-DRm3r1-Y.js} +16 -6
- package/dist/bundled/chunks/{node-4qAZNuJG.js → node-B1J8psGZ.js} +380 -2372
- package/dist/bundled/chunks/{rpc-local-community-Cog5rZLG.js → rpc-local-community-0XmKyOdO.js} +298 -580
- package/dist/bundled/chunks/{schema-Iavj-cRD.js → schema-BUUhufdT.js} +26 -11
- package/dist/bundled/chunks/{util-CfSUfLkV.js → util-Cct7-RT3.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +13 -5
- package/dist/node/clients/base-client-manager.js +19 -1
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +1 -0
- package/dist/node/clients/rpc-client/schema.d.ts +3 -0
- package/dist/node/community/schema.d.ts +24 -0
- package/dist/node/community/schema.js +6 -1
- package/dist/node/community/schema.js.map +1 -1
- package/dist/node/errors.d.ts +10 -1
- package/dist/node/errors.js +10 -1
- package/dist/node/errors.js.map +1 -1
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/pages/pages.js +8 -0
- package/dist/node/pages/pages.js.map +1 -1
- package/dist/node/pages/schema.d.ts +4 -0
- package/dist/node/pages/util.d.ts +2 -0
- package/dist/node/pages/util.js +23 -3
- package/dist/node/pages/util.js.map +1 -1
- package/dist/node/pkc/pkc.d.ts +3 -2
- package/dist/node/pkc/pkc.js +37 -24
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/publications/comment/comment-client-manager.js +22 -4
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/node/publications/comment/comment.d.ts +2 -1
- package/dist/node/publications/comment/comment.js +29 -6
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/publications/comment/crosspost-depth.d.ts +5 -0
- package/dist/node/publications/comment/crosspost-depth.js +75 -0
- package/dist/node/publications/comment/crosspost-depth.js.map +1 -0
- package/dist/node/publications/comment/crosspost-runtime.d.ts +30 -0
- package/dist/node/publications/comment/crosspost-runtime.js +133 -0
- package/dist/node/publications/comment/crosspost-runtime.js.map +1 -0
- package/dist/node/publications/comment/schema.d.ts +20 -2
- package/dist/node/publications/comment/schema.js +21 -10
- package/dist/node/publications/comment/schema.js.map +1 -1
- package/dist/node/publications/comment/types.d.ts +10 -0
- package/dist/node/publications/community-edit/schema.d.ts +4 -0
- package/dist/node/publications/publication.d.ts +4 -0
- package/dist/node/publications/publication.js +80 -5
- package/dist/node/publications/publication.js.map +1 -1
- package/dist/node/pubsub-messages/schema.d.ts +5 -0
- package/dist/node/rpc/src/index.js +14 -2
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/runtime/browser/setup-kubo-http-routers.d.ts +1 -0
- package/dist/node/runtime/browser/setup-kubo-http-routers.js +4 -0
- package/dist/node/runtime/browser/setup-kubo-http-routers.js.map +1 -0
- package/dist/node/runtime/node/community/db-handler.js +3 -2
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-validation.js +15 -0
- package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.d.ts +3 -2
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js +19 -10
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/node/runtime/node/community/page-generator.d.ts +2 -0
- package/dist/node/runtime/node/setup-kubo-http-routers.d.ts +2 -0
- package/dist/node/runtime/node/{setup-kubo-address-rewriter-and-http-router.js → setup-kubo-http-routers.js} +54 -112
- package/dist/node/runtime/node/setup-kubo-http-routers.js.map +1 -0
- package/dist/node/schema/schema-util.d.ts +17 -0
- package/dist/node/schema/schema-util.js +49 -5
- package/dist/node/schema/schema-util.js.map +1 -1
- package/dist/node/signer/signatures.d.ts +1 -10
- package/dist/node/signer/signatures.js +83 -0
- package/dist/node/signer/signatures.js.map +1 -1
- package/dist/node/test/test-util.d.ts +6 -0
- package/dist/node/util.d.ts +3 -4
- package/dist/node/util.js +7 -3
- package/dist/node/util.js.map +1 -1
- package/dist/node/version.js +1 -1
- package/package.json +2 -2
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts +0 -1
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js +0 -4
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map +0 -1
- package/dist/browser/runtime/node/address-rewriter-db.d.ts +0 -33
- package/dist/browser/runtime/node/address-rewriter-db.js +0 -156
- package/dist/browser/runtime/node/address-rewriter-db.js.map +0 -1
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.d.ts +0 -47
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js +0 -534
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js.map +0 -1
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts +0 -4
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +0 -1
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts +0 -1
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js +0 -4
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map +0 -1
- package/dist/node/runtime/node/address-rewriter-db.d.ts +0 -33
- package/dist/node/runtime/node/address-rewriter-db.js +0 -156
- package/dist/node/runtime/node/address-rewriter-db.js.map +0 -1
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.d.ts +0 -47
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js +0 -534
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js.map +0 -1
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts +0 -4
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +0 -1
- package/dist/bundled/chunks/{src-BEjAH2gY.js → src-WLgFbUwZ.js} +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Runtime handling of comment.crosspost. See docs/protocol/crossposts.md and issue #251.
|
|
2
|
+
//
|
|
3
|
+
// crosspost.cid hashes the embedded record whole, so the record a Comment instance exposes cannot be
|
|
4
|
+
// the same object the wire carries: writing a runtime field onto it would stop it reproducing its own
|
|
5
|
+
// cid, break page generation and get the comment purged by the signature sweep.
|
|
6
|
+
//
|
|
7
|
+
// So comment.crosspost is a copy of the spine — one shallow copy per chain level plus a copy of each
|
|
8
|
+
// level's author — while comment.raw.comment.crosspost stays exactly what was signed. Everything
|
|
9
|
+
// below an author (signature, flairs, avatar) is shared by reference, since nothing mutates it.
|
|
10
|
+
//
|
|
11
|
+
// The only runtime field written into the copy is author.nameResolved. Deliberately not address,
|
|
12
|
+
// publicKey or shortAddress, which the Comment's own author gets: those would have to be stripped
|
|
13
|
+
// again before the record could be republished as a crosspost, and stripping is not safely reversible
|
|
14
|
+
// on a record whose author legitimately carries `address` (old wire format). One field that is never
|
|
15
|
+
// legitimate on the wire, and is already rejected by check 3 of _verifyCrosspost if it arrives there,
|
|
16
|
+
// is reversible by deletion alone.
|
|
17
|
+
import { getAuthorNameFromWire } from "../publication-author.js";
|
|
18
|
+
import { MAX_CROSSPOST_DEPTH } from "./crosspost-depth.js";
|
|
19
|
+
import { sha256 } from "js-sha256";
|
|
20
|
+
// Walks the chain into an array, outermost first. Iterative rather than recursive: chain depth is
|
|
21
|
+
// attacker-controlled, and while verified records are capped at MAX_CROSSPOST_DEPTH (issue #250),
|
|
22
|
+
// nothing here should depend on that cap having already been enforced.
|
|
23
|
+
function _chainOf(crosspost) {
|
|
24
|
+
const chain = [];
|
|
25
|
+
for (let level = crosspost; level; level = level.comment.crosspost)
|
|
26
|
+
chain.push(level);
|
|
27
|
+
return chain;
|
|
28
|
+
}
|
|
29
|
+
export function cloneCrosspostForRuntime(crosspost) {
|
|
30
|
+
const chain = _chainOf(crosspost);
|
|
31
|
+
let child;
|
|
32
|
+
// Innermost first, so each level can point at the copy of the one below it.
|
|
33
|
+
for (let i = chain.length - 1; i >= 0; i--) {
|
|
34
|
+
const level = chain[i];
|
|
35
|
+
const comment = { ...level.comment };
|
|
36
|
+
if (level.comment.author)
|
|
37
|
+
comment.author = { ...level.comment.author };
|
|
38
|
+
// `child` is defined exactly when this level had a nested crosspost, so this preserves
|
|
39
|
+
// absence rather than writing an explicit undefined.
|
|
40
|
+
if (child)
|
|
41
|
+
comment.crosspost = child;
|
|
42
|
+
child = { cid: level.cid, comment };
|
|
43
|
+
}
|
|
44
|
+
return child;
|
|
45
|
+
}
|
|
46
|
+
// The authors this comment should trigger background name resolution for: every level of the chain.
|
|
47
|
+
//
|
|
48
|
+
// A chain is attacker-controlled in both depth and content (#249), but not in cost: #250 caps
|
|
49
|
+
// verified chains at MAX_CROSSPOST_DEPTH in schema-util.ts, before anything here runs, so a fetched
|
|
50
|
+
// comment is worth at most that many names. resolveAuthorNamesInBackground then hands them to the
|
|
51
|
+
// resolver concurrently, and a batching resolver (bso-resolver coalesces concurrent resolves into
|
|
52
|
+
// one Multicall3.aggregate3 eth_call) turns the whole chain into a single round trip. A verdict at
|
|
53
|
+
// only the first level would leave every deeper "originally by <name>" unrendered, which is the
|
|
54
|
+
// impersonation signal #251 exists to give clients.
|
|
55
|
+
//
|
|
56
|
+
// Kept as a named constant, and as an overridable param, so a caller resolving many chains at once
|
|
57
|
+
// can still bound itself.
|
|
58
|
+
export const CROSSPOST_LEVELS_TO_RESOLVE_AUTHOR_NAMES_FOR = MAX_CROSSPOST_DEPTH;
|
|
59
|
+
export function collectCrosspostAuthorsToResolve({ crosspost, maxLevels = CROSSPOST_LEVELS_TO_RESOLVE_AUTHOR_NAMES_FOR }) {
|
|
60
|
+
const authors = [];
|
|
61
|
+
const chain = _chainOf(crosspost).slice(0, maxLevels);
|
|
62
|
+
for (const level of chain) {
|
|
63
|
+
if (typeof level.comment.author?.nameResolved === "boolean")
|
|
64
|
+
continue;
|
|
65
|
+
const authorName = getAuthorNameFromWire(level.comment.author);
|
|
66
|
+
if (!authorName)
|
|
67
|
+
continue;
|
|
68
|
+
authors.push({ authorName, signaturePublicKey: level.comment.signature.publicKey });
|
|
69
|
+
}
|
|
70
|
+
return authors;
|
|
71
|
+
}
|
|
72
|
+
// Applies whatever the cache already knows to every level. Returns true if any level changed, so
|
|
73
|
+
// callers can decide whether an "update" event is warranted.
|
|
74
|
+
export function applyNameResolvedCacheToCrosspost({ crosspost, cache }) {
|
|
75
|
+
let changed = false;
|
|
76
|
+
for (const level of _chainOf(crosspost)) {
|
|
77
|
+
const author = level.comment.author;
|
|
78
|
+
if (!author)
|
|
79
|
+
continue;
|
|
80
|
+
const authorName = getAuthorNameFromWire(author);
|
|
81
|
+
if (!authorName)
|
|
82
|
+
continue;
|
|
83
|
+
const cached = cache.get(sha256(authorName + level.comment.signature.publicKey));
|
|
84
|
+
if (typeof cached !== "boolean" || author.nameResolved === cached)
|
|
85
|
+
continue;
|
|
86
|
+
author.nameResolved = cached;
|
|
87
|
+
changed = true;
|
|
88
|
+
}
|
|
89
|
+
return changed;
|
|
90
|
+
}
|
|
91
|
+
function _buildCrosspostRuntimeFields(crosspost, nameResolvedOf) {
|
|
92
|
+
const chain = _chainOf(crosspost);
|
|
93
|
+
let child;
|
|
94
|
+
let anyLevelHasAVerdict = false;
|
|
95
|
+
// Innermost first. A level with no verdict of its own is still emitted when something below it
|
|
96
|
+
// has one, because the nesting is the path deepMergeRuntimeFields walks.
|
|
97
|
+
for (let i = chain.length - 1; i >= 0; i--) {
|
|
98
|
+
const nameResolved = nameResolvedOf(chain[i]);
|
|
99
|
+
if (nameResolved === undefined && !child)
|
|
100
|
+
continue;
|
|
101
|
+
const comment = {};
|
|
102
|
+
if (nameResolved !== undefined) {
|
|
103
|
+
comment.author = { nameResolved };
|
|
104
|
+
anyLevelHasAVerdict = true;
|
|
105
|
+
}
|
|
106
|
+
if (child)
|
|
107
|
+
comment.crosspost = child;
|
|
108
|
+
child = { comment };
|
|
109
|
+
}
|
|
110
|
+
return anyLevelHasAVerdict ? child : undefined;
|
|
111
|
+
}
|
|
112
|
+
export function buildCrosspostRuntimeFieldsFromCache({ crosspost, cache }) {
|
|
113
|
+
return _buildCrosspostRuntimeFields(crosspost, (level) => {
|
|
114
|
+
const authorName = getAuthorNameFromWire(level.comment.author);
|
|
115
|
+
if (!authorName)
|
|
116
|
+
return undefined;
|
|
117
|
+
const cached = cache.get(sha256(authorName + level.comment.signature.publicKey));
|
|
118
|
+
return typeof cached === "boolean" ? cached : undefined;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
export function extractCrosspostRuntimeFields(crosspost) {
|
|
122
|
+
return _buildCrosspostRuntimeFields(crosspost, (level) => typeof level.comment.author?.nameResolved === "boolean" ? level.comment.author.nameResolved : undefined);
|
|
123
|
+
}
|
|
124
|
+
// nameResolved is strictly runtime and never on the wire, so it must not ride along into a record
|
|
125
|
+
// that is about to be signed, stored or rehashed. Mirrors the `delete instance.author.nameResolved`
|
|
126
|
+
// the Comment's own author already gets in pkc.ts.
|
|
127
|
+
export function stripNameResolvedFromCrosspost(crosspost) {
|
|
128
|
+
for (const level of _chainOf(crosspost)) {
|
|
129
|
+
if (level.comment.author?.nameResolved !== undefined)
|
|
130
|
+
delete level.comment.author.nameResolved;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=crosspost-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crosspost-runtime.js","sourceRoot":"","sources":["../../../../src/publications/comment/crosspost-runtime.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,EAAE;AACF,qGAAqG;AACrG,sGAAsG;A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ost {
|
|
4
|
+
cid: string;
|
|
5
|
+
comment: Omit<CommentIpfsType, "crosspost"> & {
|
|
6
|
+
crosspost?: Crosspost;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
2
9
|
export declare const CreateCommentOptionsSchema: z.ZodObject<{
|
|
3
10
|
flairs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4
11
|
text: z.ZodString;
|
|
@@ -17,6 +24,7 @@ export declare const CreateCommentOptionsSchema: z.ZodObject<{
|
|
|
17
24
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
18
25
|
postCid: z.ZodOptional<z.ZodString>;
|
|
19
26
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
20
28
|
signer: z.ZodObject<{
|
|
21
29
|
type: z.ZodEnum<{
|
|
22
30
|
ed25519: "ed25519";
|
|
@@ -80,6 +88,7 @@ export declare const CreateCommentOptionsWithRefinementSchema: z.ZodObject<{
|
|
|
80
88
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
81
89
|
postCid: z.ZodOptional<z.ZodString>;
|
|
82
90
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
91
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
83
92
|
signer: z.ZodObject<{
|
|
84
93
|
type: z.ZodEnum<{
|
|
85
94
|
ed25519: "ed25519";
|
|
@@ -125,7 +134,7 @@ export declare const CreateCommentOptionsWithRefinementSchema: z.ZodObject<{
|
|
|
125
134
|
challengeCommentCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
126
135
|
}, z.core.$strip>>;
|
|
127
136
|
}, z.core.$strict>;
|
|
128
|
-
export declare const CommentSignedPropertyNames: ("timestamp" | "flairs" | "author" | "communityPublicKey" | "communityName" | "protocolVersion" | "link" | "spoiler" | "nsfw" | "content" | "title" | "linkWidth" | "linkHeight" | "linkHtmlTagName" | "parentCid" | "postCid" | "quotedCids")[];
|
|
137
|
+
export declare const CommentSignedPropertyNames: ("timestamp" | "flairs" | "author" | "communityPublicKey" | "communityName" | "protocolVersion" | "link" | "spoiler" | "nsfw" | "content" | "title" | "linkWidth" | "linkHeight" | "linkHtmlTagName" | "parentCid" | "postCid" | "quotedCids" | "crosspost")[];
|
|
129
138
|
export declare const CommentPubsubMessagePublicationSchema: z.ZodObject<{
|
|
130
139
|
timestamp: z.ZodNumber;
|
|
131
140
|
signature: z.ZodObject<{
|
|
@@ -183,6 +192,7 @@ export declare const CommentPubsubMessagePublicationSchema: z.ZodObject<{
|
|
|
183
192
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
184
193
|
postCid: z.ZodOptional<z.ZodString>;
|
|
185
194
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
195
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
186
196
|
}, z.core.$strict>;
|
|
187
197
|
export declare const CommentPubsubMessageWithFlexibleAuthorSchema: z.ZodObject<{
|
|
188
198
|
timestamp: z.ZodNumber;
|
|
@@ -212,6 +222,7 @@ export declare const CommentPubsubMessageWithFlexibleAuthorSchema: z.ZodObject<{
|
|
|
212
222
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
213
223
|
postCid: z.ZodOptional<z.ZodString>;
|
|
214
224
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
225
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
215
226
|
author: z.ZodOptional<z.ZodObject<{
|
|
216
227
|
name: z.ZodOptional<z.ZodString>;
|
|
217
228
|
previousCommentCid: z.ZodOptional<z.ZodString>;
|
|
@@ -270,6 +281,7 @@ export declare const CommentPubsubMessageWithFlexibleAuthorRefinementSchema: z.Z
|
|
|
270
281
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
271
282
|
postCid: z.ZodOptional<z.ZodString>;
|
|
272
283
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
284
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
273
285
|
author: z.ZodOptional<z.ZodObject<{
|
|
274
286
|
name: z.ZodOptional<z.ZodString>;
|
|
275
287
|
previousCommentCid: z.ZodOptional<z.ZodString>;
|
|
@@ -357,6 +369,7 @@ export declare const CommentPubsubMessageWithRefinementSchema: z.ZodObject<{
|
|
|
357
369
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
358
370
|
postCid: z.ZodOptional<z.ZodString>;
|
|
359
371
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
372
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
360
373
|
}, z.core.$strict>;
|
|
361
374
|
export declare const CommentChallengeRequestToEncryptSchema: z.ZodObject<{
|
|
362
375
|
challengeAnswers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -389,6 +402,7 @@ export declare const CommentChallengeRequestToEncryptSchema: z.ZodObject<{
|
|
|
389
402
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
390
403
|
postCid: z.ZodOptional<z.ZodString>;
|
|
391
404
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
405
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
392
406
|
author: z.ZodOptional<z.ZodObject<{
|
|
393
407
|
name: z.ZodOptional<z.ZodString>;
|
|
394
408
|
previousCommentCid: z.ZodOptional<z.ZodString>;
|
|
@@ -448,6 +462,7 @@ export declare const CommentIpfsSchema: z.ZodObject<{
|
|
|
448
462
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
449
463
|
postCid: z.ZodOptional<z.ZodString>;
|
|
450
464
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
465
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
451
466
|
author: z.ZodOptional<z.ZodObject<{
|
|
452
467
|
name: z.ZodOptional<z.ZodString>;
|
|
453
468
|
previousCommentCid: z.ZodOptional<z.ZodString>;
|
|
@@ -488,7 +503,7 @@ export declare const CommentIpfsSchema: z.ZodObject<{
|
|
|
488
503
|
"per-author": "per-author";
|
|
489
504
|
}>>;
|
|
490
505
|
}, z.core.$strict>;
|
|
491
|
-
export declare const
|
|
506
|
+
export declare const CommentIpfsWithRefinementSchema: z.ZodObject<{
|
|
492
507
|
timestamp: z.ZodNumber;
|
|
493
508
|
signature: z.ZodObject<{
|
|
494
509
|
type: z.ZodString;
|
|
@@ -516,6 +531,7 @@ export declare const CommentIpfsWithRefinmentSchema: z.ZodObject<{
|
|
|
516
531
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
517
532
|
postCid: z.ZodOptional<z.ZodString>;
|
|
518
533
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
534
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
519
535
|
author: z.ZodOptional<z.ZodObject<{
|
|
520
536
|
name: z.ZodOptional<z.ZodString>;
|
|
521
537
|
previousCommentCid: z.ZodOptional<z.ZodString>;
|
|
@@ -735,6 +751,7 @@ export declare const CommentUpdateSchema: z.ZodObject<{
|
|
|
735
751
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
736
752
|
postCid: z.ZodOptional<z.ZodString>;
|
|
737
753
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
754
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
738
755
|
author: z.ZodOptional<z.ZodObject<{
|
|
739
756
|
name: z.ZodOptional<z.ZodString>;
|
|
740
757
|
previousCommentCid: z.ZodOptional<z.ZodString>;
|
|
@@ -886,6 +903,7 @@ export declare const CommentsTableRowSchema: z.ZodObject<{
|
|
|
886
903
|
linkHtmlTagName: z.ZodOptional<z.ZodString>;
|
|
887
904
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
888
905
|
quotedCids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
906
|
+
crosspost: z.ZodOptional<z.ZodType<Crosspost, Crosspost, z.core.$ZodTypeInternals<Crosspost, Crosspost>>>;
|
|
889
907
|
author: z.ZodOptional<z.ZodObject<{
|
|
890
908
|
name: z.ZodOptional<z.ZodString>;
|
|
891
909
|
previousCommentCid: z.ZodOptional<z.ZodString>;
|
|
@@ -7,11 +7,19 @@ import { keysToOmitFromSignedPropertyNames } from "../../signer/constants.js";
|
|
|
7
7
|
import { RepliesPagesIpfsSchema } from "../../pages/schema.js";
|
|
8
8
|
// Comment schemas here
|
|
9
9
|
const CommentContentSchema = z.string();
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
10
|
+
// .loose() is load-bearing, not stylistic. crosspost.cid hashes the entire embedded record, so any
|
|
11
|
+
// normalization of it breaks the crosspost. Zod's strip behavior is per-schema, so leaving this at
|
|
12
|
+
// the default would let the CommentIpfsSchema.strip().parse() in storePublication silently delete
|
|
13
|
+
// author-signed extra props from the embedded record — changing the CID that
|
|
14
|
+
// deriveCommentIpfsFromCommentTableRow reconstructs, breaking page generation, and getting the
|
|
15
|
+
// comment purged by the post-migration signature sweep.
|
|
16
|
+
// Both generic params are pinned: zod 4's ZodType defaults Input to `unknown` (zod 3 defaulted it to
|
|
17
|
+
// Output), and leaving it inferred makes z.input of any schema containing a crosspost degrade to
|
|
18
|
+
// `unknown`, which breaks the z.input/z.infer equivalence the RPC parse helpers rely on.
|
|
19
|
+
const CrosspostSchema = z.object({
|
|
20
|
+
cid: CidStringSchema,
|
|
21
|
+
comment: z.lazy(() => CommentIpfsSchema.loose())
|
|
22
|
+
});
|
|
15
23
|
export const CreateCommentOptionsSchema = z
|
|
16
24
|
.object({
|
|
17
25
|
flairs: FlairSchema.array().optional(), // Author chosen colored labels for the comment
|
|
@@ -25,12 +33,15 @@ export const CreateCommentOptionsSchema = z
|
|
|
25
33
|
linkHtmlTagName: z.string().min(1).optional(),
|
|
26
34
|
parentCid: CidStringSchema.optional(), // The parent comment CID
|
|
27
35
|
postCid: CidStringSchema.optional(), // the post cid, required if the comment is reply
|
|
28
|
-
quotedCids: z.array(CidStringSchema).optional() // CIDs of comments being quoted/referenced in this reply
|
|
36
|
+
quotedCids: z.array(CidStringSchema).optional(), // CIDs of comments being quoted/referenced in this reply
|
|
37
|
+
crosspost: CrosspostSchema.optional() // this comment IS a repost of the embedded comment. Distinct from quotedCids, which only references comments the text refers to
|
|
29
38
|
})
|
|
30
39
|
.merge(CreatePublicationUserOptionsSchema)
|
|
31
40
|
.strict();
|
|
32
41
|
// This one is used for parsing user's input
|
|
33
|
-
|
|
42
|
+
// crosspost counts as payload on its own: a comment that only reposts another comment (a
|
|
43
|
+
// "retweet") is valid with no content, link or title. See docs/protocol/crossposts.md.
|
|
44
|
+
export const CreateCommentOptionsWithRefinementSchema = CreateCommentOptionsSchema.refine((arg) => arg.link || arg.content || arg.title || arg.crosspost, messages.ERR_COMMENT_HAS_NO_CONTENT_LINK_TITLE)
|
|
34
45
|
.refine((arg) => (arg.parentCid ? arg.postCid : true), messages.ERR_REPLY_HAS_NOT_DEFINED_POST_CID)
|
|
35
46
|
.refine(hasAtLeastOneCommunityIdentifier, atLeastOneCommunityIdentifierMessage);
|
|
36
47
|
// Below is what's used to initialize a local publication to be published
|
|
@@ -42,8 +53,8 @@ export const CommentPubsubMessagePublicationSchema = CreateCommentOptionsSchema.
|
|
|
42
53
|
.strict();
|
|
43
54
|
export const CommentPubsubMessageWithFlexibleAuthorSchema = CommentPubsubMessagePublicationSchema.merge(z.object({ author: AuthorPubsubSchema.loose().optional() })).strict();
|
|
44
55
|
// This is used by the community when parsing request.comment
|
|
45
|
-
export const CommentPubsubMessageWithFlexibleAuthorRefinementSchema = CommentPubsubMessageWithFlexibleAuthorSchema.loose().refine((arg) => arg.link || arg.content || arg.title, messages.ERR_COMMENT_HAS_NO_CONTENT_LINK_TITLE);
|
|
46
|
-
export const CommentPubsubMessageWithRefinementSchema = CommentPubsubMessagePublicationSchema.refine((arg) => arg.link || arg.content || arg.title, messages.ERR_COMMENT_HAS_NO_CONTENT_LINK_TITLE).refine((arg) => (arg.parentCid ? arg.postCid : true), messages.ERR_REPLY_HAS_NOT_DEFINED_POST_CID);
|
|
56
|
+
export const CommentPubsubMessageWithFlexibleAuthorRefinementSchema = CommentPubsubMessageWithFlexibleAuthorSchema.loose().refine((arg) => arg.link || arg.content || arg.title || arg.crosspost, messages.ERR_COMMENT_HAS_NO_CONTENT_LINK_TITLE);
|
|
57
|
+
export const CommentPubsubMessageWithRefinementSchema = CommentPubsubMessagePublicationSchema.refine((arg) => arg.link || arg.content || arg.title || arg.crosspost, messages.ERR_COMMENT_HAS_NO_CONTENT_LINK_TITLE).refine((arg) => (arg.parentCid ? arg.postCid : true), messages.ERR_REPLY_HAS_NOT_DEFINED_POST_CID);
|
|
47
58
|
export const CommentChallengeRequestToEncryptSchema = CreateCommentOptionsSchema.shape.challengeRequest
|
|
48
59
|
.unwrap()
|
|
49
60
|
.extend({
|
|
@@ -61,7 +72,7 @@ export const CommentIpfsSchema = CommentPubsubMessageWithFlexibleAuthorSchema.ex
|
|
|
61
72
|
pseudonymityMode: z.enum(["per-post", "per-reply", "per-author"]).optional()
|
|
62
73
|
}).strict();
|
|
63
74
|
// This one should be used for parsing user's input or from gateway/p2p etc
|
|
64
|
-
export const
|
|
75
|
+
export const CommentIpfsWithRefinementSchema = CommentIpfsSchema.refine((arg) => arg.link || arg.content || arg.title || arg.crosspost, messages.ERR_COMMENT_HAS_NO_CONTENT_LINK_TITLE);
|
|
65
76
|
// Comment update schemas
|
|
66
77
|
export const AuthorWithCommentUpdateSchema = CommentPubsubMessagePublicationSchema.shape.author
|
|
67
78
|
.unwrap()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/publications/comment/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,kCAAkC,EAClC,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,4BAA4B,EAC5B,gCAAgC,EAChC,qBAAqB,EACrB,gCAAgC,EAChC,oCAAoC,EACvC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2DAA2D,EAAE,MAAM,2BAA2B,CAAC;AACxG,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,uBAAuB;AAEvB,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/publications/comment/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,kCAAkC,EAClC,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,4BAA4B,EAC5B,gCAAgC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iBAAiB,CAAC,KAAK,CAA8C,CAC7E,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CAAC,kCAAkC,EAAE;IACtF,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;IAClC,GAAG,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC;IAC1C,iBAAiB;CACpB,CAAC,CAAC;AAEH,gCAAgC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { CommentChallengeRequestToEncryptSchema, CommentIpfsSchema, CommentPubsubMessagePublicationSchema, CommentSignedPropertyNames, CommentsTableRowSchema, CommentUpdateForChallengeVerificationSchema, CommentUpdateForChallengeVerificationSignedPropertyNames, CommentUpdateForDisapprovedPendingComment, CommentUpdateSchema, CommentUpdateSignedPropertyNames, CommentUpdateTableRowSchema, CreateCommentOptionsSchema, DbRepliesSchema, DbRepliesSortEntrySchema, DbPostsSchema } from "./schema.js";
|
|
3
|
+
import type { Crosspost } from "./schema.js";
|
|
3
4
|
import { CommunityAuthorSchema } from "../../schema/schema.js";
|
|
4
5
|
import { RpcCommentEventResultSchema, RpcCommentUpdateResultSchema } from "../../clients/rpc-client/schema.js";
|
|
5
6
|
import type { JsonOfClass, RuntimeAuthorWithCommentUpdateType } from "../../types.js";
|
|
@@ -19,6 +20,15 @@ export type CommentUpdateType = z.infer<typeof CommentUpdateSchema>;
|
|
|
19
20
|
export type CommentUpdateForDisapprovedPendingComment = z.infer<typeof CommentUpdateForDisapprovedPendingComment>;
|
|
20
21
|
export type CommentUpdateForChallengeVerification = z.infer<typeof CommentUpdateForChallengeVerificationSchema>;
|
|
21
22
|
export type CommentIpfsType = z.infer<typeof CommentIpfsSchema>;
|
|
23
|
+
export type CrosspostRuntime = {
|
|
24
|
+
cid: Crosspost["cid"];
|
|
25
|
+
comment: Omit<Crosspost["comment"], "author" | "crosspost"> & {
|
|
26
|
+
author?: NonNullable<Crosspost["comment"]["author"]> & {
|
|
27
|
+
nameResolved?: boolean;
|
|
28
|
+
};
|
|
29
|
+
crosspost?: CrosspostRuntime;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
22
32
|
export type CommentChallengeRequestToEncryptType = z.infer<typeof CommentChallengeRequestToEncryptSchema>;
|
|
23
33
|
export type RpcCommentUpdateResultType = z.infer<typeof RpcCommentUpdateResultSchema>;
|
|
24
34
|
export type RpcCommentResultType = z.infer<typeof RpcCommentEventResultSchema>;
|
|
@@ -65,6 +65,7 @@ export declare const CreateCommunityEditPublicationOptionsSchema: import("zod").
|
|
|
65
65
|
noReplyLinks: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
66
66
|
noPolls: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
67
67
|
noCrossposts: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
68
|
+
maxCrosspostDepth: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
68
69
|
noNestedReplies: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
69
70
|
safeForWork: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
70
71
|
authorFlairs: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
@@ -224,6 +225,7 @@ export declare const CreateCommunityEditPublicationOptionsWithRefinementSchema:
|
|
|
224
225
|
noReplyLinks: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
225
226
|
noPolls: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
226
227
|
noCrossposts: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
228
|
+
maxCrosspostDepth: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
227
229
|
noNestedReplies: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
228
230
|
safeForWork: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
229
231
|
authorFlairs: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
@@ -379,6 +381,7 @@ export declare const CommunityEditPubsubMessagePublicationSchema: import("zod").
|
|
|
379
381
|
noReplyLinks: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
380
382
|
noPolls: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
381
383
|
noCrossposts: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
384
|
+
maxCrosspostDepth: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
382
385
|
noNestedReplies: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
383
386
|
safeForWork: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
384
387
|
authorFlairs: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
@@ -536,6 +539,7 @@ export declare const CommunityEditPublicationChallengeRequestToEncryptSchema: im
|
|
|
536
539
|
noReplyLinks: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
537
540
|
noPolls: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
538
541
|
noCrossposts: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
542
|
+
maxCrosspostDepth: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
539
543
|
noNestedReplies: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
540
544
|
safeForWork: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
541
545
|
authorFlairs: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
@@ -36,6 +36,7 @@ declare class Publication extends TypedEmitter<PublicationEvents> {
|
|
|
36
36
|
pubsubTopic?: CommunityIpfsType["pubsubTopic"];
|
|
37
37
|
};
|
|
38
38
|
_publishingToLocalCommunity?: LocalCommunity;
|
|
39
|
+
_backgroundCommunityRefresh?: Promise<unknown>;
|
|
39
40
|
_challengeExchanges: Record<string, // challengeRequestId stringified
|
|
40
41
|
{
|
|
41
42
|
challengeAnswer?: DecryptedChallengeAnswerMessageType;
|
|
@@ -102,6 +103,8 @@ declare class Publication extends TypedEmitter<PublicationEvents> {
|
|
|
102
103
|
_fetchCommunityForPublishing(): Promise<NonNullable<Publication["_community"]>>;
|
|
103
104
|
stop(): Promise<void>;
|
|
104
105
|
_isAllAttemptsExhausted(maxNumOfChallengeExchanges: number): boolean;
|
|
106
|
+
private _abandonProviderIfStoppedWhileSubscribing;
|
|
107
|
+
private _unregisterFromPkcOncePublishWorkSettles;
|
|
105
108
|
private _postSucessOrFailurePublishing;
|
|
106
109
|
private _handleIncomingChallengeRequestFromRpc;
|
|
107
110
|
private _handleIncomingChallengeFromRpc;
|
|
@@ -122,5 +125,6 @@ declare class Publication extends TypedEmitter<PublicationEvents> {
|
|
|
122
125
|
private _getPubsubProviders;
|
|
123
126
|
private _publishWithLocalCommunity;
|
|
124
127
|
publish(): Promise<void>;
|
|
128
|
+
private _publishAfterRegistering;
|
|
125
129
|
}
|
|
126
130
|
export default Publication;
|
|
@@ -562,9 +562,16 @@ class Publication extends TypedEmitter {
|
|
|
562
562
|
// cache.has will return false if the item is stale
|
|
563
563
|
if (!this._pkc._memCaches.communityForPublishing.has(this.communityAddress)) {
|
|
564
564
|
log("The cache of community is stale, we will use the cached and update in the background");
|
|
565
|
-
|
|
565
|
+
// Held on the publication so stop() can drain it. Without that the refresh outlives
|
|
566
|
+
// the PKC and goes on creating community instances after teardown (issue #270).
|
|
567
|
+
const refresh = this._pkc
|
|
566
568
|
.getCommunity({ publicKey: this.communityPublicKey, name: this.communityName })
|
|
567
|
-
.catch((e) => log.error("Failed to update cache of community", this.communityAddress, e))
|
|
569
|
+
.catch((e) => log.error("Failed to update cache of community", this.communityAddress, e))
|
|
570
|
+
.finally(() => {
|
|
571
|
+
if (this._backgroundCommunityRefresh === refresh)
|
|
572
|
+
this._backgroundCommunityRefresh = undefined;
|
|
573
|
+
});
|
|
574
|
+
this._backgroundCommunityRefresh = refresh;
|
|
568
575
|
}
|
|
569
576
|
return cachedCommunity;
|
|
570
577
|
}
|
|
@@ -572,8 +579,19 @@ class Publication extends TypedEmitter {
|
|
|
572
579
|
return this._clientsManager.fetchCommunityForPublishingWithCacheGuard();
|
|
573
580
|
}
|
|
574
581
|
async stop() {
|
|
575
|
-
|
|
576
|
-
|
|
582
|
+
try {
|
|
583
|
+
await this._postSucessOrFailurePublishing();
|
|
584
|
+
}
|
|
585
|
+
finally {
|
|
586
|
+
// Stopping the publication does not cancel a refresh that is already in flight, so wait
|
|
587
|
+
// it out. On the pkc.destroy() path the destroy abort has already fired, so this unwinds
|
|
588
|
+
// fast. In a finally because pkc.destroy() catches a rejecting stop() and then clears
|
|
589
|
+
// _publishingPublications, so a cleanup failure would otherwise leave the refresh
|
|
590
|
+
// running past teardown, which is the exact thing this is here to prevent.
|
|
591
|
+
if (this._backgroundCommunityRefresh)
|
|
592
|
+
await this._backgroundCommunityRefresh;
|
|
593
|
+
this._updatePublishingStateWithEmission("stopped");
|
|
594
|
+
}
|
|
577
595
|
}
|
|
578
596
|
_isAllAttemptsExhausted(maxNumOfChallengeExchanges) {
|
|
579
597
|
// When all providers failed to publish
|
|
@@ -588,8 +606,40 @@ class Publication extends TypedEmitter {
|
|
|
588
606
|
return doneWaitingForChallenge;
|
|
589
607
|
});
|
|
590
608
|
}
|
|
609
|
+
// stop() and pkc.destroy() are not cancellation: they unsubscribe and mark us stopped, but a
|
|
610
|
+
// pubsub subscribe that was already in flight still resolves afterwards and the publish loop
|
|
611
|
+
// carries on to publish a challenge request behind a torn-down PKC. Worse, that subscribe
|
|
612
|
+
// re-established a subscription after teardown already ran its unsubscribe, so returning
|
|
613
|
+
// without undoing it leaves it dangling on the provider. Returns true when the caller should
|
|
614
|
+
// abandon this provider (issue #270).
|
|
615
|
+
async _abandonProviderIfStoppedWhileSubscribing(providerUrl) {
|
|
616
|
+
if (!this._pkc.destroyed && this.state !== "stopped")
|
|
617
|
+
return false;
|
|
618
|
+
const log = Logger("pkc-js:publication:publish:_abandonProviderIfStoppedWhileSubscribing");
|
|
619
|
+
log("Publication was stopped while subscribing to pubsub, will not publish a challenge request", providerUrl);
|
|
620
|
+
try {
|
|
621
|
+
await this._clientsManager.pubsubUnsubscribeOnProvider(this._communityChallengePubsubExchangeTopic(), providerUrl, this._handleChallengeExchange);
|
|
622
|
+
}
|
|
623
|
+
catch (e) {
|
|
624
|
+
log.error("Failed to undo the pubsub subscription that resolved after being stopped", providerUrl, e);
|
|
625
|
+
}
|
|
626
|
+
this._updatePubsubState("stopped", providerUrl);
|
|
627
|
+
return true;
|
|
628
|
+
}
|
|
629
|
+
// A refresh fired at the start of publish can outlive the exchange it was fired from:
|
|
630
|
+
// getCommunity() on a remote community waits for an IPNS update, while a local challenge
|
|
631
|
+
// exchange finishes in milliseconds. Stay registered until it settles, otherwise the publish
|
|
632
|
+
// ends, we unregister, and pkc.destroy() has nothing left to drain the refresh through.
|
|
633
|
+
_unregisterFromPkcOncePublishWorkSettles() {
|
|
634
|
+
const refresh = this._backgroundCommunityRefresh;
|
|
635
|
+
if (refresh)
|
|
636
|
+
void refresh.finally(() => this._pkc._publishingPublications.delete(this));
|
|
637
|
+
else
|
|
638
|
+
this._pkc._publishingPublications.delete(this);
|
|
639
|
+
}
|
|
591
640
|
async _postSucessOrFailurePublishing() {
|
|
592
641
|
const log = Logger("pkc-js:publication:_postSucessOrFailurePublishing");
|
|
642
|
+
this._unregisterFromPkcOncePublishWorkSettles();
|
|
593
643
|
this._setStateWithEmission("stopped");
|
|
594
644
|
if (this._rpcPublishSubscriptionId) {
|
|
595
645
|
try {
|
|
@@ -844,6 +894,8 @@ class Publication extends TypedEmitter {
|
|
|
844
894
|
this._updatePubsubState("subscribing-pubsub", providerUrl);
|
|
845
895
|
try {
|
|
846
896
|
await this._clientsManager.pubsubSubscribeOnProvider(this._communityChallengePubsubExchangeTopic(), this._handleChallengeExchange, providerUrl);
|
|
897
|
+
if (await this._abandonProviderIfStoppedWhileSubscribing(providerUrl))
|
|
898
|
+
return;
|
|
847
899
|
this._updatePubsubState("publishing-challenge-request", providerUrl);
|
|
848
900
|
await this._clientsManager.pubsubPublishOnProvider(this._communityChallengePubsubExchangeTopic(), challengeRequest, providerUrl);
|
|
849
901
|
this._challengeExchanges[challengeRequest.challengeRequestId.toString()].challengeRequestPublishTimestamp =
|
|
@@ -946,8 +998,29 @@ class Publication extends TypedEmitter {
|
|
|
946
998
|
});
|
|
947
999
|
}
|
|
948
1000
|
async publish() {
|
|
949
|
-
const log = Logger("pkc-js:publication:publish");
|
|
950
1001
|
this._validatePublicationFields();
|
|
1002
|
+
// Track before the first await so pkc.destroy() can stop us no matter how far the exchange
|
|
1003
|
+
// has progressed. Untracked in _postSucessOrFailurePublishing once the exchange ends, or in
|
|
1004
|
+
// the catch below if publish never got that far.
|
|
1005
|
+
this._pkc._publishingPublications.add(this);
|
|
1006
|
+
try {
|
|
1007
|
+
return await this._publishAfterRegistering();
|
|
1008
|
+
}
|
|
1009
|
+
catch (e) {
|
|
1010
|
+
// Not every throw reaches the funnel: pre-flight failures (_initCommunity, signing, the
|
|
1011
|
+
// signature hook, the RPC publish call) reject before a challenge exchange exists, and
|
|
1012
|
+
// _initCommunity does its own stopped/failed emission and rethrows. Without this we stay
|
|
1013
|
+
// strongly referenced in _publishingPublications for the lifetime of the PKC, and
|
|
1014
|
+
// destroy() later stops a publication that never started. Unregistering directly rather
|
|
1015
|
+
// than through the funnel keeps the error path free of a redundant state emission and of
|
|
1016
|
+
// a pubsub unsubscribe for a topic that was never subscribed. Deleting twice is a no-op,
|
|
1017
|
+
// so the throw sites that do funnel are unaffected.
|
|
1018
|
+
this._unregisterFromPkcOncePublishWorkSettles();
|
|
1019
|
+
throw e;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
async _publishAfterRegistering() {
|
|
1023
|
+
const log = Logger("pkc-js:publication:publish");
|
|
951
1024
|
this._setStateWithEmission("publishing");
|
|
952
1025
|
// Fetch community for BOTH RPC and non-RPC paths (needed for signing)
|
|
953
1026
|
await this._initCommunity();
|
|
@@ -992,6 +1065,8 @@ class Publication extends TypedEmitter {
|
|
|
992
1065
|
try {
|
|
993
1066
|
// this will throw if we succeed in subscribing first attempt, but then fail to publish
|
|
994
1067
|
await this._clientsManager.pubsubSubscribeOnProvider(this._communityChallengePubsubExchangeTopic(), this._handleChallengeExchange, providerUrl);
|
|
1068
|
+
if (await this._abandonProviderIfStoppedWhileSubscribing(providerUrl))
|
|
1069
|
+
return;
|
|
995
1070
|
this._updatePubsubState("publishing-challenge-request", providerUrl);
|
|
996
1071
|
await this._clientsManager.pubsubPublishOnProvider(this._communityChallengePubsubExchangeTopic(), challengeRequest, providerUrl);
|
|
997
1072
|
this._challengeExchanges[challengeRequest.challengeRequestId.toString()].challengeRequestPublishTimestamp = timestamp();
|