@pkcprotocol/pkc-js 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (843) hide show
  1. package/LICENSE +339 -0
  2. package/README.md +1663 -0
  3. package/dist/browser/challenges.d.ts +1 -0
  4. package/dist/browser/challenges.js +2 -0
  5. package/dist/browser/challenges.js.map +1 -0
  6. package/dist/browser/clients/base-client-manager.d.ts +126 -0
  7. package/dist/browser/clients/base-client-manager.js +673 -0
  8. package/dist/browser/clients/base-client-manager.js.map +1 -0
  9. package/dist/browser/clients/name-resolver-client.d.ts +8 -0
  10. package/dist/browser/clients/name-resolver-client.js +10 -0
  11. package/dist/browser/clients/name-resolver-client.js.map +1 -0
  12. package/dist/browser/clients/pkc-typed-emitter.d.ts +9 -0
  13. package/dist/browser/clients/pkc-typed-emitter.js +52 -0
  14. package/dist/browser/clients/pkc-typed-emitter.js.map +1 -0
  15. package/dist/browser/clients/rpc-client/decode-rpc-response-util.d.ts +8 -0
  16. package/dist/browser/clients/rpc-client/decode-rpc-response-util.js +53 -0
  17. package/dist/browser/clients/rpc-client/decode-rpc-response-util.js.map +1 -0
  18. package/dist/browser/clients/rpc-client/pkc-rpc-client.d.ts +68 -0
  19. package/dist/browser/clients/rpc-client/pkc-rpc-client.js +404 -0
  20. package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -0
  21. package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +147 -0
  22. package/dist/browser/clients/rpc-client/rpc-schema-util.js +11 -0
  23. package/dist/browser/clients/rpc-client/rpc-schema-util.js.map +1 -0
  24. package/dist/browser/clients/rpc-client/schema.d.ts +433 -0
  25. package/dist/browser/clients/rpc-client/schema.js +49 -0
  26. package/dist/browser/clients/rpc-client/schema.js.map +1 -0
  27. package/dist/browser/clients/rpc-client/types.d.ts +8 -0
  28. package/dist/browser/clients/rpc-client/types.js +2 -0
  29. package/dist/browser/clients/rpc-client/types.js.map +1 -0
  30. package/dist/browser/community/community-client-manager.d.ts +60 -0
  31. package/dist/browser/community/community-client-manager.js +717 -0
  32. package/dist/browser/community/community-client-manager.js.map +1 -0
  33. package/dist/browser/community/community-clients.d.ts +18 -0
  34. package/dist/browser/community/community-clients.js +12 -0
  35. package/dist/browser/community/community-clients.js.map +1 -0
  36. package/dist/browser/community/community-wire.d.ts +20 -0
  37. package/dist/browser/community/community-wire.js +38 -0
  38. package/dist/browser/community/community-wire.js.map +1 -0
  39. package/dist/browser/community/remote-community.d.ts +110 -0
  40. package/dist/browser/community/remote-community.js +555 -0
  41. package/dist/browser/community/remote-community.js.map +1 -0
  42. package/dist/browser/community/rpc-local-community.d.ts +41 -0
  43. package/dist/browser/community/rpc-local-community.js +289 -0
  44. package/dist/browser/community/rpc-local-community.js.map +1 -0
  45. package/dist/browser/community/rpc-remote-community.d.ts +18 -0
  46. package/dist/browser/community/rpc-remote-community.js +286 -0
  47. package/dist/browser/community/rpc-remote-community.js.map +1 -0
  48. package/dist/browser/community/schema.d.ts +4217 -0
  49. package/dist/browser/community/schema.js +289 -0
  50. package/dist/browser/community/schema.js.map +1 -0
  51. package/dist/browser/community/types.d.ts +135 -0
  52. package/dist/browser/community/types.js +2 -0
  53. package/dist/browser/community/types.js.map +1 -0
  54. package/dist/browser/constants.d.ts +6 -0
  55. package/dist/browser/constants.js +9 -0
  56. package/dist/browser/constants.js.map +1 -0
  57. package/dist/browser/decorator-util.d.ts +1 -0
  58. package/dist/browser/decorator-util.js +35 -0
  59. package/dist/browser/decorator-util.js.map +1 -0
  60. package/dist/browser/errors.d.ts +343 -0
  61. package/dist/browser/errors.js +358 -0
  62. package/dist/browser/errors.js.map +1 -0
  63. package/dist/browser/general-util/limited-set.d.ts +15 -0
  64. package/dist/browser/general-util/limited-set.js +66 -0
  65. package/dist/browser/general-util/limited-set.js.map +1 -0
  66. package/dist/browser/generated-version.d.ts +1 -0
  67. package/dist/browser/generated-version.js +3 -0
  68. package/dist/browser/generated-version.js.map +1 -0
  69. package/dist/browser/generic-state-client.d.ts +6 -0
  70. package/dist/browser/generic-state-client.js +11 -0
  71. package/dist/browser/generic-state-client.js.map +1 -0
  72. package/dist/browser/helia/helia-for-pkc.d.ts +3 -0
  73. package/dist/browser/helia/helia-for-pkc.js +255 -0
  74. package/dist/browser/helia/helia-for-pkc.js.map +1 -0
  75. package/dist/browser/helia/ipns-over-pubsub-with-fetch.d.ts +36 -0
  76. package/dist/browser/helia/ipns-over-pubsub-with-fetch.js +229 -0
  77. package/dist/browser/helia/ipns-over-pubsub-with-fetch.js.map +1 -0
  78. package/dist/browser/helia/libp2pjsClient.d.ts +27 -0
  79. package/dist/browser/helia/libp2pjsClient.js +15 -0
  80. package/dist/browser/helia/libp2pjsClient.js.map +1 -0
  81. package/dist/browser/helia/types.d.ts +19 -0
  82. package/dist/browser/helia/types.js +2 -0
  83. package/dist/browser/helia/types.js.map +1 -0
  84. package/dist/browser/helia/util.d.ts +13 -0
  85. package/dist/browser/helia/util.js +98 -0
  86. package/dist/browser/helia/util.js.map +1 -0
  87. package/dist/browser/index.d.ts +244 -0
  88. package/dist/browser/index.js +36 -0
  89. package/dist/browser/index.js.map +1 -0
  90. package/dist/browser/logger.d.ts +12 -0
  91. package/dist/browser/logger.js +11 -0
  92. package/dist/browser/logger.js.map +1 -0
  93. package/dist/browser/pages/pages-client-manager.d.ts +159 -0
  94. package/dist/browser/pages/pages-client-manager.js +334 -0
  95. package/dist/browser/pages/pages-client-manager.js.map +1 -0
  96. package/dist/browser/pages/pages-clients.d.ts +11 -0
  97. package/dist/browser/pages/pages-clients.js +10 -0
  98. package/dist/browser/pages/pages-clients.js.map +1 -0
  99. package/dist/browser/pages/pages.d.ts +107 -0
  100. package/dist/browser/pages/pages.js +262 -0
  101. package/dist/browser/pages/pages.js.map +1 -0
  102. package/dist/browser/pages/schema-util.d.ts +3 -0
  103. package/dist/browser/pages/schema-util.js +3 -0
  104. package/dist/browser/pages/schema-util.js.map +1 -0
  105. package/dist/browser/pages/schema.d.ts +719 -0
  106. package/dist/browser/pages/schema.js +32 -0
  107. package/dist/browser/pages/schema.js.map +1 -0
  108. package/dist/browser/pages/types.d.ts +44 -0
  109. package/dist/browser/pages/types.js +2 -0
  110. package/dist/browser/pages/types.js.map +1 -0
  111. package/dist/browser/pages/util.d.ts +56 -0
  112. package/dist/browser/pages/util.js +446 -0
  113. package/dist/browser/pages/util.js.map +1 -0
  114. package/dist/browser/pkc/pkc-client-manager.d.ts +44 -0
  115. package/dist/browser/pkc/pkc-client-manager.js +156 -0
  116. package/dist/browser/pkc/pkc-client-manager.js.map +1 -0
  117. package/dist/browser/pkc/pkc-clients.d.ts +11 -0
  118. package/dist/browser/pkc/pkc-clients.js +8 -0
  119. package/dist/browser/pkc/pkc-clients.js.map +1 -0
  120. package/dist/browser/pkc/pkc-with-rpc-client.d.ts +19 -0
  121. package/dist/browser/pkc/pkc-with-rpc-client.js +128 -0
  122. package/dist/browser/pkc/pkc-with-rpc-client.js.map +1 -0
  123. package/dist/browser/pkc/pkc.d.ts +137 -0
  124. package/dist/browser/pkc/pkc.js +888 -0
  125. package/dist/browser/pkc/pkc.js.map +1 -0
  126. package/dist/browser/pkc/tracked-instance-registry-util.d.ts +44 -0
  127. package/dist/browser/pkc/tracked-instance-registry-util.js +106 -0
  128. package/dist/browser/pkc/tracked-instance-registry-util.js.map +1 -0
  129. package/dist/browser/pkc/tracked-instance-registry.d.ts +18 -0
  130. package/dist/browser/pkc/tracked-instance-registry.js +134 -0
  131. package/dist/browser/pkc/tracked-instance-registry.js.map +1 -0
  132. package/dist/browser/pkc-error.d.ts +65 -0
  133. package/dist/browser/pkc-error.js +137 -0
  134. package/dist/browser/pkc-error.js.map +1 -0
  135. package/dist/browser/publications/comment/comment-client-manager.d.ts +86 -0
  136. package/dist/browser/publications/comment/comment-client-manager.js +908 -0
  137. package/dist/browser/publications/comment/comment-client-manager.js.map +1 -0
  138. package/dist/browser/publications/comment/comment-clients.d.ts +19 -0
  139. package/dist/browser/publications/comment/comment-clients.js +12 -0
  140. package/dist/browser/publications/comment/comment-clients.js.map +1 -0
  141. package/dist/browser/publications/comment/comment-util.d.ts +10 -0
  142. package/dist/browser/publications/comment/comment-util.js +202 -0
  143. package/dist/browser/publications/comment/comment-util.js.map +1 -0
  144. package/dist/browser/publications/comment/comment.d.ts +147 -0
  145. package/dist/browser/publications/comment/comment.js +1044 -0
  146. package/dist/browser/publications/comment/comment.js.map +1 -0
  147. package/dist/browser/publications/comment/schema.d.ts +1237 -0
  148. package/dist/browser/publications/comment/schema.js +184 -0
  149. package/dist/browser/publications/comment/schema.js.map +1 -0
  150. package/dist/browser/publications/comment/types.d.ts +100 -0
  151. package/dist/browser/publications/comment/types.js +2 -0
  152. package/dist/browser/publications/comment/types.js.map +1 -0
  153. package/dist/browser/publications/comment-edit/comment-edit.d.ts +41 -0
  154. package/dist/browser/publications/comment-edit/comment-edit.js +63 -0
  155. package/dist/browser/publications/comment-edit/comment-edit.js.map +1 -0
  156. package/dist/browser/publications/comment-edit/schema.d.ts +295 -0
  157. package/dist/browser/publications/comment-edit/schema.js +55 -0
  158. package/dist/browser/publications/comment-edit/schema.js.map +1 -0
  159. package/dist/browser/publications/comment-edit/types.d.ts +25 -0
  160. package/dist/browser/publications/comment-edit/types.js +2 -0
  161. package/dist/browser/publications/comment-edit/types.js.map +1 -0
  162. package/dist/browser/publications/comment-moderation/comment-moderation.d.ts +36 -0
  163. package/dist/browser/publications/comment-moderation/comment-moderation.js +53 -0
  164. package/dist/browser/publications/comment-moderation/comment-moderation.js.map +1 -0
  165. package/dist/browser/publications/comment-moderation/schema.d.ts +315 -0
  166. package/dist/browser/publications/comment-moderation/schema.js +62 -0
  167. package/dist/browser/publications/comment-moderation/schema.js.map +1 -0
  168. package/dist/browser/publications/comment-moderation/types.d.ts +22 -0
  169. package/dist/browser/publications/comment-moderation/types.js +2 -0
  170. package/dist/browser/publications/comment-moderation/types.js.map +1 -0
  171. package/dist/browser/publications/community-edit/community-edit.d.ts +35 -0
  172. package/dist/browser/publications/community-edit/community-edit.js +50 -0
  173. package/dist/browser/publications/community-edit/community-edit.js.map +1 -0
  174. package/dist/browser/publications/community-edit/schema.d.ts +467 -0
  175. package/dist/browser/publications/community-edit/schema.js +36 -0
  176. package/dist/browser/publications/community-edit/schema.js.map +1 -0
  177. package/dist/browser/publications/community-edit/types.d.ts +19 -0
  178. package/dist/browser/publications/community-edit/types.js +2 -0
  179. package/dist/browser/publications/community-edit/types.js.map +1 -0
  180. package/dist/browser/publications/publication-author.d.ts +22 -0
  181. package/dist/browser/publications/publication-author.js +66 -0
  182. package/dist/browser/publications/publication-author.js.map +1 -0
  183. package/dist/browser/publications/publication-client-manager.d.ts +62 -0
  184. package/dist/browser/publications/publication-client-manager.js +257 -0
  185. package/dist/browser/publications/publication-client-manager.js.map +1 -0
  186. package/dist/browser/publications/publication-clients.d.ts +19 -0
  187. package/dist/browser/publications/publication-clients.js +12 -0
  188. package/dist/browser/publications/publication-clients.js.map +1 -0
  189. package/dist/browser/publications/publication-community.d.ts +55 -0
  190. package/dist/browser/publications/publication-community.js +87 -0
  191. package/dist/browser/publications/publication-community.js.map +1 -0
  192. package/dist/browser/publications/publication.d.ts +120 -0
  193. package/dist/browser/publications/publication.js +950 -0
  194. package/dist/browser/publications/publication.js.map +1 -0
  195. package/dist/browser/publications/types.d.ts +26 -0
  196. package/dist/browser/publications/types.js +2 -0
  197. package/dist/browser/publications/types.js.map +1 -0
  198. package/dist/browser/publications/vote/schema.d.ts +150 -0
  199. package/dist/browser/publications/vote/schema.js +44 -0
  200. package/dist/browser/publications/vote/schema.js.map +1 -0
  201. package/dist/browser/publications/vote/types.d.ts +21 -0
  202. package/dist/browser/publications/vote/types.js +2 -0
  203. package/dist/browser/publications/vote/types.js.map +1 -0
  204. package/dist/browser/publications/vote/vote.d.ts +36 -0
  205. package/dist/browser/publications/vote/vote.js +49 -0
  206. package/dist/browser/publications/vote/vote.js.map +1 -0
  207. package/dist/browser/pubsub-messages/schema.d.ts +964 -0
  208. package/dist/browser/pubsub-messages/schema.js +98 -0
  209. package/dist/browser/pubsub-messages/schema.js.map +1 -0
  210. package/dist/browser/pubsub-messages/types.d.ts +81 -0
  211. package/dist/browser/pubsub-messages/types.js +2 -0
  212. package/dist/browser/pubsub-messages/types.js.map +1 -0
  213. package/dist/browser/rpc/src/index.d.ts +483 -0
  214. package/dist/browser/rpc/src/index.js +1267 -0
  215. package/dist/browser/rpc/src/index.js.map +1 -0
  216. package/dist/browser/rpc/src/json-rpc-util.d.ts +1 -0
  217. package/dist/browser/rpc/src/json-rpc-util.js +19 -0
  218. package/dist/browser/rpc/src/json-rpc-util.js.map +1 -0
  219. package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +132 -0
  220. package/dist/browser/rpc/src/lib/pkc-js/index.js +29 -0
  221. package/dist/browser/rpc/src/lib/pkc-js/index.js.map +1 -0
  222. package/dist/browser/rpc/src/lib/pkc-js/pkc-js-mock.d.ts +1 -0
  223. package/dist/browser/rpc/src/lib/pkc-js/pkc-js-mock.js +472 -0
  224. package/dist/browser/rpc/src/lib/pkc-js/pkc-js-mock.js.map +1 -0
  225. package/dist/browser/rpc/src/schema.d.ts +843 -0
  226. package/dist/browser/rpc/src/schema.js +28 -0
  227. package/dist/browser/rpc/src/schema.js.map +1 -0
  228. package/dist/browser/rpc/src/types.d.ts +24 -0
  229. package/dist/browser/rpc/src/types.js +2 -0
  230. package/dist/browser/rpc/src/types.js.map +1 -0
  231. package/dist/browser/rpc/src/utils.d.ts +7 -0
  232. package/dist/browser/rpc/src/utils.js +58 -0
  233. package/dist/browser/rpc/src/utils.js.map +1 -0
  234. package/dist/browser/runtime/browser/community/challenges/index.d.ts +6 -0
  235. package/dist/browser/runtime/browser/community/challenges/index.js +7 -0
  236. package/dist/browser/runtime/browser/community/challenges/index.js.map +1 -0
  237. package/dist/browser/runtime/browser/community/local-community.d.ts +3 -0
  238. package/dist/browser/runtime/browser/community/local-community.js +6 -0
  239. package/dist/browser/runtime/browser/community/local-community.js.map +1 -0
  240. package/dist/browser/runtime/browser/db-handler.d.ts +4 -0
  241. package/dist/browser/runtime/browser/db-handler.js +8 -0
  242. package/dist/browser/runtime/browser/db-handler.js.map +1 -0
  243. package/dist/browser/runtime/browser/localforage-lru.d.ts +15 -0
  244. package/dist/browser/runtime/browser/localforage-lru.js +140 -0
  245. package/dist/browser/runtime/browser/localforage-lru.js.map +1 -0
  246. package/dist/browser/runtime/browser/lru-storage.d.ts +14 -0
  247. package/dist/browser/runtime/browser/lru-storage.js +34 -0
  248. package/dist/browser/runtime/browser/lru-storage.js.map +1 -0
  249. package/dist/browser/runtime/browser/native-functions.d.ts +3 -0
  250. package/dist/browser/runtime/browser/native-functions.js +6 -0
  251. package/dist/browser/runtime/browser/native-functions.js.map +1 -0
  252. package/dist/browser/runtime/browser/polyfill.d.ts +3 -0
  253. package/dist/browser/runtime/browser/polyfill.js +37 -0
  254. package/dist/browser/runtime/browser/polyfill.js.map +1 -0
  255. package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts +1 -0
  256. package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js +4 -0
  257. package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
  258. package/dist/browser/runtime/browser/storage.d.ts +13 -0
  259. package/dist/browser/runtime/browser/storage.js +37 -0
  260. package/dist/browser/runtime/browser/storage.js.map +1 -0
  261. package/dist/browser/runtime/browser/util.d.ts +14 -0
  262. package/dist/browser/runtime/browser/util.js +61 -0
  263. package/dist/browser/runtime/browser/util.js.map +1 -0
  264. package/dist/browser/runtime/node/address-rewriter-db.d.ts +31 -0
  265. package/dist/browser/runtime/node/address-rewriter-db.js +156 -0
  266. package/dist/browser/runtime/node/address-rewriter-db.js.map +1 -0
  267. package/dist/browser/runtime/node/addresses-rewriter-proxy-server.d.ts +45 -0
  268. package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js +493 -0
  269. package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js.map +1 -0
  270. package/dist/browser/runtime/node/community/challenges/exclude/exclude.d.ts +8 -0
  271. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +280 -0
  272. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -0
  273. package/dist/browser/runtime/node/community/challenges/exclude/index.d.ts +3 -0
  274. package/dist/browser/runtime/node/community/challenges/exclude/index.js +4 -0
  275. package/dist/browser/runtime/node/community/challenges/exclude/index.js.map +1 -0
  276. package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.d.ts +5 -0
  277. package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.js +127 -0
  278. package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.js.map +1 -0
  279. package/dist/browser/runtime/node/community/challenges/exclude/utils.d.ts +13 -0
  280. package/dist/browser/runtime/node/community/challenges/exclude/utils.js +52 -0
  281. package/dist/browser/runtime/node/community/challenges/exclude/utils.js.map +1 -0
  282. package/dist/browser/runtime/node/community/challenges/index.d.ts +32 -0
  283. package/dist/browser/runtime/node/community/challenges/index.js +307 -0
  284. package/dist/browser/runtime/node/community/challenges/index.js.map +1 -0
  285. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.d.ts +5 -0
  286. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +118 -0
  287. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -0
  288. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/fail.d.ts +5 -0
  289. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/fail.js +26 -0
  290. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/fail.js.map +1 -0
  291. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.d.ts +5 -0
  292. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.js +135 -0
  293. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.js.map +1 -0
  294. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/question.d.ts +5 -0
  295. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/question.js +66 -0
  296. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/question.js.map +1 -0
  297. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/text-math.d.ts +5 -0
  298. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/text-math.js +61 -0
  299. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/text-math.js.map +1 -0
  300. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.d.ts +5 -0
  301. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +118 -0
  302. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -0
  303. package/dist/browser/runtime/node/community/db-handler-types.d.ts +19 -0
  304. package/dist/browser/runtime/node/community/db-handler-types.js +2 -0
  305. package/dist/browser/runtime/node/community/db-handler-types.js.map +1 -0
  306. package/dist/browser/runtime/node/community/db-handler.d.ts +226 -0
  307. package/dist/browser/runtime/node/community/db-handler.js +2462 -0
  308. package/dist/browser/runtime/node/community/db-handler.js.map +1 -0
  309. package/dist/browser/runtime/node/community/db-row-parser.d.ts +19 -0
  310. package/dist/browser/runtime/node/community/db-row-parser.js +40 -0
  311. package/dist/browser/runtime/node/community/db-row-parser.js.map +1 -0
  312. package/dist/browser/runtime/node/community/keyv-better-sqlite3.d.ts +68 -0
  313. package/dist/browser/runtime/node/community/keyv-better-sqlite3.js +251 -0
  314. package/dist/browser/runtime/node/community/keyv-better-sqlite3.js.map +1 -0
  315. package/dist/browser/runtime/node/community/local-community.d.ts +129 -0
  316. package/dist/browser/runtime/node/community/local-community.js +2978 -0
  317. package/dist/browser/runtime/node/community/local-community.js.map +1 -0
  318. package/dist/browser/runtime/node/community/page-generator.d.ts +433 -0
  319. package/dist/browser/runtime/node/community/page-generator.js +441 -0
  320. package/dist/browser/runtime/node/community/page-generator.js.map +1 -0
  321. package/dist/browser/runtime/node/lru-storage.d.ts +14 -0
  322. package/dist/browser/runtime/node/lru-storage.js +40 -0
  323. package/dist/browser/runtime/node/lru-storage.js.map +1 -0
  324. package/dist/browser/runtime/node/native-functions.d.ts +3 -0
  325. package/dist/browser/runtime/node/native-functions.js +7 -0
  326. package/dist/browser/runtime/node/native-functions.js.map +1 -0
  327. package/dist/browser/runtime/node/polyfill.d.ts +3 -0
  328. package/dist/browser/runtime/node/polyfill.js +20 -0
  329. package/dist/browser/runtime/node/polyfill.js.map +1 -0
  330. package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts +4 -0
  331. package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js +240 -0
  332. package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
  333. package/dist/browser/runtime/node/sqlite-lru-cache.d.ts +52 -0
  334. package/dist/browser/runtime/node/sqlite-lru-cache.js +127 -0
  335. package/dist/browser/runtime/node/sqlite-lru-cache.js.map +1 -0
  336. package/dist/browser/runtime/node/storage.d.ts +14 -0
  337. package/dist/browser/runtime/node/storage.js +52 -0
  338. package/dist/browser/runtime/node/storage.js.map +1 -0
  339. package/dist/browser/runtime/node/test/helpers/hanging-runner.d.ts +1 -0
  340. package/dist/browser/runtime/node/test/helpers/hanging-runner.js +157 -0
  341. package/dist/browser/runtime/node/test/helpers/hanging-runner.js.map +1 -0
  342. package/dist/browser/runtime/node/test/helpers/run-hanging-node.d.ts +7 -0
  343. package/dist/browser/runtime/node/test/helpers/run-hanging-node.js +68 -0
  344. package/dist/browser/runtime/node/test/helpers/run-hanging-node.js.map +1 -0
  345. package/dist/browser/runtime/node/test/mock-http-router.d.ts +54 -0
  346. package/dist/browser/runtime/node/test/mock-http-router.js +397 -0
  347. package/dist/browser/runtime/node/test/mock-http-router.js.map +1 -0
  348. package/dist/browser/runtime/node/util.d.ts +43 -0
  349. package/dist/browser/runtime/node/util.js +384 -0
  350. package/dist/browser/runtime/node/util.js.map +1 -0
  351. package/dist/browser/schema/schema-util.d.ts +2751 -0
  352. package/dist/browser/schema/schema-util.js +562 -0
  353. package/dist/browser/schema/schema-util.js.map +1 -0
  354. package/dist/browser/schema/schema.d.ts +237 -0
  355. package/dist/browser/schema/schema.js +128 -0
  356. package/dist/browser/schema/schema.js.map +1 -0
  357. package/dist/browser/schema.d.ts +1142 -0
  358. package/dist/browser/schema.js +104 -0
  359. package/dist/browser/schema.js.map +1 -0
  360. package/dist/browser/signer/constants.d.ts +2 -0
  361. package/dist/browser/signer/constants.js +3 -0
  362. package/dist/browser/signer/constants.js.map +1 -0
  363. package/dist/browser/signer/encryption.d.ts +21 -0
  364. package/dist/browser/signer/encryption.js +122 -0
  365. package/dist/browser/signer/encryption.js.map +1 -0
  366. package/dist/browser/signer/index.d.ts +21 -0
  367. package/dist/browser/signer/index.js +49 -0
  368. package/dist/browser/signer/index.js.map +1 -0
  369. package/dist/browser/signer/signatures.d.ts +200 -0
  370. package/dist/browser/signer/signatures.js +594 -0
  371. package/dist/browser/signer/signatures.js.map +1 -0
  372. package/dist/browser/signer/types.d.ts +20 -0
  373. package/dist/browser/signer/types.js +2 -0
  374. package/dist/browser/signer/types.js.map +1 -0
  375. package/dist/browser/signer/util.d.ts +14 -0
  376. package/dist/browser/signer/util.js +156 -0
  377. package/dist/browser/signer/util.js.map +1 -0
  378. package/dist/browser/stats.d.ts +15 -0
  379. package/dist/browser/stats.js +64 -0
  380. package/dist/browser/stats.js.map +1 -0
  381. package/dist/browser/test/mock-ipfs-client.d.ts +34 -0
  382. package/dist/browser/test/mock-ipfs-client.js +208 -0
  383. package/dist/browser/test/mock-ipfs-client.js.map +1 -0
  384. package/dist/browser/test/node/hanging-test/scenarios/comment-publish-pending.scenario.d.ts +8 -0
  385. package/dist/browser/test/node/hanging-test/scenarios/comment-publish-pending.scenario.js +21 -0
  386. package/dist/browser/test/node/hanging-test/scenarios/comment-publish-pending.scenario.js.map +1 -0
  387. package/dist/browser/test/node/hanging-test/scenarios/comment-publish.scenario.d.ts +8 -0
  388. package/dist/browser/test/node/hanging-test/scenarios/comment-publish.scenario.js +19 -0
  389. package/dist/browser/test/node/hanging-test/scenarios/comment-publish.scenario.js.map +1 -0
  390. package/dist/browser/test/node/hanging-test/scenarios/comment-update.scenario.d.ts +8 -0
  391. package/dist/browser/test/node/hanging-test/scenarios/comment-update.scenario.js +22 -0
  392. package/dist/browser/test/node/hanging-test/scenarios/comment-update.scenario.js.map +1 -0
  393. package/dist/browser/test/node/hanging-test/scenarios/community-start.scenario.d.ts +8 -0
  394. package/dist/browser/test/node/hanging-test/scenarios/community-start.scenario.js +23 -0
  395. package/dist/browser/test/node/hanging-test/scenarios/community-start.scenario.js.map +1 -0
  396. package/dist/browser/test/node/hanging-test/scenarios/community-update.scenario.d.ts +8 -0
  397. package/dist/browser/test/node/hanging-test/scenarios/community-update.scenario.js +21 -0
  398. package/dist/browser/test/node/hanging-test/scenarios/community-update.scenario.js.map +1 -0
  399. package/dist/browser/test/node/hanging-test/scenarios/destroy-only.scenario.d.ts +7 -0
  400. package/dist/browser/test/node/hanging-test/scenarios/destroy-only.scenario.js +15 -0
  401. package/dist/browser/test/node/hanging-test/scenarios/destroy-only.scenario.js.map +1 -0
  402. package/dist/browser/test/node/hanging-test/scenarios/hanging-test-util.d.ts +30 -0
  403. package/dist/browser/test/node/hanging-test/scenarios/hanging-test-util.js +46 -0
  404. package/dist/browser/test/node/hanging-test/scenarios/hanging-test-util.js.map +1 -0
  405. package/dist/browser/test/test-util.d.ts +1019 -0
  406. package/dist/browser/test/test-util.js +1886 -0
  407. package/dist/browser/test/test-util.js.map +1 -0
  408. package/dist/browser/types.d.ts +165 -0
  409. package/dist/browser/types.js +2 -0
  410. package/dist/browser/types.js.map +1 -0
  411. package/dist/browser/util/inflight-fetch-manager.d.ts +11 -0
  412. package/dist/browser/util/inflight-fetch-manager.js +41 -0
  413. package/dist/browser/util/inflight-fetch-manager.js.map +1 -0
  414. package/dist/browser/util.d.ts +120 -0
  415. package/dist/browser/util.js +816 -0
  416. package/dist/browser/util.js.map +1 -0
  417. package/dist/browser/version.d.ts +7 -0
  418. package/dist/browser/version.js +12 -0
  419. package/dist/browser/version.js.map +1 -0
  420. package/dist/browser/zod-error-map.d.ts +1 -0
  421. package/dist/browser/zod-error-map.js +10 -0
  422. package/dist/browser/zod-error-map.js.map +1 -0
  423. package/dist/node/challenges.d.ts +1 -0
  424. package/dist/node/challenges.js +2 -0
  425. package/dist/node/challenges.js.map +1 -0
  426. package/dist/node/clients/base-client-manager.d.ts +126 -0
  427. package/dist/node/clients/base-client-manager.js +673 -0
  428. package/dist/node/clients/base-client-manager.js.map +1 -0
  429. package/dist/node/clients/name-resolver-client.d.ts +8 -0
  430. package/dist/node/clients/name-resolver-client.js +10 -0
  431. package/dist/node/clients/name-resolver-client.js.map +1 -0
  432. package/dist/node/clients/pkc-typed-emitter.d.ts +9 -0
  433. package/dist/node/clients/pkc-typed-emitter.js +52 -0
  434. package/dist/node/clients/pkc-typed-emitter.js.map +1 -0
  435. package/dist/node/clients/rpc-client/decode-rpc-response-util.d.ts +8 -0
  436. package/dist/node/clients/rpc-client/decode-rpc-response-util.js +53 -0
  437. package/dist/node/clients/rpc-client/decode-rpc-response-util.js.map +1 -0
  438. package/dist/node/clients/rpc-client/pkc-rpc-client.d.ts +68 -0
  439. package/dist/node/clients/rpc-client/pkc-rpc-client.js +404 -0
  440. package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -0
  441. package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +147 -0
  442. package/dist/node/clients/rpc-client/rpc-schema-util.js +11 -0
  443. package/dist/node/clients/rpc-client/rpc-schema-util.js.map +1 -0
  444. package/dist/node/clients/rpc-client/schema.d.ts +433 -0
  445. package/dist/node/clients/rpc-client/schema.js +49 -0
  446. package/dist/node/clients/rpc-client/schema.js.map +1 -0
  447. package/dist/node/clients/rpc-client/types.d.ts +8 -0
  448. package/dist/node/clients/rpc-client/types.js +2 -0
  449. package/dist/node/clients/rpc-client/types.js.map +1 -0
  450. package/dist/node/community/community-client-manager.d.ts +60 -0
  451. package/dist/node/community/community-client-manager.js +717 -0
  452. package/dist/node/community/community-client-manager.js.map +1 -0
  453. package/dist/node/community/community-clients.d.ts +18 -0
  454. package/dist/node/community/community-clients.js +12 -0
  455. package/dist/node/community/community-clients.js.map +1 -0
  456. package/dist/node/community/community-wire.d.ts +20 -0
  457. package/dist/node/community/community-wire.js +38 -0
  458. package/dist/node/community/community-wire.js.map +1 -0
  459. package/dist/node/community/remote-community.d.ts +110 -0
  460. package/dist/node/community/remote-community.js +555 -0
  461. package/dist/node/community/remote-community.js.map +1 -0
  462. package/dist/node/community/rpc-local-community.d.ts +41 -0
  463. package/dist/node/community/rpc-local-community.js +289 -0
  464. package/dist/node/community/rpc-local-community.js.map +1 -0
  465. package/dist/node/community/rpc-remote-community.d.ts +18 -0
  466. package/dist/node/community/rpc-remote-community.js +286 -0
  467. package/dist/node/community/rpc-remote-community.js.map +1 -0
  468. package/dist/node/community/schema.d.ts +4217 -0
  469. package/dist/node/community/schema.js +289 -0
  470. package/dist/node/community/schema.js.map +1 -0
  471. package/dist/node/community/types.d.ts +135 -0
  472. package/dist/node/community/types.js +2 -0
  473. package/dist/node/community/types.js.map +1 -0
  474. package/dist/node/constants.d.ts +6 -0
  475. package/dist/node/constants.js +9 -0
  476. package/dist/node/constants.js.map +1 -0
  477. package/dist/node/decorator-util.d.ts +1 -0
  478. package/dist/node/decorator-util.js +35 -0
  479. package/dist/node/decorator-util.js.map +1 -0
  480. package/dist/node/errors.d.ts +343 -0
  481. package/dist/node/errors.js +358 -0
  482. package/dist/node/errors.js.map +1 -0
  483. package/dist/node/general-util/limited-set.d.ts +15 -0
  484. package/dist/node/general-util/limited-set.js +66 -0
  485. package/dist/node/general-util/limited-set.js.map +1 -0
  486. package/dist/node/generated-version.d.ts +1 -0
  487. package/dist/node/generated-version.js +3 -0
  488. package/dist/node/generated-version.js.map +1 -0
  489. package/dist/node/generic-state-client.d.ts +6 -0
  490. package/dist/node/generic-state-client.js +11 -0
  491. package/dist/node/generic-state-client.js.map +1 -0
  492. package/dist/node/helia/helia-for-pkc.d.ts +3 -0
  493. package/dist/node/helia/helia-for-pkc.js +255 -0
  494. package/dist/node/helia/helia-for-pkc.js.map +1 -0
  495. package/dist/node/helia/ipns-over-pubsub-with-fetch.d.ts +36 -0
  496. package/dist/node/helia/ipns-over-pubsub-with-fetch.js +229 -0
  497. package/dist/node/helia/ipns-over-pubsub-with-fetch.js.map +1 -0
  498. package/dist/node/helia/libp2pjsClient.d.ts +27 -0
  499. package/dist/node/helia/libp2pjsClient.js +15 -0
  500. package/dist/node/helia/libp2pjsClient.js.map +1 -0
  501. package/dist/node/helia/types.d.ts +19 -0
  502. package/dist/node/helia/types.js +2 -0
  503. package/dist/node/helia/types.js.map +1 -0
  504. package/dist/node/helia/util.d.ts +13 -0
  505. package/dist/node/helia/util.js +98 -0
  506. package/dist/node/helia/util.js.map +1 -0
  507. package/dist/node/index.d.ts +244 -0
  508. package/dist/node/index.js +36 -0
  509. package/dist/node/index.js.map +1 -0
  510. package/dist/node/logger.d.ts +12 -0
  511. package/dist/node/logger.js +11 -0
  512. package/dist/node/logger.js.map +1 -0
  513. package/dist/node/pages/pages-client-manager.d.ts +159 -0
  514. package/dist/node/pages/pages-client-manager.js +334 -0
  515. package/dist/node/pages/pages-client-manager.js.map +1 -0
  516. package/dist/node/pages/pages-clients.d.ts +11 -0
  517. package/dist/node/pages/pages-clients.js +10 -0
  518. package/dist/node/pages/pages-clients.js.map +1 -0
  519. package/dist/node/pages/pages.d.ts +107 -0
  520. package/dist/node/pages/pages.js +262 -0
  521. package/dist/node/pages/pages.js.map +1 -0
  522. package/dist/node/pages/schema-util.d.ts +3 -0
  523. package/dist/node/pages/schema-util.js +3 -0
  524. package/dist/node/pages/schema-util.js.map +1 -0
  525. package/dist/node/pages/schema.d.ts +719 -0
  526. package/dist/node/pages/schema.js +32 -0
  527. package/dist/node/pages/schema.js.map +1 -0
  528. package/dist/node/pages/types.d.ts +44 -0
  529. package/dist/node/pages/types.js +2 -0
  530. package/dist/node/pages/types.js.map +1 -0
  531. package/dist/node/pages/util.d.ts +56 -0
  532. package/dist/node/pages/util.js +446 -0
  533. package/dist/node/pages/util.js.map +1 -0
  534. package/dist/node/pkc/pkc-client-manager.d.ts +44 -0
  535. package/dist/node/pkc/pkc-client-manager.js +156 -0
  536. package/dist/node/pkc/pkc-client-manager.js.map +1 -0
  537. package/dist/node/pkc/pkc-clients.d.ts +11 -0
  538. package/dist/node/pkc/pkc-clients.js +8 -0
  539. package/dist/node/pkc/pkc-clients.js.map +1 -0
  540. package/dist/node/pkc/pkc-with-rpc-client.d.ts +19 -0
  541. package/dist/node/pkc/pkc-with-rpc-client.js +128 -0
  542. package/dist/node/pkc/pkc-with-rpc-client.js.map +1 -0
  543. package/dist/node/pkc/pkc.d.ts +137 -0
  544. package/dist/node/pkc/pkc.js +888 -0
  545. package/dist/node/pkc/pkc.js.map +1 -0
  546. package/dist/node/pkc/tracked-instance-registry-util.d.ts +44 -0
  547. package/dist/node/pkc/tracked-instance-registry-util.js +106 -0
  548. package/dist/node/pkc/tracked-instance-registry-util.js.map +1 -0
  549. package/dist/node/pkc/tracked-instance-registry.d.ts +18 -0
  550. package/dist/node/pkc/tracked-instance-registry.js +134 -0
  551. package/dist/node/pkc/tracked-instance-registry.js.map +1 -0
  552. package/dist/node/pkc-error.d.ts +65 -0
  553. package/dist/node/pkc-error.js +137 -0
  554. package/dist/node/pkc-error.js.map +1 -0
  555. package/dist/node/publications/comment/comment-client-manager.d.ts +86 -0
  556. package/dist/node/publications/comment/comment-client-manager.js +908 -0
  557. package/dist/node/publications/comment/comment-client-manager.js.map +1 -0
  558. package/dist/node/publications/comment/comment-clients.d.ts +19 -0
  559. package/dist/node/publications/comment/comment-clients.js +12 -0
  560. package/dist/node/publications/comment/comment-clients.js.map +1 -0
  561. package/dist/node/publications/comment/comment-util.d.ts +10 -0
  562. package/dist/node/publications/comment/comment-util.js +202 -0
  563. package/dist/node/publications/comment/comment-util.js.map +1 -0
  564. package/dist/node/publications/comment/comment.d.ts +147 -0
  565. package/dist/node/publications/comment/comment.js +1044 -0
  566. package/dist/node/publications/comment/comment.js.map +1 -0
  567. package/dist/node/publications/comment/schema.d.ts +1237 -0
  568. package/dist/node/publications/comment/schema.js +184 -0
  569. package/dist/node/publications/comment/schema.js.map +1 -0
  570. package/dist/node/publications/comment/types.d.ts +100 -0
  571. package/dist/node/publications/comment/types.js +2 -0
  572. package/dist/node/publications/comment/types.js.map +1 -0
  573. package/dist/node/publications/comment-edit/comment-edit.d.ts +41 -0
  574. package/dist/node/publications/comment-edit/comment-edit.js +63 -0
  575. package/dist/node/publications/comment-edit/comment-edit.js.map +1 -0
  576. package/dist/node/publications/comment-edit/schema.d.ts +295 -0
  577. package/dist/node/publications/comment-edit/schema.js +55 -0
  578. package/dist/node/publications/comment-edit/schema.js.map +1 -0
  579. package/dist/node/publications/comment-edit/types.d.ts +25 -0
  580. package/dist/node/publications/comment-edit/types.js +2 -0
  581. package/dist/node/publications/comment-edit/types.js.map +1 -0
  582. package/dist/node/publications/comment-moderation/comment-moderation.d.ts +36 -0
  583. package/dist/node/publications/comment-moderation/comment-moderation.js +53 -0
  584. package/dist/node/publications/comment-moderation/comment-moderation.js.map +1 -0
  585. package/dist/node/publications/comment-moderation/schema.d.ts +315 -0
  586. package/dist/node/publications/comment-moderation/schema.js +62 -0
  587. package/dist/node/publications/comment-moderation/schema.js.map +1 -0
  588. package/dist/node/publications/comment-moderation/types.d.ts +22 -0
  589. package/dist/node/publications/comment-moderation/types.js +2 -0
  590. package/dist/node/publications/comment-moderation/types.js.map +1 -0
  591. package/dist/node/publications/community-edit/community-edit.d.ts +35 -0
  592. package/dist/node/publications/community-edit/community-edit.js +50 -0
  593. package/dist/node/publications/community-edit/community-edit.js.map +1 -0
  594. package/dist/node/publications/community-edit/schema.d.ts +467 -0
  595. package/dist/node/publications/community-edit/schema.js +36 -0
  596. package/dist/node/publications/community-edit/schema.js.map +1 -0
  597. package/dist/node/publications/community-edit/types.d.ts +19 -0
  598. package/dist/node/publications/community-edit/types.js +2 -0
  599. package/dist/node/publications/community-edit/types.js.map +1 -0
  600. package/dist/node/publications/publication-author.d.ts +22 -0
  601. package/dist/node/publications/publication-author.js +66 -0
  602. package/dist/node/publications/publication-author.js.map +1 -0
  603. package/dist/node/publications/publication-client-manager.d.ts +62 -0
  604. package/dist/node/publications/publication-client-manager.js +257 -0
  605. package/dist/node/publications/publication-client-manager.js.map +1 -0
  606. package/dist/node/publications/publication-clients.d.ts +19 -0
  607. package/dist/node/publications/publication-clients.js +12 -0
  608. package/dist/node/publications/publication-clients.js.map +1 -0
  609. package/dist/node/publications/publication-community.d.ts +55 -0
  610. package/dist/node/publications/publication-community.js +87 -0
  611. package/dist/node/publications/publication-community.js.map +1 -0
  612. package/dist/node/publications/publication.d.ts +120 -0
  613. package/dist/node/publications/publication.js +950 -0
  614. package/dist/node/publications/publication.js.map +1 -0
  615. package/dist/node/publications/types.d.ts +26 -0
  616. package/dist/node/publications/types.js +2 -0
  617. package/dist/node/publications/types.js.map +1 -0
  618. package/dist/node/publications/vote/schema.d.ts +150 -0
  619. package/dist/node/publications/vote/schema.js +44 -0
  620. package/dist/node/publications/vote/schema.js.map +1 -0
  621. package/dist/node/publications/vote/types.d.ts +21 -0
  622. package/dist/node/publications/vote/types.js +2 -0
  623. package/dist/node/publications/vote/types.js.map +1 -0
  624. package/dist/node/publications/vote/vote.d.ts +36 -0
  625. package/dist/node/publications/vote/vote.js +49 -0
  626. package/dist/node/publications/vote/vote.js.map +1 -0
  627. package/dist/node/pubsub-messages/schema.d.ts +964 -0
  628. package/dist/node/pubsub-messages/schema.js +98 -0
  629. package/dist/node/pubsub-messages/schema.js.map +1 -0
  630. package/dist/node/pubsub-messages/types.d.ts +81 -0
  631. package/dist/node/pubsub-messages/types.js +2 -0
  632. package/dist/node/pubsub-messages/types.js.map +1 -0
  633. package/dist/node/rpc/src/index.d.ts +483 -0
  634. package/dist/node/rpc/src/index.js +1267 -0
  635. package/dist/node/rpc/src/index.js.map +1 -0
  636. package/dist/node/rpc/src/json-rpc-util.d.ts +1 -0
  637. package/dist/node/rpc/src/json-rpc-util.js +19 -0
  638. package/dist/node/rpc/src/json-rpc-util.js.map +1 -0
  639. package/dist/node/rpc/src/lib/pkc-js/index.d.ts +132 -0
  640. package/dist/node/rpc/src/lib/pkc-js/index.js +29 -0
  641. package/dist/node/rpc/src/lib/pkc-js/index.js.map +1 -0
  642. package/dist/node/rpc/src/lib/pkc-js/pkc-js-mock.d.ts +1 -0
  643. package/dist/node/rpc/src/lib/pkc-js/pkc-js-mock.js +472 -0
  644. package/dist/node/rpc/src/lib/pkc-js/pkc-js-mock.js.map +1 -0
  645. package/dist/node/rpc/src/schema.d.ts +843 -0
  646. package/dist/node/rpc/src/schema.js +28 -0
  647. package/dist/node/rpc/src/schema.js.map +1 -0
  648. package/dist/node/rpc/src/types.d.ts +24 -0
  649. package/dist/node/rpc/src/types.js +2 -0
  650. package/dist/node/rpc/src/types.js.map +1 -0
  651. package/dist/node/rpc/src/utils.d.ts +7 -0
  652. package/dist/node/rpc/src/utils.js +58 -0
  653. package/dist/node/rpc/src/utils.js.map +1 -0
  654. package/dist/node/runtime/browser/community/challenges/index.d.ts +6 -0
  655. package/dist/node/runtime/browser/community/challenges/index.js +7 -0
  656. package/dist/node/runtime/browser/community/challenges/index.js.map +1 -0
  657. package/dist/node/runtime/browser/community/local-community.d.ts +3 -0
  658. package/dist/node/runtime/browser/community/local-community.js +6 -0
  659. package/dist/node/runtime/browser/community/local-community.js.map +1 -0
  660. package/dist/node/runtime/browser/db-handler.d.ts +4 -0
  661. package/dist/node/runtime/browser/db-handler.js +8 -0
  662. package/dist/node/runtime/browser/db-handler.js.map +1 -0
  663. package/dist/node/runtime/browser/localforage-lru.d.ts +15 -0
  664. package/dist/node/runtime/browser/localforage-lru.js +140 -0
  665. package/dist/node/runtime/browser/localforage-lru.js.map +1 -0
  666. package/dist/node/runtime/browser/lru-storage.d.ts +14 -0
  667. package/dist/node/runtime/browser/lru-storage.js +34 -0
  668. package/dist/node/runtime/browser/lru-storage.js.map +1 -0
  669. package/dist/node/runtime/browser/native-functions.d.ts +3 -0
  670. package/dist/node/runtime/browser/native-functions.js +6 -0
  671. package/dist/node/runtime/browser/native-functions.js.map +1 -0
  672. package/dist/node/runtime/browser/polyfill.d.ts +3 -0
  673. package/dist/node/runtime/browser/polyfill.js +37 -0
  674. package/dist/node/runtime/browser/polyfill.js.map +1 -0
  675. package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts +1 -0
  676. package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js +4 -0
  677. package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
  678. package/dist/node/runtime/browser/storage.d.ts +13 -0
  679. package/dist/node/runtime/browser/storage.js +37 -0
  680. package/dist/node/runtime/browser/storage.js.map +1 -0
  681. package/dist/node/runtime/browser/util.d.ts +14 -0
  682. package/dist/node/runtime/browser/util.js +61 -0
  683. package/dist/node/runtime/browser/util.js.map +1 -0
  684. package/dist/node/runtime/node/address-rewriter-db.d.ts +31 -0
  685. package/dist/node/runtime/node/address-rewriter-db.js +156 -0
  686. package/dist/node/runtime/node/address-rewriter-db.js.map +1 -0
  687. package/dist/node/runtime/node/addresses-rewriter-proxy-server.d.ts +45 -0
  688. package/dist/node/runtime/node/addresses-rewriter-proxy-server.js +493 -0
  689. package/dist/node/runtime/node/addresses-rewriter-proxy-server.js.map +1 -0
  690. package/dist/node/runtime/node/community/challenges/exclude/exclude.d.ts +8 -0
  691. package/dist/node/runtime/node/community/challenges/exclude/exclude.js +280 -0
  692. package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -0
  693. package/dist/node/runtime/node/community/challenges/exclude/index.d.ts +3 -0
  694. package/dist/node/runtime/node/community/challenges/exclude/index.js +4 -0
  695. package/dist/node/runtime/node/community/challenges/exclude/index.js.map +1 -0
  696. package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.d.ts +5 -0
  697. package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.js +127 -0
  698. package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.js.map +1 -0
  699. package/dist/node/runtime/node/community/challenges/exclude/utils.d.ts +13 -0
  700. package/dist/node/runtime/node/community/challenges/exclude/utils.js +52 -0
  701. package/dist/node/runtime/node/community/challenges/exclude/utils.js.map +1 -0
  702. package/dist/node/runtime/node/community/challenges/index.d.ts +32 -0
  703. package/dist/node/runtime/node/community/challenges/index.js +307 -0
  704. package/dist/node/runtime/node/community/challenges/index.js.map +1 -0
  705. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.d.ts +5 -0
  706. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +118 -0
  707. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -0
  708. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/fail.d.ts +5 -0
  709. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/fail.js +26 -0
  710. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/fail.js.map +1 -0
  711. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.d.ts +5 -0
  712. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.js +135 -0
  713. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.js.map +1 -0
  714. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/question.d.ts +5 -0
  715. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/question.js +66 -0
  716. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/question.js.map +1 -0
  717. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/text-math.d.ts +5 -0
  718. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/text-math.js +61 -0
  719. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/text-math.js.map +1 -0
  720. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.d.ts +5 -0
  721. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +118 -0
  722. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -0
  723. package/dist/node/runtime/node/community/db-handler-types.d.ts +19 -0
  724. package/dist/node/runtime/node/community/db-handler-types.js +2 -0
  725. package/dist/node/runtime/node/community/db-handler-types.js.map +1 -0
  726. package/dist/node/runtime/node/community/db-handler.d.ts +226 -0
  727. package/dist/node/runtime/node/community/db-handler.js +2462 -0
  728. package/dist/node/runtime/node/community/db-handler.js.map +1 -0
  729. package/dist/node/runtime/node/community/db-row-parser.d.ts +19 -0
  730. package/dist/node/runtime/node/community/db-row-parser.js +40 -0
  731. package/dist/node/runtime/node/community/db-row-parser.js.map +1 -0
  732. package/dist/node/runtime/node/community/keyv-better-sqlite3.d.ts +68 -0
  733. package/dist/node/runtime/node/community/keyv-better-sqlite3.js +251 -0
  734. package/dist/node/runtime/node/community/keyv-better-sqlite3.js.map +1 -0
  735. package/dist/node/runtime/node/community/local-community.d.ts +129 -0
  736. package/dist/node/runtime/node/community/local-community.js +2978 -0
  737. package/dist/node/runtime/node/community/local-community.js.map +1 -0
  738. package/dist/node/runtime/node/community/page-generator.d.ts +433 -0
  739. package/dist/node/runtime/node/community/page-generator.js +441 -0
  740. package/dist/node/runtime/node/community/page-generator.js.map +1 -0
  741. package/dist/node/runtime/node/lru-storage.d.ts +14 -0
  742. package/dist/node/runtime/node/lru-storage.js +40 -0
  743. package/dist/node/runtime/node/lru-storage.js.map +1 -0
  744. package/dist/node/runtime/node/native-functions.d.ts +3 -0
  745. package/dist/node/runtime/node/native-functions.js +7 -0
  746. package/dist/node/runtime/node/native-functions.js.map +1 -0
  747. package/dist/node/runtime/node/polyfill.d.ts +3 -0
  748. package/dist/node/runtime/node/polyfill.js +20 -0
  749. package/dist/node/runtime/node/polyfill.js.map +1 -0
  750. package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts +4 -0
  751. package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js +240 -0
  752. package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
  753. package/dist/node/runtime/node/sqlite-lru-cache.d.ts +52 -0
  754. package/dist/node/runtime/node/sqlite-lru-cache.js +127 -0
  755. package/dist/node/runtime/node/sqlite-lru-cache.js.map +1 -0
  756. package/dist/node/runtime/node/storage.d.ts +14 -0
  757. package/dist/node/runtime/node/storage.js +52 -0
  758. package/dist/node/runtime/node/storage.js.map +1 -0
  759. package/dist/node/runtime/node/test/helpers/hanging-runner.d.ts +1 -0
  760. package/dist/node/runtime/node/test/helpers/hanging-runner.js +157 -0
  761. package/dist/node/runtime/node/test/helpers/hanging-runner.js.map +1 -0
  762. package/dist/node/runtime/node/test/helpers/run-hanging-node.d.ts +7 -0
  763. package/dist/node/runtime/node/test/helpers/run-hanging-node.js +68 -0
  764. package/dist/node/runtime/node/test/helpers/run-hanging-node.js.map +1 -0
  765. package/dist/node/runtime/node/test/mock-http-router.d.ts +54 -0
  766. package/dist/node/runtime/node/test/mock-http-router.js +397 -0
  767. package/dist/node/runtime/node/test/mock-http-router.js.map +1 -0
  768. package/dist/node/runtime/node/util.d.ts +43 -0
  769. package/dist/node/runtime/node/util.js +384 -0
  770. package/dist/node/runtime/node/util.js.map +1 -0
  771. package/dist/node/schema/schema-util.d.ts +2751 -0
  772. package/dist/node/schema/schema-util.js +562 -0
  773. package/dist/node/schema/schema-util.js.map +1 -0
  774. package/dist/node/schema/schema.d.ts +237 -0
  775. package/dist/node/schema/schema.js +128 -0
  776. package/dist/node/schema/schema.js.map +1 -0
  777. package/dist/node/schema.d.ts +1142 -0
  778. package/dist/node/schema.js +104 -0
  779. package/dist/node/schema.js.map +1 -0
  780. package/dist/node/signer/constants.d.ts +2 -0
  781. package/dist/node/signer/constants.js +3 -0
  782. package/dist/node/signer/constants.js.map +1 -0
  783. package/dist/node/signer/encryption.d.ts +21 -0
  784. package/dist/node/signer/encryption.js +122 -0
  785. package/dist/node/signer/encryption.js.map +1 -0
  786. package/dist/node/signer/index.d.ts +21 -0
  787. package/dist/node/signer/index.js +49 -0
  788. package/dist/node/signer/index.js.map +1 -0
  789. package/dist/node/signer/signatures.d.ts +200 -0
  790. package/dist/node/signer/signatures.js +594 -0
  791. package/dist/node/signer/signatures.js.map +1 -0
  792. package/dist/node/signer/types.d.ts +20 -0
  793. package/dist/node/signer/types.js +2 -0
  794. package/dist/node/signer/types.js.map +1 -0
  795. package/dist/node/signer/util.d.ts +14 -0
  796. package/dist/node/signer/util.js +156 -0
  797. package/dist/node/signer/util.js.map +1 -0
  798. package/dist/node/stats.d.ts +15 -0
  799. package/dist/node/stats.js +64 -0
  800. package/dist/node/stats.js.map +1 -0
  801. package/dist/node/test/mock-ipfs-client.d.ts +34 -0
  802. package/dist/node/test/mock-ipfs-client.js +208 -0
  803. package/dist/node/test/mock-ipfs-client.js.map +1 -0
  804. package/dist/node/test/node/hanging-test/scenarios/comment-publish-pending.scenario.d.ts +8 -0
  805. package/dist/node/test/node/hanging-test/scenarios/comment-publish-pending.scenario.js +21 -0
  806. package/dist/node/test/node/hanging-test/scenarios/comment-publish-pending.scenario.js.map +1 -0
  807. package/dist/node/test/node/hanging-test/scenarios/comment-publish.scenario.d.ts +8 -0
  808. package/dist/node/test/node/hanging-test/scenarios/comment-publish.scenario.js +19 -0
  809. package/dist/node/test/node/hanging-test/scenarios/comment-publish.scenario.js.map +1 -0
  810. package/dist/node/test/node/hanging-test/scenarios/comment-update.scenario.d.ts +8 -0
  811. package/dist/node/test/node/hanging-test/scenarios/comment-update.scenario.js +22 -0
  812. package/dist/node/test/node/hanging-test/scenarios/comment-update.scenario.js.map +1 -0
  813. package/dist/node/test/node/hanging-test/scenarios/community-start.scenario.d.ts +8 -0
  814. package/dist/node/test/node/hanging-test/scenarios/community-start.scenario.js +23 -0
  815. package/dist/node/test/node/hanging-test/scenarios/community-start.scenario.js.map +1 -0
  816. package/dist/node/test/node/hanging-test/scenarios/community-update.scenario.d.ts +8 -0
  817. package/dist/node/test/node/hanging-test/scenarios/community-update.scenario.js +21 -0
  818. package/dist/node/test/node/hanging-test/scenarios/community-update.scenario.js.map +1 -0
  819. package/dist/node/test/node/hanging-test/scenarios/destroy-only.scenario.d.ts +7 -0
  820. package/dist/node/test/node/hanging-test/scenarios/destroy-only.scenario.js +15 -0
  821. package/dist/node/test/node/hanging-test/scenarios/destroy-only.scenario.js.map +1 -0
  822. package/dist/node/test/node/hanging-test/scenarios/hanging-test-util.d.ts +30 -0
  823. package/dist/node/test/node/hanging-test/scenarios/hanging-test-util.js +46 -0
  824. package/dist/node/test/node/hanging-test/scenarios/hanging-test-util.js.map +1 -0
  825. package/dist/node/test/test-util.d.ts +1019 -0
  826. package/dist/node/test/test-util.js +1886 -0
  827. package/dist/node/test/test-util.js.map +1 -0
  828. package/dist/node/types.d.ts +165 -0
  829. package/dist/node/types.js +2 -0
  830. package/dist/node/types.js.map +1 -0
  831. package/dist/node/util/inflight-fetch-manager.d.ts +11 -0
  832. package/dist/node/util/inflight-fetch-manager.js +41 -0
  833. package/dist/node/util/inflight-fetch-manager.js.map +1 -0
  834. package/dist/node/util.d.ts +120 -0
  835. package/dist/node/util.js +816 -0
  836. package/dist/node/util.js.map +1 -0
  837. package/dist/node/version.d.ts +7 -0
  838. package/dist/node/version.js +12 -0
  839. package/dist/node/version.js.map +1 -0
  840. package/dist/node/zod-error-map.d.ts +1 -0
  841. package/dist/node/zod-error-map.js +10 -0
  842. package/dist/node/zod-error-map.js.map +1 -0
  843. package/package.json +212 -0
