@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,816 @@
|
|
|
1
|
+
import { messages } from "./errors.js";
|
|
2
|
+
import { PKCError } from "./pkc-error.js";
|
|
3
|
+
//@ts-expect-error
|
|
4
|
+
import extName from "ext-name";
|
|
5
|
+
import { CID } from "kubo-rpc-client";
|
|
6
|
+
import * as Digest from "multiformats/hashes/digest";
|
|
7
|
+
import { Buffer } from "buffer";
|
|
8
|
+
import { base58btc } from "multiformats/bases/base58";
|
|
9
|
+
import * as remeda from "remeda";
|
|
10
|
+
import { DecryptedChallengeRequestPublicationSchema } from "./pubsub-messages/schema.js";
|
|
11
|
+
import pTimeout from "p-timeout";
|
|
12
|
+
import { of as calculateIpfsCidV0Lib } from "typestub-ipfs-only-hash";
|
|
13
|
+
import { toString as uint8ArrayToString } from "uint8arrays/to-string";
|
|
14
|
+
import { sha256 } from "js-sha256";
|
|
15
|
+
import { base32 } from "multiformats/bases/base32";
|
|
16
|
+
import Logger from "./logger.js";
|
|
17
|
+
import retry from "retry";
|
|
18
|
+
import PeerId from "peer-id";
|
|
19
|
+
import { unmarshalIPNSRecord } from "ipns";
|
|
20
|
+
import { importFile } from "ipfs-unixfs-importer";
|
|
21
|
+
import { MemoryBlockstore } from "blockstore-core";
|
|
22
|
+
import { findUpdatingCommunity } from "./pkc/tracked-instance-registry-util.js";
|
|
23
|
+
export function timestamp() {
|
|
24
|
+
return Math.round(Date.now() / 1000);
|
|
25
|
+
}
|
|
26
|
+
export function createAbortError(message = "The operation was aborted") {
|
|
27
|
+
const error = new Error(message);
|
|
28
|
+
error.name = "AbortError";
|
|
29
|
+
return error;
|
|
30
|
+
}
|
|
31
|
+
export function isAbortError(error) {
|
|
32
|
+
return error instanceof Error && error.name === "AbortError";
|
|
33
|
+
}
|
|
34
|
+
export function throwIfAbortSignalAborted(signal) {
|
|
35
|
+
if (!signal?.aborted)
|
|
36
|
+
return;
|
|
37
|
+
if (signal.reason instanceof Error) {
|
|
38
|
+
signal.reason.name = signal.reason.name || "AbortError";
|
|
39
|
+
throw signal.reason;
|
|
40
|
+
}
|
|
41
|
+
if (typeof signal.reason === "string" && signal.reason.length > 0)
|
|
42
|
+
throw createAbortError(signal.reason);
|
|
43
|
+
throw createAbortError();
|
|
44
|
+
}
|
|
45
|
+
export function replaceXWithY(obj, x, y) {
|
|
46
|
+
// obj is a JS object
|
|
47
|
+
if (!remeda.isPlainObject(obj))
|
|
48
|
+
return obj;
|
|
49
|
+
const newObj = {};
|
|
50
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
51
|
+
if (obj[key] === x)
|
|
52
|
+
newObj[key] = y;
|
|
53
|
+
// `typeof`` gives browser transpiling error "Uncaught ReferenceError: exports is not defined"
|
|
54
|
+
// don't know why but it can be fixed by replacing with `instanceof`
|
|
55
|
+
// else if (typeof value === "object" && value !== null) newObj[key] = replaceXWithY(value, x, y);
|
|
56
|
+
else if (remeda.isPlainObject(value))
|
|
57
|
+
newObj[key] = replaceXWithY(value, x, y);
|
|
58
|
+
else if (Array.isArray(value))
|
|
59
|
+
newObj[key] = value.map((iterValue) => replaceXWithY(iterValue, x, y));
|
|
60
|
+
else
|
|
61
|
+
newObj[key] = value;
|
|
62
|
+
});
|
|
63
|
+
return newObj;
|
|
64
|
+
}
|
|
65
|
+
export function removeNullUndefinedValues(obj) {
|
|
66
|
+
return remeda.pickBy(obj, remeda.isNonNullish);
|
|
67
|
+
}
|
|
68
|
+
function removeUndefinedValues(obj) {
|
|
69
|
+
return remeda.pickBy(obj, remeda.isDefined.strict);
|
|
70
|
+
}
|
|
71
|
+
function removeNullUndefinedEmptyObjectValues(obj) {
|
|
72
|
+
const firstStep = removeNullUndefinedValues(obj); // remove undefined and null values
|
|
73
|
+
const secondStep = remeda.omitBy(firstStep, (value) => remeda.isPlainObject(value) && remeda.isEmpty(value)); // remove empty {} values
|
|
74
|
+
return secondStep;
|
|
75
|
+
}
|
|
76
|
+
// A safe function that you can use that will not modify a JSON by removing null or empty objects
|
|
77
|
+
export function removeUndefinedValuesRecursively(obj) {
|
|
78
|
+
if (Array.isArray(obj))
|
|
79
|
+
return obj.map(removeUndefinedValuesRecursively);
|
|
80
|
+
if (!remeda.isPlainObject(obj))
|
|
81
|
+
return obj;
|
|
82
|
+
const cleanedObj = removeUndefinedValues(obj);
|
|
83
|
+
for (const [key, value] of Object.entries(cleanedObj))
|
|
84
|
+
if (remeda.isPlainObject(value) || Array.isArray(value))
|
|
85
|
+
cleanedObj[key] = removeUndefinedValuesRecursively(value);
|
|
86
|
+
return cleanedObj;
|
|
87
|
+
}
|
|
88
|
+
export function removeNullUndefinedEmptyObjectsValuesRecursively(obj) {
|
|
89
|
+
if (Array.isArray(obj))
|
|
90
|
+
return obj.map(removeNullUndefinedEmptyObjectsValuesRecursively);
|
|
91
|
+
if (!remeda.isPlainObject(obj))
|
|
92
|
+
return obj;
|
|
93
|
+
const cleanedObj = removeNullUndefinedEmptyObjectValues(obj);
|
|
94
|
+
for (const key of Object.keys(cleanedObj)) {
|
|
95
|
+
if (remeda.isPlainObject(cleanedObj[key]) || Array.isArray(cleanedObj[key]))
|
|
96
|
+
cleanedObj[key] = removeNullUndefinedEmptyObjectsValuesRecursively(cleanedObj[key]);
|
|
97
|
+
if (remeda.isPlainObject(cleanedObj[key]) && remeda.isEmpty(cleanedObj[key]))
|
|
98
|
+
delete cleanedObj[key];
|
|
99
|
+
}
|
|
100
|
+
return cleanedObj;
|
|
101
|
+
}
|
|
102
|
+
const parseIfJsonString = (jsonString) => {
|
|
103
|
+
if (typeof jsonString !== "string" || (!jsonString.startsWith("{") && !jsonString.startsWith("[")))
|
|
104
|
+
return undefined;
|
|
105
|
+
try {
|
|
106
|
+
return JSON.parse(jsonString);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
// Only for DB
|
|
113
|
+
export const parseDbResponses = (obj) => {
|
|
114
|
+
// This function is gonna be called for every query on db, it should be optimized
|
|
115
|
+
if (obj === "[object Object]")
|
|
116
|
+
throw Error(`Object shouldn't be [object Object]`);
|
|
117
|
+
if (Array.isArray(obj))
|
|
118
|
+
return obj.map((o) => parseDbResponses(o));
|
|
119
|
+
const parsedJsonString = parseIfJsonString(obj);
|
|
120
|
+
if (!remeda.isPlainObject(obj) && !parsedJsonString)
|
|
121
|
+
return obj;
|
|
122
|
+
const newObj = removeNullUndefinedValues(parsedJsonString || obj); // we may need clone here, not sure
|
|
123
|
+
const booleanFields = [
|
|
124
|
+
"deleted",
|
|
125
|
+
"spoiler",
|
|
126
|
+
"pinned",
|
|
127
|
+
"locked",
|
|
128
|
+
"archived",
|
|
129
|
+
"removed",
|
|
130
|
+
"nsfw",
|
|
131
|
+
"commentIpfs_deleted",
|
|
132
|
+
"commentIpfs_nsfw",
|
|
133
|
+
"commentIpfs_spoiler",
|
|
134
|
+
"commentIpfs_pinned",
|
|
135
|
+
"commentIpfs_locked",
|
|
136
|
+
"commentIpfs_archived",
|
|
137
|
+
"commentIpfs_removed",
|
|
138
|
+
"commentUpdate_deleted",
|
|
139
|
+
"commentUpdate_spoiler",
|
|
140
|
+
"commentUpdate_pinned",
|
|
141
|
+
"commentUpdate_locked",
|
|
142
|
+
"commentUpdate_archived",
|
|
143
|
+
"commentUpdate_removed",
|
|
144
|
+
"commentUpdate_nsfw",
|
|
145
|
+
"isAuthorEdit",
|
|
146
|
+
"publishedToPostUpdatesIpfs"
|
|
147
|
+
]; // TODO use zod here
|
|
148
|
+
for (const [key, value] of Object.entries(newObj)) {
|
|
149
|
+
if (value === "[object Object]")
|
|
150
|
+
throw Error(`key (${key}) shouldn't be [object Object]`);
|
|
151
|
+
if (booleanFields.includes(key) && (value === 1 || value === 0))
|
|
152
|
+
newObj[key] = Boolean(value);
|
|
153
|
+
else
|
|
154
|
+
newObj[key] = parseIfJsonString(value) || value;
|
|
155
|
+
}
|
|
156
|
+
if (newObj.extraProps)
|
|
157
|
+
return { ...newObj, ...newObj.extraProps };
|
|
158
|
+
else if (newObj["commentIpfs_extraProps"]) {
|
|
159
|
+
// needed when creating pages
|
|
160
|
+
const mappedExtraPropsOnCommentIpfs = remeda.mapKeys(newObj["commentIpfs_extraProps"], (key) => `commentIpfs_${String(key)}`);
|
|
161
|
+
return { ...newObj, ...mappedExtraPropsOnCommentIpfs };
|
|
162
|
+
}
|
|
163
|
+
return newObj;
|
|
164
|
+
};
|
|
165
|
+
export function shortifyAddress(address) {
|
|
166
|
+
if (address.includes("."))
|
|
167
|
+
return address; // If a domain then no need to shortify
|
|
168
|
+
// Remove prefix (12D3KooW)
|
|
169
|
+
const removedPrefix = address.slice(8);
|
|
170
|
+
// Return first 12 characters
|
|
171
|
+
const shortAddress = removedPrefix.slice(0, 12);
|
|
172
|
+
return shortAddress;
|
|
173
|
+
}
|
|
174
|
+
export function shortifyCid(cid) {
|
|
175
|
+
// Remove prefix (Qm)
|
|
176
|
+
// Return first 12 characters
|
|
177
|
+
return cid.slice(2).slice(0, 12);
|
|
178
|
+
}
|
|
179
|
+
export function delay(ms) {
|
|
180
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
181
|
+
}
|
|
182
|
+
export function firstResolve(promises) {
|
|
183
|
+
return new Promise((resolve) => promises.forEach((promise) => promise.then(resolve)));
|
|
184
|
+
}
|
|
185
|
+
export function getErrorCodeFromMessage(message) {
|
|
186
|
+
const codes = remeda.keys.strict(messages);
|
|
187
|
+
for (const code of codes)
|
|
188
|
+
if (messages[code] === message)
|
|
189
|
+
return code;
|
|
190
|
+
throw Error(`No error code was found for message (${message})`);
|
|
191
|
+
}
|
|
192
|
+
export function doesDomainAddressHaveCapitalLetter(domainAddress) {
|
|
193
|
+
if (!domainAddress.includes("."))
|
|
194
|
+
return false;
|
|
195
|
+
return /[A-Z]/.test(domainAddress); // Regex test for capital letters in English only
|
|
196
|
+
}
|
|
197
|
+
export function getPostUpdateTimestampRange(postUpdates, postTimestamp) {
|
|
198
|
+
if (!postUpdates)
|
|
199
|
+
throw Error("community has no post updates");
|
|
200
|
+
if (!postTimestamp)
|
|
201
|
+
throw Error("post has no timestamp");
|
|
202
|
+
return (remeda.keys
|
|
203
|
+
.strict(postUpdates)
|
|
204
|
+
// sort from smallest to biggest
|
|
205
|
+
.sort((a, b) => Number(a) - Number(b))
|
|
206
|
+
// find the smallest timestamp range where comment.timestamp is newer
|
|
207
|
+
.filter((timestampRange) => timestamp() - Number(timestampRange) <= postTimestamp));
|
|
208
|
+
}
|
|
209
|
+
export function isLinkValid(link) {
|
|
210
|
+
try {
|
|
211
|
+
const url = new URL(link);
|
|
212
|
+
if (url.protocol !== "https:")
|
|
213
|
+
throw Error("Not a valid https url");
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
catch (e) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
export function isLinkOfMedia(link) {
|
|
221
|
+
if (!link)
|
|
222
|
+
return false;
|
|
223
|
+
let mime;
|
|
224
|
+
try {
|
|
225
|
+
mime = extName(new URL(link).pathname.toLowerCase().replace("/", ""))[0]?.mime;
|
|
226
|
+
}
|
|
227
|
+
catch (e) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
if (mime?.startsWith("image") || mime?.startsWith("video") || mime?.startsWith("audio"))
|
|
231
|
+
return true;
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
function getMimeFromUrl(url) {
|
|
235
|
+
try {
|
|
236
|
+
return extName(new URL(url).pathname.toLowerCase().replace("/", ""))[0]?.mime;
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function isUrlOfImage(url) {
|
|
243
|
+
const mime = getMimeFromUrl(url);
|
|
244
|
+
return mime?.startsWith("image") ?? false;
|
|
245
|
+
}
|
|
246
|
+
function isUrlOfVideo(url) {
|
|
247
|
+
const mime = getMimeFromUrl(url);
|
|
248
|
+
return mime?.startsWith("video") ?? false;
|
|
249
|
+
}
|
|
250
|
+
export function isLinkOfImage(link) {
|
|
251
|
+
if (!link)
|
|
252
|
+
return false;
|
|
253
|
+
return isUrlOfImage(link);
|
|
254
|
+
}
|
|
255
|
+
export function isLinkOfVideo(link) {
|
|
256
|
+
if (!link)
|
|
257
|
+
return false;
|
|
258
|
+
return isUrlOfVideo(link);
|
|
259
|
+
}
|
|
260
|
+
// Known animated image MIME types
|
|
261
|
+
const ANIMATED_IMAGE_MIMES = new Set(["image/gif", "image/apng"]);
|
|
262
|
+
function isUrlOfAnimatedImage(url) {
|
|
263
|
+
const mime = getMimeFromUrl(url);
|
|
264
|
+
return mime !== undefined && ANIMATED_IMAGE_MIMES.has(mime);
|
|
265
|
+
}
|
|
266
|
+
export function isLinkOfAnimatedImage(link) {
|
|
267
|
+
if (!link)
|
|
268
|
+
return false;
|
|
269
|
+
return isUrlOfAnimatedImage(link);
|
|
270
|
+
}
|
|
271
|
+
function isUrlOfAudio(url) {
|
|
272
|
+
const mime = getMimeFromUrl(url);
|
|
273
|
+
return mime?.startsWith("audio") ?? false;
|
|
274
|
+
}
|
|
275
|
+
export function isLinkOfAudio(link) {
|
|
276
|
+
if (!link)
|
|
277
|
+
return false;
|
|
278
|
+
return isUrlOfAudio(link);
|
|
279
|
+
}
|
|
280
|
+
export function contentContainsMarkdownImages(content) {
|
|
281
|
+
if (!content)
|
|
282
|
+
return false;
|
|
283
|
+
// Check for HTML img tags
|
|
284
|
+
const htmlImgTagRegex = /<img\s+[^>]*src\s*=\s*["']([^"']+)["'][^>]*\/?>/gi;
|
|
285
|
+
if (htmlImgTagRegex.test(content))
|
|
286
|
+
return true;
|
|
287
|
+
// Check for markdown image syntax: 
|
|
288
|
+
// Negative lookbehind (?<!\\) ensures it's not escaped
|
|
289
|
+
const markdownImageRegex = /(?<!\\)!\[[^\]]*\]\(([^)]+)\)/g;
|
|
290
|
+
const matches = content.matchAll(markdownImageRegex);
|
|
291
|
+
for (const match of matches) {
|
|
292
|
+
const url = match[1];
|
|
293
|
+
// If URL has image extension OR no extension (could be an image), flag it
|
|
294
|
+
if (isUrlOfImage(url))
|
|
295
|
+
return true;
|
|
296
|
+
// Also flag URLs without extensions (e.g., imgur direct links)
|
|
297
|
+
const mime = getMimeFromUrl(url);
|
|
298
|
+
if (mime === undefined) {
|
|
299
|
+
// URL has no recognizable extension, still flag markdown images
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
export function contentContainsMarkdownAudio(content) {
|
|
306
|
+
if (!content)
|
|
307
|
+
return false;
|
|
308
|
+
// Check for HTML audio tags
|
|
309
|
+
const htmlAudioTagRegex = /<audio[\s>]/gi;
|
|
310
|
+
if (htmlAudioTagRegex.test(content))
|
|
311
|
+
return true;
|
|
312
|
+
// Check for markdown image syntax with audio URLs: 
|
|
313
|
+
const markdownImageRegex = /(?<!\\)!\[[^\]]*\]\(([^)]+)\)/g;
|
|
314
|
+
const matches = content.matchAll(markdownImageRegex);
|
|
315
|
+
for (const match of matches) {
|
|
316
|
+
const url = match[1];
|
|
317
|
+
if (isUrlOfAudio(url))
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
export function contentContainsMarkdownVideos(content) {
|
|
323
|
+
if (!content)
|
|
324
|
+
return false;
|
|
325
|
+
// Check for HTML video tags
|
|
326
|
+
const htmlVideoTagRegex = /<video[\s>]/gi;
|
|
327
|
+
if (htmlVideoTagRegex.test(content))
|
|
328
|
+
return true;
|
|
329
|
+
// Check for HTML iframe tags (YouTube/Vimeo embeds)
|
|
330
|
+
const htmlIframeTagRegex = /<iframe[\s>]/gi;
|
|
331
|
+
if (htmlIframeTagRegex.test(content))
|
|
332
|
+
return true;
|
|
333
|
+
// Check for markdown image syntax with video URLs: 
|
|
334
|
+
const markdownImageRegex = /(?<!\\)!\[[^\]]*\]\(([^)]+)\)/g;
|
|
335
|
+
const matches = content.matchAll(markdownImageRegex);
|
|
336
|
+
for (const match of matches) {
|
|
337
|
+
const url = match[1];
|
|
338
|
+
if (isUrlOfVideo(url) || isUrlOfAnimatedImage(url))
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
export async function genToArray(gen) {
|
|
344
|
+
const out = [];
|
|
345
|
+
for await (const x of gen) {
|
|
346
|
+
out.push(x);
|
|
347
|
+
}
|
|
348
|
+
return out;
|
|
349
|
+
}
|
|
350
|
+
export function isStringDomain(x) {
|
|
351
|
+
return typeof x === "string" && x.includes(".");
|
|
352
|
+
}
|
|
353
|
+
export function isEthAliasDomain(address) {
|
|
354
|
+
const lower = address.toLowerCase();
|
|
355
|
+
return lower.endsWith(".eth") || lower.endsWith(".bso");
|
|
356
|
+
}
|
|
357
|
+
export function normalizeEthAliasDomain(address) {
|
|
358
|
+
return address.endsWith(".bso") ? address.slice(0, -4) + ".eth" : address;
|
|
359
|
+
}
|
|
360
|
+
export function areEquivalentCommunityAddresses(addressA, addressB) {
|
|
361
|
+
if (addressA === addressB)
|
|
362
|
+
return true;
|
|
363
|
+
const lowerA = addressA.toLowerCase();
|
|
364
|
+
const lowerB = addressB.toLowerCase();
|
|
365
|
+
if (!isEthAliasDomain(lowerA) || !isEthAliasDomain(lowerB))
|
|
366
|
+
return false;
|
|
367
|
+
return normalizeEthAliasDomain(lowerA) === normalizeEthAliasDomain(lowerB);
|
|
368
|
+
}
|
|
369
|
+
export function getEquivalentCommunityAddresses(address) {
|
|
370
|
+
const lower = address.toLowerCase();
|
|
371
|
+
if (lower.endsWith(".bso"))
|
|
372
|
+
return [address, address.slice(0, -4) + ".eth"];
|
|
373
|
+
if (lower.endsWith(".eth"))
|
|
374
|
+
return [address, address.slice(0, -4) + ".bso"];
|
|
375
|
+
return [address];
|
|
376
|
+
}
|
|
377
|
+
export function isIpns(x) {
|
|
378
|
+
// This function will test if a string is of IPNS address (12D)
|
|
379
|
+
try {
|
|
380
|
+
Digest.decode(base58btc.decode(`z${x}`));
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
catch {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
export function isIpfsCid(x) {
|
|
388
|
+
try {
|
|
389
|
+
return Boolean(CID.parse(x));
|
|
390
|
+
}
|
|
391
|
+
catch {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
export function isIpfsPath(x) {
|
|
396
|
+
return x.startsWith("/ipfs/");
|
|
397
|
+
}
|
|
398
|
+
function isMultiaddrLike(value) {
|
|
399
|
+
if (typeof value !== "object" || value === null)
|
|
400
|
+
return false;
|
|
401
|
+
if (!("bytes" in value))
|
|
402
|
+
return false;
|
|
403
|
+
const candidate = value;
|
|
404
|
+
return candidate.bytes instanceof Uint8Array;
|
|
405
|
+
}
|
|
406
|
+
export function parseIpfsRawOptionToIpfsOptions(kuboRpcRawOption) {
|
|
407
|
+
if (!kuboRpcRawOption)
|
|
408
|
+
throw Error("Need to define the ipfs options");
|
|
409
|
+
if (typeof kuboRpcRawOption === "string" || kuboRpcRawOption instanceof URL) {
|
|
410
|
+
const url = new URL(kuboRpcRawOption);
|
|
411
|
+
const authorization = url.username && url.password ? "Basic " + Buffer.from(`${url.username}:${url.password}`).toString("base64") : undefined;
|
|
412
|
+
return {
|
|
413
|
+
url: authorization ? url.origin + url.pathname : kuboRpcRawOption.toString(),
|
|
414
|
+
...(authorization ? { headers: { authorization, origin: "http://localhost" } } : undefined)
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
else if (isMultiaddrLike(kuboRpcRawOption))
|
|
418
|
+
return { url: kuboRpcRawOption };
|
|
419
|
+
else
|
|
420
|
+
return kuboRpcRawOption;
|
|
421
|
+
}
|
|
422
|
+
// Deep merge runtimeFields from RPC server into parsed data.
|
|
423
|
+
// Handles nested objects (recursive), arrays (element-by-element), and primitives (overwrite).
|
|
424
|
+
// For getter-only properties (e.g. updatingState), sets the backing _field directly.
|
|
425
|
+
export function deepMergeRuntimeFields(target, source) {
|
|
426
|
+
if (!source || typeof source !== "object")
|
|
427
|
+
return;
|
|
428
|
+
if (!target || typeof target !== "object")
|
|
429
|
+
return;
|
|
430
|
+
for (const key of Object.keys(source)) {
|
|
431
|
+
if (Array.isArray(source[key]) && Array.isArray(target?.[key])) {
|
|
432
|
+
for (let i = 0; i < source[key].length; i++) {
|
|
433
|
+
if (i < target[key].length)
|
|
434
|
+
deepMergeRuntimeFields(target[key][i], source[key][i]);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
else if (source[key] && typeof source[key] === "object" && target?.[key] && typeof target[key] === "object") {
|
|
438
|
+
deepMergeRuntimeFields(target[key], source[key]);
|
|
439
|
+
}
|
|
440
|
+
else if (source[key] !== undefined) {
|
|
441
|
+
// Don't create new complex (object/array) properties on the target from runtimeFields.
|
|
442
|
+
// RuntimeFields should only merge into existing structures, not create new pages/comments/etc.
|
|
443
|
+
if ((typeof source[key] === "object" || Array.isArray(source[key])) && !(key in target)) {
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
// Check if the property is getter-only (no setter)
|
|
447
|
+
let descriptor;
|
|
448
|
+
let proto = target;
|
|
449
|
+
while (proto && !descriptor) {
|
|
450
|
+
descriptor = Object.getOwnPropertyDescriptor(proto, key);
|
|
451
|
+
proto = Object.getPrototypeOf(proto);
|
|
452
|
+
}
|
|
453
|
+
if (descriptor?.get && !descriptor.set) {
|
|
454
|
+
// Set the backing _field directly (e.g. _updatingState for updatingState)
|
|
455
|
+
target[`_${key}`] = source[key];
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
target[key] = source[key];
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
export function hideClassPrivateProps(_this) {
|
|
464
|
+
// make props that start with _ not enumerable
|
|
465
|
+
for (const propertyName in _this) {
|
|
466
|
+
if (propertyName.startsWith("_"))
|
|
467
|
+
Object.defineProperty(_this, propertyName, { enumerable: false });
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
export function derivePublicationFromChallengeRequest(request) {
|
|
471
|
+
const publicationFieldNames = remeda.keys.strict(DecryptedChallengeRequestPublicationSchema.shape);
|
|
472
|
+
for (const pubName of publicationFieldNames) {
|
|
473
|
+
const publication = request[pubName];
|
|
474
|
+
if (publication)
|
|
475
|
+
return publication;
|
|
476
|
+
}
|
|
477
|
+
throw Error("Failed to find publication on ChallengeRequest");
|
|
478
|
+
}
|
|
479
|
+
export function isRequestPubsubPublicationOfReply(request) {
|
|
480
|
+
return Boolean(request.comment && request.comment.parentCid);
|
|
481
|
+
}
|
|
482
|
+
export function isRequestPubsubPublicationOfPost(request) {
|
|
483
|
+
return Boolean(request.comment && !request.comment.parentCid);
|
|
484
|
+
}
|
|
485
|
+
export async function resolveWhenPredicateIsTrue(options) {
|
|
486
|
+
const { toUpdate, predicate, eventName = "update" } = options;
|
|
487
|
+
await new Promise((resolve, reject) => {
|
|
488
|
+
const listener = async () => {
|
|
489
|
+
try {
|
|
490
|
+
const conditionStatus = await predicate();
|
|
491
|
+
if (conditionStatus) {
|
|
492
|
+
toUpdate.removeListener(eventName, listener);
|
|
493
|
+
resolve();
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
catch (error) {
|
|
497
|
+
toUpdate.removeListener(eventName, listener);
|
|
498
|
+
reject(error);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
toUpdate.on(eventName, listener);
|
|
502
|
+
listener(); // initial check — no await, errors flow through reject()
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
export async function waitForUpdateInCommunityInstanceWithErrorAndTimeout(community, timeoutMs) {
|
|
506
|
+
const wasUpdating = community.state === "updating";
|
|
507
|
+
const updatingStates = [];
|
|
508
|
+
const updatingStateChangeListener = (state) => updatingStates.push(state);
|
|
509
|
+
community.on("updatingstatechange", updatingStateChangeListener);
|
|
510
|
+
// Wait specifically for communityIpfs to be defined — intermediate "update" events
|
|
511
|
+
// (e.g. resetInstance, toJSONInternalRpcBeforeFirstUpdate) may fire without it
|
|
512
|
+
let updateListener;
|
|
513
|
+
const updatePromise = new Promise((resolve) => {
|
|
514
|
+
updateListener = () => {
|
|
515
|
+
if (community.raw.communityIpfs) {
|
|
516
|
+
community.removeListener("update", updateListener);
|
|
517
|
+
resolve();
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
community.on("update", updateListener);
|
|
521
|
+
});
|
|
522
|
+
let updateError;
|
|
523
|
+
const errorListener = (err) => (updateError = err);
|
|
524
|
+
community.on("error", errorListener);
|
|
525
|
+
try {
|
|
526
|
+
if (community.state !== "started")
|
|
527
|
+
await community.update();
|
|
528
|
+
await pTimeout(Promise.race([updatePromise, new Promise((resolve) => community.once("error", resolve))]), {
|
|
529
|
+
milliseconds: timeoutMs,
|
|
530
|
+
message: updateError ||
|
|
531
|
+
new PKCError("ERR_GET_COMMUNITY_TIMED_OUT", {
|
|
532
|
+
communityAddress: community.address,
|
|
533
|
+
timeoutMs,
|
|
534
|
+
error: updateError,
|
|
535
|
+
updatingStates,
|
|
536
|
+
community
|
|
537
|
+
})
|
|
538
|
+
});
|
|
539
|
+
if (updateError)
|
|
540
|
+
throw updateError;
|
|
541
|
+
}
|
|
542
|
+
catch (e) {
|
|
543
|
+
if (updateError)
|
|
544
|
+
throw updateError;
|
|
545
|
+
const updatingCommunity = findUpdatingCommunity(community._pkc, { address: community.address });
|
|
546
|
+
if (updatingCommunity?._clientsManager._ipnsLoadingOperation?.mainError())
|
|
547
|
+
throw updatingCommunity._clientsManager._ipnsLoadingOperation.mainError();
|
|
548
|
+
throw e;
|
|
549
|
+
}
|
|
550
|
+
finally {
|
|
551
|
+
if (updateListener)
|
|
552
|
+
community.removeListener("update", updateListener);
|
|
553
|
+
community.removeListener("error", errorListener);
|
|
554
|
+
community.removeListener("updatingstatechange", updatingStateChangeListener);
|
|
555
|
+
if (!wasUpdating && community.state !== "started")
|
|
556
|
+
await community.stop();
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
export function calculateIpfsCidV0(content) {
|
|
560
|
+
return calculateIpfsCidV0Lib(content);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* converts a binary record key to a pubsub topic key
|
|
564
|
+
*/
|
|
565
|
+
export function binaryKeyToPubsubTopic(key) {
|
|
566
|
+
const b64url = uint8ArrayToString(key, "base64url");
|
|
567
|
+
return `/record/${b64url}`;
|
|
568
|
+
}
|
|
569
|
+
export function ipnsNameToIpnsOverPubsubTopic(ipnsName) {
|
|
570
|
+
// for ipns over pubsub, the topic is '/record/' + Base64Url(Uint8Array('/ipns/') + Uint8Array('12D...'))
|
|
571
|
+
// https://github.com/ipfs/helia/blob/1561e4a106074b94e421a77b0b8776b065e48bc5/packages/ipns/src/routing/pubsub.ts#L169
|
|
572
|
+
const ipnsNamespaceBytes = new TextEncoder().encode("/ipns/");
|
|
573
|
+
const ipnsNameBytes = PeerId.parse(ipnsName).toBytes(); // accepts base58 (12D...) and base36 (k51...)
|
|
574
|
+
const ipnsNameBytesWithNamespace = new Uint8Array(ipnsNamespaceBytes.length + ipnsNameBytes.length);
|
|
575
|
+
ipnsNameBytesWithNamespace.set(ipnsNamespaceBytes, 0);
|
|
576
|
+
ipnsNameBytesWithNamespace.set(ipnsNameBytes, ipnsNamespaceBytes.length);
|
|
577
|
+
const pubsubTopic = "/record/" + uint8ArrayToString(ipnsNameBytesWithNamespace, "base64url");
|
|
578
|
+
return pubsubTopic;
|
|
579
|
+
}
|
|
580
|
+
export const pubsubTopicToDhtKey = (pubsubTopic) => {
|
|
581
|
+
return pubsubTopicToDhtKeyCid(pubsubTopic).toString(base32);
|
|
582
|
+
};
|
|
583
|
+
export const pubsubTopicToDhtKeyCid = (pubsubTopic) => {
|
|
584
|
+
const stringToHash = `floodsub:${pubsubTopic}`;
|
|
585
|
+
const bytes = new TextEncoder().encode(stringToHash);
|
|
586
|
+
// Use synchronous sha256 from js-sha256
|
|
587
|
+
const hashBytes = sha256.array(bytes);
|
|
588
|
+
// Create a multiformats digest from the raw hash bytes
|
|
589
|
+
// 0x12 is the multicodec for SHA-256
|
|
590
|
+
const digest = Digest.create(0x12, new Uint8Array(hashBytes));
|
|
591
|
+
// Create CID with the digest
|
|
592
|
+
const cid = CID.create(1, 0x55, digest);
|
|
593
|
+
return cid;
|
|
594
|
+
};
|
|
595
|
+
export async function retryKuboBlockPutPinAndProvidePubsubTopic({ ipfsClient: kuboRpcClient, log, pubsubTopic, inputNumOfRetries, blockPutOptions, pinAddOptions, provideOptions }) {
|
|
596
|
+
const numOfRetries = inputNumOfRetries ?? 3;
|
|
597
|
+
const bytes = new TextEncoder().encode(`floodsub:${pubsubTopic}`);
|
|
598
|
+
const expectedCid = pubsubTopicToDhtKeyCid(pubsubTopic);
|
|
599
|
+
return new Promise((resolve, reject) => {
|
|
600
|
+
const operation = retry.operation({
|
|
601
|
+
retries: numOfRetries,
|
|
602
|
+
factor: 2,
|
|
603
|
+
minTimeout: 2000
|
|
604
|
+
});
|
|
605
|
+
operation.attempt(async (currentAttempt) => {
|
|
606
|
+
try {
|
|
607
|
+
const cid = (await kuboRpcClient.block.put(bytes, {
|
|
608
|
+
...blockPutOptions,
|
|
609
|
+
format: "raw",
|
|
610
|
+
mhtype: "sha2-256",
|
|
611
|
+
version: 1
|
|
612
|
+
}));
|
|
613
|
+
if (!cid.equals(expectedCid)) {
|
|
614
|
+
throw new Error(`block.put CID mismatch for pubsub topic ${pubsubTopic}: expected ${String(expectedCid)} got ${String(cid)}`);
|
|
615
|
+
}
|
|
616
|
+
await kuboRpcClient.pin.add(cid, pinAddOptions);
|
|
617
|
+
try {
|
|
618
|
+
const provideEvents = kuboRpcClient.routing.provide(cid, provideOptions);
|
|
619
|
+
for await (const event of provideEvents) {
|
|
620
|
+
log.trace(`Provide event for ${String(cid)}:`, event);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
catch (e) {
|
|
624
|
+
log.trace("Minor Error, not a big deal: Failed to provide after block.put", e);
|
|
625
|
+
}
|
|
626
|
+
resolve(cid);
|
|
627
|
+
}
|
|
628
|
+
catch (error) {
|
|
629
|
+
log.error(`Failed attempt ${currentAttempt}/${numOfRetries + 1} to store and provide pubsub topic block:`, error);
|
|
630
|
+
if (operation.retry(error))
|
|
631
|
+
return;
|
|
632
|
+
reject(operation.mainError() || error);
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
export async function retryKuboIpfsAddAndProvide({ ipfsClient: kuboRpcClient, log, content, inputNumOfRetries, addOptions, provideOptions, provideInBackground }) {
|
|
638
|
+
const numOfRetries = inputNumOfRetries ?? 3;
|
|
639
|
+
return new Promise((resolve, reject) => {
|
|
640
|
+
const operation = retry.operation({
|
|
641
|
+
retries: numOfRetries,
|
|
642
|
+
factor: 2,
|
|
643
|
+
minTimeout: 2000
|
|
644
|
+
});
|
|
645
|
+
operation.attempt(async (currentAttempt) => {
|
|
646
|
+
try {
|
|
647
|
+
const addRes = await kuboRpcClient.add(content, addOptions);
|
|
648
|
+
// I think it's not needed to provide now that the re-providing bug has been fixed
|
|
649
|
+
const runProvide = async () => {
|
|
650
|
+
try {
|
|
651
|
+
const provideEvents = kuboRpcClient.routing.provide(addRes.cid, provideOptions);
|
|
652
|
+
for await (const event of provideEvents) {
|
|
653
|
+
log.trace(`Provide event for ${addRes.cid}:`, event);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
catch (e) {
|
|
657
|
+
log.trace("Minor Error, not a big deal: Failed to provide after add", e);
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
if (provideInBackground) {
|
|
661
|
+
void runProvide();
|
|
662
|
+
}
|
|
663
|
+
else {
|
|
664
|
+
await runProvide();
|
|
665
|
+
}
|
|
666
|
+
resolve(addRes);
|
|
667
|
+
}
|
|
668
|
+
catch (error) {
|
|
669
|
+
log.error(`Failed attempt ${currentAttempt}/${numOfRetries + 1} to add and provide content to IPFS:`, error);
|
|
670
|
+
if (operation.retry(error))
|
|
671
|
+
return;
|
|
672
|
+
reject(operation.mainError() || error);
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
export async function retryKuboIpfsAdd({ ipfsClient: kuboRpcClient, log, content, inputNumOfRetries, options }) {
|
|
678
|
+
const numOfRetries = inputNumOfRetries ?? 3;
|
|
679
|
+
return new Promise((resolve, reject) => {
|
|
680
|
+
const operation = retry.operation({
|
|
681
|
+
retries: numOfRetries,
|
|
682
|
+
factor: 2,
|
|
683
|
+
minTimeout: 2000
|
|
684
|
+
});
|
|
685
|
+
operation.attempt(async (currentAttempt) => {
|
|
686
|
+
try {
|
|
687
|
+
const addRes = await kuboRpcClient.add(content, options);
|
|
688
|
+
resolve(addRes);
|
|
689
|
+
}
|
|
690
|
+
catch (error) {
|
|
691
|
+
log.error(`Failed attempt ${currentAttempt}/${numOfRetries + 1} to add content to IPFS:`, error);
|
|
692
|
+
if (operation.retry(error))
|
|
693
|
+
return;
|
|
694
|
+
reject(operation.mainError() || error);
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
export async function writeKuboFilesWithTimeout({ ipfsClient: kuboRpcClient, log, path, content, inputNumOfRetries, options, timeoutMs }) {
|
|
700
|
+
const numOfRetries = inputNumOfRetries ?? 3;
|
|
701
|
+
const timeoutMilliseconds = timeoutMs ?? 15_000;
|
|
702
|
+
return new Promise((resolve, reject) => {
|
|
703
|
+
const operation = retry.operation({
|
|
704
|
+
retries: numOfRetries,
|
|
705
|
+
factor: 2,
|
|
706
|
+
minTimeout: 2000
|
|
707
|
+
});
|
|
708
|
+
operation.attempt(async (currentAttempt) => {
|
|
709
|
+
try {
|
|
710
|
+
await pTimeout(kuboRpcClient.files.write(path, content, options), {
|
|
711
|
+
milliseconds: timeoutMilliseconds,
|
|
712
|
+
message: `Timed out writing to MFS path ${path} after ${timeoutMilliseconds}ms`
|
|
713
|
+
});
|
|
714
|
+
resolve();
|
|
715
|
+
}
|
|
716
|
+
catch (error) {
|
|
717
|
+
log.error(`Failed attempt ${currentAttempt}/${numOfRetries + 1} to write content to MFS path ${path}:`, error);
|
|
718
|
+
if (operation.retry(error))
|
|
719
|
+
return;
|
|
720
|
+
reject(operation.mainError() || error);
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
export async function removeBlocksFromKuboNode({ ipfsClient: kuboRpcClient, log, cids, inputNumOfRetries, options }) {
|
|
726
|
+
const cidsToRemove = cids.map((cid) => CID.parse(cid));
|
|
727
|
+
const numOfRetries = inputNumOfRetries ?? 3;
|
|
728
|
+
const removedCids = [];
|
|
729
|
+
return new Promise((resolve, reject) => {
|
|
730
|
+
const operation = retry.operation({
|
|
731
|
+
retries: numOfRetries,
|
|
732
|
+
factor: 2,
|
|
733
|
+
minTimeout: 1000
|
|
734
|
+
});
|
|
735
|
+
operation.attempt(async (currentAttempt) => {
|
|
736
|
+
try {
|
|
737
|
+
for await (const cid of kuboRpcClient.block.rm(cidsToRemove, options)) {
|
|
738
|
+
removedCids.push(cid.cid.toV0().toString());
|
|
739
|
+
}
|
|
740
|
+
resolve(removedCids);
|
|
741
|
+
}
|
|
742
|
+
catch (error) {
|
|
743
|
+
log.error(`Failed attempt ${currentAttempt}/${numOfRetries + 1} to remove blocks from kubo node:`, error);
|
|
744
|
+
if (operation.retry(error))
|
|
745
|
+
return;
|
|
746
|
+
reject(operation.mainError() || error);
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
export async function removeMfsFilesSafely({ kuboRpcClient, paths, log, inputNumOfRetries, rmOptions }) {
|
|
752
|
+
const logger = log ?? Logger("pkc-js:util:removeMfsFilesSafely");
|
|
753
|
+
const numOfRetries = inputNumOfRetries ?? 3;
|
|
754
|
+
return new Promise((resolve, reject) => {
|
|
755
|
+
const operation = retry.operation({
|
|
756
|
+
retries: numOfRetries,
|
|
757
|
+
factor: 2,
|
|
758
|
+
minTimeout: 1000
|
|
759
|
+
});
|
|
760
|
+
operation.attempt(async (currentAttempt) => {
|
|
761
|
+
try {
|
|
762
|
+
await pTimeout(kuboRpcClient._client.files.rm(paths, {
|
|
763
|
+
recursive: true,
|
|
764
|
+
//@ts-expect-error
|
|
765
|
+
force: true,
|
|
766
|
+
...rmOptions
|
|
767
|
+
}), {
|
|
768
|
+
milliseconds: 120000,
|
|
769
|
+
message: new PKCError("ERR_TIMED_OUT_RM_MFS_FILE", {
|
|
770
|
+
toDeleteMfsPaths: paths,
|
|
771
|
+
kuboRpcUrl: kuboRpcClient.url
|
|
772
|
+
})
|
|
773
|
+
});
|
|
774
|
+
resolve();
|
|
775
|
+
}
|
|
776
|
+
catch (error) {
|
|
777
|
+
logger.error(`Failed attempt ${currentAttempt}/${numOfRetries + 1} to remove MFS paths ${paths.join(", ")}:`, error);
|
|
778
|
+
if (operation.retry(error))
|
|
779
|
+
return;
|
|
780
|
+
reject(operation.mainError() || error);
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
export async function getIpnsRecordInLocalKuboNode(kuboRpcClient, ipnsName) {
|
|
786
|
+
const gatewayMultiaddr = await kuboRpcClient._client.config.get("Addresses.Gateway"); // need to be fetched from config Addresses.Gateway
|
|
787
|
+
const parts = gatewayMultiaddr.split("/").filter(Boolean);
|
|
788
|
+
const gatewayUrl = `http://${parts[1]}:${parts[3]}`;
|
|
789
|
+
const ipnsFetchUrl = `${gatewayUrl}/ipns/${ipnsName}?format=ipns-record`;
|
|
790
|
+
const res = await fetch(ipnsFetchUrl);
|
|
791
|
+
if (res.status !== 200)
|
|
792
|
+
throw new PKCError("ERR_FAILED_TO_LOAD_LOCAL_RAW_IPNS_RECORD", {
|
|
793
|
+
ipnsFetchUrl,
|
|
794
|
+
ipnsName,
|
|
795
|
+
status: res.status,
|
|
796
|
+
statusText: res.statusText
|
|
797
|
+
});
|
|
798
|
+
const ipnsRecordRaw = new Uint8Array(await res.arrayBuffer());
|
|
799
|
+
try {
|
|
800
|
+
return unmarshalIPNSRecord(ipnsRecordRaw);
|
|
801
|
+
}
|
|
802
|
+
catch (e) {
|
|
803
|
+
throw new PKCError("ERR_FAILED_TO_PARSE_LOCAL_RAW_IPNS_RECORD", { ipnsName, ipnsFetchUrl, parseError: e });
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
const textEncoder = new TextEncoder();
|
|
807
|
+
export async function calculateStringSizeSameAsIpfsAddCidV0(content) {
|
|
808
|
+
const blockstore = new MemoryBlockstore();
|
|
809
|
+
const entry = await importFile({ path: "content.json", content: textEncoder.encode(content) }, blockstore, {
|
|
810
|
+
cidVersion: 0,
|
|
811
|
+
rawLeaves: false,
|
|
812
|
+
wrapWithDirectory: false
|
|
813
|
+
});
|
|
814
|
+
return Number(entry.size);
|
|
815
|
+
}
|
|
816
|
+
//# sourceMappingURL=util.js.map
|