├── .nvmrc ├── .npmrc ├── .mocharc.json ├── dist ├── node │ ├── zod-error-map.d.ts │ ├── types.js │ ├── helia │ │ ├── types.js │ │ ├── types.js.map │ │ ├── helia-for-plebbit.d.ts │ │ ├── util.d.ts │ │ ├── libp2pjsClient.js.map │ │ ├── libp2pjsClient.js │ │ └── types.d.ts │ ├── pages │ │ ├── types.js │ │ ├── types.js.map │ │ ├── pages-clients.js.map │ │ ├── pages-clients.js │ │ └── pages-clients.d.ts │ ├── signer │ │ ├── types.js │ │ ├── types.js.map │ │ ├── constants.js │ │ ├── constants.d.ts │ │ ├── constants.js.map │ │ ├── index.d.ts │ │ └── util.d.ts │ ├── rpc │ │ └── src │ │ │ ├── types.js │ │ │ ├── json-rpc-util.d.ts │ │ │ ├── types.js.map │ │ │ ├── lib │ │ │ └── plebbit-js │ │ │ │ ├── index.js.map │ │ │ │ └── index.js │ │ │ ├── json-rpc-util.js.map │ │ │ ├── json-rpc-util.js │ │ │ ├── types.d.ts │ │ │ ├── schema.js.map │ │ │ ├── schema.js │ │ │ └── utils.d.ts │ ├── subplebbit │ │ ├── types.js │ │ ├── types.js.map │ │ ├── subplebbit-clients.js.map │ │ ├── subplebbit-clients.js │ │ └── rpc-remote-subplebbit.d.ts │ ├── publications │ │ ├── types.js │ │ ├── comment │ │ │ ├── types.js │ │ │ ├── types.js.map │ │ │ ├── comment-clients.js.map │ │ │ └── comment-clients.js │ │ ├── vote │ │ │ ├── types.js │ │ │ ├── types.js.map │ │ │ ├── types.d.ts │ │ │ └── vote.d.ts │ │ ├── comment-edit │ │ │ ├── types.js │ │ │ └── types.js.map │ │ ├── comment-moderation │ │ │ ├── types.js │ │ │ └── types.js.map │ │ ├── subplebbit-edit │ │ │ ├── types.js │ │ │ └── types.js.map │ │ ├── types.js.map │ │ ├── publication-clients.js.map │ │ └── publication-clients.js │ ├── pubsub-messages │ │ ├── types.js │ │ └── types.js.map │ ├── types.js.map │ ├── runtime │ │ ├── browser │ │ │ ├── subplebbit │ │ │ │ ├── local-subplebbit.d.ts │ │ │ │ ├── local-subplebbit.js │ │ │ │ ├── local-subplebbit.js.map │ │ │ │ └── challenges │ │ │ │ │ ├── index.js.map │ │ │ │ │ ├── index.js │ │ │ │ │ └── index.d.ts │ │ │ ├── db-handler.d.ts │ │ │ ├── polyfill.d.ts │ │ │ ├── setup-kubo-address-rewriter-and-http-router.d.ts │ │ │ ├── native-functions.d.ts │ │ │ ├── native-functions.js │ │ │ ├── setup-kubo-address-rewriter-and-http-router.js │ │ │ ├── db-handler.js.map │ │ │ ├── db-handler.js │ │ │ ├── native-functions.js.map │ │ │ ├── setup-kubo-address-rewriter-and-http-router.js.map │ │ │ ├── storage.d.ts │ │ │ ├── localforage-lru.d.ts │ │ │ ├── lru-storage.d.ts │ │ │ ├── util.d.ts │ │ │ ├── lru-storage.js.map │ │ │ ├── lru-storage.js │ │ │ ├── polyfill.js.map │ │ │ ├── storage.js.map │ │ │ └── storage.js │ │ └── node │ │ │ ├── polyfill.d.ts │ │ │ ├── native-functions.d.ts │ │ │ ├── setup-kubo-address-rewriter-and-http-router.d.ts │ │ │ ├── native-functions.js │ │ │ ├── subplebbit │ │ │ ├── challenges │ │ │ │ ├── plebbit-js-challenges │ │ │ │ │ ├── fail.d.ts │ │ │ │ │ ├── blacklist.d.ts │ │ │ │ │ ├── question.d.ts │ │ │ │ │ ├── text-math.d.ts │ │ │ │ │ ├── voucher.d.ts │ │ │ │ │ ├── whitelist.d.ts │ │ │ │ │ ├── publication-match.d.ts │ │ │ │ │ ├── captcha-canvas-v3 │ │ │ │ │ │ └── index.d.ts │ │ │ │ │ ├── evm-contract-call │ │ │ │ │ │ └── index.d.ts │ │ │ │ │ ├── fail.js.map │ │ │ │ │ └── fail.js │ │ │ │ └── exclude │ │ │ │ │ ├── index.d.ts │ │ │ │ │ ├── index.js │ │ │ │ │ ├── index.js.map │ │ │ │ │ ├── rate-limiter.d.ts │ │ │ │ │ └── exclude.d.ts │ │ │ └── db-row-parser.d.ts │ │ │ ├── native-functions.js.map │ │ │ ├── storage.d.ts │ │ │ ├── lru-storage.d.ts │ │ │ ├── polyfill.js.map │ │ │ ├── address-rewriter-db.d.ts │ │ │ ├── polyfill.js │ │ │ └── lru-storage.js.map │ ├── decorator-util.d.ts │ ├── version.d.ts │ ├── constants.js.map │ ├── generic-state-client.d.ts │ ├── plebbit │ │ ├── plebbit-clients.js.map │ │ ├── plebbit-clients.js │ │ └── plebbit-clients.d.ts │ ├── clients │ │ ├── rpc-client │ │ │ ├── schema.js │ │ │ ├── schema.js.map │ │ │ └── decode-rpc-response-util.d.ts │ │ ├── chain-provider-client.js.map │ │ ├── chain-provider-client.js │ │ ├── plebbit-typed-emitter.d.ts │ │ └── chain-provider-client.d.ts │ ├── generic-state-client.js.map │ ├── constants.d.ts │ ├── generic-state-client.js │ ├── test │ │ └── mock-ipfs-client.d.ts │ ├── version.js.map │ ├── version.js │ ├── general-util │ │ └── limited-set.d.ts │ ├── zod-error-map.js │ ├── constants.js │ ├── stats.d.ts │ ├── zod-error-map.js.map │ ├── domain-resolver.d.ts │ ├── index.js.map │ └── decorator-util.js.map └── browser │ ├── zod-error-map.d.ts │ ├── types.js │ ├── helia │ ├── types.js │ ├── types.js.map │ ├── helia-for-plebbit.d.ts │ ├── libp2pjsClient.js.map │ ├── util.d.ts │ ├── libp2pjsClient.js │ └── types.d.ts │ ├── pages │ ├── types.js │ ├── types.js.map │ ├── pages-clients.js.map │ ├── pages-clients.js │ └── pages-clients.d.ts │ ├── rpc │ └── src │ │ ├── types.js │ │ ├── json-rpc-util.d.ts │ │ ├── types.js.map │ │ ├── lib │ │ └── plebbit-js │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── json-rpc-util.js.map │ │ ├── json-rpc-util.js │ │ ├── types.d.ts │ │ ├── schema.js.map │ │ ├── schema.js │ │ └── utils.d.ts │ ├── signer │ ├── types.js │ ├── types.js.map │ ├── constants.js │ ├── constants.d.ts │ ├── constants.js.map │ ├── index.d.ts │ └── util.d.ts │ ├── publications │ ├── types.js │ ├── vote │ │ ├── types.js │ │ ├── types.js.map │ │ ├── types.d.ts │ │ └── vote.d.ts │ ├── comment │ │ ├── types.js │ │ ├── types.js.map │ │ ├── comment-clients.js.map │ │ └── comment-clients.js │ ├── comment-edit │ │ ├── types.js │ │ └── types.js.map │ ├── subplebbit-edit │ │ ├── types.js │ │ └── types.js.map │ ├── comment-moderation │ │ ├── types.js │ │ └── types.js.map │ ├── types.js.map │ ├── publication-clients.js.map │ └── publication-clients.js │ ├── subplebbit │ ├── types.js │ ├── types.js.map │ ├── subplebbit-clients.js.map │ ├── subplebbit-clients.js │ └── rpc-remote-subplebbit.d.ts │ ├── pubsub-messages │ ├── types.js │ └── types.js.map │ ├── runtime │ ├── browser │ │ ├── subplebbit │ │ │ ├── local-subplebbit.d.ts │ │ │ ├── local-subplebbit.js │ │ │ ├── local-subplebbit.js.map │ │ │ └── challenges │ │ │ │ ├── index.js.map │ │ │ │ ├── index.js │ │ │ │ └── index.d.ts │ │ ├── db-handler.d.ts │ │ ├── polyfill.d.ts │ │ ├── setup-kubo-address-rewriter-and-http-router.d.ts │ │ ├── native-functions.d.ts │ │ ├── native-functions.js │ │ ├── setup-kubo-address-rewriter-and-http-router.js │ │ ├── db-handler.js.map │ │ ├── db-handler.js │ │ ├── native-functions.js.map │ │ ├── setup-kubo-address-rewriter-and-http-router.js.map │ │ ├── storage.d.ts │ │ ├── localforage-lru.d.ts │ │ ├── lru-storage.d.ts │ │ ├── util.d.ts │ │ ├── lru-storage.js.map │ │ ├── lru-storage.js │ │ ├── polyfill.js.map │ │ ├── storage.js.map │ │ └── storage.js │ └── node │ │ ├── polyfill.d.ts │ │ ├── native-functions.d.ts │ │ ├── setup-kubo-address-rewriter-and-http-router.d.ts │ │ ├── native-functions.js │ │ ├── subplebbit │ │ ├── challenges │ │ │ ├── plebbit-js-challenges │ │ │ │ ├── fail.d.ts │ │ │ │ ├── voucher.d.ts │ │ │ │ ├── blacklist.d.ts │ │ │ │ ├── question.d.ts │ │ │ │ ├── text-math.d.ts │ │ │ │ ├── whitelist.d.ts │ │ │ │ ├── publication-match.d.ts │ │ │ │ ├── captcha-canvas-v3 │ │ │ │ │ └── index.d.ts │ │ │ │ ├── evm-contract-call │ │ │ │ │ └── index.d.ts │ │ │ │ ├── fail.js.map │ │ │ │ └── fail.js │ │ │ └── exclude │ │ │ │ ├── index.d.ts │ │ │ │ ├── index.js │ │ │ │ ├── index.js.map │ │ │ │ ├── rate-limiter.d.ts │ │ │ │ └── exclude.d.ts │ │ └── db-row-parser.d.ts │ │ ├── native-functions.js.map │ │ ├── storage.d.ts │ │ ├── lru-storage.d.ts │ │ ├── polyfill.js.map │ │ ├── address-rewriter-db.d.ts │ │ ├── polyfill.js │ │ └── lru-storage.js.map │ ├── types.js.map │ ├── decorator-util.d.ts │ ├── version.d.ts │ ├── constants.js.map │ ├── generic-state-client.d.ts │ ├── plebbit │ ├── plebbit-clients.js.map │ ├── plebbit-clients.js │ └── plebbit-clients.d.ts │ ├── clients │ ├── rpc-client │ │ ├── schema.js │ │ ├── schema.js.map │ │ └── decode-rpc-response-util.d.ts │ ├── chain-provider-client.js │ ├── chain-provider-client.js.map │ ├── plebbit-typed-emitter.d.ts │ └── chain-provider-client.d.ts │ ├── generic-state-client.js.map │ ├── constants.d.ts │ ├── generic-state-client.js │ ├── test │ └── mock-ipfs-client.d.ts │ ├── version.js.map │ ├── version.js │ ├── zod-error-map.js │ ├── general-util │ └── limited-set.d.ts │ ├── constants.js │ ├── stats.d.ts │ ├── zod-error-map.js.map │ ├── domain-resolver.d.ts │ ├── index.js.map │ └── decorator-util.js.map ├── prettier.config.js ├── set_ipfs.sh ├── tsconfig.json ├── src ├── rpc │ ├── start.js │ ├── test │ │ ├── test-server │ │ │ ├── config.js │ │ │ └── index.js │ │ ├── node │ │ │ └── plebbit-ws-server.test.js │ │ └── browser │ │ │ └── plebbit-ws-server.test.js │ ├── .gitignore │ └── src │ │ ├── json-rpc-util.ts │ │ ├── types.ts │ │ └── lib │ │ └── plebbit-js │ │ └── index.ts ├── pages │ ├── schema-util.ts │ └── pages-clients.ts ├── runtime │ ├── browser │ │ ├── setup-kubo-address-rewriter-and-http-router.ts │ │ ├── subplebbit │ │ │ ├── local-subplebbit.ts │ │ │ └── challenges │ │ │ │ └── index.ts │ │ ├── native-functions.ts │ │ └── db-handler.ts │ └── node │ │ ├── native-functions.ts │ │ ├── subplebbit │ │ └── challenges │ │ │ └── exclude │ │ │ └── index.ts │ │ └── polyfill.ts ├── signer │ └── constants.ts ├── constants.ts ├── version.ts ├── generic-state-client.ts ├── plebbit │ └── plebbit-clients.ts ├── clients │ ├── chain-provider-client.ts │ └── rpc-client │ │ ├── types.ts │ │ ├── rpc-schema-util.ts │ │ └── schema.ts ├── zod-error-map.ts ├── test │ └── node │ │ └── hanging-test │ │ └── scenarios │ │ ├── destroy-only.scenario.ts │ │ ├── comment-publish.scenario.ts │ │ ├── subplebbit-update.scenario.ts │ │ ├── subplebbit-start.scenario.ts │ │ ├── comment-publish-pending.scenario.ts │ │ └── comment-update.scenario.ts └── helia │ └── types.ts ├── .cursor └── rules │ └── writing-sql.mdc ├── test ├── browser │ └── root-hook-karma.util.js ├── fixtures │ ├── subplebbits_dbs │ │ ├── version_10 │ │ │ └── 12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR │ │ └── version_11 │ │ │ └── 12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR │ ├── publications.js │ ├── valid_vote.json │ └── signatures │ │ ├── commentEdit │ │ └── valid_comment_edit.json │ │ └── comment │ │ ├── valid_comment_author_address_as_domain.json │ │ ├── commentUpdate_authorEdit │ │ └── valid_comment_ipfs.json │ │ └── commentUpdate │ │ └── valid_comment_ipfs.json ├── vitest-node-setup.js ├── vitest-browser-setup.js └── server │ └── pubsub-mock-server.js ├── config ├── prettier.config.js └── tsconfig.json ├── scripts ├── build-watch-all.sh ├── build-and-test.sh ├── build-plebones.sh └── build-watch-all-debug.sh ├── .vscode └── settings.json ├── examples └── demo │ └── package.json ├── rpc └── package.json ├── .github └── workflows │ ├── CI-windows-test.yml │ ├── CI-alerts.yml │ └── CI-build.yml └── docs ├── cross-platform-native-functions.md └── testing.md /.nvmrc: -------------------------------------------------------------------------------- 1 | 20 2 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true -------------------------------------------------------------------------------- /.mocharc.json: -------------------------------------------------------------------------------- 1 | config/.mocharc.json -------------------------------------------------------------------------------- /dist/node/zod-error-map.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | config/prettier.config.js -------------------------------------------------------------------------------- /dist/browser/zod-error-map.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/node/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/helia/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/pages/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/signer/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/helia/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/pages/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/rpc/src/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/signer/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/rpc/src/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/subplebbit/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /set_ipfs.sh: -------------------------------------------------------------------------------- 1 | export IPFS_PATH=./.test-ipfs-offline 2 | export ipfs=npx ipfs 3 | -------------------------------------------------------------------------------- /dist/browser/publications/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/subplebbit/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/publications/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/pubsub-messages/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/publications/vote/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/pubsub-messages/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/publications/comment/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/publications/vote/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/publications/comment/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/publications/comment-edit/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/publications/comment-edit/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/publications/subplebbit-edit/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/publications/comment-moderation/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/node/publications/subplebbit-edit/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/browser/publications/comment-moderation/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src/**/*"], 3 | "extends": "./config/tsconfig.json" 4 | } 5 | -------------------------------------------------------------------------------- /src/rpc/start.js: -------------------------------------------------------------------------------- 1 | import Plebbit from "@plebbit/plebbit-js"; 2 | 3 | const plebbit = await Plebbit(); 4 | -------------------------------------------------------------------------------- /src/rpc/test/test-server/config.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | port: 39652 3 | }; 4 | 5 | module.exports = config; 6 | -------------------------------------------------------------------------------- /dist/node/rpc/src/json-rpc-util.d.ts: -------------------------------------------------------------------------------- 1 | export declare function sanitizeRpcNotificationResult(event: string, result: any): any; 2 | -------------------------------------------------------------------------------- /dist/node/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/rpc/src/json-rpc-util.d.ts: -------------------------------------------------------------------------------- 1 | export declare function sanitizeRpcNotificationResult(event: string, result: any): any; 2 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/subplebbit/local-subplebbit.d.ts: -------------------------------------------------------------------------------- 1 | export declare class LocalSubplebbit { 2 | constructor(); 3 | } 4 | -------------------------------------------------------------------------------- /dist/browser/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/runtime/browser/subplebbit/local-subplebbit.d.ts: -------------------------------------------------------------------------------- 1 | export declare class LocalSubplebbit { 2 | constructor(); 3 | } 4 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/db-handler.d.ts: -------------------------------------------------------------------------------- 1 | export declare class DbHandler { 2 | constructor(); 3 | } 4 | export default DbHandler; 5 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/db-handler.d.ts: -------------------------------------------------------------------------------- 1 | export declare class DbHandler { 2 | constructor(); 3 | } 4 | export default DbHandler; 5 | -------------------------------------------------------------------------------- /dist/node/helia/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/helia/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/pages/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/pages/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/helia/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/helia/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/pages/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/pages/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/runtime/node/polyfill.d.ts: -------------------------------------------------------------------------------- 1 | import "@enhances/with-resolvers"; 2 | declare const _default: () => void; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /dist/browser/signer/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/signer/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/runtime/browser/polyfill.d.ts: -------------------------------------------------------------------------------- 1 | import "@enhances/with-resolvers"; 2 | declare const _default: () => void; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/node/polyfill.d.ts: -------------------------------------------------------------------------------- 1 | import "@enhances/with-resolvers"; 2 | declare const _default: () => void; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /dist/node/signer/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/signer/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/rpc/src/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/rpc/src/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/runtime/browser/polyfill.d.ts: -------------------------------------------------------------------------------- 1 | import "@enhances/with-resolvers"; 2 | declare const _default: () => void; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /dist/node/rpc/src/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/rpc/src/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts: -------------------------------------------------------------------------------- 1 | export declare function setupKuboAddressesRewriterAndHttpRouters(): void; 2 | -------------------------------------------------------------------------------- /dist/node/subplebbit/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/subplebbit/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts: -------------------------------------------------------------------------------- 1 | export declare function setupKuboAddressesRewriterAndHttpRouters(): void; 2 | -------------------------------------------------------------------------------- /dist/browser/subplebbit/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/subplebbit/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/publications/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/publications/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/publications/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/publications/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/pubsub-messages/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/pubsub-messages/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/pubsub-messages/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/pubsub-messages/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /src/pages/schema-util.ts: -------------------------------------------------------------------------------- 1 | import { GetPageParam } from "./schema.js"; 2 | 3 | export const parsePageCidParams = (params: unknown) => GetPageParam.parse(params); 4 | -------------------------------------------------------------------------------- /dist/browser/publications/vote/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/publications/vote/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/publications/vote/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/publications/vote/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/publications/comment/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/publications/comment/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/publications/comment/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/publications/comment/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/publications/comment-edit/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/publications/comment-edit/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/publications/comment-edit/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/publications/comment-edit/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/decorator-util.d.ts: -------------------------------------------------------------------------------- 1 | export declare function measurePerformance(thresholdMs?: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; 2 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/native-functions.d.ts: -------------------------------------------------------------------------------- 1 | import { NativeFunctions } from "../../types.js"; 2 | declare const nativeFunctions: NativeFunctions; 3 | export default nativeFunctions; 4 | -------------------------------------------------------------------------------- /dist/node/decorator-util.d.ts: -------------------------------------------------------------------------------- 1 | export declare function measurePerformance(thresholdMs?: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; 2 | -------------------------------------------------------------------------------- /dist/node/publications/subplebbit-edit/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/publications/subplebbit-edit/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/runtime/browser/native-functions.d.ts: -------------------------------------------------------------------------------- 1 | import { NativeFunctions } from "../../types.js"; 2 | declare const nativeFunctions: NativeFunctions; 3 | export default nativeFunctions; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/node/native-functions.d.ts: -------------------------------------------------------------------------------- 1 | import type { NativeFunctions } from "../../types.js"; 2 | declare const nativeFunctions: NativeFunctions; 3 | export default nativeFunctions; 4 | -------------------------------------------------------------------------------- /src/runtime/browser/setup-kubo-address-rewriter-and-http-router.ts: -------------------------------------------------------------------------------- 1 | export function setupKuboAddressesRewriterAndHttpRouters() { 2 | throw Error("Should not be called in browser"); 3 | } 4 | -------------------------------------------------------------------------------- /.cursor/rules/writing-sql.mdc: -------------------------------------------------------------------------------- 1 | --- 2 | description: 3 | globs: 4 | alwaysApply: true 5 | --- 6 | If you write a query in db-handler.ts, you should make sure we're processing null to be undefined -------------------------------------------------------------------------------- /dist/browser/publications/subplebbit-edit/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/publications/subplebbit-edit/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/browser/runtime/node/native-functions.d.ts: -------------------------------------------------------------------------------- 1 | import type { NativeFunctions } from "../../types.js"; 2 | declare const nativeFunctions: NativeFunctions; 3 | export default nativeFunctions; 4 | -------------------------------------------------------------------------------- /dist/browser/signer/constants.js: -------------------------------------------------------------------------------- 1 | // Signer section 2 | export const keysToOmitFromSignedPropertyNames = [ 3 | "signer", 4 | "challengeRequest" 5 | ]; 6 | //# sourceMappingURL=constants.js.map -------------------------------------------------------------------------------- /dist/node/publications/comment-moderation/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/publications/comment-moderation/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/node/signer/constants.js: -------------------------------------------------------------------------------- 1 | // Signer section 2 | export const keysToOmitFromSignedPropertyNames = [ 3 | "signer", 4 | "challengeRequest" 5 | ]; 6 | //# sourceMappingURL=constants.js.map -------------------------------------------------------------------------------- /test/browser/root-hook-karma.util.js: -------------------------------------------------------------------------------- 1 | // For now this code will be run when karma first starts 2 | // We need to load Plebbit here to polyfill 3 | import Plebbit from "../../dist/node/index.js"; 4 | -------------------------------------------------------------------------------- /dist/browser/publications/comment-moderation/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/publications/comment-moderation/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /config/prettier.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import("prettier").Config} */ 2 | const config = { 3 | printWidth: 140, 4 | tabWidth: 4, 5 | trailingComma: "none" 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /src/runtime/browser/subplebbit/local-subplebbit.ts: -------------------------------------------------------------------------------- 1 | export class LocalSubplebbit { 2 | constructor() { 3 | throw Error("Local Subplebbit should not be instantiated in browser"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /dist/browser/version.d.ts: -------------------------------------------------------------------------------- 1 | declare const _default: { 2 | PLEBBIT_JS_VERSION: string; 3 | DB_VERSION: number; 4 | PROTOCOL_VERSION: string; 5 | USER_AGENT: string; 6 | }; 7 | export default _default; 8 | -------------------------------------------------------------------------------- /dist/node/version.d.ts: -------------------------------------------------------------------------------- 1 | declare const _default: { 2 | PLEBBIT_JS_VERSION: string; 3 | DB_VERSION: number; 4 | PROTOCOL_VERSION: string; 5 | USER_AGENT: string; 6 | }; 7 | export default _default; 8 | -------------------------------------------------------------------------------- /dist/browser/signer/constants.d.ts: -------------------------------------------------------------------------------- 1 | import type { CreatePublicationOptions } from "../types.js"; 2 | export declare const keysToOmitFromSignedPropertyNames: (keyof Pick)[]; 3 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/native-functions.js: -------------------------------------------------------------------------------- 1 | const nativeFunctions = { 2 | //@ts-ignore 3 | fetch: (...args) => window.fetch(...args) 4 | }; 5 | export default nativeFunctions; 6 | //# sourceMappingURL=native-functions.js.map -------------------------------------------------------------------------------- /dist/node/signer/constants.d.ts: -------------------------------------------------------------------------------- 1 | import type { CreatePublicationOptions } from "../types.js"; 2 | export declare const keysToOmitFromSignedPropertyNames: (keyof Pick)[]; 3 | -------------------------------------------------------------------------------- /src/rpc/test/node/plebbit-ws-server.test.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai"); 2 | const testServerConfig = require("../test-server/config"); 3 | 4 | describe("plebbit-ws-server", () => { 5 | before(async () => {}); 6 | }); 7 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/native-functions.js: -------------------------------------------------------------------------------- 1 | const nativeFunctions = { 2 | //@ts-ignore 3 | fetch: (...args) => window.fetch(...args) 4 | }; 5 | export default nativeFunctions; 6 | //# sourceMappingURL=native-functions.js.map -------------------------------------------------------------------------------- /dist/browser/signer/constants.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/signer/constants.ts"],"names":[],"mappings":"AAAA,iBAAiB;AAIjB,MAAM,CAAC,MAAM,iCAAiC,GAA4E;IACtH,QAAQ;IACR,kBAAkB;CACrB,CAAC"} -------------------------------------------------------------------------------- /dist/node/signer/constants.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/signer/constants.ts"],"names":[],"mappings":"AAAA,iBAAiB;AAIjB,MAAM,CAAC,MAAM,iCAAiC,GAA4E;IACtH,QAAQ;IACR,kBAAkB;CACrB,CAAC"} -------------------------------------------------------------------------------- /src/rpc/test/browser/plebbit-ws-server.test.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai"); 2 | const testServerConfig = require("../test-server/config"); 3 | 4 | describe("plebbit-ws-server", () => { 5 | before(async () => {}); 6 | }); 7 | -------------------------------------------------------------------------------- /test/fixtures/subplebbits_dbs/version_10/12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plebbit/plebbit-js/HEAD/test/fixtures/subplebbits_dbs/version_10/12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR -------------------------------------------------------------------------------- /test/fixtures/subplebbits_dbs/version_11/12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plebbit/plebbit-js/HEAD/test/fixtures/subplebbits_dbs/version_11/12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR -------------------------------------------------------------------------------- /dist/node/runtime/browser/subplebbit/local-subplebbit.js: -------------------------------------------------------------------------------- 1 | export class LocalSubplebbit { 2 | constructor() { 3 | throw Error("Local Subplebbit should not be instantiated in browser"); 4 | } 5 | } 6 | //# sourceMappingURL=local-subplebbit.js.map -------------------------------------------------------------------------------- /dist/browser/runtime/browser/subplebbit/local-subplebbit.js: -------------------------------------------------------------------------------- 1 | export class LocalSubplebbit { 2 | constructor() { 3 | throw Error("Local Subplebbit should not be instantiated in browser"); 4 | } 5 | } 6 | //# sourceMappingURL=local-subplebbit.js.map -------------------------------------------------------------------------------- /src/runtime/browser/native-functions.ts: -------------------------------------------------------------------------------- 1 | import { NativeFunctions } from "../../types.js"; 2 | 3 | const nativeFunctions: NativeFunctions = { 4 | //@ts-ignore 5 | fetch: (...args) => window.fetch(...args) 6 | }; 7 | 8 | export default nativeFunctions; 9 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js: -------------------------------------------------------------------------------- 1 | export function setupKuboAddressesRewriterAndHttpRouters() { 2 | throw Error("Should not be called in browser"); 3 | } 4 | //# sourceMappingURL=setup-kubo-address-rewriter-and-http-router.js.map -------------------------------------------------------------------------------- /dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js: -------------------------------------------------------------------------------- 1 | export function setupKuboAddressesRewriterAndHttpRouters() { 2 | throw Error("Should not be called in browser"); 3 | } 4 | //# sourceMappingURL=setup-kubo-address-rewriter-and-http-router.js.map -------------------------------------------------------------------------------- /dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts: -------------------------------------------------------------------------------- 1 | import { Plebbit } from "../../plebbit/plebbit.js"; 2 | export declare function setupKuboAddressesRewriterAndHttpRouters(plebbit: Plebbit): Promise<{ 3 | destroy: () => Promise; 4 | }>; 5 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts: -------------------------------------------------------------------------------- 1 | import { Plebbit } from "../../plebbit/plebbit.js"; 2 | export declare function setupKuboAddressesRewriterAndHttpRouters(plebbit: Plebbit): Promise<{ 3 | destroy: () => Promise; 4 | }>; 5 | -------------------------------------------------------------------------------- /src/runtime/browser/db-handler.ts: -------------------------------------------------------------------------------- 1 | // empty for the browser 2 | 3 | export class DbHandler { 4 | constructor() { 5 | throw Error("Should not attempt to create a new instance of DbHandler on browser"); 6 | } 7 | } 8 | 9 | export default DbHandler; 10 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/native-functions.js: -------------------------------------------------------------------------------- 1 | import dns from "node:dns"; 2 | dns.setDefaultResultOrder("ipv4first"); 3 | const nativeFunctions = { 4 | fetch: async (...args) => fetch(...args) 5 | }; 6 | export default nativeFunctions; 7 | //# sourceMappingURL=native-functions.js.map -------------------------------------------------------------------------------- /dist/node/runtime/node/native-functions.js: -------------------------------------------------------------------------------- 1 | import dns from "node:dns"; 2 | dns.setDefaultResultOrder("ipv4first"); 3 | const nativeFunctions = { 4 | fetch: async (...args) => fetch(...args) 5 | }; 6 | export default nativeFunctions; 7 | //# sourceMappingURL=native-functions.js.map -------------------------------------------------------------------------------- /dist/node/runtime/browser/db-handler.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"db-handler.js","sourceRoot":"","sources":["../../../../src/runtime/browser/db-handler.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,MAAM,OAAO,SAAS;IAClB;QACI,MAAM,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACvF,CAAC;CACJ;AAED,eAAe,SAAS,CAAC"} -------------------------------------------------------------------------------- /dist/browser/runtime/browser/db-handler.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"db-handler.js","sourceRoot":"","sources":["../../../../src/runtime/browser/db-handler.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,MAAM,OAAO,SAAS;IAClB;QACI,MAAM,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACvF,CAAC;CACJ;AAED,eAAe,SAAS,CAAC"} -------------------------------------------------------------------------------- /dist/node/runtime/browser/db-handler.js: -------------------------------------------------------------------------------- 1 | // empty for the browser 2 | export class DbHandler { 3 | constructor() { 4 | throw Error("Should not attempt to create a new instance of DbHandler on browser"); 5 | } 6 | } 7 | export default DbHandler; 8 | //# sourceMappingURL=db-handler.js.map -------------------------------------------------------------------------------- /dist/node/runtime/browser/subplebbit/local-subplebbit.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"local-subplebbit.js","sourceRoot":"","sources":["../../../../../src/runtime/browser/subplebbit/local-subplebbit.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IACxB;QACI,MAAM,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC1E,CAAC;CACJ"} -------------------------------------------------------------------------------- /src/signer/constants.ts: -------------------------------------------------------------------------------- 1 | // Signer section 2 | 3 | import type { CreatePublicationOptions } from "../types.js"; 4 | 5 | export const keysToOmitFromSignedPropertyNames = <(keyof Pick)[]>[ 6 | "signer", 7 | "challengeRequest" 8 | ]; 9 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/db-handler.js: -------------------------------------------------------------------------------- 1 | // empty for the browser 2 | export class DbHandler { 3 | constructor() { 4 | throw Error("Should not attempt to create a new instance of DbHandler on browser"); 5 | } 6 | } 7 | export default DbHandler; 8 | //# sourceMappingURL=db-handler.js.map -------------------------------------------------------------------------------- /dist/browser/runtime/browser/subplebbit/local-subplebbit.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"local-subplebbit.js","sourceRoot":"","sources":["../../../../../src/runtime/browser/subplebbit/local-subplebbit.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IACxB;QACI,MAAM,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC1E,CAAC;CACJ"} -------------------------------------------------------------------------------- /dist/node/constants.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,6EAAmB,CAAA;IACnB,mGAA8B,CAAA;IAC9B,uEAAgB,CAAA;IAChB,yGAAiC,CAAA,CAAC,iGAAiG;AACvI,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,0BAA0B"} -------------------------------------------------------------------------------- /dist/browser/constants.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,6EAAmB,CAAA;IACnB,mGAA8B,CAAA;IAC9B,uEAAgB,CAAA;IAChB,yGAAiC,CAAA,CAAC,iGAAiG;AACvI,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,0BAA0B"} -------------------------------------------------------------------------------- /scripts/build-watch-all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # go to current folder 4 | cd "$(dirname "$0")" 5 | cd .. 6 | 7 | xterm -geometry "-0+0" -e "npm run build:watch" & 8 | xterm -geometry "+0+0" -e "npm run webpack:watch" & 9 | xterm -geometry "-0-0" -e "npm run test:server" & 10 | sleep infinity 11 | -------------------------------------------------------------------------------- /src/runtime/node/native-functions.ts: -------------------------------------------------------------------------------- 1 | import type { NativeFunctions } from "../../types.js"; 2 | import dns from "node:dns"; 3 | dns.setDefaultResultOrder("ipv4first"); 4 | const nativeFunctions: NativeFunctions = { 5 | fetch: async (...args) => fetch(...args) 6 | }; 7 | 8 | export default nativeFunctions; 9 | -------------------------------------------------------------------------------- /dist/node/generic-state-client.d.ts: -------------------------------------------------------------------------------- 1 | import { PlebbitTypedEmitter } from "./clients/plebbit-typed-emitter.js"; 2 | import { GenericClientEvents } from "./types.js"; 3 | export declare class GenericStateClient extends PlebbitTypedEmitter> { 4 | state: T; 5 | constructor(state: T); 6 | } 7 | -------------------------------------------------------------------------------- /dist/browser/generic-state-client.d.ts: -------------------------------------------------------------------------------- 1 | import { PlebbitTypedEmitter } from "./clients/plebbit-typed-emitter.js"; 2 | import { GenericClientEvents } from "./types.js"; 3 | export declare class GenericStateClient extends PlebbitTypedEmitter> { 4 | state: T; 5 | constructor(state: T); 6 | } 7 | -------------------------------------------------------------------------------- /dist/browser/plebbit/plebbit-clients.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"plebbit-clients.js","sourceRoot":"","sources":["../../../src/plebbit/plebbit-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAQhE,MAAM,OAAO,wBAAyB,SAAQ,kBAAoD;CAAG;AAErG,MAAM,OAAO,oBAAqB,SAAQ,kBAAgD;CAAG;AAE7F,MAAM,OAAO,qBAAsB,SAAQ,kBAAiD;CAAG"} -------------------------------------------------------------------------------- /dist/browser/runtime/browser/native-functions.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"native-functions.js","sourceRoot":"","sources":["../../../../src/runtime/browser/native-functions.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAoB;IACrC,YAAY;IACZ,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,eAAe,eAAe,CAAC"} -------------------------------------------------------------------------------- /dist/node/plebbit/plebbit-clients.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"plebbit-clients.js","sourceRoot":"","sources":["../../../src/plebbit/plebbit-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAQhE,MAAM,OAAO,wBAAyB,SAAQ,kBAAoD;CAAG;AAErG,MAAM,OAAO,oBAAqB,SAAQ,kBAAgD;CAAG;AAE7F,MAAM,OAAO,qBAAsB,SAAQ,kBAAiD;CAAG"} -------------------------------------------------------------------------------- /dist/node/runtime/browser/native-functions.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"native-functions.js","sourceRoot":"","sources":["../../../../src/runtime/browser/native-functions.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAoB;IACrC,YAAY;IACZ,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,eAAe,eAAe,CAAC"} -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/fail.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"setup-kubo-address-rewriter-and-http-router.js","sourceRoot":"","sources":["../../../../src/runtime/browser/setup-kubo-address-rewriter-and-http-router.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,wCAAwC;IACpD,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAC;AACnD,CAAC"} -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/fail.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/voucher.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"setup-kubo-address-rewriter-and-http-router.js","sourceRoot":"","sources":["../../../../src/runtime/browser/setup-kubo-address-rewriter-and-http-router.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,wCAAwC;IACpD,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAC;AACnD,CAAC"} -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/blacklist.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/question.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/text-math.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/voucher.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/whitelist.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/blacklist.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/question.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/text-math.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/whitelist.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/publication-match.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/publication-match.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/node/clients/rpc-client/schema.js: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { CommentIpfsSchema, CommentUpdateSchema } from "../../publications/comment/schema.js"; 3 | export const SubscriptionIdSchema = z.number().positive().int(); 4 | export const RpcCommentUpdateResultSchema = CommentIpfsSchema.loose().or(CommentUpdateSchema); 5 | //# sourceMappingURL=schema.js.map -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "prettier.configPath": "./prettier.config.js", 3 | "editor.defaultFormatter": "esbenp.prettier-vscode", 4 | "editor.formatOnSave": true, 5 | "typescript.tsdk": "node_modules/typescript/lib", 6 | 7 | "files.exclude": { 8 | "dist/": true 9 | }, 10 | "git.ignoredRepositories": ["dist"] 11 | } 12 | -------------------------------------------------------------------------------- /dist/browser/clients/rpc-client/schema.js: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { CommentIpfsSchema, CommentUpdateSchema } from "../../publications/comment/schema.js"; 3 | export const SubscriptionIdSchema = z.number().positive().int(); 4 | export const RpcCommentUpdateResultSchema = CommentIpfsSchema.loose().or(CommentUpdateSchema); 5 | //# sourceMappingURL=schema.js.map -------------------------------------------------------------------------------- /dist/browser/pages/pages-clients.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"pages-clients.js","sourceRoot":"","sources":["../../../src/pages/pages-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIhE,MAAM,OAAO,sBAAuB,SAAQ,kBAAqC;CAAG;AAEpF,MAAM,OAAO,kBAAmB,SAAQ,kBAAqC;CAAG;AAEhF,MAAM,OAAO,mBAAoB,SAAQ,kBAAqC;CAAG;AAEjF,MAAM,OAAO,0BAA2B,SAAQ,kBAAqC;CAAG"} -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/captcha-canvas-v3/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/evm-contract-call/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/node/pages/pages-clients.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"pages-clients.js","sourceRoot":"","sources":["../../../src/pages/pages-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIhE,MAAM,OAAO,sBAAuB,SAAQ,kBAAqC;CAAG;AAEpF,MAAM,OAAO,kBAAmB,SAAQ,kBAAqC;CAAG;AAEhF,MAAM,OAAO,mBAAoB,SAAQ,kBAAqC;CAAG;AAEjF,MAAM,OAAO,0BAA2B,SAAQ,kBAAqC;CAAG"} -------------------------------------------------------------------------------- /dist/node/plebbit/plebbit-clients.js: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | export class PlebbitIpfsGatewayClient extends GenericStateClient { 3 | } 4 | export class PlebbitKuboRpcClient extends GenericStateClient { 5 | } 6 | export class PlebbitLibp2pJsClient extends GenericStateClient { 7 | } 8 | //# sourceMappingURL=plebbit-clients.js.map -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/exclude/index.d.ts: -------------------------------------------------------------------------------- 1 | import { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess } from "./exclude.js"; 2 | import { addToRateLimiter } from "./rate-limiter.js"; 3 | export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess, addToRateLimiter }; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/captcha-canvas-v3/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/evm-contract-call/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChallengeFileInput, SubplebbitChallengeSetting } from "../../../../../../subplebbit/types.js"; 2 | declare function ChallengeFileFactory(subplebbitChallengeSettings: SubplebbitChallengeSetting): ChallengeFileInput; 3 | export default ChallengeFileFactory; 4 | -------------------------------------------------------------------------------- /src/runtime/node/subplebbit/challenges/exclude/index.ts: -------------------------------------------------------------------------------- 1 | import { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess } from "./exclude.js"; 2 | import { addToRateLimiter } from "./rate-limiter.js"; 3 | 4 | export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess, addToRateLimiter }; 5 | -------------------------------------------------------------------------------- /dist/browser/plebbit/plebbit-clients.js: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | export class PlebbitIpfsGatewayClient extends GenericStateClient { 3 | } 4 | export class PlebbitKuboRpcClient extends GenericStateClient { 5 | } 6 | export class PlebbitLibp2pJsClient extends GenericStateClient { 7 | } 8 | //# sourceMappingURL=plebbit-clients.js.map -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/exclude/index.d.ts: -------------------------------------------------------------------------------- 1 | import { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess } from "./exclude.js"; 2 | import { addToRateLimiter } from "./rate-limiter.js"; 3 | export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess, addToRateLimiter }; 4 | -------------------------------------------------------------------------------- /dist/node/runtime/node/native-functions.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"native-functions.js","sourceRoot":"","sources":["../../../../src/runtime/node/native-functions.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,GAAG,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;AACvC,MAAM,eAAe,GAAoB;IACrC,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;CAC3C,CAAC;AAEF,eAAe,eAAe,CAAC"} -------------------------------------------------------------------------------- /dist/browser/helia/helia-for-plebbit.d.ts: -------------------------------------------------------------------------------- 1 | import type { ParsedPlebbitOptions } from "../types.js"; 2 | import { Libp2pJsClient } from "./libp2pjsClient.js"; 3 | export declare function createLibp2pJsClientOrUseExistingOne(plebbitOptions: Required> & NonNullable[number]): Promise; 4 | -------------------------------------------------------------------------------- /dist/node/helia/helia-for-plebbit.d.ts: -------------------------------------------------------------------------------- 1 | import type { ParsedPlebbitOptions } from "../types.js"; 2 | import { Libp2pJsClient } from "./libp2pjsClient.js"; 3 | export declare function createLibp2pJsClientOrUseExistingOne(plebbitOptions: Required> & NonNullable[number]): Promise; 4 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/native-functions.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"native-functions.js","sourceRoot":"","sources":["../../../../src/runtime/browser/native-functions.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,GAAG,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;AACvC,MAAM,eAAe,GAAoB;IACrC,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;CAC3C,CAAC;AAEF,eAAe,eAAe,CAAC"} -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/exclude/index.js: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/exclude/index.js: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/exclude/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/runtime/node/subplebbit/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"} -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/exclude/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/runtime/browser/subplebbit/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"} -------------------------------------------------------------------------------- /dist/browser/generic-state-client.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"generic-state-client.js","sourceRoot":"","sources":["../../src/generic-state-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,OAAO,kBAAqC,SAAQ,mBAA2C;IAGjG,YAAY,KAAQ;QAChB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACJ"} -------------------------------------------------------------------------------- /dist/node/generic-state-client.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"generic-state-client.js","sourceRoot":"","sources":["../../src/generic-state-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,OAAO,kBAAqC,SAAQ,mBAA2C;IAGjG,YAAY,KAAQ;QAChB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACJ"} -------------------------------------------------------------------------------- /test/vitest-node-setup.js: -------------------------------------------------------------------------------- 1 | // Provide Mocha-style globals that existing tests expect when running under Vitest. 2 | if (typeof globalThis.beforeAll === "function" && typeof globalThis.before !== "function") { 3 | globalThis.before = globalThis.beforeAll; 4 | } 5 | if (typeof globalThis.afterAll === "function" && typeof globalThis.after !== "function") { 6 | globalThis.after = globalThis.afterAll; 7 | } 8 | -------------------------------------------------------------------------------- /dist/node/constants.d.ts: -------------------------------------------------------------------------------- 1 | export declare enum STORAGE_KEYS { 2 | INTERNAL_SUBPLEBBIT = 0,// InternalSubplebbitType 3 | PERSISTENT_DELETED_SUBPLEBBITS = 1,// These are basically sub db files that we're unable to remove for some reason on windows 4 | LAST_IPNS_RECORD = 2,// The last published IPNS record of the sub, updated everytime we publish a new one 5 | COMBINED_HASH_OF_PENDING_COMMENTS = 3 6 | } 7 | -------------------------------------------------------------------------------- /dist/browser/constants.d.ts: -------------------------------------------------------------------------------- 1 | export declare enum STORAGE_KEYS { 2 | INTERNAL_SUBPLEBBIT = 0,// InternalSubplebbitType 3 | PERSISTENT_DELETED_SUBPLEBBITS = 1,// These are basically sub db files that we're unable to remove for some reason on windows 4 | LAST_IPNS_RECORD = 2,// The last published IPNS record of the sub, updated everytime we publish a new one 5 | COMBINED_HASH_OF_PENDING_COMMENTS = 3 6 | } 7 | -------------------------------------------------------------------------------- /dist/browser/generic-state-client.js: -------------------------------------------------------------------------------- 1 | import { PlebbitTypedEmitter } from "./clients/plebbit-typed-emitter.js"; 2 | import { hideClassPrivateProps } from "./util.js"; 3 | export class GenericStateClient extends PlebbitTypedEmitter { 4 | constructor(state) { 5 | super(); 6 | this.state = state; 7 | hideClassPrivateProps(this); 8 | } 9 | } 10 | //# sourceMappingURL=generic-state-client.js.map -------------------------------------------------------------------------------- /dist/node/generic-state-client.js: -------------------------------------------------------------------------------- 1 | import { PlebbitTypedEmitter } from "./clients/plebbit-typed-emitter.js"; 2 | import { hideClassPrivateProps } from "./util.js"; 3 | export class GenericStateClient extends PlebbitTypedEmitter { 4 | constructor(state) { 5 | super(); 6 | this.state = state; 7 | hideClassPrivateProps(this); 8 | } 9 | } 10 | //# sourceMappingURL=generic-state-client.js.map -------------------------------------------------------------------------------- /dist/browser/subplebbit/subplebbit-clients.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"subplebbit-clients.js","sourceRoot":"","sources":["../../../src/subplebbit/subplebbit-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAqBhE,MAAM,OAAO,0BAA2B,SAAQ,kBAAyC;CAAG;AAE5F,MAAM,OAAO,uBAAwB,SAAQ,kBAAuC;CAAG;AAEvF,MAAM,OAAO,+BAAgC,SAAQ,kBAAsC;CAAG;AAE9F,MAAM,OAAO,wBAAyB,SAAQ,kBAA2C;CAAG;AAE5F,MAAM,OAAO,2BAA4B,SAAQ,kBAA0C;CAAG"} -------------------------------------------------------------------------------- /dist/node/clients/chain-provider-client.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"chain-provider-client.js","sourceRoot":"","sources":["../../../src/clients/chain-provider-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,MAAM,OAAO,0BAA2B,SAAQ,mBAAmE;IAE/G,YAAY,KAA0C;QAClD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACJ"} -------------------------------------------------------------------------------- /dist/node/subplebbit/subplebbit-clients.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"subplebbit-clients.js","sourceRoot":"","sources":["../../../src/subplebbit/subplebbit-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAqBhE,MAAM,OAAO,0BAA2B,SAAQ,kBAAyC;CAAG;AAE5F,MAAM,OAAO,uBAAwB,SAAQ,kBAAuC;CAAG;AAEvF,MAAM,OAAO,+BAAgC,SAAQ,kBAAsC;CAAG;AAE9F,MAAM,OAAO,wBAAyB,SAAQ,kBAA2C;CAAG;AAE5F,MAAM,OAAO,2BAA4B,SAAQ,kBAA0C;CAAG"} -------------------------------------------------------------------------------- /dist/browser/clients/chain-provider-client.js: -------------------------------------------------------------------------------- 1 | import { hideClassPrivateProps } from "../util.js"; 2 | import { PlebbitTypedEmitter } from "./plebbit-typed-emitter.js"; 3 | export class GenericChainProviderClient extends PlebbitTypedEmitter { 4 | constructor(state) { 5 | super(); 6 | this.state = state; 7 | hideClassPrivateProps(this); 8 | } 9 | } 10 | //# sourceMappingURL=chain-provider-client.js.map -------------------------------------------------------------------------------- /dist/browser/clients/chain-provider-client.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"chain-provider-client.js","sourceRoot":"","sources":["../../../src/clients/chain-provider-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,MAAM,OAAO,0BAA2B,SAAQ,mBAAmE;IAE/G,YAAY,KAA0C;QAClD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACJ"} -------------------------------------------------------------------------------- /dist/node/clients/chain-provider-client.js: -------------------------------------------------------------------------------- 1 | import { hideClassPrivateProps } from "../util.js"; 2 | import { PlebbitTypedEmitter } from "./plebbit-typed-emitter.js"; 3 | export class GenericChainProviderClient extends PlebbitTypedEmitter { 4 | constructor(state) { 5 | super(); 6 | this.state = state; 7 | hideClassPrivateProps(this); 8 | } 9 | } 10 | //# sourceMappingURL=chain-provider-client.js.map -------------------------------------------------------------------------------- /dist/node/publications/publication-clients.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"publication-clients.js","sourceRoot":"","sources":["../../../src/publications/publication-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAqBhE,MAAM,OAAO,yBAA0B,SAAQ,kBAA4C;CAAG;AAE9F,MAAM,OAAO,wBAAyB,SAAQ,kBAAwC;CAAG;AAEzF,MAAM,OAAO,2BAA4B,SAAQ,kBAA0C;CAAG;AAE9F,MAAM,OAAO,4BAA6B,SAAQ,kBAA2C;CAAG;AAEhG,MAAM,OAAO,gCAAiC,SAAQ,kBAAuC;CAAG"} -------------------------------------------------------------------------------- /dist/node/test/mock-ipfs-client.d.ts: -------------------------------------------------------------------------------- 1 | import type { KuboRpcClient } from "../types.js"; 2 | declare class MockPubsubHttpClient { 3 | pubsub: KuboRpcClient["_client"]["pubsub"]; 4 | private subscriptions; 5 | constructor(dropRate?: number); 6 | } 7 | export declare const createMockPubsubClient: (dropRate?: number) => MockPubsubHttpClient; 8 | export declare const destroyMockPubsubClient: () => void; 9 | export {}; 10 | -------------------------------------------------------------------------------- /dist/browser/clients/rpc-client/schema.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/clients/rpc-client/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC9F,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC;AAEhE,MAAM,CAAC,MAAM,4BAA4B,GAAG,iBAAiB,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC"} -------------------------------------------------------------------------------- /dist/browser/publications/publication-clients.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"publication-clients.js","sourceRoot":"","sources":["../../../src/publications/publication-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAqBhE,MAAM,OAAO,yBAA0B,SAAQ,kBAA4C;CAAG;AAE9F,MAAM,OAAO,wBAAyB,SAAQ,kBAAwC;CAAG;AAEzF,MAAM,OAAO,2BAA4B,SAAQ,kBAA0C;CAAG;AAE9F,MAAM,OAAO,4BAA6B,SAAQ,kBAA2C;CAAG;AAEhG,MAAM,OAAO,gCAAiC,SAAQ,kBAAuC;CAAG"} -------------------------------------------------------------------------------- /dist/browser/test/mock-ipfs-client.d.ts: -------------------------------------------------------------------------------- 1 | import type { KuboRpcClient } from "../types.js"; 2 | declare class MockPubsubHttpClient { 3 | pubsub: KuboRpcClient["_client"]["pubsub"]; 4 | private subscriptions; 5 | constructor(dropRate?: number); 6 | } 7 | export declare const createMockPubsubClient: (dropRate?: number) => MockPubsubHttpClient; 8 | export declare const destroyMockPubsubClient: () => void; 9 | export {}; 10 | -------------------------------------------------------------------------------- /dist/node/clients/rpc-client/schema.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/clients/rpc-client/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC9F,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC;AAEhE,MAAM,CAAC,MAAM,4BAA4B,GAAG,iBAAiB,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC"} -------------------------------------------------------------------------------- /dist/browser/clients/plebbit-typed-emitter.d.ts: -------------------------------------------------------------------------------- 1 | import { ListenerSignature, TypedEmitter } from "tiny-typed-emitter"; 2 | export declare class PlebbitTypedEmitter> extends TypedEmitter { 3 | _mirroredClient?: PlebbitTypedEmitter; 4 | state: any; 5 | private _stateListener?; 6 | constructor(); 7 | mirror(sourceClient: PlebbitTypedEmitter): void; 8 | unmirror(): void; 9 | } 10 | -------------------------------------------------------------------------------- /dist/browser/pages/pages-clients.js: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | export class PagesIpfsGatewayClient extends GenericStateClient { 3 | } 4 | export class PagesKuboRpcClient extends GenericStateClient { 5 | } 6 | export class PagesLibp2pJsClient extends GenericStateClient { 7 | } 8 | export class PagesPlebbitRpcStateClient extends GenericStateClient { 9 | } 10 | //# sourceMappingURL=pages-clients.js.map -------------------------------------------------------------------------------- /dist/browser/publications/comment/comment-clients.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"comment-clients.js","sourceRoot":"","sources":["../../../../src/publications/comment/comment-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAoBnE,MAAM,OAAO,qBAAsB,SAAQ,kBAAwC;CAAG;AAEtF,MAAM,OAAO,oBAAqB,SAAQ,kBAAoC;CAAG;AAEjF,MAAM,OAAO,uBAAwB,SAAQ,kBAAsC;CAAG;AAEtF,MAAM,OAAO,wBAAyB,SAAQ,kBAAuC;CAAG;AAExF,MAAM,OAAO,4BAA6B,SAAQ,kBAAmC;CAAG"} -------------------------------------------------------------------------------- /dist/node/clients/plebbit-typed-emitter.d.ts: -------------------------------------------------------------------------------- 1 | import { ListenerSignature, TypedEmitter } from "tiny-typed-emitter"; 2 | export declare class PlebbitTypedEmitter> extends TypedEmitter { 3 | _mirroredClient?: PlebbitTypedEmitter; 4 | state: any; 5 | private _stateListener?; 6 | constructor(); 7 | mirror(sourceClient: PlebbitTypedEmitter): void; 8 | unmirror(): void; 9 | } 10 | -------------------------------------------------------------------------------- /dist/node/pages/pages-clients.js: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | export class PagesIpfsGatewayClient extends GenericStateClient { 3 | } 4 | export class PagesKuboRpcClient extends GenericStateClient { 5 | } 6 | export class PagesLibp2pJsClient extends GenericStateClient { 7 | } 8 | export class PagesPlebbitRpcStateClient extends GenericStateClient { 9 | } 10 | //# sourceMappingURL=pages-clients.js.map -------------------------------------------------------------------------------- /dist/node/publications/comment/comment-clients.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"comment-clients.js","sourceRoot":"","sources":["../../../../src/publications/comment/comment-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAoBnE,MAAM,OAAO,qBAAsB,SAAQ,kBAAwC;CAAG;AAEtF,MAAM,OAAO,oBAAqB,SAAQ,kBAAoC;CAAG;AAEjF,MAAM,OAAO,uBAAwB,SAAQ,kBAAsC;CAAG;AAEtF,MAAM,OAAO,wBAAyB,SAAQ,kBAAuC;CAAG;AAExF,MAAM,OAAO,4BAA6B,SAAQ,kBAAmC;CAAG"} -------------------------------------------------------------------------------- /src/rpc/.gitignore: -------------------------------------------------------------------------------- 1 | /TODO.md 2 | 3 | # generated preload.js file for karma electron tests 4 | karma-electron-preload.js 5 | 6 | # webpack bundles for karma browser tests 7 | test-karma-webpack 8 | 9 | # plebbit-js database files 10 | .plebbit 11 | .plebbit/ 12 | 13 | # build folder 14 | dist/ 15 | /dist/ 16 | dist 17 | 18 | node_modules/ 19 | packages/*/dist/ 20 | packages/example/.next/ 21 | .env.local 22 | yarn-error.log 23 | .env 24 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/subplebbit/challenges/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/runtime/browser/subplebbit/challenges/index.ts"],"names":[],"mappings":"AAAA,MAAM,2CAA2C,GAAG,EAAE,CAAC;AACvD,MAAM,4CAA4C,GAAG,EAAE,CAAC;AACxD,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,qDAAqD,GAAG,EAAE,CAAC;AACjE,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,OAAO,EACH,mBAAmB,EACnB,2CAA2C,EAC3C,4CAA4C,EAC5C,wBAAwB,EACxB,qDAAqD,EACxD,CAAC"} -------------------------------------------------------------------------------- /dist/node/runtime/browser/subplebbit/challenges/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/runtime/browser/subplebbit/challenges/index.ts"],"names":[],"mappings":"AAAA,MAAM,2CAA2C,GAAG,EAAE,CAAC;AACvD,MAAM,4CAA4C,GAAG,EAAE,CAAC;AACxD,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,qDAAqD,GAAG,EAAE,CAAC;AACjE,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,OAAO,EACH,mBAAmB,EACnB,2CAA2C,EAC3C,4CAA4C,EAC5C,wBAAwB,EACxB,qDAAqD,EACxD,CAAC"} -------------------------------------------------------------------------------- /dist/node/version.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE5E,MAAM,eAAe,GAAG,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC7D,MAAM,gBAAgB,GAAG,OAAO,CAAC,CAAC,4CAA4C;AAE9E,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,eAAe,gBAAgB,GAAG,CAAC,CAAC;AAE5E,eAAe;IACX,kBAAkB,EAAE,gBAAgB;IACpC,UAAU,EAAE,EAAE;IACd,gBAAgB,EAAE,eAAe;IACjC,UAAU,EAAE,SAAS;CACxB,CAAC"} -------------------------------------------------------------------------------- /dist/browser/version.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE5E,MAAM,eAAe,GAAG,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC7D,MAAM,gBAAgB,GAAG,OAAO,CAAC,CAAC,4CAA4C;AAE9E,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,eAAe,gBAAgB,GAAG,CAAC,CAAC;AAE5E,eAAe;IACX,kBAAkB,EAAE,gBAAgB;IACpC,UAAU,EAAE,EAAE;IACd,gBAAgB,EAAE,eAAe;IACjC,UAAU,EAAE,SAAS;CACxB,CAAC"} -------------------------------------------------------------------------------- /src/constants.ts: -------------------------------------------------------------------------------- 1 | export enum STORAGE_KEYS { 2 | INTERNAL_SUBPLEBBIT, // InternalSubplebbitType 3 | PERSISTENT_DELETED_SUBPLEBBITS, // These are basically sub db files that we're unable to remove for some reason on windows 4 | LAST_IPNS_RECORD, // The last published IPNS record of the sub, updated everytime we publish a new one 5 | COMBINED_HASH_OF_PENDING_COMMENTS // hash of all cids of pending comments. This is used to decide to publish a new mod queue or not 6 | } 7 | 8 | // Configs for LRU storage 9 | -------------------------------------------------------------------------------- /src/version.ts: -------------------------------------------------------------------------------- 1 | import { ProtocolVersionSchema, UserAgentSchema } from "./schema/schema.js"; 2 | 3 | const protocolVersion = ProtocolVersionSchema.parse("1.0.0"); 4 | const plebbitJsVersion = "0.0.7"; // TODO should be imported from package.json 5 | 6 | const userAgent = UserAgentSchema.parse(`/plebbit-js:${plebbitJsVersion}/`); 7 | 8 | export default { 9 | PLEBBIT_JS_VERSION: plebbitJsVersion, 10 | DB_VERSION: 26, 11 | PROTOCOL_VERSION: protocolVersion, 12 | USER_AGENT: userAgent 13 | }; 14 | -------------------------------------------------------------------------------- /examples/demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "plebbit_demo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "run_subplebbits.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@plebbit/plebbit-js": "https://github.com/plebbit/plebbit-js.git#38e29c0c4b0a14f959236cdd0df34924a555df63" 14 | }, 15 | "type": "module" 16 | } 17 | -------------------------------------------------------------------------------- /dist/node/clients/chain-provider-client.d.ts: -------------------------------------------------------------------------------- 1 | import type { GenericClientEvents } from "../types.js"; 2 | import { PlebbitTypedEmitter } from "./plebbit-typed-emitter.js"; 3 | type GenericChainproviderState = "stopped" | "resolving-subplebbit-address" | "resolving-author-address"; 4 | export declare class GenericChainProviderClient extends PlebbitTypedEmitter> { 5 | state: GenericChainproviderState; 6 | constructor(state: GenericChainProviderClient["state"]); 7 | } 8 | export {}; 9 | -------------------------------------------------------------------------------- /src/pages/pages-clients.ts: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | 3 | type PagesGatewayState = "fetching-ipfs" | "stopped"; 4 | 5 | export class PagesIpfsGatewayClient extends GenericStateClient {} 6 | 7 | export class PagesKuboRpcClient extends GenericStateClient {} 8 | 9 | export class PagesLibp2pJsClient extends GenericStateClient {} 10 | 11 | export class PagesPlebbitRpcStateClient extends GenericStateClient {} 12 | -------------------------------------------------------------------------------- /dist/browser/clients/chain-provider-client.d.ts: -------------------------------------------------------------------------------- 1 | import type { GenericClientEvents } from "../types.js"; 2 | import { PlebbitTypedEmitter } from "./plebbit-typed-emitter.js"; 3 | type GenericChainproviderState = "stopped" | "resolving-subplebbit-address" | "resolving-author-address"; 4 | export declare class GenericChainProviderClient extends PlebbitTypedEmitter> { 5 | state: GenericChainproviderState; 6 | constructor(state: GenericChainProviderClient["state"]); 7 | } 8 | export {}; 9 | -------------------------------------------------------------------------------- /dist/node/version.js: -------------------------------------------------------------------------------- 1 | import { ProtocolVersionSchema, UserAgentSchema } from "./schema/schema.js"; 2 | const protocolVersion = ProtocolVersionSchema.parse("1.0.0"); 3 | const plebbitJsVersion = "0.0.7"; // TODO should be imported from package.json 4 | const userAgent = UserAgentSchema.parse(`/plebbit-js:${plebbitJsVersion}/`); 5 | export default { 6 | PLEBBIT_JS_VERSION: plebbitJsVersion, 7 | DB_VERSION: 24, 8 | PROTOCOL_VERSION: protocolVersion, 9 | USER_AGENT: userAgent 10 | }; 11 | //# sourceMappingURL=version.js.map -------------------------------------------------------------------------------- /dist/browser/version.js: -------------------------------------------------------------------------------- 1 | import { ProtocolVersionSchema, UserAgentSchema } from "./schema/schema.js"; 2 | const protocolVersion = ProtocolVersionSchema.parse("1.0.0"); 3 | const plebbitJsVersion = "0.0.7"; // TODO should be imported from package.json 4 | const userAgent = UserAgentSchema.parse(`/plebbit-js:${plebbitJsVersion}/`); 5 | export default { 6 | PLEBBIT_JS_VERSION: plebbitJsVersion, 7 | DB_VERSION: 24, 8 | PROTOCOL_VERSION: protocolVersion, 9 | USER_AGENT: userAgent 10 | }; 11 | //# sourceMappingURL=version.js.map -------------------------------------------------------------------------------- /dist/node/publications/comment/comment-clients.js: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../../generic-state-client.js"; 2 | export class CommentLibp2pJsClient extends GenericStateClient { 3 | } 4 | export class CommentKuboRpcClient extends GenericStateClient { 5 | } 6 | export class CommentKuboPubsubClient extends GenericStateClient { 7 | } 8 | export class CommentIpfsGatewayClient extends GenericStateClient { 9 | } 10 | export class CommentPlebbitRpcStateClient extends GenericStateClient { 11 | } 12 | //# sourceMappingURL=comment-clients.js.map -------------------------------------------------------------------------------- /src/generic-state-client.ts: -------------------------------------------------------------------------------- 1 | import { PlebbitTypedEmitter } from "./clients/plebbit-typed-emitter.js"; 2 | import { GenericClientEvents } from "./types.js"; 3 | import { hideClassPrivateProps } from "./util.js"; 4 | 5 | export class GenericStateClient extends PlebbitTypedEmitter> { 6 | override state: T; 7 | 8 | constructor(state: T) { 9 | super(); 10 | this.state = state; 11 | this.setMaxListeners(100); 12 | hideClassPrivateProps(this); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /dist/browser/publications/comment/comment-clients.js: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../../generic-state-client.js"; 2 | export class CommentLibp2pJsClient extends GenericStateClient { 3 | } 4 | export class CommentKuboRpcClient extends GenericStateClient { 5 | } 6 | export class CommentKuboPubsubClient extends GenericStateClient { 7 | } 8 | export class CommentIpfsGatewayClient extends GenericStateClient { 9 | } 10 | export class CommentPlebbitRpcStateClient extends GenericStateClient { 11 | } 12 | //# sourceMappingURL=comment-clients.js.map -------------------------------------------------------------------------------- /dist/browser/runtime/browser/subplebbit/challenges/index.js: -------------------------------------------------------------------------------- 1 | const getPendingChallengesOrChallengeVerification = {}; 2 | const getChallengeVerificationFromChallengeAnswers = {}; 3 | const getChallengeVerification = {}; 4 | const getSubplebbitChallengeFromSubplebbitChallengeSettings = {}; 5 | const plebbitJsChallenges = {}; 6 | export { plebbitJsChallenges, getPendingChallengesOrChallengeVerification, getChallengeVerificationFromChallengeAnswers, getChallengeVerification, getSubplebbitChallengeFromSubplebbitChallengeSettings }; 7 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/browser/subplebbit/subplebbit-clients.js: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | export class SubplebbitKuboPubsubClient extends GenericStateClient { 3 | } 4 | export class SubplebbitKuboRpcClient extends GenericStateClient { 5 | } 6 | export class SubplebbitPlebbitRpcStateClient extends GenericStateClient { 7 | } 8 | export class SubplebbitLibp2pJsClient extends GenericStateClient { 9 | } 10 | export class SubplebbitIpfsGatewayClient extends GenericStateClient { 11 | } 12 | //# sourceMappingURL=subplebbit-clients.js.map -------------------------------------------------------------------------------- /dist/node/runtime/browser/storage.d.ts: -------------------------------------------------------------------------------- 1 | import { StorageInterface } from "../../types.js"; 2 | export default class Storage implements StorageInterface { 3 | private _plebbit; 4 | private _store; 5 | constructor(plebbit: Storage["_plebbit"]); 6 | toJSON(): undefined; 7 | init(): Promise; 8 | getItem(key: string): Promise; 9 | setItem(key: string, value: any): Promise; 10 | removeItem(key: string | string[]): Promise; 11 | clear(): Promise; 12 | destroy(): Promise; 13 | } 14 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/subplebbit/challenges/index.js: -------------------------------------------------------------------------------- 1 | const getPendingChallengesOrChallengeVerification = {}; 2 | const getChallengeVerificationFromChallengeAnswers = {}; 3 | const getChallengeVerification = {}; 4 | const getSubplebbitChallengeFromSubplebbitChallengeSettings = {}; 5 | const plebbitJsChallenges = {}; 6 | export { plebbitJsChallenges, getPendingChallengesOrChallengeVerification, getChallengeVerificationFromChallengeAnswers, getChallengeVerification, getSubplebbitChallengeFromSubplebbitChallengeSettings }; 7 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/node/subplebbit/subplebbit-clients.js: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | export class SubplebbitKuboPubsubClient extends GenericStateClient { 3 | } 4 | export class SubplebbitKuboRpcClient extends GenericStateClient { 5 | } 6 | export class SubplebbitPlebbitRpcStateClient extends GenericStateClient { 7 | } 8 | export class SubplebbitLibp2pJsClient extends GenericStateClient { 9 | } 10 | export class SubplebbitIpfsGatewayClient extends GenericStateClient { 11 | } 12 | //# sourceMappingURL=subplebbit-clients.js.map -------------------------------------------------------------------------------- /test/fixtures/publications.js: -------------------------------------------------------------------------------- 1 | import signers from "./signers.js"; 2 | 3 | const comment = { 4 | subplebbitAddress: signers[0].address, 5 | author: { address: signers[1].address }, 6 | timestamp: 1600000000, 7 | parentCid: "QmbSiusGgY4Uk5LdAe91bzLkBzidyKyKHRKwhXPDz7gGyx", 8 | postCid: "QmbSiusGgY4Uk5LdAe91bzLkBzidyKyKHRKwhXPDz7gGyx", 9 | content: "some content... " 10 | }; 11 | // test large content 12 | let i = 1000; 13 | while (i--) { 14 | comment.content += "some content... "; 15 | } 16 | 17 | export { comment }; 18 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/storage.d.ts: -------------------------------------------------------------------------------- 1 | import { StorageInterface } from "../../types.js"; 2 | export default class Storage implements StorageInterface { 3 | private _plebbit; 4 | private _store; 5 | constructor(plebbit: Storage["_plebbit"]); 6 | toJSON(): undefined; 7 | init(): Promise; 8 | getItem(key: string): Promise; 9 | setItem(key: string, value: any): Promise; 10 | removeItem(key: string | string[]): Promise; 11 | clear(): Promise; 12 | destroy(): Promise; 13 | } 14 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/subplebbit/challenges/index.d.ts: -------------------------------------------------------------------------------- 1 | declare const getPendingChallengesOrChallengeVerification: {}; 2 | declare const getChallengeVerificationFromChallengeAnswers: {}; 3 | declare const getChallengeVerification: {}; 4 | declare const getSubplebbitChallengeFromSubplebbitChallengeSettings: {}; 5 | declare const plebbitJsChallenges: {}; 6 | export { plebbitJsChallenges, getPendingChallengesOrChallengeVerification, getChallengeVerificationFromChallengeAnswers, getChallengeVerification, getSubplebbitChallengeFromSubplebbitChallengeSettings }; 7 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/subplebbit/challenges/index.d.ts: -------------------------------------------------------------------------------- 1 | declare const getPendingChallengesOrChallengeVerification: {}; 2 | declare const getChallengeVerificationFromChallengeAnswers: {}; 3 | declare const getChallengeVerification: {}; 4 | declare const getSubplebbitChallengeFromSubplebbitChallengeSettings: {}; 5 | declare const plebbitJsChallenges: {}; 6 | export { plebbitJsChallenges, getPendingChallengesOrChallengeVerification, getChallengeVerificationFromChallengeAnswers, getChallengeVerification, getSubplebbitChallengeFromSubplebbitChallengeSettings }; 7 | -------------------------------------------------------------------------------- /dist/browser/publications/publication-clients.js: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | export class PublicationLibp2pJsClient extends GenericStateClient { 3 | } 4 | export class PublicationKuboRpcClient extends GenericStateClient { 5 | } 6 | export class PublicationKuboPubsubClient extends GenericStateClient { 7 | } 8 | export class PublicationIpfsGatewayClient extends GenericStateClient { 9 | } 10 | export class PublicationPlebbitRpcStateClient extends GenericStateClient { 11 | } 12 | //# sourceMappingURL=publication-clients.js.map -------------------------------------------------------------------------------- /dist/node/publications/publication-clients.js: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | export class PublicationLibp2pJsClient extends GenericStateClient { 3 | } 4 | export class PublicationKuboRpcClient extends GenericStateClient { 5 | } 6 | export class PublicationKuboPubsubClient extends GenericStateClient { 7 | } 8 | export class PublicationIpfsGatewayClient extends GenericStateClient { 9 | } 10 | export class PublicationPlebbitRpcStateClient extends GenericStateClient { 11 | } 12 | //# sourceMappingURL=publication-clients.js.map -------------------------------------------------------------------------------- /src/runtime/browser/subplebbit/challenges/index.ts: -------------------------------------------------------------------------------- 1 | const getPendingChallengesOrChallengeVerification = {}; 2 | const getChallengeVerificationFromChallengeAnswers = {}; 3 | const getChallengeVerification = {}; 4 | const getSubplebbitChallengeFromSubplebbitChallengeSettings = {}; 5 | const plebbitJsChallenges = {}; 6 | export { 7 | plebbitJsChallenges, 8 | getPendingChallengesOrChallengeVerification, 9 | getChallengeVerificationFromChallengeAnswers, 10 | getChallengeVerification, 11 | getSubplebbitChallengeFromSubplebbitChallengeSettings 12 | }; 13 | -------------------------------------------------------------------------------- /dist/node/pages/pages-clients.d.ts: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | type PagesGatewayState = "fetching-ipfs" | "stopped"; 3 | export declare class PagesIpfsGatewayClient extends GenericStateClient { 4 | } 5 | export declare class PagesKuboRpcClient extends GenericStateClient { 6 | } 7 | export declare class PagesLibp2pJsClient extends GenericStateClient { 8 | } 9 | export declare class PagesPlebbitRpcStateClient extends GenericStateClient { 10 | } 11 | export {}; 12 | -------------------------------------------------------------------------------- /dist/node/runtime/node/storage.d.ts: -------------------------------------------------------------------------------- 1 | import type { StorageInterface } from "../../types.js"; 2 | export default class Storage implements StorageInterface { 3 | private _plebbit; 4 | private _keyv; 5 | private _db; 6 | constructor(plebbit: Storage["_plebbit"]); 7 | toJSON(): undefined; 8 | init(): Promise; 9 | getItem(key: string): Promise; 10 | setItem(key: string, value: any): Promise; 11 | removeItem(key: string | string[]): Promise; 12 | clear(): Promise; 13 | destroy(): Promise; 14 | } 15 | -------------------------------------------------------------------------------- /dist/browser/pages/pages-clients.d.ts: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | type PagesGatewayState = "fetching-ipfs" | "stopped"; 3 | export declare class PagesIpfsGatewayClient extends GenericStateClient { 4 | } 5 | export declare class PagesKuboRpcClient extends GenericStateClient { 6 | } 7 | export declare class PagesLibp2pJsClient extends GenericStateClient { 8 | } 9 | export declare class PagesPlebbitRpcStateClient extends GenericStateClient { 10 | } 11 | export {}; 12 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/storage.d.ts: -------------------------------------------------------------------------------- 1 | import type { StorageInterface } from "../../types.js"; 2 | export default class Storage implements StorageInterface { 3 | private _plebbit; 4 | private _keyv; 5 | private _db; 6 | constructor(plebbit: Storage["_plebbit"]); 7 | toJSON(): undefined; 8 | init(): Promise; 9 | getItem(key: string): Promise; 10 | setItem(key: string, value: any): Promise; 11 | removeItem(key: string | string[]): Promise; 12 | clear(): Promise; 13 | destroy(): Promise; 14 | } 15 | -------------------------------------------------------------------------------- /dist/browser/zod-error-map.js: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | const defaultLocaleError = z.locales.en().localeError; 3 | const friendlyErrorMap = (rawIssue) => { 4 | const pathSegments = rawIssue.path ?? []; 5 | const path = pathSegments.length ? pathSegments.map((segment) => segment.toString()).join(".") : ""; 6 | const baseMessage = rawIssue.message ?? defaultLocaleError(rawIssue) ?? "Invalid input"; 7 | return path ? { message: `${path}: ${baseMessage}` } : { message: baseMessage }; 8 | }; 9 | z.setErrorMap(friendlyErrorMap); 10 | //# sourceMappingURL=zod-error-map.js.map -------------------------------------------------------------------------------- /dist/node/general-util/limited-set.d.ts: -------------------------------------------------------------------------------- 1 | export declare class LimitedSet { 2 | private maxSize; 3 | private set; 4 | private insertionOrder; 5 | constructor(maxSize: number); 6 | add(value: T): LimitedSet; 7 | has(value: T): boolean; 8 | delete(value: T): boolean; 9 | clear(): void; 10 | get size(): number; 11 | [Symbol.iterator](): IterableIterator; 12 | entries(): IterableIterator<[T, T]>; 13 | values(): IterableIterator; 14 | forEach(callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; 15 | } 16 | -------------------------------------------------------------------------------- /dist/node/zod-error-map.js: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | const defaultLocaleError = z.locales.en().localeError; 3 | const friendlyErrorMap = (rawIssue) => { 4 | const pathSegments = rawIssue.path ?? []; 5 | const path = pathSegments.length ? pathSegments.map((segment) => segment.toString()).join(".") : ""; 6 | const baseMessage = rawIssue.message ?? defaultLocaleError(rawIssue) ?? "Invalid input"; 7 | return path ? { message: `${path}: ${baseMessage}` } : { message: baseMessage }; 8 | }; 9 | z.setErrorMap(friendlyErrorMap); 10 | //# sourceMappingURL=zod-error-map.js.map -------------------------------------------------------------------------------- /dist/browser/general-util/limited-set.d.ts: -------------------------------------------------------------------------------- 1 | export declare class LimitedSet { 2 | private maxSize; 3 | private set; 4 | private insertionOrder; 5 | constructor(maxSize: number); 6 | add(value: T): LimitedSet; 7 | has(value: T): boolean; 8 | delete(value: T): boolean; 9 | clear(): void; 10 | get size(): number; 11 | [Symbol.iterator](): IterableIterator; 12 | entries(): IterableIterator<[T, T]>; 13 | values(): IterableIterator; 14 | forEach(callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; 15 | } 16 | -------------------------------------------------------------------------------- /scripts/build-and-test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # go to current folder 4 | cd "$(dirname "$0")" 5 | cd .. 6 | 7 | # build and bundle 8 | npm install 9 | npm run build 10 | npm run webpack 11 | 12 | # wait until test server is ready 13 | npm run test:server & npm run test:server:wait-on 14 | 15 | # tests 16 | npm run test:node:parallel 17 | CHROME_BIN=$(which chrome || which chromium) FIREFOX_BIN=$(which firefox) npm run test:browser 18 | 19 | # close test server 20 | kill `pgrep --full 'node test/test-server'` 21 | # close ipfs daemons 22 | kill `pgrep --full 'ipfs daemon'` 23 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/localforage-lru.d.ts: -------------------------------------------------------------------------------- 1 | type ForageOptions = { 2 | size: number; 3 | name: string; 4 | }; 5 | export declare const createInstance: (localForageLruOptions: ForageOptions) => { 6 | getItem: (key: string) => Promise; 7 | setItem: (key: string, value: any) => Promise; 8 | removeItem: (key: string) => Promise; 9 | clear: () => Promise; 10 | key: (keyIndex: number) => Promise; 11 | keys: () => Promise; 12 | entries: () => Promise; 13 | length: () => Promise; 14 | }; 15 | export {}; 16 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/localforage-lru.d.ts: -------------------------------------------------------------------------------- 1 | type ForageOptions = { 2 | size: number; 3 | name: string; 4 | }; 5 | export declare const createInstance: (localForageLruOptions: ForageOptions) => { 6 | getItem: (key: string) => Promise; 7 | setItem: (key: string, value: any) => Promise; 8 | removeItem: (key: string) => Promise; 9 | clear: () => Promise; 10 | key: (keyIndex: number) => Promise; 11 | keys: () => Promise; 12 | entries: () => Promise; 13 | length: () => Promise; 14 | }; 15 | export {}; 16 | -------------------------------------------------------------------------------- /dist/node/runtime/node/lru-storage.d.ts: -------------------------------------------------------------------------------- 1 | import { LRUStorageConstructor, LRUStorageInterface } from "../../types.js"; 2 | export default class LRUStorage implements LRUStorageInterface { 3 | private _opts; 4 | private _cache; 5 | constructor(opts: LRUStorageConstructor); 6 | toJSON(): undefined; 7 | init(): Promise; 8 | getItem(key: string): Promise; 9 | setItem(key: string, value: any): Promise; 10 | removeItem(key: string): Promise; 11 | clear(): Promise; 12 | keys(): Promise; 13 | destroy(): Promise; 14 | } 15 | -------------------------------------------------------------------------------- /src/plebbit/plebbit-clients.ts: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | 3 | type PlebbitIpfsGatewayState = "fetching-ipfs" | "stopped"; 4 | 5 | type PlebbitKuboRpcState = "fetching-ipfs" | "stopped"; 6 | 7 | type PlebbitLibp2pJsState = "fetching-ipfs" | "stopped"; 8 | 9 | export class PlebbitIpfsGatewayClient extends GenericStateClient {} 10 | 11 | export class PlebbitKuboRpcClient extends GenericStateClient {} 12 | 13 | export class PlebbitLibp2pJsClient extends GenericStateClient {} 14 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/lru-storage.d.ts: -------------------------------------------------------------------------------- 1 | import { LRUStorageConstructor, LRUStorageInterface } from "../../types.js"; 2 | export default class LRUStorage implements LRUStorageInterface { 3 | private _opts; 4 | private _cache; 5 | constructor(opts: LRUStorageConstructor); 6 | toJSON(): undefined; 7 | init(): Promise; 8 | getItem(key: string): Promise; 9 | setItem(key: string, value: any): Promise; 10 | removeItem(key: string): Promise; 11 | clear(): Promise; 12 | keys(): Promise; 13 | destroy(): Promise; 14 | } 15 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/lru-storage.d.ts: -------------------------------------------------------------------------------- 1 | import { LRUStorageConstructor, LRUStorageInterface } from "../../types.js"; 2 | export default class LRUStorage implements LRUStorageInterface { 3 | private _opts; 4 | private _cache; 5 | constructor(opts: LRUStorageConstructor); 6 | toJSON(): undefined; 7 | init(): Promise; 8 | getItem(key: string): Promise; 9 | setItem(key: string, value: any): Promise; 10 | removeItem(key: string): Promise; 11 | clear(): Promise; 12 | keys(): Promise; 13 | destroy(): Promise; 14 | } 15 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/lru-storage.d.ts: -------------------------------------------------------------------------------- 1 | import { LRUStorageConstructor, LRUStorageInterface } from "../../types.js"; 2 | export default class LRUStorage implements LRUStorageInterface { 3 | private _opts; 4 | private _cache; 5 | constructor(opts: LRUStorageConstructor); 6 | toJSON(): undefined; 7 | init(): Promise; 8 | getItem(key: string): Promise; 9 | setItem(key: string, value: any): Promise; 10 | removeItem(key: string): Promise; 11 | clear(): Promise; 12 | keys(): Promise; 13 | destroy(): Promise; 14 | } 15 | -------------------------------------------------------------------------------- /config/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "../dist/node", 4 | "module": "ES2022", 5 | "declaration": true, 6 | "target": "ES2021", 7 | "lib": ["ES2021"], 8 | "moduleResolution": "Bundler", 9 | "customConditions": ["node"], 10 | "forceConsistentCasingInFileNames": true, 11 | "skipLibCheck": true, 12 | "sourceMap": true, 13 | "strict": true, 14 | "experimentalDecorators": true, 15 | "noImplicitOverride": true 16 | }, 17 | "include": ["../src/**/*"], 18 | "exclude": ["../node_modules"] 19 | } 20 | -------------------------------------------------------------------------------- /dist/node/plebbit/plebbit-clients.d.ts: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | type PlebbitIpfsGatewayState = "fetching-ipfs" | "stopped"; 3 | type PlebbitKuboRpcState = "fetching-ipfs" | "stopped"; 4 | type PlebbitLibp2pJsState = "fetching-ipfs" | "stopped"; 5 | export declare class PlebbitIpfsGatewayClient extends GenericStateClient { 6 | } 7 | export declare class PlebbitKuboRpcClient extends GenericStateClient { 8 | } 9 | export declare class PlebbitLibp2pJsClient extends GenericStateClient { 10 | } 11 | export {}; 12 | -------------------------------------------------------------------------------- /dist/browser/plebbit/plebbit-clients.d.ts: -------------------------------------------------------------------------------- 1 | import { GenericStateClient } from "../generic-state-client.js"; 2 | type PlebbitIpfsGatewayState = "fetching-ipfs" | "stopped"; 3 | type PlebbitKuboRpcState = "fetching-ipfs" | "stopped"; 4 | type PlebbitLibp2pJsState = "fetching-ipfs" | "stopped"; 5 | export declare class PlebbitIpfsGatewayClient extends GenericStateClient { 6 | } 7 | export declare class PlebbitKuboRpcClient extends GenericStateClient { 8 | } 9 | export declare class PlebbitLibp2pJsClient extends GenericStateClient { 10 | } 11 | export {}; 12 | -------------------------------------------------------------------------------- /dist/browser/constants.js: -------------------------------------------------------------------------------- 1 | export var STORAGE_KEYS; 2 | (function (STORAGE_KEYS) { 3 | STORAGE_KEYS[STORAGE_KEYS["INTERNAL_SUBPLEBBIT"] = 0] = "INTERNAL_SUBPLEBBIT"; 4 | STORAGE_KEYS[STORAGE_KEYS["PERSISTENT_DELETED_SUBPLEBBITS"] = 1] = "PERSISTENT_DELETED_SUBPLEBBITS"; 5 | STORAGE_KEYS[STORAGE_KEYS["LAST_IPNS_RECORD"] = 2] = "LAST_IPNS_RECORD"; 6 | STORAGE_KEYS[STORAGE_KEYS["COMBINED_HASH_OF_PENDING_COMMENTS"] = 3] = "COMBINED_HASH_OF_PENDING_COMMENTS"; // hash of all cids of pending comments. This is used to decide to publish a new mod queue or not 7 | })(STORAGE_KEYS || (STORAGE_KEYS = {})); 8 | // Configs for LRU storage 9 | //# sourceMappingURL=constants.js.map -------------------------------------------------------------------------------- /dist/node/constants.js: -------------------------------------------------------------------------------- 1 | export var STORAGE_KEYS; 2 | (function (STORAGE_KEYS) { 3 | STORAGE_KEYS[STORAGE_KEYS["INTERNAL_SUBPLEBBIT"] = 0] = "INTERNAL_SUBPLEBBIT"; 4 | STORAGE_KEYS[STORAGE_KEYS["PERSISTENT_DELETED_SUBPLEBBITS"] = 1] = "PERSISTENT_DELETED_SUBPLEBBITS"; 5 | STORAGE_KEYS[STORAGE_KEYS["LAST_IPNS_RECORD"] = 2] = "LAST_IPNS_RECORD"; 6 | STORAGE_KEYS[STORAGE_KEYS["COMBINED_HASH_OF_PENDING_COMMENTS"] = 3] = "COMBINED_HASH_OF_PENDING_COMMENTS"; // hash of all cids of pending comments. This is used to decide to publish a new mod queue or not 7 | })(STORAGE_KEYS || (STORAGE_KEYS = {})); 8 | // Configs for LRU storage 9 | //# sourceMappingURL=constants.js.map -------------------------------------------------------------------------------- /dist/node/helia/util.d.ts: -------------------------------------------------------------------------------- 1 | import type { HeliaWithLibp2pPubsub } from "./types.js"; 2 | import type { PeerId } from "@libp2p/interface"; 3 | import Logger from "@plebbit/plebbit-logger"; 4 | export declare function connectToPubsubPeers({ helia, pubsubTopic, maxPeers, options, log }: { 5 | helia: HeliaWithLibp2pPubsub; 6 | pubsubTopic: string; 7 | maxPeers: number; 8 | log: Logger; 9 | options?: { 10 | signal?: AbortSignal; 11 | }; 12 | }): Promise>[]>; 13 | export declare function waitForTopicPeers(helia: HeliaWithLibp2pPubsub, topic: string, minPeers?: number, timeoutMs?: number): Promise; 14 | -------------------------------------------------------------------------------- /scripts/build-plebones.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # go to current folder 4 | cd "$(dirname "$0")" 5 | cd .. 6 | 7 | # build and bundle 8 | npm install 9 | npm run build 10 | 11 | # build plebones 12 | git clone https://github.com/plebbit/plebones.git plebones 13 | cd plebones 14 | yarn 15 | 16 | # replace old plebbit-js in plebones deps with latest plebbit-js 17 | rm -fr node_modules/@plebbit/plebbit-js/dist 18 | cp -r ../dist node_modules/@plebbit/plebbit-js/dist 19 | 20 | # build plebones with latest plebbit-js commit ref 21 | REACT_APP_COMMIT_REF=$COMMIT_REF yarn build-netlify 22 | 23 | # copy plebones build to plebbit-js build folder 24 | cp -r build ../build 25 | -------------------------------------------------------------------------------- /dist/browser/helia/libp2pjsClient.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"libp2pjsClient.js","sourceRoot":"","sources":["../../../src/helia/libp2pjsClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAenD,MAAM,OAAO,cAAc;IAUvB,YAAY,qBAAyC;QACjD,IAAI,CAAC,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC;QAC1C,IAAI,CAAC,YAAY,GAAG,qBAAqB,CAAC,WAAW,CAAC;QACtD,IAAI,CAAC,gBAAgB,GAAG,qBAAqB,CAAC,eAAe,CAAC;QAC9D,IAAI,CAAC,+BAA+B,GAAG,qBAAqB,CAAC,+BAA+B,CAAC;QAC7F,IAAI,CAAC,uBAAuB,GAAG,qBAAqB,CAAC,sBAAsB,CAAC;QAC5E,IAAI,CAAC,mBAAmB,GAAG,qBAAqB,CAAC,kBAAkB,CAAC;QACpE,IAAI,CAAC,GAAG,GAAG,qBAAqB,CAAC,GAAG,CAAC;QACrC,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,qBAAqB,CAAC;QAEzE,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACJ"} -------------------------------------------------------------------------------- /dist/browser/helia/util.d.ts: -------------------------------------------------------------------------------- 1 | import type { HeliaWithLibp2pPubsub } from "./types.js"; 2 | import type { PeerId } from "@libp2p/interface"; 3 | import Logger from "@plebbit/plebbit-logger"; 4 | export declare function connectToPubsubPeers({ helia, pubsubTopic, maxPeers, options, log }: { 5 | helia: HeliaWithLibp2pPubsub; 6 | pubsubTopic: string; 7 | maxPeers: number; 8 | log: Logger; 9 | options?: { 10 | signal?: AbortSignal; 11 | }; 12 | }): Promise>[]>; 13 | export declare function waitForTopicPeers(helia: HeliaWithLibp2pPubsub, topic: string, minPeers?: number, timeoutMs?: number): Promise; 14 | -------------------------------------------------------------------------------- /dist/node/helia/libp2pjsClient.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"libp2pjsClient.js","sourceRoot":"","sources":["../../../src/helia/libp2pjsClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAenD,MAAM,OAAO,cAAc;IAUvB,YAAY,qBAAyC;QACjD,IAAI,CAAC,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC;QAC1C,IAAI,CAAC,YAAY,GAAG,qBAAqB,CAAC,WAAW,CAAC;QACtD,IAAI,CAAC,gBAAgB,GAAG,qBAAqB,CAAC,eAAe,CAAC;QAC9D,IAAI,CAAC,+BAA+B,GAAG,qBAAqB,CAAC,+BAA+B,CAAC;QAC7F,IAAI,CAAC,uBAAuB,GAAG,qBAAqB,CAAC,sBAAsB,CAAC;QAC5E,IAAI,CAAC,mBAAmB,GAAG,qBAAqB,CAAC,kBAAkB,CAAC;QACpE,IAAI,CAAC,GAAG,GAAG,qBAAqB,CAAC,GAAG,CAAC;QACrC,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,qBAAqB,CAAC;QAEzE,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACJ"} -------------------------------------------------------------------------------- /rpc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@plebbit/plebbit-js-rpc", 3 | "type": "module", 4 | "keywords": [ 5 | "plebbit", 6 | "subplebbit" 7 | ], 8 | "repository": "github:plebbit/plebbit-js", 9 | "license": "GPL-2.0", 10 | "publishConfig": { 11 | "access": "public" 12 | }, 13 | "version": "0.0.1", 14 | "files": [ 15 | "../dist/node/rpc/src" 16 | ], 17 | "main": "../dist/node/rpc/src/index.js", 18 | "typings": "../dist/node/rpc/src/index.d.ts", 19 | "scripts": { 20 | "prettier": "prettier {src,test,config}/**/*.{cjs,js,jsx,ts,tsx} --config config/prettier.config.js --write" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /scripts/build-watch-all-debug.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # this script is debug what's happening with "npm run build:browser:watch" 4 | # normally you don't want to look at the browser build as it doesn't 5 | # give any useful errors and you simply want to run "npm run build:watch" 6 | # which builds both for node and browser but hides the browser part 7 | 8 | # go to current folder 9 | cd "$(dirname "$0")" 10 | cd .. 11 | 12 | xterm -geometry "-0+0" -e "npm run build:node:watch" & 13 | xterm -geometry "+0+0" -e "npm run build:browser:watch" & 14 | xterm -geometry "-0-0" -e "npm run webpack:watch" & 15 | xterm -geometry "+0-0" -e "npm run test:server" & 16 | sleep infinity 17 | -------------------------------------------------------------------------------- /src/clients/chain-provider-client.ts: -------------------------------------------------------------------------------- 1 | import type { GenericClientEvents } from "../types.js"; 2 | import { hideClassPrivateProps } from "../util.js"; 3 | import { PlebbitTypedEmitter } from "./plebbit-typed-emitter.js"; 4 | 5 | type GenericChainproviderState = "stopped" | "resolving-subplebbit-address" | "resolving-author-address"; 6 | export class GenericChainProviderClient extends PlebbitTypedEmitter> { 7 | override state: GenericChainproviderState; 8 | constructor(state: GenericChainProviderClient["state"]) { 9 | super(); 10 | this.state = state; 11 | hideClassPrivateProps(this); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/fixtures/valid_vote.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": { "address": "12D3KooWMZPQsQdYtrakc4D1XtzGXwN1X3DBnAobcCjcPYYXTB6o" }, 3 | "subplebbitAddress": "12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR", 4 | "commentCid": "Qme7V7TVpK3Po9QbiiEjMSQ3mv1VDwsTZ2EnUyu9eutTZU", 5 | "timestamp": 1677422961, 6 | "vote": 1, 7 | "signature": { 8 | "signature": "x7dTBbXrB9yj8Y2+vqmV68g5fvGKY5IZboWPG7q+Ho5SmJdHkWwNxbFizp9AS7lxD+7qHsEPasP29P3rbQTvDw", 9 | "publicKey": "rnXv4wh/fpRm6rEw+yX6wYfjRg7wU5lLpk1jwFrLJsg", 10 | "type": "ed25519", 11 | "signedPropertyNames": ["subplebbitAddress", "author", "timestamp", "vote", "commentCid"] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/exclude/rate-limiter.d.ts: -------------------------------------------------------------------------------- 1 | import type { DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor } from "../../../../../pubsub-messages/types.js"; 2 | import type { ChallengeResult, Exclude, SubplebbitSettings } from "../../../../../subplebbit/types.js"; 3 | declare const testRateLimit: (exclude: Exclude, request: DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor) => boolean; 4 | declare const addToRateLimiter: (subplebbitChallenges: NonNullable, request: DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, challengeSuccess: ChallengeResult["success"]) => void; 5 | export { addToRateLimiter, testRateLimit }; 6 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/exclude/rate-limiter.d.ts: -------------------------------------------------------------------------------- 1 | import type { DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor } from "../../../../../pubsub-messages/types.js"; 2 | import type { ChallengeResult, Exclude, SubplebbitSettings } from "../../../../../subplebbit/types.js"; 3 | declare const testRateLimit: (exclude: Exclude, request: DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor) => boolean; 4 | declare const addToRateLimiter: (subplebbitChallenges: NonNullable, request: DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, challengeSuccess: ChallengeResult["success"]) => void; 5 | export { addToRateLimiter, testRateLimit }; 6 | -------------------------------------------------------------------------------- /src/clients/rpc-client/types.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { 3 | RpcAuthorAddressParamSchema, 4 | RpcCidParamSchema, 5 | RpcCommentRepliesPageParamSchema, 6 | RpcSubplebbitAddressParamSchema, 7 | RpcSubplebbitPageParamSchema 8 | } from "./schema"; 9 | 10 | export type CidRpcParam = z.infer; 11 | export type SubplebbitAddressRpcParam = z.infer; 12 | export type AuthorAddressRpcParam = z.infer; 13 | export type CommentPageRpcParam = z.infer; 14 | export type SubplebbitPageRpcParam = z.infer; 15 | -------------------------------------------------------------------------------- /src/zod-error-map.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | 3 | const defaultLocaleError = z.locales.en().localeError; 4 | 5 | type IssueWithPath = { 6 | message?: string; 7 | path?: (string | number | symbol)[]; 8 | }; 9 | 10 | const friendlyErrorMap = (rawIssue: IssueWithPath) => { 11 | const pathSegments = rawIssue.path ?? []; 12 | const path = pathSegments.length ? pathSegments.map((segment) => segment.toString()).join(".") : ""; 13 | const baseMessage = rawIssue.message ?? defaultLocaleError(rawIssue as never) ?? "Invalid input"; 14 | return path ? { message: `${path}: ${baseMessage}` } : { message: baseMessage }; 15 | }; 16 | 17 | z.setErrorMap(friendlyErrorMap as any); 18 | -------------------------------------------------------------------------------- /src/test/node/hanging-test/scenarios/destroy-only.scenario.ts: -------------------------------------------------------------------------------- 1 | import { createScenarioContext, defineHangingScenario } from "./hanging-test-util.js"; 2 | 3 | /** 4 | * Baseline scenario that simply exercises the Plebbit lifecycle. 5 | * The scenario itself is responsible for destroying the instance so the test 6 | * harness can measure whether anything keeps the process or worker alive. 7 | */ 8 | export default defineHangingScenario({ 9 | id: "destroy-only", 10 | description: "instantiate a Plebbit client and destroy it", 11 | run: async ({ configCode }) => { 12 | const { plebbit } = await createScenarioContext(configCode); 13 | 14 | await plebbit.destroy(); 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /dist/browser/rpc/src/lib/plebbit-js/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/rpc/src/lib/plebbit-js/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,kDAAkD;AAClD,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAE3C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAErD,MAAM,SAAS,GAAG;IACd,OAAO,EAAE,OAAO;CACnB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAa;IACtC,MAAM,CAAC,OAAO,QAAQ,KAAK,UAAU,EAAE,0CAA0C,QAAQ,kBAAkB,CAAC,CAAC;IAC7G,SAAS,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC7B,GAAG,CAAC,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC5B,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC;IAC5B,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAC5B,CAAC;AAED,eAAe,SAAS,CAAC"} -------------------------------------------------------------------------------- /dist/node/rpc/src/lib/plebbit-js/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/rpc/src/lib/plebbit-js/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,kDAAkD;AAClD,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAE3C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAErD,MAAM,SAAS,GAAG;IACd,OAAO,EAAE,OAAO;CACnB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAa;IACtC,MAAM,CAAC,OAAO,QAAQ,KAAK,UAAU,EAAE,0CAA0C,QAAQ,kBAAkB,CAAC,CAAC;IAC7G,SAAS,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC7B,GAAG,CAAC,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC5B,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC;IAC5B,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAC5B,CAAC;AAED,eAAe,SAAS,CAAC"} -------------------------------------------------------------------------------- /dist/node/stats.d.ts: -------------------------------------------------------------------------------- 1 | import { ChainTicker } from "./types.js"; 2 | type StatTypes = "ipns" | "ipfs" | "pubsub-publish" | "pubsub-subscribe" | ChainTicker; 3 | export default class Stats { 4 | private _plebbit; 5 | constructor(plebbit: Stats["_plebbit"]); 6 | toJSON(): undefined; 7 | private _getSuccessCountKey; 8 | private _getSuccessAverageKey; 9 | recordGatewaySuccess(gatewayUrl: string, type: StatTypes, timeElapsedMs: number): Promise; 10 | private _getBaseKey; 11 | private _getFailuresCountKey; 12 | recordGatewayFailure(gatewayUrl: string, type: StatTypes): Promise; 13 | private _gatewayScore; 14 | sortGatewaysAccordingToScore(type: StatTypes): Promise; 15 | } 16 | export {}; 17 | -------------------------------------------------------------------------------- /dist/browser/stats.d.ts: -------------------------------------------------------------------------------- 1 | import { ChainTicker } from "./types.js"; 2 | type StatTypes = "ipns" | "ipfs" | "pubsub-publish" | "pubsub-subscribe" | ChainTicker; 3 | export default class Stats { 4 | private _plebbit; 5 | constructor(plebbit: Stats["_plebbit"]); 6 | toJSON(): undefined; 7 | private _getSuccessCountKey; 8 | private _getSuccessAverageKey; 9 | recordGatewaySuccess(gatewayUrl: string, type: StatTypes, timeElapsedMs: number): Promise; 10 | private _getBaseKey; 11 | private _getFailuresCountKey; 12 | recordGatewayFailure(gatewayUrl: string, type: StatTypes): Promise; 13 | private _gatewayScore; 14 | sortGatewaysAccordingToScore(type: StatTypes): Promise; 15 | } 16 | export {}; 17 | -------------------------------------------------------------------------------- /dist/node/zod-error-map.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"zod-error-map.js","sourceRoot":"","sources":["../../src/zod-error-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,kBAAkB,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC;AAOtD,MAAM,gBAAgB,GAAG,CAAC,QAAuB,EAAE,EAAE;IACjD,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACpG,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,IAAI,kBAAkB,CAAC,QAAiB,CAAC,IAAI,eAAe,CAAC;IACjG,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,KAAK,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACpF,CAAC,CAAC;AAEF,CAAC,CAAC,WAAW,CAAC,gBAAuB,CAAC,CAAC"} -------------------------------------------------------------------------------- /dist/browser/zod-error-map.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"zod-error-map.js","sourceRoot":"","sources":["../../src/zod-error-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,kBAAkB,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC;AAOtD,MAAM,gBAAgB,GAAG,CAAC,QAAuB,EAAE,EAAE;IACjD,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACpG,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,IAAI,kBAAkB,CAAC,QAAiB,CAAC,IAAI,eAAe,CAAC;IACjG,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,KAAK,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACpF,CAAC,CAAC;AAEF,CAAC,CAAC,WAAW,CAAC,gBAAuB,CAAC,CAAC"} -------------------------------------------------------------------------------- /src/rpc/test/test-server/index.js: -------------------------------------------------------------------------------- 1 | const PlebbitRpc = require("../../dist/index"); 2 | const { port } = require("./config"); 3 | 4 | // set mock plebbit-js for tests 5 | const { default: PlebbitJsMock } = require("../../dist/lib/plebbit-js/plebbit-js-mock"); 6 | PlebbitRpc.setPlebbitJs(PlebbitJsMock); 7 | (async () => { 8 | const plebbitWebSocketServer = await PlebbitRpc.PlebbitWsServer({ port }); 9 | 10 | // debug raw JSON RPC messages in console (optional) 11 | plebbitWebSocketServer.ws.on("connection", (socket, request) => { 12 | console.log("connection"); 13 | socket.on("message", (message) => console.log(message.toString())); 14 | }); 15 | 16 | console.log(`test server plebbit wss listening on port ${port}`); 17 | })(); 18 | -------------------------------------------------------------------------------- /dist/node/runtime/node/polyfill.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../../../src/runtime/node/polyfill.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,qBAAqB;AAErB,8BAA8B;AAC9B,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAE7C,sDAAsD;AACtD,OAAO,0BAA0B,CAAC;AAElC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IACpD,wEAAwE;IACxE,yFAAyF;IACzF,MAAM,GAAG,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAC1C,GAAG,CAAC,qCAAqC,CAAC,CAAC;IAC3C,mBAAmB,CAAC,IAAI,KAAK,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,IAAI,OAAQ,UAAsC,CAAC,SAAS,KAAK,WAAW,EAAE,CAAC;IAC3E,OAAO,CAAC,GAAG,CAAC,UAAoB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;AAC9D,CAAC;AAED,6DAA6D;AAC7D,eAAe,GAAG,EAAE,GAAE,CAAC,CAAC"} -------------------------------------------------------------------------------- /dist/browser/runtime/node/polyfill.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../../../src/runtime/browser/polyfill.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,qBAAqB;AAErB,8BAA8B;AAC9B,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAE7C,sDAAsD;AACtD,OAAO,0BAA0B,CAAC;AAElC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IACpD,wEAAwE;IACxE,yFAAyF;IACzF,MAAM,GAAG,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAC1C,GAAG,CAAC,qCAAqC,CAAC,CAAC;IAC3C,mBAAmB,CAAC,IAAI,KAAK,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,IAAI,OAAQ,UAAsC,CAAC,SAAS,KAAK,WAAW,EAAE,CAAC;IAC3E,OAAO,CAAC,GAAG,CAAC,UAAoB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;AAC9D,CAAC;AAED,6DAA6D;AAC7D,eAAe,GAAG,EAAE,GAAE,CAAC,CAAC"} -------------------------------------------------------------------------------- /test/vitest-browser-setup.js: -------------------------------------------------------------------------------- 1 | // Setup file for Vitest browser tests 2 | // Add Mocha-style aliases that some tests use 3 | globalThis.before = globalThis.beforeAll; 4 | globalThis.after = globalThis.afterAll; 5 | 6 | const debugNamespaces = typeof process !== "undefined" ? process?.env?.DEBUG : undefined; 7 | if (typeof window !== "undefined" && window.localStorage && debugNamespaces) { 8 | try { 9 | const previousDebug = window.localStorage.getItem("debug"); 10 | window.localStorage.setItem("debug", previousDebug ? `${previousDebug},${debugNamespaces}` : debugNamespaces); 11 | } catch (error) { 12 | console.warn("Failed to set debug namespaces for browser tests", error); 13 | } 14 | } 15 | 16 | console.log("Vitest browser setup - PLEBBIT_CONFIGS:", globalThis.PLEBBIT_CONFIGS); 17 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/fail.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"fail.js","sourceRoot":"","sources":["../../../../../../../src/runtime/node/subplebbit/challenges/plebbit-js-challenges/fail.ts"],"names":[],"mappings":"AAAA,mHAAmH;AAUnH,MAAM,YAAY,GAAoD;IAClE;QACI,MAAM,EAAE,OAAO;QACf,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,gCAAgC;QACzC,WAAW,EAAE,qCAAqC;QAClD,WAAW,EAAE,gCAAgC;KAChD;CACJ,CAAC;AAEF,MAAM,IAAI,GAA2B,YAAY,CAAC;AAElD,MAAM,WAAW,GAAG,mEAAmE,CAAC;AAExF,MAAM,YAAY,GAAG,KAAK,EACtB,2BAAuD,EACvD,uBAAiF,EACjF,cAAsB,EACO,EAAE;IAC/B,sDAAsD;IACtD,MAAM,KAAK,GAAG,2BAA2B,EAAE,OAAO,EAAE,KAAK,CAAC;IAE1D,iEAAiE;IACjE,OAAO;QACH,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,KAAK,IAAI,gCAAgC;KACnD,CAAC;AACN,CAAC,CAAC;AAEF,SAAS,oBAAoB,CAAC,2BAAuD;IACjF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAC7D,CAAC;AAED,eAAe,oBAAoB,CAAC"} -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/fail.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"fail.js","sourceRoot":"","sources":["../../../../../../../src/runtime/browser/subplebbit/challenges/plebbit-js-challenges/fail.ts"],"names":[],"mappings":"AAAA,mHAAmH;AAUnH,MAAM,YAAY,GAAoD;IAClE;QACI,MAAM,EAAE,OAAO;QACf,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,gCAAgC;QACzC,WAAW,EAAE,qCAAqC;QAClD,WAAW,EAAE,gCAAgC;KAChD;CACJ,CAAC;AAEF,MAAM,IAAI,GAA2B,YAAY,CAAC;AAElD,MAAM,WAAW,GAAG,mEAAmE,CAAC;AAExF,MAAM,YAAY,GAAG,KAAK,EACtB,2BAAuD,EACvD,uBAAiF,EACjF,cAAsB,EACO,EAAE;IAC/B,sDAAsD;IACtD,MAAM,KAAK,GAAG,2BAA2B,EAAE,OAAO,EAAE,KAAK,CAAC;IAE1D,iEAAiE;IACjE,OAAO;QACH,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,KAAK,IAAI,gCAAgC;KACnD,CAAC;AACN,CAAC,CAAC;AAEF,SAAS,oBAAoB,CAAC,2BAAuD;IACjF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAC7D,CAAC;AAED,eAAe,oBAAoB,CAAC"} -------------------------------------------------------------------------------- /dist/node/rpc/src/json-rpc-util.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"json-rpc-util.js","sourceRoot":"","sources":["../../../../src/rpc/src/json-rpc-util.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,6BAA6B,CAAC,KAAa,EAAE,MAAW;IACpE,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IAE9E,MAAM,eAAe,GAAwB,EAAE,GAAG,MAAM,EAAE,CAAC;IAC3D,IAAI,OAAO,IAAI,eAAe;QAAE,OAAO,eAAe,CAAC,KAAK,CAAC;IAE7D,IAAI,SAAS,IAAI,eAAe,IAAI,eAAe,CAAC,OAAO,IAAI,OAAO,eAAe,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzG,MAAM,OAAO,GAAG,EAAE,GAAG,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;QAClC,IAAI,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACjD,OAAO,CAAC,KAAK,GAAG,EAAE,GAAG,WAAW,EAAE,CAAC;YACnC,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK;gBAAE,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;QAC7D,CAAC;QACD,eAAe,CAAC,OAAO,GAAG,OAAO,CAAC;IACtC,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC"} -------------------------------------------------------------------------------- /test/fixtures/signatures/commentEdit/valid_comment_edit.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": { "address": "12D3KooWMZPQsQdYtrakc4D1XtzGXwN1X3DBnAobcCjcPYYXTB6o" }, 3 | "subplebbitAddress": "12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR", 4 | "protocolVersion": "1.0.0", 5 | "timestamp": 1737116685, 6 | "commentCid": "QmbKFFGL9EMwdMVrkJUqz2yQAorzUBExchK1qogsU8BJ7e", 7 | "content": "Just so", 8 | "reason": "New comment edit", 9 | "signature": { 10 | "signature": "bfGMCrfT1OWElsSn+SdXgdOVr3fpuwsdiZMGXM8PmVWgLvRXCs40ZlLgk62+Xqa33wmgRzysUFaEDWI+MMe3AQ", 11 | "publicKey": "rnXv4wh/fpRm6rEw+yX6wYfjRg7wU5lLpk1jwFrLJsg", 12 | "type": "ed25519", 13 | "signedPropertyNames": ["author", "subplebbitAddress", "protocolVersion", "timestamp", "commentCid", "content", "reason"] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /dist/browser/rpc/src/json-rpc-util.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"json-rpc-util.js","sourceRoot":"","sources":["../../../../src/rpc/src/json-rpc-util.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,6BAA6B,CAAC,KAAa,EAAE,MAAW;IACpE,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IAE9E,MAAM,eAAe,GAAwB,EAAE,GAAG,MAAM,EAAE,CAAC;IAC3D,IAAI,OAAO,IAAI,eAAe;QAAE,OAAO,eAAe,CAAC,KAAK,CAAC;IAE7D,IAAI,SAAS,IAAI,eAAe,IAAI,eAAe,CAAC,OAAO,IAAI,OAAO,eAAe,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzG,MAAM,OAAO,GAAG,EAAE,GAAG,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;QAClC,IAAI,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACjD,OAAO,CAAC,KAAK,GAAG,EAAE,GAAG,WAAW,EAAE,CAAC;YACnC,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK;gBAAE,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;QAC7D,CAAC;QACD,eAAe,CAAC,OAAO,GAAG,OAAO,CAAC;IACtC,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC"} -------------------------------------------------------------------------------- /src/clients/rpc-client/rpc-schema-util.ts: -------------------------------------------------------------------------------- 1 | import { 2 | RpcAuthorAddressParamSchema, 3 | RpcCidParamSchema, 4 | RpcCommentRepliesPageParamSchema, 5 | RpcSubplebbitAddressParamSchema, 6 | RpcSubplebbitPageParamSchema 7 | } from "./schema.js"; 8 | 9 | export const parseRpcCidParam = (params: unknown) => RpcCidParamSchema.loose().parse(params); 10 | export const parseRpcSubplebbitAddressParam = (params: unknown) => RpcSubplebbitAddressParamSchema.loose().parse(params); 11 | export const parseRpcAuthorAddressParam = (params: unknown) => RpcAuthorAddressParamSchema.loose().parse(params); 12 | export const parseRpcSubplebbitPageParam = (params: unknown) => RpcSubplebbitPageParamSchema.loose().parse(params); 13 | export const parseRpcCommentRepliesPageParam = (params: unknown) => RpcCommentRepliesPageParamSchema.loose().parse(params); 14 | -------------------------------------------------------------------------------- /dist/node/helia/libp2pjsClient.js: -------------------------------------------------------------------------------- 1 | import { hideClassPrivateProps } from "../util.js"; 2 | export class Libp2pJsClient { 3 | constructor(libp2pJsClientOptions) { 4 | this._helia = libp2pJsClientOptions.helia; 5 | this._heliaUnixfs = libp2pJsClientOptions.heliaUnixfs; 6 | this._heliaIpnsRouter = libp2pJsClientOptions.heliaIpnsRouter; 7 | this.heliaWithKuboRpcClientFunctions = libp2pJsClientOptions.heliaWithKuboRpcClientFunctions; 8 | this._libp2pJsClientsOptions = libp2pJsClientOptions.libp2pJsClientsOptions; 9 | this._mergedHeliaOptions = libp2pJsClientOptions.mergedHeliaOptions; 10 | this.key = libp2pJsClientOptions.key; 11 | this.countOfUsesOfInstance = libp2pJsClientOptions.countOfUsesOfInstance; 12 | hideClassPrivateProps(this); 13 | } 14 | } 15 | //# sourceMappingURL=libp2pjsClient.js.map -------------------------------------------------------------------------------- /src/rpc/src/json-rpc-util.ts: -------------------------------------------------------------------------------- 1 | export function sanitizeRpcNotificationResult(event: string, result: any) { 2 | if (event !== "error" || !result || typeof result !== "object") return result; 3 | 4 | const sanitizedResult: Record = { ...result }; 5 | if ("stack" in sanitizedResult) delete sanitizedResult.stack; 6 | 7 | if ("details" in sanitizedResult && sanitizedResult.details && typeof sanitizedResult.details === "object") { 8 | const details = { ...sanitizedResult.details }; 9 | const nestedError = details.error; 10 | if (nestedError && typeof nestedError === "object") { 11 | details.error = { ...nestedError }; 12 | if ("stack" in details.error) delete details.error.stack; 13 | } 14 | sanitizedResult.details = details; 15 | } 16 | 17 | return sanitizedResult; 18 | } 19 | -------------------------------------------------------------------------------- /dist/browser/helia/libp2pjsClient.js: -------------------------------------------------------------------------------- 1 | import { hideClassPrivateProps } from "../util.js"; 2 | export class Libp2pJsClient { 3 | constructor(libp2pJsClientOptions) { 4 | this._helia = libp2pJsClientOptions.helia; 5 | this._heliaUnixfs = libp2pJsClientOptions.heliaUnixfs; 6 | this._heliaIpnsRouter = libp2pJsClientOptions.heliaIpnsRouter; 7 | this.heliaWithKuboRpcClientFunctions = libp2pJsClientOptions.heliaWithKuboRpcClientFunctions; 8 | this._libp2pJsClientsOptions = libp2pJsClientOptions.libp2pJsClientsOptions; 9 | this._mergedHeliaOptions = libp2pJsClientOptions.mergedHeliaOptions; 10 | this.key = libp2pJsClientOptions.key; 11 | this.countOfUsesOfInstance = libp2pJsClientOptions.countOfUsesOfInstance; 12 | hideClassPrivateProps(this); 13 | } 14 | } 15 | //# sourceMappingURL=libp2pjsClient.js.map -------------------------------------------------------------------------------- /dist/node/domain-resolver.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChainTicker } from "./types.js"; 2 | import { createPublicClient as createViemClient } from "viem"; 3 | import { Plebbit } from "./plebbit/plebbit.js"; 4 | export declare class DomainResolver { 5 | private _plebbit; 6 | _viemClients: Record>; 7 | private _solanaConnections; 8 | private _ethersClients; 9 | constructor(plebbit: Plebbit); 10 | destroy(): Promise; 11 | _createViemClientIfNeeded(chainTicker: ChainTicker, chainProviderUrl: string): DomainResolver["_viemClients"][string]; 12 | private _resolveViaViem; 13 | private _resolveViaSolana; 14 | private _resolveViaEthers; 15 | resolveTxtRecord(address: string, txtRecordName: string, chain: ChainTicker, chainProviderUrl: string, chainId: number | undefined): Promise; 16 | } 17 | -------------------------------------------------------------------------------- /dist/browser/domain-resolver.d.ts: -------------------------------------------------------------------------------- 1 | import type { ChainTicker } from "./types.js"; 2 | import { createPublicClient as createViemClient } from "viem"; 3 | import { Plebbit } from "./plebbit/plebbit.js"; 4 | export declare class DomainResolver { 5 | private _plebbit; 6 | _viemClients: Record>; 7 | private _solanaConnections; 8 | private _ethersClients; 9 | constructor(plebbit: Plebbit); 10 | destroy(): Promise; 11 | _createViemClientIfNeeded(chainTicker: ChainTicker, chainProviderUrl: string): DomainResolver["_viemClients"][string]; 12 | private _resolveViaViem; 13 | private _resolveViaSolana; 14 | private _resolveViaEthers; 15 | resolveTxtRecord(address: string, txtRecordName: string, chain: ChainTicker, chainProviderUrl: string, chainId: number | undefined): Promise; 16 | } 17 | -------------------------------------------------------------------------------- /dist/browser/rpc/src/json-rpc-util.js: -------------------------------------------------------------------------------- 1 | export function sanitizeRpcNotificationResult(event, result) { 2 | if (event !== "error" || !result || typeof result !== "object") 3 | return result; 4 | const sanitizedResult = { ...result }; 5 | if ("stack" in sanitizedResult) 6 | delete sanitizedResult.stack; 7 | if ("details" in sanitizedResult && sanitizedResult.details && typeof sanitizedResult.details === "object") { 8 | const details = { ...sanitizedResult.details }; 9 | const nestedError = details.error; 10 | if (nestedError && typeof nestedError === "object") { 11 | details.error = { ...nestedError }; 12 | if ("stack" in details.error) 13 | delete details.error.stack; 14 | } 15 | sanitizedResult.details = details; 16 | } 17 | return sanitizedResult; 18 | } 19 | //# sourceMappingURL=json-rpc-util.js.map -------------------------------------------------------------------------------- /dist/node/rpc/src/json-rpc-util.js: -------------------------------------------------------------------------------- 1 | export function sanitizeRpcNotificationResult(event, result) { 2 | if (event !== "error" || !result || typeof result !== "object") 3 | return result; 4 | const sanitizedResult = { ...result }; 5 | if ("stack" in sanitizedResult) 6 | delete sanitizedResult.stack; 7 | if ("details" in sanitizedResult && sanitizedResult.details && typeof sanitizedResult.details === "object") { 8 | const details = { ...sanitizedResult.details }; 9 | const nestedError = details.error; 10 | if (nestedError && typeof nestedError === "object") { 11 | details.error = { ...nestedError }; 12 | if ("stack" in details.error) 13 | delete details.error.stack; 14 | } 15 | sanitizedResult.details = details; 16 | } 17 | return sanitizedResult; 18 | } 19 | //# sourceMappingURL=json-rpc-util.js.map -------------------------------------------------------------------------------- /.github/workflows/CI-windows-test.yml: -------------------------------------------------------------------------------- 1 | # CI for testing node tests on Windows 2 | name: CI windows 3 | 4 | on: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | test-plebbit-node-windows: 9 | runs-on: windows-latest 10 | timeout-minutes: 20 11 | defaults: 12 | run: 13 | shell: bash 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: actions/setup-node@v3 17 | with: 18 | node-version: 20 19 | cache: "npm" 20 | 21 | # Setup plebbit-js deps 22 | - run: npm ci 23 | - run: npm run build 24 | - run: DEBUG="plebbit*" npm run test:server:node & npm run test:server:wait-on 25 | - run: DEBUG="plebbit*, -plebbit*trace" npm run test:node:parallel:local 26 | - run: DEBUG="plebbit*, -plebbit*trace" npm run test:node:parallel:remote 27 | -------------------------------------------------------------------------------- /src/helia/types.ts: -------------------------------------------------------------------------------- 1 | import type { createHelia } from "helia"; 2 | import type { KuboRpcClient } from "../types.js"; 3 | import type { PubsubRoutingComponents } from "@helia/ipns/routing"; 4 | 5 | export interface HeliaWithKuboRpcClientFunctions extends Pick, "add" | "cat" | "pubsub" | "stop"> { 6 | add: KuboRpcClient["_client"]["add"]; 7 | name: Pick; 8 | cat: KuboRpcClient["_client"]["cat"]; 9 | pubsub: KuboRpcClient["_client"]["pubsub"]; 10 | stop: KuboRpcClient["_client"]["stop"]; 11 | } 12 | 13 | type baseHelia = Awaited>; 14 | 15 | export interface HeliaWithLibp2pPubsub extends baseHelia { 16 | libp2p: baseHelia["libp2p"] & { 17 | services: baseHelia["libp2p"]["services"] & { 18 | pubsub: PubsubRoutingComponents["libp2p"]["services"]["pubsub"]; 19 | }; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /dist/browser/helia/types.d.ts: -------------------------------------------------------------------------------- 1 | import type { createHelia } from "helia"; 2 | import type { KuboRpcClient } from "../types.js"; 3 | import type { PubsubRoutingComponents } from "@helia/ipns/routing"; 4 | export interface HeliaWithKuboRpcClientFunctions extends Pick, "add" | "cat" | "pubsub" | "stop"> { 5 | add: KuboRpcClient["_client"]["add"]; 6 | name: Pick; 7 | cat: KuboRpcClient["_client"]["cat"]; 8 | pubsub: KuboRpcClient["_client"]["pubsub"]; 9 | stop: KuboRpcClient["_client"]["stop"]; 10 | } 11 | type baseHelia = Awaited>; 12 | export interface HeliaWithLibp2pPubsub extends baseHelia { 13 | libp2p: baseHelia["libp2p"] & { 14 | services: baseHelia["libp2p"]["services"] & { 15 | pubsub: PubsubRoutingComponents["libp2p"]["services"]["pubsub"]; 16 | }; 17 | }; 18 | } 19 | export {}; 20 | -------------------------------------------------------------------------------- /dist/node/helia/types.d.ts: -------------------------------------------------------------------------------- 1 | import type { createHelia } from "helia"; 2 | import type { KuboRpcClient } from "../types.js"; 3 | import type { PubsubRoutingComponents } from "@helia/ipns/routing"; 4 | export interface HeliaWithKuboRpcClientFunctions extends Pick, "add" | "cat" | "pubsub" | "stop"> { 5 | add: KuboRpcClient["_client"]["add"]; 6 | name: Pick; 7 | cat: KuboRpcClient["_client"]["cat"]; 8 | pubsub: KuboRpcClient["_client"]["pubsub"]; 9 | stop: KuboRpcClient["_client"]["stop"]; 10 | } 11 | type baseHelia = Awaited>; 12 | export interface HeliaWithLibp2pPubsub extends baseHelia { 13 | libp2p: baseHelia["libp2p"] & { 14 | services: baseHelia["libp2p"]["services"] & { 15 | pubsub: PubsubRoutingComponents["libp2p"]["services"]["pubsub"]; 16 | }; 17 | }; 18 | } 19 | export {}; 20 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/util.d.ts: -------------------------------------------------------------------------------- 1 | import type { KuboRpcClient, NativeFunctions } from "../../types.js"; 2 | export declare const getDefaultDataPath: () => undefined; 3 | export declare const mkdir: () => never; 4 | export declare const listSubplebbits: () => never; 5 | export declare const listSubplebbitsSync: () => never; 6 | export declare const monitorSubplebbitsDirectory: () => never; 7 | export declare const trytoDeleteSubsThatFailedToBeDeletedBefore: () => never; 8 | export declare function importSignerIntoKuboNode(ipnsKeyName: string, ipfsKey: Uint8Array, ipfsNode: KuboRpcClient["_clientOptions"]): Promise<{ 9 | id: string; 10 | name: string; 11 | }>; 12 | export declare function createKuboRpcClient(kuboRpcClientOptions: KuboRpcClient["_clientOptions"]): KuboRpcClient["_client"]; 13 | export declare const nativeFunctions: NativeFunctions; 14 | export declare const setNativeFunctions: (newNativeFunctions: Partial) => void; 15 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/util.d.ts: -------------------------------------------------------------------------------- 1 | import type { KuboRpcClient, NativeFunctions } from "../../types.js"; 2 | export declare const getDefaultDataPath: () => undefined; 3 | export declare const mkdir: () => never; 4 | export declare const listSubplebbits: () => never; 5 | export declare const listSubplebbitsSync: () => never; 6 | export declare const monitorSubplebbitsDirectory: () => never; 7 | export declare const trytoDeleteSubsThatFailedToBeDeletedBefore: () => never; 8 | export declare function importSignerIntoKuboNode(ipnsKeyName: string, ipfsKey: Uint8Array, ipfsNode: KuboRpcClient["_clientOptions"]): Promise<{ 9 | id: string; 10 | name: string; 11 | }>; 12 | export declare function createKuboRpcClient(kuboRpcClientOptions: KuboRpcClient["_clientOptions"]): KuboRpcClient["_client"]; 13 | export declare const nativeFunctions: NativeFunctions; 14 | export declare const setNativeFunctions: (newNativeFunctions: Partial) => void; 15 | -------------------------------------------------------------------------------- /dist/browser/signer/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { SignerType } from "./types.js"; 2 | export { verifyCommentIpfs, verifyCommentPubsubMessage, verifySubplebbit, verifyVote } from "./signatures.js"; 3 | export { encryptEd25519AesGcm, decryptEd25519AesGcm, decryptEd25519AesGcmPublicKeyBuffer } from "./encryption.js"; 4 | import { CreateSignerOptions } from "./types.js"; 5 | export declare class Signer implements SignerType { 6 | type: "ed25519"; 7 | privateKey: string; 8 | publicKey?: string; 9 | address: string; 10 | shortAddress: string; 11 | ipfsKey?: Uint8Array; 12 | ipnsKeyName?: string; 13 | constructor(props: SignerType); 14 | } 15 | export declare class SignerWithPublicKeyAddress extends Signer { 16 | publicKey: string; 17 | constructor(props: SignerType & { 18 | publicKey: string; 19 | }); 20 | } 21 | export declare const createSigner: (createSignerOptions?: CreateSignerOptions) => Promise; 22 | -------------------------------------------------------------------------------- /dist/node/signer/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { SignerType } from "./types.js"; 2 | export { verifyCommentIpfs, verifyCommentPubsubMessage, verifySubplebbit, verifyVote } from "./signatures.js"; 3 | export { encryptEd25519AesGcm, decryptEd25519AesGcm, decryptEd25519AesGcmPublicKeyBuffer } from "./encryption.js"; 4 | import { CreateSignerOptions } from "./types.js"; 5 | export declare class Signer implements SignerType { 6 | type: "ed25519"; 7 | privateKey: string; 8 | publicKey?: string; 9 | address: string; 10 | shortAddress: string; 11 | ipfsKey?: Uint8Array; 12 | ipnsKeyName?: string; 13 | constructor(props: SignerType); 14 | } 15 | export declare class SignerWithPublicKeyAddress extends Signer { 16 | publicKey: string; 17 | constructor(props: SignerType & { 18 | publicKey: string; 19 | }); 20 | } 21 | export declare const createSigner: (createSignerOptions?: CreateSignerOptions) => Promise; 22 | -------------------------------------------------------------------------------- /.github/workflows/CI-alerts.yml: -------------------------------------------------------------------------------- 1 | # send alerts on failed CI 2 | name: CI alerts 3 | 4 | on: 5 | workflow_run: 6 | workflows: 7 | - 'CI' 8 | types: 9 | - 'completed' 10 | 11 | jobs: 12 | on-failure: 13 | runs-on: ubuntu-latest 14 | if: ${{ github.event.workflow_run.conclusion == 'failure' }} 15 | steps: 16 | # @plebbitjs telegram chat id is -1001792656766 17 | - name: "@plebbitjs telegram alert" 18 | uses: appleboy/telegram-action@master 19 | with: 20 | to: ${{ secrets.TELEGRAM_TO }} 21 | token: ${{ secrets.TELEGRAM_TOKEN }} 22 | message: | 23 | ${{ github.event.workflow_run.name }} ${{ github.event.workflow_run.conclusion }} ${{ github.event.workflow_run.html_url }} 24 | 25 | ${{ github.event.workflow_run.head_repository.full_name }} ${{ github.event.workflow_run.head_branch }} 26 | ${{ github.event.workflow_run.head_commit.author.name }} 27 | ${{ github.event.workflow_run.head_commit.message }} 28 | -------------------------------------------------------------------------------- /dist/node/runtime/node/address-rewriter-db.d.ts: -------------------------------------------------------------------------------- 1 | export type RequestLogEntry = { 2 | keys: string[]; 3 | receivedAt: number; 4 | transmittedAt?: number; 5 | success: boolean; 6 | statusCode?: number; 7 | method: string; 8 | url: string; 9 | error?: string; 10 | retryCount?: number; 11 | }; 12 | export type ReprovideLogEntry = { 13 | key: string; 14 | timestamp: number; 15 | success: boolean; 16 | error?: string; 17 | blockNotLocal?: boolean; 18 | }; 19 | export declare class AddressRewriterDatabase { 20 | private _db; 21 | private _dbPath; 22 | constructor(dataPath: string, kuboConfig: any, proxyTarget: URL); 23 | private _initializeDbPath; 24 | initialize(): Promise; 25 | close(): void; 26 | insertRequestLogs(logs: RequestLogEntry[]): void; 27 | insertReprovideLog(key: string, success: boolean, error?: string, blockNotLocal?: boolean): void; 28 | loadFailedKeys(): string[]; 29 | saveFailedKeys(keys: string[]): void; 30 | } 31 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/address-rewriter-db.d.ts: -------------------------------------------------------------------------------- 1 | export type RequestLogEntry = { 2 | keys: string[]; 3 | receivedAt: number; 4 | transmittedAt?: number; 5 | success: boolean; 6 | statusCode?: number; 7 | method: string; 8 | url: string; 9 | error?: string; 10 | retryCount?: number; 11 | }; 12 | export type ReprovideLogEntry = { 13 | key: string; 14 | timestamp: number; 15 | success: boolean; 16 | error?: string; 17 | blockNotLocal?: boolean; 18 | }; 19 | export declare class AddressRewriterDatabase { 20 | private _db; 21 | private _dbPath; 22 | constructor(dataPath: string, kuboConfig: any, proxyTarget: URL); 23 | private _initializeDbPath; 24 | initialize(): Promise; 25 | close(): void; 26 | insertRequestLogs(logs: RequestLogEntry[]): void; 27 | insertReprovideLog(key: string, success: boolean, error?: string, blockNotLocal?: boolean): void; 28 | loadFailedKeys(): string[]; 29 | saveFailedKeys(keys: string[]): void; 30 | } 31 | -------------------------------------------------------------------------------- /src/test/node/hanging-test/scenarios/comment-publish.scenario.ts: -------------------------------------------------------------------------------- 1 | import { publishRandomPost } from "../../../test-util.js"; 2 | import { createScenarioContext, defineHangingScenario } from "./hanging-test-util.js"; 3 | 4 | /** 5 | * Template scenario showing the shape expected by the hanging test harness. 6 | * Replace the placeholder steps with the flow you want to exercise before 7 | * checking for lingering resources. Make sure any asynchronous work is awaited 8 | * so the destroy call can flush everything properly. 9 | */ 10 | export default defineHangingScenario({ 11 | id: "comment-publish", 12 | description: "Finish publishing a comment and destroy plebbit", 13 | run: async ({ configCode }) => { 14 | const subplebbitAddress = "12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR"; 15 | const { plebbit, config } = await createScenarioContext(configCode); 16 | 17 | const post = await publishRandomPost(subplebbitAddress, plebbit); 18 | 19 | await plebbit.destroy(); 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /dist/browser/rpc/src/types.d.ts: -------------------------------------------------------------------------------- 1 | import type { PlebbitError } from "../../plebbit-error.js"; 2 | import type { Plebbit } from "../../plebbit/plebbit.js"; 3 | import { CreatePlebbitWsServerOptionsSchema, SetNewSettingsPlebbitWsServerSchema, PlebbitWsServerSettingsSerializedSchema } from "./schema.js"; 4 | import { z } from "zod"; 5 | export type CreatePlebbitWsServerOptions = z.infer; 6 | export interface PlebbitWsServerClassOptions extends CreatePlebbitWsServerOptions { 7 | plebbit: Plebbit; 8 | } 9 | export type SetNewSettingsPlebbitWsServer = z.infer; 10 | export type PlebbitWsServerSettingsSerialized = z.infer; 11 | export type JsonRpcSendNotificationOptions = { 12 | method: string; 13 | result: any; 14 | subscription: number; 15 | event: string; 16 | connectionId: string; 17 | }; 18 | export type PlebbitRpcServerEvents = { 19 | error: (error: PlebbitError | Error) => void; 20 | }; 21 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/lru-storage.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"lru-storage.js","sourceRoot":"","sources":["../../../../src/runtime/browser/lru-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,kDAAkD;AAElD,MAAM,CAAC,OAAO,OAAO,UAAU;IAI3B,YAAY,IAA2B;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,MAAM;QACF,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACN,IAAI,CAAC,MAAM,GAAG,oBAAoB,CAAC;YAC/B,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YAC1B,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;SAC5B,CAAC,CAAC;IACP,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAW;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,KAAU;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAW;QACxB,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,OAAO,KAAI,CAAC;CACrB"} -------------------------------------------------------------------------------- /dist/node/rpc/src/types.d.ts: -------------------------------------------------------------------------------- 1 | import type { PlebbitError } from "../../plebbit-error.js"; 2 | import type { Plebbit } from "../../plebbit/plebbit.js"; 3 | import { CreatePlebbitWsServerOptionsSchema, SetNewSettingsPlebbitWsServerSchema, PlebbitWsServerSettingsSerializedSchema } from "./schema.js"; 4 | import { z } from "zod"; 5 | export type CreatePlebbitWsServerOptions = z.infer; 6 | export interface PlebbitWsServerClassOptions extends CreatePlebbitWsServerOptions { 7 | plebbit: Plebbit; 8 | } 9 | export type SetNewSettingsPlebbitWsServer = z.infer; 10 | export type PlebbitWsServerSettingsSerialized = z.infer; 11 | export type JsonRpcSendNotificationOptions = { 12 | method: string; 13 | result: any; 14 | subscription: number; 15 | event: string; 16 | connectionId: string; 17 | }; 18 | export type PlebbitRpcServerEvents = { 19 | error: (error: PlebbitError | Error) => void; 20 | }; 21 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/lru-storage.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"lru-storage.js","sourceRoot":"","sources":["../../../../src/runtime/browser/lru-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,kDAAkD;AAElD,MAAM,CAAC,OAAO,OAAO,UAAU;IAI3B,YAAY,IAA2B;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,MAAM;QACF,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACN,IAAI,CAAC,MAAM,GAAG,oBAAoB,CAAC;YAC/B,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YAC1B,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;SAC5B,CAAC,CAAC;IACP,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAW;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,KAAU;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAW;QACxB,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,OAAO,KAAI,CAAC;CACrB"} -------------------------------------------------------------------------------- /.github/workflows/CI-build.yml: -------------------------------------------------------------------------------- 1 | # build and commit the dist folder after successful CI 2 | name: CI build 3 | 4 | on: 5 | workflow_run: 6 | workflows: 7 | - 'CI' 8 | types: 9 | - 'completed' 10 | 11 | jobs: 12 | on-success: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: write 16 | if: ${{ github.event.workflow_run.conclusion == 'success' }} 17 | steps: 18 | - uses: actions/checkout@v3 19 | - uses: actions/setup-node@v3 20 | with: 21 | node-version: 20 22 | cache: 'npm' 23 | 24 | # build dist folder 25 | - run: npm ci 26 | - run: npm run build 27 | 28 | 29 | # NOTE: doesn't work if `git add dist --force` is removed 30 | - run: git add dist --force 31 | - run: git status 32 | 33 | # commit and push dist folder 34 | - uses: stefanzweifel/git-auto-commit-action@v4 35 | with: 36 | commit_message: CI build 37 | file_pattern: dist 38 | add_options: '--force' 39 | -------------------------------------------------------------------------------- /dist/node/rpc/src/schema.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/rpc/src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAG1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,gBAAgB;AAEhB,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAA4B,CAAC,QAAQ,EAAE;CAC1D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC;KAC9C,MAAM,CAAC;IACJ,cAAc,EAAE,CAAC,CAAC,MAAM,EAAuB,CAAC,QAAQ,EAAE,EAAE,mEAAmE;IAC/H,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC;KACD,KAAK,CAAC,oBAAoB,CAAC;KAC3B,KAAK,EAAE,CAAC;AAEb,SAAS;AAET,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC,MAAM,CAAC;IACxD,cAAc,EAAE,2BAA2B,CAAC,KAAK,EAAE;CACtD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5D,cAAc,EAAE,0BAA0B,CAAC,KAAK,EAAE;IAClD,UAAU,EAAE,CAAC,CAAC,MAAM,CAChB,CAAC,CAAC,MAAM,EAAE,EACV,mBAAmB,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,oDAAoD;KACxG;CACJ,CAAC,CAAC"} -------------------------------------------------------------------------------- /dist/node/runtime/browser/lru-storage.js: -------------------------------------------------------------------------------- 1 | import { createInstance as CreateLocalForageLRU } from "./localforage-lru.js"; 2 | // Storing items that will be evicted based on LRU 3 | export default class LRUStorage { 4 | constructor(opts) { 5 | this._opts = opts; 6 | } 7 | toJSON() { 8 | return undefined; 9 | } 10 | async init() { 11 | this._cache = CreateLocalForageLRU({ 12 | name: this._opts.cacheName, 13 | size: this._opts.maxItems 14 | }); 15 | } 16 | async getItem(key) { 17 | return this._cache.getItem(key); 18 | } 19 | async setItem(key, value) { 20 | return this._cache.setItem(key, value); 21 | } 22 | async removeItem(key) { 23 | await this._cache.removeItem(key); 24 | return true; 25 | } 26 | async clear() { 27 | return this._cache.clear(); 28 | } 29 | async keys() { 30 | return this._cache.keys(); 31 | } 32 | async destroy() { } 33 | } 34 | //# sourceMappingURL=lru-storage.js.map -------------------------------------------------------------------------------- /dist/node/runtime/node/polyfill.js: -------------------------------------------------------------------------------- 1 | // import this file at the very top of index.ts to polyfill 2 | // stuff for browsers 3 | // nothing to polyfill in node 4 | import { setGlobalDispatcher, Agent, WebSocket } from "undici"; 5 | import Logger from "@plebbit/plebbit-logger"; 6 | // Add Promise.withResolvers polyfill for Node.js < 22 7 | import "@enhances/with-resolvers"; 8 | if (Number(process.versions.node.split(".")[0]) >= 18) { 9 | // We're on node 18+, we need to change the timeout of the body globally 10 | // Should be removed at some point once kubo-rpc-client fixes their problem with node 18+ 11 | const log = Logger("plebbit-js:polyfill"); 12 | log("Patching up the global body timeout"); 13 | setGlobalDispatcher(new Agent({ bodyTimeout: Number.MAX_SAFE_INTEGER })); 14 | } 15 | if (typeof globalThis.WebSocket === "undefined") { 16 | Reflect.set(globalThis, "WebSocket", WebSocket); 17 | } 18 | // must export a function and call it or this file isn't read 19 | export default () => { }; 20 | //# sourceMappingURL=polyfill.js.map -------------------------------------------------------------------------------- /dist/browser/rpc/src/schema.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/rpc/src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAG1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,gBAAgB;AAEhB,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAA4B,CAAC,QAAQ,EAAE;CAC1D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC;KAC9C,MAAM,CAAC;IACJ,cAAc,EAAE,CAAC,CAAC,MAAM,EAAuB,CAAC,QAAQ,EAAE,EAAE,mEAAmE;IAC/H,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC;KACD,KAAK,CAAC,oBAAoB,CAAC;KAC3B,KAAK,EAAE,CAAC;AAEb,SAAS;AAET,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC,MAAM,CAAC;IACxD,cAAc,EAAE,2BAA2B,CAAC,KAAK,EAAE;CACtD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5D,cAAc,EAAE,0BAA0B,CAAC,KAAK,EAAE;IAClD,UAAU,EAAE,CAAC,CAAC,MAAM,CAChB,CAAC,CAAC,MAAM,EAAE,EACV,mBAAmB,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,oDAAoD;KACxG;CACJ,CAAC,CAAC"} -------------------------------------------------------------------------------- /dist/browser/runtime/browser/lru-storage.js: -------------------------------------------------------------------------------- 1 | import { createInstance as CreateLocalForageLRU } from "./localforage-lru.js"; 2 | // Storing items that will be evicted based on LRU 3 | export default class LRUStorage { 4 | constructor(opts) { 5 | this._opts = opts; 6 | } 7 | toJSON() { 8 | return undefined; 9 | } 10 | async init() { 11 | this._cache = CreateLocalForageLRU({ 12 | name: this._opts.cacheName, 13 | size: this._opts.maxItems 14 | }); 15 | } 16 | async getItem(key) { 17 | return this._cache.getItem(key); 18 | } 19 | async setItem(key, value) { 20 | return this._cache.setItem(key, value); 21 | } 22 | async removeItem(key) { 23 | await this._cache.removeItem(key); 24 | return true; 25 | } 26 | async clear() { 27 | return this._cache.clear(); 28 | } 29 | async keys() { 30 | return this._cache.keys(); 31 | } 32 | async destroy() { } 33 | } 34 | //# sourceMappingURL=lru-storage.js.map -------------------------------------------------------------------------------- /dist/browser/runtime/node/polyfill.js: -------------------------------------------------------------------------------- 1 | // import this file at the very top of index.ts to polyfill 2 | // stuff for browsers 3 | // nothing to polyfill in node 4 | import { setGlobalDispatcher, Agent, WebSocket } from "undici"; 5 | import Logger from "@plebbit/plebbit-logger"; 6 | // Add Promise.withResolvers polyfill for Node.js < 22 7 | import "@enhances/with-resolvers"; 8 | if (Number(process.versions.node.split(".")[0]) >= 18) { 9 | // We're on node 18+, we need to change the timeout of the body globally 10 | // Should be removed at some point once kubo-rpc-client fixes their problem with node 18+ 11 | const log = Logger("plebbit-js:polyfill"); 12 | log("Patching up the global body timeout"); 13 | setGlobalDispatcher(new Agent({ bodyTimeout: Number.MAX_SAFE_INTEGER })); 14 | } 15 | if (typeof globalThis.WebSocket === "undefined") { 16 | Reflect.set(globalThis, "WebSocket", WebSocket); 17 | } 18 | // must export a function and call it or this file isn't read 19 | export default () => { }; 20 | //# sourceMappingURL=polyfill.js.map -------------------------------------------------------------------------------- /docs/cross-platform-native-functions.md: -------------------------------------------------------------------------------- 1 | # Cross platform native functions 2 | 3 | `plebbit-js` is written entirely in Javascript and can run in the browser. Some plebbit functionalities require native functions like the file system and native HTTP requests. Electron and Android WebView allow injecting native functions into the browser renderer. Example: 4 | 5 | ```javascript 6 | import Plebbit from '@plebbit/plebbit-js' 7 | 8 | const nativeFunctions = { 9 | fetch: async () => {}, 10 | listSubplebbits: async () => {}, 11 | // ...no need to override all native functions 12 | } 13 | 14 | Plebbit.setNativeFunctions(nativeFunctions) 15 | ``` 16 | 17 | # NativeFunctions API 18 | 19 | - `nativeFunctions.fetch(url: string, fetchOptions: FetchOptions)` 20 | - `nativeFunctions.listSubplebbits()` 21 | - `nativeFunctions.deleteSubplebbit(subplebbitAddress: string)` 22 | - `nativeFunctions.createIpfsClient(ipfsHttpClientOptions: IpfsHttpClientOptions)` 23 | 24 | # TODO 25 | 26 | - Define SQL native functions to be able to run a subplebbit on Android 27 | -------------------------------------------------------------------------------- /src/clients/rpc-client/schema.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { CommentIpfsSchema, CommentUpdateSchema } from "../../publications/comment/schema.js"; 3 | import { AuthorAddressSchema, CidStringSchema, SubplebbitAddressSchema } from "../../schema/schema.js"; 4 | export const SubscriptionIdSchema = z.number().positive().int(); 5 | 6 | export const RpcCommentEventResultSchema = CommentIpfsSchema.loose(); 7 | export const RpcCommentUpdateResultSchema = CommentUpdateSchema; 8 | 9 | export const RpcCidParamSchema = z.object({ cid: CidStringSchema }).loose(); 10 | export const RpcSubplebbitAddressParamSchema = z.object({ address: SubplebbitAddressSchema }); 11 | export const RpcAuthorAddressParamSchema = z.object({ address: AuthorAddressSchema }); 12 | export const RpcSubplebbitPageParamSchema = RpcCidParamSchema.extend({ 13 | subplebbitAddress: SubplebbitAddressSchema, 14 | type: z.enum(["posts", "modqueue"]) 15 | }); 16 | export const RpcCommentRepliesPageParamSchema = RpcSubplebbitPageParamSchema.omit({ type: true }).extend({ commentCid: CidStringSchema }); 17 | -------------------------------------------------------------------------------- /src/runtime/node/polyfill.ts: -------------------------------------------------------------------------------- 1 | // import this file at the very top of index.ts to polyfill 2 | // stuff for browsers 3 | 4 | // nothing to polyfill in node 5 | import { setGlobalDispatcher, Agent, WebSocket } from "undici"; 6 | import Logger from "@plebbit/plebbit-logger"; 7 | 8 | // Add Promise.withResolvers polyfill for Node.js < 22 9 | import "@enhances/with-resolvers"; 10 | 11 | if (Number(process.versions.node.split(".")[0]) >= 18) { 12 | // We're on node 18+, we need to change the timeout of the body globally 13 | // Should be removed at some point once kubo-rpc-client fixes their problem with node 18+ 14 | const log = Logger("plebbit-js:polyfill"); 15 | log("Patching up the global body timeout"); 16 | setGlobalDispatcher(new Agent({ bodyTimeout: Number.MAX_SAFE_INTEGER })); 17 | } 18 | 19 | if (typeof (globalThis as { WebSocket?: unknown }).WebSocket === "undefined") { 20 | Reflect.set(globalThis as object, "WebSocket", WebSocket); 21 | } 22 | 23 | // must export a function and call it or this file isn't read 24 | export default () => {}; 25 | -------------------------------------------------------------------------------- /src/rpc/src/types.ts: -------------------------------------------------------------------------------- 1 | import type { PlebbitError } from "../../plebbit-error.js"; 2 | import type { Plebbit } from "../../plebbit/plebbit.js"; 3 | import { 4 | CreatePlebbitWsServerOptionsSchema, 5 | SetNewSettingsPlebbitWsServerSchema, 6 | PlebbitWsServerSettingsSerializedSchema 7 | } from "./schema.js"; 8 | import { z } from "zod"; 9 | 10 | export type CreatePlebbitWsServerOptions = z.infer; 11 | 12 | export interface PlebbitWsServerClassOptions extends CreatePlebbitWsServerOptions { 13 | plebbit: Plebbit; 14 | } 15 | 16 | export type SetNewSettingsPlebbitWsServer = z.infer; 17 | 18 | export type PlebbitWsServerSettingsSerialized = z.infer; 19 | 20 | export type JsonRpcSendNotificationOptions = { 21 | method: string; 22 | result: any; 23 | subscription: number; 24 | event: string; 25 | connectionId: string; 26 | }; 27 | 28 | export type PlebbitRpcServerEvents = { 29 | error: (error: PlebbitError | Error) => void; 30 | }; 31 | -------------------------------------------------------------------------------- /dist/browser/rpc/src/lib/plebbit-js/index.js: -------------------------------------------------------------------------------- 1 | // NOTE: don't import plebbit-js directly to be able to replace the implementation 2 | // @plebbit/plebbit-js imported from parent folder 3 | import Plebbit from "../../../../index.js"; 4 | import assert from "assert"; 5 | import Logger from "@plebbit/plebbit-logger"; 6 | const log = Logger("plebbit-react-hooks:plebbit-js"); 7 | const PlebbitJs = { 8 | Plebbit: Plebbit 9 | }; 10 | /** 11 | * replace PlebbitJs with a different implementation, for 12 | * example to mock it during unit tests, to add mock content 13 | * for developing the front-end or to add a PlebbitJs with 14 | * desktop privileges in the Electron build. 15 | */ 16 | export function setPlebbitJs(_Plebbit) { 17 | assert(typeof _Plebbit === "function", `setPlebbitJs invalid Plebbit argument '${_Plebbit}' not a function`); 18 | PlebbitJs.Plebbit = _Plebbit; 19 | log("setPlebbitJs", _Plebbit?.constructor?.name); 20 | } 21 | export function restorePlebbitJs() { 22 | PlebbitJs.Plebbit = Plebbit; 23 | log("restorePlebbitJs"); 24 | } 25 | export default PlebbitJs; 26 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/node/rpc/src/lib/plebbit-js/index.js: -------------------------------------------------------------------------------- 1 | // NOTE: don't import plebbit-js directly to be able to replace the implementation 2 | // @plebbit/plebbit-js imported from parent folder 3 | import Plebbit from "../../../../index.js"; 4 | import assert from "assert"; 5 | import Logger from "@plebbit/plebbit-logger"; 6 | const log = Logger("plebbit-react-hooks:plebbit-js"); 7 | const PlebbitJs = { 8 | Plebbit: Plebbit 9 | }; 10 | /** 11 | * replace PlebbitJs with a different implementation, for 12 | * example to mock it during unit tests, to add mock content 13 | * for developing the front-end or to add a PlebbitJs with 14 | * desktop privileges in the Electron build. 15 | */ 16 | export function setPlebbitJs(_Plebbit) { 17 | assert(typeof _Plebbit === "function", `setPlebbitJs invalid Plebbit argument '${_Plebbit}' not a function`); 18 | PlebbitJs.Plebbit = _Plebbit; 19 | log("setPlebbitJs", _Plebbit?.constructor?.name); 20 | } 21 | export function restorePlebbitJs() { 22 | PlebbitJs.Plebbit = Plebbit; 23 | log("restorePlebbitJs"); 24 | } 25 | export default PlebbitJs; 26 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/rpc/src/lib/plebbit-js/index.ts: -------------------------------------------------------------------------------- 1 | // NOTE: don't import plebbit-js directly to be able to replace the implementation 2 | 3 | // @plebbit/plebbit-js imported from parent folder 4 | import Plebbit from "../../../../index.js"; 5 | 6 | import assert from "assert"; 7 | import Logger from "@plebbit/plebbit-logger"; 8 | const log = Logger("plebbit-react-hooks:plebbit-js"); 9 | 10 | const PlebbitJs = { 11 | Plebbit: Plebbit 12 | }; 13 | 14 | /** 15 | * replace PlebbitJs with a different implementation, for 16 | * example to mock it during unit tests, to add mock content 17 | * for developing the front-end or to add a PlebbitJs with 18 | * desktop privileges in the Electron build. 19 | */ 20 | export function setPlebbitJs(_Plebbit: any) { 21 | assert(typeof _Plebbit === "function", `setPlebbitJs invalid Plebbit argument '${_Plebbit}' not a function`); 22 | PlebbitJs.Plebbit = _Plebbit; 23 | log("setPlebbitJs", _Plebbit?.constructor?.name); 24 | } 25 | 26 | export function restorePlebbitJs() { 27 | PlebbitJs.Plebbit = Plebbit; 28 | log("restorePlebbitJs"); 29 | } 30 | 31 | export default PlebbitJs; 32 | -------------------------------------------------------------------------------- /docs/testing.md: -------------------------------------------------------------------------------- 1 | #### Install 2 | 3 | - `npm install` 4 | 5 | #### Preapre for tests 6 | 7 | - Create a `.env` file and add `CHROME_BIN=/usr/bin/chromium` (replace the path with your chrome path) 8 | - In a new terminal run `npm run build:watch` to compile typescript 9 | - In a new terminal run `npm run webpack:watch` to compile the browser tests 10 | - In a new terminal run `npm run test:server` to start an ipfs node and the test subplebbits 11 | - (Optional) run all the scripts at the same time with `scripts/build-watch-all` 12 | 13 | > Note: tests are written in Javascript (using commonjs `require`, not `import`), to test the Typescript ouput from commonjs. 14 | 15 | #### Tests 16 | 17 | - `npm run test:node` for node tests and node-and-browser tests 18 | - `npm run test:browser` for browser tests and node-and-browser tests 19 | - `npm test` for all tests 20 | - `DEBUG=plebbit-js:* npm test` for tests with logs 21 | 22 | #### Build 23 | 24 | - `npm run build` 25 | 26 | > TODO: add config to to run a single file when doing `npm run test file-name`, for now to run a single file use `describe.only()` and `it.only()` in tests files. -------------------------------------------------------------------------------- /dist/browser/rpc/src/schema.js: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { PlebbitParsedOptionsSchema, PlebbitUserOptionBaseSchema } from "../../schema.js"; 3 | import { ChallengeFileSchema } from "../../subplebbit/schema.js"; 4 | // Setting up WS 5 | const WsServerClassOptions = z.object({ 6 | port: z.number().int().positive().optional(), 7 | server: z.custom().optional() 8 | }); 9 | export const CreatePlebbitWsServerOptionsSchema = z 10 | .object({ 11 | plebbitOptions: z.custom().optional(), // no need to validate here, will be validated with await Plebbit() 12 | authKey: z.string().optional() 13 | }) 14 | .merge(WsServerClassOptions) 15 | .loose(); 16 | // rpc WS 17 | export const SetNewSettingsPlebbitWsServerSchema = z.object({ 18 | plebbitOptions: PlebbitUserOptionBaseSchema.loose() 19 | }); 20 | export const PlebbitWsServerSettingsSerializedSchema = z.object({ 21 | plebbitOptions: PlebbitParsedOptionsSchema.loose(), 22 | challenges: z.record(z.string(), ChallengeFileSchema.omit({ getChallenge: true }) // to avoid throwing because of recursive dependency 23 | ) 24 | }); 25 | //# sourceMappingURL=schema.js.map -------------------------------------------------------------------------------- /dist/node/rpc/src/schema.js: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { PlebbitParsedOptionsSchema, PlebbitUserOptionBaseSchema } from "../../schema.js"; 3 | import { ChallengeFileSchema } from "../../subplebbit/schema.js"; 4 | // Setting up WS 5 | const WsServerClassOptions = z.object({ 6 | port: z.number().int().positive().optional(), 7 | server: z.custom().optional() 8 | }); 9 | export const CreatePlebbitWsServerOptionsSchema = z 10 | .object({ 11 | plebbitOptions: z.custom().optional(), // no need to validate here, will be validated with await Plebbit() 12 | authKey: z.string().optional() 13 | }) 14 | .merge(WsServerClassOptions) 15 | .loose(); 16 | // rpc WS 17 | export const SetNewSettingsPlebbitWsServerSchema = z.object({ 18 | plebbitOptions: PlebbitUserOptionBaseSchema.loose() 19 | }); 20 | export const PlebbitWsServerSettingsSerializedSchema = z.object({ 21 | plebbitOptions: PlebbitParsedOptionsSchema.loose(), 22 | challenges: z.record(z.string(), ChallengeFileSchema.omit({ getChallenge: true }) // to avoid throwing because of recursive dependency 23 | ) 24 | }); 25 | //# sourceMappingURL=schema.js.map -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/exclude/exclude.d.ts: -------------------------------------------------------------------------------- 1 | import type { Challenge, ChallengeResult, SubplebbitChallenge, SubplebbitSettings } from "../../../../../subplebbit/types.js"; 2 | import type { DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor } from "../../../../../pubsub-messages/types.js"; 3 | import { LocalSubplebbit } from "../../local-subplebbit.js"; 4 | import { Plebbit } from "../../../../../plebbit/plebbit.js"; 5 | declare const shouldExcludePublication: (subplebbitChallenge: SubplebbitChallenge, request: DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, subplebbit: LocalSubplebbit) => boolean; 6 | declare const shouldExcludeChallengeSuccess: (subplebbitChallenge: NonNullable[0], subplebbitChallengeIndex: number, challengeResults: (Challenge | ChallengeResult)[]) => boolean; 7 | declare const shouldExcludeChallengeCommentCids: (subplebbitChallenge: SubplebbitChallenge, challengeRequestMessage: DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, plebbit: Plebbit) => Promise; 8 | export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess }; 9 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/exclude/exclude.d.ts: -------------------------------------------------------------------------------- 1 | import type { Challenge, ChallengeResult, SubplebbitChallenge, SubplebbitSettings } from "../../../../../subplebbit/types.js"; 2 | import type { DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor } from "../../../../../pubsub-messages/types.js"; 3 | import { LocalSubplebbit } from "../../local-subplebbit.js"; 4 | import { Plebbit } from "../../../../../plebbit/plebbit.js"; 5 | declare const shouldExcludePublication: (subplebbitChallenge: SubplebbitChallenge, request: DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, subplebbit: LocalSubplebbit) => boolean; 6 | declare const shouldExcludeChallengeSuccess: (subplebbitChallenge: NonNullable[0], subplebbitChallengeIndex: number, challengeResults: (Challenge | ChallengeResult)[]) => boolean; 7 | declare const shouldExcludeChallengeCommentCids: (subplebbitChallenge: SubplebbitChallenge, challengeRequestMessage: DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, plebbit: Plebbit) => Promise; 8 | export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess }; 9 | -------------------------------------------------------------------------------- /dist/browser/clients/rpc-client/decode-rpc-response-util.d.ts: -------------------------------------------------------------------------------- 1 | import type { DecryptedChallengeAnswerMessageType, DecryptedChallengeMessageType, DecryptedChallengeRequestMessageType, DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, DecryptedChallengeVerificationMessageType, EncodedDecryptedChallengeAnswerMessageType, EncodedDecryptedChallengeMessageType, EncodedDecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, EncodedDecryptedChallengeVerificationMessageType } from "../../pubsub-messages/types"; 2 | export declare function decodeRpcChallengeRequestPubsubMsg(msg: EncodedDecryptedChallengeRequestMessageTypeWithSubplebbitAuthor): DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor | DecryptedChallengeRequestMessageType; 3 | export declare function decodeRpcChallengePubsubMsg(msg: EncodedDecryptedChallengeMessageType): DecryptedChallengeMessageType; 4 | export declare function decodeRpcChallengeAnswerPubsubMsg(msg: EncodedDecryptedChallengeAnswerMessageType): DecryptedChallengeAnswerMessageType; 5 | export declare function decodeRpcChallengeVerificationPubsubMsg(msg: EncodedDecryptedChallengeVerificationMessageType): DecryptedChallengeVerificationMessageType; 6 | -------------------------------------------------------------------------------- /dist/node/clients/rpc-client/decode-rpc-response-util.d.ts: -------------------------------------------------------------------------------- 1 | import type { DecryptedChallengeAnswerMessageType, DecryptedChallengeMessageType, DecryptedChallengeRequestMessageType, DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, DecryptedChallengeVerificationMessageType, EncodedDecryptedChallengeAnswerMessageType, EncodedDecryptedChallengeMessageType, EncodedDecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, EncodedDecryptedChallengeVerificationMessageType } from "../../pubsub-messages/types"; 2 | export declare function decodeRpcChallengeRequestPubsubMsg(msg: EncodedDecryptedChallengeRequestMessageTypeWithSubplebbitAuthor): DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor | DecryptedChallengeRequestMessageType; 3 | export declare function decodeRpcChallengePubsubMsg(msg: EncodedDecryptedChallengeMessageType): DecryptedChallengeMessageType; 4 | export declare function decodeRpcChallengeAnswerPubsubMsg(msg: EncodedDecryptedChallengeAnswerMessageType): DecryptedChallengeAnswerMessageType; 5 | export declare function decodeRpcChallengeVerificationPubsubMsg(msg: EncodedDecryptedChallengeVerificationMessageType): DecryptedChallengeVerificationMessageType; 6 | -------------------------------------------------------------------------------- /test/fixtures/signatures/comment/valid_comment_author_address_as_domain.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": "Mock post - 1723465331806", 3 | "title": "Mock post title", 4 | "author": { "address": "plebbit.eth", "displayName": "Mock Author - 1723465331806" }, 5 | "subplebbitAddress": "12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR", 6 | "protocolVersion": "1.0.0", 7 | "timestamp": 1723465332, 8 | "signature": { 9 | "signature": "UDvg8TCl19MoeWIrep0LcHlFlLXsTaKEciJ41xsdZXVs8Jz5tgMPwzLbZEU7gJq7lo85c7AJz1L9/BwcWlrAAA", 10 | "publicKey": "fhnnUqE9NCCtgcEfwSRNSk7KCbm2lzD1HGhzaol9n/k", 11 | "type": "ed25519", 12 | "signedPropertyNames": [ 13 | "flair", 14 | "spoiler", 15 | "content", 16 | "title", 17 | "link", 18 | "linkWidth", 19 | "linkHeight", 20 | "linkHtmlTagName", 21 | "parentCid", 22 | "author", 23 | "subplebbitAddress", 24 | "protocolVersion", 25 | "timestamp" 26 | ] 27 | }, 28 | "depth": 0, 29 | "previousCid": "QmRCzp6x9QTYAjhFuj3CgGgruknMqvSJb8oJ77GHecTkKb" 30 | } 31 | -------------------------------------------------------------------------------- /dist/browser/subplebbit/rpc-remote-subplebbit.d.ts: -------------------------------------------------------------------------------- 1 | import { RemoteSubplebbit } from "./remote-subplebbit.js"; 2 | export declare class RpcRemoteSubplebbit extends RemoteSubplebbit { 3 | private _updateRpcSubscriptionId?; 4 | private _updatingRpcSubInstanceWithListeners?; 5 | protected _setRpcClientStateWithoutEmission(newState: RemoteSubplebbit["clients"]["plebbitRpcClients"][""]["state"]): void; 6 | protected _setRpcClientStateWithEmission(newState: RemoteSubplebbit["clients"]["plebbitRpcClients"][""]["state"]): void; 7 | get updatingState(): RemoteSubplebbit["updatingState"]; 8 | protected _updateRpcClientStateFromUpdatingState(updatingState: RpcRemoteSubplebbit["updatingState"]): void; 9 | protected _processUpdateEventFromRpcUpdate(args: any): void; 10 | private _handleUpdatingStateChangeFromRpcUpdate; 11 | private _initMirroringUpdatingSubplebbit; 12 | protected _handleRpcErrorEvent(args: any): void; 13 | _initRpcUpdateSubscription(): Promise; 14 | _createAndSubscribeToNewUpdatingSubplebbit(updatingSubplebbit?: RpcRemoteSubplebbit): Promise; 15 | update(): Promise; 16 | private _cleanupMirroringUpdatingSubplebbit; 17 | stop(): Promise; 18 | } 19 | -------------------------------------------------------------------------------- /dist/node/subplebbit/rpc-remote-subplebbit.d.ts: -------------------------------------------------------------------------------- 1 | import { RemoteSubplebbit } from "./remote-subplebbit.js"; 2 | export declare class RpcRemoteSubplebbit extends RemoteSubplebbit { 3 | private _updateRpcSubscriptionId?; 4 | private _updatingRpcSubInstanceWithListeners?; 5 | protected _setRpcClientStateWithoutEmission(newState: RemoteSubplebbit["clients"]["plebbitRpcClients"][""]["state"]): void; 6 | protected _setRpcClientStateWithEmission(newState: RemoteSubplebbit["clients"]["plebbitRpcClients"][""]["state"]): void; 7 | get updatingState(): RemoteSubplebbit["updatingState"]; 8 | protected _updateRpcClientStateFromUpdatingState(updatingState: RpcRemoteSubplebbit["updatingState"]): void; 9 | protected _processUpdateEventFromRpcUpdate(args: any): void; 10 | private _handleUpdatingStateChangeFromRpcUpdate; 11 | private _initMirroringUpdatingSubplebbit; 12 | protected _handleRpcErrorEvent(args: any): void; 13 | _initRpcUpdateSubscription(): Promise; 14 | _createAndSubscribeToNewUpdatingSubplebbit(updatingSubplebbit?: RpcRemoteSubplebbit): Promise; 15 | update(): Promise; 16 | private _cleanupMirroringUpdatingSubplebbit; 17 | stop(): Promise; 18 | } 19 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/polyfill.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../../../src/runtime/browser/polyfill.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,qBAAqB;AAErB,mEAAmE;AACnE,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;IAC/B,MAAM,eAAe,GAAQ,EAAE,CAAC;IAChC,aAAa;IACb,MAAM,CAAC,OAAO,GAAG,eAAe,CAAC;AACrC,CAAC;AACD,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;IACnC,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC;AAC5B,CAAC;AAED,kGAAkG;AAElG,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,8DAA8D;AAC9D,oEAAoE;AACpE,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,qFAAqF,CAAC,CAAC;IAEnG,kBAAkB;IAClB,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,0CAA0C;IAClF,kBAAkB;IAClB,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG;QACnB,kBAAkB;QAClB,MAAM,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,EAAE;YAChC,IAAI,UAAU,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;iBAC3D,IAAI,UAAU,EAAE,IAAI,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;iBACtE,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,wCAAwC,UAAU,6BAA6B,CAAC,CAAC;gBAC/F,MAAM,KAAK,CAAC,qBAAqB,GAAG,UAAU,CAAC,CAAC;YACpD,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC;AAED,sDAAsD;AACtD,OAAO,0BAA0B,CAAC;AAElC,6DAA6D;AAC7D,eAAe,GAAG,EAAE,GAAE,CAAC,CAAC"} -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/challenges/plebbit-js-challenges/fail.js: -------------------------------------------------------------------------------- 1 | // the purpose of this challenge is to always fail, can be used with SubplebbitChallenge.exclude to whitelist users 2 | const optionInputs = [ 3 | { 4 | option: "error", 5 | label: "Error", 6 | default: `You're not allowed to publish.`, 7 | description: "The error to display to the author.", 8 | placeholder: `You're not allowed to publish.` 9 | } 10 | ]; 11 | const type = "text/plain"; 12 | const description = "A challenge that automatically fails with a custom error message."; 13 | const getChallenge = async (subplebbitChallengeSettings, challengeRequestMessage, challengeIndex) => { 14 | // add a custom error message to display to the author 15 | const error = subplebbitChallengeSettings?.options?.error; 16 | // the only way to succeed the 'fail' challenge is to be excluded 17 | return { 18 | success: false, 19 | error: error || `You're not allowed to publish.` 20 | }; 21 | }; 22 | function ChallengeFileFactory(subplebbitChallengeSettings) { 23 | return { getChallenge, optionInputs, type, description }; 24 | } 25 | export default ChallengeFileFactory; 26 | //# sourceMappingURL=fail.js.map -------------------------------------------------------------------------------- /src/test/node/hanging-test/scenarios/subplebbit-update.scenario.ts: -------------------------------------------------------------------------------- 1 | import { resolveWhenConditionIsTrue } from "../../../test-util.js"; 2 | import { createScenarioContext, defineHangingScenario } from "./hanging-test-util.js"; 3 | 4 | /** 5 | * Template scenario showing the shape expected by the hanging test harness. 6 | * Replace the placeholder steps with the flow you want to exercise before 7 | * checking for lingering resources. Make sure any asynchronous work is awaited 8 | * so the destroy call can flush everything properly. 9 | */ 10 | export default defineHangingScenario({ 11 | id: "subplebbit-update", 12 | description: "update a subplebbit and destroy plebbit", 13 | run: async ({ configCode }) => { 14 | const subplebbitAddress = "12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR"; 15 | const { plebbit, config } = await createScenarioContext(configCode); 16 | 17 | const subplebbit = await plebbit.createSubplebbit({ address: subplebbitAddress }); 18 | 19 | await subplebbit.update(); 20 | await resolveWhenConditionIsTrue({ toUpdate: subplebbit, predicate: async () => typeof subplebbit.updatedAt === "number" }); 21 | 22 | await plebbit.destroy(); 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /test/server/pubsub-mock-server.js: -------------------------------------------------------------------------------- 1 | import { Server } from "socket.io"; 2 | 3 | const ipfsMockPort = 25963; 4 | 5 | // Create a wss to mock ipfs pubsub 6 | const pubsubIoServer = new Server(ipfsMockPort, { cors: { origin: "*" }, maxHttpBufferSize: 10 * 1024 * 1024 }); 7 | let peers = []; 8 | 9 | pubsubIoServer.on("connection", async (connectedPeer) => { 10 | console.log("[mock-pubsub-server] peer connected", connectedPeer.id, "total before push", peers.length); 11 | // relay messages to all other peers 12 | 13 | connectedPeer.on("disconnect", () => { 14 | console.log("[mock-pubsub-server] peer disconnected", connectedPeer.id); 15 | peers = peers.filter((peer) => peer.id !== connectedPeer.id); 16 | }); 17 | connectedPeer.onAny(async (topic, message) => { 18 | console.log("[mock-pubsub-server] relay", topic, "to", peers.length, "peers"); 19 | // if (peers.length <= 1) 20 | // throw Error( 21 | // "Only a single peer is connected, are you sure other peers from mocked pubsub ws server are there? topic is " + topic 22 | // ); 23 | for (const curPeer of peers) curPeer.emit(topic, message); 24 | }); 25 | peers.push(connectedPeer); 26 | }); 27 | -------------------------------------------------------------------------------- /dist/browser/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,QAAQ,MAAM,4BAA4B,CAAC;AAClD,QAAQ,EAAE,CAAC;AACX,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,mBAAmB,MAAM,oCAAoC,CAAC;AACrE,OAAO,sBAAsB,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,MAAM,OAAO,GAAG,KAAK,UAAU,OAAO,CAAC,iBAAsC,EAAE;IAC3E,MAAM,OAAO,GAAG,cAAc,CAAC,wBAAwB;QACnD,CAAC,CAAC,IAAI,oBAAoB,CAAC,cAAc,CAAC;QAC1C,CAAC,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/C,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,OAAO,CAAC,kBAAkB,GAAG,sBAAsB,CAAC;AACpD,OAAO,CAAC,eAAe,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;AACzF,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;AAClC,OAAO,CAAC,eAAe,GAAG,eAAe,CAAC;AAC1C,OAAO,CAAC,UAAU,GAAG,mBAAmB,CAAC;AACzC,eAAe,OAAO,CAAC;AACvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;AACvD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC"} -------------------------------------------------------------------------------- /dist/browser/runtime/browser/polyfill.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../../../src/runtime/browser/polyfill.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,qBAAqB;AAErB,mEAAmE;AACnE,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;IAC/B,MAAM,eAAe,GAAQ,EAAE,CAAC;IAChC,aAAa;IACb,MAAM,CAAC,OAAO,GAAG,eAAe,CAAC;AACrC,CAAC;AACD,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;IACnC,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC;AAC5B,CAAC;AAED,kGAAkG;AAElG,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,8DAA8D;AAC9D,oEAAoE;AACpE,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,qFAAqF,CAAC,CAAC;IAEnG,kBAAkB;IAClB,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,0CAA0C;IAClF,kBAAkB;IAClB,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG;QACnB,kBAAkB;QAClB,MAAM,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,EAAE;YAChC,IAAI,UAAU,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;iBAC3D,IAAI,UAAU,EAAE,IAAI,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;iBACtE,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,wCAAwC,UAAU,6BAA6B,CAAC,CAAC;gBAC/F,MAAM,KAAK,CAAC,qBAAqB,GAAG,UAAU,CAAC,CAAC;YACpD,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC;AAED,sDAAsD;AACtD,OAAO,0BAA0B,CAAC;AAElC,6DAA6D;AAC7D,eAAe,GAAG,EAAE,GAAE,CAAC,CAAC"} -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/challenges/plebbit-js-challenges/fail.js: -------------------------------------------------------------------------------- 1 | // the purpose of this challenge is to always fail, can be used with SubplebbitChallenge.exclude to whitelist users 2 | const optionInputs = [ 3 | { 4 | option: "error", 5 | label: "Error", 6 | default: `You're not allowed to publish.`, 7 | description: "The error to display to the author.", 8 | placeholder: `You're not allowed to publish.` 9 | } 10 | ]; 11 | const type = "text/plain"; 12 | const description = "A challenge that automatically fails with a custom error message."; 13 | const getChallenge = async (subplebbitChallengeSettings, challengeRequestMessage, challengeIndex) => { 14 | // add a custom error message to display to the author 15 | const error = subplebbitChallengeSettings?.options?.error; 16 | // the only way to succeed the 'fail' challenge is to be excluded 17 | return { 18 | success: false, 19 | error: error || `You're not allowed to publish.` 20 | }; 21 | }; 22 | function ChallengeFileFactory(subplebbitChallengeSettings) { 23 | return { getChallenge, optionInputs, type, description }; 24 | } 25 | export default ChallengeFileFactory; 26 | //# sourceMappingURL=fail.js.map -------------------------------------------------------------------------------- /dist/node/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,QAAQ,MAAM,4BAA4B,CAAC;AAClD,QAAQ,EAAE,CAAC;AACX,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,mBAAmB,MAAM,oCAAoC,CAAC;AACrE,OAAO,sBAAsB,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,MAAM,OAAO,GAAG,KAAK,UAAU,OAAO,CAAC,iBAAsC,EAAE;IAC3E,MAAM,OAAO,GAAG,cAAc,CAAC,wBAAwB;QACnD,CAAC,CAAC,IAAI,oBAAoB,CAAC,cAAc,CAAC;QAC1C,CAAC,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/C,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,OAAO,CAAC,kBAAkB,GAAG,sBAAsB,CAAC;AACpD,OAAO,CAAC,eAAe,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;AACzF,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;AAClC,OAAO,CAAC,eAAe,GAAG,eAAe,CAAC;AAC1C,OAAO,CAAC,UAAU,GAAG,mBAAmB,CAAC;AACzC,eAAe,OAAO,CAAC;AACvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;AACvD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC"} -------------------------------------------------------------------------------- /dist/browser/decorator-util.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"decorator-util.js","sourceRoot":"","sources":["../../src/decorator-util.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,cAAsB,GAAG;IACxD,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC7E,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QACxC,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,CAAC;QAEpE,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW;YACvC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;YAEhC,IAAI,CAAC;gBACD,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAEhD,IAAI,OAAO,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;oBACvC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,cAAmB,EAAE,EAAE;wBACvC,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;wBAC9B,MAAM,aAAa,GAAG,GAAG,GAAG,KAAK,CAAC;wBAElC,IAAI,aAAa,GAAG,WAAW,EAAE,CAAC;4BAC9B,OAAO,CAAC,IAAI,CAAC,sBAAsB,WAAW,SAAS,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;wBACpG,CAAC;wBAED,OAAO,cAAc,CAAC;oBAC1B,CAAC,CAAC,CAAC;gBACP,CAAC;qBAAM,CAAC;oBACJ,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;oBAC9B,MAAM,aAAa,GAAG,GAAG,GAAG,KAAK,CAAC;oBAElC,IAAI,aAAa,GAAG,WAAW,EAAE,CAAC;wBAC9B,OAAO,CAAC,IAAI,CAAC,sBAAsB,WAAW,SAAS,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;oBACpG,CAAC;oBAED,OAAO,MAAM,CAAC;gBAClB,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC"} -------------------------------------------------------------------------------- /dist/node/decorator-util.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"decorator-util.js","sourceRoot":"","sources":["../../src/decorator-util.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,cAAsB,GAAG;IACxD,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC7E,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QACxC,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,CAAC;QAEpE,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW;YACvC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;YAEhC,IAAI,CAAC;gBACD,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAEhD,IAAI,OAAO,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;oBACvC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,cAAmB,EAAE,EAAE;wBACvC,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;wBAC9B,MAAM,aAAa,GAAG,GAAG,GAAG,KAAK,CAAC;wBAElC,IAAI,aAAa,GAAG,WAAW,EAAE,CAAC;4BAC9B,OAAO,CAAC,IAAI,CAAC,sBAAsB,WAAW,SAAS,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;wBACpG,CAAC;wBAED,OAAO,cAAc,CAAC;oBAC1B,CAAC,CAAC,CAAC;gBACP,CAAC;qBAAM,CAAC;oBACJ,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;oBAC9B,MAAM,aAAa,GAAG,GAAG,GAAG,KAAK,CAAC;oBAElC,IAAI,aAAa,GAAG,WAAW,EAAE,CAAC;wBAC9B,OAAO,CAAC,IAAI,CAAC,sBAAsB,WAAW,SAAS,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;oBACpG,CAAC;oBAED,OAAO,MAAM,CAAC;gBAClB,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC"} -------------------------------------------------------------------------------- /src/test/node/hanging-test/scenarios/subplebbit-start.scenario.ts: -------------------------------------------------------------------------------- 1 | import { resolveWhenConditionIsTrue } from "../../../test-util.js"; 2 | import { createScenarioContext, defineHangingScenario } from "./hanging-test-util.js"; 3 | 4 | /** 5 | * Template scenario showing the shape expected by the hanging test harness. 6 | * Replace the placeholder steps with the flow you want to exercise before 7 | * checking for lingering resources. Make sure any asynchronous work is awaited 8 | * so the destroy call can flush everything properly. 9 | */ 10 | export default defineHangingScenario({ 11 | id: "subplebbit-start", 12 | description: "start a subplebbit and destroy plebbit", 13 | run: async ({ configCode }) => { 14 | const allowedConfigCodes = ["local-kubo-rpc", "remote-plebbit-rpc"]; 15 | if (!allowedConfigCodes.includes(configCode)) return; 16 | const { plebbit, config } = await createScenarioContext(configCode); 17 | 18 | const subplebbit = await plebbit.createSubplebbit(); 19 | 20 | await subplebbit.start(); 21 | await resolveWhenConditionIsTrue({ toUpdate: subplebbit, predicate: async () => typeof subplebbit.updatedAt === "number" }); 22 | 23 | await plebbit.destroy(); 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /dist/node/runtime/node/subplebbit/db-row-parser.d.ts: -------------------------------------------------------------------------------- 1 | import type { CommentUpdateType, CommentsTableRow, CommentUpdatesRow, CommentIpfsType } from "../../../publications/comment/types.js"; 2 | import type { CommentEditsTableRow } from "../../../publications/comment-edit/types.js"; 3 | import type { VotesTableRow } from "../../../publications/vote/types.js"; 4 | export type CommentIpfsPrefixedColumns = { 5 | [K in keyof CommentsTableRow as `commentIpfs_${string & K}`]?: CommentsTableRow[K]; 6 | }; 7 | export type CommentUpdatePrefixedColumns = { 8 | [K in keyof CommentUpdatesRow as `commentUpdate_${string & K}`]?: CommentUpdatesRow[K]; 9 | }; 10 | export type PrefixedCommentRow = CommentIpfsPrefixedColumns & CommentUpdatePrefixedColumns; 11 | export declare function parsePrefixedComment(row: PrefixedCommentRow): { 12 | comment: CommentIpfsType; 13 | commentUpdate: CommentUpdateType; 14 | extras: Record; 15 | }; 16 | export declare function parseCommentsTableRow(row: unknown): CommentsTableRow; 17 | export declare function parseCommentUpdateRow(row: unknown): CommentUpdatesRow; 18 | export declare function parseCommentEditsRow(row: unknown): CommentEditsTableRow; 19 | export declare function parseVoteRow(row: unknown): VotesTableRow; 20 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/subplebbit/db-row-parser.d.ts: -------------------------------------------------------------------------------- 1 | import type { CommentUpdateType, CommentsTableRow, CommentUpdatesRow, CommentIpfsType } from "../../../publications/comment/types.js"; 2 | import type { CommentEditsTableRow } from "../../../publications/comment-edit/types.js"; 3 | import type { VotesTableRow } from "../../../publications/vote/types.js"; 4 | export type CommentIpfsPrefixedColumns = { 5 | [K in keyof CommentsTableRow as `commentIpfs_${string & K}`]?: CommentsTableRow[K]; 6 | }; 7 | export type CommentUpdatePrefixedColumns = { 8 | [K in keyof CommentUpdatesRow as `commentUpdate_${string & K}`]?: CommentUpdatesRow[K]; 9 | }; 10 | export type PrefixedCommentRow = CommentIpfsPrefixedColumns & CommentUpdatePrefixedColumns; 11 | export declare function parsePrefixedComment(row: PrefixedCommentRow): { 12 | comment: CommentIpfsType; 13 | commentUpdate: CommentUpdateType; 14 | extras: Record; 15 | }; 16 | export declare function parseCommentsTableRow(row: unknown): CommentsTableRow; 17 | export declare function parseCommentUpdateRow(row: unknown): CommentUpdatesRow; 18 | export declare function parseCommentEditsRow(row: unknown): CommentEditsTableRow; 19 | export declare function parseVoteRow(row: unknown): VotesTableRow; 20 | -------------------------------------------------------------------------------- /test/fixtures/signatures/comment/commentUpdate_authorEdit/valid_comment_ipfs.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": "original content", 3 | "title": "Random post Title a200582d-c2ee-48b6-8130-e75b8bbc541a", 4 | "author": { "address": "12D3KooWGwFwg6ENVaYoWD86B22i9X1n2i4symJjkzDkfguzdhb1", "displayName": "Mock Author - 1723466493.9465492" }, 5 | "subplebbitAddress": "12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR", 6 | "protocolVersion": "1.0.0", 7 | "timestamp": 1723466493, 8 | "signature": { 9 | "signature": "6jXOvY+hnisICmpXf6UOogcSRPg2lQwZJSjOZrEdSBW08vuBAeAwi5R/pW6hUbel04m9adAGuPZmq2nEtQEYBw", 10 | "publicKey": "acXVy2M8sho3Gtf3jglY07QxlRtVma+3MLPQlbLNEcQ", 11 | "type": "ed25519", 12 | "signedPropertyNames": [ 13 | "flair", 14 | "spoiler", 15 | "content", 16 | "title", 17 | "link", 18 | "linkWidth", 19 | "linkHeight", 20 | "linkHtmlTagName", 21 | "parentCid", 22 | "author", 23 | "subplebbitAddress", 24 | "protocolVersion", 25 | "timestamp" 26 | ] 27 | }, 28 | "depth": 0, 29 | "previousCid": "QmcRfj8VyuL9Yb3cunWn9Hd9qaiKPybeA2fZAwSKqdvyom" 30 | } 31 | -------------------------------------------------------------------------------- /dist/node/publications/vote/types.d.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { CreateVoteUserOptionsSchema, VoteChallengeRequestToEncryptSchema, VotePubsubMessagePublicationSchema, VoteSignedPropertyNames, VoteTablesRowSchema } from "./schema"; 3 | import Vote from "./vote"; 4 | import type { AuthorTypeWithCommentUpdate, JsonOfClass } from "../../types"; 5 | import type { JsonSignature, SignerType } from "../../signer/types"; 6 | export type CreateVoteOptions = z.infer; 7 | export type VoteChallengeRequestToEncryptType = z.infer; 8 | export type VoteJson = JsonOfClass; 9 | export interface VoteOptionsToSign extends Omit { 10 | signer: SignerType; 11 | } 12 | export interface VoteSignature extends JsonSignature { 13 | signedPropertyNames: typeof VoteSignedPropertyNames; 14 | } 15 | export type VotePubsubMessagePublication = z.infer; 16 | export interface VotePubsubMessageWithSubplebbitAuthor extends VotePubsubMessagePublication { 17 | author: AuthorTypeWithCommentUpdate; 18 | } 19 | export type VotesTableRow = z.infer; 20 | export type VotesTableRowInsert = VotesTableRow; 21 | -------------------------------------------------------------------------------- /dist/browser/publications/vote/types.d.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { CreateVoteUserOptionsSchema, VoteChallengeRequestToEncryptSchema, VotePubsubMessagePublicationSchema, VoteSignedPropertyNames, VoteTablesRowSchema } from "./schema"; 3 | import Vote from "./vote"; 4 | import type { AuthorTypeWithCommentUpdate, JsonOfClass } from "../../types"; 5 | import type { JsonSignature, SignerType } from "../../signer/types"; 6 | export type CreateVoteOptions = z.infer; 7 | export type VoteChallengeRequestToEncryptType = z.infer; 8 | export type VoteJson = JsonOfClass; 9 | export interface VoteOptionsToSign extends Omit { 10 | signer: SignerType; 11 | } 12 | export interface VoteSignature extends JsonSignature { 13 | signedPropertyNames: typeof VoteSignedPropertyNames; 14 | } 15 | export type VotePubsubMessagePublication = z.infer; 16 | export interface VotePubsubMessageWithSubplebbitAuthor extends VotePubsubMessagePublication { 17 | author: AuthorTypeWithCommentUpdate; 18 | } 19 | export type VotesTableRow = z.infer; 20 | export type VotesTableRowInsert = VotesTableRow; 21 | -------------------------------------------------------------------------------- /dist/browser/runtime/browser/storage.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../../src/runtime/browser/storage.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,iFAAiF;AACjF,MAAM,CAAC,OAAO,OAAO,OAAO;IAGxB,YAAY,OAA4B;QACpC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,MAAM;QACF,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,2BAA2B,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC;QACvG,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC;YACrC,IAAI,EAAE,WAAW;SACpB,CAAC,CAAC;IACP,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAW;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,KAAU;QACjC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAsB;QACnC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;YAChF,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAEvC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,OAAO,KAAI,CAAC;CACrB"} -------------------------------------------------------------------------------- /dist/node/runtime/browser/storage.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../../src/runtime/browser/storage.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,iFAAiF;AACjF,MAAM,CAAC,OAAO,OAAO,OAAO;IAGxB,YAAY,OAA4B;QACpC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,MAAM;QACF,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,2BAA2B,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC;QACvG,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC;YACrC,IAAI,EAAE,WAAW;SACpB,CAAC,CAAC;IACP,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAW;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,KAAU;QACjC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAsB;QACnC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;YAChF,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAEvC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,OAAO,KAAI,CAAC;CACrB"} -------------------------------------------------------------------------------- /dist/browser/publications/vote/vote.d.ts: -------------------------------------------------------------------------------- 1 | import Publication from "../publication.js"; 2 | import type { PublicationTypeName } from "../../types.js"; 3 | import { Plebbit } from "../../plebbit/plebbit.js"; 4 | import type { CreateVoteOptions, VotePubsubMessagePublication } from "./types.js"; 5 | import type { SignerType } from "../../signer/types.js"; 6 | declare class Vote extends Publication implements VotePubsubMessagePublication { 7 | commentCid: VotePubsubMessagePublication["commentCid"]; 8 | vote: VotePubsubMessagePublication["vote"]; 9 | signature: VotePubsubMessagePublication["signature"]; 10 | raw: { 11 | pubsubMessageToPublish?: VotePubsubMessagePublication; 12 | }; 13 | challengeRequest?: CreateVoteOptions["challengeRequest"]; 14 | constructor(plebbit: Plebbit); 15 | _initLocalProps(props: { 16 | vote: VotePubsubMessagePublication; 17 | signer?: SignerType; 18 | challengeRequest?: CreateVoteOptions["challengeRequest"]; 19 | }): void; 20 | _initRemoteProps(props: VotePubsubMessagePublication): void; 21 | toJSONPubsubMessagePublication(): VotePubsubMessagePublication; 22 | getType(): PublicationTypeName; 23 | private _validateSignature; 24 | publish(): Promise; 25 | } 26 | export default Vote; 27 | -------------------------------------------------------------------------------- /dist/node/publications/vote/vote.d.ts: -------------------------------------------------------------------------------- 1 | import Publication from "../publication.js"; 2 | import type { PublicationTypeName } from "../../types.js"; 3 | import { Plebbit } from "../../plebbit/plebbit.js"; 4 | import type { CreateVoteOptions, VotePubsubMessagePublication } from "./types.js"; 5 | import type { SignerType } from "../../signer/types.js"; 6 | declare class Vote extends Publication implements VotePubsubMessagePublication { 7 | commentCid: VotePubsubMessagePublication["commentCid"]; 8 | vote: VotePubsubMessagePublication["vote"]; 9 | signature: VotePubsubMessagePublication["signature"]; 10 | raw: { 11 | pubsubMessageToPublish?: VotePubsubMessagePublication; 12 | }; 13 | challengeRequest?: CreateVoteOptions["challengeRequest"]; 14 | constructor(plebbit: Plebbit); 15 | _initLocalProps(props: { 16 | vote: VotePubsubMessagePublication; 17 | signer?: SignerType; 18 | challengeRequest?: CreateVoteOptions["challengeRequest"]; 19 | }): void; 20 | _initRemoteProps(props: VotePubsubMessagePublication): void; 21 | toJSONPubsubMessagePublication(): VotePubsubMessagePublication; 22 | getType(): PublicationTypeName; 23 | private _validateSignature; 24 | publish(): Promise; 25 | } 26 | export default Vote; 27 | -------------------------------------------------------------------------------- /dist/node/runtime/browser/storage.js: -------------------------------------------------------------------------------- 1 | import localForage from "localforage"; 2 | import { v4 as uuidV4 } from "uuid"; 3 | import { hideClassPrivateProps } from "../../util.js"; 4 | // Storage is for long term items, no eviction based on ttl or anything like that 5 | export default class Storage { 6 | constructor(plebbit) { 7 | this._plebbit = plebbit; 8 | hideClassPrivateProps(this); 9 | } 10 | toJSON() { 11 | return undefined; 12 | } 13 | async init() { 14 | const storageName = this._plebbit.noData ? `Browser-storage-no-data-${uuidV4()}` : "plebbitjs_storage"; 15 | this._store = localForage.createInstance({ 16 | name: storageName 17 | }); 18 | } 19 | async getItem(key) { 20 | return this._store.getItem(key); 21 | } 22 | async setItem(key, value) { 23 | await this._store.setItem(key, value); 24 | } 25 | async removeItem(key) { 26 | if (Array.isArray(key)) 27 | await Promise.all(key.map((k) => this._store.removeItem(k))); 28 | else 29 | await this._store.removeItem(key); 30 | return true; 31 | } 32 | async clear() { 33 | await this._store.clear(); 34 | } 35 | async destroy() { } 36 | } 37 | //# sourceMappingURL=storage.js.map -------------------------------------------------------------------------------- /dist/browser/runtime/browser/storage.js: -------------------------------------------------------------------------------- 1 | import localForage from "localforage"; 2 | import { v4 as uuidV4 } from "uuid"; 3 | import { hideClassPrivateProps } from "../../util.js"; 4 | // Storage is for long term items, no eviction based on ttl or anything like that 5 | export default class Storage { 6 | constructor(plebbit) { 7 | this._plebbit = plebbit; 8 | hideClassPrivateProps(this); 9 | } 10 | toJSON() { 11 | return undefined; 12 | } 13 | async init() { 14 | const storageName = this._plebbit.noData ? `Browser-storage-no-data-${uuidV4()}` : "plebbitjs_storage"; 15 | this._store = localForage.createInstance({ 16 | name: storageName 17 | }); 18 | } 19 | async getItem(key) { 20 | return this._store.getItem(key); 21 | } 22 | async setItem(key, value) { 23 | await this._store.setItem(key, value); 24 | } 25 | async removeItem(key) { 26 | if (Array.isArray(key)) 27 | await Promise.all(key.map((k) => this._store.removeItem(k))); 28 | else 29 | await this._store.removeItem(key); 30 | return true; 31 | } 32 | async clear() { 33 | await this._store.clear(); 34 | } 35 | async destroy() { } 36 | } 37 | //# sourceMappingURL=storage.js.map -------------------------------------------------------------------------------- /dist/node/rpc/src/utils.d.ts: -------------------------------------------------------------------------------- 1 | import type { DecryptedChallengeAnswerMessageType, DecryptedChallengeMessageType, DecryptedChallengeRequestMessageType, DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, DecryptedChallengeVerificationMessageType, EncodedDecryptedChallengeAnswerMessageType, EncodedDecryptedChallengeMessageType, EncodedDecryptedChallengeRequestMessageType, EncodedDecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, EncodedDecryptedChallengeVerificationMessageType } from "../../pubsub-messages/types.js"; 2 | export declare const clone: (obj: any) => any; 3 | export declare const generateSubscriptionId: () => number; 4 | export declare function encodeChallengeRequest(msg: DecryptedChallengeRequestMessageType | DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor): EncodedDecryptedChallengeRequestMessageType | EncodedDecryptedChallengeRequestMessageTypeWithSubplebbitAuthor; 5 | export declare function encodeChallengeMessage(msg: DecryptedChallengeMessageType): EncodedDecryptedChallengeMessageType; 6 | export declare function encodeChallengeAnswerMessage(msg: DecryptedChallengeAnswerMessageType): EncodedDecryptedChallengeAnswerMessageType; 7 | export declare function encodeChallengeVerificationMessage(msg: DecryptedChallengeVerificationMessageType): EncodedDecryptedChallengeVerificationMessageType; 8 | -------------------------------------------------------------------------------- /src/test/node/hanging-test/scenarios/comment-publish-pending.scenario.ts: -------------------------------------------------------------------------------- 1 | import { generateMockPost } from "../../../test-util.js"; 2 | import { createScenarioContext, defineHangingScenario } from "./hanging-test-util.js"; 3 | 4 | /** 5 | * Template scenario showing the shape expected by the hanging test harness. 6 | * Replace the placeholder steps with the flow you want to exercise before 7 | * checking for lingering resources. Make sure any asynchronous work is awaited 8 | * so the destroy call can flush everything properly. 9 | */ 10 | export default defineHangingScenario({ 11 | id: "comment-publish-pending", 12 | description: "publish a comment over pubsub without succeeding and instead hanging. Then destroy plebbit", 13 | run: async ({ configCode }) => { 14 | const mathCliSub = "12D3KooWANwdyPERMQaCgiMnTT1t3Lr4XLFbK1z4ptFVhW2ozg1z"; 15 | const { plebbit, config } = await createScenarioContext(configCode); 16 | 17 | const post = await generateMockPost(mathCliSub, plebbit); 18 | post.removeAllListeners("challenge"); 19 | 20 | await post.publish(); // it will receive a challenge, but we won't respond because we wanna keep process hanging 21 | 22 | await plebbit.destroy(); // destroy here should remove pubsub subscription 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /dist/browser/rpc/src/utils.d.ts: -------------------------------------------------------------------------------- 1 | import type { DecryptedChallengeAnswerMessageType, DecryptedChallengeMessageType, DecryptedChallengeRequestMessageType, DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, DecryptedChallengeVerificationMessageType, EncodedDecryptedChallengeAnswerMessageType, EncodedDecryptedChallengeMessageType, EncodedDecryptedChallengeRequestMessageType, EncodedDecryptedChallengeRequestMessageTypeWithSubplebbitAuthor, EncodedDecryptedChallengeVerificationMessageType } from "../../pubsub-messages/types.js"; 2 | export declare const clone: (obj: any) => any; 3 | export declare const generateSubscriptionId: () => number; 4 | export declare function encodeChallengeRequest(msg: DecryptedChallengeRequestMessageType | DecryptedChallengeRequestMessageTypeWithSubplebbitAuthor): EncodedDecryptedChallengeRequestMessageType | EncodedDecryptedChallengeRequestMessageTypeWithSubplebbitAuthor; 5 | export declare function encodeChallengeMessage(msg: DecryptedChallengeMessageType): EncodedDecryptedChallengeMessageType; 6 | export declare function encodeChallengeAnswerMessage(msg: DecryptedChallengeAnswerMessageType): EncodedDecryptedChallengeAnswerMessageType; 7 | export declare function encodeChallengeVerificationMessage(msg: DecryptedChallengeVerificationMessageType): EncodedDecryptedChallengeVerificationMessageType; 8 | -------------------------------------------------------------------------------- /dist/node/runtime/node/lru-storage.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"lru-storage.js","sourceRoot":"","sources":["../../../../src/runtime/node/lru-storage.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAEhD,iFAAiF;AAEjF,kDAAkD;AAElD,MAAM,CAAC,OAAO,OAAO,UAAU;IAI3B,YAAY,IAA2B;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,MAAM;QACF,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,MAAM,GACR,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QACnI,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAC;YAC1B,QAAQ,EAAE,MAAM;YAChB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YACpC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;SAChC,CAAC,CAAC;IACP,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAW;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,KAAU;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAW;QACxB,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,OAAO;QACT,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACJ"} -------------------------------------------------------------------------------- /test/fixtures/signatures/comment/commentUpdate/valid_comment_ipfs.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": { "address": "12D3KooWLjZGiL8t2FyNZc21EMKw1SLR7U6khv4RW9sEFKD4aFXJ", "displayName": "Mock Author - 1728396705.2567477" }, 3 | "content": "Random post Content 4dff7ed1-c7e8-408a-aa67-0735ba20d1c1", 4 | "depth": 0, 5 | "previousCid": "QmeaD98zCjbs3h9GSCMixCGxMSJC3vUgW2i9pZoJpwkN7u", 6 | "protocolVersion": "1.0.0", 7 | "signature": { 8 | "publicKey": "ojU0zK7ZudZomVjSQPir7/ZT1u0G7J0IvlqbSx7s1S0", 9 | "signature": "gwJxMTDNb5dV+pA5ztgseaQYxRF18AaqvMal45K7yV6YBHpahLmDN1rVyjXK4ZWeOYH8V90FaMDwolfGtOD6Cg", 10 | "signedPropertyNames": [ 11 | "flair", 12 | "spoiler", 13 | "content", 14 | "title", 15 | "link", 16 | "linkWidth", 17 | "linkHeight", 18 | "linkHtmlTagName", 19 | "parentCid", 20 | "postCid", 21 | "author", 22 | "subplebbitAddress", 23 | "protocolVersion", 24 | "timestamp" 25 | ], 26 | "type": "ed25519" 27 | }, 28 | "subplebbitAddress": "12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR", 29 | "timestamp": 1728396704, 30 | "title": "Random post Title 1298bca6-e1c8-449a-aeb3-eedaa27119d9" 31 | } 32 | -------------------------------------------------------------------------------- /dist/browser/runtime/node/lru-storage.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"lru-storage.js","sourceRoot":"","sources":["../../../../src/runtime/browser/lru-storage.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAEhD,iFAAiF;AAEjF,kDAAkD;AAElD,MAAM,CAAC,OAAO,OAAO,UAAU;IAI3B,YAAY,IAA2B;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,MAAM;QACF,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,MAAM,GACR,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QACnI,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAC;YAC1B,QAAQ,EAAE,MAAM;YAChB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YACpC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;SAChC,CAAC,CAAC;IACP,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAW;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,KAAU;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAW;QACxB,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,OAAO;QACT,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACJ"} -------------------------------------------------------------------------------- /src/test/node/hanging-test/scenarios/comment-update.scenario.ts: -------------------------------------------------------------------------------- 1 | import { publishRandomPost, resolveWhenConditionIsTrue } from "../../../test-util.js"; 2 | import { createScenarioContext, defineHangingScenario } from "./hanging-test-util.js"; 3 | 4 | /** 5 | * Template scenario showing the shape expected by the hanging test harness. 6 | * Replace the placeholder steps with the flow you want to exercise before 7 | * checking for lingering resources. Make sure any asynchronous work is awaited 8 | * so the destroy call can flush everything properly. 9 | */ 10 | export default defineHangingScenario({ 11 | id: "comment-update", 12 | description: "Fetch subplebbit, update a comment and destroy plebbit", 13 | run: async ({ configCode }) => { 14 | const subplebbitAddress = "12D3KooWN5rLmRJ8fWMwTtkDN7w2RgPPGRM4mtWTnfbjpi1Sh7zR"; 15 | const { plebbit, config } = await createScenarioContext(configCode); 16 | 17 | const subplebbit = await plebbit.getSubplebbit({ address: subplebbitAddress }); 18 | 19 | const post = await plebbit.createComment({ cid: subplebbit.lastPostCid! }); 20 | await post.update(); 21 | await resolveWhenConditionIsTrue({ toUpdate: post, predicate: async () => typeof post.updatedAt === "number" }); 22 | 23 | await plebbit.destroy(); 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /dist/node/signer/util.d.ts: -------------------------------------------------------------------------------- 1 | import PeerId from "peer-id"; 2 | export declare const generatePrivateKey: () => Promise; 3 | export declare const getPlebbitAddressFromPrivateKey: (privateKeyBase64: string) => Promise; 4 | export declare const getPlebbitAddressFromPublicKey: (publicKeyBase64: string) => Promise; 5 | export declare const getPlebbitAddressFromPublicKeyBuffer: (publicKeyBuffer: Uint8Array) => Promise; 6 | export declare const getBufferedPlebbitAddressFromPublicKey: (publicKeyBase64: string) => Promise>; 7 | export declare const getIpfsKeyFromPrivateKey: (privateKeyBase64: string) => Promise>; 8 | export declare const getPublicKeyFromPrivateKey: (privateKeyBase64: string) => Promise; 9 | export declare const getPeerIdFromPrivateKey: (privateKeyBase64: string) => Promise; 10 | export declare const getPeerIdFromPublicKey: (publicKeyBase64: string) => Promise; 11 | export declare const getPeerIdFromPublicKeyBuffer: (publicKeyBuffer: Uint8Array) => Promise; 12 | export declare const convertBase58IpnsNameToBase36Cid: (ipnsName: string) => string; 13 | export declare function convertBase32ToBase58btc(base32String: string): string; 14 | export declare const getPlebbitAddressFromPublicKeySync: (publicKeyBase64: string) => string; 15 | -------------------------------------------------------------------------------- /dist/browser/signer/util.d.ts: -------------------------------------------------------------------------------- 1 | import PeerId from "peer-id"; 2 | export declare const generatePrivateKey: () => Promise; 3 | export declare const getPlebbitAddressFromPrivateKey: (privateKeyBase64: string) => Promise; 4 | export declare const getPlebbitAddressFromPublicKey: (publicKeyBase64: string) => Promise; 5 | export declare const getPlebbitAddressFromPublicKeyBuffer: (publicKeyBuffer: Uint8Array) => Promise; 6 | export declare const getBufferedPlebbitAddressFromPublicKey: (publicKeyBase64: string) => Promise>; 7 | export declare const getIpfsKeyFromPrivateKey: (privateKeyBase64: string) => Promise>; 8 | export declare const getPublicKeyFromPrivateKey: (privateKeyBase64: string) => Promise; 9 | export declare const getPeerIdFromPrivateKey: (privateKeyBase64: string) => Promise; 10 | export declare const getPeerIdFromPublicKey: (publicKeyBase64: string) => Promise; 11 | export declare const getPeerIdFromPublicKeyBuffer: (publicKeyBuffer: Uint8Array) => Promise; 12 | export declare const convertBase58IpnsNameToBase36Cid: (ipnsName: string) => string; 13 | export declare function convertBase32ToBase58btc(base32String: string): string; 14 | export declare const getPlebbitAddressFromPublicKeySync: (publicKeyBase64: string) => string; 15 | --------------------------------------------------------------------------------