@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,280 @@
|
|
|
1
|
+
//@ts-expect-error
|
|
2
|
+
import TinyCache from "tinycache";
|
|
3
|
+
import QuickLRU from "quick-lru";
|
|
4
|
+
import { testScore, testFirstCommentTimestamp, testRole, testPublicationType } from "./utils.js";
|
|
5
|
+
import { testRateLimit } from "./rate-limiter.js";
|
|
6
|
+
import { derivePublicationFromChallengeRequest } from "../../../../../util.js";
|
|
7
|
+
import { getPKCAddressFromPublicKeySync } from "../../../../../signer/util.js";
|
|
8
|
+
const shouldExcludePublication = (communityChallenge, request, community) => {
|
|
9
|
+
if (!communityChallenge) {
|
|
10
|
+
throw Error(`shouldExcludePublication invalid communityChallenge argument '${communityChallenge}'`);
|
|
11
|
+
}
|
|
12
|
+
const publication = derivePublicationFromChallengeRequest(request);
|
|
13
|
+
if (!publication?.author) {
|
|
14
|
+
throw Error(`shouldExcludePublication invalid publication argument '${publication}'`);
|
|
15
|
+
}
|
|
16
|
+
const author = publication.author;
|
|
17
|
+
if (!communityChallenge.exclude) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (!Array.isArray(communityChallenge.exclude)) {
|
|
21
|
+
throw Error(`shouldExcludePublication invalid communityChallenge argument '${communityChallenge}' communityChallenge.exclude not an array`);
|
|
22
|
+
}
|
|
23
|
+
// lazy-loaded author publication counts (only when postCount/replyCount exclude is set)
|
|
24
|
+
let authorPublicationCounts;
|
|
25
|
+
// if match any of the exclude array, should exclude
|
|
26
|
+
for (const exclude of communityChallenge.exclude) {
|
|
27
|
+
// if doesn't have any author excludes, shouldn't exclude
|
|
28
|
+
if (typeof exclude.postScore !== "number" &&
|
|
29
|
+
typeof exclude.replyScore !== "number" &&
|
|
30
|
+
typeof exclude.postCount !== "number" &&
|
|
31
|
+
typeof exclude.replyCount !== "number" &&
|
|
32
|
+
typeof exclude.firstCommentTimestamp !== "number" &&
|
|
33
|
+
!exclude.address?.length &&
|
|
34
|
+
exclude.publicationType === undefined &&
|
|
35
|
+
exclude.rateLimit === undefined &&
|
|
36
|
+
!exclude.role?.length) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
// if match all of the exclude item properties, should exclude
|
|
40
|
+
// keep separated for easier debugging
|
|
41
|
+
let shouldExclude = true;
|
|
42
|
+
if (!testScore(exclude.postScore, author.community?.postScore)) {
|
|
43
|
+
shouldExclude = false;
|
|
44
|
+
}
|
|
45
|
+
if (!testScore(exclude.replyScore, author.community?.replyScore)) {
|
|
46
|
+
shouldExclude = false;
|
|
47
|
+
}
|
|
48
|
+
if (!testFirstCommentTimestamp(exclude.firstCommentTimestamp, author.community?.firstCommentTimestamp)) {
|
|
49
|
+
shouldExclude = false;
|
|
50
|
+
}
|
|
51
|
+
if (!testPublicationType(exclude.publicationType, request)) {
|
|
52
|
+
shouldExclude = false;
|
|
53
|
+
}
|
|
54
|
+
if (!testRateLimit(exclude, request)) {
|
|
55
|
+
shouldExclude = false;
|
|
56
|
+
}
|
|
57
|
+
if (exclude.address && !exclude.address.includes(author.address)) {
|
|
58
|
+
shouldExclude = false;
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(exclude.role) && !testRole(exclude.role, publication.author.address, community?.roles)) {
|
|
61
|
+
shouldExclude = false;
|
|
62
|
+
}
|
|
63
|
+
if (typeof exclude.postCount === "number" || typeof exclude.replyCount === "number") {
|
|
64
|
+
if (!authorPublicationCounts && community?._dbHandler) {
|
|
65
|
+
const signerAddress = getPKCAddressFromPublicKeySync(publication.signature.publicKey);
|
|
66
|
+
authorPublicationCounts = community._dbHandler.queryAuthorPublicationCounts(signerAddress);
|
|
67
|
+
}
|
|
68
|
+
if (!testScore(exclude.postCount, authorPublicationCounts?.postCount)) {
|
|
69
|
+
shouldExclude = false;
|
|
70
|
+
}
|
|
71
|
+
if (!testScore(exclude.replyCount, authorPublicationCounts?.replyCount)) {
|
|
72
|
+
shouldExclude = false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// if one of the exclude item is successful, should exclude author
|
|
76
|
+
if (shouldExclude) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
};
|
|
82
|
+
const shouldExcludeChallengeSuccess = (communityChallenge, communityChallengeIndex, challengeResults) => {
|
|
83
|
+
if (!communityChallenge) {
|
|
84
|
+
throw Error(`shouldExcludeChallengeSuccess invalid communityChallenge argument '${communityChallenge}'`);
|
|
85
|
+
}
|
|
86
|
+
if (challengeResults && !Array.isArray(challengeResults)) {
|
|
87
|
+
throw Error(`shouldExcludeChallengeSuccess invalid challengeResults argument '${challengeResults}'`);
|
|
88
|
+
}
|
|
89
|
+
// no challenge results or no exclude rules
|
|
90
|
+
if (!challengeResults?.length || !communityChallenge.exclude?.length) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const challengeToExclude = challengeResults[communityChallengeIndex];
|
|
94
|
+
if (!challengeToExclude) {
|
|
95
|
+
throw Error(`shouldExcludeChallengeSuccess invalid communityChallengeIndex '${communityChallengeIndex}'`);
|
|
96
|
+
}
|
|
97
|
+
const challengeToExcludeIsPending = "challenge" in challengeToExclude;
|
|
98
|
+
// if match any of the exclude array, should exclude
|
|
99
|
+
for (const excludeItem of communityChallenge.exclude) {
|
|
100
|
+
// has no challenge success exclude rules
|
|
101
|
+
if (!excludeItem.challenges?.length) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
// if any of exclude.challenges failed, don't exclude
|
|
105
|
+
let shouldExclude = true;
|
|
106
|
+
for (const challengeIndex of excludeItem.challenges) {
|
|
107
|
+
const challengeResult = challengeResults[challengeIndex];
|
|
108
|
+
// config mistake, excluded challenge index doesn't exist
|
|
109
|
+
if (!challengeResult) {
|
|
110
|
+
shouldExclude = false;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
const challengeSuccess = "success" in challengeResult && challengeResult.success === true;
|
|
114
|
+
// if a challenge is pending, it can exclude another non-pending challenge
|
|
115
|
+
const challengePending = "challenge" in challengeResult && !challengeToExcludeIsPending;
|
|
116
|
+
if (!challengeSuccess && !challengePending) {
|
|
117
|
+
// found a false, should not exclude based on this exclude item,
|
|
118
|
+
// but try again in the next exclude item
|
|
119
|
+
shouldExclude = false;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// if all exclude.challenges succeeded, should exclude
|
|
124
|
+
if (shouldExclude) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
};
|
|
130
|
+
const commentCache = new QuickLRU({
|
|
131
|
+
maxSize: 10000
|
|
132
|
+
});
|
|
133
|
+
// cache for fetching comment updates, expire after 1 day
|
|
134
|
+
const commentUpdateCache = new TinyCache();
|
|
135
|
+
const commentUpdateCacheTime = 1000 * 60 * 60;
|
|
136
|
+
const getCommentPending = {}; // cid -> boolean if it's loading or not
|
|
137
|
+
const shouldExcludeChallengeCommentCids = async (communityChallenge, challengeRequestMessage, pkc) => {
|
|
138
|
+
if (!communityChallenge) {
|
|
139
|
+
throw Error(`shouldExcludeChallengeCommentCids invalid communityChallenge argument '${communityChallenge}'`);
|
|
140
|
+
}
|
|
141
|
+
if (!challengeRequestMessage) {
|
|
142
|
+
throw Error(`shouldExcludeChallengeCommentCids invalid challengeRequestMessage argument '${challengeRequestMessage}'`);
|
|
143
|
+
}
|
|
144
|
+
if (typeof pkc?.getComment !== "function") {
|
|
145
|
+
throw Error(`shouldExcludeChallengeCommentCids invalid pkc argument '${pkc}'`);
|
|
146
|
+
}
|
|
147
|
+
const publication = derivePublicationFromChallengeRequest(challengeRequestMessage);
|
|
148
|
+
const commentCids = challengeRequestMessage.challengeCommentCids;
|
|
149
|
+
const author = publication?.author;
|
|
150
|
+
if (commentCids && !Array.isArray(commentCids)) {
|
|
151
|
+
throw Error(`shouldExcludeChallengeCommentCids invalid commentCids argument '${commentCids}'`);
|
|
152
|
+
}
|
|
153
|
+
if (!author?.address || typeof author?.address !== "string") {
|
|
154
|
+
throw Error(`shouldExcludeChallengeCommentCids invalid challengeRequestMessage.publication.author.address argument '${author?.address}'`);
|
|
155
|
+
}
|
|
156
|
+
const _getComment = async (commentCid, addressesSet) => {
|
|
157
|
+
// comment is cached
|
|
158
|
+
let cachedComment = commentCache.get(commentCid);
|
|
159
|
+
// comment is not cached, add to cache
|
|
160
|
+
let comment;
|
|
161
|
+
if (!cachedComment) {
|
|
162
|
+
comment = await pkc.getComment({ cid: commentCid });
|
|
163
|
+
// only cache useful values
|
|
164
|
+
cachedComment = { communityAddress: comment.communityAddress, author: { address: comment.author.address } };
|
|
165
|
+
commentCache.set(commentCid, cachedComment);
|
|
166
|
+
}
|
|
167
|
+
// community address doesn't match filter
|
|
168
|
+
if (!addressesSet.has(cachedComment.communityAddress)) {
|
|
169
|
+
throw Error(`comment doesn't have matching community address`);
|
|
170
|
+
}
|
|
171
|
+
// author address doesn't match author
|
|
172
|
+
if (cachedComment?.author?.address !== author.address) {
|
|
173
|
+
throw Error(`comment author address doesn't match publication author address`);
|
|
174
|
+
}
|
|
175
|
+
// comment hasn't been updated yet
|
|
176
|
+
let cachedCommentUpdate = commentUpdateCache.get(commentCid);
|
|
177
|
+
if (!cachedCommentUpdate) {
|
|
178
|
+
const commentUpdate = comment || (await pkc.createComment({ cid: commentCid }));
|
|
179
|
+
const onUpdate = () => typeof commentUpdate.updatedAt === "number" && resolveUpdate(1);
|
|
180
|
+
let resolveUpdate;
|
|
181
|
+
const commentUpdatePromise = new Promise((resolve) => {
|
|
182
|
+
resolveUpdate = resolve;
|
|
183
|
+
commentUpdate.on("update", onUpdate);
|
|
184
|
+
});
|
|
185
|
+
await commentUpdate.update();
|
|
186
|
+
await commentUpdatePromise;
|
|
187
|
+
await commentUpdate.stop();
|
|
188
|
+
commentUpdate.removeListener("update", onUpdate);
|
|
189
|
+
// only cache useful values
|
|
190
|
+
if (commentUpdate?.author?.community) {
|
|
191
|
+
cachedCommentUpdate = { author: { community: commentUpdate?.author?.community } };
|
|
192
|
+
commentUpdateCache.put(commentCid, cachedCommentUpdate, commentUpdateCacheTime);
|
|
193
|
+
}
|
|
194
|
+
commentUpdateCache._timeouts[commentCid].unref?.();
|
|
195
|
+
}
|
|
196
|
+
return { ...cachedComment, author: { ...cachedComment.author, ...cachedCommentUpdate?.author } };
|
|
197
|
+
};
|
|
198
|
+
const getComment = async (commentCid, addressesSet) => {
|
|
199
|
+
// don't fetch the same comment twice
|
|
200
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
201
|
+
const pendingKey = commentCid + pkc.parsedPKCOptions?.ipfsGatewayUrls?.[0] + pkc.parsedPKCOptions?.kuboRpcClientsOptions?.[0].url;
|
|
202
|
+
while (getCommentPending[pendingKey] === true) {
|
|
203
|
+
await sleep(20);
|
|
204
|
+
}
|
|
205
|
+
getCommentPending[pendingKey] = true;
|
|
206
|
+
try {
|
|
207
|
+
const res = await _getComment(commentCid, addressesSet);
|
|
208
|
+
return res;
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
throw e;
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
getCommentPending[pendingKey] = false;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const validateComment = async (commentCid, addressesSet, exclude) => {
|
|
218
|
+
const comment = await getComment(commentCid, addressesSet);
|
|
219
|
+
const { postScore, replyScore, firstCommentTimestamp } = exclude?.community || {};
|
|
220
|
+
if (testScore(postScore, comment.author?.community?.postScore) &&
|
|
221
|
+
testScore(replyScore, comment.author?.community?.replyScore) &&
|
|
222
|
+
testFirstCommentTimestamp(firstCommentTimestamp, comment.author?.community?.firstCommentTimestamp)) {
|
|
223
|
+
// do nothing, comment is valid
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
throw Error(`should not exclude comment cid`);
|
|
227
|
+
};
|
|
228
|
+
const validateExclude = async (exclude) => {
|
|
229
|
+
let { addresses, maxCommentCids } = exclude?.community || {};
|
|
230
|
+
if (!maxCommentCids) {
|
|
231
|
+
maxCommentCids = 3;
|
|
232
|
+
}
|
|
233
|
+
// no friendly community addresses
|
|
234
|
+
if (!addresses?.length) {
|
|
235
|
+
throw Error("no friendly community addresses");
|
|
236
|
+
}
|
|
237
|
+
const addressesSet = new Set(addresses);
|
|
238
|
+
// author didn't provide comment cids
|
|
239
|
+
if (!commentCids?.length) {
|
|
240
|
+
throw Error(`author didn't provide comment cids`);
|
|
241
|
+
}
|
|
242
|
+
// fetch and test all comments of the author async
|
|
243
|
+
const validateCommentPromises = [];
|
|
244
|
+
let i = 0;
|
|
245
|
+
while (i < maxCommentCids) {
|
|
246
|
+
const commentCid = commentCids[i++];
|
|
247
|
+
if (commentCid) {
|
|
248
|
+
validateCommentPromises.push(validateComment(commentCid, addressesSet, exclude));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// if doesn't throw, at least 1 comment was valid
|
|
252
|
+
try {
|
|
253
|
+
await Promise.any(validateCommentPromises);
|
|
254
|
+
}
|
|
255
|
+
catch (e) {
|
|
256
|
+
// console.log(validateCommentPromises) // debug all validate comments
|
|
257
|
+
if (e instanceof Error)
|
|
258
|
+
e.message = `should not exclude: ${e.message}`;
|
|
259
|
+
throw e;
|
|
260
|
+
}
|
|
261
|
+
// if at least 1 comment was valid, do nothing, exclude is valid
|
|
262
|
+
};
|
|
263
|
+
// iterate over all excludes, and validate them async
|
|
264
|
+
const validateExcludePromises = [];
|
|
265
|
+
for (const exclude of communityChallenge.exclude || []) {
|
|
266
|
+
validateExcludePromises.push(validateExclude(exclude));
|
|
267
|
+
}
|
|
268
|
+
// if at least 1 valid exclude, should exclude
|
|
269
|
+
try {
|
|
270
|
+
await Promise.any(validateExcludePromises);
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
catch (e) {
|
|
274
|
+
// console.log(validateExcludePromises) // debug all validate excludes
|
|
275
|
+
}
|
|
276
|
+
// if no exclude are valid, should not exclude
|
|
277
|
+
return false;
|
|
278
|
+
};
|
|
279
|
+
export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess };
|
|
280
|
+
//# sourceMappingURL=exclude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exclude.js","sourceRoot":"","sources":["../../../../../../../src/runtime/node/community/challenges/exclude/exclude.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMlD,OAAO,EAAE,qCAAqC,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAE/E,MAAM,wBAAwB,GAAG,CAC7B,kBAAsC,EACtC,OAAgE,EAChE,SAAyB,EAC3B,EAAE;IACA,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACtB,MAAM,KAAK,CAAC,iEAAiE,kBAAkB,GAAG,CAAC,CAAC;IACxG,CAAC;IACD,MAAM,WAAW,GAAG,qCAAqC,CAAC,OAAO,CAAC,CAAC;IACnE,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC,0DAA0D,WAAW,GAAG,CAAC,CAAC;IAC1F,CAAC;IACD,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAElC,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IAC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AO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,sEAAsE;YACtE,IAAI,CAAC,YAAY,KAAK;gBAAE,CAAC,CAAC,OAAO,GAAG,uBAAuB,CAAC,CAAC,OAAO,EAAE,CAAC;YACvE,MAAM,CAAC,CAAC;QACZ,CAAC;QAED,gEAAgE;IACpE,CAAC,CAAC;IAEF,qDAAqD;IACrD,MAAM,uBAAuB,GAAG,EAAE,CAAC;IACnC,KAAK,MAAM,OAAO,IAAI,kBAAkB,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;QACrD,uBAAuB,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,8CAA8C;IAC9C,IAAI,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,sEAAsE;IAC1E,CAAC;IAED,8CAA8C;IAC9C,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess } from "./exclude.js";
|
|
2
|
+
import { addToRateLimiter } from "./rate-limiter.js";
|
|
3
|
+
export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess, addToRateLimiter };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess } from "./exclude.js";
|
|
2
|
+
import { addToRateLimiter } from "./rate-limiter.js";
|
|
3
|
+
export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess, addToRateLimiter };
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/runtime/node/community/challenges/exclude/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAC1H,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DecryptedChallengeRequestMessageTypeWithCommunityAuthor } from "../../../../../pubsub-messages/types.js";
|
|
2
|
+
import type { ChallengeResult, Exclude, CommunitySettings } from "../../../../../community/types.js";
|
|
3
|
+
declare const testRateLimit: (exclude: Exclude, request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
|
|
4
|
+
declare const addToRateLimiter: (communityChallenges: NonNullable<CommunitySettings["challenges"]>, request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor, challengeSuccess: ChallengeResult["success"]) => void;
|
|
5
|
+
export { addToRateLimiter, testRateLimit };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import QuickLRU from "quick-lru";
|
|
2
|
+
import { isVote, isReply, isPost, isCommentEdit, isCommentModeration, isCommunityEdit, testPublicationType } from "./utils.js";
|
|
3
|
+
import * as limiterCompat from "limiter-es6-compat";
|
|
4
|
+
import { derivePublicationFromChallengeRequest } from "../../../../../util.js";
|
|
5
|
+
// Workaround for NodeNext moduleResolution compatibility
|
|
6
|
+
const { RateLimiter } = limiterCompat;
|
|
7
|
+
// each author could have 20+ rate limiters each if the community has
|
|
8
|
+
// several rate limit rules so keep a large cache
|
|
9
|
+
const rateLimiters = new QuickLRU({ maxSize: 50000 });
|
|
10
|
+
const getPublicationType = (request) => isPost(request)
|
|
11
|
+
? "post"
|
|
12
|
+
: isReply(request)
|
|
13
|
+
? "reply"
|
|
14
|
+
: isVote(request)
|
|
15
|
+
? "vote"
|
|
16
|
+
: isCommentEdit(request)
|
|
17
|
+
? "commentEdit"
|
|
18
|
+
: isCommentModeration(request)
|
|
19
|
+
? "commentModeration"
|
|
20
|
+
: isCommunityEdit(request)
|
|
21
|
+
? "communityEdit"
|
|
22
|
+
: undefined;
|
|
23
|
+
const getRateLimiterName = (exclude, publication, publicationType, challengeSuccess) => `${publication.author.address}-${exclude.rateLimit}-${publicationType}-${challengeSuccess}`;
|
|
24
|
+
const getOrCreateRateLimiter = (exclude, publication, publicationType, challengeSuccess) => {
|
|
25
|
+
if (typeof exclude.rateLimit !== "number")
|
|
26
|
+
throw Error("Can't create a RateLimiter without exclude.rateLimit");
|
|
27
|
+
const rateLimiterName = getRateLimiterName(exclude, publication, publicationType, challengeSuccess);
|
|
28
|
+
let rateLimiter = rateLimiters.get(rateLimiterName);
|
|
29
|
+
if (!rateLimiter) {
|
|
30
|
+
rateLimiter = new RateLimiter({ tokensPerInterval: exclude.rateLimit, interval: "hour", fireImmediately: true });
|
|
31
|
+
// @ts-ignore - adding name property for debugging
|
|
32
|
+
rateLimiter.name = rateLimiterName; // add name for debugging
|
|
33
|
+
rateLimiters.set(rateLimiterName, rateLimiter);
|
|
34
|
+
}
|
|
35
|
+
return rateLimiter;
|
|
36
|
+
};
|
|
37
|
+
const addFilteredRateLimiter = (exclude, publication, publicationType, challengeSuccess, filteredRateLimiters) => {
|
|
38
|
+
filteredRateLimiters[getRateLimiterName(exclude, publication, publicationType, challengeSuccess)] = getOrCreateRateLimiter(exclude, publication, publicationType, challengeSuccess);
|
|
39
|
+
};
|
|
40
|
+
const getRateLimitersToTest = (exclude, request, challengeSuccess) => {
|
|
41
|
+
// TODO I think we need to change this
|
|
42
|
+
const publication = derivePublicationFromChallengeRequest(request);
|
|
43
|
+
// get all rate limiters associated with the exclude (publication type and challengeSuccess true/false)
|
|
44
|
+
const filteredRateLimiters = {};
|
|
45
|
+
if (testPublicationType(exclude.publicationType, request)) {
|
|
46
|
+
const publicationType = getPublicationType(request);
|
|
47
|
+
if (publicationType) {
|
|
48
|
+
addFilteredRateLimiter(exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return filteredRateLimiters;
|
|
52
|
+
};
|
|
53
|
+
const testRateLimit = (exclude, request) => {
|
|
54
|
+
// will come back here later
|
|
55
|
+
if (exclude?.rateLimit === undefined || !testPublicationType(exclude.publicationType, request)) {
|
|
56
|
+
// early exit based on exclude type and publication type
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
// if rateLimitChallengeSuccess is undefined or true, only use {challengeSuccess: true} rate limiters
|
|
60
|
+
let challengeSuccess = true;
|
|
61
|
+
if (exclude.rateLimitChallengeSuccess === false) {
|
|
62
|
+
challengeSuccess = false;
|
|
63
|
+
}
|
|
64
|
+
// check all the rate limiters that match the exclude and publication type
|
|
65
|
+
const rateLimiters = getRateLimitersToTest(exclude, request, challengeSuccess);
|
|
66
|
+
// if any of the matching rate limiter is out of tokens, test failed
|
|
67
|
+
for (const rateLimiter of Object.values(rateLimiters)) {
|
|
68
|
+
const tokensRemaining = rateLimiter.getTokensRemaining();
|
|
69
|
+
// token per action is 1, so any value below 1 is invalid
|
|
70
|
+
if (tokensRemaining < 1)
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
};
|
|
75
|
+
const getRateLimitersToAddTo = (excludeArray, request, challengeSuccess) => {
|
|
76
|
+
// get all rate limiters associated with the exclude (publication type and challengeSuccess true/false)
|
|
77
|
+
const filteredRateLimiters = {};
|
|
78
|
+
const publication = derivePublicationFromChallengeRequest(request);
|
|
79
|
+
for (const exclude of excludeArray) {
|
|
80
|
+
if (exclude?.rateLimit === undefined) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const publicationType = getPublicationType(request);
|
|
84
|
+
if (publicationType) {
|
|
85
|
+
addFilteredRateLimiter(exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
|
|
86
|
+
}
|
|
87
|
+
if (request.commentEdit) {
|
|
88
|
+
addFilteredRateLimiter(exclude, publication, "commentEdit", challengeSuccess, filteredRateLimiters);
|
|
89
|
+
}
|
|
90
|
+
if (request.commentModeration) {
|
|
91
|
+
addFilteredRateLimiter(exclude, publication, "commentModeration", challengeSuccess, filteredRateLimiters);
|
|
92
|
+
}
|
|
93
|
+
if (request.communityEdit) {
|
|
94
|
+
addFilteredRateLimiter(exclude, publication, "communityEdit", challengeSuccess, filteredRateLimiters);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return filteredRateLimiters;
|
|
98
|
+
};
|
|
99
|
+
const addToRateLimiter = (communityChallenges, request, challengeSuccess) => {
|
|
100
|
+
if (!communityChallenges) {
|
|
101
|
+
// community has no challenges, no need to rate limit
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!Array.isArray(communityChallenges)) {
|
|
105
|
+
throw Error(`addToRateLimiter invalid argument communityChallenges '${communityChallenges}' not an array`);
|
|
106
|
+
}
|
|
107
|
+
if (typeof challengeSuccess !== "boolean") {
|
|
108
|
+
throw Error(`addToRateLimiter invalid argument challengeSuccess '${challengeSuccess}' not a boolean`);
|
|
109
|
+
}
|
|
110
|
+
// get all exclude items from all community challenges
|
|
111
|
+
const excludeArray = [];
|
|
112
|
+
for (const communityChallenge of communityChallenges) {
|
|
113
|
+
for (const exclude of communityChallenge?.exclude || []) {
|
|
114
|
+
excludeArray.push(exclude);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!excludeArray.length) {
|
|
118
|
+
// no need to add to rate limiter if the community has no exclude rules in any challenges
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const rateLimiters = getRateLimitersToAddTo(excludeArray, request, challengeSuccess);
|
|
122
|
+
for (const rateLimiter of Object.values(rateLimiters)) {
|
|
123
|
+
rateLimiter.tryRemoveTokens(1);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
export { addToRateLimiter, testRateLimit };
|
|
127
|
+
//# sourceMappingURL=rate-limiter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limiter.js","sourceRoot":"","sources":["../../../../../../../src/runtime/node/community/challenges/exclude/rate-limiter.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAM/H,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACH,qCAAqC,EAGxC,MAAM,wBAAwB,CAAC;AAEhC,yDAAyD;AACzD,MAAM,EAAE,WAAW,EAAE,GAAG,aAAoB,CAAC;AAI7C,qEAAqE;AACrE,iDAAiD;AACjD,MAAM,YAAY,GAAG,IAAI,QAAQ,CAA8B,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AAEnF,MAAM,kBAAkB,GAAG,CAAC,OAAgE,EAA+B,EAAE,CACzH,MAAM,CAAC,OAAO,CAAC;IACX,CAAC,CAAC,MAAM;IACR,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;QAChB,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;YACf,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC;gBACtB,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC;oBAC5B,CAAC,CAAC,mBAAmB;oBACrB,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC;wBACxB,CAAC,CAAC,eAAe;wBACjB,CAAC,CAAC,SAAS,CAAC;AAE9B,MAAM,kBAAkB,GAAG,CACvB,OAAgB,EAChB,WAAwE,EACx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,0DAA0D,mBAAmB,gBAAgB,CAAC,CAAC;IAC/G,CAAC;IAED,IAAI,OAAO,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,KAAK,CAAC,uDAAuD,gBAAgB,iBAAiB,CAAC,CAAC;IAC1G,CAAC;IAED,sDAAsD;IACtD,MAAM,YAAY,GAAG,EAAE,CAAC;IACxB,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QACnD,KAAK,MAAM,OAAO,IAAI,kBAAkB,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;YACtD,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QACvB,yFAAyF;QACzF,OAAO;IACX,CAAC;IAED,MAAM,YAAY,GAAG,sBAAsB,CAAC,YAAY,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACrF,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QACpD,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CommunityIpfsType, CommunityRole, Exclude } from "../../../../../community/types.js";
|
|
2
|
+
import type { DecryptedChallengeRequestMessageTypeWithCommunityAuthor } from "../../../../../pubsub-messages/types.js";
|
|
3
|
+
declare const testScore: (excludeScore: number | undefined, authorScore: number | undefined) => boolean;
|
|
4
|
+
declare const testFirstCommentTimestamp: (excludeTime: number | undefined, authorFirstCommentTimestamp: number | undefined) => boolean;
|
|
5
|
+
declare const testRole: (excludeRole: CommunityRole["role"][], authorAddress: string, communityRoles: CommunityIpfsType["roles"]) => boolean;
|
|
6
|
+
declare const isVote: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
|
|
7
|
+
declare const isReply: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => request is import("../../../../../pubsub-messages/types.js").DecryptedChallengeRequestMessageWithReplyCommunityAuthor;
|
|
8
|
+
declare const isPost: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => request is import("../../../../../pubsub-messages/types.js").DecryptedChallengeRequestMessageWithPostCommunityAuthor;
|
|
9
|
+
declare const isCommentEdit: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
|
|
10
|
+
declare const isCommentModeration: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
|
|
11
|
+
declare const isCommunityEdit: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
|
|
12
|
+
declare const testPublicationType: (excludePublicationType: Exclude["publicationType"] | undefined, request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
|
|
13
|
+
export { isVote, isReply, isPost, isCommentEdit, isCommentModeration, isCommunityEdit, testPublicationType, testScore, testFirstCommentTimestamp, testRole };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isRequestPubsubPublicationOfPost, isRequestPubsubPublicationOfReply } from "../../../../../util.js";
|
|
2
|
+
// e.g. secondsToGoBack = 60 would return the timestamp 1 minute ago
|
|
3
|
+
const getTimestampSecondsAgo = (secondsToGoBack) => Math.round(Date.now() / 1000) - secondsToGoBack;
|
|
4
|
+
const testScore = (excludeScore, authorScore) => excludeScore === undefined || excludeScore <= (authorScore || 0);
|
|
5
|
+
// firstCommentTimestamp value first needs to be put through Date.now() - firstCommentTimestamp
|
|
6
|
+
const testFirstCommentTimestamp = (excludeTime, authorFirstCommentTimestamp) => excludeTime === undefined || getTimestampSecondsAgo(excludeTime) >= (authorFirstCommentTimestamp || Infinity);
|
|
7
|
+
const testRole = (excludeRole, authorAddress, communityRoles) => {
|
|
8
|
+
if (excludeRole === undefined) {
|
|
9
|
+
return true; // No role exclusion rule, so this test passes
|
|
10
|
+
}
|
|
11
|
+
if (communityRoles === undefined) {
|
|
12
|
+
return false; // Can't verify roles, so assume user doesn't have excluded role
|
|
13
|
+
}
|
|
14
|
+
for (const roleName of excludeRole) {
|
|
15
|
+
if (communityRoles[authorAddress]?.role === roleName) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
const isVote = (request) => Boolean(request.vote);
|
|
22
|
+
const isReply = (request) => isRequestPubsubPublicationOfReply(request);
|
|
23
|
+
const isPost = (request) => isRequestPubsubPublicationOfPost(request);
|
|
24
|
+
const isCommentEdit = (request) => Boolean(request.commentEdit);
|
|
25
|
+
const isCommentModeration = (request) => Boolean(request.commentModeration);
|
|
26
|
+
const isCommunityEdit = (request) => Boolean(request.communityEdit);
|
|
27
|
+
const testPublicationType = (excludePublicationType, request) => {
|
|
28
|
+
if (excludePublicationType === undefined) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (excludePublicationType.post && isPost(request)) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (excludePublicationType.reply && isReply(request)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (excludePublicationType.vote && isVote(request)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (excludePublicationType.commentEdit && isCommentEdit(request)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (excludePublicationType.commentModeration && isCommentModeration(request)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (excludePublicationType.communityEdit && isCommunityEdit(request)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
export { isVote, isReply, isPost, isCommentEdit, isCommentModeration, isCommunityEdit, testPublicationType, testScore, testFirstCommentTimestamp, testRole };
|
|
52
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 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,EAAE,CAAC;QACnE,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EACH,MAAM,EACN,OAAO,EACP,MAAM,EACN,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,yBAAyB,EACzB,QAAQ,EACX,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ChallengeVerificationMessageType, DecryptedChallengeAnswer, DecryptedChallengeRequestMessageTypeWithCommunityAuthor } from "../../../../pubsub-messages/types.js";
|
|
2
|
+
import type { Challenge, ChallengeFileFactoryInput, CommunityChallenge, CommunityChallengeSetting } from "../../../../community/types.js";
|
|
3
|
+
import { LocalCommunity } from "../local-community.js";
|
|
4
|
+
type PendingChallenge = Challenge & {
|
|
5
|
+
index: number;
|
|
6
|
+
};
|
|
7
|
+
export type GetChallengeAnswers = (challenges: Omit<Challenge, "verify">[]) => Promise<DecryptedChallengeAnswer["challengeAnswers"]>;
|
|
8
|
+
type ChallengeVerificationSuccess = {
|
|
9
|
+
challengeSuccess: true;
|
|
10
|
+
pendingApprovalSuccess: boolean;
|
|
11
|
+
};
|
|
12
|
+
type ChallengeVerificationPending = {
|
|
13
|
+
pendingChallenges: PendingChallenge[];
|
|
14
|
+
pendingApprovalSuccess: boolean;
|
|
15
|
+
};
|
|
16
|
+
type ChallengeVerificationFailure = {
|
|
17
|
+
challengeSuccess: false;
|
|
18
|
+
challengeErrors: NonNullable<ChallengeVerificationMessageType["challengeErrors"]>;
|
|
19
|
+
};
|
|
20
|
+
type PKCWithSettingsChallenges = {
|
|
21
|
+
settings?: {
|
|
22
|
+
challenges?: Record<string, ChallengeFileFactoryInput>;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
declare const pkcJsChallenges: Record<string, ChallengeFileFactoryInput>;
|
|
26
|
+
declare const getPendingChallengesOrChallengeVerification: (challengeRequestMessage: DecryptedChallengeRequestMessageTypeWithCommunityAuthor, community: LocalCommunity) => Promise<ChallengeVerificationSuccess | ChallengeVerificationPending | ChallengeVerificationFailure>;
|
|
27
|
+
declare const getChallengeVerificationFromChallengeAnswers: (pendingChallenges: PendingChallenge[], challengeAnswers: DecryptedChallengeAnswer["challengeAnswers"], community: LocalCommunity) => Promise<ChallengeVerificationSuccess | ChallengeVerificationFailure>;
|
|
28
|
+
declare const getChallengeVerification: (challengeRequestMessage: DecryptedChallengeRequestMessageTypeWithCommunityAuthor, community: LocalCommunity, getChallengeAnswers: GetChallengeAnswers) => Promise<Pick<ChallengeVerificationMessageType, "challengeErrors" | "challengeSuccess"> & {
|
|
29
|
+
pendingApproval?: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
declare const getCommunityChallengeFromCommunityChallengeSettings: (communityChallengeSettings: CommunityChallengeSetting, pkc?: PKCWithSettingsChallenges) => Promise<CommunityChallenge>;
|
|
32
|
+
export { pkcJsChallenges, getPendingChallengesOrChallengeVerification, getChallengeVerificationFromChallengeAnswers, getChallengeVerification, getCommunityChallengeFromCommunityChallengeSettings };
|