@dxos/echo-db 2.33.5-dev.ea3876ba → 2.33.5-dev.fee8f5fe

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 (411) hide show
  1. package/dist/src/api/index.d.ts +0 -5
  2. package/dist/src/api/index.d.ts.map +1 -1
  3. package/dist/src/api/index.js +5 -6
  4. package/dist/src/api/index.js.map +1 -1
  5. package/dist/src/api/schema.test.js +1 -1
  6. package/dist/src/api/schema.test.js.map +1 -1
  7. package/dist/src/echo.d.ts +1 -0
  8. package/dist/src/echo.d.ts.map +1 -1
  9. package/dist/src/echo.js +10 -21
  10. package/dist/src/echo.js.map +1 -1
  11. package/dist/src/echo.test.js +12 -4
  12. package/dist/src/echo.test.js.map +1 -1
  13. package/dist/src/halo/contact-manager.d.ts +2 -1
  14. package/dist/src/halo/contact-manager.d.ts.map +1 -1
  15. package/dist/src/halo/contact-manager.js +1 -1
  16. package/dist/src/halo/contact-manager.js.map +1 -1
  17. package/dist/src/halo/halo-factory.d.ts +4 -4
  18. package/dist/src/halo/halo-factory.d.ts.map +1 -1
  19. package/dist/src/halo/halo-factory.js +8 -13
  20. package/dist/src/halo/halo-factory.js.map +1 -1
  21. package/dist/src/halo/halo-party.d.ts +5 -4
  22. package/dist/src/halo/halo-party.d.ts.map +1 -1
  23. package/dist/src/halo/halo-party.js +16 -10
  24. package/dist/src/halo/halo-party.js.map +1 -1
  25. package/dist/src/halo/halo.d.ts +2 -2
  26. package/dist/src/halo/halo.d.ts.map +1 -1
  27. package/dist/src/halo/halo.test.js +4 -3
  28. package/dist/src/halo/halo.test.js.map +1 -1
  29. package/dist/src/halo/identity.js +2 -2
  30. package/dist/src/halo/identity.js.map +1 -1
  31. package/dist/src/halo/index.js +5 -1
  32. package/dist/src/halo/index.js.map +1 -1
  33. package/dist/src/halo/party-opener.d.ts +1 -1
  34. package/dist/src/halo/party-opener.d.ts.map +1 -1
  35. package/dist/src/halo/party-opener.js +5 -3
  36. package/dist/src/halo/party-opener.js.map +1 -1
  37. package/dist/src/halo/preferences.d.ts +1 -1
  38. package/dist/src/halo/preferences.d.ts.map +1 -1
  39. package/dist/src/halo/preferences.js +8 -11
  40. package/dist/src/halo/preferences.js.map +1 -1
  41. package/dist/src/index.d.ts +2 -2
  42. package/dist/src/index.d.ts.map +1 -1
  43. package/dist/src/index.js +7 -3
  44. package/dist/src/index.js.map +1 -1
  45. package/dist/src/invitations/greeting-initiator.d.ts +4 -5
  46. package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
  47. package/dist/src/invitations/greeting-initiator.js +4 -4
  48. package/dist/src/invitations/greeting-initiator.js.map +1 -1
  49. package/dist/src/invitations/greeting-protocol-provider.d.ts.map +1 -1
  50. package/dist/src/invitations/greeting-protocol-provider.js +5 -9
  51. package/dist/src/invitations/greeting-protocol-provider.js.map +1 -1
  52. package/dist/src/invitations/greeting-responder.d.ts +6 -4
  53. package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
  54. package/dist/src/invitations/greeting-responder.js +11 -14
  55. package/dist/src/invitations/greeting-responder.js.map +1 -1
  56. package/dist/src/invitations/halo-recovery-initiator.d.ts +1 -1
  57. package/dist/src/invitations/halo-recovery-initiator.d.ts.map +1 -1
  58. package/dist/src/invitations/halo-recovery-initiator.js +2 -2
  59. package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
  60. package/dist/src/invitations/index.js +5 -1
  61. package/dist/src/invitations/index.js.map +1 -1
  62. package/dist/src/invitations/invitation-descriptor.js +6 -2
  63. package/dist/src/invitations/invitation-descriptor.js.map +1 -1
  64. package/dist/src/invitations/invitation-factory.d.ts +5 -2
  65. package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
  66. package/dist/src/invitations/invitation-factory.js +4 -3
  67. package/dist/src/invitations/invitation-factory.js.map +1 -1
  68. package/dist/src/invitations/offline-invitation-claimer.d.ts.map +1 -1
  69. package/dist/src/invitations/offline-invitation-claimer.js +7 -9
  70. package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
  71. package/dist/src/{database → packlets/database}/data-mirror.d.ts +0 -0
  72. package/dist/src/packlets/database/data-mirror.d.ts.map +1 -0
  73. package/dist/src/{database → packlets/database}/data-mirror.js +0 -0
  74. package/dist/src/packlets/database/data-mirror.js.map +1 -0
  75. package/dist/src/{database → packlets/database}/data-mirror.test.d.ts +0 -0
  76. package/dist/src/packlets/database/data-mirror.test.d.ts.map +1 -0
  77. package/dist/src/{database → packlets/database}/data-mirror.test.js +2 -2
  78. package/dist/src/packlets/database/data-mirror.test.js.map +1 -0
  79. package/dist/src/{database → packlets/database}/data-service-host.d.ts +0 -0
  80. package/dist/src/packlets/database/data-service-host.d.ts.map +1 -0
  81. package/dist/src/{database → packlets/database}/data-service-host.js +4 -3
  82. package/dist/src/packlets/database/data-service-host.js.map +1 -0
  83. package/dist/src/{database → packlets/database}/data-service-router.d.ts +0 -0
  84. package/dist/src/packlets/database/data-service-router.d.ts.map +1 -0
  85. package/dist/src/{database → packlets/database}/data-service-router.js +0 -0
  86. package/dist/src/packlets/database/data-service-router.js.map +1 -0
  87. package/dist/src/{database → packlets/database}/database-backend.d.ts +4 -5
  88. package/dist/src/packlets/database/database-backend.d.ts.map +1 -0
  89. package/dist/src/{database → packlets/database}/database-backend.js +5 -6
  90. package/dist/src/packlets/database/database-backend.js.map +1 -0
  91. package/dist/src/{api → packlets/database}/database.d.ts +2 -1
  92. package/dist/src/packlets/database/database.d.ts.map +1 -0
  93. package/dist/src/{api → packlets/database}/database.js +2 -2
  94. package/dist/src/packlets/database/database.js.map +1 -0
  95. package/dist/src/{api → packlets/database}/database.test.d.ts +0 -0
  96. package/dist/src/packlets/database/database.test.d.ts.map +1 -0
  97. package/dist/src/{api → packlets/database}/database.test.js +3 -3
  98. package/dist/src/packlets/database/database.test.js.map +1 -0
  99. package/dist/src/{api → packlets/database}/entity.d.ts +1 -1
  100. package/dist/src/packlets/database/entity.d.ts.map +1 -0
  101. package/dist/src/{api → packlets/database}/entity.js +0 -0
  102. package/dist/src/packlets/database/entity.js.map +1 -0
  103. package/dist/src/{database → packlets/database}/index.d.ts +5 -0
  104. package/dist/src/packlets/database/index.d.ts.map +1 -0
  105. package/dist/src/{database → packlets/database}/index.js +10 -1
  106. package/dist/src/packlets/database/index.js.map +1 -0
  107. package/dist/src/{database → packlets/database}/item-demuxer.d.ts +5 -4
  108. package/dist/src/packlets/database/item-demuxer.d.ts.map +1 -0
  109. package/dist/src/{database → packlets/database}/item-demuxer.js +5 -8
  110. package/dist/src/packlets/database/item-demuxer.js.map +1 -0
  111. package/dist/src/{database → packlets/database}/item-demuxer.test.d.ts +0 -0
  112. package/dist/src/packlets/database/item-demuxer.test.d.ts.map +1 -0
  113. package/dist/src/{database → packlets/database}/item-demuxer.test.js +15 -11
  114. package/dist/src/packlets/database/item-demuxer.test.js.map +1 -0
  115. package/dist/src/{database → packlets/database}/item-manager.d.ts +3 -1
  116. package/dist/src/packlets/database/item-manager.d.ts.map +1 -0
  117. package/dist/src/{database → packlets/database}/item-manager.js +13 -12
  118. package/dist/src/packlets/database/item-manager.js.map +1 -0
  119. package/dist/src/{database → packlets/database}/item-manager.test.d.ts +0 -0
  120. package/dist/src/packlets/database/item-manager.test.d.ts.map +1 -0
  121. package/dist/src/{database → packlets/database}/item-manager.test.js +0 -0
  122. package/dist/src/packlets/database/item-manager.test.js.map +1 -0
  123. package/dist/src/{api → packlets/database}/item.d.ts +1 -1
  124. package/dist/src/packlets/database/item.d.ts.map +1 -0
  125. package/dist/src/{api → packlets/database}/item.js +0 -0
  126. package/dist/src/packlets/database/item.js.map +1 -0
  127. package/dist/src/{api → packlets/database}/link.d.ts +1 -1
  128. package/dist/src/packlets/database/link.d.ts.map +1 -0
  129. package/dist/src/{api → packlets/database}/link.js +0 -0
  130. package/dist/src/packlets/database/link.js.map +1 -0
  131. package/dist/src/{api → packlets/database}/selection/index.d.ts +0 -0
  132. package/dist/src/packlets/database/selection/index.d.ts.map +1 -0
  133. package/dist/src/{api → packlets/database}/selection/index.js +5 -1
  134. package/dist/src/packlets/database/selection/index.js.map +1 -0
  135. package/dist/src/{api → packlets/database}/selection/queries.d.ts +0 -0
  136. package/dist/src/packlets/database/selection/queries.d.ts.map +1 -0
  137. package/dist/src/{api → packlets/database}/selection/queries.js +13 -17
  138. package/dist/src/packlets/database/selection/queries.js.map +1 -0
  139. package/dist/src/{api → packlets/database}/selection/result.d.ts +0 -0
  140. package/dist/src/packlets/database/selection/result.d.ts.map +1 -0
  141. package/dist/src/{api → packlets/database}/selection/result.js +0 -0
  142. package/dist/src/packlets/database/selection/result.js.map +1 -0
  143. package/dist/src/{api → packlets/database}/selection/selection.d.ts +0 -0
  144. package/dist/src/packlets/database/selection/selection.d.ts.map +1 -0
  145. package/dist/src/{api → packlets/database}/selection/selection.js +1 -3
  146. package/dist/src/packlets/database/selection/selection.js.map +1 -0
  147. package/dist/src/{api → packlets/database}/selection/selection.test.d.ts +0 -0
  148. package/dist/src/packlets/database/selection/selection.test.d.ts.map +1 -0
  149. package/dist/src/{api → packlets/database}/selection/selection.test.js +4 -12
  150. package/dist/src/packlets/database/selection/selection.test.js.map +1 -0
  151. package/dist/src/{api → packlets/database}/selection/util.d.ts +0 -0
  152. package/dist/src/packlets/database/selection/util.d.ts.map +1 -0
  153. package/dist/src/{api → packlets/database}/selection/util.js +0 -0
  154. package/dist/src/packlets/database/selection/util.js.map +1 -0
  155. package/dist/src/{database → packlets/database}/testing.d.ts +1 -1
  156. package/dist/src/packlets/database/testing.d.ts.map +1 -0
  157. package/dist/src/{database → packlets/database}/testing.js +5 -6
  158. package/dist/src/packlets/database/testing.js.map +1 -0
  159. package/dist/src/{database → packlets/database}/timeframe-clock.d.ts +1 -0
  160. package/dist/src/packlets/database/timeframe-clock.d.ts.map +1 -0
  161. package/dist/src/{database → packlets/database}/timeframe-clock.js +3 -0
  162. package/dist/src/packlets/database/timeframe-clock.js.map +1 -0
  163. package/dist/src/{errors.d.ts → packlets/errors/index.d.ts} +1 -1
  164. package/dist/src/packlets/errors/index.d.ts.map +1 -0
  165. package/dist/src/{errors.js → packlets/errors/index.js} +1 -1
  166. package/dist/src/packlets/errors/index.js.map +1 -0
  167. package/dist/src/parties/data-party.d.ts +14 -10
  168. package/dist/src/parties/data-party.d.ts.map +1 -1
  169. package/dist/src/parties/data-party.js +39 -15
  170. package/dist/src/parties/data-party.js.map +1 -1
  171. package/dist/src/parties/data-party.test.js +42 -22
  172. package/dist/src/parties/data-party.test.js.map +1 -1
  173. package/dist/src/parties/index.js +5 -1
  174. package/dist/src/parties/index.js.map +1 -1
  175. package/dist/src/parties/party-factory.d.ts +5 -10
  176. package/dist/src/parties/party-factory.d.ts.map +1 -1
  177. package/dist/src/parties/party-factory.js +30 -54
  178. package/dist/src/parties/party-factory.js.map +1 -1
  179. package/dist/src/parties/party-manager.d.ts +3 -4
  180. package/dist/src/parties/party-manager.d.ts.map +1 -1
  181. package/dist/src/parties/party-manager.js +9 -7
  182. package/dist/src/parties/party-manager.js.map +1 -1
  183. package/dist/src/parties/party-manager.test.js +16 -15
  184. package/dist/src/parties/party-manager.test.js.map +1 -1
  185. package/dist/src/pipeline/{pipeline.d.ts → feed-muxer.d.ts} +10 -15
  186. package/dist/src/pipeline/feed-muxer.d.ts.map +1 -0
  187. package/dist/src/pipeline/{pipeline.js → feed-muxer.js} +34 -44
  188. package/dist/src/pipeline/feed-muxer.js.map +1 -0
  189. package/dist/src/pipeline/feed-muxer.test.d.ts +2 -0
  190. package/dist/src/pipeline/feed-muxer.test.d.ts.map +1 -0
  191. package/dist/src/pipeline/{pipeline.test.js → feed-muxer.test.js} +20 -18
  192. package/dist/src/pipeline/feed-muxer.test.js.map +1 -0
  193. package/dist/src/pipeline/index.d.ts +2 -2
  194. package/dist/src/pipeline/index.d.ts.map +1 -1
  195. package/dist/src/pipeline/index.js +7 -3
  196. package/dist/src/pipeline/index.js.map +1 -1
  197. package/dist/src/pipeline/message-selector.d.ts +3 -3
  198. package/dist/src/pipeline/message-selector.d.ts.map +1 -1
  199. package/dist/src/pipeline/message-selector.js +30 -29
  200. package/dist/src/pipeline/message-selector.js.map +1 -1
  201. package/dist/src/pipeline/metadata-store.d.ts +5 -4
  202. package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
  203. package/dist/src/pipeline/metadata-store.js +11 -5
  204. package/dist/src/pipeline/metadata-store.js.map +1 -1
  205. package/dist/src/pipeline/metadata-store.test.js +8 -4
  206. package/dist/src/pipeline/metadata-store.test.js.map +1 -1
  207. package/dist/src/pipeline/party-feed-provider.d.ts +2 -3
  208. package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
  209. package/dist/src/pipeline/party-feed-provider.js +2 -17
  210. package/dist/src/pipeline/party-feed-provider.js.map +1 -1
  211. package/dist/src/pipeline/{party-core.d.ts → party-pipeline.d.ts} +26 -11
  212. package/dist/src/pipeline/party-pipeline.d.ts.map +1 -0
  213. package/dist/src/pipeline/{party-core.js → party-pipeline.js} +32 -31
  214. package/dist/src/pipeline/party-pipeline.js.map +1 -0
  215. package/dist/src/pipeline/party-pipeline.test.d.ts +2 -0
  216. package/dist/src/pipeline/party-pipeline.test.d.ts.map +1 -0
  217. package/dist/src/pipeline/{party-core.test.js → party-pipeline.test.js} +64 -46
  218. package/dist/src/pipeline/party-pipeline.test.js.map +1 -0
  219. package/dist/src/pipeline/party-processor.d.ts +21 -9
  220. package/dist/src/pipeline/party-processor.d.ts.map +1 -1
  221. package/dist/src/pipeline/party-processor.js +0 -8
  222. package/dist/src/pipeline/party-processor.js.map +1 -1
  223. package/dist/src/protocol/auth-plugin.d.ts +1 -1
  224. package/dist/src/protocol/auth-plugin.d.ts.map +1 -1
  225. package/dist/src/protocol/auth-plugin.js +1 -3
  226. package/dist/src/protocol/auth-plugin.js.map +1 -1
  227. package/dist/src/protocol/authenticator.d.ts +4 -4
  228. package/dist/src/protocol/authenticator.d.ts.map +1 -1
  229. package/dist/src/protocol/authenticator.js +12 -16
  230. package/dist/src/protocol/authenticator.js.map +1 -1
  231. package/dist/src/protocol/authenticator.test.js +1 -4
  232. package/dist/src/protocol/authenticator.test.js.map +1 -1
  233. package/dist/src/protocol/halo-recovery-plugin.d.ts +1 -1
  234. package/dist/src/protocol/halo-recovery-plugin.d.ts.map +1 -1
  235. package/dist/src/protocol/halo-recovery-plugin.js +1 -3
  236. package/dist/src/protocol/halo-recovery-plugin.js.map +1 -1
  237. package/dist/src/protocol/identity-credentials.d.ts +2 -2
  238. package/dist/src/protocol/identity-credentials.d.ts.map +1 -1
  239. package/dist/src/protocol/identity-credentials.js +4 -4
  240. package/dist/src/protocol/identity-credentials.js.map +1 -1
  241. package/dist/src/protocol/index.js +5 -1
  242. package/dist/src/protocol/index.js.map +1 -1
  243. package/dist/src/protocol/offline-invitation-plugin.d.ts +1 -1
  244. package/dist/src/protocol/offline-invitation-plugin.d.ts.map +1 -1
  245. package/dist/src/protocol/offline-invitation-plugin.js +1 -3
  246. package/dist/src/protocol/offline-invitation-plugin.js.map +1 -1
  247. package/dist/src/protocol/party-protocol-factory.d.ts +1 -14
  248. package/dist/src/protocol/party-protocol-factory.d.ts.map +1 -1
  249. package/dist/src/protocol/party-protocol-factory.js +2 -55
  250. package/dist/src/protocol/party-protocol-factory.js.map +1 -1
  251. package/dist/src/protocol/replicator-plugin.d.ts +7 -0
  252. package/dist/src/protocol/replicator-plugin.d.ts.map +1 -0
  253. package/dist/src/protocol/replicator-plugin.js +36 -0
  254. package/dist/src/protocol/replicator-plugin.js.map +1 -0
  255. package/dist/src/snapshots/index.js +5 -1
  256. package/dist/src/snapshots/index.js.map +1 -1
  257. package/dist/src/snapshots/snapshot-generator.d.ts +3 -3
  258. package/dist/src/snapshots/snapshot-generator.d.ts.map +1 -1
  259. package/dist/src/snapshots/snapshot-generator.js +13 -15
  260. package/dist/src/snapshots/snapshot-generator.js.map +1 -1
  261. package/dist/src/snapshots/snapshot-store.d.ts +3 -3
  262. package/dist/src/snapshots/snapshot-store.d.ts.map +1 -1
  263. package/dist/src/snapshots/snapshot-store.js +5 -5
  264. package/dist/src/snapshots/snapshot-store.js.map +1 -1
  265. package/dist/src/snapshots/snapshot-store.test.js +1 -1
  266. package/dist/src/snapshots/snapshot-store.test.js.map +1 -1
  267. package/dist/src/snapshots/snapshot.test.js +1 -1
  268. package/dist/src/snapshots/snapshot.test.js.map +1 -1
  269. package/dist/src/testing/benchmark.test.d.ts +2 -0
  270. package/dist/src/testing/benchmark.test.d.ts.map +1 -0
  271. package/dist/src/testing/benchmark.test.js +25 -0
  272. package/dist/src/testing/benchmark.test.js.map +1 -0
  273. package/dist/src/testing/index.js +5 -1
  274. package/dist/src/testing/index.js.map +1 -1
  275. package/dist/src/testing/testing-factories.d.ts +1 -1
  276. package/dist/src/testing/testing-factories.d.ts.map +1 -1
  277. package/dist/src/testing/testing-factories.js +2 -2
  278. package/dist/src/testing/testing-factories.js.map +1 -1
  279. package/dist/tsconfig.tsbuildinfo +1 -1
  280. package/package.json +19 -19
  281. package/src/api/index.ts +0 -5
  282. package/src/api/schema.test.ts +1 -2
  283. package/src/echo.test.ts +16 -5
  284. package/src/echo.ts +11 -20
  285. package/src/halo/contact-manager.ts +3 -2
  286. package/src/halo/halo-factory.ts +11 -23
  287. package/src/halo/halo-party.ts +22 -14
  288. package/src/halo/halo.test.ts +4 -3
  289. package/src/halo/halo.ts +2 -2
  290. package/src/halo/identity.ts +2 -2
  291. package/src/halo/party-opener.ts +5 -3
  292. package/src/halo/preferences.ts +10 -12
  293. package/src/index.ts +3 -2
  294. package/src/invitations/greeting-initiator.ts +10 -9
  295. package/src/invitations/greeting-protocol-provider.ts +5 -9
  296. package/src/invitations/greeting-responder.ts +15 -17
  297. package/src/invitations/halo-recovery-initiator.ts +4 -4
  298. package/src/invitations/invitation-descriptor.ts +1 -1
  299. package/src/invitations/invitation-factory.ts +8 -5
  300. package/src/invitations/offline-invitation-claimer.ts +8 -10
  301. package/src/{database → packlets/database}/data-mirror.test.ts +3 -3
  302. package/src/{database → packlets/database}/data-mirror.ts +1 -1
  303. package/src/{database → packlets/database}/data-service-host.ts +2 -1
  304. package/src/{database → packlets/database}/data-service-router.ts +0 -0
  305. package/src/{database → packlets/database}/database-backend.ts +7 -6
  306. package/src/{api → packlets/database}/database.test.ts +2 -1
  307. package/src/{api → packlets/database}/database.ts +3 -1
  308. package/src/{api → packlets/database}/entity.ts +1 -1
  309. package/src/{database → packlets/database}/index.ts +5 -0
  310. package/src/{database → packlets/database}/item-demuxer.test.ts +21 -19
  311. package/src/{database → packlets/database}/item-demuxer.ts +10 -9
  312. package/src/{database → packlets/database}/item-manager.test.ts +0 -0
  313. package/src/{database → packlets/database}/item-manager.ts +5 -3
  314. package/src/{api → packlets/database}/item.ts +2 -2
  315. package/src/{api → packlets/database}/link.ts +1 -1
  316. package/src/{api → packlets/database}/selection/index.ts +0 -0
  317. package/src/{api → packlets/database}/selection/queries.ts +14 -18
  318. package/src/{api → packlets/database}/selection/result.ts +0 -0
  319. package/src/{api → packlets/database}/selection/selection.test.ts +4 -12
  320. package/src/{api → packlets/database}/selection/selection.ts +1 -7
  321. package/src/{api → packlets/database}/selection/util.ts +0 -0
  322. package/src/{database → packlets/database}/testing.ts +4 -7
  323. package/src/{database → packlets/database}/timeframe-clock.ts +4 -0
  324. package/src/{errors.ts → packlets/errors/index.ts} +0 -0
  325. package/src/parties/data-party.test.ts +58 -25
  326. package/src/parties/data-party.ts +48 -20
  327. package/src/parties/party-factory.ts +40 -84
  328. package/src/parties/party-manager.test.ts +24 -15
  329. package/src/parties/party-manager.ts +10 -6
  330. package/src/pipeline/{pipeline.test.ts → feed-muxer.test.ts} +23 -19
  331. package/src/pipeline/{pipeline.ts → feed-muxer.ts} +39 -55
  332. package/src/pipeline/index.ts +2 -2
  333. package/src/pipeline/message-selector.ts +32 -35
  334. package/src/pipeline/metadata-store.test.ts +8 -4
  335. package/src/pipeline/metadata-store.ts +12 -6
  336. package/src/pipeline/party-feed-provider.ts +3 -16
  337. package/src/pipeline/{party-core.test.ts → party-pipeline.test.ts} +67 -48
  338. package/src/pipeline/{party-core.ts → party-pipeline.ts} +59 -31
  339. package/src/pipeline/party-processor.ts +23 -15
  340. package/src/protocol/auth-plugin.ts +1 -3
  341. package/src/protocol/authenticator.test.ts +1 -4
  342. package/src/protocol/authenticator.ts +33 -33
  343. package/src/protocol/halo-recovery-plugin.ts +4 -6
  344. package/src/protocol/identity-credentials.ts +4 -4
  345. package/src/protocol/offline-invitation-plugin.ts +4 -6
  346. package/src/protocol/party-protocol-factory.ts +3 -56
  347. package/src/protocol/replicator-plugin.ts +37 -0
  348. package/src/snapshots/snapshot-generator.ts +14 -18
  349. package/src/snapshots/snapshot-store.test.ts +1 -1
  350. package/src/snapshots/snapshot-store.ts +5 -6
  351. package/src/snapshots/snapshot.test.ts +1 -1
  352. package/src/testing/benchmark.test.ts +30 -0
  353. package/src/testing/testing-factories.ts +3 -3
  354. package/dist/src/api/database.d.ts.map +0 -1
  355. package/dist/src/api/database.js.map +0 -1
  356. package/dist/src/api/database.test.d.ts.map +0 -1
  357. package/dist/src/api/database.test.js.map +0 -1
  358. package/dist/src/api/entity.d.ts.map +0 -1
  359. package/dist/src/api/entity.js.map +0 -1
  360. package/dist/src/api/item.d.ts.map +0 -1
  361. package/dist/src/api/item.js.map +0 -1
  362. package/dist/src/api/link.d.ts.map +0 -1
  363. package/dist/src/api/link.js.map +0 -1
  364. package/dist/src/api/selection/index.d.ts.map +0 -1
  365. package/dist/src/api/selection/index.js.map +0 -1
  366. package/dist/src/api/selection/queries.d.ts.map +0 -1
  367. package/dist/src/api/selection/queries.js.map +0 -1
  368. package/dist/src/api/selection/result.d.ts.map +0 -1
  369. package/dist/src/api/selection/result.js.map +0 -1
  370. package/dist/src/api/selection/selection.d.ts.map +0 -1
  371. package/dist/src/api/selection/selection.js.map +0 -1
  372. package/dist/src/api/selection/selection.test.d.ts.map +0 -1
  373. package/dist/src/api/selection/selection.test.js.map +0 -1
  374. package/dist/src/api/selection/util.d.ts.map +0 -1
  375. package/dist/src/api/selection/util.js.map +0 -1
  376. package/dist/src/database/data-mirror.d.ts.map +0 -1
  377. package/dist/src/database/data-mirror.js.map +0 -1
  378. package/dist/src/database/data-mirror.test.d.ts.map +0 -1
  379. package/dist/src/database/data-mirror.test.js.map +0 -1
  380. package/dist/src/database/data-service-host.d.ts.map +0 -1
  381. package/dist/src/database/data-service-host.js.map +0 -1
  382. package/dist/src/database/data-service-router.d.ts.map +0 -1
  383. package/dist/src/database/data-service-router.js.map +0 -1
  384. package/dist/src/database/database-backend.d.ts.map +0 -1
  385. package/dist/src/database/database-backend.js.map +0 -1
  386. package/dist/src/database/index.d.ts.map +0 -1
  387. package/dist/src/database/index.js.map +0 -1
  388. package/dist/src/database/item-demuxer.d.ts.map +0 -1
  389. package/dist/src/database/item-demuxer.js.map +0 -1
  390. package/dist/src/database/item-demuxer.test.d.ts.map +0 -1
  391. package/dist/src/database/item-demuxer.test.js.map +0 -1
  392. package/dist/src/database/item-manager.d.ts.map +0 -1
  393. package/dist/src/database/item-manager.js.map +0 -1
  394. package/dist/src/database/item-manager.test.d.ts.map +0 -1
  395. package/dist/src/database/item-manager.test.js.map +0 -1
  396. package/dist/src/database/testing.d.ts.map +0 -1
  397. package/dist/src/database/testing.js.map +0 -1
  398. package/dist/src/database/timeframe-clock.d.ts.map +0 -1
  399. package/dist/src/database/timeframe-clock.js.map +0 -1
  400. package/dist/src/errors.d.ts.map +0 -1
  401. package/dist/src/errors.js.map +0 -1
  402. package/dist/src/pipeline/party-core.d.ts.map +0 -1
  403. package/dist/src/pipeline/party-core.js.map +0 -1
  404. package/dist/src/pipeline/party-core.test.d.ts +0 -2
  405. package/dist/src/pipeline/party-core.test.d.ts.map +0 -1
  406. package/dist/src/pipeline/party-core.test.js.map +0 -1
  407. package/dist/src/pipeline/pipeline.d.ts.map +0 -1
  408. package/dist/src/pipeline/pipeline.js.map +0 -1
  409. package/dist/src/pipeline/pipeline.test.d.ts +0 -2
  410. package/dist/src/pipeline/pipeline.test.d.ts.map +0 -1
  411. package/dist/src/pipeline/pipeline.test.js.map +0 -1
