@bitsocial/bitsocial-react-hooks 0.1.0

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 (269) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +1365 -0
  3. package/dist/hooks/accounts/accounts.d.ts +64 -0
  4. package/dist/hooks/accounts/accounts.d.ts.map +1 -0
  5. package/dist/hooks/accounts/accounts.js +706 -0
  6. package/dist/hooks/accounts/accounts.js.map +1 -0
  7. package/dist/hooks/accounts/index.d.ts +2 -0
  8. package/dist/hooks/accounts/index.d.ts.map +1 -0
  9. package/dist/hooks/accounts/index.js +2 -0
  10. package/dist/hooks/accounts/index.js.map +1 -0
  11. package/dist/hooks/accounts/utils.d.ts +6 -0
  12. package/dist/hooks/accounts/utils.d.ts.map +1 -0
  13. package/dist/hooks/accounts/utils.js +226 -0
  14. package/dist/hooks/accounts/utils.js.map +1 -0
  15. package/dist/hooks/actions/actions.d.ts +19 -0
  16. package/dist/hooks/actions/actions.d.ts.map +1 -0
  17. package/dist/hooks/actions/actions.js +552 -0
  18. package/dist/hooks/actions/actions.js.map +1 -0
  19. package/dist/hooks/actions/index.d.ts +2 -0
  20. package/dist/hooks/actions/index.d.ts.map +1 -0
  21. package/dist/hooks/actions/index.js +2 -0
  22. package/dist/hooks/actions/index.js.map +1 -0
  23. package/dist/hooks/authors/author-avatars.d.ts +28 -0
  24. package/dist/hooks/authors/author-avatars.d.ts.map +1 -0
  25. package/dist/hooks/authors/author-avatars.js +191 -0
  26. package/dist/hooks/authors/author-avatars.js.map +1 -0
  27. package/dist/hooks/authors/authors.d.ts +37 -0
  28. package/dist/hooks/authors/authors.d.ts.map +1 -0
  29. package/dist/hooks/authors/authors.js +509 -0
  30. package/dist/hooks/authors/authors.js.map +1 -0
  31. package/dist/hooks/authors/index.d.ts +2 -0
  32. package/dist/hooks/authors/index.d.ts.map +1 -0
  33. package/dist/hooks/authors/index.js +2 -0
  34. package/dist/hooks/authors/index.js.map +1 -0
  35. package/dist/hooks/authors/utils.d.ts +4 -0
  36. package/dist/hooks/authors/utils.d.ts.map +1 -0
  37. package/dist/hooks/authors/utils.js +21 -0
  38. package/dist/hooks/authors/utils.js.map +1 -0
  39. package/dist/hooks/comments.d.ts +17 -0
  40. package/dist/hooks/comments.d.ts.map +1 -0
  41. package/dist/hooks/comments.js +351 -0
  42. package/dist/hooks/comments.js.map +1 -0
  43. package/dist/hooks/communities.d.ts +31 -0
  44. package/dist/hooks/communities.d.ts.map +1 -0
  45. package/dist/hooks/communities.js +389 -0
  46. package/dist/hooks/communities.js.map +1 -0
  47. package/dist/hooks/feeds/feeds.d.ts +18 -0
  48. package/dist/hooks/feeds/feeds.d.ts.map +1 -0
  49. package/dist/hooks/feeds/feeds.js +315 -0
  50. package/dist/hooks/feeds/feeds.js.map +1 -0
  51. package/dist/hooks/feeds/index.d.ts +2 -0
  52. package/dist/hooks/feeds/index.d.ts.map +1 -0
  53. package/dist/hooks/feeds/index.js +2 -0
  54. package/dist/hooks/feeds/index.js.map +1 -0
  55. package/dist/hooks/pkc-rpc.d.ts +7 -0
  56. package/dist/hooks/pkc-rpc.d.ts.map +1 -0
  57. package/dist/hooks/pkc-rpc.js +88 -0
  58. package/dist/hooks/pkc-rpc.js.map +1 -0
  59. package/dist/hooks/replies.d.ts +5 -0
  60. package/dist/hooks/replies.d.ts.map +1 -0
  61. package/dist/hooks/replies.js +155 -0
  62. package/dist/hooks/replies.js.map +1 -0
  63. package/dist/hooks/states.d.ts +15 -0
  64. package/dist/hooks/states.d.ts.map +1 -0
  65. package/dist/hooks/states.js +213 -0
  66. package/dist/hooks/states.js.map +1 -0
  67. package/dist/hooks/utils/use-interval.d.ts +3 -0
  68. package/dist/hooks/utils/use-interval.d.ts.map +1 -0
  69. package/dist/hooks/utils/use-interval.js +36 -0
  70. package/dist/hooks/utils/use-interval.js.map +1 -0
  71. package/dist/hooks/utils/use-previous.d.ts +1 -0
  72. package/dist/hooks/utils/use-previous.js +10 -0
  73. package/dist/index.d.ts +82 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +128 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/lib/chain/chain.d.ts +36 -0
  78. package/dist/lib/chain/chain.d.ts.map +1 -0
  79. package/dist/lib/chain/chain.js +195 -0
  80. package/dist/lib/chain/chain.js.map +1 -0
  81. package/dist/lib/chain/index.d.ts +4 -0
  82. package/dist/lib/chain/index.d.ts.map +1 -0
  83. package/dist/lib/chain/index.js +4 -0
  84. package/dist/lib/chain/index.js.map +1 -0
  85. package/dist/lib/community-address.d.ts +6 -0
  86. package/dist/lib/community-address.d.ts.map +1 -0
  87. package/dist/lib/community-address.js +26 -0
  88. package/dist/lib/community-address.js.map +1 -0
  89. package/dist/lib/community-ref.d.ts +23 -0
  90. package/dist/lib/community-ref.d.ts.map +1 -0
  91. package/dist/lib/community-ref.js +113 -0
  92. package/dist/lib/community-ref.js.map +1 -0
  93. package/dist/lib/debug-utils.d.ts +9 -0
  94. package/dist/lib/debug-utils.d.ts.map +1 -0
  95. package/dist/lib/debug-utils.js +21 -0
  96. package/dist/lib/debug-utils.js.map +1 -0
  97. package/dist/lib/feed-sort-type.d.ts +2 -0
  98. package/dist/lib/feed-sort-type.d.ts.map +1 -0
  99. package/dist/lib/feed-sort-type.js +22 -0
  100. package/dist/lib/feed-sort-type.js.map +1 -0
  101. package/dist/lib/localforage-lru/index.d.ts +3 -0
  102. package/dist/lib/localforage-lru/index.d.ts.map +1 -0
  103. package/dist/lib/localforage-lru/index.js +46 -0
  104. package/dist/lib/localforage-lru/index.js.map +1 -0
  105. package/dist/lib/localforage-lru/localforage-lru.d.ts +6 -0
  106. package/dist/lib/localforage-lru/localforage-lru.d.ts.map +1 -0
  107. package/dist/lib/localforage-lru/localforage-lru.js +182 -0
  108. package/dist/lib/localforage-lru/localforage-lru.js.map +1 -0
  109. package/dist/lib/pkc-compat.d.ts +25 -0
  110. package/dist/lib/pkc-compat.d.ts.map +1 -0
  111. package/dist/lib/pkc-compat.js +131 -0
  112. package/dist/lib/pkc-compat.js.map +1 -0
  113. package/dist/lib/pkc-js/fixtures/markdown-example.d.ts +3 -0
  114. package/dist/lib/pkc-js/fixtures/markdown-example.d.ts.map +1 -0
  115. package/dist/lib/pkc-js/fixtures/markdown-example.js +280 -0
  116. package/dist/lib/pkc-js/fixtures/markdown-example.js.map +1 -0
  117. package/dist/lib/pkc-js/index.d.ts +11 -0
  118. package/dist/lib/pkc-js/index.d.ts.map +1 -0
  119. package/dist/lib/pkc-js/index.js +85 -0
  120. package/dist/lib/pkc-js/index.js.map +1 -0
  121. package/dist/lib/pkc-js/pkc-js-mock-content.d.ts +3 -0
  122. package/dist/lib/pkc-js/pkc-js-mock-content.d.ts.map +1 -0
  123. package/dist/lib/pkc-js/pkc-js-mock-content.js +1235 -0
  124. package/dist/lib/pkc-js/pkc-js-mock-content.js.map +1 -0
  125. package/dist/lib/pkc-js/pkc-js-mock.d.ts +137 -0
  126. package/dist/lib/pkc-js/pkc-js-mock.d.ts.map +1 -0
  127. package/dist/lib/pkc-js/pkc-js-mock.js +644 -0
  128. package/dist/lib/pkc-js/pkc-js-mock.js.map +1 -0
  129. package/dist/lib/polyfill.d.ts +3 -0
  130. package/dist/lib/polyfill.d.ts.map +1 -0
  131. package/dist/lib/polyfill.js +14 -0
  132. package/dist/lib/polyfill.js.map +1 -0
  133. package/dist/lib/protocol-compat.d.ts +14 -0
  134. package/dist/lib/protocol-compat.d.ts.map +1 -0
  135. package/dist/lib/protocol-compat.js +67 -0
  136. package/dist/lib/protocol-compat.js.map +1 -0
  137. package/dist/lib/test-utils.d.ts +29 -0
  138. package/dist/lib/test-utils.d.ts.map +1 -0
  139. package/dist/lib/test-utils.js +184 -0
  140. package/dist/lib/test-utils.js.map +1 -0
  141. package/dist/lib/utils/comment-moderation.d.ts +4 -0
  142. package/dist/lib/utils/comment-moderation.d.ts.map +1 -0
  143. package/dist/lib/utils/comment-moderation.js +56 -0
  144. package/dist/lib/utils/comment-moderation.js.map +1 -0
  145. package/dist/lib/utils/index.d.ts +4 -0
  146. package/dist/lib/utils/index.d.ts.map +1 -0
  147. package/dist/lib/utils/index.js +4 -0
  148. package/dist/lib/utils/index.js.map +1 -0
  149. package/dist/lib/utils/utils.d.ts +23 -0
  150. package/dist/lib/utils/utils.d.ts.map +1 -0
  151. package/dist/lib/utils/utils.js +375 -0
  152. package/dist/lib/utils/utils.js.map +1 -0
  153. package/dist/lib/validator.d.ts +30 -0
  154. package/dist/lib/validator.d.ts.map +1 -0
  155. package/dist/lib/validator.js +307 -0
  156. package/dist/lib/validator.js.map +1 -0
  157. package/dist/stores/accounts/account-generator.d.ts +51 -0
  158. package/dist/stores/accounts/account-generator.d.ts.map +1 -0
  159. package/dist/stores/accounts/account-generator.js +160 -0
  160. package/dist/stores/accounts/account-generator.js.map +1 -0
  161. package/dist/stores/accounts/accounts-actions-internal.d.ts +8 -0
  162. package/dist/stores/accounts/accounts-actions-internal.d.ts.map +1 -0
  163. package/dist/stores/accounts/accounts-actions-internal.js +403 -0
  164. package/dist/stores/accounts/accounts-actions-internal.js.map +1 -0
  165. package/dist/stores/accounts/accounts-actions.d.ts +46 -0
  166. package/dist/stores/accounts/accounts-actions.d.ts.map +1 -0
  167. package/dist/stores/accounts/accounts-actions.js +1341 -0
  168. package/dist/stores/accounts/accounts-actions.js.map +1 -0
  169. package/dist/stores/accounts/accounts-database.d.ts +34 -0
  170. package/dist/stores/accounts/accounts-database.d.ts.map +1 -0
  171. package/dist/stores/accounts/accounts-database.js +685 -0
  172. package/dist/stores/accounts/accounts-database.js.map +1 -0
  173. package/dist/stores/accounts/accounts-store.d.ts +32 -0
  174. package/dist/stores/accounts/accounts-store.d.ts.map +1 -0
  175. package/dist/stores/accounts/accounts-store.js +169 -0
  176. package/dist/stores/accounts/accounts-store.js.map +1 -0
  177. package/dist/stores/accounts/index.d.ts +4 -0
  178. package/dist/stores/accounts/index.d.ts.map +1 -0
  179. package/dist/stores/accounts/index.js +4 -0
  180. package/dist/stores/accounts/index.js.map +1 -0
  181. package/dist/stores/accounts/utils.d.ts +49 -0
  182. package/dist/stores/accounts/utils.d.ts.map +1 -0
  183. package/dist/stores/accounts/utils.js +419 -0
  184. package/dist/stores/accounts/utils.js.map +1 -0
  185. package/dist/stores/authors-comments/authors-comments-store.d.ts +37 -0
  186. package/dist/stores/authors-comments/authors-comments-store.d.ts.map +1 -0
  187. package/dist/stores/authors-comments/authors-comments-store.js +338 -0
  188. package/dist/stores/authors-comments/authors-comments-store.js.map +1 -0
  189. package/dist/stores/authors-comments/index.d.ts +4 -0
  190. package/dist/stores/authors-comments/index.d.ts.map +1 -0
  191. package/dist/stores/authors-comments/index.js +4 -0
  192. package/dist/stores/authors-comments/index.js.map +1 -0
  193. package/dist/stores/authors-comments/utils.d.ts +14 -0
  194. package/dist/stores/authors-comments/utils.d.ts.map +1 -0
  195. package/dist/stores/authors-comments/utils.js +81 -0
  196. package/dist/stores/authors-comments/utils.js.map +1 -0
  197. package/dist/stores/comments/comments-store.d.ts +19 -0
  198. package/dist/stores/comments/comments-store.d.ts.map +1 -0
  199. package/dist/stores/comments/comments-store.js +385 -0
  200. package/dist/stores/comments/comments-store.js.map +1 -0
  201. package/dist/stores/comments/index.d.ts +4 -0
  202. package/dist/stores/comments/index.d.ts.map +1 -0
  203. package/dist/stores/comments/index.js +4 -0
  204. package/dist/stores/comments/index.js.map +1 -0
  205. package/dist/stores/communities/communities-store.d.ts +17 -0
  206. package/dist/stores/communities/communities-store.d.ts.map +1 -0
  207. package/dist/stores/communities/communities-store.js +304 -0
  208. package/dist/stores/communities/communities-store.js.map +1 -0
  209. package/dist/stores/communities/index.d.ts +4 -0
  210. package/dist/stores/communities/index.d.ts.map +1 -0
  211. package/dist/stores/communities/index.js +4 -0
  212. package/dist/stores/communities/index.js.map +1 -0
  213. package/dist/stores/communities-pages/communities-pages-store.d.ts +23 -0
  214. package/dist/stores/communities-pages/communities-pages-store.d.ts.map +1 -0
  215. package/dist/stores/communities-pages/communities-pages-store.js +316 -0
  216. package/dist/stores/communities-pages/communities-pages-store.js.map +1 -0
  217. package/dist/stores/communities-pages/index.d.ts +4 -0
  218. package/dist/stores/communities-pages/index.d.ts.map +1 -0
  219. package/dist/stores/communities-pages/index.js +4 -0
  220. package/dist/stores/communities-pages/index.js.map +1 -0
  221. package/dist/stores/feeds/feed-sorter.d.ts +5 -0
  222. package/dist/stores/feeds/feed-sorter.d.ts.map +1 -0
  223. package/dist/stores/feeds/feed-sorter.js +135 -0
  224. package/dist/stores/feeds/feed-sorter.js.map +1 -0
  225. package/dist/stores/feeds/feeds-store.d.ts +25 -0
  226. package/dist/stores/feeds/feeds-store.d.ts.map +1 -0
  227. package/dist/stores/feeds/feeds-store.js +459 -0
  228. package/dist/stores/feeds/feeds-store.js.map +1 -0
  229. package/dist/stores/feeds/index.d.ts +4 -0
  230. package/dist/stores/feeds/index.d.ts.map +1 -0
  231. package/dist/stores/feeds/index.js +4 -0
  232. package/dist/stores/feeds/index.js.map +1 -0
  233. package/dist/stores/feeds/utils.d.ts +43 -0
  234. package/dist/stores/feeds/utils.d.ts.map +1 -0
  235. package/dist/stores/feeds/utils.js +736 -0
  236. package/dist/stores/feeds/utils.js.map +1 -0
  237. package/dist/stores/replies/index.d.ts +4 -0
  238. package/dist/stores/replies/index.d.ts.map +1 -0
  239. package/dist/stores/replies/index.js +4 -0
  240. package/dist/stores/replies/index.js.map +1 -0
  241. package/dist/stores/replies/replies-comments-store.d.ts +8 -0
  242. package/dist/stores/replies/replies-comments-store.d.ts.map +1 -0
  243. package/dist/stores/replies/replies-comments-store.js +23 -0
  244. package/dist/stores/replies/replies-comments-store.js.map +1 -0
  245. package/dist/stores/replies/replies-store.d.ts +29 -0
  246. package/dist/stores/replies/replies-store.d.ts.map +1 -0
  247. package/dist/stores/replies/replies-store.js +413 -0
  248. package/dist/stores/replies/replies-store.js.map +1 -0
  249. package/dist/stores/replies/utils.d.ts +25 -0
  250. package/dist/stores/replies/utils.d.ts.map +1 -0
  251. package/dist/stores/replies/utils.js +549 -0
  252. package/dist/stores/replies/utils.js.map +1 -0
  253. package/dist/stores/replies-pages/index.d.ts +4 -0
  254. package/dist/stores/replies-pages/index.d.ts.map +1 -0
  255. package/dist/stores/replies-pages/index.js +4 -0
  256. package/dist/stores/replies-pages/index.js.map +1 -0
  257. package/dist/stores/replies-pages/replies-pages-store.d.ts +20 -0
  258. package/dist/stores/replies-pages/replies-pages-store.d.ts.map +1 -0
  259. package/dist/stores/replies-pages/replies-pages-store.js +270 -0
  260. package/dist/stores/replies-pages/replies-pages-store.js.map +1 -0
  261. package/dist/stores/replies-pages/utils.d.ts +3 -0
  262. package/dist/stores/replies-pages/utils.d.ts.map +1 -0
  263. package/dist/stores/replies-pages/utils.js +43 -0
  264. package/dist/stores/replies-pages/utils.js.map +1 -0
  265. package/dist/types.d.ts +638 -0
  266. package/dist/types.d.ts.map +1 -0
  267. package/dist/types.js +3 -0
  268. package/dist/types.js.map +1 -0
  269. package/package.json +160 -0
