@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,888 @@
|
|
|
1
|
+
import { getDefaultDataPath, listCommunitiesSync as nodeListCommunities, createKuboRpcClient, monitorCommunitiesDirectory, tryToDeleteCommunitiesThatFailedToBeDeletedBefore } from "../runtime/browser/util.js";
|
|
2
|
+
import { Comment } from "../publications/comment/comment.js";
|
|
3
|
+
import { waitForUpdateInCommunityInstanceWithErrorAndTimeout, areEquivalentCommunityAddresses, deepMergeRuntimeFields, doesDomainAddressHaveCapitalLetter, hideClassPrivateProps, isStringDomain, removeUndefinedValuesRecursively, timestamp, resolveWhenPredicateIsTrue } from "../util.js";
|
|
4
|
+
import Vote from "../publications/vote/vote.js";
|
|
5
|
+
import { createSigner } from "../signer/index.js";
|
|
6
|
+
import { CommentEdit } from "../publications/comment-edit/comment-edit.js";
|
|
7
|
+
import Logger from "../logger.js";
|
|
8
|
+
import env from "../version.js";
|
|
9
|
+
import { verifyCommentIpfs, verifyCommentUpdate } from "../signer/signatures.js";
|
|
10
|
+
import Stats from "../stats.js";
|
|
11
|
+
import Storage from "../runtime/browser/storage.js";
|
|
12
|
+
import { PKCClientsManager } from "./pkc-client-manager.js";
|
|
13
|
+
import PKCRpcClient from "../clients/rpc-client/pkc-rpc-client.js";
|
|
14
|
+
import { PKCError } from "../pkc-error.js";
|
|
15
|
+
import { InflightFetchManager } from "../util/inflight-fetch-manager.js";
|
|
16
|
+
import LRUStorage from "../runtime/browser/lru-storage.js";
|
|
17
|
+
import { RemoteCommunity } from "../community/remote-community.js";
|
|
18
|
+
import { LocalCommunity } from "../runtime/browser/community/local-community.js";
|
|
19
|
+
import { extractCommunityRuntimeFieldsFromParsedPages } from "../pages/util.js";
|
|
20
|
+
import pTimeout, { TimeoutError } from "p-timeout";
|
|
21
|
+
import * as remeda from "remeda";
|
|
22
|
+
import { PubsubTopicSchema, CommunityIpfsSchema } from "../community/schema.js";
|
|
23
|
+
import { parseCidStringSchemaWithPKCErrorIfItFails, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, parseCommentIpfsSchemaWithPKCErrorIfItFails, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, parsePKCUserOptionsSchemaWithPKCErrorIfItFails, parseCommunityAddressWithPKCErrorIfItFails, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails } from "../schema/schema-util.js";
|
|
24
|
+
import { CommentModeration } from "../publications/comment-moderation/comment-moderation.js";
|
|
25
|
+
import { setupKuboAddressesRewriterAndHttpRouters } from "../runtime/browser/setup-kubo-address-rewriter-and-http-router.js";
|
|
26
|
+
import CommunityEdit from "../publications/community-edit/community-edit.js";
|
|
27
|
+
import { LRUCache } from "lru-cache";
|
|
28
|
+
import { PKCTypedEmitter } from "../clients/pkc-typed-emitter.js";
|
|
29
|
+
import { createLibp2pJsClientOrUseExistingOne } from "../helia/helia-for-pkc.js";
|
|
30
|
+
import { parseRpcAuthorNameParam, parseRpcCidParam, parseRpcCommunityLookupParam } from "../clients/rpc-client/rpc-schema-util.js";
|
|
31
|
+
import { cleanWireAuthor, normalizeCreatePublicationAuthor } from "../publications/publication-author.js";
|
|
32
|
+
import { TrackedInstanceRegistry } from "./tracked-instance-registry.js";
|
|
33
|
+
import { findUpdatingCommunity, listStartedCommunities, listUpdatingComments, listUpdatingCommunities } from "./tracked-instance-registry-util.js";
|
|
34
|
+
export class PKC extends PKCTypedEmitter {
|
|
35
|
+
constructor(options) {
|
|
36
|
+
super();
|
|
37
|
+
this._pubsubSubscriptions = {};
|
|
38
|
+
this._updatingCommunities = new TrackedInstanceRegistry(); // storing community instances that are getting updated rn
|
|
39
|
+
this._updatingComments = new TrackedInstanceRegistry(); // storing comment instancse that are getting updated rn
|
|
40
|
+
this._startedCommunities = new TrackedInstanceRegistry(); // storing community instances that are started rn
|
|
41
|
+
this.destroyed = false;
|
|
42
|
+
this._storageLRUs = {}; // Cache name to storage interface
|
|
43
|
+
this._timeouts = {
|
|
44
|
+
"community-ipns": 5 * 60 * 1000, // 5min, for resolving community IPNS, or fetching community from gateways
|
|
45
|
+
"community-ipfs": 60 * 1000, // 1min, for fetching community cid P2P
|
|
46
|
+
"comment-ipfs": 60 * 1000, // 1 min
|
|
47
|
+
"comment-update-ipfs": 2 * 60 * 1000, // 2 min
|
|
48
|
+
"page-ipfs": 30 * 1000, // 30s for pages
|
|
49
|
+
"generic-ipfs": 30 * 1000 // 30s generic ipfs
|
|
50
|
+
}; // timeout in ms for each load type when we're loading from kubo/helia/gateway
|
|
51
|
+
this._userPKCOptions = options;
|
|
52
|
+
this.parsedPKCOptions = parsePKCUserOptionsSchemaWithPKCErrorIfItFails(options);
|
|
53
|
+
// Make nameResolver function props non-enumerable so they're excluded from JSON serialization and spread
|
|
54
|
+
if (this.parsedPKCOptions.nameResolvers) {
|
|
55
|
+
for (const resolver of this.parsedPKCOptions.nameResolvers) {
|
|
56
|
+
Object.defineProperty(resolver, "resolve", {
|
|
57
|
+
enumerable: false,
|
|
58
|
+
value: resolver.resolve,
|
|
59
|
+
writable: true,
|
|
60
|
+
configurable: true
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(resolver, "canResolve", {
|
|
63
|
+
enumerable: false,
|
|
64
|
+
value: resolver.canResolve,
|
|
65
|
+
writable: true,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
68
|
+
if (resolver.destroy) {
|
|
69
|
+
Object.defineProperty(resolver, "destroy", {
|
|
70
|
+
enumerable: false,
|
|
71
|
+
value: resolver.destroy,
|
|
72
|
+
writable: true,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// initializing fields
|
|
79
|
+
this.pkcRpcClientsOptions = this.parsedPKCOptions.pkcRpcClientsOptions;
|
|
80
|
+
this.ipfsGatewayUrls = this.parsedPKCOptions.ipfsGatewayUrls =
|
|
81
|
+
this.pkcRpcClientsOptions || !this.parsedPKCOptions.ipfsGatewayUrls?.length ? undefined : this.parsedPKCOptions.ipfsGatewayUrls;
|
|
82
|
+
this.kuboRpcClientsOptions = this.parsedPKCOptions.kuboRpcClientsOptions = this.pkcRpcClientsOptions
|
|
83
|
+
? undefined
|
|
84
|
+
: this.parsedPKCOptions.kuboRpcClientsOptions;
|
|
85
|
+
// We default for ipfsHttpClientsOptions first, but if it's not defined we use the default from schema
|
|
86
|
+
this.pubsubKuboRpcClientsOptions = this.parsedPKCOptions.pubsubKuboRpcClientsOptions = this.pkcRpcClientsOptions
|
|
87
|
+
? undefined
|
|
88
|
+
: this._userPKCOptions.pubsubKuboRpcClientsOptions // did the user provide their own pubsub options
|
|
89
|
+
? this.parsedPKCOptions.pubsubKuboRpcClientsOptions // if not, then we use ipfsHttpClientOptions or defaults
|
|
90
|
+
: this.parsedPKCOptions.kuboRpcClientsOptions || this.parsedPKCOptions.pubsubKuboRpcClientsOptions;
|
|
91
|
+
this.libp2pJsClientsOptions = this.parsedPKCOptions.libp2pJsClientsOptions;
|
|
92
|
+
if (this.libp2pJsClientsOptions && (this.kuboRpcClientsOptions?.length || this.pubsubKuboRpcClientsOptions?.length))
|
|
93
|
+
throw new PKCError("ERR_CAN_NOT_HAVE_BOTH_KUBO_AND_LIBP2P_JS_CLIENTS_DEFINED", {
|
|
94
|
+
libp2pJsClientsOptions: this.libp2pJsClientsOptions,
|
|
95
|
+
kuboRpcClientsOptions: this.kuboRpcClientsOptions,
|
|
96
|
+
pubsubKuboRpcClientsOptions: this.pubsubKuboRpcClientsOptions
|
|
97
|
+
});
|
|
98
|
+
this.resolveAuthorNames = this.parsedPKCOptions.resolveAuthorNames;
|
|
99
|
+
this.publishInterval = this.parsedPKCOptions.publishInterval;
|
|
100
|
+
this.updateInterval = this.parsedPKCOptions.updateInterval;
|
|
101
|
+
this.noData = this.parsedPKCOptions.noData;
|
|
102
|
+
this.validatePages = this.parsedPKCOptions.validatePages;
|
|
103
|
+
this.userAgent = this.parsedPKCOptions.userAgent;
|
|
104
|
+
this.httpRoutersOptions = this.parsedPKCOptions.httpRoutersOptions;
|
|
105
|
+
this.settings = {
|
|
106
|
+
challenges: this.parsedPKCOptions.challenges
|
|
107
|
+
};
|
|
108
|
+
// nameResolvers contains functions that can't be serialized over RPC, so skip for RPC clients
|
|
109
|
+
this.nameResolvers = this.pkcRpcClientsOptions ? undefined : this.parsedPKCOptions.nameResolvers;
|
|
110
|
+
this.on("communitieschange", (newCommunities) => {
|
|
111
|
+
this.communities = newCommunities;
|
|
112
|
+
});
|
|
113
|
+
this._promiseToWaitForFirstCommunitieschangeEvent = new Promise((resolve) => this.once("communitieschange", resolve));
|
|
114
|
+
//@ts-expect-error
|
|
115
|
+
this.clients = {};
|
|
116
|
+
this._initKuboRpcClientsIfNeeded();
|
|
117
|
+
this._initKuboPubsubClientsIfNeeded();
|
|
118
|
+
this._initRpcClientsIfNeeded();
|
|
119
|
+
this._initIpfsGatewaysIfNeeded();
|
|
120
|
+
this._initMemCaches();
|
|
121
|
+
this._inflightFetchManager = new InflightFetchManager();
|
|
122
|
+
if (!this.noData && !this.pkcRpcClientsOptions)
|
|
123
|
+
this.dataPath = this.parsedPKCOptions.dataPath =
|
|
124
|
+
"dataPath" in this.parsedPKCOptions ? this.parsedPKCOptions.dataPath : getDefaultDataPath();
|
|
125
|
+
}
|
|
126
|
+
_initMemCaches() {
|
|
127
|
+
this._memCaches = {
|
|
128
|
+
communityVerificationCache: new LRUCache({ max: 100 }),
|
|
129
|
+
pageVerificationCache: new LRUCache({ max: 1000 }),
|
|
130
|
+
commentVerificationCache: new LRUCache({ max: 5000 }),
|
|
131
|
+
commentUpdateVerificationCache: new LRUCache({ max: 100_000 }),
|
|
132
|
+
commentIpfs: new LRUCache({ max: 10 }),
|
|
133
|
+
communityForPublishing: new LRUCache({
|
|
134
|
+
max: 100,
|
|
135
|
+
ttl: 600000
|
|
136
|
+
}),
|
|
137
|
+
pageCidToSortTypes: new LRUCache({ max: 5000 }),
|
|
138
|
+
pagesMaxSize: new LRUCache({ max: 50000 }),
|
|
139
|
+
nameResolvedCache: new LRUCache({ max: 5000 })
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
_initKuboRpcClientsIfNeeded() {
|
|
143
|
+
this.clients.kuboRpcClients = {};
|
|
144
|
+
if (!this.kuboRpcClientsOptions)
|
|
145
|
+
return;
|
|
146
|
+
for (const clientOptions of this.kuboRpcClientsOptions) {
|
|
147
|
+
const kuboRpcClient = createKuboRpcClient(clientOptions);
|
|
148
|
+
this.clients.kuboRpcClients[clientOptions.url.toString()] = {
|
|
149
|
+
_client: kuboRpcClient,
|
|
150
|
+
_clientOptions: clientOptions,
|
|
151
|
+
peers: kuboRpcClient.swarm.peers,
|
|
152
|
+
url: clientOptions.url.toString(),
|
|
153
|
+
destroy: async () => { }
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
_initKuboPubsubClientsIfNeeded() {
|
|
158
|
+
this.clients.pubsubKuboRpcClients = {};
|
|
159
|
+
if (!this.pubsubKuboRpcClientsOptions)
|
|
160
|
+
return;
|
|
161
|
+
for (const clientOptions of this.pubsubKuboRpcClientsOptions) {
|
|
162
|
+
const kuboRpcClient = createKuboRpcClient(clientOptions);
|
|
163
|
+
this.clients.pubsubKuboRpcClients[clientOptions.url.toString()] = {
|
|
164
|
+
_client: kuboRpcClient,
|
|
165
|
+
_clientOptions: clientOptions,
|
|
166
|
+
peers: async () => {
|
|
167
|
+
const topics = await kuboRpcClient.pubsub.ls();
|
|
168
|
+
const topicPeers = remeda.flattenDeep(await Promise.all(topics.map((topic) => kuboRpcClient.pubsub.peers(topic))));
|
|
169
|
+
const peers = remeda.unique(topicPeers.map((topicPeer) => topicPeer.toString()));
|
|
170
|
+
return peers;
|
|
171
|
+
},
|
|
172
|
+
url: clientOptions.url.toString(),
|
|
173
|
+
destroy: async () => { }
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async _initLibp2pJsClientsIfNeeded() {
|
|
178
|
+
this.clients.libp2pJsClients = {};
|
|
179
|
+
if (!this.libp2pJsClientsOptions)
|
|
180
|
+
return;
|
|
181
|
+
if (!this.httpRoutersOptions)
|
|
182
|
+
throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
183
|
+
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
184
|
+
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
185
|
+
...clientOptions,
|
|
186
|
+
httpRoutersOptions: this.httpRoutersOptions
|
|
187
|
+
});
|
|
188
|
+
this.clients.libp2pJsClients[clientOptions.key] = heliaNode;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
_initRpcClientsIfNeeded() {
|
|
192
|
+
this.clients.pkcRpcClients = {};
|
|
193
|
+
if (!this.pkcRpcClientsOptions)
|
|
194
|
+
return;
|
|
195
|
+
for (const rpcUrl of this.pkcRpcClientsOptions)
|
|
196
|
+
this.clients.pkcRpcClients[rpcUrl] = new PKCRpcClient(rpcUrl);
|
|
197
|
+
}
|
|
198
|
+
_initIpfsGatewaysIfNeeded() {
|
|
199
|
+
// If user did not provide ipfsGatewayUrls
|
|
200
|
+
this.clients.ipfsGateways = {};
|
|
201
|
+
if (!this.ipfsGatewayUrls)
|
|
202
|
+
return;
|
|
203
|
+
for (const gatewayUrl of this.ipfsGatewayUrls)
|
|
204
|
+
this.clients.ipfsGateways[gatewayUrl] = {};
|
|
205
|
+
}
|
|
206
|
+
async _setupHttpRoutersWithKuboNodeInBackground() {
|
|
207
|
+
const log = Logger("pkc-js:pkc:_initHttpRoutersWithIpfsInBackground");
|
|
208
|
+
if (this.destroyed)
|
|
209
|
+
return;
|
|
210
|
+
if (this.httpRoutersOptions?.length && this.kuboRpcClientsOptions?.length && this._canCreateNewLocalCommunity()) {
|
|
211
|
+
// only for node
|
|
212
|
+
const setupPromise = setupKuboAddressesRewriterAndHttpRouters(this)
|
|
213
|
+
.then(async (addressesRewriterProxyServer) => {
|
|
214
|
+
if (this.destroyed) {
|
|
215
|
+
await addressesRewriterProxyServer.destroy();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
log("Set http router options and their proxies successfully on all connected ipfs", Object.keys(this.clients.kuboRpcClients));
|
|
219
|
+
this._addressRewriterDestroy = addressesRewriterProxyServer.destroy;
|
|
220
|
+
})
|
|
221
|
+
.catch((e) => {
|
|
222
|
+
if (this.destroyed)
|
|
223
|
+
return;
|
|
224
|
+
log.error("Failed to set http router options and their proxies on ipfs nodes due to error", e);
|
|
225
|
+
this.emit("error", e);
|
|
226
|
+
});
|
|
227
|
+
this._addressRewriterSetupPromise = setupPromise;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
async _init() {
|
|
231
|
+
const log = Logger("pkc-js:pkc:_init");
|
|
232
|
+
// Init storage
|
|
233
|
+
this._storage = new Storage(this);
|
|
234
|
+
await this._storage.init();
|
|
235
|
+
// Init stats
|
|
236
|
+
this._stats = new Stats({ _storage: this._storage, clients: this.clients });
|
|
237
|
+
// Init clients manager
|
|
238
|
+
// pkc-with-rpc-client will subscribe to communitieschange and settingschange for us
|
|
239
|
+
if (this._canCreateNewLocalCommunity() && !this.pkcRpcClientsOptions) {
|
|
240
|
+
await tryToDeleteCommunitiesThatFailedToBeDeletedBefore(this, log);
|
|
241
|
+
this._communityFsWatchAbort = await monitorCommunitiesDirectory(this);
|
|
242
|
+
await this._waitForCommunitiesToBeDefined();
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
this.communities = []; // communities = [] on browser
|
|
246
|
+
}
|
|
247
|
+
await this._setupHttpRoutersWithKuboNodeInBackground();
|
|
248
|
+
await this._initLibp2pJsClientsIfNeeded();
|
|
249
|
+
this._clientsManager = new PKCClientsManager(this);
|
|
250
|
+
hideClassPrivateProps(this);
|
|
251
|
+
}
|
|
252
|
+
async getCommunity(getCommunityArgs) {
|
|
253
|
+
const parsedArgs = parseRpcCommunityLookupParam(getCommunityArgs);
|
|
254
|
+
const community = await this.createCommunity(parsedArgs);
|
|
255
|
+
if (typeof community.createdAt === "number")
|
|
256
|
+
return community; // It's a local community, and already has been loaded, no need to wait
|
|
257
|
+
const timeoutMs = this._timeouts["community-ipns"];
|
|
258
|
+
await waitForUpdateInCommunityInstanceWithErrorAndTimeout(community, timeoutMs);
|
|
259
|
+
return community;
|
|
260
|
+
}
|
|
261
|
+
async getComment(cid) {
|
|
262
|
+
const log = Logger("pkc-js:pkc:getComment");
|
|
263
|
+
const parsedGetCommentArgs = parseRpcCidParam(cid);
|
|
264
|
+
// getComment is interested in loading CommentIpfs only
|
|
265
|
+
const comment = await this.createComment(parsedGetCommentArgs);
|
|
266
|
+
let lastUpdateError;
|
|
267
|
+
const errorListener = (err) => (lastUpdateError = err);
|
|
268
|
+
comment.on("error", errorListener);
|
|
269
|
+
const commentTimeout = this._timeouts["comment-ipfs"];
|
|
270
|
+
try {
|
|
271
|
+
await pTimeout(comment._attemptInfintelyToLoadCommentIpfs(), {
|
|
272
|
+
milliseconds: commentTimeout,
|
|
273
|
+
message: lastUpdateError ||
|
|
274
|
+
new TimeoutError(`pkc.getComment({cid: ${parsedGetCommentArgs}}) timed out after ${commentTimeout}ms`)
|
|
275
|
+
});
|
|
276
|
+
if (!comment.signature)
|
|
277
|
+
throw Error("Failed to load CommentIpfs");
|
|
278
|
+
return comment;
|
|
279
|
+
}
|
|
280
|
+
catch (e) {
|
|
281
|
+
if (lastUpdateError)
|
|
282
|
+
throw lastUpdateError;
|
|
283
|
+
throw e;
|
|
284
|
+
}
|
|
285
|
+
finally {
|
|
286
|
+
comment.removeListener("error", errorListener);
|
|
287
|
+
await comment.stop();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async _initMissingFieldsOfPublicationBeforeSigning(pubOptions, log) {
|
|
291
|
+
const finalOptions = remeda.clone(pubOptions);
|
|
292
|
+
if (!finalOptions.signer)
|
|
293
|
+
throw Error("User did not provide a signer to create a local publication");
|
|
294
|
+
const normalizedAuthor = normalizeCreatePublicationAuthor(finalOptions.author);
|
|
295
|
+
let cleanedAuthor = cleanWireAuthor(normalizedAuthor);
|
|
296
|
+
// Strip empty objects from author — empty {} should not be signed
|
|
297
|
+
if (cleanedAuthor) {
|
|
298
|
+
for (const key of Object.keys(cleanedAuthor)) {
|
|
299
|
+
const val = cleanedAuthor[key];
|
|
300
|
+
if (typeof val === "object" && val !== null && !Array.isArray(val) && Object.keys(val).length === 0)
|
|
301
|
+
delete cleanedAuthor[key];
|
|
302
|
+
}
|
|
303
|
+
if (remeda.isEmpty(cleanedAuthor))
|
|
304
|
+
cleanedAuthor = undefined;
|
|
305
|
+
}
|
|
306
|
+
const filledTimestamp = typeof finalOptions.timestamp !== "number" ? timestamp() : finalOptions.timestamp;
|
|
307
|
+
const filledSigner = await this.createSigner(finalOptions.signer);
|
|
308
|
+
const filledProtocolVersion = finalOptions.protocolVersion || env.PROTOCOL_VERSION;
|
|
309
|
+
return {
|
|
310
|
+
...finalOptions,
|
|
311
|
+
timestamp: filledTimestamp,
|
|
312
|
+
signer: filledSigner,
|
|
313
|
+
author: cleanedAuthor,
|
|
314
|
+
protocolVersion: filledProtocolVersion
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
async _createCommentInstanceFromAnotherCommentInstance(options) {
|
|
318
|
+
const commentInstance = new Comment(this);
|
|
319
|
+
if (options.cid)
|
|
320
|
+
commentInstance.setCid(options.cid);
|
|
321
|
+
if (options.communityAddress)
|
|
322
|
+
commentInstance.setCommunityAddress(options.communityAddress);
|
|
323
|
+
if (options.raw?.commentUpdate?.cid)
|
|
324
|
+
commentInstance.setCid(options.raw?.commentUpdate?.cid);
|
|
325
|
+
if ("pubsubMessageToPublish" in options.raw && options.raw.pubsubMessageToPublish && "signer" in options && options.signer)
|
|
326
|
+
commentInstance._initLocalProps({
|
|
327
|
+
comment: options.raw.pubsubMessageToPublish,
|
|
328
|
+
signer: options.signer,
|
|
329
|
+
challengeRequest: options.challengeRequest
|
|
330
|
+
});
|
|
331
|
+
else if ("signer" in options && options.signer) {
|
|
332
|
+
const unsignedOpts = options.raw.unsignedPublicationOptions;
|
|
333
|
+
if (unsignedOpts) {
|
|
334
|
+
const log = Logger("pkc-js:pkc:createComment");
|
|
335
|
+
const finalOptions = (await this._initMissingFieldsOfPublicationBeforeSigning({ ...unsignedOpts, signer: options.signer }, log));
|
|
336
|
+
commentInstance._initUnsignedLocalProps({
|
|
337
|
+
unsignedOptions: finalOptions,
|
|
338
|
+
challengeRequest: options.challengeRequest
|
|
339
|
+
});
|
|
340
|
+
await commentInstance._signPublicationWithKnownCommunityFieldsIfAvailable();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (options.raw.comment)
|
|
344
|
+
commentInstance._initIpfsProps(options.raw.comment);
|
|
345
|
+
// can only get one CommentUpdate
|
|
346
|
+
if ("commentUpdateFromChallengeVerification" in options.raw && options.raw.commentUpdateFromChallengeVerification)
|
|
347
|
+
commentInstance._initCommentUpdateFromChallengeVerificationProps(options.raw.commentUpdateFromChallengeVerification);
|
|
348
|
+
if (options.raw.commentUpdate)
|
|
349
|
+
commentInstance._initCommentUpdate(options.raw.commentUpdate);
|
|
350
|
+
// nameResolved is strictly runtime — never carry it over when cloning
|
|
351
|
+
if (commentInstance.author?.nameResolved !== undefined)
|
|
352
|
+
delete commentInstance.author.nameResolved;
|
|
353
|
+
return commentInstance;
|
|
354
|
+
}
|
|
355
|
+
async createComment(options) {
|
|
356
|
+
const log = Logger("pkc-js:pkc:createComment");
|
|
357
|
+
if ("clients" in options || "raw" in options || "original" in options || options instanceof Comment)
|
|
358
|
+
return this._createCommentInstanceFromAnotherCommentInstance(options); // CommentJson
|
|
359
|
+
const commentInstance = new Comment(this);
|
|
360
|
+
if ("communityAddress" in options && options.communityAddress)
|
|
361
|
+
commentInstance.setCommunityAddress(parseCommunityAddressWithPKCErrorIfItFails(options.communityAddress));
|
|
362
|
+
else if ("subplebbitAddress" in options && options.subplebbitAddress)
|
|
363
|
+
commentInstance.setCommunityAddress(parseCommunityAddressWithPKCErrorIfItFails(options.subplebbitAddress));
|
|
364
|
+
if ("communityPublicKey" in options && typeof options.communityPublicKey === "string")
|
|
365
|
+
commentInstance.communityPublicKey = options.communityPublicKey;
|
|
366
|
+
else if (commentInstance.communityAddress && !isStringDomain(commentInstance.communityAddress))
|
|
367
|
+
commentInstance.communityPublicKey = commentInstance.communityAddress;
|
|
368
|
+
if ("communityName" in options && typeof options.communityName === "string")
|
|
369
|
+
commentInstance.communityName = options.communityName;
|
|
370
|
+
else if (commentInstance.communityAddress && isStringDomain(commentInstance.communityAddress))
|
|
371
|
+
commentInstance.communityName = commentInstance.communityAddress;
|
|
372
|
+
if ("depth" in options) {
|
|
373
|
+
// Options is CommentIpfs | CommentIpfsWithCidDefined | MinimumCommentFieldsToFetchPages
|
|
374
|
+
if ("cid" in options)
|
|
375
|
+
commentInstance.setCid(parseCidStringSchemaWithPKCErrorIfItFails(options.cid));
|
|
376
|
+
//@ts-expect-error
|
|
377
|
+
const commentIpfs = remeda.omit(options, ["cid"]); // remove cid to make sure if options:CommentIpfsWithCidDefined that cid doesn't become part of comment.raw.comment
|
|
378
|
+
// if it has signature it means it's a full CommentIpfs
|
|
379
|
+
if (!("signature" in options))
|
|
380
|
+
Object.assign(commentInstance, options);
|
|
381
|
+
else
|
|
382
|
+
commentInstance._initIpfsProps(parseCommentIpfsSchemaWithPKCErrorIfItFails(commentIpfs));
|
|
383
|
+
// nameResolved is strictly runtime — never carry it over
|
|
384
|
+
if (commentInstance.author?.nameResolved !== undefined)
|
|
385
|
+
delete commentInstance.author.nameResolved;
|
|
386
|
+
}
|
|
387
|
+
else if ("signature" in options) {
|
|
388
|
+
// parsedOptions is CommentPubsubMessage
|
|
389
|
+
const parsedOptions = parseCommentPubsubMessagePublicationWithPKCErrorIfItFails(options);
|
|
390
|
+
commentInstance._initPubsubMessageProps(parsedOptions);
|
|
391
|
+
}
|
|
392
|
+
else if ("signer" in options) {
|
|
393
|
+
// options is CreateCommentOptions
|
|
394
|
+
const parsedOptions = parseCreateCommentOptionsSchemaWithPKCErrorIfItFails(options);
|
|
395
|
+
// Defer signing to publish() — just fill missing fields and store unsigned options
|
|
396
|
+
const fieldsFilled = await this._initMissingFieldsOfPublicationBeforeSigning(parsedOptions, log);
|
|
397
|
+
commentInstance._initUnsignedLocalProps({
|
|
398
|
+
unsignedOptions: fieldsFilled,
|
|
399
|
+
challengeRequest: parsedOptions.challengeRequest
|
|
400
|
+
});
|
|
401
|
+
await commentInstance._signPublicationWithKnownCommunityFieldsIfAvailable();
|
|
402
|
+
}
|
|
403
|
+
else if ("cid" in options) {
|
|
404
|
+
// {cid: string, communityAddress?: string} (also accepts subplebbitAddress for backward compat)
|
|
405
|
+
commentInstance.setCid(parseCidStringSchemaWithPKCErrorIfItFails(options.cid));
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
throw Error("Make sure you provided a remote comment props or signer to create a new local comment");
|
|
409
|
+
}
|
|
410
|
+
if (commentInstance.cid) {
|
|
411
|
+
commentInstance._useUpdatePropsFromUpdatingStartedCommunityIfPossible();
|
|
412
|
+
commentInstance._useUpdatePropsFromUpdatingCommentIfPossible();
|
|
413
|
+
}
|
|
414
|
+
return commentInstance;
|
|
415
|
+
}
|
|
416
|
+
_canCreateNewLocalCommunity() {
|
|
417
|
+
// TODO check if we have a connection to kubo rpc node for IPFS and pubsub
|
|
418
|
+
const isNode = typeof process?.versions?.node !== "undefined";
|
|
419
|
+
return isNode && Boolean(this.dataPath);
|
|
420
|
+
}
|
|
421
|
+
async _setCommunityIpfsOnInstanceIfPossible(community, options) {
|
|
422
|
+
await community.initRemoteCommunityPropsNoMerge(options);
|
|
423
|
+
const preservedRuntimeFields = extractCommunityRuntimeFieldsFromParsedPages({
|
|
424
|
+
postsPages: community.posts.pages,
|
|
425
|
+
modQueuePages: community.modQueue.pages
|
|
426
|
+
});
|
|
427
|
+
const reapplyPreservedRuntimeFields = () => {
|
|
428
|
+
if (preservedRuntimeFields)
|
|
429
|
+
deepMergeRuntimeFields(community, preservedRuntimeFields);
|
|
430
|
+
};
|
|
431
|
+
if ("raw" in options && options.raw.communityIpfs) {
|
|
432
|
+
await community.initCommunityIpfsPropsNoMerge(options.raw.communityIpfs); // we're setting CommunityIpfs
|
|
433
|
+
reapplyPreservedRuntimeFields();
|
|
434
|
+
}
|
|
435
|
+
if ("updateCid" in options && options.updateCid)
|
|
436
|
+
community.updateCid = options.updateCid;
|
|
437
|
+
if (!community.raw.communityIpfs) {
|
|
438
|
+
// we didn't receive options that we can parse into CommunityIpfs
|
|
439
|
+
// let's try using _updatingCommunities
|
|
440
|
+
await community._setCommunityIpfsPropsFromUpdatingCommunitiesIfPossible();
|
|
441
|
+
if (community.raw.communityIpfs)
|
|
442
|
+
reapplyPreservedRuntimeFields();
|
|
443
|
+
}
|
|
444
|
+
// last resort to set community ipfs props
|
|
445
|
+
if (!community.raw.communityIpfs) {
|
|
446
|
+
if (options.signature) {
|
|
447
|
+
const resParseCommunityIpfs = CommunityIpfsSchema.loose().safeParse(remeda.pick(options, [...options.signature.signedPropertyNames, "signature"]));
|
|
448
|
+
if (resParseCommunityIpfs.success) {
|
|
449
|
+
const cleanedRecord = removeUndefinedValuesRecursively(resParseCommunityIpfs.data); // safe way to replicate JSON.stringify() which is done before adding record to ipfs
|
|
450
|
+
await community.initCommunityIpfsPropsNoMerge(cleanedRecord);
|
|
451
|
+
reapplyPreservedRuntimeFields();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// Backward compat: old serialized instances have raw.subplebbitIpfs instead of raw.communityIpfs
|
|
456
|
+
if (!community.raw.communityIpfs && "raw" in options) {
|
|
457
|
+
const legacyRaw = options.raw.subplebbitIpfs;
|
|
458
|
+
if (legacyRaw) {
|
|
459
|
+
community.raw.communityIpfs = legacyRaw;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
async _waitForCommunitiesToBeDefined() {
|
|
464
|
+
// we're just wait until this.communities is either defined, or communitieschange is emitted
|
|
465
|
+
await this._promiseToWaitForFirstCommunitieschangeEvent;
|
|
466
|
+
if (!Array.isArray(this.communities))
|
|
467
|
+
throw Error("pkc.communities should be defined after communitieschange event");
|
|
468
|
+
}
|
|
469
|
+
async _awaitCommunitiesToIncludeCommunity(communityAddress) {
|
|
470
|
+
if (this.communities.includes(communityAddress))
|
|
471
|
+
return;
|
|
472
|
+
else
|
|
473
|
+
await resolveWhenPredicateIsTrue({
|
|
474
|
+
toUpdate: this,
|
|
475
|
+
predicate: () => this.communities.includes(communityAddress),
|
|
476
|
+
eventName: "communitieschange"
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
async _createRemoteCommunityInstance(options) {
|
|
480
|
+
const log = Logger("pkc-js:pkc:createRemoteCommunity");
|
|
481
|
+
log.trace("Received community options to create a remote community instance:", options);
|
|
482
|
+
const community = new RemoteCommunity(this);
|
|
483
|
+
await this._setCommunityIpfsOnInstanceIfPossible(community, options);
|
|
484
|
+
log.trace(`Created remote community instance (${community.address})`);
|
|
485
|
+
return community;
|
|
486
|
+
}
|
|
487
|
+
async _createLocalCommunity(options) {
|
|
488
|
+
const log = Logger("pkc-js:pkc:createLocalCommunity");
|
|
489
|
+
log.trace("Received community options to create a local community instance:", options);
|
|
490
|
+
const canCreateLocalCommunity = this._canCreateNewLocalCommunity();
|
|
491
|
+
if (!canCreateLocalCommunity)
|
|
492
|
+
throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
493
|
+
const localCommunities = await nodeListCommunities(this);
|
|
494
|
+
const isLocalCommunity = localCommunities.includes(options.address); // Community exists already, only pass address so we don't override other props
|
|
495
|
+
const community = new LocalCommunity(this);
|
|
496
|
+
if (isLocalCommunity) {
|
|
497
|
+
// If the community is already created before, then load it with address only. We don't care about other props
|
|
498
|
+
community.setAddress(options.address);
|
|
499
|
+
await community._updateInstancePropsWithStartedCommunityOrDb();
|
|
500
|
+
log.trace(`Created instance of existing local community (${community.address}) with props:`);
|
|
501
|
+
community.emit("update", community);
|
|
502
|
+
return community;
|
|
503
|
+
}
|
|
504
|
+
else if ("signer" in options) {
|
|
505
|
+
// This is a new community
|
|
506
|
+
const parsedOptions = options;
|
|
507
|
+
await community.initNewLocalCommunityPropsNoMerge(parsedOptions); // We're initializing a new local community props here
|
|
508
|
+
await community._createNewLocalCommunityDb();
|
|
509
|
+
log.trace(`Created a new local community (${community.address}) with props:`);
|
|
510
|
+
community.emit("update", community);
|
|
511
|
+
await this._awaitCommunitiesToIncludeCommunity(community.address);
|
|
512
|
+
return community;
|
|
513
|
+
}
|
|
514
|
+
else
|
|
515
|
+
throw Error("Are you trying to create a local community with no address or signer? This is a critical error");
|
|
516
|
+
}
|
|
517
|
+
async _createCommunityInstanceFromJsonifiedCommunity(jsonfied) {
|
|
518
|
+
// jsonfied = JSON.parse(JSON.stringify(communityInstance))
|
|
519
|
+
// should probably exclude internal and instance-exclusive props like states
|
|
520
|
+
if (this.communities.includes(jsonfied.address))
|
|
521
|
+
return this._createLocalCommunity(jsonfied);
|
|
522
|
+
else
|
|
523
|
+
return this._createRemoteCommunityInstance(jsonfied);
|
|
524
|
+
}
|
|
525
|
+
async createCommunity(options = {}) {
|
|
526
|
+
const log = Logger("pkc-js:pkc:createCommunity");
|
|
527
|
+
if ("clients" in options)
|
|
528
|
+
return this._createCommunityInstanceFromJsonifiedCommunity(options);
|
|
529
|
+
const parsedOptions = options;
|
|
530
|
+
log.trace("Received options: ", parsedOptions);
|
|
531
|
+
const hasAddress = "address" in parsedOptions && typeof parsedOptions.address === "string";
|
|
532
|
+
const hasName = "name" in parsedOptions && typeof parsedOptions.name === "string";
|
|
533
|
+
const hasPublicKey = "publicKey" in parsedOptions && typeof parsedOptions.publicKey === "string";
|
|
534
|
+
const hasSigner = "signer" in parsedOptions && parsedOptions.signer !== undefined;
|
|
535
|
+
const hasIdentifier = hasAddress || hasName || hasPublicKey; // can identify an existing community
|
|
536
|
+
// Derive effective address for local-vs-remote checks
|
|
537
|
+
const effectiveAddress = parsedOptions.address ||
|
|
538
|
+
parsedOptions.name ||
|
|
539
|
+
parsedOptions.publicKey;
|
|
540
|
+
if (effectiveAddress && doesDomainAddressHaveCapitalLetter(effectiveAddress))
|
|
541
|
+
throw new PKCError("ERR_COMMUNITY_NAME_HAS_CAPITAL_LETTER", { ...parsedOptions });
|
|
542
|
+
// Creating a community when we're connected to RPC will be handled in pkc-with-rpc-client
|
|
543
|
+
// Code below is for NodeJS and browser using IPFS-P2P/gateway
|
|
544
|
+
const canCreateLocalCommunity = this._canCreateNewLocalCommunity(); // this is true if we're on NodeJS and have a dataPath
|
|
545
|
+
if (hasSigner && !canCreateLocalCommunity)
|
|
546
|
+
throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", {
|
|
547
|
+
pkcOptions: this._userPKCOptions,
|
|
548
|
+
isEnvNode: Boolean(process),
|
|
549
|
+
hasDataPath: Boolean(this.dataPath)
|
|
550
|
+
});
|
|
551
|
+
if (!canCreateLocalCommunity) {
|
|
552
|
+
// we're either on browser or on NodeJS with no dataPath
|
|
553
|
+
const parsedRemoteOptions = parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails(options);
|
|
554
|
+
return this._createRemoteCommunityInstance(parsedRemoteOptions);
|
|
555
|
+
}
|
|
556
|
+
if (hasIdentifier && !hasSigner) {
|
|
557
|
+
// community is already created, need to check if it's local or remote
|
|
558
|
+
const localCommunities = await nodeListCommunities(this);
|
|
559
|
+
// Check for exact match or .eth/.bso alias match
|
|
560
|
+
const localCommunityAddress = localCommunities.find((localAddr) => areEquivalentCommunityAddresses(localAddr, effectiveAddress));
|
|
561
|
+
if (localCommunityAddress)
|
|
562
|
+
return this._createLocalCommunity({ address: localCommunityAddress });
|
|
563
|
+
else {
|
|
564
|
+
const parsedRemoteOptions = parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails(options);
|
|
565
|
+
return this._createRemoteCommunityInstance(parsedRemoteOptions);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
else if (!hasIdentifier && !hasSigner) {
|
|
569
|
+
// no identifier, no signer, create signer and assign address to signer.address
|
|
570
|
+
const signer = await this.createSigner();
|
|
571
|
+
const localOptions = { ...parsedOptions, signer, address: signer.address };
|
|
572
|
+
log(`Did not provide CreateCommunityOptions.signer, generated random signer with address (${localOptions.address})`);
|
|
573
|
+
return this._createLocalCommunity(localOptions);
|
|
574
|
+
}
|
|
575
|
+
else if (!hasIdentifier && hasSigner) {
|
|
576
|
+
const signerInput = parsedOptions.signer;
|
|
577
|
+
const signer = await this.createSigner(signerInput);
|
|
578
|
+
const localOptions = {
|
|
579
|
+
...parsedOptions,
|
|
580
|
+
address: signer.address,
|
|
581
|
+
signer
|
|
582
|
+
};
|
|
583
|
+
return this._createLocalCommunity(localOptions);
|
|
584
|
+
}
|
|
585
|
+
else if (hasIdentifier && hasSigner)
|
|
586
|
+
return this._createLocalCommunity(parsedOptions);
|
|
587
|
+
else
|
|
588
|
+
throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { parsedOptions });
|
|
589
|
+
}
|
|
590
|
+
async _createVoteInstanceFromJsonfiedVote(jsonfied) {
|
|
591
|
+
const voteInstance = new Vote(this);
|
|
592
|
+
const unsignedOpts = jsonfied.raw.unsignedPublicationOptions;
|
|
593
|
+
if (jsonfied.raw.pubsubMessageToPublish)
|
|
594
|
+
voteInstance._initLocalProps({
|
|
595
|
+
vote: jsonfied.raw.pubsubMessageToPublish,
|
|
596
|
+
signer: jsonfied.signer,
|
|
597
|
+
challengeRequest: jsonfied.challengeRequest
|
|
598
|
+
});
|
|
599
|
+
else if (unsignedOpts && jsonfied.signer) {
|
|
600
|
+
const log = Logger("pkc-js:pkc:createVote");
|
|
601
|
+
const finalOptions = (await this._initMissingFieldsOfPublicationBeforeSigning({ ...unsignedOpts, signer: jsonfied.signer }, log));
|
|
602
|
+
voteInstance._initUnsignedLocalProps({
|
|
603
|
+
unsignedOptions: finalOptions,
|
|
604
|
+
challengeRequest: jsonfied.challengeRequest
|
|
605
|
+
});
|
|
606
|
+
await voteInstance._signPublicationWithKnownCommunityFieldsIfAvailable();
|
|
607
|
+
}
|
|
608
|
+
return voteInstance;
|
|
609
|
+
}
|
|
610
|
+
async createVote(options) {
|
|
611
|
+
const log = Logger("pkc-js:pkc:createVote");
|
|
612
|
+
if ("clients" in options)
|
|
613
|
+
return this._createVoteInstanceFromJsonfiedVote(options);
|
|
614
|
+
const voteInstance = new Vote(this);
|
|
615
|
+
if ("signature" in options) {
|
|
616
|
+
const parsedOptions = parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails(options);
|
|
617
|
+
voteInstance._initRemoteProps(parsedOptions);
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
const parsedOptions = parseCreateVoteOptionsSchemaWithPKCErrorIfItFails(options);
|
|
621
|
+
const finalOptions = await this._initMissingFieldsOfPublicationBeforeSigning(parsedOptions, log);
|
|
622
|
+
voteInstance._initUnsignedLocalProps({
|
|
623
|
+
unsignedOptions: finalOptions,
|
|
624
|
+
challengeRequest: parsedOptions.challengeRequest
|
|
625
|
+
});
|
|
626
|
+
await voteInstance._signPublicationWithKnownCommunityFieldsIfAvailable();
|
|
627
|
+
}
|
|
628
|
+
return voteInstance;
|
|
629
|
+
}
|
|
630
|
+
async _createCommentEditInstanceFromJsonfiedCommentEdit(jsonfied) {
|
|
631
|
+
const editInstance = new CommentEdit(this);
|
|
632
|
+
const unsignedOpts = jsonfied.raw.unsignedPublicationOptions;
|
|
633
|
+
if (jsonfied.raw.pubsubMessageToPublish)
|
|
634
|
+
editInstance._initLocalProps({
|
|
635
|
+
commentEdit: jsonfied.raw.pubsubMessageToPublish,
|
|
636
|
+
signer: jsonfied.signer,
|
|
637
|
+
challengeRequest: jsonfied.challengeRequest
|
|
638
|
+
});
|
|
639
|
+
else if (unsignedOpts && jsonfied.signer) {
|
|
640
|
+
const log = Logger("pkc-js:pkc:createCommentEdit");
|
|
641
|
+
const finalOptions = (await this._initMissingFieldsOfPublicationBeforeSigning({ ...unsignedOpts, signer: jsonfied.signer }, log));
|
|
642
|
+
editInstance._initUnsignedLocalProps({
|
|
643
|
+
unsignedOptions: finalOptions,
|
|
644
|
+
challengeRequest: jsonfied.challengeRequest
|
|
645
|
+
});
|
|
646
|
+
await editInstance._signPublicationWithKnownCommunityFieldsIfAvailable();
|
|
647
|
+
}
|
|
648
|
+
return editInstance;
|
|
649
|
+
}
|
|
650
|
+
async createCommentEdit(options) {
|
|
651
|
+
const log = Logger("pkc-js:pkc:createCommentEdit");
|
|
652
|
+
if ("clients" in options)
|
|
653
|
+
return this._createCommentEditInstanceFromJsonfiedCommentEdit(options);
|
|
654
|
+
const editInstance = new CommentEdit(this);
|
|
655
|
+
if ("signature" in options) {
|
|
656
|
+
const parsedOptions = parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails(options);
|
|
657
|
+
editInstance._initPubsubPublicationProps(parsedOptions); // User just wants to instantiate a CommentEdit object, not publish
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
const parsedOptions = parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails(options);
|
|
661
|
+
const finalOptions = await this._initMissingFieldsOfPublicationBeforeSigning(options, log);
|
|
662
|
+
editInstance._initUnsignedLocalProps({
|
|
663
|
+
unsignedOptions: finalOptions,
|
|
664
|
+
challengeRequest: parsedOptions.challengeRequest
|
|
665
|
+
});
|
|
666
|
+
await editInstance._signPublicationWithKnownCommunityFieldsIfAvailable();
|
|
667
|
+
}
|
|
668
|
+
return editInstance;
|
|
669
|
+
}
|
|
670
|
+
async _createCommentModerationInstanceFromJsonfiedCommentModeration(jsonfied) {
|
|
671
|
+
const modInstance = new CommentModeration(this);
|
|
672
|
+
const unsignedOpts = jsonfied.raw.unsignedPublicationOptions;
|
|
673
|
+
if (jsonfied.raw.pubsubMessageToPublish)
|
|
674
|
+
modInstance._initLocalProps({
|
|
675
|
+
commentModeration: jsonfied.raw.pubsubMessageToPublish,
|
|
676
|
+
signer: jsonfied.signer,
|
|
677
|
+
challengeRequest: jsonfied.challengeRequest
|
|
678
|
+
});
|
|
679
|
+
else if (unsignedOpts && jsonfied.signer) {
|
|
680
|
+
const log = Logger("pkc-js:pkc:createCommentModeration");
|
|
681
|
+
const finalOptions = (await this._initMissingFieldsOfPublicationBeforeSigning({ ...unsignedOpts, signer: jsonfied.signer }, log));
|
|
682
|
+
modInstance._initUnsignedLocalProps({
|
|
683
|
+
unsignedOptions: finalOptions,
|
|
684
|
+
challengeRequest: jsonfied.challengeRequest
|
|
685
|
+
});
|
|
686
|
+
await modInstance._signPublicationWithKnownCommunityFieldsIfAvailable();
|
|
687
|
+
}
|
|
688
|
+
return modInstance;
|
|
689
|
+
}
|
|
690
|
+
async createCommentModeration(options) {
|
|
691
|
+
const log = Logger("pkc-js:pkc:createCommentEdit");
|
|
692
|
+
if ("clients" in options)
|
|
693
|
+
return this._createCommentModerationInstanceFromJsonfiedCommentModeration(options);
|
|
694
|
+
const modInstance = new CommentModeration(this);
|
|
695
|
+
if ("signature" in options) {
|
|
696
|
+
const parsedOptions = parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails(options);
|
|
697
|
+
modInstance._initPubsubPublication(parsedOptions); // User just wants to instantiate a CommentEdit object, not publish
|
|
698
|
+
}
|
|
699
|
+
else {
|
|
700
|
+
const parsedOptions = parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails(options);
|
|
701
|
+
const finalOptions = (await this._initMissingFieldsOfPublicationBeforeSigning(parsedOptions, log));
|
|
702
|
+
modInstance._initUnsignedLocalProps({
|
|
703
|
+
unsignedOptions: finalOptions,
|
|
704
|
+
challengeRequest: parsedOptions.challengeRequest
|
|
705
|
+
});
|
|
706
|
+
await modInstance._signPublicationWithKnownCommunityFieldsIfAvailable();
|
|
707
|
+
}
|
|
708
|
+
return modInstance;
|
|
709
|
+
}
|
|
710
|
+
async _createCommunityEditInstanceFromJsonfiedCommunityEdit(jsonfied) {
|
|
711
|
+
const communityEditInstance = new CommunityEdit(this);
|
|
712
|
+
const unsignedOpts = jsonfied.raw.unsignedPublicationOptions;
|
|
713
|
+
if (jsonfied.raw.pubsubMessageToPublish)
|
|
714
|
+
communityEditInstance._initLocalProps({
|
|
715
|
+
communityEdit: jsonfied.raw.pubsubMessageToPublish,
|
|
716
|
+
signer: jsonfied.signer,
|
|
717
|
+
challengeRequest: jsonfied.challengeRequest
|
|
718
|
+
});
|
|
719
|
+
else if (unsignedOpts && jsonfied.signer) {
|
|
720
|
+
const log = Logger("pkc-js:pkc:createCommunityEdit");
|
|
721
|
+
const finalOptions = (await this._initMissingFieldsOfPublicationBeforeSigning({ ...unsignedOpts, signer: jsonfied.signer }, log));
|
|
722
|
+
communityEditInstance._initUnsignedLocalProps({
|
|
723
|
+
unsignedOptions: finalOptions,
|
|
724
|
+
challengeRequest: jsonfied.challengeRequest
|
|
725
|
+
});
|
|
726
|
+
await communityEditInstance._signPublicationWithKnownCommunityFieldsIfAvailable();
|
|
727
|
+
}
|
|
728
|
+
return communityEditInstance;
|
|
729
|
+
}
|
|
730
|
+
async createCommunityEdit(options) {
|
|
731
|
+
const log = Logger("pkc-js:pkc:createCommunityEdit");
|
|
732
|
+
if ("clients" in options)
|
|
733
|
+
return this._createCommunityEditInstanceFromJsonfiedCommunityEdit(options);
|
|
734
|
+
const communityEditInstance = new CommunityEdit(this);
|
|
735
|
+
if ("signature" in options) {
|
|
736
|
+
const parsedOptions = parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails(options);
|
|
737
|
+
communityEditInstance._initRemoteProps(parsedOptions);
|
|
738
|
+
}
|
|
739
|
+
else {
|
|
740
|
+
const parsedOptions = parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails(options);
|
|
741
|
+
const finalOptions = (await this._initMissingFieldsOfPublicationBeforeSigning(parsedOptions, log));
|
|
742
|
+
communityEditInstance._initUnsignedLocalProps({
|
|
743
|
+
unsignedOptions: finalOptions,
|
|
744
|
+
challengeRequest: parsedOptions.challengeRequest
|
|
745
|
+
});
|
|
746
|
+
await communityEditInstance._signPublicationWithKnownCommunityFieldsIfAvailable();
|
|
747
|
+
}
|
|
748
|
+
return communityEditInstance;
|
|
749
|
+
}
|
|
750
|
+
createSigner(createSignerOptions) {
|
|
751
|
+
return createSigner(createSignerOptions);
|
|
752
|
+
}
|
|
753
|
+
async fetchCid(fetchCidArgs) {
|
|
754
|
+
// pkc-with-rpc-client will handle if user is connected to rpc client
|
|
755
|
+
const parsedArgs = parseRpcCidParam(fetchCidArgs);
|
|
756
|
+
return this._clientsManager.fetchCid(parsedArgs.cid);
|
|
757
|
+
}
|
|
758
|
+
// Used to pre-subscribe so publishing on pubsub would be faster
|
|
759
|
+
async pubsubSubscribe(pubsubTopic) {
|
|
760
|
+
const parsedTopic = PubsubTopicSchema.parse(pubsubTopic);
|
|
761
|
+
if (this._pubsubSubscriptions[parsedTopic])
|
|
762
|
+
return;
|
|
763
|
+
const handler = () => { };
|
|
764
|
+
await this._clientsManager.pubsubSubscribe(parsedTopic, handler);
|
|
765
|
+
this._pubsubSubscriptions[parsedTopic] = handler;
|
|
766
|
+
}
|
|
767
|
+
async pubsubUnsubscribe(pubsubTopic) {
|
|
768
|
+
const parsedTopic = PubsubTopicSchema.parse(pubsubTopic);
|
|
769
|
+
if (!this._pubsubSubscriptions[parsedTopic])
|
|
770
|
+
return;
|
|
771
|
+
await this._clientsManager.pubsubUnsubscribe(parsedTopic, this._pubsubSubscriptions[parsedTopic]);
|
|
772
|
+
delete this._pubsubSubscriptions[parsedTopic];
|
|
773
|
+
}
|
|
774
|
+
async resolveAuthorName(resolveAuthorAddressArgs) {
|
|
775
|
+
const parsedArgs = parseRpcAuthorNameParam(resolveAuthorAddressArgs);
|
|
776
|
+
const resolved = await this._clientsManager.resolveAuthorNameIfNeeded({ authorAddress: parsedArgs.address });
|
|
777
|
+
return resolved;
|
|
778
|
+
}
|
|
779
|
+
async validateComment(comment, opts) {
|
|
780
|
+
const commentIpfs = comment.raw.comment;
|
|
781
|
+
const commentUpdate = comment.raw.commentUpdate;
|
|
782
|
+
const commentCid = comment.cid;
|
|
783
|
+
const postCid = comment.postCid;
|
|
784
|
+
if (!commentCid)
|
|
785
|
+
throw new PKCError("ERR_COMMENT_MISSING_CID", { comment, commentCid });
|
|
786
|
+
if (!commentIpfs)
|
|
787
|
+
throw new PKCError("ERR_COMMENT_MISSING_IPFS", { comment, commentIpfs });
|
|
788
|
+
if (!commentUpdate)
|
|
789
|
+
throw new PKCError("ERR_COMMENT_MISSING_UPDATE", { comment, commentUpdate });
|
|
790
|
+
if (!postCid)
|
|
791
|
+
throw new PKCError("ERR_COMMENT_MISSING_POST_CID", { comment, postCid }); // postCid should always be defined if you have CommentIpfs
|
|
792
|
+
const commentIpfsVerificationOpts = {
|
|
793
|
+
comment: commentIpfs,
|
|
794
|
+
resolveAuthorNames: this.resolveAuthorNames,
|
|
795
|
+
clientsManager: this._clientsManager,
|
|
796
|
+
calculatedCommentCid: commentCid
|
|
797
|
+
};
|
|
798
|
+
const commentIpfsValidity = await verifyCommentIpfs(commentIpfsVerificationOpts);
|
|
799
|
+
if (!commentIpfsValidity.valid)
|
|
800
|
+
throw new PKCError("ERR_INVALID_COMMENT_IPFS", {
|
|
801
|
+
commentIpfsVerificationOpts,
|
|
802
|
+
commentIpfsValidity
|
|
803
|
+
});
|
|
804
|
+
const communityIpfs = findUpdatingCommunity(this, { address: comment.communityAddress })?.raw?.communityIpfs;
|
|
805
|
+
const community = communityIpfs
|
|
806
|
+
? { address: comment.communityAddress, signature: communityIpfs.signature }
|
|
807
|
+
: { address: comment.communityAddress };
|
|
808
|
+
const commentUpdateVerificationOpts = {
|
|
809
|
+
update: commentUpdate,
|
|
810
|
+
resolveAuthorNames: this.resolveAuthorNames,
|
|
811
|
+
clientsManager: this._clientsManager,
|
|
812
|
+
community,
|
|
813
|
+
validatePages: typeof opts?.validateReplies === "boolean" ? opts.validateReplies : this.validatePages,
|
|
814
|
+
comment: { ...commentIpfs, cid: commentCid, postCid },
|
|
815
|
+
validateUpdateSignature: true
|
|
816
|
+
};
|
|
817
|
+
const commentUpdateValidity = await verifyCommentUpdate(commentUpdateVerificationOpts);
|
|
818
|
+
if (!commentUpdateValidity.valid)
|
|
819
|
+
throw new PKCError("ERR_INVALID_COMMENT_UPDATE", {
|
|
820
|
+
commentUpdateVerificationOpts,
|
|
821
|
+
commentUpdateValidity
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
async _createStorageLRU(opts) {
|
|
825
|
+
// should add the storage LRU to an array, so we can destroy all of them on pkc.destroy
|
|
826
|
+
if (!this._storageLRUs[opts.cacheName]) {
|
|
827
|
+
this._storageLRUs[opts.cacheName] = new LRUStorage({ ...opts, pkc: this });
|
|
828
|
+
await this._storageLRUs[opts.cacheName].init();
|
|
829
|
+
}
|
|
830
|
+
return this._storageLRUs[opts.cacheName];
|
|
831
|
+
}
|
|
832
|
+
async destroy() {
|
|
833
|
+
const log = Logger("pkc-js:pkc:destroy");
|
|
834
|
+
if (this.destroyed)
|
|
835
|
+
return;
|
|
836
|
+
this.destroyed = true;
|
|
837
|
+
// Clean up connections
|
|
838
|
+
for (const comment of listUpdatingComments(this))
|
|
839
|
+
await comment.stop();
|
|
840
|
+
for (const community of listUpdatingCommunities(this))
|
|
841
|
+
await community.stop();
|
|
842
|
+
await Promise.all(listStartedCommunities(this).map((community) => community.stop()));
|
|
843
|
+
if (this._communityFsWatchAbort)
|
|
844
|
+
this._communityFsWatchAbort.abort();
|
|
845
|
+
if (this._addressRewriterSetupPromise) {
|
|
846
|
+
await this._addressRewriterSetupPromise;
|
|
847
|
+
this._addressRewriterSetupPromise = undefined;
|
|
848
|
+
}
|
|
849
|
+
if (this._addressRewriterDestroy) {
|
|
850
|
+
await this._addressRewriterDestroy();
|
|
851
|
+
this._addressRewriterDestroy = undefined;
|
|
852
|
+
}
|
|
853
|
+
await this._storage.destroy();
|
|
854
|
+
for (const storage of Object.values(this._storageLRUs))
|
|
855
|
+
await storage.destroy();
|
|
856
|
+
Object.values(this._memCaches).forEach((cache) => cache.clear());
|
|
857
|
+
if (Object.keys(this._pubsubSubscriptions).length > 0) {
|
|
858
|
+
for (const client of Object.values(this.clients.pubsubKuboRpcClients)) {
|
|
859
|
+
try {
|
|
860
|
+
const subscribedPubsubTopics = await client._client.pubsub.ls();
|
|
861
|
+
for (const topic of subscribedPubsubTopics) {
|
|
862
|
+
await client._client.pubsub.unsubscribe(topic);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
catch (e) {
|
|
866
|
+
log.error("Error unsubscribing from pubsub topics", e);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
const kuboClients = [...Object.values(this.clients.kuboRpcClients), ...Object.values(this.clients.pubsubKuboRpcClients)];
|
|
871
|
+
await Promise.all(kuboClients.map(async (client) => client.destroy()));
|
|
872
|
+
await Promise.all(Object.values(this.clients.libp2pJsClients).map((client) => client.heliaWithKuboRpcClientFunctions.stop()));
|
|
873
|
+
await Promise.all(Object.values(this.clients.pkcRpcClients).map((client) => client.destroy()));
|
|
874
|
+
if (this.nameResolvers) {
|
|
875
|
+
await Promise.all(this.nameResolvers.map((resolver) => resolver.destroy?.()));
|
|
876
|
+
}
|
|
877
|
+
// Get all methods on the instance and override them to throw errors if used after destruction
|
|
878
|
+
Object.getOwnPropertyNames(Object.getPrototypeOf(this))
|
|
879
|
+
.filter((prop) => typeof this[prop] === "function")
|
|
880
|
+
.forEach((method) => {
|
|
881
|
+
this[method] = () => {
|
|
882
|
+
throw new PKCError("ERR_PKC_IS_DESTROYED");
|
|
883
|
+
};
|
|
884
|
+
});
|
|
885
|
+
log("Destroyed pkc instance");
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
//# sourceMappingURL=pkc.js.map
|