@pkcprotocol/pkc-js 0.0.11
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/LICENSE +339 -0
- package/README.md +1663 -0
- package/dist/browser/challenges.d.ts +1 -0
- package/dist/browser/challenges.js +2 -0
- package/dist/browser/challenges.js.map +1 -0
- package/dist/browser/clients/base-client-manager.d.ts +126 -0
- package/dist/browser/clients/base-client-manager.js +673 -0
- package/dist/browser/clients/base-client-manager.js.map +1 -0
- package/dist/browser/clients/name-resolver-client.d.ts +8 -0
- package/dist/browser/clients/name-resolver-client.js +10 -0
- package/dist/browser/clients/name-resolver-client.js.map +1 -0
- package/dist/browser/clients/pkc-typed-emitter.d.ts +9 -0
- package/dist/browser/clients/pkc-typed-emitter.js +52 -0
- package/dist/browser/clients/pkc-typed-emitter.js.map +1 -0
- package/dist/browser/clients/rpc-client/decode-rpc-response-util.d.ts +8 -0
- package/dist/browser/clients/rpc-client/decode-rpc-response-util.js +53 -0
- package/dist/browser/clients/rpc-client/decode-rpc-response-util.js.map +1 -0
- package/dist/browser/clients/rpc-client/pkc-rpc-client.d.ts +68 -0
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js +404 -0
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -0
- package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +147 -0
- package/dist/browser/clients/rpc-client/rpc-schema-util.js +11 -0
- package/dist/browser/clients/rpc-client/rpc-schema-util.js.map +1 -0
- package/dist/browser/clients/rpc-client/schema.d.ts +433 -0
- package/dist/browser/clients/rpc-client/schema.js +49 -0
- package/dist/browser/clients/rpc-client/schema.js.map +1 -0
- package/dist/browser/clients/rpc-client/types.d.ts +8 -0
- package/dist/browser/clients/rpc-client/types.js +2 -0
- package/dist/browser/clients/rpc-client/types.js.map +1 -0
- package/dist/browser/community/community-client-manager.d.ts +60 -0
- package/dist/browser/community/community-client-manager.js +717 -0
- package/dist/browser/community/community-client-manager.js.map +1 -0
- package/dist/browser/community/community-clients.d.ts +18 -0
- package/dist/browser/community/community-clients.js +12 -0
- package/dist/browser/community/community-clients.js.map +1 -0
- package/dist/browser/community/community-wire.d.ts +20 -0
- package/dist/browser/community/community-wire.js +38 -0
- package/dist/browser/community/community-wire.js.map +1 -0
- package/dist/browser/community/remote-community.d.ts +110 -0
- package/dist/browser/community/remote-community.js +555 -0
- package/dist/browser/community/remote-community.js.map +1 -0
- package/dist/browser/community/rpc-local-community.d.ts +41 -0
- package/dist/browser/community/rpc-local-community.js +289 -0
- package/dist/browser/community/rpc-local-community.js.map +1 -0
- package/dist/browser/community/rpc-remote-community.d.ts +18 -0
- package/dist/browser/community/rpc-remote-community.js +286 -0
- package/dist/browser/community/rpc-remote-community.js.map +1 -0
- package/dist/browser/community/schema.d.ts +4217 -0
- package/dist/browser/community/schema.js +289 -0
- package/dist/browser/community/schema.js.map +1 -0
- package/dist/browser/community/types.d.ts +135 -0
- package/dist/browser/community/types.js +2 -0
- package/dist/browser/community/types.js.map +1 -0
- package/dist/browser/constants.d.ts +6 -0
- package/dist/browser/constants.js +9 -0
- package/dist/browser/constants.js.map +1 -0
- package/dist/browser/decorator-util.d.ts +1 -0
- package/dist/browser/decorator-util.js +35 -0
- package/dist/browser/decorator-util.js.map +1 -0
- package/dist/browser/errors.d.ts +343 -0
- package/dist/browser/errors.js +358 -0
- package/dist/browser/errors.js.map +1 -0
- package/dist/browser/general-util/limited-set.d.ts +15 -0
- package/dist/browser/general-util/limited-set.js +66 -0
- package/dist/browser/general-util/limited-set.js.map +1 -0
- package/dist/browser/generated-version.d.ts +1 -0
- package/dist/browser/generated-version.js +3 -0
- package/dist/browser/generated-version.js.map +1 -0
- package/dist/browser/generic-state-client.d.ts +6 -0
- package/dist/browser/generic-state-client.js +11 -0
- package/dist/browser/generic-state-client.js.map +1 -0
- package/dist/browser/helia/helia-for-pkc.d.ts +3 -0
- package/dist/browser/helia/helia-for-pkc.js +255 -0
- package/dist/browser/helia/helia-for-pkc.js.map +1 -0
- package/dist/browser/helia/ipns-over-pubsub-with-fetch.d.ts +36 -0
- package/dist/browser/helia/ipns-over-pubsub-with-fetch.js +229 -0
- package/dist/browser/helia/ipns-over-pubsub-with-fetch.js.map +1 -0
- package/dist/browser/helia/libp2pjsClient.d.ts +27 -0
- package/dist/browser/helia/libp2pjsClient.js +15 -0
- package/dist/browser/helia/libp2pjsClient.js.map +1 -0
- package/dist/browser/helia/types.d.ts +19 -0
- package/dist/browser/helia/types.js +2 -0
- package/dist/browser/helia/types.js.map +1 -0
- package/dist/browser/helia/util.d.ts +13 -0
- package/dist/browser/helia/util.js +98 -0
- package/dist/browser/helia/util.js.map +1 -0
- package/dist/browser/index.d.ts +244 -0
- package/dist/browser/index.js +36 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/logger.d.ts +12 -0
- package/dist/browser/logger.js +11 -0
- package/dist/browser/logger.js.map +1 -0
- package/dist/browser/pages/pages-client-manager.d.ts +159 -0
- package/dist/browser/pages/pages-client-manager.js +334 -0
- package/dist/browser/pages/pages-client-manager.js.map +1 -0
- package/dist/browser/pages/pages-clients.d.ts +11 -0
- package/dist/browser/pages/pages-clients.js +10 -0
- package/dist/browser/pages/pages-clients.js.map +1 -0
- package/dist/browser/pages/pages.d.ts +107 -0
- package/dist/browser/pages/pages.js +262 -0
- package/dist/browser/pages/pages.js.map +1 -0
- package/dist/browser/pages/schema-util.d.ts +3 -0
- package/dist/browser/pages/schema-util.js +3 -0
- package/dist/browser/pages/schema-util.js.map +1 -0
- package/dist/browser/pages/schema.d.ts +719 -0
- package/dist/browser/pages/schema.js +32 -0
- package/dist/browser/pages/schema.js.map +1 -0
- package/dist/browser/pages/types.d.ts +44 -0
- package/dist/browser/pages/types.js +2 -0
- package/dist/browser/pages/types.js.map +1 -0
- package/dist/browser/pages/util.d.ts +56 -0
- package/dist/browser/pages/util.js +446 -0
- package/dist/browser/pages/util.js.map +1 -0
- package/dist/browser/pkc/pkc-client-manager.d.ts +44 -0
- package/dist/browser/pkc/pkc-client-manager.js +156 -0
- package/dist/browser/pkc/pkc-client-manager.js.map +1 -0
- package/dist/browser/pkc/pkc-clients.d.ts +11 -0
- package/dist/browser/pkc/pkc-clients.js +8 -0
- package/dist/browser/pkc/pkc-clients.js.map +1 -0
- package/dist/browser/pkc/pkc-with-rpc-client.d.ts +19 -0
- package/dist/browser/pkc/pkc-with-rpc-client.js +128 -0
- package/dist/browser/pkc/pkc-with-rpc-client.js.map +1 -0
- package/dist/browser/pkc/pkc.d.ts +137 -0
- package/dist/browser/pkc/pkc.js +888 -0
- package/dist/browser/pkc/pkc.js.map +1 -0
- package/dist/browser/pkc/tracked-instance-registry-util.d.ts +44 -0
- package/dist/browser/pkc/tracked-instance-registry-util.js +106 -0
- package/dist/browser/pkc/tracked-instance-registry-util.js.map +1 -0
- package/dist/browser/pkc/tracked-instance-registry.d.ts +18 -0
- package/dist/browser/pkc/tracked-instance-registry.js +134 -0
- package/dist/browser/pkc/tracked-instance-registry.js.map +1 -0
- package/dist/browser/pkc-error.d.ts +65 -0
- package/dist/browser/pkc-error.js +137 -0
- package/dist/browser/pkc-error.js.map +1 -0
- package/dist/browser/publications/comment/comment-client-manager.d.ts +86 -0
- package/dist/browser/publications/comment/comment-client-manager.js +908 -0
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -0
- package/dist/browser/publications/comment/comment-clients.d.ts +19 -0
- package/dist/browser/publications/comment/comment-clients.js +12 -0
- package/dist/browser/publications/comment/comment-clients.js.map +1 -0
- package/dist/browser/publications/comment/comment-util.d.ts +10 -0
- package/dist/browser/publications/comment/comment-util.js +202 -0
- package/dist/browser/publications/comment/comment-util.js.map +1 -0
- package/dist/browser/publications/comment/comment.d.ts +147 -0
- package/dist/browser/publications/comment/comment.js +1044 -0
- package/dist/browser/publications/comment/comment.js.map +1 -0
- package/dist/browser/publications/comment/schema.d.ts +1237 -0
- package/dist/browser/publications/comment/schema.js +184 -0
- package/dist/browser/publications/comment/schema.js.map +1 -0
- package/dist/browser/publications/comment/types.d.ts +100 -0
- package/dist/browser/publications/comment/types.js +2 -0
- package/dist/browser/publications/comment/types.js.map +1 -0
- package/dist/browser/publications/comment-edit/comment-edit.d.ts +41 -0
- package/dist/browser/publications/comment-edit/comment-edit.js +63 -0
- package/dist/browser/publications/comment-edit/comment-edit.js.map +1 -0
- package/dist/browser/publications/comment-edit/schema.d.ts +295 -0
- package/dist/browser/publications/comment-edit/schema.js +55 -0
- package/dist/browser/publications/comment-edit/schema.js.map +1 -0
- package/dist/browser/publications/comment-edit/types.d.ts +25 -0
- package/dist/browser/publications/comment-edit/types.js +2 -0
- package/dist/browser/publications/comment-edit/types.js.map +1 -0
- package/dist/browser/publications/comment-moderation/comment-moderation.d.ts +36 -0
- package/dist/browser/publications/comment-moderation/comment-moderation.js +53 -0
- package/dist/browser/publications/comment-moderation/comment-moderation.js.map +1 -0
- package/dist/browser/publications/comment-moderation/schema.d.ts +315 -0
- package/dist/browser/publications/comment-moderation/schema.js +62 -0
- package/dist/browser/publications/comment-moderation/schema.js.map +1 -0
- package/dist/browser/publications/comment-moderation/types.d.ts +22 -0
- package/dist/browser/publications/comment-moderation/types.js +2 -0
- package/dist/browser/publications/comment-moderation/types.js.map +1 -0
- package/dist/browser/publications/community-edit/community-edit.d.ts +35 -0
- package/dist/browser/publications/community-edit/community-edit.js +50 -0
- package/dist/browser/publications/community-edit/community-edit.js.map +1 -0
- package/dist/browser/publications/community-edit/schema.d.ts +467 -0
- package/dist/browser/publications/community-edit/schema.js +36 -0
- package/dist/browser/publications/community-edit/schema.js.map +1 -0
- package/dist/browser/publications/community-edit/types.d.ts +19 -0
- package/dist/browser/publications/community-edit/types.js +2 -0
- package/dist/browser/publications/community-edit/types.js.map +1 -0
- package/dist/browser/publications/publication-author.d.ts +22 -0
- package/dist/browser/publications/publication-author.js +66 -0
- package/dist/browser/publications/publication-author.js.map +1 -0
- package/dist/browser/publications/publication-client-manager.d.ts +62 -0
- package/dist/browser/publications/publication-client-manager.js +257 -0
- package/dist/browser/publications/publication-client-manager.js.map +1 -0
- package/dist/browser/publications/publication-clients.d.ts +19 -0
- package/dist/browser/publications/publication-clients.js +12 -0
- package/dist/browser/publications/publication-clients.js.map +1 -0
- package/dist/browser/publications/publication-community.d.ts +55 -0
- package/dist/browser/publications/publication-community.js +87 -0
- package/dist/browser/publications/publication-community.js.map +1 -0
- package/dist/browser/publications/publication.d.ts +120 -0
- package/dist/browser/publications/publication.js +950 -0
- package/dist/browser/publications/publication.js.map +1 -0
- package/dist/browser/publications/types.d.ts +26 -0
- package/dist/browser/publications/types.js +2 -0
- package/dist/browser/publications/types.js.map +1 -0
- package/dist/browser/publications/vote/schema.d.ts +150 -0
- package/dist/browser/publications/vote/schema.js +44 -0
- package/dist/browser/publications/vote/schema.js.map +1 -0
- package/dist/browser/publications/vote/types.d.ts +21 -0
- package/dist/browser/publications/vote/types.js +2 -0
- package/dist/browser/publications/vote/types.js.map +1 -0
- package/dist/browser/publications/vote/vote.d.ts +36 -0
- package/dist/browser/publications/vote/vote.js +49 -0
- package/dist/browser/publications/vote/vote.js.map +1 -0
- package/dist/browser/pubsub-messages/schema.d.ts +964 -0
- package/dist/browser/pubsub-messages/schema.js +98 -0
- package/dist/browser/pubsub-messages/schema.js.map +1 -0
- package/dist/browser/pubsub-messages/types.d.ts +81 -0
- package/dist/browser/pubsub-messages/types.js +2 -0
- package/dist/browser/pubsub-messages/types.js.map +1 -0
- package/dist/browser/rpc/src/index.d.ts +483 -0
- package/dist/browser/rpc/src/index.js +1267 -0
- package/dist/browser/rpc/src/index.js.map +1 -0
- package/dist/browser/rpc/src/json-rpc-util.d.ts +1 -0
- package/dist/browser/rpc/src/json-rpc-util.js +19 -0
- package/dist/browser/rpc/src/json-rpc-util.js.map +1 -0
- package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +132 -0
- package/dist/browser/rpc/src/lib/pkc-js/index.js +29 -0
- package/dist/browser/rpc/src/lib/pkc-js/index.js.map +1 -0
- package/dist/browser/rpc/src/lib/pkc-js/pkc-js-mock.d.ts +1 -0
- package/dist/browser/rpc/src/lib/pkc-js/pkc-js-mock.js +472 -0
- package/dist/browser/rpc/src/lib/pkc-js/pkc-js-mock.js.map +1 -0
- package/dist/browser/rpc/src/schema.d.ts +843 -0
- package/dist/browser/rpc/src/schema.js +28 -0
- package/dist/browser/rpc/src/schema.js.map +1 -0
- package/dist/browser/rpc/src/types.d.ts +24 -0
- package/dist/browser/rpc/src/types.js +2 -0
- package/dist/browser/rpc/src/types.js.map +1 -0
- package/dist/browser/rpc/src/utils.d.ts +7 -0
- package/dist/browser/rpc/src/utils.js +58 -0
- package/dist/browser/rpc/src/utils.js.map +1 -0
- package/dist/browser/runtime/browser/community/challenges/index.d.ts +6 -0
- package/dist/browser/runtime/browser/community/challenges/index.js +7 -0
- package/dist/browser/runtime/browser/community/challenges/index.js.map +1 -0
- package/dist/browser/runtime/browser/community/local-community.d.ts +3 -0
- package/dist/browser/runtime/browser/community/local-community.js +6 -0
- package/dist/browser/runtime/browser/community/local-community.js.map +1 -0
- package/dist/browser/runtime/browser/db-handler.d.ts +4 -0
- package/dist/browser/runtime/browser/db-handler.js +8 -0
- package/dist/browser/runtime/browser/db-handler.js.map +1 -0
- package/dist/browser/runtime/browser/localforage-lru.d.ts +15 -0
- package/dist/browser/runtime/browser/localforage-lru.js +140 -0
- package/dist/browser/runtime/browser/localforage-lru.js.map +1 -0
- package/dist/browser/runtime/browser/lru-storage.d.ts +14 -0
- package/dist/browser/runtime/browser/lru-storage.js +34 -0
- package/dist/browser/runtime/browser/lru-storage.js.map +1 -0
- package/dist/browser/runtime/browser/native-functions.d.ts +3 -0
- package/dist/browser/runtime/browser/native-functions.js +6 -0
- package/dist/browser/runtime/browser/native-functions.js.map +1 -0
- package/dist/browser/runtime/browser/polyfill.d.ts +3 -0
- package/dist/browser/runtime/browser/polyfill.js +37 -0
- package/dist/browser/runtime/browser/polyfill.js.map +1 -0
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts +1 -0
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js +4 -0
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
- package/dist/browser/runtime/browser/storage.d.ts +13 -0
- package/dist/browser/runtime/browser/storage.js +37 -0
- package/dist/browser/runtime/browser/storage.js.map +1 -0
- package/dist/browser/runtime/browser/util.d.ts +14 -0
- package/dist/browser/runtime/browser/util.js +61 -0
- package/dist/browser/runtime/browser/util.js.map +1 -0
- package/dist/browser/runtime/node/address-rewriter-db.d.ts +31 -0
- package/dist/browser/runtime/node/address-rewriter-db.js +156 -0
- package/dist/browser/runtime/node/address-rewriter-db.js.map +1 -0
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.d.ts +45 -0
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js +493 -0
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.d.ts +8 -0
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +280 -0
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/exclude/index.d.ts +3 -0
- package/dist/browser/runtime/node/community/challenges/exclude/index.js +4 -0
- package/dist/browser/runtime/node/community/challenges/exclude/index.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.d.ts +5 -0
- package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.js +127 -0
- package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/exclude/utils.d.ts +13 -0
- package/dist/browser/runtime/node/community/challenges/exclude/utils.js +52 -0
- package/dist/browser/runtime/node/community/challenges/exclude/utils.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/index.d.ts +32 -0
- package/dist/browser/runtime/node/community/challenges/index.js +307 -0
- package/dist/browser/runtime/node/community/challenges/index.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.d.ts +5 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +118 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/fail.d.ts +5 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/fail.js +26 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/fail.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.d.ts +5 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.js +135 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/question.d.ts +5 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/question.js +66 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/question.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/text-math.d.ts +5 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/text-math.js +61 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/text-math.js.map +1 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.d.ts +5 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +118 -0
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -0
- package/dist/browser/runtime/node/community/db-handler-types.d.ts +19 -0
- package/dist/browser/runtime/node/community/db-handler-types.js +2 -0
- package/dist/browser/runtime/node/community/db-handler-types.js.map +1 -0
- package/dist/browser/runtime/node/community/db-handler.d.ts +226 -0
- package/dist/browser/runtime/node/community/db-handler.js +2462 -0
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -0
- package/dist/browser/runtime/node/community/db-row-parser.d.ts +19 -0
- package/dist/browser/runtime/node/community/db-row-parser.js +40 -0
- package/dist/browser/runtime/node/community/db-row-parser.js.map +1 -0
- package/dist/browser/runtime/node/community/keyv-better-sqlite3.d.ts +68 -0
- package/dist/browser/runtime/node/community/keyv-better-sqlite3.js +251 -0
- package/dist/browser/runtime/node/community/keyv-better-sqlite3.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community.d.ts +129 -0
- package/dist/browser/runtime/node/community/local-community.js +2978 -0
- package/dist/browser/runtime/node/community/local-community.js.map +1 -0
- package/dist/browser/runtime/node/community/page-generator.d.ts +433 -0
- package/dist/browser/runtime/node/community/page-generator.js +441 -0
- package/dist/browser/runtime/node/community/page-generator.js.map +1 -0
- package/dist/browser/runtime/node/lru-storage.d.ts +14 -0
- package/dist/browser/runtime/node/lru-storage.js +40 -0
- package/dist/browser/runtime/node/lru-storage.js.map +1 -0
- package/dist/browser/runtime/node/native-functions.d.ts +3 -0
- package/dist/browser/runtime/node/native-functions.js +7 -0
- package/dist/browser/runtime/node/native-functions.js.map +1 -0
- package/dist/browser/runtime/node/polyfill.d.ts +3 -0
- package/dist/browser/runtime/node/polyfill.js +20 -0
- package/dist/browser/runtime/node/polyfill.js.map +1 -0
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts +4 -0
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js +240 -0
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
- package/dist/browser/runtime/node/sqlite-lru-cache.d.ts +52 -0
- package/dist/browser/runtime/node/sqlite-lru-cache.js +127 -0
- package/dist/browser/runtime/node/sqlite-lru-cache.js.map +1 -0
- package/dist/browser/runtime/node/storage.d.ts +14 -0
- package/dist/browser/runtime/node/storage.js +52 -0
- package/dist/browser/runtime/node/storage.js.map +1 -0
- package/dist/browser/runtime/node/test/helpers/hanging-runner.d.ts +1 -0
- package/dist/browser/runtime/node/test/helpers/hanging-runner.js +157 -0
- package/dist/browser/runtime/node/test/helpers/hanging-runner.js.map +1 -0
- package/dist/browser/runtime/node/test/helpers/run-hanging-node.d.ts +7 -0
- package/dist/browser/runtime/node/test/helpers/run-hanging-node.js +68 -0
- package/dist/browser/runtime/node/test/helpers/run-hanging-node.js.map +1 -0
- package/dist/browser/runtime/node/test/mock-http-router.d.ts +54 -0
- package/dist/browser/runtime/node/test/mock-http-router.js +397 -0
- package/dist/browser/runtime/node/test/mock-http-router.js.map +1 -0
- package/dist/browser/runtime/node/util.d.ts +43 -0
- package/dist/browser/runtime/node/util.js +384 -0
- package/dist/browser/runtime/node/util.js.map +1 -0
- package/dist/browser/schema/schema-util.d.ts +2751 -0
- package/dist/browser/schema/schema-util.js +562 -0
- package/dist/browser/schema/schema-util.js.map +1 -0
- package/dist/browser/schema/schema.d.ts +237 -0
- package/dist/browser/schema/schema.js +128 -0
- package/dist/browser/schema/schema.js.map +1 -0
- package/dist/browser/schema.d.ts +1142 -0
- package/dist/browser/schema.js +104 -0
- package/dist/browser/schema.js.map +1 -0
- package/dist/browser/signer/constants.d.ts +2 -0
- package/dist/browser/signer/constants.js +3 -0
- package/dist/browser/signer/constants.js.map +1 -0
- package/dist/browser/signer/encryption.d.ts +21 -0
- package/dist/browser/signer/encryption.js +122 -0
- package/dist/browser/signer/encryption.js.map +1 -0
- package/dist/browser/signer/index.d.ts +21 -0
- package/dist/browser/signer/index.js +49 -0
- package/dist/browser/signer/index.js.map +1 -0
- package/dist/browser/signer/signatures.d.ts +200 -0
- package/dist/browser/signer/signatures.js +594 -0
- package/dist/browser/signer/signatures.js.map +1 -0
- package/dist/browser/signer/types.d.ts +20 -0
- package/dist/browser/signer/types.js +2 -0
- package/dist/browser/signer/types.js.map +1 -0
- package/dist/browser/signer/util.d.ts +14 -0
- package/dist/browser/signer/util.js +156 -0
- package/dist/browser/signer/util.js.map +1 -0
- package/dist/browser/stats.d.ts +15 -0
- package/dist/browser/stats.js +64 -0
- package/dist/browser/stats.js.map +1 -0
- package/dist/browser/test/mock-ipfs-client.d.ts +34 -0
- package/dist/browser/test/mock-ipfs-client.js +208 -0
- package/dist/browser/test/mock-ipfs-client.js.map +1 -0
- package/dist/browser/test/node/hanging-test/scenarios/comment-publish-pending.scenario.d.ts +8 -0
- package/dist/browser/test/node/hanging-test/scenarios/comment-publish-pending.scenario.js +21 -0
- package/dist/browser/test/node/hanging-test/scenarios/comment-publish-pending.scenario.js.map +1 -0
- package/dist/browser/test/node/hanging-test/scenarios/comment-publish.scenario.d.ts +8 -0
- package/dist/browser/test/node/hanging-test/scenarios/comment-publish.scenario.js +19 -0
- package/dist/browser/test/node/hanging-test/scenarios/comment-publish.scenario.js.map +1 -0
- package/dist/browser/test/node/hanging-test/scenarios/comment-update.scenario.d.ts +8 -0
- package/dist/browser/test/node/hanging-test/scenarios/comment-update.scenario.js +22 -0
- package/dist/browser/test/node/hanging-test/scenarios/comment-update.scenario.js.map +1 -0
- package/dist/browser/test/node/hanging-test/scenarios/community-start.scenario.d.ts +8 -0
- package/dist/browser/test/node/hanging-test/scenarios/community-start.scenario.js +23 -0
- package/dist/browser/test/node/hanging-test/scenarios/community-start.scenario.js.map +1 -0
- package/dist/browser/test/node/hanging-test/scenarios/community-update.scenario.d.ts +8 -0
- package/dist/browser/test/node/hanging-test/scenarios/community-update.scenario.js +21 -0
- package/dist/browser/test/node/hanging-test/scenarios/community-update.scenario.js.map +1 -0
- package/dist/browser/test/node/hanging-test/scenarios/destroy-only.scenario.d.ts +7 -0
- package/dist/browser/test/node/hanging-test/scenarios/destroy-only.scenario.js +15 -0
- package/dist/browser/test/node/hanging-test/scenarios/destroy-only.scenario.js.map +1 -0
- package/dist/browser/test/node/hanging-test/scenarios/hanging-test-util.d.ts +30 -0
- package/dist/browser/test/node/hanging-test/scenarios/hanging-test-util.js +46 -0
- package/dist/browser/test/node/hanging-test/scenarios/hanging-test-util.js.map +1 -0
- package/dist/browser/test/test-util.d.ts +1019 -0
- package/dist/browser/test/test-util.js +1886 -0
- package/dist/browser/test/test-util.js.map +1 -0
- package/dist/browser/types.d.ts +165 -0
- package/dist/browser/types.js +2 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/browser/util/inflight-fetch-manager.d.ts +11 -0
- package/dist/browser/util/inflight-fetch-manager.js +41 -0
- package/dist/browser/util/inflight-fetch-manager.js.map +1 -0
- package/dist/browser/util.d.ts +120 -0
- package/dist/browser/util.js +816 -0
- package/dist/browser/util.js.map +1 -0
- package/dist/browser/version.d.ts +7 -0
- package/dist/browser/version.js +12 -0
- package/dist/browser/version.js.map +1 -0
- package/dist/browser/zod-error-map.d.ts +1 -0
- package/dist/browser/zod-error-map.js +10 -0
- package/dist/browser/zod-error-map.js.map +1 -0
- package/dist/node/challenges.d.ts +1 -0
- package/dist/node/challenges.js +2 -0
- package/dist/node/challenges.js.map +1 -0
- package/dist/node/clients/base-client-manager.d.ts +126 -0
- package/dist/node/clients/base-client-manager.js +673 -0
- package/dist/node/clients/base-client-manager.js.map +1 -0
- package/dist/node/clients/name-resolver-client.d.ts +8 -0
- package/dist/node/clients/name-resolver-client.js +10 -0
- package/dist/node/clients/name-resolver-client.js.map +1 -0
- package/dist/node/clients/pkc-typed-emitter.d.ts +9 -0
- package/dist/node/clients/pkc-typed-emitter.js +52 -0
- package/dist/node/clients/pkc-typed-emitter.js.map +1 -0
- package/dist/node/clients/rpc-client/decode-rpc-response-util.d.ts +8 -0
- package/dist/node/clients/rpc-client/decode-rpc-response-util.js +53 -0
- package/dist/node/clients/rpc-client/decode-rpc-response-util.js.map +1 -0
- package/dist/node/clients/rpc-client/pkc-rpc-client.d.ts +68 -0
- package/dist/node/clients/rpc-client/pkc-rpc-client.js +404 -0
- package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -0
- package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +147 -0
- package/dist/node/clients/rpc-client/rpc-schema-util.js +11 -0
- package/dist/node/clients/rpc-client/rpc-schema-util.js.map +1 -0
- package/dist/node/clients/rpc-client/schema.d.ts +433 -0
- package/dist/node/clients/rpc-client/schema.js +49 -0
- package/dist/node/clients/rpc-client/schema.js.map +1 -0
- package/dist/node/clients/rpc-client/types.d.ts +8 -0
- package/dist/node/clients/rpc-client/types.js +2 -0
- package/dist/node/clients/rpc-client/types.js.map +1 -0
- package/dist/node/community/community-client-manager.d.ts +60 -0
- package/dist/node/community/community-client-manager.js +717 -0
- package/dist/node/community/community-client-manager.js.map +1 -0
- package/dist/node/community/community-clients.d.ts +18 -0
- package/dist/node/community/community-clients.js +12 -0
- package/dist/node/community/community-clients.js.map +1 -0
- package/dist/node/community/community-wire.d.ts +20 -0
- package/dist/node/community/community-wire.js +38 -0
- package/dist/node/community/community-wire.js.map +1 -0
- package/dist/node/community/remote-community.d.ts +110 -0
- package/dist/node/community/remote-community.js +555 -0
- package/dist/node/community/remote-community.js.map +1 -0
- package/dist/node/community/rpc-local-community.d.ts +41 -0
- package/dist/node/community/rpc-local-community.js +289 -0
- package/dist/node/community/rpc-local-community.js.map +1 -0
- package/dist/node/community/rpc-remote-community.d.ts +18 -0
- package/dist/node/community/rpc-remote-community.js +286 -0
- package/dist/node/community/rpc-remote-community.js.map +1 -0
- package/dist/node/community/schema.d.ts +4217 -0
- package/dist/node/community/schema.js +289 -0
- package/dist/node/community/schema.js.map +1 -0
- package/dist/node/community/types.d.ts +135 -0
- package/dist/node/community/types.js +2 -0
- package/dist/node/community/types.js.map +1 -0
- package/dist/node/constants.d.ts +6 -0
- package/dist/node/constants.js +9 -0
- package/dist/node/constants.js.map +1 -0
- package/dist/node/decorator-util.d.ts +1 -0
- package/dist/node/decorator-util.js +35 -0
- package/dist/node/decorator-util.js.map +1 -0
- package/dist/node/errors.d.ts +343 -0
- package/dist/node/errors.js +358 -0
- package/dist/node/errors.js.map +1 -0
- package/dist/node/general-util/limited-set.d.ts +15 -0
- package/dist/node/general-util/limited-set.js +66 -0
- package/dist/node/general-util/limited-set.js.map +1 -0
- package/dist/node/generated-version.d.ts +1 -0
- package/dist/node/generated-version.js +3 -0
- package/dist/node/generated-version.js.map +1 -0
- package/dist/node/generic-state-client.d.ts +6 -0
- package/dist/node/generic-state-client.js +11 -0
- package/dist/node/generic-state-client.js.map +1 -0
- package/dist/node/helia/helia-for-pkc.d.ts +3 -0
- package/dist/node/helia/helia-for-pkc.js +255 -0
- package/dist/node/helia/helia-for-pkc.js.map +1 -0
- package/dist/node/helia/ipns-over-pubsub-with-fetch.d.ts +36 -0
- package/dist/node/helia/ipns-over-pubsub-with-fetch.js +229 -0
- package/dist/node/helia/ipns-over-pubsub-with-fetch.js.map +1 -0
- package/dist/node/helia/libp2pjsClient.d.ts +27 -0
- package/dist/node/helia/libp2pjsClient.js +15 -0
- package/dist/node/helia/libp2pjsClient.js.map +1 -0
- package/dist/node/helia/types.d.ts +19 -0
- package/dist/node/helia/types.js +2 -0
- package/dist/node/helia/types.js.map +1 -0
- package/dist/node/helia/util.d.ts +13 -0
- package/dist/node/helia/util.js +98 -0
- package/dist/node/helia/util.js.map +1 -0
- package/dist/node/index.d.ts +244 -0
- package/dist/node/index.js +36 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/logger.d.ts +12 -0
- package/dist/node/logger.js +11 -0
- package/dist/node/logger.js.map +1 -0
- package/dist/node/pages/pages-client-manager.d.ts +159 -0
- package/dist/node/pages/pages-client-manager.js +334 -0
- package/dist/node/pages/pages-client-manager.js.map +1 -0
- package/dist/node/pages/pages-clients.d.ts +11 -0
- package/dist/node/pages/pages-clients.js +10 -0
- package/dist/node/pages/pages-clients.js.map +1 -0
- package/dist/node/pages/pages.d.ts +107 -0
- package/dist/node/pages/pages.js +262 -0
- package/dist/node/pages/pages.js.map +1 -0
- package/dist/node/pages/schema-util.d.ts +3 -0
- package/dist/node/pages/schema-util.js +3 -0
- package/dist/node/pages/schema-util.js.map +1 -0
- package/dist/node/pages/schema.d.ts +719 -0
- package/dist/node/pages/schema.js +32 -0
- package/dist/node/pages/schema.js.map +1 -0
- package/dist/node/pages/types.d.ts +44 -0
- package/dist/node/pages/types.js +2 -0
- package/dist/node/pages/types.js.map +1 -0
- package/dist/node/pages/util.d.ts +56 -0
- package/dist/node/pages/util.js +446 -0
- package/dist/node/pages/util.js.map +1 -0
- package/dist/node/pkc/pkc-client-manager.d.ts +44 -0
- package/dist/node/pkc/pkc-client-manager.js +156 -0
- package/dist/node/pkc/pkc-client-manager.js.map +1 -0
- package/dist/node/pkc/pkc-clients.d.ts +11 -0
- package/dist/node/pkc/pkc-clients.js +8 -0
- package/dist/node/pkc/pkc-clients.js.map +1 -0
- package/dist/node/pkc/pkc-with-rpc-client.d.ts +19 -0
- package/dist/node/pkc/pkc-with-rpc-client.js +128 -0
- package/dist/node/pkc/pkc-with-rpc-client.js.map +1 -0
- package/dist/node/pkc/pkc.d.ts +137 -0
- package/dist/node/pkc/pkc.js +888 -0
- package/dist/node/pkc/pkc.js.map +1 -0
- package/dist/node/pkc/tracked-instance-registry-util.d.ts +44 -0
- package/dist/node/pkc/tracked-instance-registry-util.js +106 -0
- package/dist/node/pkc/tracked-instance-registry-util.js.map +1 -0
- package/dist/node/pkc/tracked-instance-registry.d.ts +18 -0
- package/dist/node/pkc/tracked-instance-registry.js +134 -0
- package/dist/node/pkc/tracked-instance-registry.js.map +1 -0
- package/dist/node/pkc-error.d.ts +65 -0
- package/dist/node/pkc-error.js +137 -0
- package/dist/node/pkc-error.js.map +1 -0
- package/dist/node/publications/comment/comment-client-manager.d.ts +86 -0
- package/dist/node/publications/comment/comment-client-manager.js +908 -0
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -0
- package/dist/node/publications/comment/comment-clients.d.ts +19 -0
- package/dist/node/publications/comment/comment-clients.js +12 -0
- package/dist/node/publications/comment/comment-clients.js.map +1 -0
- package/dist/node/publications/comment/comment-util.d.ts +10 -0
- package/dist/node/publications/comment/comment-util.js +202 -0
- package/dist/node/publications/comment/comment-util.js.map +1 -0
- package/dist/node/publications/comment/comment.d.ts +147 -0
- package/dist/node/publications/comment/comment.js +1044 -0
- package/dist/node/publications/comment/comment.js.map +1 -0
- package/dist/node/publications/comment/schema.d.ts +1237 -0
- package/dist/node/publications/comment/schema.js +184 -0
- package/dist/node/publications/comment/schema.js.map +1 -0
- package/dist/node/publications/comment/types.d.ts +100 -0
- package/dist/node/publications/comment/types.js +2 -0
- package/dist/node/publications/comment/types.js.map +1 -0
- package/dist/node/publications/comment-edit/comment-edit.d.ts +41 -0
- package/dist/node/publications/comment-edit/comment-edit.js +63 -0
- package/dist/node/publications/comment-edit/comment-edit.js.map +1 -0
- package/dist/node/publications/comment-edit/schema.d.ts +295 -0
- package/dist/node/publications/comment-edit/schema.js +55 -0
- package/dist/node/publications/comment-edit/schema.js.map +1 -0
- package/dist/node/publications/comment-edit/types.d.ts +25 -0
- package/dist/node/publications/comment-edit/types.js +2 -0
- package/dist/node/publications/comment-edit/types.js.map +1 -0
- package/dist/node/publications/comment-moderation/comment-moderation.d.ts +36 -0
- package/dist/node/publications/comment-moderation/comment-moderation.js +53 -0
- package/dist/node/publications/comment-moderation/comment-moderation.js.map +1 -0
- package/dist/node/publications/comment-moderation/schema.d.ts +315 -0
- package/dist/node/publications/comment-moderation/schema.js +62 -0
- package/dist/node/publications/comment-moderation/schema.js.map +1 -0
- package/dist/node/publications/comment-moderation/types.d.ts +22 -0
- package/dist/node/publications/comment-moderation/types.js +2 -0
- package/dist/node/publications/comment-moderation/types.js.map +1 -0
- package/dist/node/publications/community-edit/community-edit.d.ts +35 -0
- package/dist/node/publications/community-edit/community-edit.js +50 -0
- package/dist/node/publications/community-edit/community-edit.js.map +1 -0
- package/dist/node/publications/community-edit/schema.d.ts +467 -0
- package/dist/node/publications/community-edit/schema.js +36 -0
- package/dist/node/publications/community-edit/schema.js.map +1 -0
- package/dist/node/publications/community-edit/types.d.ts +19 -0
- package/dist/node/publications/community-edit/types.js +2 -0
- package/dist/node/publications/community-edit/types.js.map +1 -0
- package/dist/node/publications/publication-author.d.ts +22 -0
- package/dist/node/publications/publication-author.js +66 -0
- package/dist/node/publications/publication-author.js.map +1 -0
- package/dist/node/publications/publication-client-manager.d.ts +62 -0
- package/dist/node/publications/publication-client-manager.js +257 -0
- package/dist/node/publications/publication-client-manager.js.map +1 -0
- package/dist/node/publications/publication-clients.d.ts +19 -0
- package/dist/node/publications/publication-clients.js +12 -0
- package/dist/node/publications/publication-clients.js.map +1 -0
- package/dist/node/publications/publication-community.d.ts +55 -0
- package/dist/node/publications/publication-community.js +87 -0
- package/dist/node/publications/publication-community.js.map +1 -0
- package/dist/node/publications/publication.d.ts +120 -0
- package/dist/node/publications/publication.js +950 -0
- package/dist/node/publications/publication.js.map +1 -0
- package/dist/node/publications/types.d.ts +26 -0
- package/dist/node/publications/types.js +2 -0
- package/dist/node/publications/types.js.map +1 -0
- package/dist/node/publications/vote/schema.d.ts +150 -0
- package/dist/node/publications/vote/schema.js +44 -0
- package/dist/node/publications/vote/schema.js.map +1 -0
- package/dist/node/publications/vote/types.d.ts +21 -0
- package/dist/node/publications/vote/types.js +2 -0
- package/dist/node/publications/vote/types.js.map +1 -0
- package/dist/node/publications/vote/vote.d.ts +36 -0
- package/dist/node/publications/vote/vote.js +49 -0
- package/dist/node/publications/vote/vote.js.map +1 -0
- package/dist/node/pubsub-messages/schema.d.ts +964 -0
- package/dist/node/pubsub-messages/schema.js +98 -0
- package/dist/node/pubsub-messages/schema.js.map +1 -0
- package/dist/node/pubsub-messages/types.d.ts +81 -0
- package/dist/node/pubsub-messages/types.js +2 -0
- package/dist/node/pubsub-messages/types.js.map +1 -0
- package/dist/node/rpc/src/index.d.ts +483 -0
- package/dist/node/rpc/src/index.js +1267 -0
- package/dist/node/rpc/src/index.js.map +1 -0
- package/dist/node/rpc/src/json-rpc-util.d.ts +1 -0
- package/dist/node/rpc/src/json-rpc-util.js +19 -0
- package/dist/node/rpc/src/json-rpc-util.js.map +1 -0
- package/dist/node/rpc/src/lib/pkc-js/index.d.ts +132 -0
- package/dist/node/rpc/src/lib/pkc-js/index.js +29 -0
- package/dist/node/rpc/src/lib/pkc-js/index.js.map +1 -0
- package/dist/node/rpc/src/lib/pkc-js/pkc-js-mock.d.ts +1 -0
- package/dist/node/rpc/src/lib/pkc-js/pkc-js-mock.js +472 -0
- package/dist/node/rpc/src/lib/pkc-js/pkc-js-mock.js.map +1 -0
- package/dist/node/rpc/src/schema.d.ts +843 -0
- package/dist/node/rpc/src/schema.js +28 -0
- package/dist/node/rpc/src/schema.js.map +1 -0
- package/dist/node/rpc/src/types.d.ts +24 -0
- package/dist/node/rpc/src/types.js +2 -0
- package/dist/node/rpc/src/types.js.map +1 -0
- package/dist/node/rpc/src/utils.d.ts +7 -0
- package/dist/node/rpc/src/utils.js +58 -0
- package/dist/node/rpc/src/utils.js.map +1 -0
- package/dist/node/runtime/browser/community/challenges/index.d.ts +6 -0
- package/dist/node/runtime/browser/community/challenges/index.js +7 -0
- package/dist/node/runtime/browser/community/challenges/index.js.map +1 -0
- package/dist/node/runtime/browser/community/local-community.d.ts +3 -0
- package/dist/node/runtime/browser/community/local-community.js +6 -0
- package/dist/node/runtime/browser/community/local-community.js.map +1 -0
- package/dist/node/runtime/browser/db-handler.d.ts +4 -0
- package/dist/node/runtime/browser/db-handler.js +8 -0
- package/dist/node/runtime/browser/db-handler.js.map +1 -0
- package/dist/node/runtime/browser/localforage-lru.d.ts +15 -0
- package/dist/node/runtime/browser/localforage-lru.js +140 -0
- package/dist/node/runtime/browser/localforage-lru.js.map +1 -0
- package/dist/node/runtime/browser/lru-storage.d.ts +14 -0
- package/dist/node/runtime/browser/lru-storage.js +34 -0
- package/dist/node/runtime/browser/lru-storage.js.map +1 -0
- package/dist/node/runtime/browser/native-functions.d.ts +3 -0
- package/dist/node/runtime/browser/native-functions.js +6 -0
- package/dist/node/runtime/browser/native-functions.js.map +1 -0
- package/dist/node/runtime/browser/polyfill.d.ts +3 -0
- package/dist/node/runtime/browser/polyfill.js +37 -0
- package/dist/node/runtime/browser/polyfill.js.map +1 -0
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts +1 -0
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js +4 -0
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
- package/dist/node/runtime/browser/storage.d.ts +13 -0
- package/dist/node/runtime/browser/storage.js +37 -0
- package/dist/node/runtime/browser/storage.js.map +1 -0
- package/dist/node/runtime/browser/util.d.ts +14 -0
- package/dist/node/runtime/browser/util.js +61 -0
- package/dist/node/runtime/browser/util.js.map +1 -0
- package/dist/node/runtime/node/address-rewriter-db.d.ts +31 -0
- package/dist/node/runtime/node/address-rewriter-db.js +156 -0
- package/dist/node/runtime/node/address-rewriter-db.js.map +1 -0
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.d.ts +45 -0
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js +493 -0
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/exclude/exclude.d.ts +8 -0
- package/dist/node/runtime/node/community/challenges/exclude/exclude.js +280 -0
- package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/exclude/index.d.ts +3 -0
- package/dist/node/runtime/node/community/challenges/exclude/index.js +4 -0
- package/dist/node/runtime/node/community/challenges/exclude/index.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.d.ts +5 -0
- package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.js +127 -0
- package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/exclude/utils.d.ts +13 -0
- package/dist/node/runtime/node/community/challenges/exclude/utils.js +52 -0
- package/dist/node/runtime/node/community/challenges/exclude/utils.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/index.d.ts +32 -0
- package/dist/node/runtime/node/community/challenges/index.js +307 -0
- package/dist/node/runtime/node/community/challenges/index.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.d.ts +5 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +118 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/fail.d.ts +5 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/fail.js +26 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/fail.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.d.ts +5 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.js +135 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/question.d.ts +5 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/question.js +66 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/question.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/text-math.d.ts +5 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/text-math.js +61 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/text-math.js.map +1 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.d.ts +5 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +118 -0
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -0
- package/dist/node/runtime/node/community/db-handler-types.d.ts +19 -0
- package/dist/node/runtime/node/community/db-handler-types.js +2 -0
- package/dist/node/runtime/node/community/db-handler-types.js.map +1 -0
- package/dist/node/runtime/node/community/db-handler.d.ts +226 -0
- package/dist/node/runtime/node/community/db-handler.js +2462 -0
- package/dist/node/runtime/node/community/db-handler.js.map +1 -0
- package/dist/node/runtime/node/community/db-row-parser.d.ts +19 -0
- package/dist/node/runtime/node/community/db-row-parser.js +40 -0
- package/dist/node/runtime/node/community/db-row-parser.js.map +1 -0
- package/dist/node/runtime/node/community/keyv-better-sqlite3.d.ts +68 -0
- package/dist/node/runtime/node/community/keyv-better-sqlite3.js +251 -0
- package/dist/node/runtime/node/community/keyv-better-sqlite3.js.map +1 -0
- package/dist/node/runtime/node/community/local-community.d.ts +129 -0
- package/dist/node/runtime/node/community/local-community.js +2978 -0
- package/dist/node/runtime/node/community/local-community.js.map +1 -0
- package/dist/node/runtime/node/community/page-generator.d.ts +433 -0
- package/dist/node/runtime/node/community/page-generator.js +441 -0
- package/dist/node/runtime/node/community/page-generator.js.map +1 -0
- package/dist/node/runtime/node/lru-storage.d.ts +14 -0
- package/dist/node/runtime/node/lru-storage.js +40 -0
- package/dist/node/runtime/node/lru-storage.js.map +1 -0
- package/dist/node/runtime/node/native-functions.d.ts +3 -0
- package/dist/node/runtime/node/native-functions.js +7 -0
- package/dist/node/runtime/node/native-functions.js.map +1 -0
- package/dist/node/runtime/node/polyfill.d.ts +3 -0
- package/dist/node/runtime/node/polyfill.js +20 -0
- package/dist/node/runtime/node/polyfill.js.map +1 -0
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts +4 -0
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js +240 -0
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
- package/dist/node/runtime/node/sqlite-lru-cache.d.ts +52 -0
- package/dist/node/runtime/node/sqlite-lru-cache.js +127 -0
- package/dist/node/runtime/node/sqlite-lru-cache.js.map +1 -0
- package/dist/node/runtime/node/storage.d.ts +14 -0
- package/dist/node/runtime/node/storage.js +52 -0
- package/dist/node/runtime/node/storage.js.map +1 -0
- package/dist/node/runtime/node/test/helpers/hanging-runner.d.ts +1 -0
- package/dist/node/runtime/node/test/helpers/hanging-runner.js +157 -0
- package/dist/node/runtime/node/test/helpers/hanging-runner.js.map +1 -0
- package/dist/node/runtime/node/test/helpers/run-hanging-node.d.ts +7 -0
- package/dist/node/runtime/node/test/helpers/run-hanging-node.js +68 -0
- package/dist/node/runtime/node/test/helpers/run-hanging-node.js.map +1 -0
- package/dist/node/runtime/node/test/mock-http-router.d.ts +54 -0
- package/dist/node/runtime/node/test/mock-http-router.js +397 -0
- package/dist/node/runtime/node/test/mock-http-router.js.map +1 -0
- package/dist/node/runtime/node/util.d.ts +43 -0
- package/dist/node/runtime/node/util.js +384 -0
- package/dist/node/runtime/node/util.js.map +1 -0
- package/dist/node/schema/schema-util.d.ts +2751 -0
- package/dist/node/schema/schema-util.js +562 -0
- package/dist/node/schema/schema-util.js.map +1 -0
- package/dist/node/schema/schema.d.ts +237 -0
- package/dist/node/schema/schema.js +128 -0
- package/dist/node/schema/schema.js.map +1 -0
- package/dist/node/schema.d.ts +1142 -0
- package/dist/node/schema.js +104 -0
- package/dist/node/schema.js.map +1 -0
- package/dist/node/signer/constants.d.ts +2 -0
- package/dist/node/signer/constants.js +3 -0
- package/dist/node/signer/constants.js.map +1 -0
- package/dist/node/signer/encryption.d.ts +21 -0
- package/dist/node/signer/encryption.js +122 -0
- package/dist/node/signer/encryption.js.map +1 -0
- package/dist/node/signer/index.d.ts +21 -0
- package/dist/node/signer/index.js +49 -0
- package/dist/node/signer/index.js.map +1 -0
- package/dist/node/signer/signatures.d.ts +200 -0
- package/dist/node/signer/signatures.js +594 -0
- package/dist/node/signer/signatures.js.map +1 -0
- package/dist/node/signer/types.d.ts +20 -0
- package/dist/node/signer/types.js +2 -0
- package/dist/node/signer/types.js.map +1 -0
- package/dist/node/signer/util.d.ts +14 -0
- package/dist/node/signer/util.js +156 -0
- package/dist/node/signer/util.js.map +1 -0
- package/dist/node/stats.d.ts +15 -0
- package/dist/node/stats.js +64 -0
- package/dist/node/stats.js.map +1 -0
- package/dist/node/test/mock-ipfs-client.d.ts +34 -0
- package/dist/node/test/mock-ipfs-client.js +208 -0
- package/dist/node/test/mock-ipfs-client.js.map +1 -0
- package/dist/node/test/node/hanging-test/scenarios/comment-publish-pending.scenario.d.ts +8 -0
- package/dist/node/test/node/hanging-test/scenarios/comment-publish-pending.scenario.js +21 -0
- package/dist/node/test/node/hanging-test/scenarios/comment-publish-pending.scenario.js.map +1 -0
- package/dist/node/test/node/hanging-test/scenarios/comment-publish.scenario.d.ts +8 -0
- package/dist/node/test/node/hanging-test/scenarios/comment-publish.scenario.js +19 -0
- package/dist/node/test/node/hanging-test/scenarios/comment-publish.scenario.js.map +1 -0
- package/dist/node/test/node/hanging-test/scenarios/comment-update.scenario.d.ts +8 -0
- package/dist/node/test/node/hanging-test/scenarios/comment-update.scenario.js +22 -0
- package/dist/node/test/node/hanging-test/scenarios/comment-update.scenario.js.map +1 -0
- package/dist/node/test/node/hanging-test/scenarios/community-start.scenario.d.ts +8 -0
- package/dist/node/test/node/hanging-test/scenarios/community-start.scenario.js +23 -0
- package/dist/node/test/node/hanging-test/scenarios/community-start.scenario.js.map +1 -0
- package/dist/node/test/node/hanging-test/scenarios/community-update.scenario.d.ts +8 -0
- package/dist/node/test/node/hanging-test/scenarios/community-update.scenario.js +21 -0
- package/dist/node/test/node/hanging-test/scenarios/community-update.scenario.js.map +1 -0
- package/dist/node/test/node/hanging-test/scenarios/destroy-only.scenario.d.ts +7 -0
- package/dist/node/test/node/hanging-test/scenarios/destroy-only.scenario.js +15 -0
- package/dist/node/test/node/hanging-test/scenarios/destroy-only.scenario.js.map +1 -0
- package/dist/node/test/node/hanging-test/scenarios/hanging-test-util.d.ts +30 -0
- package/dist/node/test/node/hanging-test/scenarios/hanging-test-util.js +46 -0
- package/dist/node/test/node/hanging-test/scenarios/hanging-test-util.js.map +1 -0
- package/dist/node/test/test-util.d.ts +1019 -0
- package/dist/node/test/test-util.js +1886 -0
- package/dist/node/test/test-util.js.map +1 -0
- package/dist/node/types.d.ts +165 -0
- package/dist/node/types.js +2 -0
- package/dist/node/types.js.map +1 -0
- package/dist/node/util/inflight-fetch-manager.d.ts +11 -0
- package/dist/node/util/inflight-fetch-manager.js +41 -0
- package/dist/node/util/inflight-fetch-manager.js.map +1 -0
- package/dist/node/util.d.ts +120 -0
- package/dist/node/util.js +816 -0
- package/dist/node/util.js.map +1 -0
- package/dist/node/version.d.ts +7 -0
- package/dist/node/version.js +12 -0
- package/dist/node/version.js.map +1 -0
- package/dist/node/zod-error-map.d.ts +1 -0
- package/dist/node/zod-error-map.js +10 -0
- package/dist/node/zod-error-map.js.map +1 -0
- package/package.json +212 -0
package/README.md
ADDED
|
@@ -0,0 +1,1663 @@
|
|
|
1
|
+
*Telegram group for this repo https://t.me/pkc_js*
|
|
2
|
+
|
|
3
|
+
`pkc-js` is an NPM module to wrap around the IPFS APIs used by PKC. It is used in all clients: CLI, Electron (desktop GUI) and web.
|
|
4
|
+
|
|
5
|
+
### Glossary:
|
|
6
|
+
|
|
7
|
+
- CID: https://docs.ipfs.io/concepts/content-addressing/
|
|
8
|
+
- IPNS: https://docs.ipfs.io/concepts/ipns/#example-ipns-setup-with-cli
|
|
9
|
+
- IPNS name: hash of a public key, the private key is used by community owners for signing IPNS records, and by authors for signing posts and comments
|
|
10
|
+
- Pubsub topic: the string to publish/subscribe to in the pubsub https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/PUBSUB.md#ipfspubsubsubscribetopic-handler-options and https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.0.md#topic-membership
|
|
11
|
+
- IPNS record: https://github.com/ipfs/specs/blob/master/IPNS.md#ipns-record
|
|
12
|
+
- IPNS signature: https://github.com/ipfs/notes/issues/249
|
|
13
|
+
- PKC signature types: https://github.com/pkcprotocol/pkc-js/blob/master/docs/signatures.md
|
|
14
|
+
- PKC encryption types: https://github.com/pkcprotocol/pkc-js/blob/master/docs/encryption.md
|
|
15
|
+
|
|
16
|
+
Note: IPFS files are immutable, fetched by their CID, which is a hash of their content. IPNS records are mutable, fetched by their IPNS name, which is the hash of a public key. The private key's owner can update the content. Always use IPFS files over IPNS records when possible because they are much faster to fetch.
|
|
17
|
+
|
|
18
|
+
### Schema:
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
Address: string // a PKC author, community or multisub "address" can be a crypto domain like memes.bso, an IPNS name, an ethereum address, etc. How to resolve ENS names https://github.com/pkcprotocol/pkc-js/blob/master/docs/ens.md
|
|
22
|
+
Publication {
|
|
23
|
+
author: Author
|
|
24
|
+
communityAddress: string // all publications are directed to a community owner
|
|
25
|
+
timestamp: number // number in seconds
|
|
26
|
+
signature: Signature // sign immutable fields like author, title, content, timestamp to prevent tampering
|
|
27
|
+
protocolVersion: '1.0.0' // semantic version of the protocol https://semver.org/
|
|
28
|
+
}
|
|
29
|
+
Comment extends Publication /* (IPFS file) */ {
|
|
30
|
+
parentCid?: string // same as postCid for top level comments, undefined for posts
|
|
31
|
+
content?: string
|
|
32
|
+
title?: string
|
|
33
|
+
link?: string
|
|
34
|
+
linkWidth?: number // author can optionally provide dimensions of image/video link which helps UI clients with infinite scrolling feeds
|
|
35
|
+
linkHeight?: number
|
|
36
|
+
linkHtmlTagName?: 'a' | 'img' | 'video' | 'audio' // author can optionally provide the HTML element to use for the link
|
|
37
|
+
spoiler?: boolean
|
|
38
|
+
nsfw?: boolean
|
|
39
|
+
flairs?: Flair[] // arbitrary colored strings added by the author or mods to describe the author or comment
|
|
40
|
+
quotedCids?: string[] // CIDs of comments being quoted/referenced in this reply
|
|
41
|
+
// below are added by community owner, not author
|
|
42
|
+
previousCid?: string // each comment/post is a linked list of other comments/posts with same comment.depth and comment.parentCid, undefined if first comment in list
|
|
43
|
+
postCid?: string // helps faster loading post info for reply direct linking, undefined for posts, a post can't know its own CID
|
|
44
|
+
depth: number // 0 = post, 1 = top level reply, 2+ = nested reply
|
|
45
|
+
thumbnailUrl?: string // optionally fetched by community owner, some web pages have thumbnail urls in their meta tags https://moz.com/blog/meta-data-templates-123
|
|
46
|
+
thumbnailUrlWidth?: number // community owner can optionally provide dimensions of thumbails which helps UI clients with infinite scrolling feeds
|
|
47
|
+
thumbnailUrlHeight?: number
|
|
48
|
+
}
|
|
49
|
+
Vote extends Publication {
|
|
50
|
+
commentCid: string
|
|
51
|
+
vote: 1 | -1 | 0 // 0 is needed to cancel a vote
|
|
52
|
+
}
|
|
53
|
+
CommentEdit extends Publication {
|
|
54
|
+
commentCid: string
|
|
55
|
+
content?: string
|
|
56
|
+
deleted?: boolean
|
|
57
|
+
flairs?: Flair[]
|
|
58
|
+
spoiler?: boolean
|
|
59
|
+
nsfw?: boolean
|
|
60
|
+
reason?: string
|
|
61
|
+
}
|
|
62
|
+
CommentModeration extends Publication {
|
|
63
|
+
commentCid: string
|
|
64
|
+
commentModeration: {
|
|
65
|
+
flairs?: Flair[]
|
|
66
|
+
spoiler?: boolean
|
|
67
|
+
nsfw?: boolean
|
|
68
|
+
pinned?: boolean
|
|
69
|
+
locked?: boolean
|
|
70
|
+
archived?: boolean
|
|
71
|
+
approved?: boolean
|
|
72
|
+
removed?: boolean
|
|
73
|
+
purged?: boolean
|
|
74
|
+
reason?: string
|
|
75
|
+
author?: {
|
|
76
|
+
flairs?: Flair[]
|
|
77
|
+
banExpiresAt?: number
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
CommunityEdit extends Publication {
|
|
82
|
+
communityEdit: CreateCommunityOptions
|
|
83
|
+
}
|
|
84
|
+
MultisubEdit extends CreateMultisubOptions, Publication {}
|
|
85
|
+
CommentUpdate /* (IPFS file) */ {
|
|
86
|
+
cid: string // cid of the comment, need it in signature to prevent attack
|
|
87
|
+
edit?: AuthorCommentEdit // most recent edit by comment author, commentUpdate.edit.content, commentUpdate.edit.deleted, commentUpdate.edit.flairs override Comment instance props. Validate commentUpdate.edit.signature
|
|
88
|
+
upvoteCount: number
|
|
89
|
+
downvoteCount: number
|
|
90
|
+
replies?: Pages // only preload page 1 sorted by 'topAll', might preload more later, only provide sorting for posts (not comments) that have 100+ child comments
|
|
91
|
+
replyCount: number
|
|
92
|
+
childCount?: number // the total of direct children of the comment, does not include indirect children
|
|
93
|
+
number?: number // sequential comment number assigned by the community
|
|
94
|
+
postNumber?: number // sequential post number assigned by the community
|
|
95
|
+
flairs?: Flair[] // arbitrary colored strings to describe the comment, added by mods, override comment.flairs and comment.edit.flairs (which are added by author)
|
|
96
|
+
spoiler?: boolean
|
|
97
|
+
nsfw?: boolean
|
|
98
|
+
pinned?: boolean
|
|
99
|
+
locked?: boolean
|
|
100
|
+
archived?: boolean
|
|
101
|
+
approved?: boolean // if comment was pending approval and it got approved or disapproved
|
|
102
|
+
removed?: boolean // mod deleted a comment
|
|
103
|
+
reason?: string // reason the mod took a mod action
|
|
104
|
+
updatedAt: number // timestamp in seconds the CommentUpdate was updated
|
|
105
|
+
protocolVersion: '1.0.0' // semantic version of the protocol https://semver.org/
|
|
106
|
+
signature: Signature // signature of the CommentUpdate by the community owner to protect against malicious gateway
|
|
107
|
+
author?: { // add commentUpdate.author.community to comment.author.community, override comment.author.flairs with commentUpdate.author.community.flairs if any
|
|
108
|
+
community: CommunityAuthor
|
|
109
|
+
}
|
|
110
|
+
lastReplyTimestamp?: number // the timestamp of the most recent direct or indirect child of the comment
|
|
111
|
+
lastChildCid?: string // the CID of the most recent direct child of the comment
|
|
112
|
+
}
|
|
113
|
+
Author {
|
|
114
|
+
address: string
|
|
115
|
+
shortAddress: string // not part of IPFS files, added to `Author` instance as convenience. Copy address, if address is a hash, remove hash prefix and trim to 12 first chars
|
|
116
|
+
name?: string // author chosen username
|
|
117
|
+
previousCommentCid?: string // linked list of the author's comments
|
|
118
|
+
displayName?: string
|
|
119
|
+
wallets?: {[chainTicker: string]: Wallet}
|
|
120
|
+
avatar?: Nft
|
|
121
|
+
flairs?: Flair[] // (added by author originally, can be overridden by commentUpdate.author.community.flairs)
|
|
122
|
+
community?: CommunityAuthor // (added by CommentUpdate) up to date author properties specific to the community it's in
|
|
123
|
+
}
|
|
124
|
+
CommunityAuthor {
|
|
125
|
+
banExpiresAt?: number // (added by moderator only) timestamp in second, if defined the author was banned for this comment
|
|
126
|
+
flairs?: Flair[] // (added by moderator only) for when a mod wants to edit an author's flairs
|
|
127
|
+
postScore: number // total post karma in the community
|
|
128
|
+
replyScore: number // total reply karma in the community
|
|
129
|
+
lastCommentCid: string // last comment by the author in the community, can be used with author.previousCommentCid to get a recent author comment history in all communities
|
|
130
|
+
firstCommentTimestamp: number // timestamp of the first comment by the author in the community, used for account age based challenges
|
|
131
|
+
}
|
|
132
|
+
Wallet {
|
|
133
|
+
address: string
|
|
134
|
+
timestamp: number // in seconds, allows partial blocking multiple authors using the same wallet
|
|
135
|
+
signature: Signature // type 'eip191' {domainSeparator:"plebbit-author-wallet",authorAddress:"${authorAddress}",timestamp:"${wallet.timestamp}"}
|
|
136
|
+
// ...will add more stuff later, like signer or send/sign or balance
|
|
137
|
+
}
|
|
138
|
+
Nft {
|
|
139
|
+
chainTicker: string // ticker of the chain, like eth, avax, sol, etc in lowercase
|
|
140
|
+
timestamp: number // in seconds, needed to mitigate multiple users using the same signature
|
|
141
|
+
address: string // address of the NFT contract
|
|
142
|
+
id: string // tokenId or index of the specific NFT used, must be string type, not number
|
|
143
|
+
signature: Signature // proof that author.address owns the nft
|
|
144
|
+
// how to resolve and verify NFT signatures https://github.com/pkcprotocol/pkc-js/blob/master/docs/nft.md
|
|
145
|
+
}
|
|
146
|
+
Signature {
|
|
147
|
+
signature: string // data in base64
|
|
148
|
+
publicKey: string // 32 bytes base64 string
|
|
149
|
+
type: 'ed25519' | 'eip191' // multiple versions/types to allow signing with metamask/other wallet or to change the signature fields or algorithm
|
|
150
|
+
signedPropertyNames: string[] // the fields that were signed as part of the signature e.g. ['title', 'content', 'author', etc.] client should require that certain fields be signed or reject the publication, e.g. 'content', 'author', 'timestamp' are essential
|
|
151
|
+
}
|
|
152
|
+
Signer {
|
|
153
|
+
privateKey?: string // 32 bytes base64 string
|
|
154
|
+
type: 'ed25519' | 'eip191' // multiple versions/types to allow signing with metamask/other wallet or to change the signature fields or algorithm https://eips.ethereum.org/EIPS/eip-191
|
|
155
|
+
publicKey?: string // 32 bytes base64 string
|
|
156
|
+
address: string // public key hash, not needed for signing
|
|
157
|
+
ipfsKey?: IpfsKey // a Key object used for importing into IpfsHttpClient https://docs.ipfs.io/reference/cli/#ipfs-key-import
|
|
158
|
+
}
|
|
159
|
+
Community /* (IPNS record Community.address) */ {
|
|
160
|
+
address: string // validate community address in signature to prevent a crypto domain resolving to an impersonated community
|
|
161
|
+
title?: string
|
|
162
|
+
description?: string
|
|
163
|
+
roles?: {[authorAddress: string]: CommunityRole} // each author address can be mapped to 1 CommunityRole
|
|
164
|
+
pubsubTopic?: string // the string to publish to in the pubsub, a public key of the community owner's choice
|
|
165
|
+
lastPostCid?: string // the most recent post in the linked list of posts
|
|
166
|
+
lastCommentCid?: string // the most recent comment (posts and replies included), last comment is often displayed with a list of forums
|
|
167
|
+
posts?: Pages // only preload page 1 sorted by 'hot', might preload more later, comments should include Comment + CommentUpdate data
|
|
168
|
+
statsCid?: string
|
|
169
|
+
createdAt: number
|
|
170
|
+
updatedAt: number
|
|
171
|
+
features?: CommunityFeatures
|
|
172
|
+
suggested?: CommunitySuggested
|
|
173
|
+
rules?: string[]
|
|
174
|
+
flairs?: {[key: 'post' | 'author']: Flair[]} // list of post/author flairs authors and mods can choose from
|
|
175
|
+
protocolVersion: '1.0.0' // semantic version of the protocol https://semver.org/
|
|
176
|
+
encryption: CommunityEncryption
|
|
177
|
+
signature: Signature // signature of the Community update by the community owner to protect against malicious gateway
|
|
178
|
+
}
|
|
179
|
+
CommunitySuggested { // values suggested by the community owner, the client/user can ignore them without breaking interoperability
|
|
180
|
+
primaryColor?: string
|
|
181
|
+
secondaryColor?: string
|
|
182
|
+
avatarUrl?: string
|
|
183
|
+
bannerUrl?: string
|
|
184
|
+
backgroundUrl?: string
|
|
185
|
+
language?: string
|
|
186
|
+
// TODO: menu links, wiki pages, sidebar widgets
|
|
187
|
+
}
|
|
188
|
+
CommunityFeatures { // any boolean that changes the functionality of the community, add "no" in front if doesn't default to false
|
|
189
|
+
// implemented
|
|
190
|
+
noUpvotes?: boolean
|
|
191
|
+
noPostUpvotes?: boolean
|
|
192
|
+
noReplyUpvotes?: boolean
|
|
193
|
+
noDownvotes?: boolean
|
|
194
|
+
noPostDownvotes?: boolean
|
|
195
|
+
noReplyDownvotes?: boolean
|
|
196
|
+
requirePostLink?: boolean // require post.link be defined and a valid https url
|
|
197
|
+
requirePostLinkIsMedia?: boolean // require post.link be media, e.g. for imageboards
|
|
198
|
+
requireReplyLink?: boolean // require reply.link be defined and a valid https url
|
|
199
|
+
requireReplyLinkIsMedia?: boolean // require reply.link be media
|
|
200
|
+
noMarkdownImages?: boolean // don't embed images in text posts markdown
|
|
201
|
+
noMarkdownVideos?: boolean // don't embed videos in text posts markdown
|
|
202
|
+
noMarkdownAudio?: boolean // don't embed audio in text posts markdown
|
|
203
|
+
noVideos?: boolean // block all comments with video links
|
|
204
|
+
noImages?: boolean // block all comments with image links
|
|
205
|
+
noAudio?: boolean // block all comments with audio links
|
|
206
|
+
noSpoilers?: boolean // author can't set spoiler = true on any comment
|
|
207
|
+
noVideoReplies?: boolean // block only replies with video links
|
|
208
|
+
noImageReplies?: boolean // block only replies with image links
|
|
209
|
+
noAudioReplies?: boolean // block only replies with audio links
|
|
210
|
+
noSpoilerReplies?: boolean // author can't set spoiler = true on replies
|
|
211
|
+
noNestedReplies?: boolean // no nested replies, like old school forums and 4chan. Maximum depth is 1
|
|
212
|
+
safeForWork?: boolean // informational flag indicating this community is safe for work
|
|
213
|
+
pseudonymityMode?: 'per-post' | 'per-reply' | 'per-author'
|
|
214
|
+
authorFlairs?: boolean // authors can choose their own author flairs (otherwise only mods can)
|
|
215
|
+
requireAuthorFlairs?: boolean // force authors to choose an author flair before posting
|
|
216
|
+
postFlairs?: boolean // authors can choose their own post flairs (otherwise only mods can)
|
|
217
|
+
requirePostFlairs?: boolean // force authors to choose a post flair before posting
|
|
218
|
+
// not implemented
|
|
219
|
+
noPolls?: boolean
|
|
220
|
+
noCrossposts?: boolean
|
|
221
|
+
markdownImageReplies?: boolean
|
|
222
|
+
markdownVideoReplies?: boolean
|
|
223
|
+
}
|
|
224
|
+
CommunityEncryption {
|
|
225
|
+
type: 'ed25519-aes-gcm' // https://github.com/pkcprotocol/pkc-js/blob/master/docs/encryption.md
|
|
226
|
+
publicKey: string // 32 bytes base64 string
|
|
227
|
+
}
|
|
228
|
+
CommunityRole {
|
|
229
|
+
role: 'owner' | 'admin' | 'moderator'
|
|
230
|
+
// TODO: custom roles with other props
|
|
231
|
+
}
|
|
232
|
+
Flair {
|
|
233
|
+
text: string
|
|
234
|
+
backgroundColor?: string
|
|
235
|
+
textColor?: string
|
|
236
|
+
expiresAt?: number // timestamp in seconds, a flair assigned to an author by a mod will follow the author in future comments, unless it expires
|
|
237
|
+
}
|
|
238
|
+
Pages {
|
|
239
|
+
pages: {[key: PostsSortType | RepliesSortType]: Page} // e.g. community.posts.pages.hot.comments[0].cid = '12D3KooW...'
|
|
240
|
+
pageCids: {[key: PostsSortType | RepliesSortType | ModSortType]: pageCid} // e.g. community.posts.pageCids.topAll = '12D3KooW...'
|
|
241
|
+
}
|
|
242
|
+
Page {
|
|
243
|
+
nextCid: string // get next page (sorted by the same sort type)
|
|
244
|
+
comments: Comment[] // Comments should include merged Comment and CommentUpdate
|
|
245
|
+
}
|
|
246
|
+
PageIpfs /* (IPFS file) */ {
|
|
247
|
+
nextCid: string // get next page (sorted by the same sort type)
|
|
248
|
+
comments: PageIpfsComment[] // PageIpfs is fetched from IPFS, then Comments and CommentUpdates are merged to create the Page instance
|
|
249
|
+
}
|
|
250
|
+
PageIpfsComment {
|
|
251
|
+
comment: Comment
|
|
252
|
+
commentUpdate: CommentUpdate
|
|
253
|
+
}
|
|
254
|
+
PostsSortType: 'hot' | 'new' | 'active' | 'topHour' | 'topDay' | 'topWeek' | 'topMonth' | 'topYear' | 'topAll' | 'controversialHour' | 'controversialDay' | 'controversialWeek' | 'controversialMonth' | 'controversialYear' | 'controversialAll'
|
|
255
|
+
RepliesSortType: 'topAll' | 'new' | 'old' | 'controversialAll'
|
|
256
|
+
ModSortType: 'reports' | 'spam' | 'modqueue' | 'unmoderated' | 'edited'
|
|
257
|
+
CommunityStats {
|
|
258
|
+
hourActiveUserCount: number
|
|
259
|
+
dayActiveUserCount: number
|
|
260
|
+
weekActiveUserCount: number
|
|
261
|
+
monthActiveUserCount: number
|
|
262
|
+
yearActiveUserCount: number
|
|
263
|
+
allActiveUserCount: number
|
|
264
|
+
hourPostCount: number
|
|
265
|
+
dayPostCount: number
|
|
266
|
+
weekPostCount: number
|
|
267
|
+
monthPostCount: number
|
|
268
|
+
yearPostCount: number
|
|
269
|
+
allPostCount: number
|
|
270
|
+
hourReplyCount: number
|
|
271
|
+
dayReplyCount: number
|
|
272
|
+
weekReplyCount: number
|
|
273
|
+
monthReplyCount: number
|
|
274
|
+
yearReplyCount: number
|
|
275
|
+
allReplyCount: number
|
|
276
|
+
}
|
|
277
|
+
ChallengeType {
|
|
278
|
+
type: 'image/png' | 'text/plain' | 'chain/<chainTicker>'
|
|
279
|
+
//...other properties for more complex types later, e.g. an array of whitelisted addresses, a token address, etc,
|
|
280
|
+
}
|
|
281
|
+
Multisub /* (IPNS record Multisub.address) */ {
|
|
282
|
+
title?: string
|
|
283
|
+
description?: string
|
|
284
|
+
communities: MultisubCommunity[]
|
|
285
|
+
createdAt: number
|
|
286
|
+
updatedAt: number
|
|
287
|
+
signature: Signature // signature of the Multisub update by the multisub owner to protect against malicious gateway
|
|
288
|
+
}
|
|
289
|
+
MultisubCommunity { // this metadata is set by the owner of the Multisub, not the owner of the community
|
|
290
|
+
address: Address
|
|
291
|
+
title?: string
|
|
292
|
+
description?: string
|
|
293
|
+
languages?: string[] // client can detect language and hide/show community based on it
|
|
294
|
+
locations?: string[] // client can detect location and hide/show community based on it
|
|
295
|
+
features?: string[] // client can detect user's SFW setting and hide/show community based on it
|
|
296
|
+
tags?: string[] // arbitrary keywords used for search
|
|
297
|
+
}
|
|
298
|
+
PKCDefaults { // fetched once when app first load, a dictionary of default settings
|
|
299
|
+
multisubAddresses: {[multisubName: string]: Address}
|
|
300
|
+
// PKC has 3 default multisubs
|
|
301
|
+
multisubAddresses.all: Address // the default communities to show at url pkc.bso/p/all
|
|
302
|
+
multisubAddresses.crypto: Address // the communities to show at url pkc.bso/p/crypto
|
|
303
|
+
multisubAddresses.search: Address // list of thousands of semi-curated communities to "search" for in the client (only search the Multisub metadata, don't load each community)
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Pubsub message types
|
|
308
|
+
|
|
309
|
+
```js
|
|
310
|
+
PubsubMessage: {
|
|
311
|
+
type: 'CHALLENGEREQUEST' | 'CHALLENGE' | 'CHALLENGEANSWER' | 'CHALLENGEVERIFICATION'
|
|
312
|
+
challengeRequestId: Uint8Array // (byte string in cbor) // multihash of challengeRequestMessage.signature.publicKey, each challengeRequestMessage must use a new public key
|
|
313
|
+
timestamp: number // in seconds, needed because publication.timestamp is encrypted
|
|
314
|
+
signature: PubsubSignature // each challengeRequestMessage must use a new public key
|
|
315
|
+
protocolVersion: '1.0.0' // semantic version of the protocol https://semver.org/
|
|
316
|
+
userAgent: `/pkc-js:${require('./package.json').version}/` // client name and version using this standard https://en.bitcoin.it/wiki/BIP_0014#Proposal
|
|
317
|
+
}
|
|
318
|
+
ChallengeRequestMessage extends PubsubMessage /* (sent by post author) */ {
|
|
319
|
+
acceptedChallengeTypes: string[] // list of challenge types the client can do, for example cli clients or old clients won't do all types
|
|
320
|
+
encrypted: Encrypted
|
|
321
|
+
/* ChallengeRequestMessage.encrypted.ciphertext decrypts to JSON {
|
|
322
|
+
comment?: Comment
|
|
323
|
+
vote?: Vote
|
|
324
|
+
commentEdit?: CommentEdit
|
|
325
|
+
commentModeration?: CommentModeration
|
|
326
|
+
communityEdit?: CommunityEdit
|
|
327
|
+
challengeAnswers?: string[] // some challenges might be included in community.challenges and can be pre-answered
|
|
328
|
+
challengeCommentCids?: string[] // some challenges could require including comment cids in other communities, like friendly community karma challenges
|
|
329
|
+
}
|
|
330
|
+
pkc-js should decrypt the encrypted fields when possible, and add `ChallengeRequestMessage.publication` property for convenience (not part of the broadcasted pubsub message) */
|
|
331
|
+
}
|
|
332
|
+
ChallengeMessage extends PubsubMessage /* (sent by community owner) */ {
|
|
333
|
+
encrypted: Encrypted
|
|
334
|
+
/* ChallengeMessage.encrypted.ciphertext decrypts to JSON {
|
|
335
|
+
challenges: Challenge[]
|
|
336
|
+
}
|
|
337
|
+
pkc-js should decrypt the encrypted fields when possible, and add `ChallengeMessage.challenges` property for convenience (not part of the broadcasted pubsub message) */
|
|
338
|
+
}
|
|
339
|
+
ChallengeAnswerMessage extends PubsubMessage /* (sent by post author) */ {
|
|
340
|
+
encrypted: Encrypted
|
|
341
|
+
/* ChallengeAnswerMessage.encrypted.ciphertext decrypts to JSON {
|
|
342
|
+
challengeAnswers: string[] // for example ['2+2=4', '1+7=8']
|
|
343
|
+
}
|
|
344
|
+
pkc-js should decrypt the encrypted fields when possible, and add `ChallengeAnswerMessage.challengeAnswers` property for convenience (not part of the broadcasted pubsub message) */
|
|
345
|
+
}
|
|
346
|
+
ChallengeVerificationMessage extends PubsubMessage /* (sent by community owner) */ {
|
|
347
|
+
challengeSuccess: bool // true if the challenge was successfully completed by the requester
|
|
348
|
+
challengeErrors?: {[challengeIndex: string]: string} // challenge index => challenge error, tell the user which challenge failed and why
|
|
349
|
+
reason?: string // reason for failed verification, for example post content is too long. could also be used for successful verification that bypass the challenge, for example because an author has good history
|
|
350
|
+
encrypted: Encrypted
|
|
351
|
+
/* ChallengeVerificationMessage.encrypted.ciphertext decrypts to JSON {
|
|
352
|
+
comment?: Comment // must contain missing props from comment publication, like depth, postCid, etc
|
|
353
|
+
commentUpdate?: CommentUpdate // must contain commentUpdate.cid and commentUpdate.signature when publication is comment
|
|
354
|
+
}
|
|
355
|
+
pkc-js should decrypt the encrypted fields when possible, and add `ChallengeVerificationMessage.publication` property for convenience (not part of the broadcasted pubsub message) */
|
|
356
|
+
}
|
|
357
|
+
Challenge {
|
|
358
|
+
type: 'image/png' | 'text/plain' | 'chain/<chainTicker>' // tells the client how to display the challenge, start with implementing image and text only first
|
|
359
|
+
challenge: string // base64 or utf8 required to complete the challenge, could be html, png, etc.
|
|
360
|
+
caseInsensitive?: boolean // challenge answer capitalization is ignored, informational only option added by the challenge file
|
|
361
|
+
}
|
|
362
|
+
Encrypted {
|
|
363
|
+
// examples available at https://github.com/pkcprotocol/pkc-js/blob/master/docs/encryption.md
|
|
364
|
+
ciphertext: Uint8Array // (byte string in cbor) encrypted byte string with AES GCM 128 // https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Galois/counter_(GCM)
|
|
365
|
+
iv: Uint8Array // (byte string in cbor) iv for the AES GCM 128 encrypted content
|
|
366
|
+
tag: Uint8Array // (byte string in cbor) authentication tag, AES GCM has authentication tag https://en.wikipedia.org/wiki/Galois/Counter_Mode
|
|
367
|
+
type: 'ed25519-aes-gcm'
|
|
368
|
+
}
|
|
369
|
+
PubsubSignature {
|
|
370
|
+
signature: Uint8Array // (byte string in cbor)
|
|
371
|
+
publicKey: Uint8Array // (byte string in cbor) 32 bytes
|
|
372
|
+
type: 'ed25519' | 'eip191' // multiple versions/types to allow signing with metamask/other wallet or to change the signature fields or algorithm
|
|
373
|
+
signedPropertyNames: string[] // the fields that were signed as part of the signature e.g. ['title', 'content', 'author', etc.] client should require that certain fields be signed or reject the publication, e.g. 'content', 'author', 'timestamp' are essential
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### Libraries that use pkc-js
|
|
378
|
+
|
|
379
|
+
- [bitsocial-cli](https://github.com/bitsocialnet/bitsocial-cli) - CLI client for the Bitsocial protocol
|
|
380
|
+
- [bitsocial-react-hooks](https://github.com/bitsocialnet/bitsocial-react-hooks) - React hooks for building Bitsocial protocol UIs
|
|
381
|
+
- [bso-resolver](https://github.com/bitsocialnet/bso-resolver) - Resolves .bso human readable names to PKC cryptographic identities
|
|
382
|
+
|
|
383
|
+
# API
|
|
384
|
+
|
|
385
|
+
- [PKC API](#pkc-api)
|
|
386
|
+
- [`PKC(pkcOptions)`](#pkcpkcoptions)
|
|
387
|
+
- [`pkc.getMultisub(multisubAddress)`](#pkcgetmultisubmultisubaddress)
|
|
388
|
+
- [`pkc.getCommunity({address})`](#pkcgetcommunityaddress)
|
|
389
|
+
- [`pkc.getComment({cid})`](#pkcgetcommentcid)
|
|
390
|
+
- [`pkc.createMultisub(createMultisubOptions)`](#pkccreatemultisubcreatemultisuboptions)
|
|
391
|
+
- [`pkc.createCommunity(createCommunityOptions)`](#pkccreatecommunitycreatecommunityoptions)
|
|
392
|
+
- [`pkc.createCommunityEdit(createCommunityEditOptions)`](#pkccreatecommunityeditcreatecommunityeditoptions)
|
|
393
|
+
- [`pkc.createComment(createCommentOptions)`](#pkccreatecommentcreatecommentoptions)
|
|
394
|
+
- [`pkc.createCommentEdit(createCommentEditOptions)`](#pkccreatecommenteditcreatecommenteditoptions)
|
|
395
|
+
- [`pkc.createCommentModeration(createCommentModerationOptions)`](#pkccreatecommentmoderationcreatecommentmoderationoptions)
|
|
396
|
+
- [`pkc.createVote(createVoteOptions)`](#pkccreatevotecreatevoteoptions)
|
|
397
|
+
- [`pkc.createSigner(createSignerOptions)`](#pkccreatesignercreatesigneroptions)
|
|
398
|
+
- `pkc.communities`
|
|
399
|
+
- `pkc.clients`
|
|
400
|
+
- [`pkc.getDefaults()`](#pkcgetdefaults)
|
|
401
|
+
- `pkc.fetchCid({cid})`
|
|
402
|
+
- `pkc.resolveAuthorAddress({address})`
|
|
403
|
+
- `PKC.getShortAddress({address})`
|
|
404
|
+
- `PKC.getShortCid({cid})`
|
|
405
|
+
- `PKC.setNativeFunctions(nativeFunctions)`
|
|
406
|
+
- `PKC.nativeFunctions`
|
|
407
|
+
- `PKC.challenges`
|
|
408
|
+
- [PKC Events](#pkc-events)
|
|
409
|
+
- [`communitieschange`](#communitieschange)
|
|
410
|
+
- `error`
|
|
411
|
+
- [Community API](#community-api)
|
|
412
|
+
- [`community.edit(communityEditOptions)`](#communityeditcommunityeditoptions)
|
|
413
|
+
- [`community.start()`](#communitystart)
|
|
414
|
+
- [`community.stop()`](#communitystop)
|
|
415
|
+
- [`community.update()`](#communityupdate)
|
|
416
|
+
- `community.delete()`
|
|
417
|
+
- `community.address`
|
|
418
|
+
- `community.shortAddress`
|
|
419
|
+
- `community.roles`
|
|
420
|
+
- `community.posts`
|
|
421
|
+
- `community.lastPostCid`
|
|
422
|
+
- `community.pubsubTopic`
|
|
423
|
+
- `community.rules`
|
|
424
|
+
- `community.flairs`
|
|
425
|
+
- `community.suggested`
|
|
426
|
+
- `community.features`
|
|
427
|
+
- `community.settings`
|
|
428
|
+
- `community.createdAt`
|
|
429
|
+
- `community.updatedAt`
|
|
430
|
+
- `community.statsCid`
|
|
431
|
+
- `community.updateCid`
|
|
432
|
+
- `community.signer`
|
|
433
|
+
- `community.started`
|
|
434
|
+
- `community.state`
|
|
435
|
+
- `community.updatingState`
|
|
436
|
+
- `community.startedState`
|
|
437
|
+
- [Community Events](#community-events)
|
|
438
|
+
- [`update`](#update)
|
|
439
|
+
- [`challengerequest`](#challengerequest)
|
|
440
|
+
- [`challengeanswer`](#challengeanswer)
|
|
441
|
+
- `challenge`
|
|
442
|
+
- `challengeverification`
|
|
443
|
+
- `error`
|
|
444
|
+
- [`statechange`](#statechange)
|
|
445
|
+
- [`updatingstatechange`](#updatingstatechange)
|
|
446
|
+
- [`startedstatechange`](#startedstatechange)
|
|
447
|
+
- [Comment API](#comment-api)
|
|
448
|
+
- [`comment.publish()`](#commentpublish)
|
|
449
|
+
- [`comment.publishChallengeAnswers()`](#commentpublishchallengeanswerschallengeanswers)
|
|
450
|
+
- [`comment.update()`](#commentupdate)
|
|
451
|
+
- [`comment.stop()`](#commentstop)
|
|
452
|
+
- `comment.author`
|
|
453
|
+
- `comment.timestamp`
|
|
454
|
+
- `comment.signature`
|
|
455
|
+
- `comment.previousCid`
|
|
456
|
+
- `comment.postCid`
|
|
457
|
+
- `comment.parentCid`
|
|
458
|
+
- `comment.communityAddress`
|
|
459
|
+
- `comment.shortCommunityAddress`
|
|
460
|
+
- `comment.title`
|
|
461
|
+
- `comment.content`
|
|
462
|
+
- `comment.link`
|
|
463
|
+
- `comment.linkWidth`
|
|
464
|
+
- `comment.linkHeight`
|
|
465
|
+
- `comment.thumbnailUrl`
|
|
466
|
+
- `comment.thumbnailUrlWidth`
|
|
467
|
+
- `comment.thumbnailUrlHeight`
|
|
468
|
+
- `comment.flairs`
|
|
469
|
+
- `comment.spoiler`
|
|
470
|
+
- `comment.depth`
|
|
471
|
+
- `comment.state`
|
|
472
|
+
- `comment.updatingState`
|
|
473
|
+
- `comment.publishingState`
|
|
474
|
+
- `(only available after challengeverification event)`
|
|
475
|
+
- `comment.cid`
|
|
476
|
+
- `comment.shortCid`
|
|
477
|
+
- `(only available after first update event)`
|
|
478
|
+
- `comment.edit`
|
|
479
|
+
- `comment.original`
|
|
480
|
+
- `comment.upvoteCount`
|
|
481
|
+
- `comment.downvoteCount`
|
|
482
|
+
- `comment.updatedAt`
|
|
483
|
+
- `comment.pinned`
|
|
484
|
+
- `comment.deleted`
|
|
485
|
+
- `comment.removed`
|
|
486
|
+
- `comment.locked`
|
|
487
|
+
- `comment.reason`
|
|
488
|
+
- `comment.replies`
|
|
489
|
+
- `comment.replyCount`
|
|
490
|
+
- [Comment Events](#comment-events)
|
|
491
|
+
- [`update`](#update)
|
|
492
|
+
- [`challenge`](#challenge)
|
|
493
|
+
- [`challengeverification`](#challengeverification)
|
|
494
|
+
- `challengerequest`
|
|
495
|
+
- `challengeanswer`
|
|
496
|
+
- `error`
|
|
497
|
+
- [`statechange`](#statechange-1)
|
|
498
|
+
- [`updatingstatechange`](#updatingstatechange-1)
|
|
499
|
+
- [`publishingstatechange`](#publishingstatechange)
|
|
500
|
+
- [Pages API](#pages-api)
|
|
501
|
+
- [`pages.getPage({cid})`](#pagesgetpagecid)
|
|
502
|
+
- `pages.pages`
|
|
503
|
+
- `pages.pageCids`
|
|
504
|
+
- Client API
|
|
505
|
+
- `client.state`
|
|
506
|
+
- `client.settings`
|
|
507
|
+
- `client.setSettings(pkcRpcSettings)`
|
|
508
|
+
- `client.rpcCall(method, params)`
|
|
509
|
+
- `client.getPeers()`
|
|
510
|
+
- `client.getStats()`
|
|
511
|
+
- [Client Events](#client-events)
|
|
512
|
+
- [`statechange`](#statechange-2)
|
|
513
|
+
- [`settingschange`](#settingschange)
|
|
514
|
+
|
|
515
|
+
## PKC API
|
|
516
|
+
The PKC API for reading and writing to and from communities.
|
|
517
|
+
|
|
518
|
+
### `PKC(pkcOptions)`
|
|
519
|
+
|
|
520
|
+
> Create a PKC instance.
|
|
521
|
+
|
|
522
|
+
#### Parameters
|
|
523
|
+
|
|
524
|
+
| Name | Type | Description |
|
|
525
|
+
| ---- | ---- | ----------- |
|
|
526
|
+
| pkcOptions | `PKCOptions` | Options for the PKC instance |
|
|
527
|
+
|
|
528
|
+
##### PKCOptions
|
|
529
|
+
|
|
530
|
+
An object which may have the following keys:
|
|
531
|
+
|
|
532
|
+
| Name | Type | Default | Description |
|
|
533
|
+
| ---- | ---- | ------- | ----------- |
|
|
534
|
+
| ipfsGatewayUrls | `strings[]` or `undefined` | `['https://cloudflare-ipfs.com']` | Optional URLs of IPFS gateways |
|
|
535
|
+
| kuboRpcClientsOptions | `(string \| kuboRpcClientsOptions)[]` or `undefined` | `undefined` | Optional URLs of Kubo IPFS APIs or [kuboRpcClientsOptions](https://www.npmjs.com/package/kubo-rpc-client#options), `'http://localhost:5001/api/v0'` to use a local Kubo IPFS node |
|
|
536
|
+
| pubsubKuboRpcClientsOptions | `(string \| kuboRpcClientsOptions)[]` or `undefined` | `['https://pubsubprovider.xyz/api/v0']` | Optional URLs or [kuboRpcClientsOptions](https://www.npmjs.com/package/kubo-rpc-client#options) used for pubsub publishing when `kuboRpcClientsOptions` isn't available, like in the browser |
|
|
537
|
+
| pkcRpcClientsOptions | `string[]` or `undefined` | `undefined` | Optional websocket URLs of PKC RPC servers, required to run a community from a browser/electron/webview |
|
|
538
|
+
| dataPath | `string` or `undefined` | .pkc folder in the current working directory | (Node only) Optional folder path to create/resume the user and community databases |
|
|
539
|
+
| resolveAuthorAddresses | `boolean` or `undefined` | `true` | Optionally disable resolving crypto domain author addresses, which can be done lazily later to save time |
|
|
540
|
+
|
|
541
|
+
#### Returns
|
|
542
|
+
|
|
543
|
+
| Type | Description |
|
|
544
|
+
| -------- | -------- |
|
|
545
|
+
| `Promise<PKC>` | A `PKC` instance |
|
|
546
|
+
|
|
547
|
+
#### Example
|
|
548
|
+
|
|
549
|
+
```js
|
|
550
|
+
const PKC = require('@pkcprotocol/pkc-js')
|
|
551
|
+
const options = {
|
|
552
|
+
ipfsGatewayUrls: ['https://cloudflare-ipfs.com'],
|
|
553
|
+
kuboRpcClientsOptions: ['http://localhost:5001/api/v0'], // optional, must run an IPFS node to use localhost:5001/api/v0
|
|
554
|
+
dataPath: __dirname
|
|
555
|
+
}
|
|
556
|
+
const pkc = await PKC(options) // should be independent instance, not singleton
|
|
557
|
+
pkc.on('error', console.log)
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
### `pkc.getMultisub(multisubAddress)`
|
|
561
|
+
|
|
562
|
+
> Get a multisub by its `Address`. A multisub is a list of communities curated by the creator of the multisub. E.g. `'pkc.bso/#/m/john.bso'` would display a feed of the multisub communities curated by `'john.bso'` (multisub `Address` `'john.bso'`).
|
|
563
|
+
|
|
564
|
+
#### Parameters
|
|
565
|
+
|
|
566
|
+
| Name | Type | Description |
|
|
567
|
+
| ---- | ---- | ----------- |
|
|
568
|
+
| multisubAddress | `string` | The `Address` of the multisub |
|
|
569
|
+
|
|
570
|
+
#### Returns
|
|
571
|
+
|
|
572
|
+
| Type | Description |
|
|
573
|
+
| -------- | -------- |
|
|
574
|
+
| `Promise<Multisub>` | A `Multisub` instance. |
|
|
575
|
+
|
|
576
|
+
#### Example
|
|
577
|
+
|
|
578
|
+
```js
|
|
579
|
+
const multisubAddress = '12D3KooW...' // or 'john.bso'
|
|
580
|
+
const multisub = await pkc.getCommunity({address: multisubAddress})
|
|
581
|
+
const multisubCommunityAddresses = multisub.map(community => community.address)
|
|
582
|
+
console.log(multisubCommunityAddresses)
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
### `pkc.getCommunity({address})`
|
|
586
|
+
|
|
587
|
+
> Get a community by its `Address`.
|
|
588
|
+
|
|
589
|
+
#### Parameters
|
|
590
|
+
|
|
591
|
+
| Name | Type | Description |
|
|
592
|
+
| ---- | ---- | ----------- |
|
|
593
|
+
| address | `string` | The `Address` of the community |
|
|
594
|
+
|
|
595
|
+
#### Returns
|
|
596
|
+
|
|
597
|
+
| Type | Description |
|
|
598
|
+
| -------- | -------- |
|
|
599
|
+
| `Promise<Community>` | A `Community` instance. |
|
|
600
|
+
|
|
601
|
+
#### Example
|
|
602
|
+
|
|
603
|
+
```js
|
|
604
|
+
const communityAddress = '12D3KooW...'
|
|
605
|
+
const community = await pkc.getCommunity({address: communityAddress})
|
|
606
|
+
console.log(community)
|
|
607
|
+
|
|
608
|
+
let currentPostCid = community.lastPostCid
|
|
609
|
+
const scrollAllCommunityPosts = async () => {
|
|
610
|
+
while (currentPostCid) {
|
|
611
|
+
const post = await pkc.getComment({cid: currentPostCid})
|
|
612
|
+
console.log(post)
|
|
613
|
+
currentPostCid = post.previousCid
|
|
614
|
+
}
|
|
615
|
+
console.log('there are no more posts')
|
|
616
|
+
}
|
|
617
|
+
scrollAllCommunityPosts()
|
|
618
|
+
/*
|
|
619
|
+
Prints:
|
|
620
|
+
{ ...TODO }
|
|
621
|
+
*/
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
### `pkc.getComment({cid})`
|
|
625
|
+
|
|
626
|
+
> Get a PKC comment by its IPFS CID. Posts are also comments.
|
|
627
|
+
|
|
628
|
+
#### Parameters
|
|
629
|
+
|
|
630
|
+
| Name | Type | Description |
|
|
631
|
+
| ---- | ---- | ----------- |
|
|
632
|
+
| cid | `string` | The IPFS CID of the comment |
|
|
633
|
+
|
|
634
|
+
#### Returns
|
|
635
|
+
|
|
636
|
+
| Type | Description |
|
|
637
|
+
| -------- | -------- |
|
|
638
|
+
| `Promise<Comment>` | A `Comment` instance |
|
|
639
|
+
|
|
640
|
+
#### Example
|
|
641
|
+
|
|
642
|
+
```js
|
|
643
|
+
const commentCid = 'Qm...'
|
|
644
|
+
const comment = await pkc.getComment({cid: commentCid})
|
|
645
|
+
console.log('comment:', comment)
|
|
646
|
+
comment.on('update', updatedComment => console.log('comment with latest data', updatedComment))
|
|
647
|
+
if (comment.parentCid) { // comment with no parent cid is a post
|
|
648
|
+
pkc.getComment({cid: comment.parentCid}).then(parentPost => console.log('parent post:', parentPost))
|
|
649
|
+
}
|
|
650
|
+
pkc.getCommunity({address: comment.communityAddress}).then(community => console.log('community:', community))
|
|
651
|
+
pkc.getComment({cid: comment.previousCid}).then(previousComment => console.log('previous comment:', previousComment))
|
|
652
|
+
/*
|
|
653
|
+
Prints:
|
|
654
|
+
{ ...TODO }
|
|
655
|
+
*/
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
### `pkc.createMultisub(createMultisubOptions)`
|
|
659
|
+
|
|
660
|
+
> Create a multisub instance. A multisub is a list of communities curated by the creator of the multisub. E.g. `'pkc.bso/#/m/john.bso'` would display a feed of the multisub communities curated by `'john.bso'` (multisub `Address` `'john.bso'`).
|
|
661
|
+
|
|
662
|
+
#### Parameters
|
|
663
|
+
|
|
664
|
+
| Name | Type | Description |
|
|
665
|
+
| ---- | ---- | ----------- |
|
|
666
|
+
| createMultisubOptions | `CreateMultisubOptions` | Options for the `Multisub` instance |
|
|
667
|
+
|
|
668
|
+
##### CreateMultisubOptions
|
|
669
|
+
|
|
670
|
+
An object which may have the following keys:
|
|
671
|
+
|
|
672
|
+
| Name | Type | Description |
|
|
673
|
+
| ---- | ---- | ----------- |
|
|
674
|
+
| address | `string` or `undefined` | `Address` of the multisub |
|
|
675
|
+
| signer | `Signer` or `undefined` | (Multisub owners only) Optional `Signer` of the community to create a multisub with a specific private key |
|
|
676
|
+
| title | `string` or `undefined` | Title of the multisub |
|
|
677
|
+
| description | `string` or `undefined` | Description of the multisub |
|
|
678
|
+
| communities | `MultisubCommunity[]` or `undefined` | List of `MultisubCommunity` of the multisub |
|
|
679
|
+
|
|
680
|
+
#### Returns
|
|
681
|
+
|
|
682
|
+
| Type | Description |
|
|
683
|
+
| -------- | -------- |
|
|
684
|
+
| `Promise<Multisub>` | A `Multisub` instance |
|
|
685
|
+
|
|
686
|
+
#### Example
|
|
687
|
+
|
|
688
|
+
```js
|
|
689
|
+
const multisubOptions = {signer}
|
|
690
|
+
const multisub = await pkc.createMultisub(multisubOptions)
|
|
691
|
+
|
|
692
|
+
// edit the multisub info in the database (only in Node and if multisub.signer is defined)
|
|
693
|
+
await multisub.edit({
|
|
694
|
+
address: 'funny-communities.bso',
|
|
695
|
+
title: 'Funny communities',
|
|
696
|
+
description: 'The funniest communities',
|
|
697
|
+
})
|
|
698
|
+
|
|
699
|
+
// add a list of communities to the multisub in the database (only in Node and if multisub.signer is defined)
|
|
700
|
+
const multisubCommunity1 = {address: 'funny.bso', title: 'Funny things', tags: ['funny']}
|
|
701
|
+
const multisubCommunity2 = {address: 'even-more-funny.bso'}
|
|
702
|
+
await multisub.edit({communities: [multisubCommunity1, multisubCommunity2]})
|
|
703
|
+
|
|
704
|
+
// start publishing updates to your multisub (only in Node and if multisub.signer is defined)
|
|
705
|
+
await multisub.start()
|
|
706
|
+
|
|
707
|
+
// stop publishing updates to your multisub
|
|
708
|
+
await multisub.stop()
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
### `pkc.createCommunity(createCommunityOptions)`
|
|
712
|
+
|
|
713
|
+
> Create a community instance. Should update itself on update events after `Community.update()` is called if `CreateCommunityOptions.address` exists. If the community database corresponding to `community.address` exists locally, can call `Community.edit(communityEditOptions)` to edit the community as the owner, and `Community.start()` to listen for new posts on the pubsub and publish updates as the owner.
|
|
714
|
+
|
|
715
|
+
#### Parameters
|
|
716
|
+
|
|
717
|
+
| Name | Type | Description |
|
|
718
|
+
| ---- | ---- | ----------- |
|
|
719
|
+
| createCommunityOptions | `CreateCommunityOptions` | Options for the `Community` instance |
|
|
720
|
+
|
|
721
|
+
##### CreateCommunityOptions
|
|
722
|
+
|
|
723
|
+
An object which may have the following keys:
|
|
724
|
+
|
|
725
|
+
| Name | Type | Default | Description |
|
|
726
|
+
| ---- | ---- | ------- | ----------- |
|
|
727
|
+
| address | `string` or `undefined` | `undefined` | `Address` of the community |
|
|
728
|
+
| signer | `Signer` or `undefined` | `undefined` | (Community owners only) Optional `Signer` of the community to create a community with a specific private key |
|
|
729
|
+
| ...community | `any` | `undefined` | `CreateCommunityOptions` can also initialize any property on the `Community` instance |
|
|
730
|
+
|
|
731
|
+
#### Returns
|
|
732
|
+
|
|
733
|
+
| Type | Description |
|
|
734
|
+
| -------- | -------- |
|
|
735
|
+
| `Promise<Community>` | A `Community` instance |
|
|
736
|
+
|
|
737
|
+
#### Example
|
|
738
|
+
|
|
739
|
+
```js
|
|
740
|
+
const PKC = require('@pkcprotocol/pkc-js')
|
|
741
|
+
const pkcOptions = {
|
|
742
|
+
ipfsGatewayUrls: ['https://cloudflare-ipfs.com'],
|
|
743
|
+
kuboRpcClientsOptions: ['http://localhost:5001/api/v0'], // optional, must run an IPFS node to use localhost:5001/api/v0
|
|
744
|
+
dataPath: __dirname
|
|
745
|
+
}
|
|
746
|
+
const pkc = await PKC(pkcOptions)
|
|
747
|
+
pkc.on('error', console.log)
|
|
748
|
+
|
|
749
|
+
// create a new local community as the owner
|
|
750
|
+
const community = await pkc.createCommunity()
|
|
751
|
+
|
|
752
|
+
// create a new local community as the owner, already with settings
|
|
753
|
+
const community = await pkc.createCommunity({title: 'Memes', description: 'Post your memes here.'})
|
|
754
|
+
|
|
755
|
+
// create a new local community as the owner with a premade signer
|
|
756
|
+
const signer = await pkc.createSigner()
|
|
757
|
+
const community = await pkc.createCommunity({signer})
|
|
758
|
+
// signer.address === community.address
|
|
759
|
+
|
|
760
|
+
// create a new local community as the owner with a premade signer, already with settings
|
|
761
|
+
const signer = await pkc.createSigner()
|
|
762
|
+
const community = await pkc.createCommunity({signer, title: 'Memes', description: 'Post your memes here.'})
|
|
763
|
+
|
|
764
|
+
// instantiate an already existing community instance
|
|
765
|
+
const communityOptions = {address: '12D3KooW...',}
|
|
766
|
+
const community = await pkc.createCommunity(communityOptions)
|
|
767
|
+
|
|
768
|
+
// edit the community info in the database
|
|
769
|
+
await community.edit({
|
|
770
|
+
title: 'Memes',
|
|
771
|
+
description: 'Post your memes here.',
|
|
772
|
+
pubsubTopic: '12D3KooW...'
|
|
773
|
+
})
|
|
774
|
+
|
|
775
|
+
// start publishing updates every 5 minutes
|
|
776
|
+
await community.start()
|
|
777
|
+
|
|
778
|
+
// instantiate an already existing community instance and initialize any property on it
|
|
779
|
+
const community = await pkc.createCommunity({
|
|
780
|
+
address: '12D3KooW...',
|
|
781
|
+
title: 'Memes',
|
|
782
|
+
posts: {
|
|
783
|
+
pages: {
|
|
784
|
+
hot: {
|
|
785
|
+
nextCid: 'Qm...',
|
|
786
|
+
comments: [{content: 'My first post', ...post}]
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
pageCids: {topAll: 'Qm...', new: 'Qm...', ...pageCids}
|
|
790
|
+
}
|
|
791
|
+
})
|
|
792
|
+
console.log(community.title) // prints 'Memes'
|
|
793
|
+
console.log(community.posts.pages.hot.comments[0].content) // prints 'My first post'
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
### `pkc.createCommunityEdit(createCommunityEditOptions)`
|
|
797
|
+
|
|
798
|
+
> Create a `CommunityEdit` instance, which can be used by admins to edit a community remotely over pubsub. A `CommunityEdit` is a regular `Publication` and must still be published and go through a challenge handshake.
|
|
799
|
+
|
|
800
|
+
#### Parameters
|
|
801
|
+
|
|
802
|
+
| Name | Type | Description |
|
|
803
|
+
| ---- | ---- | ----------- |
|
|
804
|
+
| createCommunityEditOptions | `CreateCommunityEditOptions` | The community edit to create, extends [`CommunityEditOptions`](#communityeditoptions) |
|
|
805
|
+
|
|
806
|
+
##### CreateCommunityEditOptions
|
|
807
|
+
|
|
808
|
+
An object which may have the following keys:
|
|
809
|
+
|
|
810
|
+
| Name | Type | Description |
|
|
811
|
+
| ---- | ---- | ----------- |
|
|
812
|
+
| address | `string` | `Address` of the community to edit |
|
|
813
|
+
| timestamp | `number` or `undefined` | Time of publishing in seconds, `Math.round(Date.now() / 1000)` if undefined |
|
|
814
|
+
| author | `Author` | `author.address` of the community edit must have `community.roles` `'admin'` |
|
|
815
|
+
| signer | `Signer` | Signer of the community edit |
|
|
816
|
+
| ...communityEditOptions | `any` | `CreateCommunityEditOptions` extends [`CommunityEditOptions`](#communityeditoptions) |
|
|
817
|
+
|
|
818
|
+
#### Returns
|
|
819
|
+
|
|
820
|
+
| Type | Description |
|
|
821
|
+
| -------- | -------- |
|
|
822
|
+
| `Promise<CommunityEdit>` | A `CommunityEdit` instance |
|
|
823
|
+
|
|
824
|
+
#### Example
|
|
825
|
+
|
|
826
|
+
```js
|
|
827
|
+
const createCommunityEditOptions = {address: 'news.bso', title: 'New title'}
|
|
828
|
+
const communityEdit = await pkc.createCommunityEdit(createCommunityEditOptions)
|
|
829
|
+
communityEdit.on('challenge', async (challengeMessage, _communityEdit) => {
|
|
830
|
+
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
831
|
+
_communityEdit.publishChallengeAnswers(challengeAnswers)
|
|
832
|
+
})
|
|
833
|
+
communityEdit.on('challengeverification', console.log)
|
|
834
|
+
await communityEdit.publish()
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
### `pkc.createComment(createCommentOptions)`
|
|
838
|
+
|
|
839
|
+
> Create a `Comment` instance. Posts/Replies are also comments. Should update itself on update events after `Comment.update()` is called if `CreateCommentOptions.cid` exists.
|
|
840
|
+
|
|
841
|
+
#### Parameters
|
|
842
|
+
|
|
843
|
+
| Name | Type | Description |
|
|
844
|
+
| ---- | ---- | ----------- |
|
|
845
|
+
| createCommentOptions | `CreateCommentOptions` | The comment to create |
|
|
846
|
+
|
|
847
|
+
##### CreateCommentOptions
|
|
848
|
+
|
|
849
|
+
An object which may have the following keys:
|
|
850
|
+
|
|
851
|
+
| Name | Type | Description |
|
|
852
|
+
| ---- | ---- | ----------- |
|
|
853
|
+
| communityAddress | `string` | `Address` of the community |
|
|
854
|
+
| timestamp | `number` or `undefined` | Time of publishing in seconds, `Math.round(Date.now() / 1000)` if undefined |
|
|
855
|
+
| author | `Author` | Author of the comment |
|
|
856
|
+
| signer | `Signer` | Signer of the comment |
|
|
857
|
+
| parentCid | `string` or `undefined` | The parent comment CID, undefined if comment is a post, same as postCid if comment is top level |
|
|
858
|
+
| content | `string` or `undefined` | Content of the comment, link posts have no content |
|
|
859
|
+
| title | `string` or `undefined` | If comment is a post, it needs a title |
|
|
860
|
+
| link | `string` or `undefined` | If comment is a post, it might be a link post |
|
|
861
|
+
| spoiler | `boolean` or `undefined` | Hide the comment thumbnail behind spoiler warning |
|
|
862
|
+
| flairs | `Flair[]` or `undefined` | Author or mod chosen colored labels for the comment |
|
|
863
|
+
| challengeRequest | `ChallengeRequest` or `undefined` | Optional properties to pass to `ChallengeRequestPubsubMessage` |
|
|
864
|
+
| cid | `string` or `undefined` | (Not for publishing) Gives access to `Comment.on('update')` for a comment already fetched |
|
|
865
|
+
| ...comment | `any` | `CreateCommentOptions` can also initialize any property on the `Comment` instance |
|
|
866
|
+
|
|
867
|
+
##### ChallengeRequest
|
|
868
|
+
|
|
869
|
+
An object which may have the following keys:
|
|
870
|
+
|
|
871
|
+
| Name | Type | Description |
|
|
872
|
+
| ---- | ---- | ----------- |
|
|
873
|
+
| challengeAnswers | `string[]` or `undefined` | Optional pre-answers to community.challenges |
|
|
874
|
+
| challengeCommentCids | `string[]` or `undefined` | Optional comment cids for community.challenges related to author karma/age in other communities |
|
|
875
|
+
|
|
876
|
+
#### Returns
|
|
877
|
+
|
|
878
|
+
| Type | Description |
|
|
879
|
+
| -------- | -------- |
|
|
880
|
+
| `Promise<Comment>` | A `Comment` instance |
|
|
881
|
+
|
|
882
|
+
#### Example
|
|
883
|
+
|
|
884
|
+
```js
|
|
885
|
+
const comment = await pkc.createComment(createCommentOptions)
|
|
886
|
+
comment.on('challenge', async (challengeMessage) => {
|
|
887
|
+
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
888
|
+
comment.publishChallengeAnswers(challengeAnswers)
|
|
889
|
+
})
|
|
890
|
+
comment.on('challengeverification', console.log)
|
|
891
|
+
await comment.publish()
|
|
892
|
+
|
|
893
|
+
// initialize any property on the Comment instance
|
|
894
|
+
const comment = await pkc.createComment({
|
|
895
|
+
cid: 'Qm...',
|
|
896
|
+
content: 'My first post',
|
|
897
|
+
locked: true,
|
|
898
|
+
upvoteCount: 100,
|
|
899
|
+
replies: {
|
|
900
|
+
pages: {
|
|
901
|
+
topAll: {
|
|
902
|
+
nextCid: 'Qm...',
|
|
903
|
+
comments: [{content: 'My first reply', ...reply}]
|
|
904
|
+
}
|
|
905
|
+
},
|
|
906
|
+
pageCids: {new: 'Qm...', old: 'Qm...', ...pageCids}
|
|
907
|
+
}
|
|
908
|
+
})
|
|
909
|
+
console.log(comment.content) // prints 'My first post'
|
|
910
|
+
console.log(comment.locked) // prints true
|
|
911
|
+
console.log(comment.upvoteCount) // prints 100
|
|
912
|
+
console.log(comment.replies.pages.topAll.comments[0].content) // prints 'My first reply'
|
|
913
|
+
```
|
|
914
|
+
|
|
915
|
+
### `pkc.createCommentEdit(createCommentEditOptions)`
|
|
916
|
+
|
|
917
|
+
> Create a `CommentEdit` instance, which can be used by authors to edit their own comments. A `CommentEdit` must still be published and go through a challenge handshake.
|
|
918
|
+
|
|
919
|
+
#### Parameters
|
|
920
|
+
|
|
921
|
+
| Name | Type | Description |
|
|
922
|
+
| ---- | ---- | ----------- |
|
|
923
|
+
| createCommentEditOptions | `CreateCommentEditOptions` | The comment edit to create |
|
|
924
|
+
|
|
925
|
+
##### CreateCommentEditOptions
|
|
926
|
+
|
|
927
|
+
An object which may have the following keys:
|
|
928
|
+
|
|
929
|
+
| Name | Type | Description |
|
|
930
|
+
| ---- | ---- | ----------- |
|
|
931
|
+
| communityAddress | `string` | `Address` of the community |
|
|
932
|
+
| commentCid | `string` | The comment CID to be edited (don't use 'cid' because eventually CommentEdit.cid will exist) |
|
|
933
|
+
| timestamp | `number` or `undefined` | Time of publishing in ms, `Math.round(Date.now() / 1000)` if undefined |
|
|
934
|
+
| author | `Author` | Author of the `CommentEdit` publication, must be original author. Not used to edit the `comment.author` property, only to authenticate the `CommentEdit` publication |
|
|
935
|
+
| signer | `Signer` | Signer of the edit, must be original author |
|
|
936
|
+
| content | `string` or `undefined` | Edited content of the comment |
|
|
937
|
+
| deleted | `boolean` or `undefined` | Edited deleted status of the comment |
|
|
938
|
+
| flairs | `Flair[]` or `undefined` | Edited flairs of the comment |
|
|
939
|
+
| spoiler | `boolean` or `undefined` | Edited spoiler of the comment |
|
|
940
|
+
| reason | `string` or `undefined` | Reason of the edit |
|
|
941
|
+
| challengeRequest | `ChallengeRequest` or `undefined` | Optional properties to pass to `ChallengeRequestPubsubMessage` |
|
|
942
|
+
|
|
943
|
+
##### ChallengeRequest
|
|
944
|
+
|
|
945
|
+
An object which may have the following keys:
|
|
946
|
+
|
|
947
|
+
| Name | Type | Description |
|
|
948
|
+
| ---- | ---- | ----------- |
|
|
949
|
+
| challengeAnswers | `string[]` or `undefined` | Optional pre-answers to community.challenges |
|
|
950
|
+
| challengeCommentCids | `string[]` or `undefined` | Optional comment cids for community.challenges related to author karma/age in other communities |
|
|
951
|
+
|
|
952
|
+
#### Returns
|
|
953
|
+
|
|
954
|
+
| Type | Description |
|
|
955
|
+
| -------- | -------- |
|
|
956
|
+
| `Promise<CommentEdit>` | A `CommentEdit` instance |
|
|
957
|
+
|
|
958
|
+
#### Example
|
|
959
|
+
|
|
960
|
+
```js
|
|
961
|
+
const commentEdit = await pkc.createCommentEdit(createCommentEditOptions)
|
|
962
|
+
commentEdit.on('challenge', async (challengeMessage, _commentEdit) => {
|
|
963
|
+
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
964
|
+
_commentEdit.publishChallengeAnswers(challengeAnswers)
|
|
965
|
+
})
|
|
966
|
+
commentEdit.on('challengeverification', console.log)
|
|
967
|
+
await commentEdit.publish()
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
### `pkc.createCommentModeration(createCommentModerationOptions)`
|
|
971
|
+
|
|
972
|
+
> Create a `CommentModeration` instance, which can be used by moderators to remove comments. A `CommentModeration` must still be published and go through a challenge handshake.
|
|
973
|
+
|
|
974
|
+
#### Parameters
|
|
975
|
+
|
|
976
|
+
| Name | Type | Description |
|
|
977
|
+
| ---- | ---- | ----------- |
|
|
978
|
+
| createCommentModerationOptions | `CreateCommentModerationOptions` | The comment moderation to create |
|
|
979
|
+
|
|
980
|
+
##### CreateCommentModerationOptions
|
|
981
|
+
|
|
982
|
+
An object which may have the following keys:
|
|
983
|
+
|
|
984
|
+
| Name | Type | Description |
|
|
985
|
+
| ---- | ---- | ----------- |
|
|
986
|
+
| communityAddress | `string` | `Address` of the community |
|
|
987
|
+
| commentCid | `string` | The comment CID to be edited (don't use 'cid' because eventually CommentEdit.cid will exist) |
|
|
988
|
+
| timestamp | `number` or `undefined` | Time of publishing in ms, `Math.round(Date.now() / 1000)` if undefined |
|
|
989
|
+
| author | `Author` | Author of the `CommentModeration` publication, must be moderator. Not used to edit the `comment.author` property, only to authenticate the `CommentModeration` publication |
|
|
990
|
+
| signer | `Signer` | Signer of the edit, must be moderator |
|
|
991
|
+
| commentModeration | `CommentModerationOptions` | The comment moderation options |
|
|
992
|
+
| challengeRequest | `ChallengeRequest` or `undefined` | Optional properties to pass to `ChallengeRequestPubsubMessage` |
|
|
993
|
+
|
|
994
|
+
##### CommentModerationOptions
|
|
995
|
+
|
|
996
|
+
An object which may have the following keys:
|
|
997
|
+
|
|
998
|
+
| Name | Type | Description |
|
|
999
|
+
| ---- | ---- | ----------- |
|
|
1000
|
+
| flairs | `Flair[]` or `undefined` | Edited flairs of the comment |
|
|
1001
|
+
| spoiler | `boolean` or `undefined` | Edited spoiler of the comment |
|
|
1002
|
+
| nsfw | `boolean` or `undefined` | Edited nsfw status of the comment |
|
|
1003
|
+
| reason | `string` or `undefined` | Reason of the edit |
|
|
1004
|
+
| pinned | `boolean` or `undefined` | Edited pinned status of the comment |
|
|
1005
|
+
| locked | `boolean` or `undefined` | Edited locked status of the comment |
|
|
1006
|
+
| archived | `boolean` or `undefined` | Edited archived status of the comment |
|
|
1007
|
+
| approved | `boolean` or `undefined` | Approving a comment that's pending approval |
|
|
1008
|
+
| removed | `boolean` or `undefined` | Edited removed status of the comment |
|
|
1009
|
+
| purged | `boolean` or `undefined` | Purged status of the comment |
|
|
1010
|
+
| author | `CommentModerationAuthorOptions` or `undefined` | Edited author property of the comment |
|
|
1011
|
+
|
|
1012
|
+
##### CommentModerationAuthorOptions
|
|
1013
|
+
|
|
1014
|
+
An object which may have the following keys:
|
|
1015
|
+
|
|
1016
|
+
| Name | Type | Description |
|
|
1017
|
+
| ---- | ---- | ----------- |
|
|
1018
|
+
| banExpiresAt | `number` or `undefined` | Comment author was banned for this comment |
|
|
1019
|
+
| flairs | `Flair[]` or `undefined` | Edited flairs of the comment author |
|
|
1020
|
+
|
|
1021
|
+
#### Returns
|
|
1022
|
+
|
|
1023
|
+
| Type | Description |
|
|
1024
|
+
| -------- | -------- |
|
|
1025
|
+
| `Promise<CommentModeration>` | A `CommentModeration` instance |
|
|
1026
|
+
|
|
1027
|
+
#### Example
|
|
1028
|
+
|
|
1029
|
+
```js
|
|
1030
|
+
const commentModeration = await pkc.createCommentModeration(createCommentModerationOptions)
|
|
1031
|
+
commentModeration.on('challenge', async (challengeMessage, _commentModeration) => {
|
|
1032
|
+
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
1033
|
+
_commentModeration.publishChallengeAnswers(challengeAnswers)
|
|
1034
|
+
})
|
|
1035
|
+
commentModeration.on('challengeverification', console.log)
|
|
1036
|
+
await commentModeration.publish()
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
### `pkc.createVote(createVoteOptions)`
|
|
1040
|
+
|
|
1041
|
+
> Create a `Vote` instance. `Vote` inherits from `Publication`, like `Comment`, so has the same API.
|
|
1042
|
+
|
|
1043
|
+
#### Parameters
|
|
1044
|
+
|
|
1045
|
+
| Name | Type | Description |
|
|
1046
|
+
| ---- | ---- | ----------- |
|
|
1047
|
+
| createVoteOptions | `CreateVoteOptions` | The vote to create |
|
|
1048
|
+
|
|
1049
|
+
##### CreateVoteOptions
|
|
1050
|
+
|
|
1051
|
+
An object which may have the following keys:
|
|
1052
|
+
|
|
1053
|
+
| Name | Type | Description |
|
|
1054
|
+
| ---- | ---- | ----------- |
|
|
1055
|
+
| communityAddress | `string` | `Address` of the community |
|
|
1056
|
+
| commentCid | `string` | The comment or post to vote on |
|
|
1057
|
+
| timestamp | `number` or `undefined` | Time of publishing in ms, `Math.round(Date.now() / 1000)` if undefined |
|
|
1058
|
+
| author | `Author` | Author of the comment, will be needed for voting with NFTs or tokens |
|
|
1059
|
+
| vote | `1` or `0` or `-1` | 0 is for resetting a vote |
|
|
1060
|
+
| signer | `Signer` | Signer of the vote |
|
|
1061
|
+
| challengeRequest | `ChallengeRequest` or `undefined` | Optional properties to pass to `ChallengeRequestPubsubMessage` |
|
|
1062
|
+
|
|
1063
|
+
##### ChallengeRequest
|
|
1064
|
+
|
|
1065
|
+
An object which may have the following keys:
|
|
1066
|
+
|
|
1067
|
+
| Name | Type | Description |
|
|
1068
|
+
| ---- | ---- | ----------- |
|
|
1069
|
+
| challengeAnswers | `string[]` or `undefined` | Optional pre-answers to community.challenges |
|
|
1070
|
+
| challengeCommentCids | `string[]` or `undefined` | Optional comment cids for community.challenges related to author karma/age in other communities |
|
|
1071
|
+
|
|
1072
|
+
#### Returns
|
|
1073
|
+
|
|
1074
|
+
| Type | Description |
|
|
1075
|
+
| -------- | -------- |
|
|
1076
|
+
| `Promise<Vote>` | A `Vote` instance |
|
|
1077
|
+
|
|
1078
|
+
#### Example
|
|
1079
|
+
|
|
1080
|
+
```js
|
|
1081
|
+
const vote = await pkc.createVote(createVoteOptions)
|
|
1082
|
+
vote.on('challenge', async (challengeMessage, _vote) => {
|
|
1083
|
+
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
1084
|
+
_vote.publishChallengeAnswers(challengeAnswers)
|
|
1085
|
+
})
|
|
1086
|
+
vote.on('challengeverification', console.log)
|
|
1087
|
+
await vote.publish()
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
### `pkc.createSigner(createSignerOptions)`
|
|
1091
|
+
|
|
1092
|
+
> Create a `Signer` instance to be used in `CreateCommentOptions`.
|
|
1093
|
+
|
|
1094
|
+
#### Parameters
|
|
1095
|
+
|
|
1096
|
+
| Name | Type | Description |
|
|
1097
|
+
| ---- | ---- | ----------- |
|
|
1098
|
+
| createSignerOptions | `CreateSignerOptions` or `undefined` | The options of the signer |
|
|
1099
|
+
|
|
1100
|
+
##### CreateSignerOptions
|
|
1101
|
+
|
|
1102
|
+
An object which may have the following keys:
|
|
1103
|
+
|
|
1104
|
+
| Name | Type | Description |
|
|
1105
|
+
| ---- | ---- | ----------- |
|
|
1106
|
+
| privateKey | `string` or `undefined` | If undefined, generate a random `privateKey` |
|
|
1107
|
+
| type | `string` | Required if `privateKey` defined, only `'ed25519'` for now |
|
|
1108
|
+
|
|
1109
|
+
#### Returns
|
|
1110
|
+
|
|
1111
|
+
| Type | Description |
|
|
1112
|
+
| -------- | -------- |
|
|
1113
|
+
| `Promise<Signer>` | A `Signer` instance |
|
|
1114
|
+
|
|
1115
|
+
#### Example
|
|
1116
|
+
|
|
1117
|
+
```js
|
|
1118
|
+
const newRandomSigner = await pkc.createSigner()
|
|
1119
|
+
const signerFromPrivateKey = await pkc.createSigner({privateKey: 'AbCd...', type: 'ed25519'})
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
### `pkc.listCommunities()`
|
|
1123
|
+
|
|
1124
|
+
> (Only for Node or over RPC) Get all the community addresses in the `${pkc.dataPath}/communities` folder. Same as doing `ls ${pkc.dataPath}/communities`.
|
|
1125
|
+
|
|
1126
|
+
#### Returns
|
|
1127
|
+
|
|
1128
|
+
| Type | Description |
|
|
1129
|
+
| -------- | -------- |
|
|
1130
|
+
| `Promise<Address[]>` | An array of `Address` strings |
|
|
1131
|
+
|
|
1132
|
+
#### Example
|
|
1133
|
+
|
|
1134
|
+
```js
|
|
1135
|
+
// start all the communities you own and have stored locally
|
|
1136
|
+
const communityAddresses = await pkc.listCommunities()
|
|
1137
|
+
for (const address of communityAddresses) {
|
|
1138
|
+
const community = await pkc.createCommunity({address})
|
|
1139
|
+
await community.start()
|
|
1140
|
+
}
|
|
1141
|
+
```
|
|
1142
|
+
|
|
1143
|
+
### `pkc.getDefaults()`
|
|
1144
|
+
|
|
1145
|
+
> Get the default global PKC settings, e.g. the default multisubs like p/all, p/dao, etc.
|
|
1146
|
+
|
|
1147
|
+
#### Returns
|
|
1148
|
+
|
|
1149
|
+
| Type | Description |
|
|
1150
|
+
| -------- | -------- |
|
|
1151
|
+
| `Promise<PKCDefaults>` | A `PKCDefaults` instance. |
|
|
1152
|
+
|
|
1153
|
+
#### Example
|
|
1154
|
+
|
|
1155
|
+
```js
|
|
1156
|
+
const pkcDefaults = await pkc.getDefaults()
|
|
1157
|
+
const allMultisub = await pkc.getMultisub(pkcDefaults.multisubAddresses.all)
|
|
1158
|
+
const allCommunityAddresses = allMultisub.map(community => community.address)
|
|
1159
|
+
console.log(allCommunityAddresses)
|
|
1160
|
+
```
|
|
1161
|
+
|
|
1162
|
+
## PKC Events
|
|
1163
|
+
The PKC events.
|
|
1164
|
+
|
|
1165
|
+
### `communitieschange`
|
|
1166
|
+
|
|
1167
|
+
> `PKC.communities` property changed.
|
|
1168
|
+
|
|
1169
|
+
#### Emits
|
|
1170
|
+
|
|
1171
|
+
| Type | Description |
|
|
1172
|
+
| -------- | -------- |
|
|
1173
|
+
| `string[]` | The `PKC.communities` property |
|
|
1174
|
+
|
|
1175
|
+
## Community API
|
|
1176
|
+
The community API for getting community updates, or creating, editing, running a community as an owner.
|
|
1177
|
+
|
|
1178
|
+
### `community.edit(communityEditOptions)`
|
|
1179
|
+
|
|
1180
|
+
> Edit the content/information of a community in your local database. Only usable if the community database corresponding to `community.address` exists locally (ie. you are the community owner).
|
|
1181
|
+
|
|
1182
|
+
#### Parameters
|
|
1183
|
+
|
|
1184
|
+
| Name | Type | Description |
|
|
1185
|
+
| ---- | ---- | ----------- |
|
|
1186
|
+
| community | `CommunityEditOptions` | The content/information of the community |
|
|
1187
|
+
|
|
1188
|
+
##### CommunityEditOptions
|
|
1189
|
+
|
|
1190
|
+
An object which may have the following keys:
|
|
1191
|
+
|
|
1192
|
+
| Name | Type | Description |
|
|
1193
|
+
| ---- | ---- | ----------- |
|
|
1194
|
+
| address | `string` or `undefined` | Address of the community, used to add a crypto domain |
|
|
1195
|
+
| signer | `Signer` or `undefined` | Signer of the community, useful to change the private if the owner gets hacked, but still has his crypto domain
|
|
1196
|
+
| title | `string` or `undefined` | Title of the community |
|
|
1197
|
+
| description | `string` or `undefined` | Description of the community |
|
|
1198
|
+
| roles | `{[authorAddress: string]: CommunityRole}` or `undefined` | Author addresses of the moderators |
|
|
1199
|
+
| lastPostCid | `string` or `undefined` | The most recent post in the linked list of posts |
|
|
1200
|
+
| posts | `Pages` or `undefined` | Only preload page 1 sorted by 'hot', might preload more later, should include some child comments and vote counts for each post |
|
|
1201
|
+
| pubsubTopic | `string` or `undefined` | The string to publish to in the pubsub, a public key of the community owner's choice |
|
|
1202
|
+
| features | `CommunityFeatures` or `undefined` | The features of the community |
|
|
1203
|
+
| suggested | `CommunitySuggested` or `undefined` | The suggested client settings for the community |
|
|
1204
|
+
| flairs | `{[key: 'post' or 'author']: Flair[]}` or `undefined` | The list of flairs (colored labels for comments or authors) authors or mods can choose from |
|
|
1205
|
+
| settings | `CommunitySettings` or `undefined` | The private community.settings property of the community, not shared in the community IPNS |
|
|
1206
|
+
|
|
1207
|
+
##### CommunitySettings
|
|
1208
|
+
|
|
1209
|
+
An object which may have the following keys:
|
|
1210
|
+
|
|
1211
|
+
| Name | Type | Description |
|
|
1212
|
+
| ---- | ---- | ----------- |
|
|
1213
|
+
| fetchThumbnailUrls | `boolean` or `undefined` | Fetch the thumbnail URLs of comments `comment.link` property, could reveal the IP address of the community node |
|
|
1214
|
+
| fetchThumbnailUrlsProxyUrl | `string` or `undefined` | The HTTP proxy URL used to fetch thumbnail URLs |
|
|
1215
|
+
|
|
1216
|
+
#### Example
|
|
1217
|
+
|
|
1218
|
+
```js
|
|
1219
|
+
// TODO
|
|
1220
|
+
```
|
|
1221
|
+
|
|
1222
|
+
### `community.start()`
|
|
1223
|
+
|
|
1224
|
+
> Start listening for new posts on the pubsub, and publishing them every 5 minutes. Only usable if the community database corresponding to `community.address` exists locally (ie. you are the community owner).
|
|
1225
|
+
|
|
1226
|
+
#### Example
|
|
1227
|
+
|
|
1228
|
+
```js
|
|
1229
|
+
const options = {
|
|
1230
|
+
title: 'Your community title'
|
|
1231
|
+
}
|
|
1232
|
+
const community = await pkc.createCommunity(options)
|
|
1233
|
+
// edit the community info in the database
|
|
1234
|
+
await community.edit({
|
|
1235
|
+
title: 'Memes',
|
|
1236
|
+
description: 'Post your memes here.',
|
|
1237
|
+
pubsubTopic: '12D3KooW...'
|
|
1238
|
+
})
|
|
1239
|
+
// start publishing updates/new posts
|
|
1240
|
+
await community.start()
|
|
1241
|
+
```
|
|
1242
|
+
|
|
1243
|
+
### `community.stop()`
|
|
1244
|
+
|
|
1245
|
+
> Stop polling the network for new community updates started by community.update(). Also stop listening for new posts on the pubsub started by community.start(), and stop publishing them every 5 minutes.
|
|
1246
|
+
|
|
1247
|
+
### `community.update()`
|
|
1248
|
+
|
|
1249
|
+
> Start polling the network for new posts published in the community, update itself and emit the 'update' event. Only usable if community.address exists.
|
|
1250
|
+
|
|
1251
|
+
#### Example
|
|
1252
|
+
|
|
1253
|
+
```js
|
|
1254
|
+
const options = {
|
|
1255
|
+
address: '12D3KooW...'
|
|
1256
|
+
}
|
|
1257
|
+
const community = await pkc.createCommunity(options)
|
|
1258
|
+
community.on('update', (updatedCommunityInstance) => {
|
|
1259
|
+
console.log(updatedCommunityInstance)
|
|
1260
|
+
|
|
1261
|
+
// if you want to stop polling for new updates after only the first one
|
|
1262
|
+
community.stop()
|
|
1263
|
+
})
|
|
1264
|
+
community.update()
|
|
1265
|
+
```
|
|
1266
|
+
|
|
1267
|
+
## Community Events
|
|
1268
|
+
The community events.
|
|
1269
|
+
|
|
1270
|
+
### `update`
|
|
1271
|
+
|
|
1272
|
+
> The community's IPNS record has been updated, which means new posts may have been published.
|
|
1273
|
+
|
|
1274
|
+
#### Emits
|
|
1275
|
+
|
|
1276
|
+
| Type | Description |
|
|
1277
|
+
| -------- | -------- |
|
|
1278
|
+
| `Community` | The updated `Community` instance (the instance emits itself), i.e. `this` |
|
|
1279
|
+
|
|
1280
|
+
#### Example
|
|
1281
|
+
|
|
1282
|
+
```js
|
|
1283
|
+
const options = {
|
|
1284
|
+
address: '12D3KooW...'
|
|
1285
|
+
}
|
|
1286
|
+
const community = await pkc.createCommunity(options)
|
|
1287
|
+
community.on('update', (updatedCommunity) => console.log(updatedCommunity))
|
|
1288
|
+
community.update()
|
|
1289
|
+
|
|
1290
|
+
// stop updating in 10 minutes
|
|
1291
|
+
setTimeout(() => community.stop(), 60000)
|
|
1292
|
+
```
|
|
1293
|
+
|
|
1294
|
+
### `challengerequest`
|
|
1295
|
+
|
|
1296
|
+
> When the user publishes a comment, he makes a `'challengerequest'` to the pubsub, the community owner will send back a `challenge`, eg. a captcha that the user must complete.
|
|
1297
|
+
|
|
1298
|
+
#### Emits
|
|
1299
|
+
|
|
1300
|
+
| Type | Description |
|
|
1301
|
+
| -------- | -------- |
|
|
1302
|
+
| `ChallengeRequestMessage` | The comment of the user and the challenge request |
|
|
1303
|
+
|
|
1304
|
+
Object is of the form:
|
|
1305
|
+
|
|
1306
|
+
```js
|
|
1307
|
+
{ // ...TODO }
|
|
1308
|
+
```
|
|
1309
|
+
|
|
1310
|
+
#### Example
|
|
1311
|
+
|
|
1312
|
+
```js
|
|
1313
|
+
{ // ...TODO }
|
|
1314
|
+
```
|
|
1315
|
+
|
|
1316
|
+
### `challengeanswer`
|
|
1317
|
+
|
|
1318
|
+
> After receiving a `Challenge`, the user owner will send back a `challengeanswer`.
|
|
1319
|
+
|
|
1320
|
+
#### Emits
|
|
1321
|
+
|
|
1322
|
+
| Type | Description |
|
|
1323
|
+
| -------- | -------- |
|
|
1324
|
+
| `ChallengeAnswerMessage` | The challenge answer |
|
|
1325
|
+
|
|
1326
|
+
Object is of the form:
|
|
1327
|
+
|
|
1328
|
+
```js
|
|
1329
|
+
{ // ...TODO }
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
### `challengerequest`
|
|
1333
|
+
|
|
1334
|
+
> When the user publishes a comment, he makes a `'challengerequest'` to the pubsub, the community owner will send back a `challenge`, eg. a captcha that the user must complete.
|
|
1335
|
+
|
|
1336
|
+
#### Emits
|
|
1337
|
+
|
|
1338
|
+
| Type | Description |
|
|
1339
|
+
| -------- | -------- |
|
|
1340
|
+
| `ChallengeRequestMessage` | The comment of the user and the challenge request |
|
|
1341
|
+
|
|
1342
|
+
Object is of the form:
|
|
1343
|
+
|
|
1344
|
+
```js
|
|
1345
|
+
{ // ...TODO }
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1348
|
+
#### Example
|
|
1349
|
+
|
|
1350
|
+
```js
|
|
1351
|
+
{ // ...TODO }
|
|
1352
|
+
```
|
|
1353
|
+
|
|
1354
|
+
### `statechange`
|
|
1355
|
+
|
|
1356
|
+
> `Community.state` property changed.
|
|
1357
|
+
|
|
1358
|
+
#### Emits
|
|
1359
|
+
|
|
1360
|
+
| Type | Description |
|
|
1361
|
+
| -------- | -------- |
|
|
1362
|
+
| `'stopped' \| 'updating' \| 'started'` | The `Community.state` property |
|
|
1363
|
+
|
|
1364
|
+
### `updatingstatechange`
|
|
1365
|
+
|
|
1366
|
+
> `Community.updatingState` property changed.
|
|
1367
|
+
|
|
1368
|
+
#### Emits
|
|
1369
|
+
|
|
1370
|
+
| Type | Description |
|
|
1371
|
+
| -------- | -------- |
|
|
1372
|
+
| `'stopped' \| 'resolving-address' \| 'fetching-ipns' \| 'fetching-ipfs' \| 'failed' \| 'succeeded'` | The `Community.updatingState` property |
|
|
1373
|
+
|
|
1374
|
+
### `startedstatechange`
|
|
1375
|
+
|
|
1376
|
+
> `Community.startedState` property changed.
|
|
1377
|
+
|
|
1378
|
+
#### Emits
|
|
1379
|
+
|
|
1380
|
+
| Type | Description |
|
|
1381
|
+
| -------- | -------- |
|
|
1382
|
+
| `'stopped' \| 'fetching-ipns' \| 'publishing-ipns' \| 'failed' \| 'succeeded'` | The `Community.startedState` property |
|
|
1383
|
+
|
|
1384
|
+
## Comment API
|
|
1385
|
+
The comment API for publishing a comment as an author, or getting comment updates. `Comment`, `Vote` and `CommentEdit` inherit `Publication` class and all have a similar API. A `Comment` updates itselfs on update events after `Comment.update()` is called if `Comment.cid` exists.
|
|
1386
|
+
|
|
1387
|
+
### `comment.publish()`
|
|
1388
|
+
|
|
1389
|
+
> Publish the comment to the pubsub. You must then wait for the `'challenge'` event and answer with a `ChallengeAnswer`.
|
|
1390
|
+
|
|
1391
|
+
#### Example
|
|
1392
|
+
|
|
1393
|
+
```js
|
|
1394
|
+
const comment = await pkc.createComment(commentObject)
|
|
1395
|
+
comment.on('challenge', async (challengeMessage) => {
|
|
1396
|
+
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
1397
|
+
comment.publishChallengeAnswers(challengeAnswers)
|
|
1398
|
+
})
|
|
1399
|
+
comment.on('challengeverification', console.log)
|
|
1400
|
+
await comment.publish()
|
|
1401
|
+
```
|
|
1402
|
+
|
|
1403
|
+
### `comment.publishChallengeAnswers(challengeAnswers)`
|
|
1404
|
+
|
|
1405
|
+
> Publish your answers to the challenges e.g. the captcha answers.
|
|
1406
|
+
|
|
1407
|
+
#### Parameters
|
|
1408
|
+
|
|
1409
|
+
| Name | Type | Description |
|
|
1410
|
+
| ---- | ---- | ----------- |
|
|
1411
|
+
| challengeAnswers | `string[]` | The challenge answers |
|
|
1412
|
+
|
|
1413
|
+
#### Example
|
|
1414
|
+
|
|
1415
|
+
```js
|
|
1416
|
+
const comment = await pkc.createComment(commentObject)
|
|
1417
|
+
comment.on('challenge', async (challengeMessage) => {
|
|
1418
|
+
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
1419
|
+
comment.publishChallengeAnswers(challengeAnswers)
|
|
1420
|
+
})
|
|
1421
|
+
comment.on('challengeverification', console.log)
|
|
1422
|
+
await comment.publish()
|
|
1423
|
+
```
|
|
1424
|
+
|
|
1425
|
+
### `comment.update()`
|
|
1426
|
+
|
|
1427
|
+
> Start polling the network for comment updates (replies, upvotes, edits, etc), update itself and emit the update event. Only usable if comment.cid or exists.
|
|
1428
|
+
|
|
1429
|
+
#### Example
|
|
1430
|
+
|
|
1431
|
+
```js
|
|
1432
|
+
const commentCid = 'Qm...'
|
|
1433
|
+
const comment = await pkc.getComment({cid: commentCid})
|
|
1434
|
+
comment.on('update', (updatedCommentInstance) => {
|
|
1435
|
+
console.log(updatedCommentInstance)
|
|
1436
|
+
|
|
1437
|
+
// if you want to stop polling for new updates after only the first one
|
|
1438
|
+
comment.stop()
|
|
1439
|
+
})
|
|
1440
|
+
comment.update()
|
|
1441
|
+
|
|
1442
|
+
// if you already fetched the comment and only want the updates
|
|
1443
|
+
const commentDataFetchedEarlier = {content, author, cid, ...comment}
|
|
1444
|
+
const comment = await pkc.createComment(commentDataFetchedEarlier)
|
|
1445
|
+
comment.on('update', () => {
|
|
1446
|
+
console.log('the comment instance updated itself:', comment)
|
|
1447
|
+
})
|
|
1448
|
+
comment.update()
|
|
1449
|
+
```
|
|
1450
|
+
|
|
1451
|
+
### `comment.stop()`
|
|
1452
|
+
|
|
1453
|
+
> Stop polling the network for new comment updates started by comment.update().
|
|
1454
|
+
|
|
1455
|
+
## Comment Events
|
|
1456
|
+
The comment events.
|
|
1457
|
+
|
|
1458
|
+
### `update`
|
|
1459
|
+
|
|
1460
|
+
> The comment has been updated, which means vote counts and replies may have changed. To start polling the network for updates, call `Comment.update()`. If the previous `CommentUpdate` is the same, do not emit `update`.
|
|
1461
|
+
|
|
1462
|
+
#### Emits
|
|
1463
|
+
|
|
1464
|
+
| Type | Description |
|
|
1465
|
+
| -------- | -------- |
|
|
1466
|
+
| `Comment` | The updated `Comment`, i.e. itself, `this` |
|
|
1467
|
+
|
|
1468
|
+
Object is of the form:
|
|
1469
|
+
|
|
1470
|
+
```js
|
|
1471
|
+
{ // ...TODO }
|
|
1472
|
+
```
|
|
1473
|
+
|
|
1474
|
+
#### Example
|
|
1475
|
+
|
|
1476
|
+
```js
|
|
1477
|
+
const comment = await pkc.getComment({cid: commentCid})
|
|
1478
|
+
comment.on('update', (updatedComment) => {
|
|
1479
|
+
console.log(updatedComment)
|
|
1480
|
+
})
|
|
1481
|
+
comment.update()
|
|
1482
|
+
|
|
1483
|
+
// stop looking for updates after 10 minutes
|
|
1484
|
+
setTimeout(() => comment.stop(), 60000)
|
|
1485
|
+
```
|
|
1486
|
+
|
|
1487
|
+
### `challenge`
|
|
1488
|
+
|
|
1489
|
+
> After publishing a comment, the community owner will send back a `challenge`, eg. a captcha that the user must complete.
|
|
1490
|
+
|
|
1491
|
+
#### Emits
|
|
1492
|
+
|
|
1493
|
+
| Type | Description |
|
|
1494
|
+
| -------- | -------- |
|
|
1495
|
+
| `ChallengeMessage` | The challenge the user must complete |
|
|
1496
|
+
| `Comment` | The `Comment` instance, i.e. `this` |
|
|
1497
|
+
|
|
1498
|
+
Object is of the form:
|
|
1499
|
+
|
|
1500
|
+
```js
|
|
1501
|
+
{ // ...TODO }
|
|
1502
|
+
```
|
|
1503
|
+
|
|
1504
|
+
#### Example
|
|
1505
|
+
|
|
1506
|
+
```js
|
|
1507
|
+
const comment = await pkc.createComment(commentObject)
|
|
1508
|
+
comment.on('challenge', async (challengeMessage, _comment) => {
|
|
1509
|
+
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
1510
|
+
_comment.publishChallengeAnswers(challengeAnswers)
|
|
1511
|
+
})
|
|
1512
|
+
comment.on('challengeverification', console.log)
|
|
1513
|
+
await comment.publish()
|
|
1514
|
+
```
|
|
1515
|
+
|
|
1516
|
+
### `challengeverification`
|
|
1517
|
+
|
|
1518
|
+
> After publishing a challenge answer, the community owner will send back a `challengeverification` to let the network know if the challenge was completed successfully.
|
|
1519
|
+
|
|
1520
|
+
#### Emits
|
|
1521
|
+
|
|
1522
|
+
| Type | Description |
|
|
1523
|
+
| -------- | -------- |
|
|
1524
|
+
| `ChallengeVerificationMessage` | The challenge verification result |
|
|
1525
|
+
| `Comment` | The `Comment` instance, i.e. `this` |
|
|
1526
|
+
|
|
1527
|
+
Object is of the form:
|
|
1528
|
+
|
|
1529
|
+
```js
|
|
1530
|
+
{ // ...TODO }
|
|
1531
|
+
```
|
|
1532
|
+
|
|
1533
|
+
#### Example
|
|
1534
|
+
|
|
1535
|
+
```js
|
|
1536
|
+
const comment = await pkc.createComment(commentObject)
|
|
1537
|
+
comment.on('challenge', async (challengeMessage) => {
|
|
1538
|
+
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
1539
|
+
comment.publishChallengeAnswers(challengeAnswers)
|
|
1540
|
+
})
|
|
1541
|
+
comment.on('challengeverification', (challengeVerification) => console.log('published post cid is', challengeVerification?.publication?.cid))
|
|
1542
|
+
await comment.publish()
|
|
1543
|
+
```
|
|
1544
|
+
|
|
1545
|
+
### `statechange`
|
|
1546
|
+
|
|
1547
|
+
> `Comment.state` property changed.
|
|
1548
|
+
|
|
1549
|
+
#### Emits
|
|
1550
|
+
|
|
1551
|
+
| Type | Description |
|
|
1552
|
+
| -------- | -------- |
|
|
1553
|
+
| `'stopped' \| 'updating' \| 'publishing'` | The `Comment.state` property |
|
|
1554
|
+
|
|
1555
|
+
### `updatingstatechange`
|
|
1556
|
+
|
|
1557
|
+
> `Comment.updatingState` property changed.
|
|
1558
|
+
|
|
1559
|
+
#### Emits
|
|
1560
|
+
|
|
1561
|
+
| Type | Description |
|
|
1562
|
+
| -------- | -------- |
|
|
1563
|
+
| `'stopped' \| 'resolving-author-address' \| 'fetching-ipfs' \| 'fetching-update-ipns' \| 'fetching-update-ipfs' \| 'failed' \| 'succeeded'` | The `Comment.updatingState` property |
|
|
1564
|
+
|
|
1565
|
+
### `publishingstatechange`
|
|
1566
|
+
|
|
1567
|
+
> `Comment.publishingState` property changed.
|
|
1568
|
+
|
|
1569
|
+
#### Emits
|
|
1570
|
+
|
|
1571
|
+
| Type | Description |
|
|
1572
|
+
| -------- | -------- |
|
|
1573
|
+
| `'stopped' \| 'resolving-community-address' \| 'fetching-community-ipns' \| 'fetching-community-ipfs' \| 'publishing-challenge-request' \| 'waiting-challenge' \| 'waiting-challenge-answers' \| 'publishing-challenge-answer' \| 'waiting-challenge-verification' \| 'failed' \| 'succeeded'` | The `Comment.publishingState` property |
|
|
1574
|
+
|
|
1575
|
+
## Pages API
|
|
1576
|
+
The pages API for scrolling pages of a community or replies to a post/comment. `Community.posts` and `Comment.replies` are `Pages` instances. `Community.posts.pages.hot` is a `Page` instance.
|
|
1577
|
+
|
|
1578
|
+
### `pages.getPage({cid})`
|
|
1579
|
+
|
|
1580
|
+
> Get a `Page` instance using an IPFS CID from `Pages.pageCids[sortType]`, e.g. `Community.posts.pageCids.hot` or `Comment.replies.pageCids.topAll`.
|
|
1581
|
+
|
|
1582
|
+
#### Parameters
|
|
1583
|
+
|
|
1584
|
+
| Name | Type | Description |
|
|
1585
|
+
| ---- | ---- | ----------- |
|
|
1586
|
+
| cid | `string` | The IPFS CID of the page |
|
|
1587
|
+
|
|
1588
|
+
#### Returns
|
|
1589
|
+
|
|
1590
|
+
| Type | Description |
|
|
1591
|
+
| -------- | -------- |
|
|
1592
|
+
| `Promise<Page>` | A `Page` instance |
|
|
1593
|
+
|
|
1594
|
+
#### Example
|
|
1595
|
+
|
|
1596
|
+
```js
|
|
1597
|
+
// get sorted posts in a community
|
|
1598
|
+
const community = await pkc.getCommunity({address: communityAddress})
|
|
1599
|
+
const pageSortedByTopYear = await community.posts.getPage({cid: community.posts.pageCids.topYear})
|
|
1600
|
+
const postsSortedByTopYear = pageSortedByTopYear.comments
|
|
1601
|
+
console.log(postsSortedByTopYear)
|
|
1602
|
+
|
|
1603
|
+
// get sorted replies to a post or comment
|
|
1604
|
+
const post = await pkc.getComment({cid: commentCid})
|
|
1605
|
+
post.on('update', async updatedPost => {
|
|
1606
|
+
let replies
|
|
1607
|
+
// try to get sorted replies by sort type 'new'
|
|
1608
|
+
// sorted replies pages are not always available, for example if the post only has a few replies
|
|
1609
|
+
if (updatedPost.replies?.pageCids?.new) {
|
|
1610
|
+
const repliesPageSortedByNew = await updatedPost.replies.getPage({cid: updatedPost.replies.pageCids.new})
|
|
1611
|
+
replies = repliesPageSortedByNew.comments
|
|
1612
|
+
}
|
|
1613
|
+
else {
|
|
1614
|
+
// the 'topAll' sort type is always preloaded by default on replies and can be used as fallback
|
|
1615
|
+
// on community.posts only 'hot' is preloaded by default
|
|
1616
|
+
replies = updatedPost.replies.pages.topAll.comments
|
|
1617
|
+
}
|
|
1618
|
+
console.log(replies)
|
|
1619
|
+
})
|
|
1620
|
+
```
|
|
1621
|
+
|
|
1622
|
+
## Client Events
|
|
1623
|
+
The client events.
|
|
1624
|
+
|
|
1625
|
+
### `statechange`
|
|
1626
|
+
|
|
1627
|
+
> `Client.state` property changed.
|
|
1628
|
+
|
|
1629
|
+
#### Emits
|
|
1630
|
+
|
|
1631
|
+
| Type | Description |
|
|
1632
|
+
| -------- | -------- |
|
|
1633
|
+
| `'stopped' \| 'resolving-author-address' \| 'fetching-ipfs' \| 'fetching-update-ipns' \| 'fetching-update-ipfs' \| 'resolving-community-address' \| 'fetching-community-ipns' \| 'fetching-community-ipfs' \| 'subscribing-pubsub' \| 'publishing-challenge-request' \| 'waiting-challenge' \| 'waiting-challenge-answers' \| 'publishing-challenge-answer' \| 'waiting-challenge-verification' \| 'connecting' \| 'connected'` | The `Client.state` property |
|
|
1634
|
+
|
|
1635
|
+
#### Example
|
|
1636
|
+
|
|
1637
|
+
```js
|
|
1638
|
+
const onStateChange = (state) => console.log('client state changed:', state)
|
|
1639
|
+
for (const clientUrl in clients?.ipfsGateways) {
|
|
1640
|
+
comment.clients?.ipfsGateways?.[clientUrl].on('statechange', onStateChange)
|
|
1641
|
+
}
|
|
1642
|
+
for (const clientUrl in clients?.ipfsClients) {
|
|
1643
|
+
comment.clients?.ipfsClients?.[clientUrl].on('statechange', onStateChange)
|
|
1644
|
+
}
|
|
1645
|
+
for (const clientUrl in clients?.pubsubClients) {
|
|
1646
|
+
comment.clients?.pubsubClients?.[clientUrl].on('statechange', onStateChange)
|
|
1647
|
+
}
|
|
1648
|
+
for (const chainTicker in clients?.chainProviders) {
|
|
1649
|
+
for (const clientUrl in clients?.chainProviders?.[chainTicker]) {
|
|
1650
|
+
comment.clients?.chainProviders?.[chainTicker]?.[clientUrl].on('statechange', onStateChange)
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
```
|
|
1654
|
+
|
|
1655
|
+
### `settingschange`
|
|
1656
|
+
|
|
1657
|
+
> `Client.settings` property changed.
|
|
1658
|
+
|
|
1659
|
+
#### Emits
|
|
1660
|
+
|
|
1661
|
+
| Type | Description |
|
|
1662
|
+
| -------- | -------- |
|
|
1663
|
+
| `PKCRpcSettings` | The `Client.settings` property |
|