@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
|
@@ -0,0 +1,908 @@
|
|
|
1
|
+
import * as remeda from "remeda";
|
|
2
|
+
import { parseCommentIpfsSchemaWithPKCErrorIfItFails, parseCommentUpdateSchemaWithPKCErrorIfItFails, parseJsonWithPKCErrorIfFails } from "../../schema/schema-util.js";
|
|
3
|
+
import { FailedToFetchCommentUpdateFromGatewaysError, PKCError } from "../../pkc-error.js";
|
|
4
|
+
import { verifyCommentIpfs, verifyCommentUpdate } from "../../signer/signatures.js";
|
|
5
|
+
import Logger from "../../logger.js";
|
|
6
|
+
import { getPostUpdateTimestampRange, hideClassPrivateProps, isAbortError, resolveWhenPredicateIsTrue } from "../../util.js";
|
|
7
|
+
import { PublicationClientsManager } from "../publication-client-manager.js";
|
|
8
|
+
import { findCommentInPageInstance, findCommentInPageInstanceRecursively, findCommentInParsedPages } from "../../pages/util.js";
|
|
9
|
+
import { CommentKuboRpcClient, CommentLibp2pJsClient, CommentPKCRpcStateClient } from "./comment-clients.js";
|
|
10
|
+
import { InflightResourceTypes } from "../../util/inflight-fetch-manager.js";
|
|
11
|
+
import { loadAllPagesUnderCommunityToFindComment } from "./comment-util.js";
|
|
12
|
+
import { findStartedCommunity, findUpdatingComment, findUpdatingCommunity } from "../../pkc/tracked-instance-registry-util.js";
|
|
13
|
+
const fetchCommentLogger = Logger("pkc-js:comment:client-manager:fetchAndVerifyCommentCid");
|
|
14
|
+
export const MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE = 1024 * 1024;
|
|
15
|
+
export class CommentClientsManager extends PublicationClientsManager {
|
|
16
|
+
constructor(comment) {
|
|
17
|
+
super(comment);
|
|
18
|
+
this._postForUpdating = undefined;
|
|
19
|
+
this._comment = comment;
|
|
20
|
+
this._fetchingUpdateForReplyUsingPageCidsPromise = undefined;
|
|
21
|
+
this._parentFirstPageCidsAlreadyLoaded = new Set();
|
|
22
|
+
hideClassPrivateProps(this);
|
|
23
|
+
}
|
|
24
|
+
_initKuboRpcClients() {
|
|
25
|
+
if (this._pkc.clients.kuboRpcClients)
|
|
26
|
+
for (const ipfsUrl of remeda.keys.strict(this._pkc.clients.kuboRpcClients))
|
|
27
|
+
this.clients.kuboRpcClients = { ...this.clients.kuboRpcClients, [ipfsUrl]: new CommentKuboRpcClient("stopped") };
|
|
28
|
+
}
|
|
29
|
+
_initLibp2pJsClients() {
|
|
30
|
+
for (const libp2pJsClientKey of remeda.keys.strict(this._pkc.clients.libp2pJsClients))
|
|
31
|
+
this.clients.libp2pJsClients = { ...this.clients.libp2pJsClients, [libp2pJsClientKey]: new CommentLibp2pJsClient("stopped") };
|
|
32
|
+
}
|
|
33
|
+
_initPKCRpcClients() {
|
|
34
|
+
for (const rpcUrl of remeda.keys.strict(this._pkc.clients.pkcRpcClients))
|
|
35
|
+
this.clients.pkcRpcClients = { ...this.clients.pkcRpcClients, [rpcUrl]: new CommentPKCRpcStateClient("stopped") };
|
|
36
|
+
}
|
|
37
|
+
updateLibp2pJsClientState(newState, libp2pJsClientKey) {
|
|
38
|
+
super.updateLibp2pJsClientState(newState, libp2pJsClientKey);
|
|
39
|
+
}
|
|
40
|
+
updateKuboRpcState(newState, kuboRpcClientUrl) {
|
|
41
|
+
super.updateKuboRpcState(newState, kuboRpcClientUrl);
|
|
42
|
+
}
|
|
43
|
+
updateGatewayState(newState, ipfsGatewayClientUrl) {
|
|
44
|
+
super.updateGatewayState(newState, ipfsGatewayClientUrl);
|
|
45
|
+
}
|
|
46
|
+
updateKuboRpcPubsubState(newState, pubsubKuboRpcClientUrl) {
|
|
47
|
+
super.updateKuboRpcPubsubState(newState, pubsubKuboRpcClientUrl);
|
|
48
|
+
}
|
|
49
|
+
// Resolver methods here
|
|
50
|
+
preResolveNameResolver(opts) {
|
|
51
|
+
super.preResolveNameResolver(opts);
|
|
52
|
+
if (this._comment.state === "updating")
|
|
53
|
+
this._comment._setUpdatingStateWithEmissionIfNewState("resolving-author-name"); // Resolving for CommentIpfs and author.address is a domain
|
|
54
|
+
}
|
|
55
|
+
_calculatePathForPostCommentUpdate(folderCid, postCid) {
|
|
56
|
+
return `${folderCid}/` + postCid + "/update";
|
|
57
|
+
}
|
|
58
|
+
_updateKuboRpcClientOrHeliaState(newState, kuboRpcOrHelia) {
|
|
59
|
+
if ("_helia" in kuboRpcOrHelia)
|
|
60
|
+
this.updateLibp2pJsClientState(newState, kuboRpcOrHelia._libp2pJsClientsOptions.key);
|
|
61
|
+
else
|
|
62
|
+
this.updateKuboRpcState(newState, kuboRpcOrHelia.url);
|
|
63
|
+
}
|
|
64
|
+
async _fetchPostCommentUpdateIpfsP2P(subIpns, timestampRanges, log) {
|
|
65
|
+
// only get new CommentUpdates
|
|
66
|
+
// not interested in CommentUpdate we already fetched before
|
|
67
|
+
const attemptedPathsToLoadErrors = {};
|
|
68
|
+
const kuboRpcOrHelia = this.getDefaultKuboRpcClientOrHelia();
|
|
69
|
+
const didLastPostUpdateRangeHaveSameFolderCid = timestampRanges.some((timestampRange) => {
|
|
70
|
+
if (!this._comment._commentUpdateIpfsPath)
|
|
71
|
+
return false;
|
|
72
|
+
const folderCid = subIpns.postUpdates[timestampRange];
|
|
73
|
+
const lastFolderCid = this._comment._commentUpdateIpfsPath.split("/")[0];
|
|
74
|
+
return folderCid === lastFolderCid;
|
|
75
|
+
});
|
|
76
|
+
if (didLastPostUpdateRangeHaveSameFolderCid) {
|
|
77
|
+
log("Comment", this._comment.cid, "last post update range has same folder cid", this._comment._commentUpdateIpfsPath, "will be skipping loading CommentUpdate");
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
|
|
81
|
+
for (const timestampRange of timestampRanges) {
|
|
82
|
+
const folderCid = subIpns.postUpdates[timestampRange];
|
|
83
|
+
const path = this._calculatePathForPostCommentUpdate(folderCid, this._comment.postCid);
|
|
84
|
+
this._updateKuboRpcClientOrHeliaState("fetching-update-ipfs", kuboRpcOrHelia);
|
|
85
|
+
let res;
|
|
86
|
+
const commentUpdateTimeoutMs = this._pkc._timeouts["comment-update-ipfs"];
|
|
87
|
+
try {
|
|
88
|
+
res = await this._fetchCidP2P(path, {
|
|
89
|
+
maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE,
|
|
90
|
+
timeoutMs: commentUpdateTimeoutMs,
|
|
91
|
+
abortSignal: this._comment._getStopAbortSignal()
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
// failed to load the record, maybe our node is offline or the content is unreachable
|
|
96
|
+
log.trace(`Failed to fetch CommentUpdate from path (${path}) with IPFS P2P. Trying the next timestamp range`);
|
|
97
|
+
attemptedPathsToLoadErrors[path] = e;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
this._updateKuboRpcClientOrHeliaState("stopped", kuboRpcOrHelia);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const commentUpdate = parseCommentUpdateSchemaWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(res));
|
|
105
|
+
await this._throwIfCommentUpdateHasInvalidSignature(commentUpdate, subIpns);
|
|
106
|
+
if (commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0))
|
|
107
|
+
return { commentUpdate, commentUpdateIpfsPath: path };
|
|
108
|
+
else
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
// there's a problem with the record itself, could be signature or schema or bad json
|
|
113
|
+
this._comment._invalidCommentUpdateMfsPaths.add(path);
|
|
114
|
+
if (e instanceof PKCError)
|
|
115
|
+
e.details = { ...e.details, commentUpdatePath: path, postCid: this._comment.cid };
|
|
116
|
+
throw e;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
throw new PKCError("ERR_FAILED_TO_FETCH_COMMENT_UPDATE_FROM_ALL_POST_UPDATES_RANGES", {
|
|
120
|
+
timestampRanges,
|
|
121
|
+
attemptedPathsToLoadErrors,
|
|
122
|
+
postCid: this._comment.cid,
|
|
123
|
+
commentDepth: this._comment.depth
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
_shouldWeFetchCommentUpdateFromNextTimestamp(err) {
|
|
127
|
+
// Is there a problem with the record itself, or is this an issue with fetching?
|
|
128
|
+
if (!(err instanceof PKCError))
|
|
129
|
+
return false; // If it's not a recognizable error, then we throw to notify the user
|
|
130
|
+
if (err.code === "ERR_COMMENT_UPDATE_SIGNATURE_IS_INVALID" ||
|
|
131
|
+
err.code === "ERR_INVALID_COMMENT_UPDATE_SCHEMA" ||
|
|
132
|
+
err.code === "ERR_OVER_DOWNLOAD_LIMIT" ||
|
|
133
|
+
err.code === "ERR_INVALID_JSON")
|
|
134
|
+
return false; // These errors means there's a problem with the record itself, not the loading
|
|
135
|
+
if (err instanceof FailedToFetchCommentUpdateFromGatewaysError) {
|
|
136
|
+
// If all gateway errors are due to the record itself, then we throw an error and don't jump to the next timestamp
|
|
137
|
+
for (const gatewayError of Object.values(err.details.gatewayToError))
|
|
138
|
+
if (this._shouldWeFetchCommentUpdateFromNextTimestamp(gatewayError))
|
|
139
|
+
return true; // if there's at least one gateway whose error is not due to the record
|
|
140
|
+
return false; // if all gateways have issues with the record validity itself, then we stop fetching
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
async _throwIfCommentUpdateHasInvalidSignature(commentUpdate, communityIpfs) {
|
|
145
|
+
if (!this._comment.raw.comment)
|
|
146
|
+
throw Error("Can't validate comment update when CommentIpfs hasn't been loaded");
|
|
147
|
+
if (!this._comment.cid)
|
|
148
|
+
throw Error("can't validate comment update when cid is not defined");
|
|
149
|
+
if (!this._comment.postCid)
|
|
150
|
+
throw Error("can't validate comment update when postCid is not defined");
|
|
151
|
+
const verifyOptions = {
|
|
152
|
+
update: commentUpdate,
|
|
153
|
+
resolveAuthorNames: this._pkc.resolveAuthorNames,
|
|
154
|
+
clientsManager: this,
|
|
155
|
+
community: { address: this._comment.communityAddress, signature: communityIpfs.signature },
|
|
156
|
+
comment: { ...this._comment.raw.comment, cid: this._comment.cid, postCid: this._comment.postCid },
|
|
157
|
+
validatePages: this._pkc.validatePages,
|
|
158
|
+
validateUpdateSignature: true,
|
|
159
|
+
abortSignal: this._comment._getStopAbortSignal()
|
|
160
|
+
};
|
|
161
|
+
const signatureValidity = await verifyCommentUpdate(verifyOptions);
|
|
162
|
+
if (!signatureValidity.valid)
|
|
163
|
+
throw new PKCError("ERR_COMMENT_UPDATE_SIGNATURE_IS_INVALID", {
|
|
164
|
+
signatureValidity,
|
|
165
|
+
verifyOptions
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async _fetchPostCommentUpdateFromGateways(subIpns, timestampRanges, log) {
|
|
169
|
+
const didLastPostUpdateRangeHaveSameFolderCid = timestampRanges.some((timestampRange) => {
|
|
170
|
+
if (!this._comment._commentUpdateIpfsPath)
|
|
171
|
+
return false;
|
|
172
|
+
const folderCid = subIpns.postUpdates[timestampRange];
|
|
173
|
+
const lastFolderCid = this._comment._commentUpdateIpfsPath.split("/")[0];
|
|
174
|
+
return folderCid === lastFolderCid;
|
|
175
|
+
});
|
|
176
|
+
if (didLastPostUpdateRangeHaveSameFolderCid) {
|
|
177
|
+
log("Comment", this._comment.cid, "last post update range has same folder cid", this._comment._commentUpdateIpfsPath, "will be skipping loading CommentUpdate");
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
const attemptedPathsToLoadErrors = {};
|
|
181
|
+
let commentUpdate;
|
|
182
|
+
const validateCommentFromGateway = async (res) => {
|
|
183
|
+
if (typeof res.resText !== "string")
|
|
184
|
+
throw Error("Gateway response has no body");
|
|
185
|
+
const commentUpdateBeforeSignature = parseCommentUpdateSchemaWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(res.resText));
|
|
186
|
+
await this._throwIfCommentUpdateHasInvalidSignature(commentUpdateBeforeSignature, subIpns);
|
|
187
|
+
commentUpdate = commentUpdateBeforeSignature; // at this point, we know the gateway has provided a valid comment update and we can use it
|
|
188
|
+
};
|
|
189
|
+
this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
|
|
190
|
+
for (const timestampRange of timestampRanges) {
|
|
191
|
+
// We're validating schema and signature here for every gateway because it's not a regular cid whose content we can verify to match the cid
|
|
192
|
+
const folderCid = subIpns.postUpdates[timestampRange];
|
|
193
|
+
const path = this._calculatePathForPostCommentUpdate(folderCid, this._comment.postCid);
|
|
194
|
+
try {
|
|
195
|
+
// Validate the Comment Update within the gateway fetching algo
|
|
196
|
+
// fetchFromMultipleGateways will throw if all gateways failed to load the record
|
|
197
|
+
await this.fetchFromMultipleGateways({
|
|
198
|
+
recordIpfsType: "ipfs",
|
|
199
|
+
root: folderCid,
|
|
200
|
+
path: path.replace(`${folderCid}/`, ""),
|
|
201
|
+
recordPKCType: "comment-update",
|
|
202
|
+
validateGatewayResponseFunc: validateCommentFromGateway,
|
|
203
|
+
log,
|
|
204
|
+
maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE,
|
|
205
|
+
timeoutMs: this._pkc._timeouts["comment-update-ipfs"],
|
|
206
|
+
abortSignal: this._comment._getStopAbortSignal()
|
|
207
|
+
});
|
|
208
|
+
if (!commentUpdate)
|
|
209
|
+
throw Error("Failed to load comment update from gateways. This is a critical logic error");
|
|
210
|
+
if (commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0))
|
|
211
|
+
return { commentUpdate, commentUpdateIpfsPath: path };
|
|
212
|
+
else
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
catch (e) {
|
|
216
|
+
// We need to find out if it's loading error, and if it is we just move on to the next timestamp range
|
|
217
|
+
// If it's a schema or signature error we should stop and throw
|
|
218
|
+
if (this._shouldWeFetchCommentUpdateFromNextTimestamp(e)) {
|
|
219
|
+
attemptedPathsToLoadErrors[path] = e;
|
|
220
|
+
log.trace(`Failed to fetch CommentUpdate from path (${path}) from gateways. Trying the next timestamp range`);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
// non retriable error
|
|
225
|
+
// a problem with the record itself, bad signature/schema/etc
|
|
226
|
+
this._comment._invalidCommentUpdateMfsPaths.add(path);
|
|
227
|
+
throw e;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
throw new PKCError("ERR_FAILED_TO_FETCH_COMMENT_UPDATE_FROM_ALL_POST_UPDATES_RANGES", {
|
|
232
|
+
timestampRanges,
|
|
233
|
+
attemptedPathsToLoadErrors,
|
|
234
|
+
commentCid: this._comment.cid,
|
|
235
|
+
commentDepth: this._comment.depth
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
_useLoadedCommentUpdateIfNewInfo(loadedCommentUpdate, community, log) {
|
|
239
|
+
if ((this._comment.raw.commentUpdate?.updatedAt || 0) < loadedCommentUpdate.commentUpdate.updatedAt) {
|
|
240
|
+
log(`${this._comment.depth === 0 ? "Post" : "Reply"} (${this._comment.cid}) received a new CommentUpdate`);
|
|
241
|
+
this._comment._initCommentUpdate(loadedCommentUpdate.commentUpdate, community);
|
|
242
|
+
if ("commentUpdateIpfsPath" in loadedCommentUpdate)
|
|
243
|
+
this._comment._commentUpdateIpfsPath = loadedCommentUpdate.commentUpdateIpfsPath;
|
|
244
|
+
this._comment._changeCommentStateEmitEventEmitStateChangeEvent({
|
|
245
|
+
newUpdatingState: "succeeded",
|
|
246
|
+
event: { name: "update", args: [this._comment] }
|
|
247
|
+
});
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
else
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
async useCommunityPostUpdatesToFetchCommentUpdateForPost(subIpfs) {
|
|
254
|
+
const log = Logger("pkc-js:comment:useCommunityPostUpdatesToFetchCommentUpdate");
|
|
255
|
+
if (!subIpfs.postUpdates) {
|
|
256
|
+
throw new PKCError("ERR_COMMUNITY_HAS_NO_POST_UPDATES", { subIpfs, postCid: this._comment.cid });
|
|
257
|
+
}
|
|
258
|
+
const postCid = this._comment.postCid;
|
|
259
|
+
if (!postCid)
|
|
260
|
+
throw Error("comment.postCid needs to be defined to fetch comment update");
|
|
261
|
+
const postTimestamp = this._comment.timestamp;
|
|
262
|
+
if (typeof postTimestamp !== "number")
|
|
263
|
+
throw Error("Post timestamp is not defined by the time we're fetching from postUpdates");
|
|
264
|
+
const timestampRanges = getPostUpdateTimestampRange(subIpfs.postUpdates, postTimestamp);
|
|
265
|
+
if (timestampRanges.length === 0)
|
|
266
|
+
throw Error("Post has no timestamp range bucket");
|
|
267
|
+
let newCommentUpdate;
|
|
268
|
+
try {
|
|
269
|
+
if (Object.keys(this._pkc.clients.kuboRpcClients).length > 0 || Object.keys(this._pkc.clients.libp2pJsClients).length > 0) {
|
|
270
|
+
newCommentUpdate = await this._fetchPostCommentUpdateIpfsP2P(subIpfs, timestampRanges, log);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
newCommentUpdate = await this._fetchPostCommentUpdateFromGateways(subIpfs, timestampRanges, log);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
catch (e) {
|
|
277
|
+
if (e instanceof Error) {
|
|
278
|
+
if (isAbortError(e))
|
|
279
|
+
return;
|
|
280
|
+
if (this._shouldWeFetchCommentUpdateFromNextTimestamp(e)) {
|
|
281
|
+
// this is a retriable error
|
|
282
|
+
// could be problems loading from the network or gateways
|
|
283
|
+
log.trace(`Post`, this._comment.cid, "Failed to load CommentUpdate. Will retry later", e);
|
|
284
|
+
this._comment._changeCommentStateEmitEventEmitStateChangeEvent({
|
|
285
|
+
newUpdatingState: "waiting-retry",
|
|
286
|
+
event: { name: "error", args: [e] }
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
// non retriable error, problem with schema/signature
|
|
291
|
+
log.error("Received a non retriable error when attempting to load post commentUpdate. Will be emitting error", this._comment.cid, e);
|
|
292
|
+
this._comment._changeCommentStateEmitEventEmitStateChangeEvent({
|
|
293
|
+
newUpdatingState: "failed",
|
|
294
|
+
event: { name: "error", args: [e] }
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (newCommentUpdate) {
|
|
301
|
+
this._useLoadedCommentUpdateIfNewInfo(newCommentUpdate, subIpfs, log);
|
|
302
|
+
}
|
|
303
|
+
else if (newCommentUpdate === undefined) {
|
|
304
|
+
log.trace(`Comment`, this._comment.cid, "loaded an old comment update. Ignoring it");
|
|
305
|
+
this._comment._setUpdatingStateWithEmissionIfNewState("waiting-retry");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
async _fetchRawCommentCidIpfsP2P(cid) {
|
|
309
|
+
const kuboRpcOrHelia = this.getDefaultKuboRpcClientOrHelia();
|
|
310
|
+
this._updateKuboRpcClientOrHeliaState("fetching-ipfs", kuboRpcOrHelia);
|
|
311
|
+
let commentRawString;
|
|
312
|
+
const commentTimeoutMs = this._pkc._timeouts["comment-ipfs"];
|
|
313
|
+
try {
|
|
314
|
+
commentRawString = await this._fetchCidP2P(cid, {
|
|
315
|
+
maxFileSizeBytes: 1024 * 1024,
|
|
316
|
+
timeoutMs: commentTimeoutMs,
|
|
317
|
+
abortSignal: this._comment._getStopAbortSignal()
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
catch (e) {
|
|
321
|
+
//@ts-expect-error
|
|
322
|
+
e.details = { ...e.details, commentCid: cid, commentTimeoutMs };
|
|
323
|
+
throw e;
|
|
324
|
+
}
|
|
325
|
+
finally {
|
|
326
|
+
this._updateKuboRpcClientOrHeliaState("stopped", kuboRpcOrHelia);
|
|
327
|
+
}
|
|
328
|
+
return commentRawString;
|
|
329
|
+
}
|
|
330
|
+
async _fetchCommentIpfsFromGateways(parentCid) {
|
|
331
|
+
// We only need to validate once, because with Comment Ipfs the fetchFromMultipleGateways already validates if the response is the same as its cid
|
|
332
|
+
const log = Logger("pkc-js:comment:client-manager:_fetchCommentIpfsFromGateways");
|
|
333
|
+
const res = await this.fetchFromMultipleGateways({
|
|
334
|
+
recordIpfsType: "ipfs",
|
|
335
|
+
recordPKCType: "comment",
|
|
336
|
+
root: parentCid,
|
|
337
|
+
validateGatewayResponseFunc: async () => { },
|
|
338
|
+
log,
|
|
339
|
+
maxFileSizeBytes: 1024 * 1024,
|
|
340
|
+
timeoutMs: this._pkc._timeouts["comment-ipfs"],
|
|
341
|
+
abortSignal: this._comment._getStopAbortSignal()
|
|
342
|
+
});
|
|
343
|
+
return res.resText;
|
|
344
|
+
}
|
|
345
|
+
async _throwIfCommentIpfsIsInvalid(commentIpfs, commentCid) {
|
|
346
|
+
// Can potentially throw if resolver if not working
|
|
347
|
+
const verificationOpts = {
|
|
348
|
+
comment: commentIpfs,
|
|
349
|
+
resolveAuthorNames: this._pkc.resolveAuthorNames,
|
|
350
|
+
clientsManager: this,
|
|
351
|
+
calculatedCommentCid: commentCid,
|
|
352
|
+
communityAddressFromInstance: this._comment.communityAddress,
|
|
353
|
+
abortSignal: this._comment._getStopAbortSignal()
|
|
354
|
+
};
|
|
355
|
+
const commentIpfsValidation = await verifyCommentIpfs(verificationOpts);
|
|
356
|
+
if (!commentIpfsValidation.valid)
|
|
357
|
+
throw new PKCError("ERR_COMMENT_IPFS_SIGNATURE_IS_INVALID", { commentIpfsValidation, verificationOpts });
|
|
358
|
+
}
|
|
359
|
+
async _fetchCommentIpfsFromPages() {
|
|
360
|
+
// this code below won't be executed by a post, and instead it will be a reply
|
|
361
|
+
// what do we do if we don't have parentCid?
|
|
362
|
+
// - download all comments under a community and look for our specific comment
|
|
363
|
+
if (!this._comment.communityAddress)
|
|
364
|
+
throw Error("Comment communityAddress should be defined");
|
|
365
|
+
if (!this._comment.cid)
|
|
366
|
+
throw Error("Comment cid should be defined");
|
|
367
|
+
const community = await this._pkc.createCommunity({
|
|
368
|
+
name: this._comment.communityName,
|
|
369
|
+
publicKey: this._comment.communityPublicKey,
|
|
370
|
+
address: this._comment.communityAddress
|
|
371
|
+
});
|
|
372
|
+
const abortController = new AbortController();
|
|
373
|
+
const abortIfNeeded = async () => {
|
|
374
|
+
if (!abortController.signal.aborted)
|
|
375
|
+
abortController.abort();
|
|
376
|
+
if (community.state === "updating")
|
|
377
|
+
await community.stop();
|
|
378
|
+
};
|
|
379
|
+
const onCommentUpdate = async () => {
|
|
380
|
+
if (this._comment.raw.comment)
|
|
381
|
+
await abortIfNeeded();
|
|
382
|
+
};
|
|
383
|
+
const onStateChange = async (newState) => {
|
|
384
|
+
if (newState === "stopped")
|
|
385
|
+
await abortIfNeeded();
|
|
386
|
+
};
|
|
387
|
+
this._comment.on("update", onCommentUpdate);
|
|
388
|
+
this._comment.on("statechange", onStateChange);
|
|
389
|
+
if (this._comment.state === "stopped" || this._pkc.destroyed)
|
|
390
|
+
return;
|
|
391
|
+
try {
|
|
392
|
+
if (abortController.signal.aborted)
|
|
393
|
+
return;
|
|
394
|
+
await community.update();
|
|
395
|
+
await new Promise((resolve, reject) => {
|
|
396
|
+
const abortError = () => {
|
|
397
|
+
const error = new Error("The operation was aborted");
|
|
398
|
+
error.name = "AbortError";
|
|
399
|
+
return error;
|
|
400
|
+
};
|
|
401
|
+
const cleanup = () => {
|
|
402
|
+
community.removeListener("update", onUpdate);
|
|
403
|
+
abortController.signal.removeEventListener("abort", onAbort);
|
|
404
|
+
};
|
|
405
|
+
const onAbort = () => {
|
|
406
|
+
cleanup();
|
|
407
|
+
reject(abortError());
|
|
408
|
+
};
|
|
409
|
+
const onUpdate = async () => {
|
|
410
|
+
try {
|
|
411
|
+
if (typeof community.updatedAt === "number") {
|
|
412
|
+
cleanup();
|
|
413
|
+
resolve();
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
catch (error) {
|
|
417
|
+
cleanup();
|
|
418
|
+
reject(error);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
if (abortController.signal.aborted) {
|
|
422
|
+
reject(abortError());
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
abortController.signal.addEventListener("abort", onAbort);
|
|
426
|
+
community.on("update", onUpdate);
|
|
427
|
+
void onUpdate();
|
|
428
|
+
});
|
|
429
|
+
await community.stop();
|
|
430
|
+
const commentAfterSearchingAllPages = await loadAllPagesUnderCommunityToFindComment({
|
|
431
|
+
community: community,
|
|
432
|
+
commentCidToFind: this._comment.cid,
|
|
433
|
+
postCid: this._comment.postCid,
|
|
434
|
+
parentCid: this._comment.parentCid,
|
|
435
|
+
signal: abortController.signal
|
|
436
|
+
});
|
|
437
|
+
if (commentAfterSearchingAllPages) {
|
|
438
|
+
if (!this._comment.raw.comment) {
|
|
439
|
+
this._comment._initIpfsProps(commentAfterSearchingAllPages.comment);
|
|
440
|
+
this._comment.emit("update", this._comment);
|
|
441
|
+
}
|
|
442
|
+
if ((this._comment.updatedAt || 0) < commentAfterSearchingAllPages.commentUpdate.updatedAt)
|
|
443
|
+
this._comment._initCommentUpdate(commentAfterSearchingAllPages.commentUpdate, community.raw.communityIpfs);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
catch (err) {
|
|
447
|
+
if (err?.name !== "AbortError")
|
|
448
|
+
throw err;
|
|
449
|
+
}
|
|
450
|
+
finally {
|
|
451
|
+
this._comment.removeListener("update", onCommentUpdate);
|
|
452
|
+
this._comment.removeListener("statechange", onStateChange);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// We're gonna fetch Comment Ipfs, and verify its signature and schema
|
|
456
|
+
async fetchAndVerifyCommentCid(cid) {
|
|
457
|
+
const cachedComment = this._pkc._memCaches.commentIpfs.get(cid);
|
|
458
|
+
if (cachedComment) {
|
|
459
|
+
fetchCommentLogger.trace("Serving comment CID from cache", cid);
|
|
460
|
+
return remeda.clone(cachedComment);
|
|
461
|
+
}
|
|
462
|
+
const verifiedComment = await this._pkc._inflightFetchManager.withResource(InflightResourceTypes.COMMENT_IPFS, cid, async () => {
|
|
463
|
+
fetchCommentLogger.trace("Fetching comment CID", cid);
|
|
464
|
+
let commentRawString;
|
|
465
|
+
if (Object.keys(this._pkc.clients.kuboRpcClients).length > 0 || Object.keys(this._pkc.clients.libp2pJsClients).length > 0) {
|
|
466
|
+
commentRawString = await this._fetchRawCommentCidIpfsP2P(cid);
|
|
467
|
+
}
|
|
468
|
+
else
|
|
469
|
+
commentRawString = await this._fetchCommentIpfsFromGateways(cid);
|
|
470
|
+
const commentIpfs = parseCommentIpfsSchemaWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(commentRawString)); // could throw if schema is invalid
|
|
471
|
+
await this._throwIfCommentIpfsIsInvalid(commentIpfs, cid);
|
|
472
|
+
return commentIpfs;
|
|
473
|
+
});
|
|
474
|
+
this._pkc._memCaches.commentIpfs.set(cid, verifiedComment);
|
|
475
|
+
return verifiedComment;
|
|
476
|
+
}
|
|
477
|
+
_isPublishing() {
|
|
478
|
+
return this._comment.state === "publishing";
|
|
479
|
+
}
|
|
480
|
+
_findCommentInPagesOfUpdatingCommentsOrCommunity(opts) {
|
|
481
|
+
// TODO rewrite this to use updating comments and community
|
|
482
|
+
if (typeof this._comment.cid !== "string")
|
|
483
|
+
throw Error("Need to have defined cid");
|
|
484
|
+
const community = findStartedCommunity(this._pkc, { address: this._comment.communityAddress }) ||
|
|
485
|
+
findUpdatingCommunity(this._pkc, { address: this._comment.communityAddress }) ||
|
|
486
|
+
opts?.community;
|
|
487
|
+
let updateFromCommunity;
|
|
488
|
+
if (community)
|
|
489
|
+
updateFromCommunity = findCommentInPageInstanceRecursively(community.posts, this._comment.cid);
|
|
490
|
+
const post = this._comment.postCid
|
|
491
|
+
? findUpdatingComment(this._pkc, { cid: this._comment.postCid })
|
|
492
|
+
: opts?.post;
|
|
493
|
+
let updateFromPost;
|
|
494
|
+
if (post)
|
|
495
|
+
updateFromPost = findCommentInPageInstanceRecursively(post.replies, this._comment.cid);
|
|
496
|
+
const parent = this._comment.parentCid
|
|
497
|
+
? opts?.parent || findUpdatingComment(this._pkc, { cid: this._comment.parentCid })
|
|
498
|
+
: undefined;
|
|
499
|
+
let updateFromParent;
|
|
500
|
+
if (parent) {
|
|
501
|
+
updateFromParent = parent.replies && findCommentInPageInstance(parent.replies, this._comment.cid);
|
|
502
|
+
}
|
|
503
|
+
const updates = [updateFromCommunity, updateFromPost, updateFromParent].filter((update) => !!update);
|
|
504
|
+
const latestUpdate = updates.sort((a, b) => b.commentUpdate.updatedAt - a.commentUpdate.updatedAt)[0];
|
|
505
|
+
return latestUpdate;
|
|
506
|
+
}
|
|
507
|
+
// will handling community states down here
|
|
508
|
+
// this is for posts with depth === 0
|
|
509
|
+
async handleUpdateEventFromCommunity(community) {
|
|
510
|
+
const log = Logger("pkc-js:comment:update");
|
|
511
|
+
if (!this._comment.cid) {
|
|
512
|
+
log("comment.cid is not defined because comment is publishing, waiting until cid is defined");
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
// a new update has been emitted by community
|
|
516
|
+
if (this._comment.state === "stopped") {
|
|
517
|
+
// there are async cases where we fetch a CommunityUpdate in the background and stop() is called midway
|
|
518
|
+
await this._comment.stop();
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
if (!community.raw.communityIpfs)
|
|
522
|
+
throw Error("Community IPFS should be defined when an update is emitted");
|
|
523
|
+
// let's try to find a CommentUpdate in community pages, or _updatingComments
|
|
524
|
+
// this._communityForUpdating!.community.raw.communityIpfs?.posts.
|
|
525
|
+
const postInUpdatingCommunity = this._findCommentInPagesOfUpdatingCommentsOrCommunity({ community });
|
|
526
|
+
if (postInUpdatingCommunity &&
|
|
527
|
+
postInUpdatingCommunity.commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0)) {
|
|
528
|
+
const log = Logger("pkc-js:comment:update:handleUpdateEventFromCommunity:find-comment-update-in-updating-community-or-comments-pages");
|
|
529
|
+
this._useLoadedCommentUpdateIfNewInfo({ commentUpdate: postInUpdatingCommunity.commentUpdate }, community.raw.communityIpfs, log);
|
|
530
|
+
}
|
|
531
|
+
else
|
|
532
|
+
try {
|
|
533
|
+
// this is only for posts with depth === 0
|
|
534
|
+
await this.useCommunityPostUpdatesToFetchCommentUpdateForPost(community.raw.communityIpfs);
|
|
535
|
+
}
|
|
536
|
+
catch (e) {
|
|
537
|
+
if (isAbortError(e))
|
|
538
|
+
return;
|
|
539
|
+
log.error("Failed to use community update to fetch new CommentUpdate", e);
|
|
540
|
+
this._comment._changeCommentStateEmitEventEmitStateChangeEvent({
|
|
541
|
+
newUpdatingState: "failed",
|
|
542
|
+
event: { name: "error", args: [e] }
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
_chooseWhichPagesBasedOnParentAndReplyTimestamp(parentCommentTimestamp) {
|
|
547
|
+
// Choose which page type to search first based on our reply's timestamp
|
|
548
|
+
const replyTimestamp = this._comment.timestamp;
|
|
549
|
+
const currentTime = Math.floor(Date.now() / 1000);
|
|
550
|
+
// Calculate if our reply is relatively newer or older within the reply timeline
|
|
551
|
+
// The reply timeline spans from parentComment timestamp to current time
|
|
552
|
+
const replyTimelineSpan = currentTime - parentCommentTimestamp;
|
|
553
|
+
// Ensure our reply timestamp is at least the parentComment timestamp
|
|
554
|
+
const adjustedReplyTimestamp = Math.max(replyTimestamp, parentCommentTimestamp);
|
|
555
|
+
// Calculate how far along the timeline our reply is (0 = oldest possible, 1 = newest possible)
|
|
556
|
+
const replyRelativeAge = (currentTime - adjustedReplyTimestamp) / replyTimelineSpan;
|
|
557
|
+
// If replyRelativeAge is closer to 0, the reply is newer (less age)
|
|
558
|
+
// If replyRelativeAge is closer to 1, the reply is older (more age)
|
|
559
|
+
// So we start with 'new' pages if replyRelativeAge < 0.5
|
|
560
|
+
const startWithNewPages = replyRelativeAge < 0.5;
|
|
561
|
+
return startWithNewPages ? "new" : "old";
|
|
562
|
+
}
|
|
563
|
+
async usePageCidsOfParentToFetchCommentUpdateForReply(postCommentInstance) {
|
|
564
|
+
const log = Logger("pkc-js:comment:update:usePageCidsOfParentToFetchCommentUpdateForReply");
|
|
565
|
+
if (!this._comment.cid)
|
|
566
|
+
throw Error("comment.cid needs to be defined to fetch comment update of reply");
|
|
567
|
+
if (!this._comment.parentCid)
|
|
568
|
+
throw Error("comment.parentCid needs to be defined to fetch comment update of reply");
|
|
569
|
+
const communityWithSignature = postCommentInstance.replies._community;
|
|
570
|
+
if (!communityWithSignature.signature)
|
|
571
|
+
throw Error("comment.replies._community.signature needs to be defined to fetch comment update of reply");
|
|
572
|
+
const parentCommentInstance = postCommentInstance.cid === this._comment.parentCid
|
|
573
|
+
? postCommentInstance
|
|
574
|
+
: await this._pkc.createComment({ cid: this._comment.parentCid });
|
|
575
|
+
let startedUpdatingParentComment = false;
|
|
576
|
+
if (parentCommentInstance.state === "stopped") {
|
|
577
|
+
await parentCommentInstance.update();
|
|
578
|
+
startedUpdatingParentComment = true;
|
|
579
|
+
}
|
|
580
|
+
await resolveWhenPredicateIsTrue({
|
|
581
|
+
toUpdate: parentCommentInstance,
|
|
582
|
+
predicate: () => typeof parentCommentInstance.updatedAt === "number"
|
|
583
|
+
});
|
|
584
|
+
if (startedUpdatingParentComment)
|
|
585
|
+
await parentCommentInstance.stop();
|
|
586
|
+
if (parentCommentInstance.updatedAt < this._comment.timestamp)
|
|
587
|
+
return; // if updatedAt is older then it doesn't include this comment yet
|
|
588
|
+
const replyInPreloadedParentPages = parentCommentInstance.replies && findCommentInPageInstance(parentCommentInstance.replies, this._comment.cid);
|
|
589
|
+
if (replyInPreloadedParentPages &&
|
|
590
|
+
replyInPreloadedParentPages.commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0)) {
|
|
591
|
+
this._useLoadedCommentUpdateIfNewInfo({ commentUpdate: replyInPreloadedParentPages.commentUpdate }, communityWithSignature, log);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
if (Object.keys(parentCommentInstance.replies.pageCids).length === 0) {
|
|
595
|
+
// Parent has no pageCids - all replies fit in preloaded pages
|
|
596
|
+
// If we found the reply in preloaded pages (line 675-676), use it even if not strictly "newer"
|
|
597
|
+
if (replyInPreloadedParentPages) {
|
|
598
|
+
log("Parent comment", this._comment.parentCid, "has no pageCids but reply", this._comment.cid, "found in preloaded pages - using it");
|
|
599
|
+
this._useLoadedCommentUpdateIfNewInfo({ commentUpdate: replyInPreloadedParentPages.commentUpdate }, communityWithSignature, log);
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
// Reply not in preloaded pages and no pageCids to search - wait for update
|
|
603
|
+
log("Parent comment", this._comment.parentCid, "of reply", this._comment.cid, "does not have any pageCids and reply not in preloaded pages, will wait until another update event by post");
|
|
604
|
+
this._comment._setUpdatingStateWithEmissionIfNewState("waiting-retry");
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
const pageSortName = this._chooseWhichPagesBasedOnParentAndReplyTimestamp(parentCommentInstance.timestamp);
|
|
608
|
+
let curPageCid = parentCommentInstance.replies.pageCids[pageSortName];
|
|
609
|
+
if (!curPageCid)
|
|
610
|
+
throw Error("Parent comment does not have any new or old pages");
|
|
611
|
+
if (this._parentFirstPageCidsAlreadyLoaded.has(curPageCid)) {
|
|
612
|
+
log(`Reply`, this._comment.cid, `:SKIPPING: Page CID ${curPageCid} already loaded parent page cid`);
|
|
613
|
+
// we already loaded this page before and have its comment update, no need to do anything
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
|
|
617
|
+
let newCommentUpdate;
|
|
618
|
+
const pageCidsSearchedForNewUpdate = [];
|
|
619
|
+
let replyFoundWithoutNewerUpdate = false;
|
|
620
|
+
while (curPageCid && !newCommentUpdate) {
|
|
621
|
+
let pageLoaded;
|
|
622
|
+
try {
|
|
623
|
+
pageLoaded = await parentCommentInstance.replies.getPage({ cid: curPageCid });
|
|
624
|
+
}
|
|
625
|
+
catch (e) {
|
|
626
|
+
if (isAbortError(e))
|
|
627
|
+
throw e;
|
|
628
|
+
pageCidsSearchedForNewUpdate.push({ pageCid: curPageCid, error: e });
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
if (pageCidsSearchedForNewUpdate.length === 0) {
|
|
632
|
+
this._parentFirstPageCidsAlreadyLoaded.add(curPageCid);
|
|
633
|
+
}
|
|
634
|
+
const replyWithinParentPage = findCommentInParsedPages(pageLoaded, this._comment.cid)?.raw;
|
|
635
|
+
const replyWithinUpdatingPages = this._findCommentInPagesOfUpdatingCommentsOrCommunity({ parent: parentCommentInstance });
|
|
636
|
+
pageCidsSearchedForNewUpdate.push({
|
|
637
|
+
pageCid: curPageCid,
|
|
638
|
+
replyWithinParentPage: Boolean(replyWithinParentPage),
|
|
639
|
+
replyWithinUpdatingPages: Boolean(replyWithinUpdatingPages)
|
|
640
|
+
});
|
|
641
|
+
if (replyWithinParentPage) {
|
|
642
|
+
const isNewUpdate = replyWithinParentPage.commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0);
|
|
643
|
+
if (isNewUpdate) {
|
|
644
|
+
newCommentUpdate = replyWithinParentPage;
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
replyFoundWithoutNewerUpdate = true;
|
|
648
|
+
}
|
|
649
|
+
break; // if we found the comment in parent pages, there's no point in continuing to look for it in updating pages
|
|
650
|
+
}
|
|
651
|
+
else if (replyWithinUpdatingPages) {
|
|
652
|
+
const isNewUpdate = replyWithinUpdatingPages.commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0);
|
|
653
|
+
if (isNewUpdate)
|
|
654
|
+
newCommentUpdate = replyWithinUpdatingPages;
|
|
655
|
+
else
|
|
656
|
+
replyFoundWithoutNewerUpdate = true;
|
|
657
|
+
}
|
|
658
|
+
if (pageSortName === "new" && pageLoaded.comments.find((comment) => comment.timestamp < this._comment.timestamp)) {
|
|
659
|
+
log("Reply", this._comment.cid, "we found a comment in the page that is older than our reply, stopping search for new comment update");
|
|
660
|
+
break;
|
|
661
|
+
}
|
|
662
|
+
else if (pageSortName === "old" && pageLoaded.comments.find((comment) => comment.timestamp > this._comment.timestamp)) {
|
|
663
|
+
log("Reply", this._comment.cid, "we found a comment in the page that is newer than our reply, stopping search for old comment update");
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
curPageCid = pageLoaded.nextCid;
|
|
667
|
+
}
|
|
668
|
+
log("Searched for new comment update of comment", this._comment.cid, "in the following pageCids of page sort", pageSortName, "of parent comment:", parentCommentInstance.cid, pageCidsSearchedForNewUpdate, "and found", newCommentUpdate ? "a new comment update" : "no new comment update");
|
|
669
|
+
if (newCommentUpdate)
|
|
670
|
+
this._useLoadedCommentUpdateIfNewInfo({ commentUpdate: newCommentUpdate.commentUpdate }, communityWithSignature, log);
|
|
671
|
+
else if (!replyFoundWithoutNewerUpdate)
|
|
672
|
+
throw new PKCError("ERR_FAILED_TO_FIND_REPLY_COMMENT_UPDATE_WITHIN_PARENT_COMMENT_PAGE_CIDS", {
|
|
673
|
+
replyCid: this._comment.cid,
|
|
674
|
+
parentCommentCid: parentCommentInstance.cid,
|
|
675
|
+
pageSortName,
|
|
676
|
+
pageCidsSearchedForNewUpdate
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
async handleErrorEventFromCommunity(error) {
|
|
680
|
+
// we received a non retriable error from community instance
|
|
681
|
+
if (this._comment.state === "publishing")
|
|
682
|
+
return super.handleErrorEventFromCommunity(error);
|
|
683
|
+
else if (this._communityForUpdating?.community?.updatingState === "failed") {
|
|
684
|
+
// let's make sure
|
|
685
|
+
// we're updating a comment
|
|
686
|
+
const log = Logger("pkc-js:comment:update");
|
|
687
|
+
log.error(this._comment.depth === 0 ? "Post" : "Reply", this._comment.cid, "received a non retriable error from its community instance. Will stop comment updating", error);
|
|
688
|
+
this._comment._changeCommentStateEmitEventEmitStateChangeEvent({
|
|
689
|
+
newUpdatingState: "failed",
|
|
690
|
+
event: { name: "error", args: [error] }
|
|
691
|
+
});
|
|
692
|
+
await this._comment.stop();
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
handleIpfsGatewayCommunityState(communityNewGatewayState, gatewayUrl) {
|
|
696
|
+
if (this._comment.state === "publishing")
|
|
697
|
+
return super.handleIpfsGatewayCommunityState(communityNewGatewayState, gatewayUrl);
|
|
698
|
+
// we're updating
|
|
699
|
+
else if (communityNewGatewayState === "fetching-ipns")
|
|
700
|
+
this.updateGatewayState("fetching-community-ipns", gatewayUrl);
|
|
701
|
+
}
|
|
702
|
+
_translateCommunityUpdatingStateToCommentUpdatingState(newCommunityUpdatingState) {
|
|
703
|
+
const communityUpdatingStateToCommentUpdatingState = {
|
|
704
|
+
failed: "failed",
|
|
705
|
+
"fetching-ipfs": "fetching-community-ipfs",
|
|
706
|
+
"fetching-ipns": "fetching-community-ipns",
|
|
707
|
+
"resolving-name": "resolving-community-name",
|
|
708
|
+
"waiting-retry": "waiting-retry",
|
|
709
|
+
stopped: "stopped",
|
|
710
|
+
succeeded: undefined,
|
|
711
|
+
"publishing-ipns": undefined
|
|
712
|
+
};
|
|
713
|
+
const translatedCommentUpdatingState = communityUpdatingStateToCommentUpdatingState[newCommunityUpdatingState];
|
|
714
|
+
if (translatedCommentUpdatingState)
|
|
715
|
+
this._comment._setUpdatingStateWithEmissionIfNewState(translatedCommentUpdatingState);
|
|
716
|
+
}
|
|
717
|
+
handleUpdatingStateChangeEventFromCommunity(newCommunityUpdatingState) {
|
|
718
|
+
if (this._comment.state === "publishing")
|
|
719
|
+
return super.handleUpdatingStateChangeEventFromCommunity(newCommunityUpdatingState);
|
|
720
|
+
if (this._comment.updatingState === "fetching-update-ipfs")
|
|
721
|
+
return;
|
|
722
|
+
this._translateCommunityUpdatingStateToCommentUpdatingState(newCommunityUpdatingState);
|
|
723
|
+
}
|
|
724
|
+
handleErrorEventFromPost(error) {
|
|
725
|
+
this._comment.emit("error", error);
|
|
726
|
+
}
|
|
727
|
+
handleUpdatingStateChangeEventFromPost(newState) {
|
|
728
|
+
const postUpdatingStateToReplyUpdatingState = {
|
|
729
|
+
failed: "failed",
|
|
730
|
+
"fetching-community-ipfs": "fetching-community-ipfs",
|
|
731
|
+
"fetching-community-ipns": "fetching-community-ipns",
|
|
732
|
+
"resolving-community-name": "resolving-community-name",
|
|
733
|
+
"waiting-retry": "waiting-retry",
|
|
734
|
+
stopped: undefined,
|
|
735
|
+
succeeded: undefined,
|
|
736
|
+
"fetching-ipfs": undefined,
|
|
737
|
+
"resolving-author-name": undefined,
|
|
738
|
+
"fetching-update-ipfs": undefined
|
|
739
|
+
};
|
|
740
|
+
const replyState = postUpdatingStateToReplyUpdatingState[newState];
|
|
741
|
+
if (replyState) {
|
|
742
|
+
if (this._fetchingUpdateForReplyUsingPageCidsPromise)
|
|
743
|
+
this._fetchingUpdateForReplyUsingPageCidsPromise.then(() => this._comment._setUpdatingStateWithEmissionIfNewState(replyState));
|
|
744
|
+
else
|
|
745
|
+
this._comment._setUpdatingStateWithEmissionIfNewState(replyState);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
_handleIpfsGatewayPostState(newState, gatewayUrl) {
|
|
749
|
+
this.updateGatewayState(newState, gatewayUrl);
|
|
750
|
+
}
|
|
751
|
+
_handleKuboRpcPostState(newState, kuboRpcUrl) {
|
|
752
|
+
this.updateKuboRpcState(newState, kuboRpcUrl);
|
|
753
|
+
}
|
|
754
|
+
_handleLibp2pJsClientPostState(newState, libp2pJsClientKey) {
|
|
755
|
+
this.updateLibp2pJsClientState(newState, libp2pJsClientKey);
|
|
756
|
+
}
|
|
757
|
+
_handleNameResolverPostState(newState, resolverKey) {
|
|
758
|
+
// Don't forward page-author resolution states from the post — only community-name resolution is relevant
|
|
759
|
+
if (newState === "resolving-author-name")
|
|
760
|
+
return;
|
|
761
|
+
this.updateNameResolverState(newState, resolverKey);
|
|
762
|
+
}
|
|
763
|
+
async handleUpdateEventFromPostToFetchReplyCommentUpdate(postInstance) {
|
|
764
|
+
if (!this._comment.cid)
|
|
765
|
+
throw Error("comment.cid should be defined");
|
|
766
|
+
const log = Logger("pkc-js:comment:update:handleUpdateEventFromPost");
|
|
767
|
+
log("Received update event from post", postInstance.cid, "for reply", this._comment.cid, "with depth", this._comment.depth);
|
|
768
|
+
if (Object.keys(postInstance.replies.pageCids).length === 0 && Object.keys(postInstance.replies.pages).length === 0) {
|
|
769
|
+
log("Post", postInstance.cid, "has no replies, therefore reply", this._comment.cid, "will wait until another update event by post");
|
|
770
|
+
this._comment._setUpdatingStateWithEmissionIfNewState("waiting-retry");
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
const replyInPage = this._findCommentInPagesOfUpdatingCommentsOrCommunity({ post: postInstance });
|
|
774
|
+
const updatingCommunity = findUpdatingCommunity(this._pkc, { address: postInstance.communityAddress });
|
|
775
|
+
const startedCommunity = findStartedCommunity(this._pkc, { address: postInstance.communityAddress });
|
|
776
|
+
const repliesCommunity = ((updatingCommunity?.raw?.communityIpfs || startedCommunity?.raw?.communityIpfs || postInstance.replies._community));
|
|
777
|
+
if (!repliesCommunity.signature)
|
|
778
|
+
throw Error("repliesCommunity.signature needs to be defined to fetch comment update of reply");
|
|
779
|
+
if (replyInPage && !this._comment.raw.comment) {
|
|
780
|
+
this._comment._initIpfsProps(replyInPage.comment);
|
|
781
|
+
this._comment.emit("update", this._comment);
|
|
782
|
+
}
|
|
783
|
+
if (replyInPage && replyInPage.commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0)) {
|
|
784
|
+
const log = Logger("pkc-js:comment:update:handleUpdateEventFromPostToFetchReplyCommentUpdate:find-comment-update-in-updating-community-or-comments-pages");
|
|
785
|
+
this._useLoadedCommentUpdateIfNewInfo({ commentUpdate: replyInPage.commentUpdate }, repliesCommunity, log);
|
|
786
|
+
return; // we found an update from pages, no need to do anything else
|
|
787
|
+
}
|
|
788
|
+
if (this._fetchingUpdateForReplyUsingPageCidsPromise)
|
|
789
|
+
await this._fetchingUpdateForReplyUsingPageCidsPromise;
|
|
790
|
+
this._fetchingUpdateForReplyUsingPageCidsPromise = this.usePageCidsOfParentToFetchCommentUpdateForReply(postInstance)
|
|
791
|
+
.catch((error) => {
|
|
792
|
+
if (isAbortError(error))
|
|
793
|
+
return;
|
|
794
|
+
log.error("Failed to fetch reply commentUpdate update from parent pages", error);
|
|
795
|
+
this._comment._changeCommentStateEmitEventEmitStateChangeEvent({
|
|
796
|
+
newUpdatingState: "failed",
|
|
797
|
+
event: { name: "error", args: [error] }
|
|
798
|
+
});
|
|
799
|
+
})
|
|
800
|
+
.finally(() => {
|
|
801
|
+
this._fetchingUpdateForReplyUsingPageCidsPromise = undefined;
|
|
802
|
+
});
|
|
803
|
+
await this._fetchingUpdateForReplyUsingPageCidsPromise;
|
|
804
|
+
this._fetchingUpdateForReplyUsingPageCidsPromise = undefined;
|
|
805
|
+
}
|
|
806
|
+
async _createPostInstanceWithStateTranslation() {
|
|
807
|
+
// this function will be for translating between the states of the post and its clients to reply states
|
|
808
|
+
if (!this._comment.postCid)
|
|
809
|
+
throw Error("comment.postCid needs to be defined to fetch comment update of reply");
|
|
810
|
+
const post = findUpdatingComment(this._pkc, { cid: this._comment.postCid }) ||
|
|
811
|
+
(await this._pkc.createComment({ cid: this._comment.postCid }));
|
|
812
|
+
this._postForUpdating = {
|
|
813
|
+
comment: post,
|
|
814
|
+
error: this.handleErrorEventFromPost.bind(this),
|
|
815
|
+
update: this.handleUpdateEventFromPostToFetchReplyCommentUpdate.bind(this),
|
|
816
|
+
updatingstatechange: this.handleUpdatingStateChangeEventFromPost.bind(this)
|
|
817
|
+
};
|
|
818
|
+
if (this._postForUpdating.comment.clients.ipfsGateways &&
|
|
819
|
+
Object.keys(this._postForUpdating.comment.clients.ipfsGateways).length > 0) {
|
|
820
|
+
// we're using gateways
|
|
821
|
+
const ipfsGatewayListeners = {};
|
|
822
|
+
for (const gatewayUrl of Object.keys(this._postForUpdating.comment.clients.ipfsGateways)) {
|
|
823
|
+
const ipfsStateListener = (postNewIpfsState) => this._handleIpfsGatewayPostState(postNewIpfsState, gatewayUrl);
|
|
824
|
+
this._postForUpdating.comment.clients.ipfsGateways[gatewayUrl].on("statechange", ipfsStateListener);
|
|
825
|
+
ipfsGatewayListeners[gatewayUrl] = ipfsStateListener;
|
|
826
|
+
}
|
|
827
|
+
this._postForUpdating.ipfsGatewayListeners = ipfsGatewayListeners;
|
|
828
|
+
}
|
|
829
|
+
// Add Kubo RPC client state listeners
|
|
830
|
+
if (this._postForUpdating.comment.clients.kuboRpcClients &&
|
|
831
|
+
Object.keys(this._postForUpdating.comment.clients.kuboRpcClients).length > 0) {
|
|
832
|
+
const kuboRpcListeners = {};
|
|
833
|
+
for (const kuboRpcUrl of Object.keys(this._postForUpdating.comment.clients.kuboRpcClients)) {
|
|
834
|
+
const kuboRpcStateListener = (postNewKuboRpcState) => this._handleKuboRpcPostState(postNewKuboRpcState, kuboRpcUrl);
|
|
835
|
+
this._postForUpdating.comment.clients.kuboRpcClients[kuboRpcUrl].on("statechange", kuboRpcStateListener);
|
|
836
|
+
kuboRpcListeners[kuboRpcUrl] = kuboRpcStateListener;
|
|
837
|
+
}
|
|
838
|
+
this._postForUpdating.kuboRpcListeners = kuboRpcListeners;
|
|
839
|
+
}
|
|
840
|
+
if (this._postForUpdating.comment.clients.libp2pJsClients &&
|
|
841
|
+
Object.keys(this._postForUpdating.comment.clients.libp2pJsClients).length > 0) {
|
|
842
|
+
const libp2pJsClientListeners = {};
|
|
843
|
+
for (const libp2pJsClientKey of Object.keys(this._postForUpdating.comment.clients.libp2pJsClients)) {
|
|
844
|
+
const libp2pJsStateListener = (postNewLibp2pJsState) => this._handleLibp2pJsClientPostState(postNewLibp2pJsState, libp2pJsClientKey);
|
|
845
|
+
this._postForUpdating.comment.clients.libp2pJsClients[libp2pJsClientKey].on("statechange", libp2pJsStateListener);
|
|
846
|
+
libp2pJsClientListeners[libp2pJsClientKey] = libp2pJsStateListener;
|
|
847
|
+
}
|
|
848
|
+
this._postForUpdating.libp2pJsClientListeners = libp2pJsClientListeners;
|
|
849
|
+
}
|
|
850
|
+
// Add name resolver state listeners
|
|
851
|
+
if (this._postForUpdating.comment.clients.nameResolvers &&
|
|
852
|
+
Object.keys(this._postForUpdating.comment.clients.nameResolvers).length > 0) {
|
|
853
|
+
const nameResolverListeners = {};
|
|
854
|
+
for (const resolverKey of Object.keys(this._postForUpdating.comment.clients.nameResolvers)) {
|
|
855
|
+
const resolverStateListener = (postNewResolverState) => this._handleNameResolverPostState(postNewResolverState, resolverKey);
|
|
856
|
+
this._postForUpdating.comment.clients.nameResolvers[resolverKey].on("statechange", resolverStateListener);
|
|
857
|
+
nameResolverListeners[resolverKey] = resolverStateListener;
|
|
858
|
+
}
|
|
859
|
+
this._postForUpdating.nameResolverListeners = nameResolverListeners;
|
|
860
|
+
}
|
|
861
|
+
this._postForUpdating.comment.on("update", this._postForUpdating.update);
|
|
862
|
+
this._postForUpdating.comment.on("updatingstatechange", this._postForUpdating.updatingstatechange);
|
|
863
|
+
this._postForUpdating.comment.on("error", this._postForUpdating.error);
|
|
864
|
+
return this._postForUpdating;
|
|
865
|
+
}
|
|
866
|
+
async cleanUpUpdatingPostInstance() {
|
|
867
|
+
if (!this._postForUpdating)
|
|
868
|
+
return; // it has been cleared out somewhere else
|
|
869
|
+
// Clean up IPFS Gateway listeners
|
|
870
|
+
if (this._postForUpdating.ipfsGatewayListeners) {
|
|
871
|
+
for (const gatewayUrl of Object.keys(this._postForUpdating.ipfsGatewayListeners)) {
|
|
872
|
+
this._postForUpdating.comment.clients.ipfsGateways[gatewayUrl].removeListener("statechange", this._postForUpdating.ipfsGatewayListeners[gatewayUrl]);
|
|
873
|
+
this.updateGatewayState("stopped", gatewayUrl); // need to reset all gateway states
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
// Clean up Kubo RPC listeners
|
|
877
|
+
if (this._postForUpdating.kuboRpcListeners) {
|
|
878
|
+
for (const kuboRpcUrl of Object.keys(this._postForUpdating.kuboRpcListeners)) {
|
|
879
|
+
this._postForUpdating.comment.clients.kuboRpcClients[kuboRpcUrl].removeListener("statechange", this._postForUpdating.kuboRpcListeners[kuboRpcUrl]);
|
|
880
|
+
this.updateKuboRpcState("stopped", kuboRpcUrl); // need to reset all Kubo RPC states
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
// Clean up libp2pJs client listeners
|
|
884
|
+
if (this._postForUpdating.libp2pJsClientListeners) {
|
|
885
|
+
for (const libp2pJsClientKey of Object.keys(this._postForUpdating.libp2pJsClientListeners)) {
|
|
886
|
+
this._postForUpdating.comment.clients.libp2pJsClients[libp2pJsClientKey].removeListener("statechange", this._postForUpdating.libp2pJsClientListeners[libp2pJsClientKey]);
|
|
887
|
+
this.updateLibp2pJsClientState("stopped", libp2pJsClientKey); // need to reset all libp2pJs client states
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
// Clean up name resolver listeners
|
|
891
|
+
if (this._postForUpdating.nameResolverListeners) {
|
|
892
|
+
for (const resolverKey of Object.keys(this._postForUpdating.nameResolverListeners)) {
|
|
893
|
+
this._postForUpdating.comment.clients.nameResolvers[resolverKey].removeListener("statechange", this._postForUpdating.nameResolverListeners[resolverKey]);
|
|
894
|
+
this.updateNameResolverState("stopped", resolverKey); // need to reset all name resolver states
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
// Remove update event at the end
|
|
898
|
+
this._postForUpdating.comment.removeListener("updatingstatechange", this._postForUpdating.updatingstatechange);
|
|
899
|
+
this._postForUpdating.comment.removeListener("error", this._postForUpdating.error);
|
|
900
|
+
this._postForUpdating.comment.removeListener("update", this._postForUpdating.update);
|
|
901
|
+
// only stop if it's mirroring the actual comment instance updating at pkc._updatingComments
|
|
902
|
+
if (this._postForUpdating.comment._updatingCommentInstance)
|
|
903
|
+
await this._postForUpdating.comment.stop();
|
|
904
|
+
this._parentFirstPageCidsAlreadyLoaded.clear();
|
|
905
|
+
this._postForUpdating = undefined;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
//# sourceMappingURL=comment-client-manager.js.map
|