@@ -5,7 +5,7 @@
5
5
  import expect from 'expect';
6
6
  import { it as test } from 'mocha';
7
7
 
8
- import { createKeyAdmitMessage, createPartyGenesisMessage, defaultSecretProvider, KeyHint, Keyring, KeyType, codec as haloCodec } from '@dxos/credentials';
8
+ import { createKeyAdmitMessage, createPartyGenesisMessage, defaultSecretProvider, Keyring, KeyType, codec as haloCodec } from '@dxos/credentials';
9
9
  import { PublicKey } from '@dxos/crypto';
10
10
  import { codec } from '@dxos/echo-protocol';
11
11
  import { FeedStore } from '@dxos/feed-store';
@@ -22,24 +22,29 @@ import { SnapshotStore } from '../snapshots';
22
22
  import { DataParty } from './data-party';
23
23
 
24
24
  describe('DataParty', () => {
25
- const createParty = async (identity: IdentityCredentials, partyKey: PublicKey, hints: KeyHint[]) => {
26
- const metadataStore = new MetadataStore(createStorage('metadata', StorageType.RAM));
27
- const feedStore = new FeedStore(createStorage('feed', StorageType.RAM), { valueEncoding: codec });
28
- const snapshotStore = new SnapshotStore(createStorage('snapshots', StorageType.RAM));
25
+ const createParty = async (identity: IdentityCredentials, partyKey: PublicKey, feedHints: PublicKey[]) => {
26
+
27
+ const storage = createStorage('', StorageType.RAM);
28
+ const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
29
+ const metadataStore = new MetadataStore(storage.directory('metadata'));
30
+ const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
29
31
  const modelFactory = new ModelFactory().registerModel(ObjectModel);
30
32
  const networkManager = new NetworkManager();
31
33
  const partyFeedProvider = new PartyFeedProvider(metadataStore, identity.keyring, feedStore, partyKey);
34
+ const writableFeed = await partyFeedProvider.createOrOpenWritableFeed();
32
35
 
33
- return new DataParty(
36
+ const party = new DataParty(
34
37
  partyKey,
35
38
  modelFactory,
36
39
  snapshotStore,
37
40
  partyFeedProvider,
41
+ metadataStore,
38
42
  identity.createCredentialsSigner(),
39
43
  identity.preferences,
40
- networkManager,
41
- hints
44
+ networkManager
42
45
  );
46
+ party._setFeedHints([...feedHints, writableFeed.key]);
47
+ return party;
43
48
  };
44
49
 
45
50
  test('open & close', async () => {
@@ -59,8 +64,8 @@ describe('DataParty', () => {
59
64
  const party = await createParty(identity, partyKey.publicKey, []);
60
65
  await party.open();
61
66
 
62
- const feed = await party.feedProvider.createOrOpenWritableFeed();
63
- await party.processor.writeHaloMessage(createPartyGenesisMessage(
67
+ const feed = await party.getWriteFeed();
68
+ await party.credentialsWriter.write(createPartyGenesisMessage(
64
69
  keyring,
65
70
  partyKey,
66
71
  feed.key,
@@ -72,6 +77,33 @@ describe('DataParty', () => {
72
77
  await party.close();
73
78
  });
74
79
 
80
+ test('data is immediately available after re-opening', async () => {
81
+ const keyring = new Keyring();
82
+ const identity = await createTestIdentityCredentials(keyring);
83
+ const partyKey = await keyring.createKeyRecord({ type: KeyType.PARTY });
84
+ const party = await createParty(identity, partyKey.publicKey, []);
85
+ await party.open();
86
+
87
+ const feed = await party.getWriteFeed();
88
+ await party.credentialsWriter.write(createPartyGenesisMessage(
89
+ keyring,
90
+ partyKey,
91
+ feed.key,
92
+ partyKey
93
+ ));
94
+
95
+ for (let i = 0; i < 10; i++) {
96
+ await party.database.createItem({ type: 'test:item' });
97
+ }
98
+
99
+ await party.close();
100
+ await party.open();
101
+
102
+ expect(party.database.select({ type: 'test:item' }).exec().entities).toHaveLength(10);
103
+
104
+ await party.close();
105
+ });
106
+
75
107
  test('authenticates its own credentials', async () => {
76
108
  const keyring = new Keyring();
77
109
  const identity = await createTestIdentityCredentials(keyring);
@@ -79,15 +111,16 @@ describe('DataParty', () => {
79
111
 
80
112
  const party = await createParty(identity, partyKey.publicKey, []);
81
113
  await party.open();
82
- const feed = await party.feedProvider.createOrOpenWritableFeed();
83
- await party.processor.writeHaloMessage(createPartyGenesisMessage(
114
+ const feed = await party.getWriteFeed();
115
+ await party.credentialsWriter.write(createPartyGenesisMessage(
84
116
  keyring,
85
117
  partyKey,
86
118
  feed.key,
87
119
  partyKey
88
120
  ));
121
+ await party.processor.feedAdded.waitForCount(1);
89
122
 
90
- const authenticator = createAuthenticator(party.processor, identity.createCredentialsSigner());
123
+ const authenticator = createAuthenticator(party.processor, identity.createCredentialsSigner(), party.credentialsWriter);
91
124
  const credentialsProvider = createCredentialsProvider(identity.createCredentialsSigner(), party.key, feed.key);
92
125
 
93
126
  const wrappedCredentials = haloCodec.decode(credentialsProvider.get());
@@ -103,14 +136,16 @@ describe('DataParty', () => {
103
136
 
104
137
  const party = await createParty(identityA, partyKey.publicKey, []);
105
138
  await party.open();
106
- const feed = await party.feedProvider.createOrOpenWritableFeed();
107
- await party.processor.writeHaloMessage(createPartyGenesisMessage(
139
+ const feed = await party.getWriteFeed();
140
+ await party.credentialsWriter.write(createPartyGenesisMessage(
108
141
  keyring,
109
142
  partyKey,
110
143
  feed.key,
111
144
  partyKey
112
145
  ));
113
- const authenticator = createAuthenticator(party.processor, identityA.createCredentialsSigner());
146
+ await party.processor.feedAdded.waitForCount(1);
147
+
148
+ const authenticator = createAuthenticator(party.processor, identityA.createCredentialsSigner(), party.credentialsWriter);
114
149
 
115
150
  const identityB = await deriveTestDeviceCredentials(identityA);
116
151
  const credentialsProvider = createCredentialsProvider(identityB.createCredentialsSigner(), party.key, feed.key);
@@ -128,14 +163,14 @@ describe('DataParty', () => {
128
163
 
129
164
  const partyA = await createParty(identityA, partyKey.publicKey, []);
130
165
  await partyA.open();
131
- const feedA = await partyA.feedProvider.createOrOpenWritableFeed();
132
- await partyA.processor.writeHaloMessage(createPartyGenesisMessage(
166
+ const feedA = await partyA.getWriteFeed();
167
+ await partyA.credentialsWriter.write(createPartyGenesisMessage(
133
168
  keyring,
134
169
  partyKey,
135
170
  feedA.key,
136
171
  partyKey
137
172
  ));
138
- await partyA.processor.writeHaloMessage(createKeyAdmitMessage(
173
+ await partyA.credentialsWriter.write(createKeyAdmitMessage(
139
174
  keyring,
140
175
  partyKey.publicKey,
141
176
  identityA.identityKey,
@@ -143,9 +178,7 @@ describe('DataParty', () => {
143
178
  ));
144
179
 
145
180
  const identityB = await deriveTestDeviceCredentials(identityA);
146
- const partyB = await createParty(identityB, partyKey.publicKey, [
147
- { type: KeyType.FEED, publicKey: feedA.key }
148
- ]);
181
+ const partyB = await createParty(identityB, partyKey.publicKey, [feedA.key]);
149
182
  await partyB.open();
150
183
 
151
184
  await partyA.database.createItem({ type: 'test:item-a' });
@@ -164,14 +197,14 @@ describe('DataParty', () => {
164
197
 
165
198
  const partyA = await createParty(identityA, partyKeyA.publicKey, []);
166
199
  await partyA.open();
167
- const feedA = await partyA.feedProvider.createOrOpenWritableFeed();
168
- await partyA.processor.writeHaloMessage(createPartyGenesisMessage(
200
+ const feedA = await partyA.getWriteFeed();
201
+ await partyA.credentialsWriter.write(createPartyGenesisMessage(
169
202
  identityA.keyring,
170
203
  partyKeyA,
171
204
  feedA.key,
172
205
  partyKeyA
173
206
  ));
174
- await partyA.processor.writeHaloMessage(createKeyAdmitMessage(
207
+ await partyA.credentialsWriter.write(createKeyAdmitMessage(
175
208
  identityA.keyring,
176
209
  partyKeyA.publicKey,
177
210
  identityA.identityKey,
@@ -5,20 +5,22 @@
5
5
  import assert from 'assert';
6
6
 
7
7
  import { synchronized, Event } from '@dxos/async';
8
- import { KeyHint } from '@dxos/credentials';
9
8
  import { PublicKey } from '@dxos/crypto';
10
9
  import { timed } from '@dxos/debug';
11
10
  import { PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
11
+ import { FeedDescriptor } from '@dxos/feed-store';
12
12
  import { ModelFactory } from '@dxos/model-factory';
13
13
  import { NetworkManager } from '@dxos/network-manager';
14
14
  import { ObjectModel } from '@dxos/object-model';
15
15
 
16
- import { Database, Item, ResultSet } from '../api';
16
+ import { ResultSet } from '../api';
17
17
  import { ActivationOptions, PartyPreferences, Preferences } from '../halo';
18
18
  import { InvitationFactory } from '../invitations';
19
- import { PartyFeedProvider, PartyProtocolFactory, PartyCore, PartyOptions } from '../pipeline';
19
+ import { Database, Item } from '../packlets/database';
20
+ import { PartyFeedProvider, PartyProtocolFactory, PartyPipeline, PipelineOptions, MetadataStore } from '../pipeline';
20
21
  import { createAuthPlugin, createOfflineInvitationPlugin, createAuthenticator, createCredentialsProvider } from '../protocol';
21
22
  import { CredentialsSigner } from '../protocol/credentials-signer';
23
+ import { createReplicatorPlugin } from '../protocol/replicator-plugin';
22
24
  import { SnapshotStore } from '../snapshots';
23
25
  import { CONTACT_DEBOUNCE_INTERVAL } from './party-manager';
24
26
 
@@ -40,31 +42,31 @@ export interface PartyMember {
40
42
  export class DataParty {
41
43
  public readonly update = new Event<void>();
42
44
 
43
- private readonly _partyCore: PartyCore;
45
+ private readonly _partyCore: PartyPipeline;
44
46
  private readonly _preferences?: PartyPreferences;
45
47
  private _invitationManager?: InvitationFactory;
46
48
  private _protocol?: PartyProtocolFactory;
49
+ private _feedHints: PublicKey[] = []
47
50
 
48
51
  constructor (
49
52
  partyKey: PartyKey,
50
53
  modelFactory: ModelFactory,
51
54
  snapshotStore: SnapshotStore,
52
55
  private readonly _feedProvider: PartyFeedProvider,
56
+ private readonly _metadataStore: MetadataStore,
53
57
  private readonly _credentialsSigner: CredentialsSigner,
54
58
  // TODO(dmaretskyi): Pull this out to a higher level. Should preferences be part of client API instead?
55
59
  private readonly _profilePreferences: Preferences | undefined,
56
60
  private readonly _networkManager: NetworkManager,
57
- private readonly _hints: KeyHint[] = [],
58
- _initialTimeframe?: Timeframe,
59
- _options: PartyOptions = {}
61
+ private readonly _initialTimeframe?: Timeframe,
62
+ _options: PipelineOptions = {}
60
63
  ) {
61
- this._partyCore = new PartyCore(
64
+ this._partyCore = new PartyPipeline(
62
65
  partyKey,
63
66
  _feedProvider,
64
67
  modelFactory,
65
68
  snapshotStore,
66
69
  this._credentialsSigner.getIdentityKey().publicKey,
67
- _initialTimeframe,
68
70
  _options
69
71
  );
70
72
 
@@ -125,14 +127,8 @@ export class DataParty {
125
127
  return this._invitationManager;
126
128
  }
127
129
 
128
- // TODO(burdon): Remove?
129
- get feedProvider (): PartyFeedProvider {
130
- return this._feedProvider;
131
- }
132
-
133
- get preferences (): PartyPreferences {
134
- assert(this._preferences, 'Preferences not available.');
135
- return this._preferences;
130
+ get credentialsWriter () {
131
+ return this._partyCore.credentialsWriter;
136
132
  }
137
133
 
138
134
  get title () {
@@ -145,6 +141,13 @@ export class DataParty {
145
141
  await this._preferences?.setLastKnownTitle(title);
146
142
  }
147
143
 
144
+ /**
145
+ * @internal
146
+ */
147
+ _setFeedHints (feedHints: PublicKey[]) {
148
+ this._feedHints = feedHints;
149
+ }
150
+
148
151
  /**
149
152
  * Opens the pipeline and connects the streams.
150
153
  */
@@ -155,11 +158,25 @@ export class DataParty {
155
158
  return this;
156
159
  }
157
160
 
158
- await this._partyCore.open(this._hints);
161
+ // TODO(dmaretskyi): May be undefined in some tests.
162
+ const party = this._metadataStore.getParty(this._partyCore.key);
163
+
164
+ await this._partyCore.open({
165
+ feedHints: this._feedHints,
166
+ initialTimeframe: this._initialTimeframe,
167
+ targetTimeframe: party?.latestTimeframe
168
+ });
169
+
170
+ // Keep updating latest reached timeframe in the metadata.
171
+ // This timeframe will be waited for when opening the party next time.
172
+ this._partyCore.timeframeUpdate.on(timeframe => {
173
+ void this._metadataStore.setTimeframe(this._partyCore.key, timeframe);
174
+ });
159
175
 
160
176
  this._invitationManager = new InvitationFactory(
161
177
  this._partyCore.processor,
162
178
  this._credentialsSigner,
179
+ this._partyCore.credentialsWriter,
163
180
  this._networkManager
164
181
  );
165
182
 
@@ -173,13 +190,13 @@ export class DataParty {
173
190
  this._protocol = new PartyProtocolFactory(
174
191
  this._partyCore.key,
175
192
  this._networkManager,
176
- this._feedProvider,
177
193
  deviceKey.publicKey,
178
194
  createCredentialsProvider(this._credentialsSigner, this._partyCore.key, writeFeed.key)
179
195
  );
180
196
 
181
197
  await this._protocol.start([
182
- createAuthPlugin(createAuthenticator(this._partyCore.processor, this._credentialsSigner), deviceKey.publicKey),
198
+ createReplicatorPlugin(this._feedProvider),
199
+ createAuthPlugin(createAuthenticator(this._partyCore.processor, this._credentialsSigner, this.credentialsWriter), deviceKey.publicKey),
183
200
  createOfflineInvitationPlugin(this._invitationManager, deviceKey.publicKey)
184
201
  ]);
185
202
 
@@ -199,6 +216,9 @@ export class DataParty {
199
216
  return this;
200
217
  }
201
218
 
219
+ // Save the latest reached timeframe.
220
+ await this._metadataStore.setTimeframe(this._partyCore.key, this._partyCore.timeframe);
221
+
202
222
  await this._partyCore.close();
203
223
  await this._protocol?.stop();
204
224
 
@@ -210,6 +230,14 @@ export class DataParty {
210
230
  return this;
211
231
  }
212
232
 
233
+ async getWriteFeed (): Promise<FeedDescriptor> {
234
+ return this._feedProvider.createOrOpenWritableFeed();
235
+ }
236
+
237
+ getFeeds (): FeedDescriptor[] {
238
+ return this._feedProvider.getFeeds();
239
+ }
240
+
213
241
  get isActive (): boolean {
214
242
  assert(this._preferences, 'PartyActivator required');
215
243
  return this._preferences.isActive;
@@ -9,7 +9,6 @@ import {
9
9
  createEnvelopeMessage,
10
10
  createFeedAdmitMessage,
11
11
  createPartyGenesisMessage,
12
- KeyHint,
13
12
  KeyType,
14
13
  SecretProvider,
15
14
  wrapMessage
@@ -21,12 +20,12 @@ import { ModelFactory } from '@dxos/model-factory';
21
20
  import { NetworkManager } from '@dxos/network-manager';
22
21
  import { ObjectModel } from '@dxos/object-model';
23
22
 
24
- import { IdentityNotInitializedError } from '../errors';
25
23
  import {
26
24
  createDataPartyAdmissionMessages,
27
25
  GreetingInitiator, InvitationDescriptor, InvitationDescriptorType, OfflineInvitationClaimer
28
26
  } from '../invitations';
29
- import { PartyFeedProvider, PartyOptions } from '../pipeline';
27
+ import { IdentityNotInitializedError } from '../packlets/errors';
28
+ import { MetadataStore, PartyFeedProvider, PipelineOptions } from '../pipeline';
30
29
  import { IdentityCredentialsProvider } from '../protocol/identity-credentials';
31
30
  import { SnapshotStore } from '../snapshots';
32
31
  import { DataParty, PARTY_ITEM_TYPE } from './data-party';
@@ -43,7 +42,8 @@ export class PartyFactory {
43
42
  private readonly _modelFactory: ModelFactory,
44
43
  private readonly _snapshotStore: SnapshotStore,
45
44
  private readonly _feedProviderFactory: (partyKey: PublicKey) => PartyFeedProvider,
46
- private readonly _options: PartyOptions = {}
45
+ private readonly _metadataStore: MetadataStore,
46
+ private readonly _options: PipelineOptions = {}
47
47
  ) {}
48
48
 
49
49
  /**
@@ -57,13 +57,15 @@ export class PartyFactory {
57
57
  const partyKey = await identity.keyring.createKeyRecord({ type: KeyType.PARTY });
58
58
  const party = await this.constructParty(partyKey.publicKey);
59
59
 
60
+ const writableFeed = await party.getWriteFeed();
61
+ // Hint at the newly created writable feed so that we can start replicating from it.
62
+ party._setFeedHints([writableFeed.key]);
63
+
60
64
  // Connect the pipeline.
61
65
  await party.open();
62
66
 
63
- const writableFeed = await party.feedProvider.createOrOpenWritableFeed();
64
-
65
67
  // PartyGenesis (self-signed by Party).
66
- await party.processor.writeHaloMessage(createPartyGenesisMessage(
68
+ await party.credentialsWriter.write(createPartyGenesisMessage(
67
69
  identity.keyring,
68
70
  partyKey,
69
71
  writableFeed.key,
@@ -71,7 +73,7 @@ export class PartyFactory {
71
73
  );
72
74
 
73
75
  // KeyAdmit (IdentityGenesis in an Envelope signed by Party).
74
- await party.processor.writeHaloMessage(createEnvelopeMessage(
76
+ await party.credentialsWriter.write(createEnvelopeMessage(
75
77
  identity.keyring,
76
78
  partyKey.publicKey,
77
79
  wrapMessage(identity.identityGenesis),
@@ -80,7 +82,7 @@ export class PartyFactory {
80
82
 
81
83
  // FeedAdmit (signed by the Device KeyChain).
82
84
  // TODO(dmaretskyi): Is this really needed since a feed is already admitted by party genesis message.
83
- await party.processor.writeHaloMessage(createFeedAdmitMessage(
85
+ await party.credentialsWriter.write(createFeedAdmitMessage(
84
86
  identity.keyring,
85
87
  partyKey.publicKey,
86
88
  writableFeed.key,
@@ -89,7 +91,7 @@ export class PartyFactory {
89
91
 
90
92
  // IdentityInfo in an Envelope signed by the Device KeyChain.
91
93
  if (identity.identityInfo) {
92
- await party.processor.writeHaloMessage(createEnvelopeMessage(
94
+ await party.credentialsWriter.write(createEnvelopeMessage(
93
95
  identity.keyring,
94
96
  partyKey.publicKey,
95
97
  wrapMessage(identity.identityInfo),
@@ -106,61 +108,14 @@ export class PartyFactory {
106
108
  return party;
107
109
  }
108
110
 
109
- /**
110
- * Constructs a party object and creates a local write feed for it.
111
- * @param partyKey
112
- * @param hints
113
- */
114
- async addParty (partyKey: PartyKey, hints: KeyHint[] = []) {
115
- const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
116
-
117
- /*
118
- * TODO(telackey): We shouldn't have to add our key here, it should be in the hints, but our hint
119
- * mechanism is broken by not waiting on the messages to be processed before returning.
120
- */
121
-
122
- const feedProvider = this._feedProviderFactory(partyKey);
123
- const { feed } = await feedProvider.createOrOpenWritableFeed();
124
- const feedKeyPair = identity.keyring.getKey(feed.key);
125
- assert(feedKeyPair, 'Keypair for writable feed not found.');
126
- const party = new DataParty(
127
- partyKey,
128
- this._modelFactory,
129
- this._snapshotStore,
130
- feedProvider,
131
- identity.createCredentialsSigner(),
132
- identity.preferences,
133
- this._networkManager,
134
- hints,
135
- undefined,
136
- this._options
137
- );
138
-
139
- await party.open();
140
- const isHalo = identity.identityKey.publicKey.equals(partyKey);
141
- const signingKey = isHalo ? identity.deviceKey : identity.deviceKeyChain;
142
- assert(signingKey, 'No device key or keychain.');
143
- // Write the Feed genesis message.
144
- await party.processor.writeHaloMessage(createFeedAdmitMessage(
145
- identity.keyring,
146
- partyKey,
147
- feedKeyPair.publicKey,
148
- [signingKey]
149
- ));
150
- return party;
151
- }
152
-
153
111
  /**
154
112
  * Constructs a party object from an existing set of feeds.
155
113
  * @param partyKey
156
114
  * @param hints
157
115
  */
158
- async constructParty (partyKey: PartyKey, hints: KeyHint[] = [], initialTimeframe?: Timeframe) {
116
+ async constructParty (partyKey: PartyKey, initialTimeframe?: Timeframe) {
159
117
  const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
160
118
 
161
- // TODO(marik-d): Support read-only parties if this feed doesn't exist?
162
- const feedProvider = this._feedProviderFactory(partyKey);
163
-
164
119
  //
165
120
  // Create the party.
166
121
  //
@@ -168,11 +123,11 @@ export class PartyFactory {
168
123
  partyKey,
169
124
  this._modelFactory,
170
125
  this._snapshotStore,
171
- feedProvider,
126
+ this._feedProviderFactory(partyKey),
127
+ this._metadataStore,
172
128
  identity.createCredentialsSigner(),
173
129
  identity.preferences,
174
130
  this._networkManager,
175
- hints,
176
131
  initialTimeframe,
177
132
  this._options
178
133
  );
@@ -184,13 +139,12 @@ export class PartyFactory {
184
139
  assert(snapshot.partyKey);
185
140
  log(`Constructing ${humanize(snapshot.partyKey)} from snapshot at ${JSON.stringify(snapshot.timeframe)}.`);
186
141
 
187
- const party = await this.constructParty(PublicKey.from(snapshot.partyKey), [], snapshot.timeframe);
142
+ const party = await this.constructParty(PublicKey.from(snapshot.partyKey), snapshot.timeframe);
188
143
  await party.restoreFromSnapshot(snapshot);
189
144
  return party;
190
145
  }
191
146
 
192
147
  async joinParty (invitationDescriptor: InvitationDescriptor, secretProvider: SecretProvider): Promise<DataParty> {
193
- const haloInvitation = !!invitationDescriptor.identityKey;
194
148
  const originalInvitation = invitationDescriptor;
195
149
 
196
150
  const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
@@ -218,19 +172,19 @@ export class PartyFactory {
218
172
 
219
173
  await initiator.connect();
220
174
  const { partyKey, hints } = await initiator.redeemInvitation(secretProvider);
221
- const party = await this.addParty(partyKey, hints);
175
+ const party = await this.constructParty(partyKey);
176
+ party._setFeedHints(hints);
177
+ await party.open();
222
178
  await initiator.destroy();
223
- if (!haloInvitation) {
224
- // Copy our signed IdentityInfo into the new Party.
225
- const infoMessage = identity.identityInfo;
226
- if (infoMessage) {
227
- await party.processor.writeHaloMessage(createEnvelopeMessage(
228
- identity.keyring,
229
- partyKey,
230
- wrapMessage(infoMessage),
231
- [identity.deviceKeyChain]
232
- ));
233
- }
179
+
180
+ // Copy our signed IdentityInfo into the new Party.
181
+ if (identity.identityInfo) {
182
+ await party.credentialsWriter.write(createEnvelopeMessage(
183
+ identity.keyring,
184
+ partyKey,
185
+ wrapMessage(identity.identityInfo),
186
+ [identity.deviceKeyChain]
187
+ ));
234
188
  }
235
189
 
236
190
  return party;
@@ -244,13 +198,15 @@ export class PartyFactory {
244
198
  const partyKey = await identity.keyring.createKeyRecord({ type: KeyType.PARTY });
245
199
  const party = await this.constructParty(partyKey.publicKey);
246
200
 
201
+ const writableFeed = await party.getWriteFeed();
202
+ // Hint at the newly created writable feed so that we can start replicating from it.
203
+ party._setFeedHints([writableFeed.key]);
204
+
247
205
  // Connect the pipeline.
248
206
  await party.open();
249
207
 
250
- const writableFeed = await party.feedProvider.createOrOpenWritableFeed();
251
-
252
208
  // PartyGenesis (self-signed by Party).
253
- await party.processor.writeHaloMessage(createPartyGenesisMessage(
209
+ await party.credentialsWriter.write(createPartyGenesisMessage(
254
210
  identity.keyring,
255
211
  partyKey,
256
212
  writableFeed.key,
@@ -258,7 +214,7 @@ export class PartyFactory {
258
214
  );
259
215
 
260
216
  // KeyAdmit (IdentityGenesis in an Envelope signed by Party).
261
- await party.processor.writeHaloMessage(createEnvelopeMessage(
217
+ await party.credentialsWriter.write(createEnvelopeMessage(
262
218
  identity.keyring,
263
219
  partyKey.publicKey,
264
220
  wrapMessage(identity.identityGenesis),
@@ -266,7 +222,7 @@ export class PartyFactory {
266
222
  ));
267
223
 
268
224
  // FeedAdmit (signed by the Device KeyChain).
269
- await party.processor.writeHaloMessage(createFeedAdmitMessage(
225
+ await party.credentialsWriter.write(createFeedAdmitMessage(
270
226
  identity.keyring,
271
227
  partyKey.publicKey,
272
228
  writableFeed.key,
@@ -275,7 +231,7 @@ export class PartyFactory {
275
231
 
276
232
  // IdentityInfo in an Envelope signed by the Device KeyChain.
277
233
  if (identity.identityInfo) {
278
- await party.processor.writeHaloMessage(createEnvelopeMessage(
234
+ await party.credentialsWriter.write(createEnvelopeMessage(
279
235
  identity.keyring,
280
236
  partyKey.publicKey,
281
237
  wrapMessage(identity.identityInfo),
@@ -285,7 +241,7 @@ export class PartyFactory {
285
241
 
286
242
  // const keyAdmitMessage = snapshot.halo?.messages?.[1];
287
243
  // assert(keyAdmitMessage);
288
- // await party.processor.writeHaloMessage(createEnvelopeMessage(
244
+ // await party.writeCredentialsMessage(createEnvelopeMessage(
289
245
  // identity.signer,
290
246
  // partyKey.publicKey,
291
247
  // keyAdmitMessage,
@@ -293,13 +249,14 @@ export class PartyFactory {
293
249
  // ));
294
250
 
295
251
  // for(const message of snapshot.halo?.messages?.slice(2) || []) {
296
- // await party.processor.writeHaloMessage(message);
252
+ // await party.writeCredentialsMessage(message);
297
253
  // }
298
254
 
299
255
  // Write messages to create ECHO items.
300
256
  const feedWriter = createFeedWriter(writableFeed.feed);
301
257
  for (const item of snapshot.database?.items || []) {
302
258
  const message: FeedMessage = {
259
+ timeframe: new Timeframe(),
303
260
  echo: {
304
261
  itemId: item.itemId ?? failUndefined(),
305
262
  genesis: {
@@ -310,8 +267,7 @@ export class PartyFactory {
310
267
  itemMutation: {
311
268
  parentId: item.parentId
312
269
  },
313
- snapshot: item.model,
314
- timeframe: new Timeframe()
270
+ snapshot: item.model
315
271
  }
316
272
  };
317
273
  await feedWriter.write(message);