@@ -0,0 +1,307 @@
1
+ import assert from "assert";
2
+ import { assertCommunityRef } from "./community-ref.js";
3
+ const toString = (value) => {
4
+ if (typeof value === "string") {
5
+ return value;
6
+ }
7
+ try {
8
+ const string = JSON.stringify(value);
9
+ return string;
10
+ }
11
+ catch (_a) { }
12
+ return value;
13
+ };
14
+ const getPublicationCommunityAddress = (options) => (options === null || options === void 0 ? void 0 : options.communityAddress) || (options === null || options === void 0 ? void 0 : options.communityAddress);
15
+ const getAccountProtocolClient = (account) => (account === null || account === void 0 ? void 0 : account.pkc) || (account === null || account === void 0 ? void 0 : account.pkc);
16
+ const validateAccountsActionsPublishCommentArguments = ({ publishCommentOptions, accountName, account, }) => {
17
+ assert(!accountName || typeof accountName === "string", `publishComment accountName '${accountName}' not a string`);
18
+ assert(accountName !== "", `publishComment accountName argument is empty string`);
19
+ assert(!accountName || account, `publishComment no account with name '${accountName}' in accountsStore`);
20
+ assert(publishCommentOptions && typeof publishCommentOptions === "object", "publishComment publishCommentOptions not an object");
21
+ assert(typeof publishCommentOptions.onChallenge === "function", "publishComment publishCommentOptions.onChallenge not a function");
22
+ assert(typeof publishCommentOptions.onChallengeVerification === "function", "publishComment publishCommentOptions.onChallengeVerification not a function");
23
+ assert(!publishCommentOptions.onError || typeof publishCommentOptions.onError === "function", "publishComment publishCommentOptions.onError not a function");
24
+ assert(typeof getPublicationCommunityAddress(publishCommentOptions) === "string", "publishComment publishCommentOptions.communityAddress/communityAddress not a string");
25
+ assert(!publishCommentOptions.parentCid || typeof publishCommentOptions.parentCid === "string", "publishComment publishCommentOptions.parentCid not a string");
26
+ assert(!publishCommentOptions.timestamp || typeof publishCommentOptions.timestamp === "number", "publishComment publishCommentOptions.timestamp is not a number");
27
+ // validate content
28
+ assert(!publishCommentOptions.content || typeof publishCommentOptions.content === "string", "publishComment publishCommentOptions.content not a string");
29
+ assert(publishCommentOptions.content !== "", "publishComment publishCommentOptions.content is an empty string");
30
+ assert(!publishCommentOptions.link || typeof publishCommentOptions.link === "string", "publishComment publishCommentOptions.link not a string");
31
+ assert(publishCommentOptions.link !== "", "publishComment publishCommentOptions.link is an empty string");
32
+ assert(!publishCommentOptions.title || typeof publishCommentOptions.title === "string", "publishComment publishCommentOptions.title not a string");
33
+ assert(publishCommentOptions.title !== "", "publishComment publishCommentOptions.title is an empty string");
34
+ };
35
+ const validateAccountsActionsPublishVoteArguments = ({ publishVoteOptions, accountName, account, }) => {
36
+ assert(!accountName || typeof accountName === "string", `publishVote accountName '${accountName}' not a string`);
37
+ assert(accountName !== "", `publishVote accountName argument is empty string`);
38
+ assert(!accountName || account, `publishVote no account with name '${accountName}' in accountsStore`);
39
+ assert(publishVoteOptions && typeof publishVoteOptions === "object", "publishVote publishVoteOptions not an object");
40
+ assert(typeof publishVoteOptions.onChallenge === "function", "publishVote publishVoteOptions.onChallenge not a function");
41
+ assert(typeof publishVoteOptions.onChallengeVerification === "function", "publishVote publishVoteOptions.onChallengeVerification not a function");
42
+ assert(!publishVoteOptions.onError || typeof publishVoteOptions.onError === "function", "publishVote publishVoteOptions.onError not a function");
43
+ assert(typeof getPublicationCommunityAddress(publishVoteOptions) === "string", "publishVote publishVoteOptions.communityAddress/communityAddress not a string");
44
+ assert(typeof publishVoteOptions.commentCid === "string", "publishVote publishVoteOptions.commentCid not a string");
45
+ assert(publishVoteOptions.vote === 1 ||
46
+ publishVoteOptions.vote === 0 ||
47
+ publishVoteOptions.vote === -1, "publishVote publishVoteOptions.vote not 1, 0 or -1");
48
+ assert(!publishVoteOptions.timestamp || typeof publishVoteOptions.timestamp === "number", "publishVote publishVoteOptions.timestamp is not a number");
49
+ };
50
+ const validateAccountsActionsPublishCommentEditArguments = ({ publishCommentEditOptions, accountName, account, }) => {
51
+ assert(!accountName || typeof accountName === "string", `publishCommentEdit accountName '${accountName}' not a string`);
52
+ assert(accountName !== "", `publishCommentEdit accountName argument is empty string`);
53
+ assert(!accountName || account, `publishCommentEdit no account with name '${accountName}' in accountsStore`);
54
+ assert(publishCommentEditOptions && typeof publishCommentEditOptions === "object", "publishCommentEdit publishCommentEditOptions not an object");
55
+ assert(typeof publishCommentEditOptions.onChallenge === "function", "publishCommentEdit publishCommentEditOptions.onChallenge not a function");
56
+ assert(typeof publishCommentEditOptions.onChallengeVerification === "function", "publishCommentEdit publishCommentEditOptions.onChallengeVerification not a function");
57
+ assert(!publishCommentEditOptions.onError || typeof publishCommentEditOptions.onError === "function", "publishCommentEditOptions publishCommentEditOptions.onError not a function");
58
+ assert(typeof getPublicationCommunityAddress(publishCommentEditOptions) === "string", "publishCommentEdit publishCommentEditOptions.communityAddress/communityAddress not a string");
59
+ assert(typeof publishCommentEditOptions.commentCid === "string", "publishCommentEdit publishCommentEditOptions.commentCid not a string");
60
+ assert(!publishCommentEditOptions.timestamp || typeof publishCommentEditOptions.timestamp === "number", "publishCommentEdit publishCommentEditOptions.timestamp is not a number");
61
+ };
62
+ const validateAccountsActionsPublishCommentModerationArguments = ({ publishCommentModerationOptions, accountName, account, }) => {
63
+ assert(!accountName || typeof accountName === "string", `publishCommentModeration accountName '${accountName}' not a string`);
64
+ assert(accountName !== "", `publishCommentModeration accountName argument is empty string`);
65
+ assert(!accountName || account, `publishCommentModeration no account with name '${accountName}' in accountsStore`);
66
+ assert(publishCommentModerationOptions && typeof publishCommentModerationOptions === "object", "publishCommentModeration publishCommentModerationOptions not an object");
67
+ assert(typeof publishCommentModerationOptions.onChallenge === "function", "publishCommentModeration publishCommentModerationOptions.onChallenge not a function");
68
+ assert(typeof publishCommentModerationOptions.onChallengeVerification === "function", "publishCommentModeration publishCommentModerationOptions.onChallengeVerification not a function");
69
+ assert(!publishCommentModerationOptions.onError ||
70
+ typeof publishCommentModerationOptions.onError === "function", "publishCommentModerationOptions publishCommentModerationOptions.onError not a function");
71
+ assert(typeof getPublicationCommunityAddress(publishCommentModerationOptions) === "string", "publishCommentModeration publishCommentModerationOptions.communityAddress/communityAddress not a string");
72
+ assert(typeof publishCommentModerationOptions.commentCid === "string", "publishCommentModeration publishCommentModerationOptions.commentCid not a string");
73
+ assert(!publishCommentModerationOptions.timestamp ||
74
+ typeof publishCommentModerationOptions.timestamp === "number", "publishCommentModeration publishCommentModerationOptions.timestamp is not a number");
75
+ assert(publishCommentModerationOptions.commentModeration &&
76
+ typeof publishCommentModerationOptions.commentModeration === "object", "publishCommentModeration publishCommentModerationOptions.commentModeration is not an object");
77
+ };
78
+ const validateAccountsActionsPublishCommunityEditArguments = ({ communityAddress, publishCommunityEditOptions, accountName, account, }) => {
79
+ assert(!accountName || typeof accountName === "string", `publishCommunityEdit accountName '${accountName}' not a string`);
80
+ assert(accountName !== "", `publishCommunityEdit accountName argument is empty string`);
81
+ assert(!accountName || account, `publishCommunityEdit no account with name '${accountName}' in accountsStore`);
82
+ assert(publishCommunityEditOptions && typeof publishCommunityEditOptions === "object", "publishCommunityEdit publishCommunityEditOptions not an object");
83
+ assert(typeof publishCommunityEditOptions.onChallenge === "function", "publishCommunityEdit publishCommunityEditOptions.onChallenge not a function");
84
+ assert(typeof publishCommunityEditOptions.onChallengeVerification === "function", "publishCommunityEdit publishCommunityEditOptions.onChallengeVerification not a function");
85
+ assert(!publishCommunityEditOptions.onError ||
86
+ typeof publishCommunityEditOptions.onError === "function", "publishCommunityEdit publishCommunityEditOptions.onError not a function");
87
+ assert(communityAddress !== "", `publishCommunityEdit communityAddress argument is empty string`);
88
+ assert(typeof communityAddress === "string", "publishCommunityEdit communityAddress not a string");
89
+ assert(!publishCommunityEditOptions.timestamp ||
90
+ typeof publishCommunityEditOptions.timestamp === "number", "publishCommunityEdit publishCommunityEditOptions.timestamp is not a number");
91
+ };
92
+ const validateAccountsActionsExportAccountArguments = (accountName) => {
93
+ assert(typeof accountName === "string", `exportAccount accountName '${accountName}' not a string`);
94
+ assert(accountName !== "", `exportAccount accountName argument is empty string`);
95
+ };
96
+ const validateAccountsActionsSetAccountsOrderArguments = (newOrderedAccountNames, accountNames) => {
97
+ assert(JSON.stringify([...accountNames].sort()) === JSON.stringify([...newOrderedAccountNames].sort()), `previous account names '${accountNames} contain different account names than argument newOrderedAccountNames '${newOrderedAccountNames}'`);
98
+ };
99
+ const validateAccountsActionsSetAccountArguments = (account) => {
100
+ assert(account && typeof account === "object", `setAccount account '${account}' not an object`);
101
+ assert(typeof account.name === "string", `setAccount account.name '${account.name}' not a string`);
102
+ assert(account.name !== "", `setAccount account.name is empty string`);
103
+ assert(typeof account.id === "string", `setAccount account.id '${account.id}' not a string`);
104
+ assert(account.id !== "", `setAccount account.id is empty string`);
105
+ };
106
+ const validateAccountsActionsSetActiveAccountArguments = (accountName) => {
107
+ assert(typeof accountName === "string", `setActiveAccountName accountName '${accountName}' not a string`);
108
+ assert(accountName !== "", `setActiveAccountName accountName argument is empty string`);
109
+ };
110
+ const validateAccountsDatabaseGetAccountsArguments = (accountIds) => {
111
+ assert(Array.isArray(accountIds), `accountsDatabase.getAccounts accountIds '${accountIds}' not an array`);
112
+ assert(accountIds.length > 0, `accountsDatabase.getAccounts accountIds array is empty`);
113
+ for (const accountId of accountIds) {
114
+ assert(typeof accountId === "string", `accountsDatabase.getAccountsaccountIds '${accountIds}' accountId '${accountId}' not a string`);
115
+ assert(accountId !== "", `accountsDatabase.getAccounts accountIds '${accountIds}' an accountId argument is empty string`);
116
+ }
117
+ };
118
+ const validateAccountsDatabaseAccountNames = (accountNames) => {
119
+ assert(Array.isArray(accountNames), `accountsDatabase accountNames '${accountNames}' not an array`);
120
+ for (const accountName of accountNames) {
121
+ assert(typeof accountName === "string", `accountsDatabase accountNames '${accountNames}' accountName '${accountName}' not a string`);
122
+ }
123
+ };
124
+ const validateAccountsDatabaseAddAccountArguments = (account) => {
125
+ assert(account && typeof account === "object", `accountsDatabase.addAccount '${account}' not an object`);
126
+ assert(typeof account.name === "string", `accountsDatabase.addAccount account.name '${account.name}' not a string`);
127
+ assert(account.name !== "", `accountsDatabase.addAccount account.name is empty string`);
128
+ assert(typeof account.id === "string", `accountsDatabase.addAccount account.id '${account.id}' not a string`);
129
+ assert(account.id !== "", `accountsDatabase.addAccount account.id is empty string`);
130
+ };
131
+ const validateUseCommentArguments = (commentCid, account) => {
132
+ assert(typeof commentCid === "string", `useComment commentCid '${commentCid}' not a string`);
133
+ assert(getAccountProtocolClient(account) && typeof getAccountProtocolClient(account) === "object", `useComment account.pkc/account.pkc '${getAccountProtocolClient(account)}' not an object`);
134
+ };
135
+ const validateUseCommentsArguments = (commentCids, account) => {
136
+ assert(Array.isArray(commentCids), `useComment commentCids '${toString(commentCids)}' not an array`);
137
+ for (const commentCid of commentCids) {
138
+ assert(typeof commentCid === "string", `useComments commentCids '${toString(commentCids)}' commentCid '${toString(commentCid)}' not a string`);
139
+ }
140
+ assert(getAccountProtocolClient(account) && typeof getAccountProtocolClient(account) === "object", `useComments account.pkc/account.pkc '${getAccountProtocolClient(account)}' not an object`);
141
+ };
142
+ const validateCommunityIdentifierArguments = (community, legacyCommunityAddress, scope) => {
143
+ assert(legacyCommunityAddress === undefined, `${scope} communityAddress has been removed, pass { community: { name, publicKey } }`);
144
+ if (community === undefined) {
145
+ return;
146
+ }
147
+ assertCommunityRef(community, `${scope} community`);
148
+ };
149
+ const validateUseCommunityArguments = ({ community, communityAddress, account }) => {
150
+ validateCommunityIdentifierArguments(community, communityAddress, "useCommunity");
151
+ if (account !== undefined && account !== null) {
152
+ assert(getAccountProtocolClient(account) && typeof getAccountProtocolClient(account) === "object", `useCommunity account.pkc/account.pkc '${getAccountProtocolClient(account)}' not an object`);
153
+ }
154
+ };
155
+ const validateUseCommunityStatsArguments = ({ community, communityAddress }) => {
156
+ validateCommunityIdentifierArguments(community, communityAddress, "useCommunityStats");
157
+ };
158
+ const validateCommunitiesArguments = (communities, communityRefs, communityAddresses, scope) => {
159
+ assert(communityRefs === undefined, `${scope} communityRefs has been removed, pass communities instead`);
160
+ assert(communityAddresses === undefined, `${scope} communityAddresses has been removed, pass communities instead`);
161
+ if (communities !== undefined) {
162
+ assert(Array.isArray(communities), `${scope} communities '${toString(communities)}' not an array`);
163
+ for (const community of communities) {
164
+ assertCommunityRef(community, `${scope} communities '${toString(communities)}' community '${toString(community)}'`);
165
+ }
166
+ }
167
+ };
168
+ const validateUseCommunitiesArguments = ({ communities, communityRefs, communityAddresses, account, }) => {
169
+ validateCommunitiesArguments(communities, communityRefs, communityAddresses, "useCommunities");
170
+ if (account !== undefined && account !== null) {
171
+ assert(getAccountProtocolClient(account) && typeof getAccountProtocolClient(account) === "object", `useCommunity account.pkc/account.pkc '${getAccountProtocolClient(account)}' not an object`);
172
+ }
173
+ };
174
+ const feedSortTypes = new Set([
175
+ "hot",
176
+ "new",
177
+ "active",
178
+ "topHour",
179
+ "topDay",
180
+ "topWeek",
181
+ "topMonth",
182
+ "topYear",
183
+ "topAll",
184
+ "controversialHour",
185
+ "controversialDay",
186
+ "controversialWeek",
187
+ "controversialMonth",
188
+ "controversialYear",
189
+ "controversialAll",
190
+ ]);
191
+ const validateFeedSortType = (sortType) => {
192
+ assert(feedSortTypes.has(sortType), `invalid feed sort type '${sortType}'`);
193
+ };
194
+ const validateUseFeedArguments = ({ communities, communityRefs, communityAddresses, sortType, accountName, postsPerPage, filter, newerThan, accountComments, }) => {
195
+ validateCommunitiesArguments(communities, communityRefs, communityAddresses, "useFeed");
196
+ assert(feedSortTypes.has(sortType), `useFeed sortType argument '${sortType}' invalid`);
197
+ if (accountName) {
198
+ assert(typeof accountName === "string", `useFeed accountName argument '${accountName}' not a string`);
199
+ }
200
+ if (postsPerPage !== undefined && postsPerPage !== null) {
201
+ assert(typeof postsPerPage === "number", `useFeed postsPerPage argument '${postsPerPage}' not a number`);
202
+ }
203
+ if (filter) {
204
+ assert(typeof filter.filter === "function", `useFeed filter.filter argument '${filter.filter}' not a function, useFeedOptions.filter is now an object Filter {filter: (comment: Comment) => Boolean, key: string}`);
205
+ assert(typeof filter.key === "string", `useFeed filter.key argument '${filter.key}' not a string, a unique filter.key is now required to cache the filter`);
206
+ }
207
+ if (newerThan !== undefined && newerThan !== null) {
208
+ assert(typeof newerThan === "number", `useFeed newerThan argument '${newerThan}' not a number`);
209
+ }
210
+ if (accountComments) {
211
+ assert(typeof accountComments === "object", `useFeed accountComments argument '${accountComments}' not an object`);
212
+ assert(typeof accountComments.newerThan === "number", `useFeed accountComments.newerThan argument '${accountComments}' not a number`);
213
+ }
214
+ };
215
+ const validateUseBufferedFeedsArguments = ({ feedsOptions, accountName, }) => {
216
+ assert(Array.isArray(feedsOptions), `useBufferedFeeds feedsOptions argument '${toString(feedsOptions)}' not an array`);
217
+ for (const { communities, communityRefs, communityAddresses, sortType, postsPerPage, filter, newerThan, } of feedsOptions) {
218
+ validateCommunitiesArguments(communities, communityRefs, communityAddresses, "useBufferedFeeds feedOptions");
219
+ if (sortType) {
220
+ assert(feedSortTypes.has(sortType), `useBufferedFeeds feedOptions.sortType argument '${sortType}' invalid`);
221
+ }
222
+ if (postsPerPage !== undefined && postsPerPage !== null) {
223
+ assert(typeof postsPerPage === "number", `useBufferedFeeds feedOptions.postsPerPage argument '${postsPerPage}' not a number`);
224
+ }
225
+ if (filter) {
226
+ assert(typeof filter.filter === "function", `useBufferedFeeds feedOptions.filter.filter argument '${filter.filter}' not a function, useFeedOptions.filter is now an object Filter {filter: (comment: Comment) => Boolean, key: string}`);
227
+ assert(typeof filter.key === "string", `useBufferedFeeds feedOptions.filter.key argument '${filter.key}' not a string, a unique filter.key is now required to cache the filter`);
228
+ }
229
+ if (newerThan !== undefined && newerThan !== null) {
230
+ assert(typeof newerThan === "number", `useBufferedFeeds feedOptions.newerThan argument '${newerThan}' not a number`);
231
+ }
232
+ }
233
+ if (accountName) {
234
+ assert(typeof accountName === "string", `useBufferedFeeds accountName argument '${accountName}' not a string`);
235
+ }
236
+ };
237
+ const validateUseCommunitiesStatesArguments = ({ communities, communityRefs, communityAddresses, }) => {
238
+ validateCommunitiesArguments(communities, communityRefs, communityAddresses, "useCommunitiesStates");
239
+ };
240
+ const repliesSortTypes = new Set([
241
+ "best",
242
+ "topHour",
243
+ "topDay",
244
+ "topWeek",
245
+ "topMonth",
246
+ "topYear",
247
+ "topAll",
248
+ "new",
249
+ "newFlat",
250
+ "old",
251
+ "oldFlat",
252
+ ]);
253
+ const validateRepliesSortType = (sortType) => {
254
+ assert(repliesSortTypes.has(sortType), `invalid replies sort type '${sortType}'`);
255
+ };
256
+ const validateUseRepliesArguments = (comment, sortType, accountName, onlyIfCached, flat, accountComments, postsPerPage, filter) => {
257
+ assert(!comment || typeof comment === "object", `useReplies comment argument '${comment}' not an object`);
258
+ assert(!(comment === null || comment === void 0 ? void 0 : comment.cid) || typeof comment.cid === "string", `useReplies comment.cid argument '${comment === null || comment === void 0 ? void 0 : comment.cid}' not a string`);
259
+ assert(repliesSortTypes.has(sortType), `useReplies sortType argument '${sortType}' invalid`);
260
+ if (accountName) {
261
+ assert(typeof accountName === "string", `useReplies accountName argument '${accountName}' not a string`);
262
+ }
263
+ if (onlyIfCached !== undefined && onlyIfCached !== null) {
264
+ assert(typeof onlyIfCached === "boolean", `useReplies onlyIfCached argument '${onlyIfCached}' not a boolean`);
265
+ }
266
+ if (postsPerPage !== undefined && postsPerPage !== null) {
267
+ assert(typeof postsPerPage === "number", `useReplies postsPerPage argument '${postsPerPage}' not a number`);
268
+ }
269
+ if (flat !== undefined && flat !== null) {
270
+ assert(typeof flat === "boolean", `useReplies flat argument '${flat}' not a boolean`);
271
+ }
272
+ if (accountComments !== undefined && accountComments !== null) {
273
+ assert(typeof accountComments.newerThan === "number", `useReplies accountComments.newerThan argument '${accountComments.newerThan}' not a number`);
274
+ assert(!accountComments.append || typeof accountComments.append === "boolean", `useReplies accountComments.append argument '${accountComments.append}' not a boolean`);
275
+ }
276
+ if (filter) {
277
+ assert(typeof filter.filter === "function", `useReplies filter.filter argument '${filter.filter}' not a function, useRepliesOptions.filter is now an object Filter {filter: (comment: Comment) => Boolean, key: string}`);
278
+ assert(typeof filter.key === "string", `useReplies filter.key argument '${filter.key}' not a string, a unique filter.key is now required to cache the filter`);
279
+ }
280
+ };
281
+ const validator = {
282
+ validateAccountsActionsPublishCommentArguments,
283
+ validateAccountsActionsPublishCommentEditArguments,
284
+ validateAccountsActionsPublishCommentModerationArguments,
285
+ validateAccountsActionsPublishCommunityEditArguments,
286
+ validateAccountsActionsPublishVoteArguments,
287
+ validateAccountsActionsExportAccountArguments,
288
+ validateAccountsActionsSetAccountsOrderArguments,
289
+ validateAccountsActionsSetAccountArguments,
290
+ validateAccountsActionsSetActiveAccountArguments,
291
+ validateAccountsDatabaseAddAccountArguments,
292
+ validateAccountsDatabaseGetAccountsArguments,
293
+ validateAccountsDatabaseAccountNames,
294
+ validateUseCommentArguments,
295
+ validateUseCommentsArguments,
296
+ validateUseCommunityArguments,
297
+ validateUseCommunityStatsArguments,
298
+ validateUseCommunitiesArguments,
299
+ validateUseCommunitiesStatesArguments,
300
+ validateFeedSortType,
301
+ validateUseFeedArguments,
302
+ validateUseBufferedFeedsArguments,
303
+ validateRepliesSortType,
304
+ validateUseRepliesArguments,
305
+ };
306
+ export default validator;
307
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAE,EAAE;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,WAAM,CAAC,CAAA,CAAC;IACV,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,8BAA8B,GAAG,CAAC,OAAY,EAAE,EAAE,CACtD,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,MAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,CAAA,CAAC;AACzD,MAAM,wBAAwB,GAAG,CAAC,OAAY,EAAE,EAAE,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,MAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,CAAA,CAAC;AAEhF,MAAM,8CAA8C,GAAG,CAAC,EACtD,qBAAqB,EACrB,WAAW,EACX,OAAO,GACH,EAAE,EAAE;IACR,MAAM,CACJ,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAC/C,+BAA+B,WAAW,gBAAgB,CAC3D,CAAC;IACF,MAAM,CAAC,WAAW,KAAK,EAAE,EAAE,qDAAqD,CAAC,CAAC;IAClF,MAAM,CACJ,CAAC,WAAW,IAAI,OAAO,EACvB,wCAAwC,WAAW,oBAAoB,CACxE,CAAC;IACF,MAAM,CACJ,qBAAq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CACJ,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EACnC,sCAAsC,MAAM,CAAC,MAAM,yHAAyH,CAC7K,CAAC;QACF,MAAM,CACJ,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,EAC9B,mCAAmC,MAAM,CAAC,GAAG,yEAAyE,CACvH,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG;IAChB,8CAA8C;IAC9C,kDAAkD;IAClD,wDAAwD;IACxD,oDAAoD;IACpD,2CAA2C;IAC3C,6CAA6C;IAC7C,gDAAgD;IAChD,0CAA0C;IAC1C,gDAAgD;IAChD,2CAA2C;IAC3C,4CAA4C;IAC5C,oCAAoC;IACpC,2BAA2B;IAC3B,4BAA4B;IAC5B,6BAA6B;IAC7B,kCAAkC;IAClC,+BAA+B;IAC/B,qCAAqC;IACrC,oBAAoB;IACpB,wBAAwB;IACxB,iCAAiC;IACjC,uBAAuB;IACvB,2BAA2B;CAC5B,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import assert from \"assert\";\nimport { assertCommunityRef } from \"./community-ref\";\n\nconst toString = (value: any) => {\n if (typeof value === \"string\") {\n return value;\n }\n try {\n const string = JSON.stringify(value);\n return string;\n } catch {}\n return value;\n};\n\nconst getPublicationCommunityAddress = (options: any) =>\n options?.communityAddress || options?.communityAddress;\nconst getAccountProtocolClient = (account: any) => account?.pkc || account?.pkc;\n\nconst validateAccountsActionsPublishCommentArguments = ({\n publishCommentOptions,\n accountName,\n account,\n}: any) => {\n assert(\n !accountName || typeof accountName === \"string\",\n `publishComment accountName '${accountName}' not a string`,\n );\n assert(accountName !== \"\", `publishComment accountName argument is empty string`);\n assert(\n !accountName || account,\n `publishComment no account with name '${accountName}' in accountsStore`,\n );\n assert(\n publishCommentOptions && typeof publishCommentOptions === \"object\",\n \"publishComment publishCommentOptions not an object\",\n );\n assert(\n typeof publishCommentOptions.onChallenge === \"function\",\n \"publishComment publishCommentOptions.onChallenge not a function\",\n );\n assert(\n typeof publishCommentOptions.onChallengeVerification === \"function\",\n \"publishComment publishCommentOptions.onChallengeVerification not a function\",\n );\n assert(\n !publishCommentOptions.onError || typeof publishCommentOptions.onError === \"function\",\n \"publishComment publishCommentOptions.onError not a function\",\n );\n assert(\n typeof getPublicationCommunityAddress(publishCommentOptions) === \"string\",\n \"publishComment publishCommentOptions.communityAddress/communityAddress not a string\",\n );\n assert(\n !publishCommentOptions.parentCid || typeof publishCommentOptions.parentCid === \"string\",\n \"publishComment publishCommentOptions.parentCid not a string\",\n );\n assert(\n !publishCommentOptions.timestamp || typeof publishCommentOptions.timestamp === \"number\",\n \"publishComment publishCommentOptions.timestamp is not a number\",\n );\n\n // validate content\n assert(\n !publishCommentOptions.content || typeof publishCommentOptions.content === \"string\",\n \"publishComment publishCommentOptions.content not a string\",\n );\n assert(\n publishCommentOptions.content !== \"\",\n \"publishComment publishCommentOptions.content is an empty string\",\n );\n assert(\n !publishCommentOptions.link || typeof publishCommentOptions.link === \"string\",\n \"publishComment publishCommentOptions.link not a string\",\n );\n assert(\n publishCommentOptions.link !== \"\",\n \"publishComment publishCommentOptions.link is an empty string\",\n );\n assert(\n !publishCommentOptions.title || typeof publishCommentOptions.title === \"string\",\n \"publishComment publishCommentOptions.title not a string\",\n );\n assert(\n publishCommentOptions.title !== \"\",\n \"publishComment publishCommentOptions.title is an empty string\",\n );\n};\n\nconst validateAccountsActionsPublishVoteArguments = ({\n publishVoteOptions,\n accountName,\n account,\n}: any) => {\n assert(\n !accountName || typeof accountName === \"string\",\n `publishVote accountName '${accountName}' not a string`,\n );\n assert(accountName !== \"\", `publishVote accountName argument is empty string`);\n assert(\n !accountName || account,\n `publishVote no account with name '${accountName}' in accountsStore`,\n );\n assert(\n publishVoteOptions && typeof publishVoteOptions === \"object\",\n \"publishVote publishVoteOptions not an object\",\n );\n assert(\n typeof publishVoteOptions.onChallenge === \"function\",\n \"publishVote publishVoteOptions.onChallenge not a function\",\n );\n assert(\n typeof publishVoteOptions.onChallengeVerification === \"function\",\n \"publishVote publishVoteOptions.onChallengeVerification not a function\",\n );\n assert(\n !publishVoteOptions.onError || typeof publishVoteOptions.onError === \"function\",\n \"publishVote publishVoteOptions.onError not a function\",\n );\n assert(\n typeof getPublicationCommunityAddress(publishVoteOptions) === \"string\",\n \"publishVote publishVoteOptions.communityAddress/communityAddress not a string\",\n );\n assert(\n typeof publishVoteOptions.commentCid === \"string\",\n \"publishVote publishVoteOptions.commentCid not a string\",\n );\n assert(\n publishVoteOptions.vote === 1 ||\n publishVoteOptions.vote === 0 ||\n publishVoteOptions.vote === -1,\n \"publishVote publishVoteOptions.vote not 1, 0 or -1\",\n );\n assert(\n !publishVoteOptions.timestamp || typeof publishVoteOptions.timestamp === \"number\",\n \"publishVote publishVoteOptions.timestamp is not a number\",\n );\n};\n\nconst validateAccountsActionsPublishCommentEditArguments = ({\n publishCommentEditOptions,\n accountName,\n account,\n}: any) => {\n assert(\n !accountName || typeof accountName === \"string\",\n `publishCommentEdit accountName '${accountName}' not a string`,\n );\n assert(accountName !== \"\", `publishCommentEdit accountName argument is empty string`);\n assert(\n !accountName || account,\n `publishCommentEdit no account with name '${accountName}' in accountsStore`,\n );\n assert(\n publishCommentEditOptions && typeof publishCommentEditOptions === \"object\",\n \"publishCommentEdit publishCommentEditOptions not an object\",\n );\n assert(\n typeof publishCommentEditOptions.onChallenge === \"function\",\n \"publishCommentEdit publishCommentEditOptions.onChallenge not a function\",\n );\n assert(\n typeof publishCommentEditOptions.onChallengeVerification === \"function\",\n \"publishCommentEdit publishCommentEditOptions.onChallengeVerification not a function\",\n );\n assert(\n !publishCommentEditOptions.onError || typeof publishCommentEditOptions.onError === \"function\",\n \"publishCommentEditOptions publishCommentEditOptions.onError not a function\",\n );\n assert(\n typeof getPublicationCommunityAddress(publishCommentEditOptions) === \"string\",\n \"publishCommentEdit publishCommentEditOptions.communityAddress/communityAddress not a string\",\n );\n assert(\n typeof publishCommentEditOptions.commentCid === \"string\",\n \"publishCommentEdit publishCommentEditOptions.commentCid not a string\",\n );\n assert(\n !publishCommentEditOptions.timestamp || typeof publishCommentEditOptions.timestamp === \"number\",\n \"publishCommentEdit publishCommentEditOptions.timestamp is not a number\",\n );\n};\n\nconst validateAccountsActionsPublishCommentModerationArguments = ({\n publishCommentModerationOptions,\n accountName,\n account,\n}: any) => {\n assert(\n !accountName || typeof accountName === \"string\",\n `publishCommentModeration accountName '${accountName}' not a string`,\n );\n assert(accountName !== \"\", `publishCommentModeration accountName argument is empty string`);\n assert(\n !accountName || account,\n `publishCommentModeration no account with name '${accountName}' in accountsStore`,\n );\n assert(\n publishCommentModerationOptions && typeof publishCommentModerationOptions === \"object\",\n \"publishCommentModeration publishCommentModerationOptions not an object\",\n );\n assert(\n typeof publishCommentModerationOptions.onChallenge === \"function\",\n \"publishCommentModeration publishCommentModerationOptions.onChallenge not a function\",\n );\n assert(\n typeof publishCommentModerationOptions.onChallengeVerification === \"function\",\n \"publishCommentModeration publishCommentModerationOptions.onChallengeVerification not a function\",\n );\n assert(\n !publishCommentModerationOptions.onError ||\n typeof publishCommentModerationOptions.onError === \"function\",\n \"publishCommentModerationOptions publishCommentModerationOptions.onError not a function\",\n );\n assert(\n typeof getPublicationCommunityAddress(publishCommentModerationOptions) === \"string\",\n \"publishCommentModeration publishCommentModerationOptions.communityAddress/communityAddress not a string\",\n );\n assert(\n typeof publishCommentModerationOptions.commentCid === \"string\",\n \"publishCommentModeration publishCommentModerationOptions.commentCid not a string\",\n );\n assert(\n !publishCommentModerationOptions.timestamp ||\n typeof publishCommentModerationOptions.timestamp === \"number\",\n \"publishCommentModeration publishCommentModerationOptions.timestamp is not a number\",\n );\n assert(\n publishCommentModerationOptions.commentModeration &&\n typeof publishCommentModerationOptions.commentModeration === \"object\",\n \"publishCommentModeration publishCommentModerationOptions.commentModeration is not an object\",\n );\n};\n\nconst validateAccountsActionsPublishCommunityEditArguments = ({\n communityAddress,\n publishCommunityEditOptions,\n accountName,\n account,\n}: any) => {\n assert(\n !accountName || typeof accountName === \"string\",\n `publishCommunityEdit accountName '${accountName}' not a string`,\n );\n assert(accountName !== \"\", `publishCommunityEdit accountName argument is empty string`);\n assert(\n !accountName || account,\n `publishCommunityEdit no account with name '${accountName}' in accountsStore`,\n );\n assert(\n publishCommunityEditOptions && typeof publishCommunityEditOptions === \"object\",\n \"publishCommunityEdit publishCommunityEditOptions not an object\",\n );\n assert(\n typeof publishCommunityEditOptions.onChallenge === \"function\",\n \"publishCommunityEdit publishCommunityEditOptions.onChallenge not a function\",\n );\n assert(\n typeof publishCommunityEditOptions.onChallengeVerification === \"function\",\n \"publishCommunityEdit publishCommunityEditOptions.onChallengeVerification not a function\",\n );\n assert(\n !publishCommunityEditOptions.onError ||\n typeof publishCommunityEditOptions.onError === \"function\",\n \"publishCommunityEdit publishCommunityEditOptions.onError not a function\",\n );\n assert(communityAddress !== \"\", `publishCommunityEdit communityAddress argument is empty string`);\n assert(\n typeof communityAddress === \"string\",\n \"publishCommunityEdit communityAddress not a string\",\n );\n assert(\n !publishCommunityEditOptions.timestamp ||\n typeof publishCommunityEditOptions.timestamp === \"number\",\n \"publishCommunityEdit publishCommunityEditOptions.timestamp is not a number\",\n );\n};\n\nconst validateAccountsActionsExportAccountArguments = (accountName: any) => {\n assert(\n typeof accountName === \"string\",\n `exportAccount accountName '${accountName}' not a string`,\n );\n assert(accountName !== \"\", `exportAccount accountName argument is empty string`);\n};\n\nconst validateAccountsActionsSetAccountsOrderArguments = (\n newOrderedAccountNames: any,\n accountNames: any,\n) => {\n assert(\n JSON.stringify([...accountNames].sort()) === JSON.stringify([...newOrderedAccountNames].sort()),\n `previous account names '${accountNames} contain different account names than argument newOrderedAccountNames '${newOrderedAccountNames}'`,\n );\n};\n\nconst validateAccountsActionsSetAccountArguments = (account: any) => {\n assert(account && typeof account === \"object\", `setAccount account '${account}' not an object`);\n assert(\n typeof account.name === \"string\",\n `setAccount account.name '${account.name}' not a string`,\n );\n assert(account.name !== \"\", `setAccount account.name is empty string`);\n assert(typeof account.id === \"string\", `setAccount account.id '${account.id}' not a string`);\n assert(account.id !== \"\", `setAccount account.id is empty string`);\n};\n\nconst validateAccountsActionsSetActiveAccountArguments = (accountName: any) => {\n assert(\n typeof accountName === \"string\",\n `setActiveAccountName accountName '${accountName}' not a string`,\n );\n assert(accountName !== \"\", `setActiveAccountName accountName argument is empty string`);\n};\n\nconst validateAccountsDatabaseGetAccountsArguments = (accountIds: any) => {\n assert(\n Array.isArray(accountIds),\n `accountsDatabase.getAccounts accountIds '${accountIds}' not an array`,\n );\n assert(accountIds.length > 0, `accountsDatabase.getAccounts accountIds array is empty`);\n for (const accountId of accountIds) {\n assert(\n typeof accountId === \"string\",\n `accountsDatabase.getAccountsaccountIds '${accountIds}' accountId '${accountId}' not a string`,\n );\n assert(\n accountId !== \"\",\n `accountsDatabase.getAccounts accountIds '${accountIds}' an accountId argument is empty string`,\n );\n }\n};\n\nconst validateAccountsDatabaseAccountNames = (accountNames: any) => {\n assert(\n Array.isArray(accountNames),\n `accountsDatabase accountNames '${accountNames}' not an array`,\n );\n for (const accountName of accountNames) {\n assert(\n typeof accountName === \"string\",\n `accountsDatabase accountNames '${accountNames}' accountName '${accountName}' not a string`,\n );\n }\n};\n\nconst validateAccountsDatabaseAddAccountArguments = (account: any) => {\n assert(\n account && typeof account === \"object\",\n `accountsDatabase.addAccount '${account}' not an object`,\n );\n assert(\n typeof account.name === \"string\",\n `accountsDatabase.addAccount account.name '${account.name}' not a string`,\n );\n assert(account.name !== \"\", `accountsDatabase.addAccount account.name is empty string`);\n assert(\n typeof account.id === \"string\",\n `accountsDatabase.addAccount account.id '${account.id}' not a string`,\n );\n assert(account.id !== \"\", `accountsDatabase.addAccount account.id is empty string`);\n};\n\nconst validateUseCommentArguments = (commentCid: any, account: any) => {\n assert(typeof commentCid === \"string\", `useComment commentCid '${commentCid}' not a string`);\n assert(\n getAccountProtocolClient(account) && typeof getAccountProtocolClient(account) === \"object\",\n `useComment account.pkc/account.pkc '${getAccountProtocolClient(account)}' not an object`,\n );\n};\n\nconst validateUseCommentsArguments = (commentCids: any, account: any) => {\n assert(\n Array.isArray(commentCids),\n `useComment commentCids '${toString(commentCids)}' not an array`,\n );\n for (const commentCid of commentCids) {\n assert(\n typeof commentCid === \"string\",\n `useComments commentCids '${toString(commentCids)}' commentCid '${toString(commentCid)}' not a string`,\n );\n }\n assert(\n getAccountProtocolClient(account) && typeof getAccountProtocolClient(account) === \"object\",\n `useComments account.pkc/account.pkc '${getAccountProtocolClient(account)}' not an object`,\n );\n};\n\nconst validateCommunityIdentifierArguments = (\n community: any,\n legacyCommunityAddress: any,\n scope: string,\n) => {\n assert(\n legacyCommunityAddress === undefined,\n `${scope} communityAddress has been removed, pass { community: { name, publicKey } }`,\n );\n if (community === undefined) {\n return;\n }\n assertCommunityRef(community, `${scope} community`);\n};\n\nconst validateUseCommunityArguments = ({ community, communityAddress, account }: any) => {\n validateCommunityIdentifierArguments(community, communityAddress, \"useCommunity\");\n if (account !== undefined && account !== null) {\n assert(\n getAccountProtocolClient(account) && typeof getAccountProtocolClient(account) === \"object\",\n `useCommunity account.pkc/account.pkc '${getAccountProtocolClient(account)}' not an object`,\n );\n }\n};\n\nconst validateUseCommunityStatsArguments = ({ community, communityAddress }: any) => {\n validateCommunityIdentifierArguments(community, communityAddress, \"useCommunityStats\");\n};\n\nconst validateCommunitiesArguments = (\n communities: any,\n communityRefs: any,\n communityAddresses: any,\n scope: string,\n) => {\n assert(\n communityRefs === undefined,\n `${scope} communityRefs has been removed, pass communities instead`,\n );\n assert(\n communityAddresses === undefined,\n `${scope} communityAddresses has been removed, pass communities instead`,\n );\n if (communities !== undefined) {\n assert(\n Array.isArray(communities),\n `${scope} communities '${toString(communities)}' not an array`,\n );\n for (const community of communities) {\n assertCommunityRef(\n community,\n `${scope} communities '${toString(communities)}' community '${toString(community)}'`,\n );\n }\n }\n};\n\nconst validateUseCommunitiesArguments = ({\n communities,\n communityRefs,\n communityAddresses,\n account,\n}: any) => {\n validateCommunitiesArguments(communities, communityRefs, communityAddresses, \"useCommunities\");\n if (account !== undefined && account !== null) {\n assert(\n getAccountProtocolClient(account) && typeof getAccountProtocolClient(account) === \"object\",\n `useCommunity account.pkc/account.pkc '${getAccountProtocolClient(account)}' not an object`,\n );\n }\n};\n\nconst feedSortTypes = new Set([\n \"hot\",\n \"new\",\n \"active\",\n \"topHour\",\n \"topDay\",\n \"topWeek\",\n \"topMonth\",\n \"topYear\",\n \"topAll\",\n \"controversialHour\",\n \"controversialDay\",\n \"controversialWeek\",\n \"controversialMonth\",\n \"controversialYear\",\n \"controversialAll\",\n]);\nconst validateFeedSortType = (sortType: any) => {\n assert(feedSortTypes.has(sortType), `invalid feed sort type '${sortType}'`);\n};\nconst validateUseFeedArguments = ({\n communities,\n communityRefs,\n communityAddresses,\n sortType,\n accountName,\n postsPerPage,\n filter,\n newerThan,\n accountComments,\n}: any) => {\n validateCommunitiesArguments(communities, communityRefs, communityAddresses, \"useFeed\");\n assert(feedSortTypes.has(sortType), `useFeed sortType argument '${sortType}' invalid`);\n if (accountName) {\n assert(\n typeof accountName === \"string\",\n `useFeed accountName argument '${accountName}' not a string`,\n );\n }\n if (postsPerPage !== undefined && postsPerPage !== null) {\n assert(\n typeof postsPerPage === \"number\",\n `useFeed postsPerPage argument '${postsPerPage}' not a number`,\n );\n }\n if (filter) {\n assert(\n typeof filter.filter === \"function\",\n `useFeed filter.filter argument '${filter.filter}' not a function, useFeedOptions.filter is now an object Filter {filter: (comment: Comment) => Boolean, key: string}`,\n );\n assert(\n typeof filter.key === \"string\",\n `useFeed filter.key argument '${filter.key}' not a string, a unique filter.key is now required to cache the filter`,\n );\n }\n if (newerThan !== undefined && newerThan !== null) {\n assert(typeof newerThan === \"number\", `useFeed newerThan argument '${newerThan}' not a number`);\n }\n if (accountComments) {\n assert(\n typeof accountComments === \"object\",\n `useFeed accountComments argument '${accountComments}' not an object`,\n );\n assert(\n typeof accountComments.newerThan === \"number\",\n `useFeed accountComments.newerThan argument '${accountComments}' not a number`,\n );\n }\n};\nconst validateUseBufferedFeedsArguments = ({\n feedsOptions,\n accountName,\n}: {\n feedsOptions?: any;\n accountName?: any;\n}) => {\n assert(\n Array.isArray(feedsOptions),\n `useBufferedFeeds feedsOptions argument '${toString(feedsOptions)}' not an array`,\n );\n for (const {\n communities,\n communityRefs,\n communityAddresses,\n sortType,\n postsPerPage,\n filter,\n newerThan,\n } of feedsOptions) {\n validateCommunitiesArguments(\n communities,\n communityRefs,\n communityAddresses,\n \"useBufferedFeeds feedOptions\",\n );\n if (sortType) {\n assert(\n feedSortTypes.has(sortType),\n `useBufferedFeeds feedOptions.sortType argument '${sortType}' invalid`,\n );\n }\n if (postsPerPage !== undefined && postsPerPage !== null) {\n assert(\n typeof postsPerPage === \"number\",\n `useBufferedFeeds feedOptions.postsPerPage argument '${postsPerPage}' not a number`,\n );\n }\n if (filter) {\n assert(\n typeof filter.filter === \"function\",\n `useBufferedFeeds feedOptions.filter.filter argument '${filter.filter}' not a function, useFeedOptions.filter is now an object Filter {filter: (comment: Comment) => Boolean, key: string}`,\n );\n assert(\n typeof filter.key === \"string\",\n `useBufferedFeeds feedOptions.filter.key argument '${filter.key}' not a string, a unique filter.key is now required to cache the filter`,\n );\n }\n if (newerThan !== undefined && newerThan !== null) {\n assert(\n typeof newerThan === \"number\",\n `useBufferedFeeds feedOptions.newerThan argument '${newerThan}' not a number`,\n );\n }\n }\n if (accountName) {\n assert(\n typeof accountName === \"string\",\n `useBufferedFeeds accountName argument '${accountName}' not a string`,\n );\n }\n};\n\nconst validateUseCommunitiesStatesArguments = ({\n communities,\n communityRefs,\n communityAddresses,\n}: any) => {\n validateCommunitiesArguments(\n communities,\n communityRefs,\n communityAddresses,\n \"useCommunitiesStates\",\n );\n};\n\nconst repliesSortTypes = new Set([\n \"best\",\n \"topHour\",\n \"topDay\",\n \"topWeek\",\n \"topMonth\",\n \"topYear\",\n \"topAll\",\n \"new\",\n \"newFlat\",\n \"old\",\n \"oldFlat\",\n]);\nconst validateRepliesSortType = (sortType: any) => {\n assert(repliesSortTypes.has(sortType), `invalid replies sort type '${sortType}'`);\n};\nconst validateUseRepliesArguments = (\n comment?: any,\n sortType?: any,\n accountName?: any,\n onlyIfCached?: any,\n flat?: any,\n accountComments?: any,\n postsPerPage?: any,\n filter?: any,\n) => {\n assert(\n !comment || typeof comment === \"object\",\n `useReplies comment argument '${comment}' not an object`,\n );\n assert(\n !comment?.cid || typeof comment.cid === \"string\",\n `useReplies comment.cid argument '${comment?.cid}' not a string`,\n );\n assert(repliesSortTypes.has(sortType), `useReplies sortType argument '${sortType}' invalid`);\n if (accountName) {\n assert(\n typeof accountName === \"string\",\n `useReplies accountName argument '${accountName}' not a string`,\n );\n }\n if (onlyIfCached !== undefined && onlyIfCached !== null) {\n assert(\n typeof onlyIfCached === \"boolean\",\n `useReplies onlyIfCached argument '${onlyIfCached}' not a boolean`,\n );\n }\n if (postsPerPage !== undefined && postsPerPage !== null) {\n assert(\n typeof postsPerPage === \"number\",\n `useReplies postsPerPage argument '${postsPerPage}' not a number`,\n );\n }\n if (flat !== undefined && flat !== null) {\n assert(typeof flat === \"boolean\", `useReplies flat argument '${flat}' not a boolean`);\n }\n if (accountComments !== undefined && accountComments !== null) {\n assert(\n typeof accountComments.newerThan === \"number\",\n `useReplies accountComments.newerThan argument '${accountComments.newerThan}' not a number`,\n );\n assert(\n !accountComments.append || typeof accountComments.append === \"boolean\",\n `useReplies accountComments.append argument '${accountComments.append}' not a boolean`,\n );\n }\n if (filter) {\n assert(\n typeof filter.filter === \"function\",\n `useReplies filter.filter argument '${filter.filter}' not a function, useRepliesOptions.filter is now an object Filter {filter: (comment: Comment) => Boolean, key: string}`,\n );\n assert(\n typeof filter.key === \"string\",\n `useReplies filter.key argument '${filter.key}' not a string, a unique filter.key is now required to cache the filter`,\n );\n }\n};\n\nconst validator = {\n validateAccountsActionsPublishCommentArguments,\n validateAccountsActionsPublishCommentEditArguments,\n validateAccountsActionsPublishCommentModerationArguments,\n validateAccountsActionsPublishCommunityEditArguments,\n validateAccountsActionsPublishVoteArguments,\n validateAccountsActionsExportAccountArguments,\n validateAccountsActionsSetAccountsOrderArguments,\n validateAccountsActionsSetAccountArguments,\n validateAccountsActionsSetActiveAccountArguments,\n validateAccountsDatabaseAddAccountArguments,\n validateAccountsDatabaseGetAccountsArguments,\n validateAccountsDatabaseAccountNames,\n validateUseCommentArguments,\n validateUseCommentsArguments,\n validateUseCommunityArguments,\n validateUseCommunityStatsArguments,\n validateUseCommunitiesArguments,\n validateUseCommunitiesStatesArguments,\n validateFeedSortType,\n validateUseFeedArguments,\n validateUseBufferedFeedsArguments,\n validateRepliesSortType,\n validateUseRepliesArguments,\n};\n\nexport default validator;\n"]}
@@ -0,0 +1,51 @@
1
+ import { AccountCommunity, ChainProviders } from "../../types.js";
2
+ export declare const DEFAULT_ETH_RPC_URL = "https://ethereum-rpc.publicnode.com";
3
+ export declare const overwritePkcOptions: {
4
+ resolveAuthorNames: boolean;
5
+ resolveAuthorAddresses: boolean;
6
+ validatePages: boolean;
7
+ };
8
+ export declare const getDefaultChainProviders: () => ChainProviders;
9
+ export declare const getDefaultPkcOptions: () => {
10
+ resolveAuthorNames: any;
11
+ resolveAuthorAddresses: any;
12
+ };
13
+ declare const accountGenerator: {
14
+ generateDefaultAccount: () => Promise<{
15
+ id: string;
16
+ version: number;
17
+ name: string;
18
+ author: {
19
+ address: any;
20
+ wallets: {
21
+ eth: {
22
+ address: string;
23
+ timestamp: number;
24
+ signature: {
25
+ signature: string;
26
+ type: string;
27
+ };
28
+ } | undefined;
29
+ };
30
+ };
31
+ signer: any;
32
+ chainProviders: ChainProviders;
33
+ pkcOptions: {
34
+ resolveAuthorNames: any;
35
+ resolveAuthorAddresses: any;
36
+ };
37
+ subscriptions: never[];
38
+ blockedAddresses: {};
39
+ blockedCids: {};
40
+ communities: {
41
+ [communityAddress: string]: AccountCommunity;
42
+ };
43
+ mediaIpfsGatewayUrl: string;
44
+ }>;
45
+ getDefaultPkcOptions: () => {
46
+ resolveAuthorNames: any;
47
+ resolveAuthorAddresses: any;
48
+ };
49
+ };
50
+ export default accountGenerator;
51
+ //# sourceMappingURL=account-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-generator.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAY,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASzE,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AAgBzE,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAqBF,eAAO,MAAM,wBAAwB,QAQd,cACtB,CAAC;AAGF,eAAO,MAAM,oBAAoB;;;CAoChC,CAAC;AAuFF,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,160 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import PkcJs from "../../lib/pkc-js/index.js";
11
+ import validator from "../../lib/validator.js";
12
+ import chain from "../../lib/chain/index.js";
13
+ import { v4 as uuid } from "uuid";
14
+ import accountsDatabase from "./accounts-database.js";
15
+ import { getPkcClientOptions, normalizeAccountProtocolConfig, withProtocolAliases, } from "../../lib/pkc-compat.js";
16
+ import Logger from "@pkcprotocol/pkc-logger";
17
+ const log = Logger("bitsocial-react-hooks:accounts:stores");
18
+ export const DEFAULT_ETH_RPC_URL = "https://ethereum-rpc.publicnode.com";
19
+ // default chain providers
20
+ const chainProviders = {
21
+ eth: {
22
+ // default should not use a url, but rather ethers' default provider
23
+ urls: [DEFAULT_ETH_RPC_URL, "viem", "ethers.js"],
24
+ chainId: 1,
25
+ },
26
+ matic: {
27
+ urls: ["https://polygon-rpc.com"],
28
+ chainId: 137,
29
+ },
30
+ };
31
+ // force using these options or can cause bugs
32
+ export const overwritePkcOptions = {
33
+ resolveAuthorNames: false,
34
+ resolveAuthorAddresses: false,
35
+ validatePages: false,
36
+ };
37
+ const aliasProtocolOptions = (options) => {
38
+ var _a, _b, _c, _d;
39
+ return (Object.assign(Object.assign({}, options), { resolveAuthorNames: (_b = (_a = options.resolveAuthorNames) !== null && _a !== void 0 ? _a : options.resolveAuthorAddresses) !== null && _b !== void 0 ? _b : false, resolveAuthorAddresses: (_d = (_c = options.resolveAuthorAddresses) !== null && _c !== void 0 ? _c : options.resolveAuthorNames) !== null && _d !== void 0 ? _d : false }));
40
+ };
41
+ const addMissingChainProviders = (options) => {
42
+ const optionsWithChainProviders = Object.assign({}, options);
43
+ if (!optionsWithChainProviders.chainProviders) {
44
+ optionsWithChainProviders.chainProviders = {};
45
+ }
46
+ for (const chainTicker in chainProviders) {
47
+ if (!optionsWithChainProviders.chainProviders[chainTicker]) {
48
+ optionsWithChainProviders.chainProviders[chainTicker] = chainProviders[chainTicker];
49
+ }
50
+ }
51
+ return optionsWithChainProviders;
52
+ };
53
+ export const getDefaultChainProviders = () => {
54
+ // @ts-ignore
55
+ const defaultWindowOptions = window.defaultPkcOptions;
56
+ const windowChainProviders = (defaultWindowOptions === null || defaultWindowOptions === void 0 ? void 0 : defaultWindowOptions.chainProviders)
57
+ ? JSON.parse(JSON.stringify(defaultWindowOptions.chainProviders))
58
+ : undefined;
59
+ return addMissingChainProviders({
60
+ chainProviders: windowChainProviders,
61
+ }).chainProviders;
62
+ };
63
+ // default options aren't saved to database so they can be changed
64
+ export const getDefaultPkcOptions = () => {
65
+ // default PKC options defined by the electron process
66
+ // @ts-ignore
67
+ const defaultWindowOptions = window.defaultPkcOptions;
68
+ if (defaultWindowOptions) {
69
+ // @ts-ignore
70
+ const defaultPkcOptions = JSON.parse(JSON.stringify(Object.assign(Object.assign({}, defaultWindowOptions), { libp2pJsClientsOptions: undefined })));
71
+ delete defaultPkcOptions.chainProviders;
72
+ delete defaultPkcOptions.nameResolversChainProviders;
73
+ // @ts-ignore
74
+ defaultPkcOptions.libp2pJsClientsOptions = defaultWindowOptions.libp2pJsClientsOptions; // libp2pJsClientsOptions is not always just json
75
+ return aliasProtocolOptions(Object.assign(Object.assign({}, defaultPkcOptions), overwritePkcOptions));
76
+ }
77
+ // default PKC options for web client
78
+ return aliasProtocolOptions(Object.assign({ ipfsGatewayUrls: [
79
+ "https://ipfsgateway.xyz",
80
+ "https://gateway.plebpubsub.xyz",
81
+ "https://gateway.forumindex.com",
82
+ ], kuboRpcClientsOptions: undefined, pubsubKuboRpcClientsOptions: [
83
+ "https://pubsubprovider.xyz/api/v0",
84
+ "https://plebpubsub.xyz/api/v0",
85
+ "https://rannithepleb.com/api/v0",
86
+ ], httpRoutersOptions: [
87
+ "https://routing.lol",
88
+ "https://peers.pleb.bot",
89
+ "https://peers.plebpubsub.xyz",
90
+ "https://peers.forumindex.com",
91
+ ] }, overwritePkcOptions));
92
+ };
93
+ // the gateway to use in <img src> for nft avatars
94
+ // @ts-ignore
95
+ const defaultMediaIpfsGatewayUrl = window.defaultMediaIpfsGatewayUrl || "https://ipfs.io";
96
+ const generateDefaultAccount = () => __awaiter(void 0, void 0, void 0, function* () {
97
+ const pkcOptions = getDefaultPkcOptions();
98
+ const chainProviders = getDefaultChainProviders();
99
+ const pkc = yield PkcJs.PKC(getPkcClientOptions({
100
+ chainProviders,
101
+ pkcOptions,
102
+ }, pkcOptions));
103
+ // handle errors or error events are uncaught
104
+ // no need to log them because pkc-js already logs them
105
+ pkc.on("error", (error) => log.error("uncaught pkc instance error, should never happen", { error }));
106
+ const signer = yield pkc.createSigner();
107
+ const author = {
108
+ address: signer.address,
109
+ wallets: {
110
+ eth: yield chain.getEthWalletFromPkcPrivateKey(signer.privateKey, signer.address),
111
+ },
112
+ };
113
+ const accountName = yield getNextAvailableDefaultAccountName();
114
+ // communities where the account has a role, like moderator, admin, owner, etc.
115
+ const communities = {};
116
+ const account = normalizeAccountProtocolConfig(withProtocolAliases({
117
+ id: uuid(),
118
+ version: accountsDatabase.accountVersion,
119
+ name: accountName,
120
+ author,
121
+ signer,
122
+ chainProviders,
123
+ pkcOptions,
124
+ subscriptions: [],
125
+ blockedAddresses: {},
126
+ blockedCids: {},
127
+ communities,
128
+ mediaIpfsGatewayUrl: defaultMediaIpfsGatewayUrl,
129
+ }, pkc, pkcOptions), chainProviders);
130
+ return account;
131
+ });
132
+ const getNextAvailableDefaultAccountName = () => __awaiter(void 0, void 0, void 0, function* () {
133
+ const accountIds = yield accountsDatabase.accountsMetadataDatabase.getItem("accountIds");
134
+ const accountNames = [];
135
+ if (accountIds === null || accountIds === void 0 ? void 0 : accountIds.length) {
136
+ const accounts = yield accountsDatabase.getAccounts(accountIds);
137
+ for (const accountId of accountIds) {
138
+ accountNames.push(accounts[accountId].name);
139
+ }
140
+ }
141
+ let accountNumber = 1;
142
+ if (!(accountNames === null || accountNames === void 0 ? void 0 : accountNames.length)) {
143
+ return `Account ${accountNumber}`;
144
+ }
145
+ validator.validateAccountsDatabaseAccountNames(accountNames);
146
+ const accountNamesSet = new Set(accountNames);
147
+ while (true) {
148
+ const accountName = `Account ${accountNumber}`;
149
+ if (!accountNamesSet.has(accountName)) {
150
+ return accountName;
151
+ }
152
+ accountNumber++;
153
+ }
154
+ });
155
+ const accountGenerator = {
156
+ generateDefaultAccount,
157
+ getDefaultPkcOptions,
158
+ };
159
+ export default accountGenerator;
160
+ //# sourceMappingURL=account-generator.js.map