@pkcprotocol/pkc-js 0.0.157 → 0.0.159
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 +58 -3
- package/dist/browser/clients/base-client-manager.js +24 -11
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js +17 -9
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
- package/dist/browser/clients/rpc-client/schema.d.ts +2 -0
- package/dist/browser/community/schema.d.ts +26 -0
- package/dist/browser/detached-guard.d.ts +5 -0
- package/dist/browser/detached-guard.js +50 -0
- package/dist/browser/detached-guard.js.map +1 -0
- package/dist/browser/errors.d.ts +2 -0
- package/dist/browser/errors.js +2 -0
- 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/helia/helia-for-pkc.js +6 -5
- package/dist/browser/helia/helia-for-pkc.js.map +1 -1
- package/dist/browser/index-with-compile-cache.d.ts +4 -0
- package/dist/browser/index.d.ts +8 -0
- package/dist/browser/pages/schema.d.ts +6 -0
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/publications/comment/comment.d.ts +2 -0
- package/dist/browser/publications/comment/comment.js +2 -0
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/publications/comment/schema.d.ts +6 -2
- package/dist/browser/publications/comment/schema.js +13 -1
- package/dist/browser/publications/comment/schema.js.map +1 -1
- package/dist/browser/publications/comment-moderation/schema.js +2 -2
- package/dist/browser/publications/comment-moderation/schema.js.map +1 -1
- package/dist/browser/publications/publication.js +26 -32
- package/dist/browser/publications/publication.js.map +1 -1
- package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +4 -0
- package/dist/browser/rpc/src/schema.d.ts +24 -0
- package/dist/browser/runtime/node/community/db-handler.d.ts +1 -0
- package/dist/browser/runtime/node/community/db-handler.js +31 -7
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/cleanup.js +6 -0
- package/dist/browser/runtime/node/community/local-community/cleanup.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/comment-updates.js +36 -0
- package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/db-fault.d.ts +3 -0
- package/dist/browser/runtime/node/community/local-community/db-fault.js +13 -0
- package/dist/browser/runtime/node/community/local-community/db-fault.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +36 -2
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +36 -2
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/post-updates-bucket.d.ts +21 -0
- package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js +141 -4
- package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.d.ts +7 -0
- package/dist/browser/runtime/node/community/local-community.js +18 -0
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/test/helpers/hanging-runner.js +7 -3
- package/dist/browser/runtime/node/test/helpers/hanging-runner.js.map +1 -1
- package/dist/browser/runtime/node/test/helpers/run-hanging-node.js +6 -1
- package/dist/browser/runtime/node/test/helpers/run-hanging-node.js.map +1 -1
- package/dist/browser/schema/schema-util.d.ts +10 -0
- package/dist/browser/schema/schema.d.ts +9 -0
- package/dist/browser/schema/schema.js +9 -1
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/schema.d.ts +32 -0
- package/dist/browser/signer/pseudonymity-author-tag.d.ts +8 -0
- package/dist/browser/signer/pseudonymity-author-tag.js +39 -0
- package/dist/browser/signer/pseudonymity-author-tag.js.map +1 -0
- package/dist/browser/signer/signatures.js +16 -0
- package/dist/browser/signer/signatures.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +10 -0
- package/dist/browser/version.js +1 -1
- package/dist/bundled/bundle-manifest.json +58 -53
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-BT2UmDem.js → helia-for-pkc-CP5A7i4M.js} +5 -4
- package/dist/bundled/chunks/{local-community-oqjqTa9T.js → local-community-0xsjgulY.js} +373 -26
- package/dist/bundled/chunks/{local-community-BexngGU7.js → local-community-CUDfHfH_.js} +1 -1
- package/dist/bundled/chunks/{node-CvXtQ-4A.js → node-Bv7hIiW_.js} +40 -38
- package/dist/bundled/chunks/{page-sort-scoring-VN_GGInQ.js → page-sort-scoring-I02fuGkI.js} +1 -1
- package/dist/bundled/chunks/{rpc-local-community-BjIHRbYy.js → rpc-local-community-Bo4Z7ilA.js} +57 -13
- package/dist/bundled/chunks/{util-DDsWXOtP.js → util-BZuCmqxu.js} +12 -9
- package/dist/bundled/chunks/{util-Bu3ItQsN.js → util-xhgmI11L.js} +1 -1
- package/dist/bundled/chunks/{validate-package-factories-CmJt781W.js → validate-package-factories-BsSEIr__.js} +2 -2
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/page-sorts.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/clients/base-client-manager.js +24 -11
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/clients/rpc-client/pkc-rpc-client.js +17 -9
- package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
- package/dist/node/clients/rpc-client/schema.d.ts +2 -0
- package/dist/node/community/schema.d.ts +26 -0
- package/dist/node/detached-guard.d.ts +5 -0
- package/dist/node/detached-guard.js +50 -0
- package/dist/node/detached-guard.js.map +1 -0
- package/dist/node/errors.d.ts +2 -0
- package/dist/node/errors.js +2 -0
- 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/helia/helia-for-pkc.js +6 -5
- package/dist/node/helia/helia-for-pkc.js.map +1 -1
- package/dist/node/index-with-compile-cache.d.ts +4 -0
- package/dist/node/index.d.ts +8 -0
- package/dist/node/pages/schema.d.ts +6 -0
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/publications/comment/comment.d.ts +2 -0
- package/dist/node/publications/comment/comment.js +2 -0
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/publications/comment/schema.d.ts +6 -2
- package/dist/node/publications/comment/schema.js +13 -1
- package/dist/node/publications/comment/schema.js.map +1 -1
- package/dist/node/publications/comment-moderation/schema.js +2 -2
- package/dist/node/publications/comment-moderation/schema.js.map +1 -1
- package/dist/node/publications/publication.js +26 -32
- package/dist/node/publications/publication.js.map +1 -1
- package/dist/node/rpc/src/lib/pkc-js/index.d.ts +4 -0
- package/dist/node/rpc/src/schema.d.ts +24 -0
- package/dist/node/runtime/node/community/db-handler.d.ts +1 -0
- package/dist/node/runtime/node/community/db-handler.js +31 -7
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/cleanup.js +6 -0
- package/dist/node/runtime/node/community/local-community/cleanup.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/comment-updates.js +36 -0
- package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/db-fault.d.ts +3 -0
- package/dist/node/runtime/node/community/local-community/db-fault.js +13 -0
- package/dist/node/runtime/node/community/local-community/db-fault.js.map +1 -0
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js +36 -2
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/lifecycle.js +36 -2
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/post-updates-bucket.d.ts +21 -0
- package/dist/node/runtime/node/community/local-community/post-updates-bucket.js +141 -4
- package/dist/node/runtime/node/community/local-community/post-updates-bucket.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.d.ts +7 -0
- package/dist/node/runtime/node/community/local-community.js +18 -0
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/test/helpers/hanging-runner.js +7 -3
- package/dist/node/runtime/node/test/helpers/hanging-runner.js.map +1 -1
- package/dist/node/runtime/node/test/helpers/run-hanging-node.js +6 -1
- package/dist/node/runtime/node/test/helpers/run-hanging-node.js.map +1 -1
- package/dist/node/schema/schema-util.d.ts +10 -0
- package/dist/node/schema/schema.d.ts +9 -0
- package/dist/node/schema/schema.js +9 -1
- package/dist/node/schema/schema.js.map +1 -1
- package/dist/node/schema.d.ts +32 -0
- package/dist/node/signer/pseudonymity-author-tag.d.ts +8 -0
- package/dist/node/signer/pseudonymity-author-tag.js +39 -0
- package/dist/node/signer/pseudonymity-author-tag.js.map +1 -0
- package/dist/node/signer/signatures.js +16 -0
- package/dist/node/signer/signatures.js.map +1 -1
- package/dist/node/test/test-util.d.ts +10 -0
- package/dist/node/version.js +1 -1
- package/package.json +3 -2
|
@@ -43,6 +43,12 @@ const TABLES = Object.freeze({
|
|
|
43
43
|
PSEUDONYMITY_ALIASES: "pseudonymityAliases"
|
|
44
44
|
});
|
|
45
45
|
// The address an alias row's original public key derives to, or null when the key is malformed (kept, never looked up)
|
|
46
|
+
// A moderation's `author` that sets the author's ban: a positive timestamp, future (a ban) or past (an unban).
|
|
47
|
+
// A 0 only removes the mark from the comment it was published on (commentUpdate.authorBanExpiresAt), so the author
|
|
48
|
+
// aggregate skips it and falls through to the newest row that does carry a timestamp (issue #363).
|
|
49
|
+
function isAuthorBanRow(modEdit) {
|
|
50
|
+
return typeof modEdit?.banExpiresAt === "number" && modEdit.banExpiresAt > 0;
|
|
51
|
+
}
|
|
46
52
|
function deriveAliasOriginalAuthorSignerAddress(originalAuthorPublicKey) {
|
|
47
53
|
try {
|
|
48
54
|
return getPKCAddressFromPublicKeySync(originalAuthorPublicKey);
|
|
@@ -365,13 +371,15 @@ export class DbHandler {
|
|
|
365
371
|
removed INTEGER NULLABLE, -- BOOLEAN (0/1)
|
|
366
372
|
approved INTEGER NULLABLE, -- BOOLEAN (0/1)
|
|
367
373
|
reason TEXT NULLABLE,
|
|
374
|
+
authorBanExpiresAt INTEGER NULLABLE, -- the ban a mod published on this comment (issue #363)
|
|
368
375
|
updatedAt INTEGER NOT NULL CHECK(updatedAt > 0),
|
|
369
376
|
protocolVersion TEXT NOT NULL,
|
|
370
377
|
signature TEXT NOT NULL, -- JSON
|
|
371
378
|
author TEXT NULLABLE, -- JSON
|
|
372
379
|
replies TEXT NULLABLE, -- JSON: CID refs per sort (DbRepliesSchema)
|
|
373
380
|
lastChildCid TEXT NULLABLE,
|
|
374
|
-
lastReplyTimestamp INTEGER NULLABLE,
|
|
381
|
+
lastReplyTimestamp INTEGER NULLABLE,
|
|
382
|
+
pseudonymityAuthorTag TEXT NULLABLE, -- own-post recognition tag on aliased comments (issue #381); a signed CommentUpdate field
|
|
375
383
|
postUpdatesBucket INTEGER NULLABLE,
|
|
376
384
|
publishedToPostUpdatesMFS INTEGER NOT NULL, -- BOOLEAN (0/1)
|
|
377
385
|
insertedAt INTEGER NOT NULL,
|
|
@@ -1125,16 +1133,16 @@ export class DbHandler {
|
|
|
1125
1133
|
const columnNames = this._getColumnNames(TABLES.COMMENT_UPDATES);
|
|
1126
1134
|
const stmt = this._prepareCached(`
|
|
1127
1135
|
INSERT INTO ${TABLES.COMMENT_UPDATES}
|
|
1128
|
-
(cid, edit, upvoteCount, downvoteCount, replyCount, childCount, number, postNumber, flairs, spoiler, nsfw, pinned, locked, archived, removed, approved, reason, updatedAt, protocolVersion, signature, author, replies, lastChildCid, lastReplyTimestamp, postUpdatesBucket, publishedToPostUpdatesMFS, insertedAt, extraProps)
|
|
1129
|
-
VALUES (@cid, @edit, @upvoteCount, @downvoteCount, @replyCount, @childCount, @number, @postNumber, @flairs, @spoiler, @nsfw, @pinned, @locked, @archived, @removed, @approved, @reason, @updatedAt, @protocolVersion, @signature, @author, @replies, @lastChildCid, @lastReplyTimestamp, @postUpdatesBucket, @publishedToPostUpdatesMFS, @insertedAt, @extraProps)
|
|
1136
|
+
(cid, edit, upvoteCount, downvoteCount, replyCount, childCount, number, postNumber, flairs, spoiler, nsfw, pinned, locked, archived, removed, approved, reason, authorBanExpiresAt, updatedAt, protocolVersion, signature, author, replies, lastChildCid, lastReplyTimestamp, pseudonymityAuthorTag, postUpdatesBucket, publishedToPostUpdatesMFS, insertedAt, extraProps)
|
|
1137
|
+
VALUES (@cid, @edit, @upvoteCount, @downvoteCount, @replyCount, @childCount, @number, @postNumber, @flairs, @spoiler, @nsfw, @pinned, @locked, @archived, @removed, @approved, @reason, @authorBanExpiresAt, @updatedAt, @protocolVersion, @signature, @author, @replies, @lastChildCid, @lastReplyTimestamp, @pseudonymityAuthorTag, @postUpdatesBucket, @publishedToPostUpdatesMFS, @insertedAt, @extraProps)
|
|
1130
1138
|
ON CONFLICT(cid) DO UPDATE SET
|
|
1131
1139
|
edit = excluded.edit, upvoteCount = excluded.upvoteCount, downvoteCount = excluded.downvoteCount, replyCount = excluded.replyCount, childCount = excluded.childCount,
|
|
1132
1140
|
number = COALESCE(excluded.number, ${TABLES.COMMENT_UPDATES}.number),
|
|
1133
1141
|
postNumber = COALESCE(excluded.postNumber, ${TABLES.COMMENT_UPDATES}.postNumber),
|
|
1134
1142
|
flairs = excluded.flairs, spoiler = excluded.spoiler, nsfw = excluded.nsfw, pinned = excluded.pinned, locked = excluded.locked, archived = excluded.archived,
|
|
1135
|
-
removed = excluded.removed, approved = excluded.approved, reason = excluded.reason, updatedAt = excluded.updatedAt, protocolVersion = excluded.protocolVersion,
|
|
1143
|
+
removed = excluded.removed, approved = excluded.approved, reason = excluded.reason, authorBanExpiresAt = excluded.authorBanExpiresAt, updatedAt = excluded.updatedAt, protocolVersion = excluded.protocolVersion,
|
|
1136
1144
|
signature = excluded.signature, author = excluded.author, replies = excluded.replies, lastChildCid = excluded.lastChildCid,
|
|
1137
|
-
lastReplyTimestamp = excluded.lastReplyTimestamp, postUpdatesBucket = excluded.postUpdatesBucket,
|
|
1145
|
+
lastReplyTimestamp = excluded.lastReplyTimestamp, pseudonymityAuthorTag = excluded.pseudonymityAuthorTag, postUpdatesBucket = excluded.postUpdatesBucket,
|
|
1138
1146
|
publishedToPostUpdatesMFS = excluded.publishedToPostUpdatesMFS,
|
|
1139
1147
|
insertedAt = excluded.insertedAt,
|
|
1140
1148
|
extraProps = excluded.extraProps
|
|
@@ -2349,6 +2357,8 @@ export class DbHandler {
|
|
|
2349
2357
|
...moderation?.flags,
|
|
2350
2358
|
// moderatorReason wins when present, else fall back to the challenge-supplied reason (if any).
|
|
2351
2359
|
reason: moderation?.reason ?? comment.challengeCommentUpdate?.reason,
|
|
2360
|
+
// 0 is the mod's revoke: it is the newest ban value on this comment, and it means no mark
|
|
2361
|
+
authorBanExpiresAt: moderation?.authorBanExpiresAt || undefined,
|
|
2352
2362
|
author: { community: { ...(challengeAuthorCommunity ?? {}), ...authorCommunity } },
|
|
2353
2363
|
lastChildCid: lastChildCids.get(comment.cid),
|
|
2354
2364
|
lastReplyTimestamp: lastReplyTimestamps.get(comment.cid),
|
|
@@ -2477,6 +2487,9 @@ export class DbHandler {
|
|
|
2477
2487
|
}
|
|
2478
2488
|
// What the moderations of each comment say, newest first, one read for the batch: the latest non-null value per
|
|
2479
2489
|
// field (reason, flairs, approved and the six flags), the same precedence as the per-field statements this replaces.
|
|
2490
|
+
// authorBanExpiresAt is the newest author.banExpiresAt published on the comment itself, 0 included: a 0 removes the
|
|
2491
|
+
// mark. author.community.banExpiresAt is the newest across all of the author's comments and skips 0 rows
|
|
2492
|
+
// (isAuthorBanRow), so removing a mark never touches the ban.
|
|
2480
2493
|
_queryModerationSummariesByCids(cids) {
|
|
2481
2494
|
const FLAG_NAMES = ["spoiler", "pinned", "locked", "archived", "removed", "nsfw"];
|
|
2482
2495
|
const result = new Map();
|
|
@@ -2491,6 +2504,9 @@ export class DbHandler {
|
|
|
2491
2504
|
}
|
|
2492
2505
|
if (summary.reason === undefined && typeof moderation.reason === "string")
|
|
2493
2506
|
summary.reason = moderation.reason;
|
|
2507
|
+
const banExpiresAt = moderation.author?.banExpiresAt;
|
|
2508
|
+
if (summary.authorBanExpiresAt === undefined && typeof banExpiresAt === "number")
|
|
2509
|
+
summary.authorBanExpiresAt = banExpiresAt;
|
|
2494
2510
|
if (summary.flairs === undefined && moderation.flairs !== null && moderation.flairs !== undefined)
|
|
2495
2511
|
summary.flairs = moderation.flairs;
|
|
2496
2512
|
if (summary.approved === undefined && moderation.approved !== null && moderation.approved !== undefined)
|
|
@@ -2636,7 +2652,7 @@ export class DbHandler {
|
|
|
2636
2652
|
.filter((row) => (row.targetAuthorSignerAddress !== null && modEditSet.has(row.targetAuthorSignerAddress)) ||
|
|
2637
2653
|
(need.domain !== undefined && row.targetAuthorDomain === need.domain))
|
|
2638
2654
|
.map((row) => row.author);
|
|
2639
|
-
const banAuthor = modAuthorEdits.find(
|
|
2655
|
+
const banAuthor = modAuthorEdits.find(isAuthorBanRow);
|
|
2640
2656
|
const authorFlairsByMod = modAuthorEdits.find((modEdit) => modEdit?.flairs);
|
|
2641
2657
|
const modEdits = {};
|
|
2642
2658
|
if (banAuthor?.banExpiresAt)
|
|
@@ -2822,7 +2838,7 @@ export class DbHandler {
|
|
|
2822
2838
|
WHERE (${conditions.join(" OR ")}) AND json_extract(commentModeration, '$.author') IS NOT NULL ORDER BY rowid DESC
|
|
2823
2839
|
`).all(...params);
|
|
2824
2840
|
const modAuthorEdits = modAuthorEditsRaw.map((r) => JSON.parse(r.commentAuthorJson));
|
|
2825
|
-
const banAuthor = modAuthorEdits.find(
|
|
2841
|
+
const banAuthor = modAuthorEdits.find(isAuthorBanRow);
|
|
2826
2842
|
const authorFlairsByMod = modAuthorEdits.find((modEdit) => modEdit?.flairs);
|
|
2827
2843
|
const aggregateAuthor = {};
|
|
2828
2844
|
if (banAuthor?.banExpiresAt)
|
|
@@ -3175,6 +3191,14 @@ export class DbHandler {
|
|
|
3175
3191
|
return;
|
|
3176
3192
|
this._runForEachCidBatch(commentCids, (placeholders) => `UPDATE ${TABLES.COMMENT_UPDATES} SET publishedToPostUpdatesMFS = 1 WHERE cid IN (${placeholders})`);
|
|
3177
3193
|
}
|
|
3194
|
+
// The posts whose CommentUpdate file was written to this postUpdates bucket and acknowledged. No index backs it:
|
|
3195
|
+
// it is for the rare audit of a bucket MFS may have lost entries of, never for a hot path.
|
|
3196
|
+
queryPublishedPostCidsOfBucket(bucket) {
|
|
3197
|
+
return this._db
|
|
3198
|
+
.prepare(`SELECT cid FROM ${TABLES.COMMENT_UPDATES} WHERE postUpdatesBucket = ? AND publishedToPostUpdatesMFS = 1`)
|
|
3199
|
+
.pluck()
|
|
3200
|
+
.all(bucket);
|
|
3201
|
+
}
|
|
3178
3202
|
forceUpdateOnAllComments() {
|
|
3179
3203
|
this._db.prepare(`UPDATE ${TABLES.COMMENT_UPDATES} SET publishedToPostUpdatesMFS = 0`).run();
|
|
3180
3204
|
}
|