@pkcprotocol/pkc-js 0.0.62 → 0.0.64
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/dist/browser/clients/base-client-manager.js +15 -15
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/community/community-client-manager.js +10 -12
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/community/community-gateway-selection.js +4 -4
- package/dist/browser/community/community-gateway-selection.js.map +1 -1
- package/dist/browser/community/community-wire.js +3 -3
- package/dist/browser/community/community-wire.js.map +1 -1
- package/dist/browser/community/remote-community.d.ts +1 -1
- package/dist/browser/community/remote-community.js +10 -7
- package/dist/browser/community/remote-community.js.map +1 -1
- package/dist/browser/community/rpc-local-community.js +3 -3
- package/dist/browser/community/rpc-local-community.js.map +1 -1
- package/dist/browser/community/rpc-remote-community.js +5 -5
- package/dist/browser/community/rpc-remote-community.js.map +1 -1
- package/dist/browser/community/schema.js +5 -5
- package/dist/browser/community/schema.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-client-manager.js +11 -15
- package/dist/browser/pages/pages-client-manager.js.map +1 -1
- package/dist/browser/pages/util.js +9 -9
- package/dist/browser/pages/util.js.map +1 -1
- package/dist/browser/pkc/pkc-client-manager.js +6 -6
- package/dist/browser/pkc/pkc-client-manager.js.map +1 -1
- package/dist/browser/pkc/pkc.js +19 -13
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/publications/comment/comment-client-manager.js +5 -5
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/browser/publications/comment/comment.js +16 -16
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/publications/comment/schema.js +17 -17
- package/dist/browser/publications/comment/schema.js.map +1 -1
- package/dist/browser/publications/comment-edit/schema.js +7 -7
- package/dist/browser/publications/comment-edit/schema.js.map +1 -1
- package/dist/browser/publications/comment-moderation/schema.js +11 -7
- package/dist/browser/publications/comment-moderation/schema.js.map +1 -1
- package/dist/browser/publications/community-edit/schema.js +6 -6
- package/dist/browser/publications/community-edit/schema.js.map +1 -1
- package/dist/browser/publications/publication-author.js +3 -3
- package/dist/browser/publications/publication-author.js.map +1 -1
- package/dist/browser/publications/publication-client-manager.js +4 -4
- package/dist/browser/publications/publication-client-manager.js.map +1 -1
- package/dist/browser/publications/publication.js +9 -9
- package/dist/browser/publications/publication.js.map +1 -1
- package/dist/browser/publications/vote/schema.js +11 -7
- package/dist/browser/publications/vote/schema.js.map +1 -1
- package/dist/browser/publications/vote/vote.js.map +1 -1
- package/dist/browser/pubsub-messages/schema.js +5 -5
- package/dist/browser/pubsub-messages/schema.js.map +1 -1
- package/dist/browser/rpc/src/index.js +54 -15
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/runtime/browser/localforage-lru.js +2 -2
- package/dist/browser/runtime/browser/localforage-lru.js.map +1 -1
- package/dist/browser/runtime/browser/util.d.ts +1 -1
- package/dist/browser/runtime/browser/util.js +4 -2
- package/dist/browser/runtime/browser/util.js.map +1 -1
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js +3 -3
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/index.js +3 -3
- package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.js +4 -4
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.js.map +1 -1
- package/dist/browser/runtime/node/community/db-handler.js +32 -32
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/challenges.js +7 -7
- package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/comment-updates.js +5 -5
- package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/db-state.js +8 -8
- package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/editing.js +6 -6
- package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +10 -7
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +4 -4
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-store.js +13 -19
- package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-validation.js +10 -10
- 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.js +5 -5
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.js +7 -7
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/community/page-generator.js +5 -7
- package/dist/browser/runtime/node/community/page-generator.js.map +1 -1
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js +2 -2
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +1 -1
- package/dist/browser/runtime/node/sqlite-lru-cache.js +2 -2
- package/dist/browser/runtime/node/sqlite-lru-cache.js.map +1 -1
- package/dist/browser/runtime/node/util.d.ts +1 -1
- package/dist/browser/runtime/node/util.js +12 -8
- package/dist/browser/runtime/node/util.js.map +1 -1
- package/dist/browser/schema/schema.js +4 -4
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/signer/constants.d.ts +1 -2
- package/dist/browser/signer/constants.js +9 -1
- package/dist/browser/signer/constants.js.map +1 -1
- package/dist/browser/signer/signatures.js +14 -12
- package/dist/browser/signer/signatures.js.map +1 -1
- package/dist/browser/stats.js +5 -5
- package/dist/browser/stats.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +9 -10
- package/dist/browser/test/test-util.js +25 -37
- package/dist/browser/test/test-util.js.map +1 -1
- package/dist/browser/types.d.ts +1 -1
- package/dist/browser/util.d.ts +2 -2
- package/dist/browser/util.js +24 -22
- package/dist/browser/util.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +242 -312
- package/dist/bundled/chunks/chunk-2rV9d50f.js +35 -0
- package/dist/bundled/chunks/{helia-for-pkc-55fcY7oN.js → helia-for-pkc-CYDRSysz.js} +6 -6
- package/dist/bundled/chunks/{local-community-Bdasy8ZJ.js → local-community-DYvRQWsK.js} +148 -98
- package/dist/bundled/chunks/{local-community-Bz-P-EGM.js → local-community-DyaGG6lj.js} +1 -1
- package/dist/bundled/chunks/{node-DU0tGecu.js → node-DadVit9c.js} +50 -43
- package/dist/bundled/chunks/{rpc-local-community-NkCEOv2-.js → rpc-local-community-1Uvl5iwp.js} +343 -111
- package/dist/bundled/chunks/schema-Dtvt2tQ8.js +16182 -0
- package/dist/bundled/chunks/src-0J9-Tmgd.js +4147 -0
- package/dist/bundled/chunks/src-4u0f92eE.js +9899 -0
- package/dist/bundled/chunks/src-BOzgM7Fp.js +800 -0
- package/dist/bundled/chunks/src-CYIMjhjK.js +48 -0
- package/dist/bundled/chunks/{util-DpR-szdu.js → util-CjfTxkQ8.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +44 -25
- package/dist/node/clients/base-client-manager.js +15 -15
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/community/community-client-manager.js +10 -12
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/community/community-gateway-selection.js +4 -4
- package/dist/node/community/community-gateway-selection.js.map +1 -1
- package/dist/node/community/community-wire.js +3 -3
- package/dist/node/community/community-wire.js.map +1 -1
- package/dist/node/community/remote-community.d.ts +1 -1
- package/dist/node/community/remote-community.js +10 -7
- package/dist/node/community/remote-community.js.map +1 -1
- package/dist/node/community/rpc-local-community.js +3 -3
- package/dist/node/community/rpc-local-community.js.map +1 -1
- package/dist/node/community/rpc-remote-community.js +5 -5
- package/dist/node/community/rpc-remote-community.js.map +1 -1
- package/dist/node/community/schema.js +5 -5
- package/dist/node/community/schema.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-client-manager.js +11 -15
- package/dist/node/pages/pages-client-manager.js.map +1 -1
- package/dist/node/pages/util.js +9 -9
- package/dist/node/pages/util.js.map +1 -1
- package/dist/node/pkc/pkc-client-manager.js +6 -6
- package/dist/node/pkc/pkc-client-manager.js.map +1 -1
- package/dist/node/pkc/pkc.js +19 -13
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/publications/comment/comment-client-manager.js +5 -5
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/node/publications/comment/comment.js +16 -16
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/publications/comment/schema.js +17 -17
- package/dist/node/publications/comment/schema.js.map +1 -1
- package/dist/node/publications/comment-edit/schema.js +7 -7
- package/dist/node/publications/comment-edit/schema.js.map +1 -1
- package/dist/node/publications/comment-moderation/schema.js +11 -7
- package/dist/node/publications/comment-moderation/schema.js.map +1 -1
- package/dist/node/publications/community-edit/schema.js +6 -6
- package/dist/node/publications/community-edit/schema.js.map +1 -1
- package/dist/node/publications/publication-author.js +3 -3
- package/dist/node/publications/publication-author.js.map +1 -1
- package/dist/node/publications/publication-client-manager.js +4 -4
- package/dist/node/publications/publication-client-manager.js.map +1 -1
- package/dist/node/publications/publication.js +9 -9
- package/dist/node/publications/publication.js.map +1 -1
- package/dist/node/publications/vote/schema.js +11 -7
- package/dist/node/publications/vote/schema.js.map +1 -1
- package/dist/node/publications/vote/vote.js.map +1 -1
- package/dist/node/pubsub-messages/schema.js +5 -5
- package/dist/node/pubsub-messages/schema.js.map +1 -1
- package/dist/node/rpc/src/index.js +54 -15
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/runtime/browser/localforage-lru.js +2 -2
- package/dist/node/runtime/browser/localforage-lru.js.map +1 -1
- package/dist/node/runtime/browser/util.d.ts +1 -1
- package/dist/node/runtime/browser/util.js +4 -2
- package/dist/node/runtime/browser/util.js.map +1 -1
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js +3 -3
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/index.js +3 -3
- package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.js +4 -4
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.js.map +1 -1
- package/dist/node/runtime/node/community/db-handler.js +32 -32
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/challenges.js +7 -7
- package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/comment-updates.js +5 -5
- package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/db-state.js +8 -8
- package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/editing.js +6 -6
- package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js +10 -7
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/lifecycle.js +4 -4
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-store.js +13 -19
- package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-validation.js +10 -10
- 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.js +5 -5
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.js +7 -7
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/community/page-generator.js +5 -7
- package/dist/node/runtime/node/community/page-generator.js.map +1 -1
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js +2 -2
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +1 -1
- package/dist/node/runtime/node/sqlite-lru-cache.js +2 -2
- package/dist/node/runtime/node/sqlite-lru-cache.js.map +1 -1
- package/dist/node/runtime/node/util.d.ts +1 -1
- package/dist/node/runtime/node/util.js +12 -8
- package/dist/node/runtime/node/util.js.map +1 -1
- package/dist/node/schema/schema.js +4 -4
- package/dist/node/schema/schema.js.map +1 -1
- package/dist/node/signer/constants.d.ts +1 -2
- package/dist/node/signer/constants.js +9 -1
- package/dist/node/signer/constants.js.map +1 -1
- package/dist/node/signer/signatures.js +14 -12
- package/dist/node/signer/signatures.js.map +1 -1
- package/dist/node/stats.js +5 -5
- package/dist/node/stats.js.map +1 -1
- package/dist/node/test/test-util.d.ts +9 -10
- package/dist/node/test/test-util.js +25 -37
- package/dist/node/test/test-util.js.map +1 -1
- package/dist/node/types.d.ts +1 -1
- package/dist/node/util.d.ts +2 -2
- package/dist/node/util.js +24 -22
- package/dist/node/util.js.map +1 -1
- package/package.json +2 -2
- package/dist/bundled/chunks/schema-qXcvCeAO.js +0 -34744
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// Create Vote section here
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { CidStringSchema, CreatePublicationUserOptionsSchema, JsonSignatureSchema, PKCTimestampSchema, PublicationBaseBeforeSigning, SignerWithAddressPublicKeySchema, hasAtLeastOneCommunityIdentifier, atLeastOneCommunityIdentifierMessage } from "../../schema/schema.js";
|
|
4
|
-
import
|
|
4
|
+
import { difference, keys, mapToObj, omit, unique } from "remeda";
|
|
5
5
|
import { keysToOmitFromSignedPropertyNames } from "../../signer/constants.js";
|
|
6
6
|
export const CreateVoteUserOptionsSchema = CreatePublicationUserOptionsSchema.extend({
|
|
7
7
|
commentCid: CidStringSchema,
|
|
8
8
|
vote: z.union([z.literal(1), z.literal(0), z.literal(-1)])
|
|
9
9
|
}).strict();
|
|
10
10
|
export const CreateVoteUserOptionsWithRefinementSchema = CreateVoteUserOptionsSchema.refine(hasAtLeastOneCommunityIdentifier, atLeastOneCommunityIdentifierMessage);
|
|
11
|
-
export const VoteSignedPropertyNames =
|
|
12
|
-
const votePickOptions = (
|
|
11
|
+
export const VoteSignedPropertyNames = keys(omit(CreateVoteUserOptionsSchema.shape, keysToOmitFromSignedPropertyNames));
|
|
12
|
+
const votePickOptions = (mapToObj([...VoteSignedPropertyNames, "signature"], (x) => [x, true]));
|
|
13
13
|
// Will be used by the community when parsing request.publication
|
|
14
14
|
export const VotePubsubMessagePublicationSchema = CreateVoteUserOptionsSchema.merge(PublicationBaseBeforeSigning)
|
|
15
15
|
.extend({ signature: JsonSignatureSchema, author: PublicationBaseBeforeSigning.shape.author.unwrap().loose().optional() })
|
|
@@ -28,9 +28,13 @@ export const VoteTablesRowSchema = VotePubsubMessagePublicationSchema.pick({
|
|
|
28
28
|
export const VoteChallengeRequestToEncryptSchema = CreateVoteUserOptionsSchema.shape.challengeRequest.unwrap().extend({
|
|
29
29
|
vote: VotePubsubMessagePublicationSchema.loose()
|
|
30
30
|
});
|
|
31
|
-
export const VotePubsubReservedFields =
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
export const VotePubsubReservedFields = difference(
|
|
32
|
+
// unique() because remeda v2's difference is multiset (removes each `other` element once, not
|
|
33
|
+
// all occurrences); `vote` appears in both source schemas AND the pubsub schema and would
|
|
34
|
+
// otherwise survive as reserved. v1's difference was set-based. (Matches comment-edit's guard.)
|
|
35
|
+
unique([
|
|
36
|
+
...keys(VoteTablesRowSchema.shape),
|
|
37
|
+
...keys(VoteChallengeRequestToEncryptSchema.shape),
|
|
34
38
|
"shortCommunityAddress",
|
|
35
39
|
"shortCommunityAddress",
|
|
36
40
|
"communityAddress",
|
|
@@ -41,5 +45,5 @@ export const VotePubsubReservedFields = remeda.difference([
|
|
|
41
45
|
"signer",
|
|
42
46
|
"clients",
|
|
43
47
|
"nameResolved"
|
|
44
|
-
],
|
|
48
|
+
]), keys(VotePubsubMessagePublicationSchema.shape));
|
|
45
49
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/publications/vote/schema.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,eAAe,EACf,kCAAkC,EAClC,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,oCAAoC,EACvC,MAAM,wBAAwB,CAAC;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/publications/vote/schema.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,eAAe,EACf,kCAAkC,EAClC,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,oCAAoC,EACvC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAE9E,MAAM,CAAC,MAAM,2BAA2B,GAAG,kCAAkC,CAAC,MAAM,CAAC;IACjF,UAAU,EAAE,eAAe;IAC3B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAA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C,gBAAgB,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC;IAClH,IAAI,EAAE,kCAAkC,CAAC,KAAK,EAAE;CACnD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU;AAC9C,8FAA8F;AAC9F,0FAA0F;AAC1F,gGAAgG;AAChG,MAAM,CAAC;IACH,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;IAClC,GAAG,IAAI,CAAC,mCAAmC,CAAC,KAAK,CAAC;IAClD,uBAAuB;IACvB,uBAAuB;IACvB,kBAAkB;IAClB,oBAAoB;IACpB,eAAe;IACf,OAAO;IACP,iBAAiB;IACjB,QAAQ;IACR,SAAS;IACT,cAAc;CACjB,CAAC,EACF,IAAI,CAAC,kCAAkC,CAAC,KAAK,CAAC,CACjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vote.js","sourceRoot":"","sources":["../../../../src/publications/vote/vote.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"vote.js","sourceRoot":"","sources":["../../../../src/publications/vote/vote.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAK9C,4CAA4C;AAC5C,MAAM,IAAK,SAAQ,WAAW;IAQ1B,YAAY,GAAQ;QAChB,KAAK,CAAC,GAAG,CAAC,CAAC;QAJN,QAAG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AAuB,CAAC,CAAC,CAAC,CAAC,kEAAkE;QAChJ,MAAM,iBAAiB,GAAG,MAAM,UAAU,CAAC;YACvC,IAAI,EAAE,OAAO;YACb,kBAAkB,EAAE,IAAI,CAAC,IAAI,CAAC,kBAAkB;YAChD,cAAc,EAAE,IAAI,CAAC,eAAe;SACvC,CAAC,CAAC;QACH,IAAI,CAAC,iBAAiB,CAAC,KAAK;YAAE,MAAM,IAAI,QAAQ,CAAC,0BAA0B,EAAE,EAAE,iBAAiB,EAAE,CAAC,CAAC;IACxG,CAAC;CACJ;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { VotePubsubMessagePublicationSchema } from "../publications/vote/schema.
|
|
|
4
4
|
import { CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "../publications/comment-edit/schema.js";
|
|
5
5
|
import { CommentIpfsSchema, CommentPubsubMessageWithFlexibleAuthorRefinementSchema, CommentUpdateForChallengeVerificationSchema } from "../publications/comment/schema.js";
|
|
6
6
|
import { ChallengeFileSchema, ChallengeFromGetChallengeSchema } from "../community/schema.js";
|
|
7
|
-
import
|
|
7
|
+
import { keys, omit } from "remeda";
|
|
8
8
|
import { CommentModerationPubsubMessagePublicationSchema } from "../publications/comment-moderation/schema.js";
|
|
9
9
|
import { CommunityEditPubsubMessagePublicationSchema } from "../publications/community-edit/schema.js";
|
|
10
10
|
import { Uint8ArraySchema, nonNegativeIntStringSchema } from "../schema.js";
|
|
@@ -49,7 +49,7 @@ export const DecryptedChallengeRequestPublicationSchema = z.object({
|
|
|
49
49
|
});
|
|
50
50
|
// ChallengeRequestMessage.encrypted.ciphertext decrypts to JSON, with these props
|
|
51
51
|
export const DecryptedChallengeRequestSchema = DecryptedChallengeRequestPublicationSchema.merge(CreatePublicationUserOptionsSchema.shape.challengeRequest.unwrap());
|
|
52
|
-
export const ChallengeRequestMessageSignedPropertyNames =
|
|
52
|
+
export const ChallengeRequestMessageSignedPropertyNames = keys(omit(ChallengeRequestMessageSchema.shape, ["signature"]));
|
|
53
53
|
// Challenge message
|
|
54
54
|
export const ChallengeInChallengePubsubMessageSchema = z
|
|
55
55
|
.object({
|
|
@@ -67,7 +67,7 @@ export const DecryptedChallengeSchema = z
|
|
|
67
67
|
challenges: ChallengeInChallengePubsubMessageSchema.array()
|
|
68
68
|
})
|
|
69
69
|
.strict();
|
|
70
|
-
export const ChallengeMessageSignedPropertyNames =
|
|
70
|
+
export const ChallengeMessageSignedPropertyNames = keys(omit(ChallengeMessageSchema.shape, ["signature"]));
|
|
71
71
|
// Challenge answer
|
|
72
72
|
export const ChallengeAnswerMessageSchema = PubsubMessageBaseSchema.extend({
|
|
73
73
|
type: z.literal("CHALLENGEANSWER"),
|
|
@@ -78,7 +78,7 @@ export const DecryptedChallengeAnswerSchema = z
|
|
|
78
78
|
challengeAnswers: ChallengeAnswersSchema // for example ['2+2=4', '1+7=8']
|
|
79
79
|
})
|
|
80
80
|
.strict();
|
|
81
|
-
export const ChallengeAnswerMessageSignedPropertyNames =
|
|
81
|
+
export const ChallengeAnswerMessageSignedPropertyNames = keys(omit(ChallengeAnswerMessageSchema.shape, ["signature"]));
|
|
82
82
|
// Challenge Verification
|
|
83
83
|
export const ChallengeVerificationMessageSchema = PubsubMessageBaseSchema.extend({
|
|
84
84
|
type: z.literal("CHALLENGEVERIFICATION"),
|
|
@@ -93,6 +93,6 @@ export const DecryptedChallengeVerificationSchema = z
|
|
|
93
93
|
commentUpdate: CommentUpdateForChallengeVerificationSchema.loose()
|
|
94
94
|
})
|
|
95
95
|
.strict();
|
|
96
|
-
export const ChallengeVerificationMessageSignedPropertyNames =
|
|
96
|
+
export const ChallengeVerificationMessageSignedPropertyNames = keys(omit(ChallengeVerificationMessageSchema.shape, ["signature"]));
|
|
97
97
|
// Handling challenges for community
|
|
98
98
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/pubsub-messages/schema.ts"],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;CACrE,CAAC;KACD,MAAM,EAAE,CAAC;AAEd,MAAM,CAAC,MAAM,+CAA+C,GAAG,IAAI,CAAC,IAAI,CAAC,kCAAkC,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AAEnI,oCAAoC"}
|
|
@@ -12,7 +12,7 @@ import Logger from "../../logger.js";
|
|
|
12
12
|
import { PKCError } from "../../pkc-error.js";
|
|
13
13
|
import { LocalCommunity } from "../../runtime/browser/community/local-community.js";
|
|
14
14
|
import { hideClassPrivateProps, replaceXWithY } from "../../util.js";
|
|
15
|
-
import
|
|
15
|
+
import { keys, mapValues, omit } from "remeda";
|
|
16
16
|
import { parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, parseDecryptedChallengeAnswerWithPKCErrorIfItFails, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails } from "../../schema/schema-util.js";
|
|
17
17
|
import { stringify as deterministicStringify } from "safe-stable-stringify";
|
|
18
18
|
import { TypedEmitter } from "tiny-typed-emitter";
|
|
@@ -738,7 +738,7 @@ class PKCWsServer extends TypedEmitter {
|
|
|
738
738
|
...builtInChallenges, // built-ins first
|
|
739
739
|
...(pkc.settings?.challenges || {}) // user-defined override
|
|
740
740
|
};
|
|
741
|
-
const challenges =
|
|
741
|
+
const challenges = mapValues(allChallengeFactories, (challengeFactory) => omit(challengeFactory({ challengeSettings: {} }), ["getChallenge"]));
|
|
742
742
|
return { pkcOptions, challenges };
|
|
743
743
|
}
|
|
744
744
|
async settingsSubscribe(params, connectionId) {
|
|
@@ -788,11 +788,11 @@ class PKCWsServer extends TypedEmitter {
|
|
|
788
788
|
});
|
|
789
789
|
this._initPKC(newPKC); // swap to new instance first so new RPC calls don't hit a destroyed pkc
|
|
790
790
|
// send a settingsNotification to all subscribers
|
|
791
|
-
for (const connectionId of
|
|
791
|
+
for (const connectionId of keys(this._onSettingsChange)) {
|
|
792
792
|
const connectionHandlers = this._onSettingsChange[connectionId];
|
|
793
793
|
if (!connectionHandlers)
|
|
794
794
|
continue;
|
|
795
|
-
for (const subscriptionId of
|
|
795
|
+
for (const subscriptionId of keys(connectionHandlers)) {
|
|
796
796
|
const handler = connectionHandlers[subscriptionId];
|
|
797
797
|
if (!handler)
|
|
798
798
|
continue;
|
|
@@ -972,9 +972,42 @@ class PKCWsServer extends TypedEmitter {
|
|
|
972
972
|
sendEvent("error", rpcError);
|
|
973
973
|
};
|
|
974
974
|
community.on("error", errorListener);
|
|
975
|
+
// Guards recovery from firing during transitions we initiate on purpose (an unsubscribe
|
|
976
|
+
// teardown, or the stop()+update() swap in the settings handler below)
|
|
977
|
+
let intentionalStopInFlight = false;
|
|
978
|
+
let recovering = false;
|
|
979
|
+
// The subscription's mirror shares a server-side pkc._updatingCommunities entry with every
|
|
980
|
+
// other subscription to the same community. That shared entry can be stopped while this
|
|
981
|
+
// client is still subscribed (its refcount driven to 0 by another subscription's teardown
|
|
982
|
+
// or setSettings, or a pkc being destroyed), which cascades this mirror to "stopped"
|
|
983
|
+
// (src/community/remote-community.ts). Nothing else revives it, so the client's websocket
|
|
984
|
+
// would stay connected but silent forever (issue #129 / #181). The client never asked to
|
|
985
|
+
// stop, so re-establish updating on a fresh entry.
|
|
986
|
+
const recoverIfStrandedListener = async (newState) => {
|
|
987
|
+
if (newState !== "stopped" || isStartedCommunity || intentionalStopInFlight || recovering)
|
|
988
|
+
return;
|
|
989
|
+
// Client has unsubscribed if the cleanup is gone; don't resurrect a dead subscription
|
|
990
|
+
if (!this.subscriptionCleanups?.[connectionId]?.[subscriptionId])
|
|
991
|
+
return;
|
|
992
|
+
recovering = true;
|
|
993
|
+
try {
|
|
994
|
+
log("Recovering community subscription", community.address, "whose shared updating instance was stopped");
|
|
995
|
+
await community.update();
|
|
996
|
+
}
|
|
997
|
+
catch (e) {
|
|
998
|
+
log.error("Failed to recover community subscription after its updating instance stopped", community.address, e);
|
|
999
|
+
}
|
|
1000
|
+
finally {
|
|
1001
|
+
recovering = false;
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
community.on("statechange", recoverIfStrandedListener);
|
|
975
1005
|
// cleanup function
|
|
976
1006
|
this.subscriptionCleanups[connectionId][subscriptionId] = async () => {
|
|
977
1007
|
log("Cleaning up community", community.address, "client subscription");
|
|
1008
|
+
// Remove the recovery listener FIRST so the stop() below (an intentional teardown) does
|
|
1009
|
+
// not trigger a resurrection
|
|
1010
|
+
community.removeListener("statechange", recoverIfStrandedListener);
|
|
978
1011
|
community.removeListener("update", updateListener);
|
|
979
1012
|
community.removeListener("updatingstatechange", updatingStateListener);
|
|
980
1013
|
community.removeListener("error", errorListener);
|
|
@@ -989,9 +1022,15 @@ class PKCWsServer extends TypedEmitter {
|
|
|
989
1022
|
this._onSettingsChange[connectionId][subscriptionId] = async ({ newPKC }) => {
|
|
990
1023
|
// TODO this may need changing
|
|
991
1024
|
if (!isStartedCommunity) {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1025
|
+
intentionalStopInFlight = true;
|
|
1026
|
+
try {
|
|
1027
|
+
community._pkc = newPKC;
|
|
1028
|
+
await community.stop();
|
|
1029
|
+
await community.update();
|
|
1030
|
+
}
|
|
1031
|
+
finally {
|
|
1032
|
+
intentionalStopInFlight = false;
|
|
1033
|
+
}
|
|
995
1034
|
}
|
|
996
1035
|
};
|
|
997
1036
|
// if fail, cleanup
|
|
@@ -1013,7 +1052,7 @@ class PKCWsServer extends TypedEmitter {
|
|
|
1013
1052
|
async _createCommentInstanceFromPublishCommentParams(params) {
|
|
1014
1053
|
const pkc = await this._getPKCInstance();
|
|
1015
1054
|
const comment = await pkc.createComment(params.comment);
|
|
1016
|
-
comment.challengeRequest =
|
|
1055
|
+
comment.challengeRequest = omit(params, ["comment"]);
|
|
1017
1056
|
return comment;
|
|
1018
1057
|
}
|
|
1019
1058
|
async publishComment(params, connectionId) {
|
|
@@ -1087,7 +1126,7 @@ class PKCWsServer extends TypedEmitter {
|
|
|
1087
1126
|
async _createVoteInstanceFromPublishVoteParams(params) {
|
|
1088
1127
|
const pkc = await this._getPKCInstance();
|
|
1089
1128
|
const vote = await pkc.createVote(params.vote);
|
|
1090
|
-
vote.challengeRequest =
|
|
1129
|
+
vote.challengeRequest = omit(params, ["vote"]);
|
|
1091
1130
|
return vote;
|
|
1092
1131
|
}
|
|
1093
1132
|
async publishVote(params, connectionId) {
|
|
@@ -1145,7 +1184,7 @@ class PKCWsServer extends TypedEmitter {
|
|
|
1145
1184
|
async _createCommunityEditInstanceFromPublishCommunityEditParams(params) {
|
|
1146
1185
|
const pkc = await this._getPKCInstance();
|
|
1147
1186
|
const communityEdit = await pkc.createCommunityEdit(params.communityEdit);
|
|
1148
|
-
communityEdit.challengeRequest =
|
|
1187
|
+
communityEdit.challengeRequest = omit(params, ["communityEdit"]);
|
|
1149
1188
|
return communityEdit;
|
|
1150
1189
|
}
|
|
1151
1190
|
async publishCommunityEdit(params, connectionId) {
|
|
@@ -1207,7 +1246,7 @@ class PKCWsServer extends TypedEmitter {
|
|
|
1207
1246
|
async _createCommentEditInstanceFromPublishCommentEditParams(params) {
|
|
1208
1247
|
const pkc = await this._getPKCInstance();
|
|
1209
1248
|
const commentEdit = await pkc.createCommentEdit(params.commentEdit);
|
|
1210
|
-
commentEdit.challengeRequest =
|
|
1249
|
+
commentEdit.challengeRequest = omit(params, ["commentEdit"]);
|
|
1211
1250
|
return commentEdit;
|
|
1212
1251
|
}
|
|
1213
1252
|
async publishCommentEdit(params, connectionId) {
|
|
@@ -1272,7 +1311,7 @@ class PKCWsServer extends TypedEmitter {
|
|
|
1272
1311
|
async _createCommentModerationInstanceFromPublishCommentModerationParams(params) {
|
|
1273
1312
|
const pkc = await this._getPKCInstance();
|
|
1274
1313
|
const commentModeration = await pkc.createCommentModeration(params.commentModeration);
|
|
1275
|
-
commentModeration.challengeRequest =
|
|
1314
|
+
commentModeration.challengeRequest = omit(params, ["commentModeration"]);
|
|
1276
1315
|
return commentModeration;
|
|
1277
1316
|
}
|
|
1278
1317
|
async publishCommentModeration(params, connectionId) {
|
|
@@ -1605,15 +1644,15 @@ class PKCWsServer extends TypedEmitter {
|
|
|
1605
1644
|
return { success: true };
|
|
1606
1645
|
}
|
|
1607
1646
|
async destroy() {
|
|
1608
|
-
for (const connectionId of
|
|
1609
|
-
for (const subscriptionId of
|
|
1647
|
+
for (const connectionId of keys(this.subscriptionCleanups))
|
|
1648
|
+
for (const subscriptionId of keys(this.subscriptionCleanups[connectionId]))
|
|
1610
1649
|
await this.unsubscribe([{ subscriptionId: Number(subscriptionId) }], connectionId);
|
|
1611
1650
|
this.ws.close();
|
|
1612
1651
|
if (this._ownsHttpServer && this._httpServer)
|
|
1613
1652
|
await new Promise((r) => this._httpServer.close(() => r()));
|
|
1614
1653
|
const pkc = await this._getPKCInstance();
|
|
1615
1654
|
await pkc.destroy(); // this will stop all started communities
|
|
1616
|
-
for (const communityAddress of
|
|
1655
|
+
for (const communityAddress of keys(this._startedCommunities)) {
|
|
1617
1656
|
delete this._startedCommunities[communityAddress];
|
|
1618
1657
|
}
|
|
1619
1658
|
this._exportCommunityInstances.clear();
|