@@ -0,0 +1,280 @@
1
+ //@ts-expect-error
2
+ import TinyCache from "tinycache";
3
+ import QuickLRU from "quick-lru";
4
+ import { testScore, testFirstCommentTimestamp, testRole, testPublicationType } from "./utils.js";
5
+ import { testRateLimit } from "./rate-limiter.js";
6
+ import { derivePublicationFromChallengeRequest } from "../../../../../util.js";
7
+ import { getPKCAddressFromPublicKeySync } from "../../../../../signer/util.js";
8
+ const shouldExcludePublication = (communityChallenge, request, community) => {
9
+ if (!communityChallenge) {
10
+ throw Error(`shouldExcludePublication invalid communityChallenge argument '${communityChallenge}'`);
11
+ }
12
+ const publication = derivePublicationFromChallengeRequest(request);
13
+ if (!publication?.author) {
14
+ throw Error(`shouldExcludePublication invalid publication argument '${publication}'`);
15
+ }
16
+ const author = publication.author;
17
+ if (!communityChallenge.exclude) {
18
+ return false;
19
+ }
20
+ if (!Array.isArray(communityChallenge.exclude)) {
21
+ throw Error(`shouldExcludePublication invalid communityChallenge argument '${communityChallenge}' communityChallenge.exclude not an array`);
22
+ }
23
+ // lazy-loaded author publication counts (only when postCount/replyCount exclude is set)
24
+ let authorPublicationCounts;
25
+ // if match any of the exclude array, should exclude
26
+ for (const exclude of communityChallenge.exclude) {
27
+ // if doesn't have any author excludes, shouldn't exclude
28
+ if (typeof exclude.postScore !== "number" &&
29
+ typeof exclude.replyScore !== "number" &&
30
+ typeof exclude.postCount !== "number" &&
31
+ typeof exclude.replyCount !== "number" &&
32
+ typeof exclude.firstCommentTimestamp !== "number" &&
33
+ !exclude.address?.length &&
34
+ exclude.publicationType === undefined &&
35
+ exclude.rateLimit === undefined &&
36
+ !exclude.role?.length) {
37
+ continue;
38
+ }
39
+ // if match all of the exclude item properties, should exclude
40
+ // keep separated for easier debugging
41
+ let shouldExclude = true;
42
+ if (!testScore(exclude.postScore, author.community?.postScore)) {
43
+ shouldExclude = false;
44
+ }
45
+ if (!testScore(exclude.replyScore, author.community?.replyScore)) {
46
+ shouldExclude = false;
47
+ }
48
+ if (!testFirstCommentTimestamp(exclude.firstCommentTimestamp, author.community?.firstCommentTimestamp)) {
49
+ shouldExclude = false;
50
+ }
51
+ if (!testPublicationType(exclude.publicationType, request)) {
52
+ shouldExclude = false;
53
+ }
54
+ if (!testRateLimit(exclude, request)) {
55
+ shouldExclude = false;
56
+ }
57
+ if (exclude.address && !exclude.address.includes(author.address)) {
58
+ shouldExclude = false;
59
+ }
60
+ if (Array.isArray(exclude.role) && !testRole(exclude.role, publication.author.address, community?.roles)) {
61
+ shouldExclude = false;
62
+ }
63
+ if (typeof exclude.postCount === "number" || typeof exclude.replyCount === "number") {
64
+ if (!authorPublicationCounts && community?._dbHandler) {
65
+ const signerAddress = getPKCAddressFromPublicKeySync(publication.signature.publicKey);
66
+ authorPublicationCounts = community._dbHandler.queryAuthorPublicationCounts(signerAddress);
67
+ }
68
+ if (!testScore(exclude.postCount, authorPublicationCounts?.postCount)) {
69
+ shouldExclude = false;
70
+ }
71
+ if (!testScore(exclude.replyCount, authorPublicationCounts?.replyCount)) {
72
+ shouldExclude = false;
73
+ }
74
+ }
75
+ // if one of the exclude item is successful, should exclude author
76
+ if (shouldExclude) {
77
+ return true;
78
+ }
79
+ }
80
+ return false;
81
+ };
82
+ const shouldExcludeChallengeSuccess = (communityChallenge, communityChallengeIndex, challengeResults) => {
83
+ if (!communityChallenge) {
84
+ throw Error(`shouldExcludeChallengeSuccess invalid communityChallenge argument '${communityChallenge}'`);
85
+ }
86
+ if (challengeResults && !Array.isArray(challengeResults)) {
87
+ throw Error(`shouldExcludeChallengeSuccess invalid challengeResults argument '${challengeResults}'`);
88
+ }
89
+ // no challenge results or no exclude rules
90
+ if (!challengeResults?.length || !communityChallenge.exclude?.length) {
91
+ return false;
92
+ }
93
+ const challengeToExclude = challengeResults[communityChallengeIndex];
94
+ if (!challengeToExclude) {
95
+ throw Error(`shouldExcludeChallengeSuccess invalid communityChallengeIndex '${communityChallengeIndex}'`);
96
+ }
97
+ const challengeToExcludeIsPending = "challenge" in challengeToExclude;
98
+ // if match any of the exclude array, should exclude
99
+ for (const excludeItem of communityChallenge.exclude) {
100
+ // has no challenge success exclude rules
101
+ if (!excludeItem.challenges?.length) {
102
+ continue;
103
+ }
104
+ // if any of exclude.challenges failed, don't exclude
105
+ let shouldExclude = true;
106
+ for (const challengeIndex of excludeItem.challenges) {
107
+ const challengeResult = challengeResults[challengeIndex];
108
+ // config mistake, excluded challenge index doesn't exist
109
+ if (!challengeResult) {
110
+ shouldExclude = false;
111
+ break;
112
+ }
113
+ const challengeSuccess = "success" in challengeResult && challengeResult.success === true;
114
+ // if a challenge is pending, it can exclude another non-pending challenge
115
+ const challengePending = "challenge" in challengeResult && !challengeToExcludeIsPending;
116
+ if (!challengeSuccess && !challengePending) {
117
+ // found a false, should not exclude based on this exclude item,
118
+ // but try again in the next exclude item
119
+ shouldExclude = false;
120
+ break;
121
+ }
122
+ }
123
+ // if all exclude.challenges succeeded, should exclude
124
+ if (shouldExclude) {
125
+ return true;
126
+ }
127
+ }
128
+ return false;
129
+ };
130
+ const commentCache = new QuickLRU({
131
+ maxSize: 10000
132
+ });
133
+ // cache for fetching comment updates, expire after 1 day
134
+ const commentUpdateCache = new TinyCache();
135
+ const commentUpdateCacheTime = 1000 * 60 * 60;
136
+ const getCommentPending = {}; // cid -> boolean if it's loading or not
137
+ const shouldExcludeChallengeCommentCids = async (communityChallenge, challengeRequestMessage, pkc) => {
138
+ if (!communityChallenge) {
139
+ throw Error(`shouldExcludeChallengeCommentCids invalid communityChallenge argument '${communityChallenge}'`);
140
+ }
141
+ if (!challengeRequestMessage) {
142
+ throw Error(`shouldExcludeChallengeCommentCids invalid challengeRequestMessage argument '${challengeRequestMessage}'`);
143
+ }
144
+ if (typeof pkc?.getComment !== "function") {
145
+ throw Error(`shouldExcludeChallengeCommentCids invalid pkc argument '${pkc}'`);
146
+ }
147
+ const publication = derivePublicationFromChallengeRequest(challengeRequestMessage);
148
+ const commentCids = challengeRequestMessage.challengeCommentCids;
149
+ const author = publication?.author;
150
+ if (commentCids && !Array.isArray(commentCids)) {
151
+ throw Error(`shouldExcludeChallengeCommentCids invalid commentCids argument '${commentCids}'`);
152
+ }
153
+ if (!author?.address || typeof author?.address !== "string") {
154
+ throw Error(`shouldExcludeChallengeCommentCids invalid challengeRequestMessage.publication.author.address argument '${author?.address}'`);
155
+ }
156
+ const _getComment = async (commentCid, addressesSet) => {
157
+ // comment is cached
158
+ let cachedComment = commentCache.get(commentCid);
159
+ // comment is not cached, add to cache
160
+ let comment;
161
+ if (!cachedComment) {
162
+ comment = await pkc.getComment({ cid: commentCid });
163
+ // only cache useful values
164
+ cachedComment = { communityAddress: comment.communityAddress, author: { address: comment.author.address } };
165
+ commentCache.set(commentCid, cachedComment);
166
+ }
167
+ // community address doesn't match filter
168
+ if (!addressesSet.has(cachedComment.communityAddress)) {
169
+ throw Error(`comment doesn't have matching community address`);
170
+ }
171
+ // author address doesn't match author
172
+ if (cachedComment?.author?.address !== author.address) {
173
+ throw Error(`comment author address doesn't match publication author address`);
174
+ }
175
+ // comment hasn't been updated yet
176
+ let cachedCommentUpdate = commentUpdateCache.get(commentCid);
177
+ if (!cachedCommentUpdate) {
178
+ const commentUpdate = comment || (await pkc.createComment({ cid: commentCid }));
179
+ const onUpdate = () => typeof commentUpdate.updatedAt === "number" && resolveUpdate(1);
180
+ let resolveUpdate;
181
+ const commentUpdatePromise = new Promise((resolve) => {
182
+ resolveUpdate = resolve;
183
+ commentUpdate.on("update", onUpdate);
184
+ });
185
+ await commentUpdate.update();
186
+ await commentUpdatePromise;
187
+ await commentUpdate.stop();
188
+ commentUpdate.removeListener("update", onUpdate);
189
+ // only cache useful values
190
+ if (commentUpdate?.author?.community) {
191
+ cachedCommentUpdate = { author: { community: commentUpdate?.author?.community } };
192
+ commentUpdateCache.put(commentCid, cachedCommentUpdate, commentUpdateCacheTime);
193
+ }
194
+ commentUpdateCache._timeouts[commentCid].unref?.();
195
+ }
196
+ return { ...cachedComment, author: { ...cachedComment.author, ...cachedCommentUpdate?.author } };
197
+ };
198
+ const getComment = async (commentCid, addressesSet) => {
199
+ // don't fetch the same comment twice
200
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
201
+ const pendingKey = commentCid + pkc.parsedPKCOptions?.ipfsGatewayUrls?.[0] + pkc.parsedPKCOptions?.kuboRpcClientsOptions?.[0].url;
202
+ while (getCommentPending[pendingKey] === true) {
203
+ await sleep(20);
204
+ }
205
+ getCommentPending[pendingKey] = true;
206
+ try {
207
+ const res = await _getComment(commentCid, addressesSet);
208
+ return res;
209
+ }
210
+ catch (e) {
211
+ throw e;
212
+ }
213
+ finally {
214
+ getCommentPending[pendingKey] = false;
215
+ }
216
+ };
217
+ const validateComment = async (commentCid, addressesSet, exclude) => {
218
+ const comment = await getComment(commentCid, addressesSet);
219
+ const { postScore, replyScore, firstCommentTimestamp } = exclude?.community || {};
220
+ if (testScore(postScore, comment.author?.community?.postScore) &&
221
+ testScore(replyScore, comment.author?.community?.replyScore) &&
222
+ testFirstCommentTimestamp(firstCommentTimestamp, comment.author?.community?.firstCommentTimestamp)) {
223
+ // do nothing, comment is valid
224
+ return;
225
+ }
226
+ throw Error(`should not exclude comment cid`);
227
+ };
228
+ const validateExclude = async (exclude) => {
229
+ let { addresses, maxCommentCids } = exclude?.community || {};
230
+ if (!maxCommentCids) {
231
+ maxCommentCids = 3;
232
+ }
233
+ // no friendly community addresses
234
+ if (!addresses?.length) {
235
+ throw Error("no friendly community addresses");
236
+ }
237
+ const addressesSet = new Set(addresses);
238
+ // author didn't provide comment cids
239
+ if (!commentCids?.length) {
240
+ throw Error(`author didn't provide comment cids`);
241
+ }
242
+ // fetch and test all comments of the author async
243
+ const validateCommentPromises = [];
244
+ let i = 0;
245
+ while (i < maxCommentCids) {
246
+ const commentCid = commentCids[i++];
247
+ if (commentCid) {
248
+ validateCommentPromises.push(validateComment(commentCid, addressesSet, exclude));
249
+ }
250
+ }
251
+ // if doesn't throw, at least 1 comment was valid
252
+ try {
253
+ await Promise.any(validateCommentPromises);
254
+ }
255
+ catch (e) {
256
+ // console.log(validateCommentPromises) // debug all validate comments
257
+ if (e instanceof Error)
258
+ e.message = `should not exclude: ${e.message}`;
259
+ throw e;
260
+ }
261
+ // if at least 1 comment was valid, do nothing, exclude is valid
262
+ };
263
+ // iterate over all excludes, and validate them async
264
+ const validateExcludePromises = [];
265
+ for (const exclude of communityChallenge.exclude || []) {
266
+ validateExcludePromises.push(validateExclude(exclude));
267
+ }
268
+ // if at least 1 valid exclude, should exclude
269
+ try {
270
+ await Promise.any(validateExcludePromises);
271
+ return true;
272
+ }
273
+ catch (e) {
274
+ // console.log(validateExcludePromises) // debug all validate excludes
275
+ }
276
+ // if no exclude are valid, should not exclude
277
+ return false;
278
+ };
279
+ export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess };
280
+ //# sourceMappingURL=exclude.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exclude.js","sourceRoot":"","sources":["../../../../../../../src/runtime/node/community/challenges/exclude/exclude.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMlD,OAAO,EAAE,qCAAqC,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAE/E,MAAM,wBAAwB,GAAG,CAC7B,kBAAsC,EACtC,OAAgE,EAChE,SAAyB,EAC3B,EAAE;IACA,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACtB,MAAM,KAAK,CAAC,iEAAiE,kBAAkB,GAAG,CAAC,CAAC;IACxG,CAAC;IACD,MAAM,WAAW,GAAG,qCAAqC,CAAC,OAAO,CAAC,CAAC;IACnE,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC,0DAA0D,WAAW,GAAG,CAAC,CAAC;IAC1F,CAAC;IACD,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAElC,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;I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AAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,sEAAsE;YACtE,IAAI,CAAC,YAAY,KAAK;gBAAE,CAAC,CAAC,OAAO,GAAG,uBAAuB,CAAC,CAAC,OAAO,EAAE,CAAC;YACvE,MAAM,CAAC,CAAC;QACZ,CAAC;QAED,gEAAgE;IACpE,CAAC,CAAC;IAEF,qDAAqD;IACrD,MAAM,uBAAuB,GAAG,EAAE,CAAC;IACnC,KAAK,MAAM,OAAO,IAAI,kBAAkB,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;QACrD,uBAAuB,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,8CAA8C;IAC9C,IAAI,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,sEAAsE;IAC1E,CAAC;IAED,8CAA8C;IAC9C,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess } from "./exclude.js";
2
+ import { addToRateLimiter } from "./rate-limiter.js";
3
+ export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess, addToRateLimiter };
@@ -0,0 +1,4 @@
1
+ import { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess } from "./exclude.js";
2
+ import { addToRateLimiter } from "./rate-limiter.js";
3
+ export { shouldExcludeChallengeCommentCids, shouldExcludePublication, shouldExcludeChallengeSuccess, addToRateLimiter };
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/runtime/node/community/challenges/exclude/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAC1H,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { DecryptedChallengeRequestMessageTypeWithCommunityAuthor } from "../../../../../pubsub-messages/types.js";
2
+ import type { ChallengeResult, Exclude, CommunitySettings } from "../../../../../community/types.js";
3
+ declare const testRateLimit: (exclude: Exclude, request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
4
+ declare const addToRateLimiter: (communityChallenges: NonNullable<CommunitySettings["challenges"]>, request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor, challengeSuccess: ChallengeResult["success"]) => void;
5
+ export { addToRateLimiter, testRateLimit };
@@ -0,0 +1,127 @@
1
+ import QuickLRU from "quick-lru";
2
+ import { isVote, isReply, isPost, isCommentEdit, isCommentModeration, isCommunityEdit, testPublicationType } from "./utils.js";
3
+ import * as limiterCompat from "limiter-es6-compat";
4
+ import { derivePublicationFromChallengeRequest } from "../../../../../util.js";
5
+ // Workaround for NodeNext moduleResolution compatibility
6
+ const { RateLimiter } = limiterCompat;
7
+ // each author could have 20+ rate limiters each if the community has
8
+ // several rate limit rules so keep a large cache
9
+ const rateLimiters = new QuickLRU({ maxSize: 50000 });
10
+ const getPublicationType = (request) => isPost(request)
11
+ ? "post"
12
+ : isReply(request)
13
+ ? "reply"
14
+ : isVote(request)
15
+ ? "vote"
16
+ : isCommentEdit(request)
17
+ ? "commentEdit"
18
+ : isCommentModeration(request)
19
+ ? "commentModeration"
20
+ : isCommunityEdit(request)
21
+ ? "communityEdit"
22
+ : undefined;
23
+ const getRateLimiterName = (exclude, publication, publicationType, challengeSuccess) => `${publication.author.address}-${exclude.rateLimit}-${publicationType}-${challengeSuccess}`;
24
+ const getOrCreateRateLimiter = (exclude, publication, publicationType, challengeSuccess) => {
25
+ if (typeof exclude.rateLimit !== "number")
26
+ throw Error("Can't create a RateLimiter without exclude.rateLimit");
27
+ const rateLimiterName = getRateLimiterName(exclude, publication, publicationType, challengeSuccess);
28
+ let rateLimiter = rateLimiters.get(rateLimiterName);
29
+ if (!rateLimiter) {
30
+ rateLimiter = new RateLimiter({ tokensPerInterval: exclude.rateLimit, interval: "hour", fireImmediately: true });
31
+ // @ts-ignore - adding name property for debugging
32
+ rateLimiter.name = rateLimiterName; // add name for debugging
33
+ rateLimiters.set(rateLimiterName, rateLimiter);
34
+ }
35
+ return rateLimiter;
36
+ };
37
+ const addFilteredRateLimiter = (exclude, publication, publicationType, challengeSuccess, filteredRateLimiters) => {
38
+ filteredRateLimiters[getRateLimiterName(exclude, publication, publicationType, challengeSuccess)] = getOrCreateRateLimiter(exclude, publication, publicationType, challengeSuccess);
39
+ };
40
+ const getRateLimitersToTest = (exclude, request, challengeSuccess) => {
41
+ // TODO I think we need to change this
42
+ const publication = derivePublicationFromChallengeRequest(request);
43
+ // get all rate limiters associated with the exclude (publication type and challengeSuccess true/false)
44
+ const filteredRateLimiters = {};
45
+ if (testPublicationType(exclude.publicationType, request)) {
46
+ const publicationType = getPublicationType(request);
47
+ if (publicationType) {
48
+ addFilteredRateLimiter(exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
49
+ }
50
+ }
51
+ return filteredRateLimiters;
52
+ };
53
+ const testRateLimit = (exclude, request) => {
54
+ // will come back here later
55
+ if (exclude?.rateLimit === undefined || !testPublicationType(exclude.publicationType, request)) {
56
+ // early exit based on exclude type and publication type
57
+ return true;
58
+ }
59
+ // if rateLimitChallengeSuccess is undefined or true, only use {challengeSuccess: true} rate limiters
60
+ let challengeSuccess = true;
61
+ if (exclude.rateLimitChallengeSuccess === false) {
62
+ challengeSuccess = false;
63
+ }
64
+ // check all the rate limiters that match the exclude and publication type
65
+ const rateLimiters = getRateLimitersToTest(exclude, request, challengeSuccess);
66
+ // if any of the matching rate limiter is out of tokens, test failed
67
+ for (const rateLimiter of Object.values(rateLimiters)) {
68
+ const tokensRemaining = rateLimiter.getTokensRemaining();
69
+ // token per action is 1, so any value below 1 is invalid
70
+ if (tokensRemaining < 1)
71
+ return false;
72
+ }
73
+ return true;
74
+ };
75
+ const getRateLimitersToAddTo = (excludeArray, request, challengeSuccess) => {
76
+ // get all rate limiters associated with the exclude (publication type and challengeSuccess true/false)
77
+ const filteredRateLimiters = {};
78
+ const publication = derivePublicationFromChallengeRequest(request);
79
+ for (const exclude of excludeArray) {
80
+ if (exclude?.rateLimit === undefined) {
81
+ continue;
82
+ }
83
+ const publicationType = getPublicationType(request);
84
+ if (publicationType) {
85
+ addFilteredRateLimiter(exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
86
+ }
87
+ if (request.commentEdit) {
88
+ addFilteredRateLimiter(exclude, publication, "commentEdit", challengeSuccess, filteredRateLimiters);
89
+ }
90
+ if (request.commentModeration) {
91
+ addFilteredRateLimiter(exclude, publication, "commentModeration", challengeSuccess, filteredRateLimiters);
92
+ }
93
+ if (request.communityEdit) {
94
+ addFilteredRateLimiter(exclude, publication, "communityEdit", challengeSuccess, filteredRateLimiters);
95
+ }
96
+ }
97
+ return filteredRateLimiters;
98
+ };
99
+ const addToRateLimiter = (communityChallenges, request, challengeSuccess) => {
100
+ if (!communityChallenges) {
101
+ // community has no challenges, no need to rate limit
102
+ return;
103
+ }
104
+ if (!Array.isArray(communityChallenges)) {
105
+ throw Error(`addToRateLimiter invalid argument communityChallenges '${communityChallenges}' not an array`);
106
+ }
107
+ if (typeof challengeSuccess !== "boolean") {
108
+ throw Error(`addToRateLimiter invalid argument challengeSuccess '${challengeSuccess}' not a boolean`);
109
+ }
110
+ // get all exclude items from all community challenges
111
+ const excludeArray = [];
112
+ for (const communityChallenge of communityChallenges) {
113
+ for (const exclude of communityChallenge?.exclude || []) {
114
+ excludeArray.push(exclude);
115
+ }
116
+ }
117
+ if (!excludeArray.length) {
118
+ // no need to add to rate limiter if the community has no exclude rules in any challenges
119
+ return;
120
+ }
121
+ const rateLimiters = getRateLimitersToAddTo(excludeArray, request, challengeSuccess);
122
+ for (const rateLimiter of Object.values(rateLimiters)) {
123
+ rateLimiter.tryRemoveTokens(1);
124
+ }
125
+ };
126
+ export { addToRateLimiter, testRateLimit };
127
+ //# sourceMappingURL=rate-limiter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limiter.js","sourceRoot":"","sources":["../../../../../../../src/runtime/node/community/challenges/exclude/rate-limiter.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAM/H,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACH,qCAAqC,EAGxC,MAAM,wBAAwB,CAAC;AAEhC,yDAAyD;AACzD,MAAM,EAAE,WAAW,EAAE,GAAG,aAAoB,CAAC;AAI7C,qEAAqE;AACrE,iDAAiD;AACjD,MAAM,YAAY,GAAG,IAAI,QAAQ,CAA8B,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AAEnF,MAAM,kBAAkB,GAAG,CAAC,OAAgE,EAA+B,EAAE,CACzH,MAAM,CAAC,OAAO,CAAC;IACX,CAAC,CAAC,MAAM;IACR,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;QAChB,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;YACf,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC;gBACtB,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC;oBAC5B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,EAC9C,EAAE;IACA,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACvB,qDAAqD;QACrD,OAAO;IACX,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACtC,MAAM,KAAK,CAAC,0DAA0D,mBAAmB,gBAAgB,CAAC,CAAC;IAC/G,CAAC;IAED,IAAI,OAAO,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,KAAK,CAAC,uDAAuD,gBAAgB,iBAAiB,CAAC,CAAC;IAC1G,CAAC;IAED,sDAAsD;IACtD,MAAM,YAAY,GAAG,EAAE,CAAC;IACxB,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QACnD,KAAK,MAAM,OAAO,IAAI,kBAAkB,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;YACtD,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QACvB,yFAAyF;QACzF,OAAO;IACX,CAAC;IAED,MAAM,YAAY,GAAG,sBAAsB,CAAC,YAAY,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACrF,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QACpD,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { CommunityIpfsType, CommunityRole, Exclude } from "../../../../../community/types.js";
2
+ import type { DecryptedChallengeRequestMessageTypeWithCommunityAuthor } from "../../../../../pubsub-messages/types.js";
3
+ declare const testScore: (excludeScore: number | undefined, authorScore: number | undefined) => boolean;
4
+ declare const testFirstCommentTimestamp: (excludeTime: number | undefined, authorFirstCommentTimestamp: number | undefined) => boolean;
5
+ declare const testRole: (excludeRole: CommunityRole["role"][], authorAddress: string, communityRoles: CommunityIpfsType["roles"]) => boolean;
6
+ declare const isVote: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
7
+ declare const isReply: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => request is import("../../../../../pubsub-messages/types.js").DecryptedChallengeRequestMessageWithReplyCommunityAuthor;
8
+ declare const isPost: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => request is import("../../../../../pubsub-messages/types.js").DecryptedChallengeRequestMessageWithPostCommunityAuthor;
9
+ declare const isCommentEdit: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
10
+ declare const isCommentModeration: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
11
+ declare const isCommunityEdit: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
12
+ declare const testPublicationType: (excludePublicationType: Exclude["publicationType"] | undefined, request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => boolean;
13
+ export { isVote, isReply, isPost, isCommentEdit, isCommentModeration, isCommunityEdit, testPublicationType, testScore, testFirstCommentTimestamp, testRole };
@@ -0,0 +1,52 @@
1
+ import { isRequestPubsubPublicationOfPost, isRequestPubsubPublicationOfReply } from "../../../../../util.js";
2
+ // e.g. secondsToGoBack = 60 would return the timestamp 1 minute ago
3
+ const getTimestampSecondsAgo = (secondsToGoBack) => Math.round(Date.now() / 1000) - secondsToGoBack;
4
+ const testScore = (excludeScore, authorScore) => excludeScore === undefined || excludeScore <= (authorScore || 0);
5
+ // firstCommentTimestamp value first needs to be put through Date.now() - firstCommentTimestamp
6
+ const testFirstCommentTimestamp = (excludeTime, authorFirstCommentTimestamp) => excludeTime === undefined || getTimestampSecondsAgo(excludeTime) >= (authorFirstCommentTimestamp || Infinity);
7
+ const testRole = (excludeRole, authorAddress, communityRoles) => {
8
+ if (excludeRole === undefined) {
9
+ return true; // No role exclusion rule, so this test passes
10
+ }
11
+ if (communityRoles === undefined) {
12
+ return false; // Can't verify roles, so assume user doesn't have excluded role
13
+ }
14
+ for (const roleName of excludeRole) {
15
+ if (communityRoles[authorAddress]?.role === roleName) {
16
+ return true;
17
+ }
18
+ }
19
+ return false;
20
+ };
21
+ const isVote = (request) => Boolean(request.vote);
22
+ const isReply = (request) => isRequestPubsubPublicationOfReply(request);
23
+ const isPost = (request) => isRequestPubsubPublicationOfPost(request);
24
+ const isCommentEdit = (request) => Boolean(request.commentEdit);
25
+ const isCommentModeration = (request) => Boolean(request.commentModeration);
26
+ const isCommunityEdit = (request) => Boolean(request.communityEdit);
27
+ const testPublicationType = (excludePublicationType, request) => {
28
+ if (excludePublicationType === undefined) {
29
+ return true;
30
+ }
31
+ if (excludePublicationType.post && isPost(request)) {
32
+ return true;
33
+ }
34
+ if (excludePublicationType.reply && isReply(request)) {
35
+ return true;
36
+ }
37
+ if (excludePublicationType.vote && isVote(request)) {
38
+ return true;
39
+ }
40
+ if (excludePublicationType.commentEdit && isCommentEdit(request)) {
41
+ return true;
42
+ }
43
+ if (excludePublicationType.commentModeration && isCommentModeration(request)) {
44
+ return true;
45
+ }
46
+ if (excludePublicationType.communityEdit && isCommunityEdit(request)) {
47
+ return true;
48
+ }
49
+ return false;
50
+ };
51
+ export { isVote, isReply, isPost, isCommentEdit, isCommentModeration, isCommunityEdit, testPublicationType, testScore, testFirstCommentTimestamp, testRole };
52
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../src/runtime/node/community/challenges/exclude/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gCAAgC,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAE7G,oEAAoE;AACpE,MAAM,sBAAsB,GAAG,CAAC,eAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,eA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WithCommunityAuthor } from "../../../../pubsub-messages/types.js";
2
+ import type { Challenge, ChallengeFileFactoryInput, CommunityChallenge, CommunityChallengeSetting } from "../../../../community/types.js";
3
+ import { LocalCommunity } from "../local-community.js";
4
+ type PendingChallenge = Challenge & {
5
+ index: number;
6
+ };
7
+ export type GetChallengeAnswers = (challenges: Omit<Challenge, "verify">[]) => Promise<DecryptedChallengeAnswer["challengeAnswers"]>;
8
+ type ChallengeVerificationSuccess = {
9
+ challengeSuccess: true;
10
+ pendingApprovalSuccess: boolean;
11
+ };
12
+ type ChallengeVerificationPending = {
13
+ pendingChallenges: PendingChallenge[];
14
+ pendingApprovalSuccess: boolean;
15
+ };
16
+ type ChallengeVerificationFailure = {
17
+ challengeSuccess: false;
18
+ challengeErrors: NonNullable<ChallengeVerificationMessageType["challengeErrors"]>;
19
+ };
20
+ type PKCWithSettingsChallenges = {
21
+ settings?: {
22
+ challenges?: Record<string, ChallengeFileFactoryInput>;
23
+ };
24
+ };
25
+ declare const pkcJsChallenges: Record<string, ChallengeFileFactoryInput>;
26
+ declare const getPendingChallengesOrChallengeVerification: (challengeRequestMessage: DecryptedChallengeRequestMessageTypeWithCommunityAuthor, community: LocalCommunity) => Promise<ChallengeVerificationSuccess | ChallengeVerificationPending | ChallengeVerificationFailure>;
27
+ declare const getChallengeVerificationFromChallengeAnswers: (pendingChallenges: PendingChallenge[], challengeAnswers: DecryptedChallengeAnswer["challengeAnswers"], community: LocalCommunity) => Promise<ChallengeVerificationSuccess | ChallengeVerificationFailure>;
28
+ declare const getChallengeVerification: (challengeRequestMessage: DecryptedChallengeRequestMessageTypeWithCommunityAuthor, community: LocalCommunity, getChallengeAnswers: GetChallengeAnswers) => Promise<Pick<ChallengeVerificationMessageType, "challengeErrors" | "challengeSuccess"> & {
29
+ pendingApproval?: boolean;
30
+ }>;
31
+ declare const getCommunityChallengeFromCommunityChallengeSettings: (communityChallengeSettings: CommunityChallengeSetting, pkc?: PKCWithSettingsChallenges) => Promise<CommunityChallenge>;
32
+ export { pkcJsChallenges, getPendingChallengesOrChallengeVerification, getChallengeVerificationFromChallengeAnswers, getChallengeVerification, getCommunityChallengeFromCommunityChallengeSettings };