@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,717 @@
|
|
|
1
|
+
import retry from "retry";
|
|
2
|
+
import { PKCClientsManager } from "../pkc/pkc-client-manager.js";
|
|
3
|
+
import { FailedToFetchCommunityFromGatewaysError, PKCError } from "../pkc-error.js";
|
|
4
|
+
import * as remeda from "remeda";
|
|
5
|
+
import { getCommunityNameFromWire } from "./community-wire.js";
|
|
6
|
+
import { getPKCAddressFromPublicKeySync } from "../signer/util.js";
|
|
7
|
+
import Logger from "../logger.js";
|
|
8
|
+
import { areEquivalentCommunityAddresses, hideClassPrivateProps, ipnsNameToIpnsOverPubsubTopic, isStringDomain, pubsubTopicToDhtKey, throwIfAbortSignalAborted, timestamp } from "../util.js";
|
|
9
|
+
import pLimit from "p-limit";
|
|
10
|
+
import { parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, parseJsonWithPKCErrorIfFails } from "../schema/schema-util.js";
|
|
11
|
+
import { verifyCommunity } from "../signer/index.js";
|
|
12
|
+
import { LimitedSet } from "../general-util/limited-set.js";
|
|
13
|
+
import { CommunityKuboPubsubClient, CommunityKuboRpcClient, CommunityLibp2pJsClient, CommunityPKCRpcStateClient } from "./community-clients.js";
|
|
14
|
+
import { CID } from "kubo-rpc-client";
|
|
15
|
+
import { getAuthorDomainFromRuntime } from "../publications/publication-author.js";
|
|
16
|
+
export const MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS = 1024 * 1024; // 1mb
|
|
17
|
+
export class CommunityClientsManager extends PKCClientsManager {
|
|
18
|
+
constructor(community) {
|
|
19
|
+
super(community._pkc);
|
|
20
|
+
this._suppressUpdatingStateForNameResolution = 0;
|
|
21
|
+
this._ipnsLoadingOperation = undefined;
|
|
22
|
+
this._updateCidsAlreadyLoaded = new LimitedSet(30); // we will keep track of the last 50 community update cids that we loaded
|
|
23
|
+
this._community = community;
|
|
24
|
+
this._initPKCRpcClients();
|
|
25
|
+
hideClassPrivateProps(this);
|
|
26
|
+
}
|
|
27
|
+
_initKuboRpcClients() {
|
|
28
|
+
if (this._pkc.clients.kuboRpcClients)
|
|
29
|
+
for (const ipfsUrl of remeda.keys.strict(this._pkc.clients.kuboRpcClients))
|
|
30
|
+
this.clients.kuboRpcClients = { ...this.clients.kuboRpcClients, [ipfsUrl]: new CommunityKuboRpcClient("stopped") };
|
|
31
|
+
}
|
|
32
|
+
_initPubsubKuboRpcClients() {
|
|
33
|
+
for (const pubsubUrl of remeda.keys.strict(this._pkc.clients.pubsubKuboRpcClients))
|
|
34
|
+
this.clients.pubsubKuboRpcClients = {
|
|
35
|
+
...this.clients.pubsubKuboRpcClients,
|
|
36
|
+
[pubsubUrl]: new CommunityKuboPubsubClient("stopped")
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
_initLibp2pJsClients() {
|
|
40
|
+
if (this._pkc.clients.libp2pJsClients)
|
|
41
|
+
for (const libp2pJsClientUrl of remeda.keys.strict(this._pkc.clients.libp2pJsClients))
|
|
42
|
+
this.clients.libp2pJsClients = {
|
|
43
|
+
...this.clients.libp2pJsClients,
|
|
44
|
+
[libp2pJsClientUrl]: new CommunityLibp2pJsClient("stopped")
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
_initPKCRpcClients() {
|
|
48
|
+
for (const rpcUrl of remeda.keys.strict(this._pkc.clients.pkcRpcClients))
|
|
49
|
+
this.clients.pkcRpcClients = {
|
|
50
|
+
...this.clients.pkcRpcClients,
|
|
51
|
+
[rpcUrl]: new CommunityPKCRpcStateClient("stopped")
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
updateKuboRpcState(newState, kuboRpcClientUrl) {
|
|
55
|
+
super.updateKuboRpcState(newState, kuboRpcClientUrl);
|
|
56
|
+
}
|
|
57
|
+
updateKuboRpcPubsubState(newState, pubsubProvider) {
|
|
58
|
+
super.updateKuboRpcPubsubState(newState, pubsubProvider);
|
|
59
|
+
}
|
|
60
|
+
updateGatewayState(newState, gateway) {
|
|
61
|
+
super.updateGatewayState(newState, gateway);
|
|
62
|
+
}
|
|
63
|
+
updateLibp2pJsClientState(newState, libp2pJsClientUrl) {
|
|
64
|
+
super.updateLibp2pJsClientState(newState, libp2pJsClientUrl);
|
|
65
|
+
}
|
|
66
|
+
emitError(e) {
|
|
67
|
+
this._community.emit("error", e);
|
|
68
|
+
}
|
|
69
|
+
_getStatePriorToResolvingCommunityIpns() {
|
|
70
|
+
return "fetching-ipns";
|
|
71
|
+
}
|
|
72
|
+
preResolveNameResolver(opts) {
|
|
73
|
+
super.preResolveNameResolver(opts);
|
|
74
|
+
if (this._suppressUpdatingStateForNameResolution > 0)
|
|
75
|
+
return;
|
|
76
|
+
this._community._setUpdatingStateWithEventEmissionIfNewState("resolving-name");
|
|
77
|
+
}
|
|
78
|
+
postResolveNameResolverSuccess(opts) {
|
|
79
|
+
super.postResolveNameResolverSuccess(opts);
|
|
80
|
+
if (!opts.resolvedValue && this._community.state === "updating") {
|
|
81
|
+
throw new PKCError("ERR_DOMAIN_TXT_RECORD_NOT_FOUND", {
|
|
82
|
+
communityAddress: opts.address,
|
|
83
|
+
textRecord: "bitsocial"
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
_getCommunityAddressFromInstance() {
|
|
88
|
+
return this._community.address;
|
|
89
|
+
}
|
|
90
|
+
_areEquivalentCommunityAddresses(addressA, addressB) {
|
|
91
|
+
return areEquivalentCommunityAddresses(addressA, addressB);
|
|
92
|
+
}
|
|
93
|
+
_deriveAddressFromWireRecord(communityJson) {
|
|
94
|
+
// Old records have address in the wire format, new records use name || publicKey
|
|
95
|
+
return (getCommunityNameFromWire(communityJson) ||
|
|
96
|
+
getPKCAddressFromPublicKeySync(communityJson.signature.publicKey));
|
|
97
|
+
}
|
|
98
|
+
// functions for updatingCommunityInstance
|
|
99
|
+
async _retryLoadingCommunityAddress(communityAddress) {
|
|
100
|
+
const log = Logger("pkc-js:remote-community:update:_retryLoadingCommunityIpns");
|
|
101
|
+
return new Promise((resolve) => {
|
|
102
|
+
this._ipnsLoadingOperation.attempt(async (curAttempt) => {
|
|
103
|
+
log.trace(`Retrying to load community ${communityAddress} for the ${curAttempt}th time`);
|
|
104
|
+
try {
|
|
105
|
+
const update = await this.fetchNewUpdateForCommunity(communityAddress);
|
|
106
|
+
resolve(update);
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
const error = e;
|
|
110
|
+
if (error.name === "AbortError")
|
|
111
|
+
return resolve({ aborted: true });
|
|
112
|
+
//@ts-expect-error
|
|
113
|
+
error.details = {
|
|
114
|
+
//@ts-expect-error
|
|
115
|
+
...error.details,
|
|
116
|
+
ipnsPubsubTopic: this._community.ipnsPubsubTopic,
|
|
117
|
+
ipnsPubsubTopicRoutingCid: this._community.ipnsPubsubTopicRoutingCid
|
|
118
|
+
};
|
|
119
|
+
if (!this._community._isRetriableErrorWhenLoading(error)) {
|
|
120
|
+
// critical error that can't be retried
|
|
121
|
+
if (error instanceof PKCError)
|
|
122
|
+
error.details = { ...error.details, countOfLoadAttempts: curAttempt, retriableError: false };
|
|
123
|
+
resolve({ criticalError: error });
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// we encountered a retriable error, could be gateways failing to load
|
|
127
|
+
// does not include gateways returning an old record
|
|
128
|
+
if (error instanceof PKCError)
|
|
129
|
+
error.details = { ...error.details, countOfLoadAttempts: curAttempt, retriableError: true };
|
|
130
|
+
log.trace(`Failed to load Community ${this._community.address} record for the ${curAttempt}th attempt. We will retry`, error);
|
|
131
|
+
this._community._changeStateEmitEventEmitStateChangeEvent({
|
|
132
|
+
event: { name: "error", args: [error] },
|
|
133
|
+
newUpdatingState: "waiting-retry"
|
|
134
|
+
});
|
|
135
|
+
this._ipnsLoadingOperation.retry(e);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async updateOnce() {
|
|
142
|
+
const log = Logger("pkc-js:remote-community:update");
|
|
143
|
+
this._ipnsLoadingOperation = retry.operation({ forever: true, factor: 2, maxTimeout: 30000 });
|
|
144
|
+
const communityLoadingRes = await this._retryLoadingCommunityAddress(this._community.address); // will return undefined if no new community CID is found
|
|
145
|
+
this._ipnsLoadingOperation.stop();
|
|
146
|
+
if (communityLoadingRes && "aborted" in communityLoadingRes) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
else if (communityLoadingRes && "criticalError" in communityLoadingRes) {
|
|
150
|
+
// Log individual gateway errors separately to avoid Node.js [Object] truncation
|
|
151
|
+
if (communityLoadingRes.criticalError instanceof FailedToFetchCommunityFromGatewaysError) {
|
|
152
|
+
for (const [gatewayUrl, gatewayError] of Object.entries(communityLoadingRes.criticalError.details.gatewayToError)) {
|
|
153
|
+
log.error(`Community ${this._community.address} gateway ${gatewayUrl} non-retriable error:`, gatewayError);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
log.error(`Community ${this._community.address} encountered a non retriable error while updating, will emit an error event and mark invalid cid to not be loaded again`, communityLoadingRes.criticalError);
|
|
157
|
+
this._community._changeStateEmitEventEmitStateChangeEvent({
|
|
158
|
+
event: { name: "error", args: [communityLoadingRes.criticalError] },
|
|
159
|
+
newUpdatingState: "failed"
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
else if (communityLoadingRes?.community &&
|
|
163
|
+
(this._community.raw.communityIpfs?.updatedAt || 0) < communityLoadingRes.community.updatedAt) {
|
|
164
|
+
this._community.initCommunityIpfsPropsNoMerge(communityLoadingRes.community);
|
|
165
|
+
this._community.updateCid = communityLoadingRes.cid;
|
|
166
|
+
// If we just discovered a name, trigger background resolution now (don't wait for next loop)
|
|
167
|
+
if (!isStringDomain(this._community.address) &&
|
|
168
|
+
this._community.name &&
|
|
169
|
+
this._community.publicKey &&
|
|
170
|
+
typeof this._community.nameResolved !== "boolean") {
|
|
171
|
+
this._resolveNameInBackground(this._community.name);
|
|
172
|
+
}
|
|
173
|
+
log(`Remote Community`, this._community.address, `received a new update. Will emit an update event with updatedAt`, this._community.updatedAt, "that's", timestamp() - this._community.updatedAt, "seconds old");
|
|
174
|
+
this._community._changeStateEmitEventEmitStateChangeEvent({
|
|
175
|
+
event: { name: "update", args: [this._community] },
|
|
176
|
+
newUpdatingState: "succeeded"
|
|
177
|
+
});
|
|
178
|
+
this._resolvePageAuthorNamesInBackground();
|
|
179
|
+
}
|
|
180
|
+
else if (communityLoadingRes === undefined) {
|
|
181
|
+
// we loaded a community record that we already consumed
|
|
182
|
+
// we will retry later
|
|
183
|
+
this._community._setUpdatingStateWithEventEmissionIfNewState("waiting-retry");
|
|
184
|
+
}
|
|
185
|
+
else if (communityLoadingRes?.community) {
|
|
186
|
+
this._community._setUpdatingStateWithEventEmissionIfNewState("succeeded");
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
async startUpdatingLoop() {
|
|
190
|
+
const log = Logger("pkc-js:remote-community:update");
|
|
191
|
+
this._community._createStopAbortController();
|
|
192
|
+
const areWeConnectedToKuboOrHelia = Object.keys(this._pkc.clients.kuboRpcClients).length > 0 || Object.keys(this._pkc.clients.libp2pJsClients).length > 0;
|
|
193
|
+
const updateInterval = areWeConnectedToKuboOrHelia ? 1000 : this._pkc.updateInterval; // if we're on helia or kubo we should resolve IPNS every second
|
|
194
|
+
while (this._community.state === "updating" && !this._community._getStopAbortSignal()?.aborted) {
|
|
195
|
+
try {
|
|
196
|
+
await this.updateOnce();
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
log.error(`Failed to update community ${this._community.address} for this iteration, will retry later`, e);
|
|
200
|
+
}
|
|
201
|
+
finally {
|
|
202
|
+
await new Promise((resolve) => {
|
|
203
|
+
const stopSignal = this._community._getStopAbortSignal();
|
|
204
|
+
if (stopSignal?.aborted)
|
|
205
|
+
return resolve();
|
|
206
|
+
const timer = setTimeout(resolve, updateInterval);
|
|
207
|
+
stopSignal?.addEventListener("abort", () => {
|
|
208
|
+
clearTimeout(timer);
|
|
209
|
+
resolve();
|
|
210
|
+
}, { once: true });
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
this._community._clearStopAbortController();
|
|
215
|
+
log("Community", this._community.address, "is no longer updating");
|
|
216
|
+
}
|
|
217
|
+
async stopUpdatingLoop() {
|
|
218
|
+
this._ipnsLoadingOperation?.stop();
|
|
219
|
+
this._updateCidsAlreadyLoaded.clear();
|
|
220
|
+
}
|
|
221
|
+
// fetching community ipns here
|
|
222
|
+
async _resolveCommunityNameWithoutUpdatingState({ communityAddress, abortSignal }) {
|
|
223
|
+
this._suppressUpdatingStateForNameResolution++;
|
|
224
|
+
try {
|
|
225
|
+
return await this.resolveCommunityNameIfNeeded({ communityAddress, abortSignal });
|
|
226
|
+
}
|
|
227
|
+
finally {
|
|
228
|
+
this._suppressUpdatingStateForNameResolution--;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
_resolveNameInBackground(name) {
|
|
232
|
+
const log = Logger("pkc-js:community-client-manager:_resolveNameInBackground");
|
|
233
|
+
const setNameResolvedAndEmitUpdate = (newNameResolved) => {
|
|
234
|
+
if (this._community.nameResolved === newNameResolved)
|
|
235
|
+
return;
|
|
236
|
+
this._community.nameResolved = newNameResolved;
|
|
237
|
+
// Only emit update if the community has been loaded at least once —
|
|
238
|
+
// otherwise we'd fire a premature "update" before the IPNS fetch completes.
|
|
239
|
+
if (typeof this._community.updatedAt === "number") {
|
|
240
|
+
this._community.emit("update", this._community);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
this._resolveCommunityNameWithoutUpdatingState({
|
|
244
|
+
communityAddress: name,
|
|
245
|
+
abortSignal: this._community._getStopAbortSignal()
|
|
246
|
+
})
|
|
247
|
+
.then((resolved) => {
|
|
248
|
+
if (resolved && resolved !== this._community.publicKey) {
|
|
249
|
+
// Key change detected: name now points to a different key.
|
|
250
|
+
// Most likely: cached publicKey is stale after community key migration.
|
|
251
|
+
log("Key migration detected for", name, "old:", this._community.publicKey, "new:", resolved);
|
|
252
|
+
const previousPublicKey = this._community.publicKey;
|
|
253
|
+
const error = new PKCError("ERR_COMMUNITY_NAME_RESOLVES_TO_DIFFERENT_PUBLIC_KEY", {
|
|
254
|
+
communityName: name,
|
|
255
|
+
previousPublicKey,
|
|
256
|
+
newPublicKey: resolved
|
|
257
|
+
});
|
|
258
|
+
// Clear all data immediately (old data may be from compromised key)
|
|
259
|
+
this._community._clearDataForKeyMigration(resolved);
|
|
260
|
+
this._updateCidsAlreadyLoaded.clear();
|
|
261
|
+
this._community.nameResolved = true;
|
|
262
|
+
// Abort in-flight fetch (using old key) by aborting the stop controller,
|
|
263
|
+
// then immediately create a new one so the update loop continues.
|
|
264
|
+
this._community._abortStopOperations("Key migration: name resolved to different public key");
|
|
265
|
+
this._community._createStopAbortController();
|
|
266
|
+
// Emit update so UI drops stale data right away
|
|
267
|
+
this._community.emit("update", this._community);
|
|
268
|
+
this._community.emit("error", error);
|
|
269
|
+
}
|
|
270
|
+
else if (resolved) {
|
|
271
|
+
setNameResolvedAndEmitUpdate(true);
|
|
272
|
+
}
|
|
273
|
+
// If resolved is null but community has a name, the name is not resolving
|
|
274
|
+
if (!resolved && this._community.name) {
|
|
275
|
+
setNameResolvedAndEmitUpdate(false);
|
|
276
|
+
}
|
|
277
|
+
})
|
|
278
|
+
.catch((e) => {
|
|
279
|
+
if (e instanceof PKCError && (e.code === "ERR_NO_RESOLVER_FOR_NAME" || e.code === "ERR_DOMAIN_TXT_RECORD_NOT_FOUND")) {
|
|
280
|
+
// Definitive: either no resolver can handle this TLD, or the domain has no community TXT record.
|
|
281
|
+
setNameResolvedAndEmitUpdate(false);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
log.trace("Background name resolution failed for", name, e);
|
|
285
|
+
// Transient failure -- leave nameResolved as undefined
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
_resolvePageAuthorNamesInBackground() {
|
|
290
|
+
if (!this._pkc.resolveAuthorNames)
|
|
291
|
+
return;
|
|
292
|
+
const pages = this._community.posts?.pages;
|
|
293
|
+
if (!pages)
|
|
294
|
+
return;
|
|
295
|
+
const authors = [];
|
|
296
|
+
for (const page of Object.values(pages)) {
|
|
297
|
+
if (!page)
|
|
298
|
+
continue;
|
|
299
|
+
for (const comment of page.comments) {
|
|
300
|
+
const domain = getAuthorDomainFromRuntime(comment.author);
|
|
301
|
+
if (domain && typeof comment.author.nameResolved !== "boolean") {
|
|
302
|
+
authors.push({ authorName: domain, signaturePublicKey: comment.signature.publicKey });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (authors.length === 0)
|
|
307
|
+
return;
|
|
308
|
+
this.resolveAuthorNamesInBackground({
|
|
309
|
+
authors,
|
|
310
|
+
onResolved: () => {
|
|
311
|
+
// Silently re-apply cache to all pages — no update emission.
|
|
312
|
+
// Only community.nameResolved changes should emit updates (handled by _resolveNameInBackground).
|
|
313
|
+
for (const page of Object.values(this._community.posts?.pages || {})) {
|
|
314
|
+
if (page)
|
|
315
|
+
this._community.posts._applyNameResolvedCacheToPage(page);
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
abortSignal: this._community._getStopAbortSignal()
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
async fetchNewUpdateForCommunity(subAddress) {
|
|
322
|
+
return this._withInflightCommunityFetch(subAddress, async () => {
|
|
323
|
+
let ipnsName;
|
|
324
|
+
const isDomain = isStringDomain(subAddress);
|
|
325
|
+
if (this._community.publicKey && (isDomain || (!isDomain && this._community.name && this._community.nameResolved === true))) {
|
|
326
|
+
// Once a domain has been verified against a public key, keep fetching through the current public key
|
|
327
|
+
// even if the immutable address on the instance is a raw IPNS key.
|
|
328
|
+
ipnsName = this._community.publicKey;
|
|
329
|
+
if (isDomain)
|
|
330
|
+
this._resolveNameInBackground(subAddress);
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
// Name only or publicKey only: use existing resolution flow
|
|
334
|
+
ipnsName = await this.resolveCommunityNameIfNeeded({
|
|
335
|
+
communityAddress: subAddress,
|
|
336
|
+
abortSignal: this._community._getStopAbortSignal()
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
// When loaded by raw IPNS key, verify the record's name claim in background (once)
|
|
340
|
+
if (!isDomain && this._community.name && this._community.publicKey && typeof this._community.nameResolved !== "boolean") {
|
|
341
|
+
this._resolveNameInBackground(this._community.name);
|
|
342
|
+
}
|
|
343
|
+
if (!ipnsName)
|
|
344
|
+
throw Error("Failed to resolve community address to an IPNS name");
|
|
345
|
+
// If the community address is a domain, we need to update the ipnsName and ipns pubsub props
|
|
346
|
+
// even if we fail to load the IPNS record, so that pubsub can work correctly
|
|
347
|
+
if (this._community.ipnsName !== ipnsName) {
|
|
348
|
+
this._community.ipnsName = ipnsName;
|
|
349
|
+
this._community.ipnsPubsubTopic = ipnsNameToIpnsOverPubsubTopic(ipnsName);
|
|
350
|
+
this._community.ipnsPubsubTopicRoutingCid = pubsubTopicToDhtKey(this._community.ipnsPubsubTopic);
|
|
351
|
+
}
|
|
352
|
+
if (this._community.updateCid)
|
|
353
|
+
this._updateCidsAlreadyLoaded.add(this._community.updateCid);
|
|
354
|
+
// This function should fetch CommunityIpfs, parse it and verify its signature
|
|
355
|
+
// Then return CommunityIpfs
|
|
356
|
+
// only exception is if the ipnsRecord.value (ipfs path) has already been loaded and stored in this._updateCidsAlreadyLoaded
|
|
357
|
+
// in that case no need to fetch the communityIpfs, we will return undefined
|
|
358
|
+
this._community._setUpdatingStateWithEventEmissionIfNewState("fetching-ipns");
|
|
359
|
+
let subRes;
|
|
360
|
+
const areWeConnectedToKuboOrHelia = Object.keys(this._pkc.clients.kuboRpcClients).length > 0 || Object.keys(this._pkc.clients.libp2pJsClients).length > 0;
|
|
361
|
+
if (areWeConnectedToKuboOrHelia) {
|
|
362
|
+
const kuboRpcOrHelia = this.getDefaultKuboRpcClientOrHelia();
|
|
363
|
+
// we're connected to kubo or helia
|
|
364
|
+
try {
|
|
365
|
+
subRes = await this._fetchCommunityIpnsP2PAndVerify(ipnsName);
|
|
366
|
+
}
|
|
367
|
+
catch (e) {
|
|
368
|
+
//@ts-expect-error
|
|
369
|
+
e.details = {
|
|
370
|
+
//@ts-expect-error
|
|
371
|
+
...e.details,
|
|
372
|
+
ipnsName,
|
|
373
|
+
subAddress,
|
|
374
|
+
ipnsPubsubTopic: this._community.ipnsPubsubTopic,
|
|
375
|
+
ipnsPubsubTopicRoutingCid: this._community.ipnsPubsubTopicRoutingCid
|
|
376
|
+
};
|
|
377
|
+
throw e;
|
|
378
|
+
}
|
|
379
|
+
finally {
|
|
380
|
+
if ("_helia" in kuboRpcOrHelia)
|
|
381
|
+
this.updateLibp2pJsClientState("stopped", kuboRpcOrHelia._libp2pJsClientsOptions.key);
|
|
382
|
+
else
|
|
383
|
+
this.updateKuboRpcState("stopped", kuboRpcOrHelia.url);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
else
|
|
387
|
+
subRes = await this._fetchCommunityFromGateways(ipnsName); // let's use gateways to fetch because we're not connected to kubo or helia
|
|
388
|
+
// States of gateways should be updated by fetchFromMultipleGateways
|
|
389
|
+
// Community records are verified within _fetchCommunityFromGateways
|
|
390
|
+
if (subRes?.community) {
|
|
391
|
+
// we found a new record that is verified
|
|
392
|
+
// Compute address from wire record (old records have address, new records derive from name/publicKey)
|
|
393
|
+
const recordAddress = this._deriveAddressFromWireRecord(subRes.community);
|
|
394
|
+
this._pkc._memCaches.communityForPublishing.set(recordAddress, {
|
|
395
|
+
encryption: subRes.community.encryption,
|
|
396
|
+
pubsubTopic: subRes.community.pubsubTopic,
|
|
397
|
+
address: recordAddress,
|
|
398
|
+
publicKey: getPKCAddressFromPublicKeySync(subRes.community.signature.publicKey),
|
|
399
|
+
name: subRes.community.name
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
return subRes;
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
async _fetchCommunityIpnsP2PAndVerify(ipnsName) {
|
|
406
|
+
const log = Logger("pkc-js:clients-manager:_fetchCommunityIpnsP2PAndVerify");
|
|
407
|
+
const kuboRpcOrHelia = this.getDefaultKuboRpcClientOrHelia();
|
|
408
|
+
if ("_helia" in kuboRpcOrHelia) {
|
|
409
|
+
this.updateLibp2pJsClientState("fetching-ipns", kuboRpcOrHelia._libp2pJsClientsOptions.key);
|
|
410
|
+
}
|
|
411
|
+
else
|
|
412
|
+
this.updateKuboRpcState("fetching-ipns", kuboRpcOrHelia.url);
|
|
413
|
+
const latestCommunityCid = await this.resolveIpnsToCidP2P(ipnsName, {
|
|
414
|
+
timeoutMs: this._pkc._timeouts["community-ipns"],
|
|
415
|
+
abortSignal: this._community._getStopAbortSignal()
|
|
416
|
+
});
|
|
417
|
+
log.trace(`Resolved community IPNS`, ipnsName, `to CID`, latestCommunityCid);
|
|
418
|
+
if (this._updateCidsAlreadyLoaded.has(latestCommunityCid)) {
|
|
419
|
+
log.trace("Resolved community IPNS", ipnsName, "to a cid that we already loaded before. No need to fetch its ipfs", latestCommunityCid);
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
422
|
+
if ("_helia" in kuboRpcOrHelia)
|
|
423
|
+
this.updateLibp2pJsClientState("fetching-ipfs", kuboRpcOrHelia._libp2pJsClientsOptions.key);
|
|
424
|
+
else
|
|
425
|
+
this.updateKuboRpcState("fetching-ipfs", kuboRpcOrHelia.url);
|
|
426
|
+
this._community._setUpdatingStateWithEventEmissionIfNewState("fetching-ipfs");
|
|
427
|
+
let rawCommunityJsonString;
|
|
428
|
+
try {
|
|
429
|
+
rawCommunityJsonString = await this._fetchCidP2P(latestCommunityCid, {
|
|
430
|
+
maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS,
|
|
431
|
+
timeoutMs: this._pkc._timeouts["community-ipfs"],
|
|
432
|
+
abortSignal: this._community._getStopAbortSignal()
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
catch (e) {
|
|
436
|
+
//@ts-expect-error
|
|
437
|
+
e.details = {
|
|
438
|
+
//@ts-expect-error
|
|
439
|
+
...e.details,
|
|
440
|
+
communityIpnsName: ipnsName,
|
|
441
|
+
ipnsPubsubTopic: this._community.ipnsPubsubTopic,
|
|
442
|
+
ipnsPubsubTopicRoutingCid: this._community.ipnsPubsubTopicRoutingCid,
|
|
443
|
+
communityCid: latestCommunityCid
|
|
444
|
+
};
|
|
445
|
+
if (e instanceof PKCError && e.code === "ERR_OVER_DOWNLOAD_LIMIT")
|
|
446
|
+
this._updateCidsAlreadyLoaded.add(latestCommunityCid);
|
|
447
|
+
throw e;
|
|
448
|
+
}
|
|
449
|
+
this._updateCidsAlreadyLoaded.add(latestCommunityCid);
|
|
450
|
+
try {
|
|
451
|
+
const communityIpfs = parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(rawCommunityJsonString));
|
|
452
|
+
const errInRecord = await this._findErrorInCommunityRecord(communityIpfs, ipnsName, latestCommunityCid);
|
|
453
|
+
if (errInRecord)
|
|
454
|
+
throw errInRecord;
|
|
455
|
+
return { community: communityIpfs, cid: latestCommunityCid };
|
|
456
|
+
}
|
|
457
|
+
catch (e) {
|
|
458
|
+
// invalid community record
|
|
459
|
+
e.details = {
|
|
460
|
+
...e.details,
|
|
461
|
+
cidOfCommunityIpns: latestCommunityCid,
|
|
462
|
+
ipnsPubsubTopic: this._community.ipnsPubsubTopic,
|
|
463
|
+
ipnsPubsubTopicRoutingCid: this._community.ipnsPubsubTopicRoutingCid
|
|
464
|
+
};
|
|
465
|
+
throw e;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
async _fetchCommunityFromGateways(ipnsName) {
|
|
469
|
+
const log = Logger("pkc-js:community:fetchCommunityFromGateways");
|
|
470
|
+
const concurrencyLimit = 3;
|
|
471
|
+
const timeoutMs = this._pkc._timeouts["community-ipns"];
|
|
472
|
+
const queueLimit = pLimit(concurrencyLimit);
|
|
473
|
+
// Only sort if we have more than 3 gateways
|
|
474
|
+
const gatewaysSorted = remeda.keys.strict(this._pkc.clients.ipfsGateways).length <= concurrencyLimit
|
|
475
|
+
? remeda.keys.strict(this._pkc.clients.ipfsGateways)
|
|
476
|
+
: await this._pkc._stats.sortGatewaysAccordingToScore("ipns");
|
|
477
|
+
// need to handle
|
|
478
|
+
// if all gateways returned the same community.updateCid
|
|
479
|
+
const gatewayFetches = {};
|
|
480
|
+
for (const gatewayUrl of gatewaysSorted) {
|
|
481
|
+
const abortController = new AbortController();
|
|
482
|
+
const throwIfGatewayRespondsWithInvalidCommunity = async (gatewayRes) => {
|
|
483
|
+
if (typeof gatewayRes.resText !== "string")
|
|
484
|
+
throw Error("Gateway response has no body");
|
|
485
|
+
// get ipfs cid of IPNS from header or calculate it
|
|
486
|
+
const calculatedCommunityCidFromBody = await this.calculateIpfsCid(gatewayRes.resText); // cid v0
|
|
487
|
+
if (this._updateCidsAlreadyLoaded.has(calculatedCommunityCidFromBody))
|
|
488
|
+
throw new PKCError("ERR_GATEWAY_ABORTING_LOADING_COMMUNITY_BECAUSE_WE_ALREADY_LOADED_THIS_RECORD", {
|
|
489
|
+
calculatedCommunityCidFromBody,
|
|
490
|
+
ipnsName,
|
|
491
|
+
ipnsPubsubTopic: this._community.ipnsPubsubTopic,
|
|
492
|
+
ipnsPubsubTopicRoutingCid: this._community.ipnsPubsubTopicRoutingCid,
|
|
493
|
+
gatewayRes,
|
|
494
|
+
gatewayUrl
|
|
495
|
+
});
|
|
496
|
+
this._updateCidsAlreadyLoaded.add(calculatedCommunityCidFromBody);
|
|
497
|
+
let communityIpfs;
|
|
498
|
+
try {
|
|
499
|
+
communityIpfs = parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(gatewayRes.resText));
|
|
500
|
+
}
|
|
501
|
+
catch (e) {
|
|
502
|
+
e.details = {
|
|
503
|
+
...e.details,
|
|
504
|
+
cidOfCommunityIpns: calculatedCommunityCidFromBody,
|
|
505
|
+
ipnsPubsubTopic: this._community.ipnsPubsubTopic,
|
|
506
|
+
ipnsPubsubTopicRoutingCid: this._community.ipnsPubsubTopicRoutingCid
|
|
507
|
+
};
|
|
508
|
+
throw e;
|
|
509
|
+
}
|
|
510
|
+
const errorWithinRecord = await this._findErrorInCommunityRecord(communityIpfs, ipnsName, calculatedCommunityCidFromBody);
|
|
511
|
+
if (errorWithinRecord) {
|
|
512
|
+
delete errorWithinRecord["stack"];
|
|
513
|
+
if (errorWithinRecord.code === "ERR_COMMUNITY_SIGNATURE_IS_INVALID") {
|
|
514
|
+
const log = Logger("pkc-js:community-client-manager:throwIfGatewayRespondsWithInvalidCommunity");
|
|
515
|
+
const etag = gatewayRes?.res?.headers?.get("etag");
|
|
516
|
+
log.error(`Gateway ${gatewayUrl} returned community record with invalid signature. ` +
|
|
517
|
+
`Reason: ${errorWithinRecord.details?.signatureValidity?.reason}. ` +
|
|
518
|
+
`Client-computed CID: ${calculatedCommunityCidFromBody}. ` +
|
|
519
|
+
`Etag header (Kubo CID): ${etag}. ` +
|
|
520
|
+
`updatedAt: ${communityIpfs.updatedAt}. ` +
|
|
521
|
+
`Response body: ${gatewayRes.resText}`);
|
|
522
|
+
}
|
|
523
|
+
throw errorWithinRecord;
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
gatewayFetches[gatewayUrl].communityRecord = communityIpfs;
|
|
527
|
+
gatewayFetches[gatewayUrl].cid = calculatedCommunityCidFromBody;
|
|
528
|
+
// Log the TTL from max-age header after successfully setting the community record
|
|
529
|
+
const cacheControl = gatewayRes?.res?.headers?.get("cache-control");
|
|
530
|
+
if (cacheControl) {
|
|
531
|
+
const maxAgeMatch = cacheControl.match(/max-age=(\d+)/);
|
|
532
|
+
if (maxAgeMatch && maxAgeMatch[1]) {
|
|
533
|
+
const ttl = parseInt(maxAgeMatch[1]);
|
|
534
|
+
gatewayFetches[gatewayUrl].ttl = ttl;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
const checkResponseHeadersIfOldCid = async (gatewayRes) => {
|
|
540
|
+
const cidOfIpnsFromEtagHeader = gatewayRes?.headers?.get("etag")?.toString();
|
|
541
|
+
// If etag is missing, skip early-abort optimization and let the body be fetched
|
|
542
|
+
if (!cidOfIpnsFromEtagHeader) {
|
|
543
|
+
return; // Continue to fetch and validate the body normally
|
|
544
|
+
}
|
|
545
|
+
let parsedCid;
|
|
546
|
+
try {
|
|
547
|
+
// clean up W/ prefix and quotes from the etag header
|
|
548
|
+
parsedCid = CID.parse(cidOfIpnsFromEtagHeader.replace(/^W\//, "").split('"').join("")).toV0().toString();
|
|
549
|
+
}
|
|
550
|
+
catch (e) {
|
|
551
|
+
// Malformed etag header - skip optimization and let body be fetched
|
|
552
|
+
return; // Continue to fetch and validate the body normally
|
|
553
|
+
}
|
|
554
|
+
if (this._updateCidsAlreadyLoaded.has(parsedCid)) {
|
|
555
|
+
abortController.abort("Aborting community IPNS request because we already loaded this record");
|
|
556
|
+
return new PKCError("ERR_GATEWAY_ABORTING_LOADING_COMMUNITY_BECAUSE_WE_ALREADY_LOADED_THIS_RECORD", {
|
|
557
|
+
cidOfIpnsFromEtagHeader,
|
|
558
|
+
ipnsName,
|
|
559
|
+
gatewayRes,
|
|
560
|
+
gatewayUrl
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
const requestHeaders = this._updateCidsAlreadyLoaded.size > 0
|
|
565
|
+
? { "If-None-Match": '"' + Array.from(this._updateCidsAlreadyLoaded.values()).join(",") + '"' } // tell the gateway we already loaded these records
|
|
566
|
+
: undefined;
|
|
567
|
+
gatewayFetches[gatewayUrl] = {
|
|
568
|
+
abortController,
|
|
569
|
+
promise: queueLimit(() => this._fetchWithGateway(gatewayUrl, {
|
|
570
|
+
recordIpfsType: "ipns",
|
|
571
|
+
root: ipnsName,
|
|
572
|
+
recordPKCType: "community",
|
|
573
|
+
validateGatewayResponseFunc: throwIfGatewayRespondsWithInvalidCommunity,
|
|
574
|
+
abortRequestErrorBeforeLoadingBodyFunc: checkResponseHeadersIfOldCid,
|
|
575
|
+
abortController,
|
|
576
|
+
maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS,
|
|
577
|
+
timeoutMs: this._pkc._timeouts["community-ipns"],
|
|
578
|
+
log,
|
|
579
|
+
requestHeaders: requestHeaders
|
|
580
|
+
})),
|
|
581
|
+
timeoutId: setTimeout(() => abortController.abort("Aborting community IPNS request because it timed out after " + timeoutMs + "ms"), timeoutMs)
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
const stopSignal = this._community._getStopAbortSignal();
|
|
585
|
+
const onStopAbort = () => cleanUp();
|
|
586
|
+
const cleanUp = () => {
|
|
587
|
+
queueLimit.clearQueue();
|
|
588
|
+
Object.values(gatewayFetches).forEach((gateway) => {
|
|
589
|
+
if (!gateway.communityRecord && !gateway.error)
|
|
590
|
+
gateway.abortController.abort("Cleaning up requests for community");
|
|
591
|
+
clearTimeout(gateway.timeoutId);
|
|
592
|
+
});
|
|
593
|
+
if (stopSignal)
|
|
594
|
+
stopSignal.removeEventListener("abort", onStopAbort);
|
|
595
|
+
};
|
|
596
|
+
if (stopSignal) {
|
|
597
|
+
throwIfAbortSignalAborted(stopSignal);
|
|
598
|
+
stopSignal.addEventListener("abort", onStopAbort, { once: true });
|
|
599
|
+
}
|
|
600
|
+
const _findRecentCommunity = () => {
|
|
601
|
+
// Try to find a very recent community
|
|
602
|
+
// If not then go with the most recent community record after fetching from 3 gateways
|
|
603
|
+
const gatewaysWithCommunity = remeda.keys
|
|
604
|
+
.strict(gatewayFetches)
|
|
605
|
+
.filter((gatewayUrl) => gatewayFetches[gatewayUrl].communityRecord);
|
|
606
|
+
if (gatewaysWithCommunity.length === 0)
|
|
607
|
+
return undefined;
|
|
608
|
+
const currentUpdatedAt = this._community.raw.communityIpfs?.updatedAt || 0;
|
|
609
|
+
const totalGateways = gatewaysSorted.length;
|
|
610
|
+
const gatewaysWithError = remeda.keys.strict(gatewayFetches).filter((gatewayUrl) => gatewayFetches[gatewayUrl].error);
|
|
611
|
+
const bestGatewayUrl = (remeda.maxBy(gatewaysWithCommunity, (gatewayUrl) => gatewayFetches[gatewayUrl].communityRecord.updatedAt));
|
|
612
|
+
const bestGatewayRecordAge = timestamp() - gatewayFetches[bestGatewayUrl].communityRecord.updatedAt; // how old is the record, relative to now, in seconds
|
|
613
|
+
if (gatewayFetches[bestGatewayUrl].communityRecord.updatedAt > currentUpdatedAt) {
|
|
614
|
+
const bestCommunityRecord = gatewayFetches[bestGatewayUrl].communityRecord;
|
|
615
|
+
log(`Gateway (${bestGatewayUrl}) was able to find a very recent community (${this._deriveAddressFromWireRecord(bestCommunityRecord)}) whose IPNS is (${ipnsName}). The record has updatedAt (${bestCommunityRecord.updatedAt}) that's ${bestGatewayRecordAge}s old with a TTL of ${gatewayFetches[bestGatewayUrl].ttl} seconds`);
|
|
616
|
+
return { community: bestCommunityRecord, cid: gatewayFetches[bestGatewayUrl].cid };
|
|
617
|
+
}
|
|
618
|
+
// We weren't able to find any new community records
|
|
619
|
+
if (gatewaysWithError.length + gatewaysWithCommunity.length === totalGateways)
|
|
620
|
+
return undefined;
|
|
621
|
+
};
|
|
622
|
+
const promisesToIterate = (Object.values(gatewayFetches).map((gatewayFetch) => gatewayFetch.promise));
|
|
623
|
+
let suitableCommunity;
|
|
624
|
+
try {
|
|
625
|
+
suitableCommunity = await new Promise((resolve, reject) => promisesToIterate.map((gatewayPromise, i) => gatewayPromise
|
|
626
|
+
.then(async (res) => {
|
|
627
|
+
if ("error" in res)
|
|
628
|
+
Object.values(gatewayFetches)[i].error = res.error;
|
|
629
|
+
const gatewaysWithError = remeda.keys
|
|
630
|
+
.strict(gatewayFetches)
|
|
631
|
+
.filter((gatewayUrl) => gatewayFetches[gatewayUrl].error);
|
|
632
|
+
if (gatewaysWithError.length === gatewaysSorted.length)
|
|
633
|
+
// All gateways failed
|
|
634
|
+
reject("All gateways failed to fetch community record " + ipnsName);
|
|
635
|
+
const recentCommunity = _findRecentCommunity();
|
|
636
|
+
if (recentCommunity) {
|
|
637
|
+
cleanUp();
|
|
638
|
+
resolve(recentCommunity);
|
|
639
|
+
}
|
|
640
|
+
})
|
|
641
|
+
.catch((err) => reject("One of the gateway promise requests thrown an error, should not happens:" + err))));
|
|
642
|
+
}
|
|
643
|
+
catch {
|
|
644
|
+
cleanUp();
|
|
645
|
+
throwIfAbortSignalAborted(stopSignal);
|
|
646
|
+
const gatewayToError = remeda.mapValues(gatewayFetches, (gatewayFetch) => gatewayFetch.error);
|
|
647
|
+
const hasGatewayConfirmingCurrentRecord = Object.keys(gatewayFetches)
|
|
648
|
+
.map((gatewayUrl) => gatewayFetches[gatewayUrl].error)
|
|
649
|
+
.some((err) => err.details?.status === 304 ||
|
|
650
|
+
err.code === "ERR_GATEWAY_ABORTING_LOADING_COMMUNITY_BECAUSE_WE_ALREADY_LOADED_THIS_RECORD");
|
|
651
|
+
if (hasGatewayConfirmingCurrentRecord)
|
|
652
|
+
return undefined; // any gateway confirmed we already have the latest consumed record
|
|
653
|
+
const combinedError = new FailedToFetchCommunityFromGatewaysError({
|
|
654
|
+
ipnsName,
|
|
655
|
+
gatewayToError,
|
|
656
|
+
communityAddress: this._community.address,
|
|
657
|
+
ipnsPubsubTopic: this._community.ipnsPubsubTopic,
|
|
658
|
+
ipnsPubsubTopicRoutingCid: this._community.ipnsPubsubTopicRoutingCid
|
|
659
|
+
});
|
|
660
|
+
delete combinedError.stack;
|
|
661
|
+
throw combinedError;
|
|
662
|
+
}
|
|
663
|
+
// TODO add punishment for gateway that returns old ipns record
|
|
664
|
+
// TODO add punishment for gateway that returns invalid community
|
|
665
|
+
return suitableCommunity;
|
|
666
|
+
}
|
|
667
|
+
async _findErrorInCommunityRecord(communityJson, ipnsNameOfCommunity, cidOfCommunityIpns) {
|
|
668
|
+
const communityInstanceAddress = this._getCommunityAddressFromInstance();
|
|
669
|
+
const recordAddress = this._deriveAddressFromWireRecord(communityJson);
|
|
670
|
+
const addressMatchesInstance = this._areEquivalentCommunityAddresses(recordAddress, communityInstanceAddress);
|
|
671
|
+
// When address is a domain but we loaded via publicKey fallback, the record's derived address
|
|
672
|
+
// might be the publicKey (if the record has no name field) — also accept that as a match
|
|
673
|
+
const addressMatchesPublicKey = this._community.publicKey
|
|
674
|
+
? this._areEquivalentCommunityAddresses(recordAddress, this._community.publicKey)
|
|
675
|
+
: false;
|
|
676
|
+
// Accept when user loaded by raw IPNS key and the record's signature key matches.
|
|
677
|
+
// Handles: {address: "12D3Koo..."} loads record with name: "plebbit.bso".
|
|
678
|
+
// NOT applied for domain addresses (Scenario C stays rejected).
|
|
679
|
+
const instanceAddressIsDomain = isStringDomain(communityInstanceAddress);
|
|
680
|
+
const signatureKeyMatchesIpnsName = !instanceAddressIsDomain
|
|
681
|
+
? this._areEquivalentCommunityAddresses(getPKCAddressFromPublicKeySync(communityJson.signature.publicKey), ipnsNameOfCommunity)
|
|
682
|
+
: false;
|
|
683
|
+
if (!addressMatchesInstance && !addressMatchesPublicKey && !signatureKeyMatchesIpnsName) {
|
|
684
|
+
// Did the gateway supply us with a different community's ipns
|
|
685
|
+
const error = new PKCError("ERR_THE_COMMUNITY_IPNS_RECORD_POINTS_TO_DIFFERENT_ADDRESS_THAN_WE_EXPECTED", {
|
|
686
|
+
addressFromCommunityInstance: communityInstanceAddress,
|
|
687
|
+
ipnsName: ipnsNameOfCommunity,
|
|
688
|
+
addressFromGateway: recordAddress,
|
|
689
|
+
communityIpnsFromGateway: communityJson,
|
|
690
|
+
ipnsPubsubTopic: this._community.ipnsPubsubTopic,
|
|
691
|
+
ipnsPubsubTopicRoutingCid: this._community.ipnsPubsubTopicRoutingCid,
|
|
692
|
+
cidOfCommunityIpns
|
|
693
|
+
});
|
|
694
|
+
return error;
|
|
695
|
+
}
|
|
696
|
+
const verificationOpts = {
|
|
697
|
+
community: communityJson,
|
|
698
|
+
communityIpnsName: ipnsNameOfCommunity,
|
|
699
|
+
resolveAuthorNames: this._pkc.resolveAuthorNames,
|
|
700
|
+
clientsManager: this,
|
|
701
|
+
validatePages: this._pkc.validatePages,
|
|
702
|
+
abortSignal: this._community._getStopAbortSignal()
|
|
703
|
+
};
|
|
704
|
+
const updateValidity = await verifyCommunity(verificationOpts);
|
|
705
|
+
if (!updateValidity.valid) {
|
|
706
|
+
const error = new PKCError("ERR_COMMUNITY_SIGNATURE_IS_INVALID", {
|
|
707
|
+
signatureValidity: updateValidity,
|
|
708
|
+
ipnsPubsubTopic: this._community.ipnsPubsubTopic,
|
|
709
|
+
ipnsPubsubTopicRoutingCid: this._community.ipnsPubsubTopicRoutingCid,
|
|
710
|
+
verificationOpts,
|
|
711
|
+
cidOfCommunityIpns
|
|
712
|
+
});
|
|
713
|
+
return error;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
//# sourceMappingURL=community-client-manager.js.map
|