@dxos/client-services 0.1.1 → 0.1.3

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 (282) hide show
  1. package/dist/src/index.d.ts +4 -1
  2. package/dist/src/index.d.ts.map +1 -1
  3. package/dist/src/index.js +4 -1
  4. package/dist/src/index.js.map +1 -1
  5. package/dist/src/packlets/deprecated/index.d.ts +5 -0
  6. package/dist/src/packlets/deprecated/index.d.ts.map +1 -0
  7. package/dist/src/packlets/{services/impl → deprecated}/index.js +1 -3
  8. package/dist/src/packlets/deprecated/index.js.map +1 -0
  9. package/dist/src/packlets/{invitations/common.d.ts → deprecated/invitations.d.ts} +14 -2
  10. package/dist/src/packlets/deprecated/invitations.d.ts.map +1 -0
  11. package/dist/src/packlets/{invitations/common.js → deprecated/invitations.js} +1 -1
  12. package/dist/src/packlets/deprecated/invitations.js.map +1 -0
  13. package/dist/src/packlets/{services/impl → deprecated}/profile.d.ts +5 -5
  14. package/dist/src/packlets/deprecated/profile.d.ts.map +1 -0
  15. package/dist/src/packlets/{services/impl → deprecated}/profile.js +10 -10
  16. package/dist/src/packlets/deprecated/profile.js.map +1 -0
  17. package/dist/src/packlets/deprecated/space.d.ts +23 -0
  18. package/dist/src/packlets/deprecated/space.d.ts.map +1 -0
  19. package/dist/src/packlets/deprecated/space.js +206 -0
  20. package/dist/src/packlets/deprecated/space.js.map +1 -0
  21. package/dist/src/packlets/{services/impl → deprecated}/system.d.ts +2 -2
  22. package/dist/src/packlets/deprecated/system.d.ts.map +1 -0
  23. package/dist/src/packlets/{services/impl → deprecated}/system.js +3 -3
  24. package/dist/src/packlets/deprecated/system.js.map +1 -0
  25. package/dist/src/packlets/deprecated/tracing.d.ts +12 -0
  26. package/dist/src/packlets/deprecated/tracing.d.ts.map +1 -0
  27. package/dist/src/packlets/{services/impl → deprecated}/tracing.js +3 -3
  28. package/dist/src/packlets/deprecated/tracing.js.map +1 -0
  29. package/dist/src/packlets/{services/impl → devtools}/devtools.d.ts +11 -7
  30. package/dist/src/packlets/devtools/devtools.d.ts.map +1 -0
  31. package/dist/src/packlets/devtools/devtools.js +86 -0
  32. package/dist/src/packlets/devtools/devtools.js.map +1 -0
  33. package/dist/src/packlets/devtools/feeds.d.ts.map +1 -1
  34. package/dist/src/packlets/devtools/feeds.js +28 -26
  35. package/dist/src/packlets/devtools/feeds.js.map +1 -1
  36. package/dist/src/packlets/devtools/index.d.ts +1 -1
  37. package/dist/src/packlets/devtools/index.d.ts.map +1 -1
  38. package/dist/src/packlets/devtools/index.js +1 -1
  39. package/dist/src/packlets/devtools/index.js.map +1 -1
  40. package/dist/src/packlets/devtools/spaces.d.ts +2 -2
  41. package/dist/src/packlets/devtools/spaces.d.ts.map +1 -1
  42. package/dist/src/packlets/devtools/spaces.js +13 -13
  43. package/dist/src/packlets/devtools/spaces.js.map +1 -1
  44. package/dist/src/packlets/identity/devices-service-impl.d.ts +10 -0
  45. package/dist/src/packlets/identity/devices-service-impl.d.ts.map +1 -0
  46. package/dist/src/packlets/identity/devices-service-impl.js +47 -0
  47. package/dist/src/packlets/identity/devices-service-impl.js.map +1 -0
  48. package/dist/src/packlets/identity/identity-manager.test.js +7 -11
  49. package/dist/src/packlets/identity/identity-manager.test.js.map +1 -1
  50. package/dist/src/packlets/identity/identity.d.ts +2 -0
  51. package/dist/src/packlets/identity/identity.d.ts.map +1 -1
  52. package/dist/src/packlets/identity/identity.js +4 -1
  53. package/dist/src/packlets/identity/identity.js.map +1 -1
  54. package/dist/src/packlets/identity/identity.test.js +2 -3
  55. package/dist/src/packlets/identity/identity.test.js.map +1 -1
  56. package/dist/src/packlets/invitations/encoder.d.ts +9 -0
  57. package/dist/src/packlets/invitations/encoder.d.ts.map +1 -0
  58. package/dist/src/packlets/invitations/encoder.js +27 -0
  59. package/dist/src/packlets/invitations/encoder.js.map +1 -0
  60. package/dist/src/packlets/invitations/encoder.test.d.ts +2 -0
  61. package/dist/src/packlets/invitations/encoder.test.d.ts.map +1 -0
  62. package/dist/src/packlets/invitations/encoder.test.js +19 -0
  63. package/dist/src/packlets/invitations/encoder.test.js.map +1 -0
  64. package/dist/src/packlets/invitations/halo-invitations.d.ts +3 -3
  65. package/dist/src/packlets/invitations/halo-invitations.d.ts.map +1 -1
  66. package/dist/src/packlets/invitations/halo-invitations.js +14 -10
  67. package/dist/src/packlets/invitations/halo-invitations.js.map +1 -1
  68. package/dist/src/packlets/invitations/halo-invitations.test.d.ts +2 -0
  69. package/dist/src/packlets/invitations/halo-invitations.test.d.ts.map +1 -0
  70. package/dist/src/packlets/{services/testing/halo.test.js → invitations/halo-invitations.test.js} +6 -6
  71. package/dist/src/packlets/invitations/halo-invitations.test.js.map +1 -0
  72. package/dist/src/packlets/invitations/index.d.ts +6 -3
  73. package/dist/src/packlets/invitations/index.d.ts.map +1 -1
  74. package/dist/src/packlets/invitations/index.js +6 -3
  75. package/dist/src/packlets/invitations/index.js.map +1 -1
  76. package/dist/src/packlets/invitations/invitations-proxy.d.ts +14 -0
  77. package/dist/src/packlets/invitations/invitations-proxy.d.ts.map +1 -0
  78. package/dist/src/packlets/invitations/invitations-proxy.js +126 -0
  79. package/dist/src/packlets/invitations/invitations-proxy.js.map +1 -0
  80. package/dist/src/packlets/invitations/invitations.d.ts +90 -0
  81. package/dist/src/packlets/invitations/invitations.d.ts.map +1 -0
  82. package/dist/src/packlets/invitations/invitations.js +55 -0
  83. package/dist/src/packlets/invitations/invitations.js.map +1 -0
  84. package/dist/src/packlets/invitations/space-invitations-handler.d.ts +24 -0
  85. package/dist/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -0
  86. package/dist/src/packlets/invitations/space-invitations-handler.js +232 -0
  87. package/dist/src/packlets/invitations/space-invitations-handler.js.map +1 -0
  88. package/dist/src/packlets/invitations/space-invitations-handler.test.d.ts +2 -0
  89. package/dist/src/packlets/invitations/space-invitations-handler.test.d.ts.map +1 -0
  90. package/dist/src/packlets/invitations/space-invitations-handler.test.js +131 -0
  91. package/dist/src/packlets/invitations/space-invitations-handler.test.js.map +1 -0
  92. package/dist/src/packlets/invitations/space-invitations-proxy.d.ts +11 -0
  93. package/dist/src/packlets/invitations/space-invitations-proxy.d.ts.map +1 -0
  94. package/dist/src/packlets/invitations/space-invitations-proxy.js +17 -0
  95. package/dist/src/packlets/invitations/space-invitations-proxy.js.map +1 -0
  96. package/dist/src/packlets/invitations/space-invitations-service.d.ts +22 -0
  97. package/dist/src/packlets/invitations/space-invitations-service.d.ts.map +1 -0
  98. package/dist/src/packlets/invitations/space-invitations-service.js +189 -0
  99. package/dist/src/packlets/invitations/space-invitations-service.js.map +1 -0
  100. package/dist/src/packlets/invitations/space-invitations-service.test.d.ts +2 -0
  101. package/dist/src/packlets/invitations/space-invitations-service.test.d.ts.map +1 -0
  102. package/dist/src/packlets/invitations/space-invitations-service.test.js +100 -0
  103. package/dist/src/packlets/invitations/space-invitations-service.test.js.map +1 -0
  104. package/dist/src/packlets/services/index.d.ts +3 -2
  105. package/dist/src/packlets/services/index.d.ts.map +1 -1
  106. package/dist/src/packlets/services/index.js +3 -2
  107. package/dist/src/packlets/services/index.js.map +1 -1
  108. package/dist/src/packlets/services/service-context.d.ts +4 -7
  109. package/dist/src/packlets/services/service-context.d.ts.map +1 -1
  110. package/dist/src/packlets/services/service-context.js +9 -25
  111. package/dist/src/packlets/services/service-context.js.map +1 -1
  112. package/dist/src/packlets/services/service-definitions.d.ts +30 -0
  113. package/dist/src/packlets/services/service-definitions.d.ts.map +1 -0
  114. package/dist/src/packlets/services/{services.js → service-definitions.js} +9 -5
  115. package/dist/src/packlets/services/service-definitions.js.map +1 -0
  116. package/dist/src/packlets/services/service-host.d.ts +9 -12
  117. package/dist/src/packlets/services/service-host.d.ts.map +1 -1
  118. package/dist/src/packlets/services/service-host.js +55 -54
  119. package/dist/src/packlets/services/service-host.js.map +1 -1
  120. package/dist/src/packlets/services/service-host.test.js +7 -17
  121. package/dist/src/packlets/services/service-host.test.js.map +1 -1
  122. package/dist/src/packlets/services/service-proxy.d.ts +17 -0
  123. package/dist/src/packlets/services/service-proxy.d.ts.map +1 -0
  124. package/dist/src/packlets/services/service-proxy.js +48 -0
  125. package/dist/src/packlets/services/service-proxy.js.map +1 -0
  126. package/dist/src/packlets/services/service-registry.d.ts +12 -0
  127. package/dist/src/packlets/services/service-registry.d.ts.map +1 -0
  128. package/dist/src/packlets/services/service-registry.js +24 -0
  129. package/dist/src/packlets/services/service-registry.js.map +1 -0
  130. package/dist/src/packlets/services/service-registry.test.d.ts +2 -0
  131. package/dist/src/packlets/services/service-registry.test.d.ts.map +1 -0
  132. package/dist/src/packlets/services/service-registry.test.js +75 -0
  133. package/dist/src/packlets/services/service-registry.test.js.map +1 -0
  134. package/dist/src/packlets/services/signer.d.ts +0 -3
  135. package/dist/src/packlets/services/signer.d.ts.map +1 -1
  136. package/dist/src/packlets/spaces/index.d.ts +2 -0
  137. package/dist/src/packlets/spaces/index.d.ts.map +1 -0
  138. package/dist/src/packlets/spaces/index.js +21 -0
  139. package/dist/src/packlets/spaces/index.js.map +1 -0
  140. package/dist/src/packlets/spaces/spaces-service.d.ts +11 -0
  141. package/dist/src/packlets/spaces/spaces-service.d.ts.map +1 -0
  142. package/dist/src/packlets/spaces/spaces-service.js +22 -0
  143. package/dist/src/packlets/spaces/spaces-service.js.map +1 -0
  144. package/dist/src/packlets/storage/storage.js +1 -1
  145. package/dist/src/packlets/storage/storage.js.map +1 -1
  146. package/dist/src/packlets/testing/index.d.ts +2 -0
  147. package/dist/src/packlets/testing/index.d.ts.map +1 -0
  148. package/dist/src/packlets/testing/index.js +21 -0
  149. package/dist/src/packlets/testing/index.js.map +1 -0
  150. package/dist/src/packlets/testing/test-builder.d.ts +14 -0
  151. package/dist/src/packlets/testing/test-builder.d.ts.map +1 -0
  152. package/dist/src/packlets/testing/test-builder.js +65 -0
  153. package/dist/src/packlets/testing/test-builder.js.map +1 -0
  154. package/dist/src/packlets/vault/iframe-runtime.d.ts +19 -0
  155. package/dist/src/packlets/vault/iframe-runtime.d.ts.map +1 -0
  156. package/dist/src/packlets/vault/iframe-runtime.js +54 -0
  157. package/dist/src/packlets/vault/iframe-runtime.js.map +1 -0
  158. package/dist/src/packlets/vault/index.d.ts +4 -0
  159. package/dist/src/packlets/vault/index.d.ts.map +1 -0
  160. package/dist/src/packlets/vault/index.js +23 -0
  161. package/dist/src/packlets/vault/index.js.map +1 -0
  162. package/dist/src/packlets/vault/services.d.ts +13 -0
  163. package/dist/src/packlets/vault/services.d.ts.map +1 -0
  164. package/dist/src/packlets/vault/services.js +15 -0
  165. package/dist/src/packlets/vault/services.js.map +1 -0
  166. package/dist/src/packlets/vault/worker-runtime.d.ts +32 -0
  167. package/dist/src/packlets/vault/worker-runtime.d.ts.map +1 -0
  168. package/dist/src/packlets/vault/worker-runtime.js +94 -0
  169. package/dist/src/packlets/vault/worker-runtime.js.map +1 -0
  170. package/dist/src/packlets/vault/worker-session.d.ts +29 -0
  171. package/dist/src/packlets/vault/worker-session.d.ts.map +1 -0
  172. package/dist/src/packlets/vault/worker-session.js +84 -0
  173. package/dist/src/packlets/vault/worker-session.js.map +1 -0
  174. package/package.json +26 -26
  175. package/src/index.ts +5 -2
  176. package/src/packlets/{services/impl → deprecated}/index.ts +1 -4
  177. package/src/packlets/{invitations/common.ts → deprecated/invitations.ts} +18 -3
  178. package/src/packlets/{services/impl → deprecated}/profile.ts +13 -13
  179. package/src/packlets/deprecated/space.ts +245 -0
  180. package/src/packlets/{services/impl → deprecated}/system.ts +2 -2
  181. package/src/packlets/{services/impl → deprecated}/tracing.ts +2 -2
  182. package/src/packlets/{services/impl → devtools}/devtools.ts +33 -34
  183. package/src/packlets/devtools/feeds.ts +31 -27
  184. package/src/packlets/devtools/index.ts +1 -1
  185. package/src/packlets/devtools/spaces.ts +19 -18
  186. package/src/packlets/identity/devices-service-impl.ts +54 -0
  187. package/src/packlets/identity/identity-manager.test.ts +7 -8
  188. package/src/packlets/identity/identity.test.ts +2 -3
  189. package/src/packlets/identity/identity.ts +5 -1
  190. package/src/packlets/invitations/encoder.test.ts +22 -0
  191. package/src/packlets/invitations/encoder.ts +26 -0
  192. package/src/packlets/{services/testing/halo.test.ts → invitations/halo-invitations.test.ts} +5 -5
  193. package/src/packlets/invitations/halo-invitations.ts +12 -10
  194. package/src/packlets/invitations/index.ts +6 -3
  195. package/src/packlets/invitations/invitations-proxy.ts +157 -0
  196. package/src/packlets/invitations/invitations.ts +149 -0
  197. package/src/packlets/invitations/space-invitations-handler.test.ts +154 -0
  198. package/src/packlets/invitations/space-invitations-handler.ts +266 -0
  199. package/src/packlets/invitations/space-invitations-proxy.ts +16 -0
  200. package/src/packlets/invitations/space-invitations-service.test.ts +129 -0
  201. package/src/packlets/invitations/space-invitations-service.ts +196 -0
  202. package/src/packlets/services/index.ts +3 -2
  203. package/src/packlets/services/service-context.ts +9 -31
  204. package/src/packlets/services/service-definitions.ts +54 -0
  205. package/src/packlets/services/service-host.test.ts +12 -24
  206. package/src/packlets/services/service-host.ts +64 -64
  207. package/src/packlets/services/service-proxy.ts +54 -0
  208. package/src/packlets/services/service-registry.test.ts +95 -0
  209. package/src/packlets/services/service-registry.ts +24 -0
  210. package/src/packlets/services/signer.ts +1 -3
  211. package/src/packlets/spaces/index.ts +5 -0
  212. package/src/packlets/spaces/spaces-service.ts +28 -0
  213. package/src/packlets/storage/storage.ts +1 -1
  214. package/src/packlets/testing/index.ts +5 -0
  215. package/src/packlets/testing/test-builder.ts +79 -0
  216. package/src/packlets/vault/iframe-runtime.ts +68 -0
  217. package/src/packlets/vault/index.ts +7 -0
  218. package/src/packlets/vault/services.ts +26 -0
  219. package/src/packlets/vault/worker-runtime.ts +111 -0
  220. package/src/packlets/vault/worker-session.ts +113 -0
  221. package/dist/src/packlets/devtools/devtools-host-events.d.ts +0 -5
  222. package/dist/src/packlets/devtools/devtools-host-events.d.ts.map +0 -1
  223. package/dist/src/packlets/devtools/devtools-host-events.js +0 -14
  224. package/dist/src/packlets/devtools/devtools-host-events.js.map +0 -1
  225. package/dist/src/packlets/invitations/common.d.ts.map +0 -1
  226. package/dist/src/packlets/invitations/common.js.map +0 -1
  227. package/dist/src/packlets/invitations/invitation-wrapper.d.ts +0 -36
  228. package/dist/src/packlets/invitations/invitation-wrapper.d.ts.map +0 -1
  229. package/dist/src/packlets/invitations/invitation-wrapper.js +0 -104
  230. package/dist/src/packlets/invitations/invitation-wrapper.js.map +0 -1
  231. package/dist/src/packlets/invitations/space-invitations.d.ts +0 -25
  232. package/dist/src/packlets/invitations/space-invitations.d.ts.map +0 -1
  233. package/dist/src/packlets/invitations/space-invitations.js +0 -136
  234. package/dist/src/packlets/invitations/space-invitations.js.map +0 -1
  235. package/dist/src/packlets/services/impl/devtools.d.ts.map +0 -1
  236. package/dist/src/packlets/services/impl/devtools.js +0 -77
  237. package/dist/src/packlets/services/impl/devtools.js.map +0 -1
  238. package/dist/src/packlets/services/impl/halo.d.ts +0 -20
  239. package/dist/src/packlets/services/impl/halo.d.ts.map +0 -1
  240. package/dist/src/packlets/services/impl/halo.js +0 -93
  241. package/dist/src/packlets/services/impl/halo.js.map +0 -1
  242. package/dist/src/packlets/services/impl/index.d.ts +0 -6
  243. package/dist/src/packlets/services/impl/index.d.ts.map +0 -1
  244. package/dist/src/packlets/services/impl/index.js.map +0 -1
  245. package/dist/src/packlets/services/impl/party.d.ts +0 -25
  246. package/dist/src/packlets/services/impl/party.d.ts.map +0 -1
  247. package/dist/src/packlets/services/impl/party.js +0 -265
  248. package/dist/src/packlets/services/impl/party.js.map +0 -1
  249. package/dist/src/packlets/services/impl/profile.d.ts.map +0 -1
  250. package/dist/src/packlets/services/impl/profile.js.map +0 -1
  251. package/dist/src/packlets/services/impl/system.d.ts.map +0 -1
  252. package/dist/src/packlets/services/impl/system.js.map +0 -1
  253. package/dist/src/packlets/services/impl/tracing.d.ts +0 -12
  254. package/dist/src/packlets/services/impl/tracing.d.ts.map +0 -1
  255. package/dist/src/packlets/services/impl/tracing.js.map +0 -1
  256. package/dist/src/packlets/services/service-factory.d.ts +0 -15
  257. package/dist/src/packlets/services/service-factory.d.ts.map +0 -1
  258. package/dist/src/packlets/services/service-factory.js +0 -25
  259. package/dist/src/packlets/services/service-factory.js.map +0 -1
  260. package/dist/src/packlets/services/services.d.ts +0 -19
  261. package/dist/src/packlets/services/services.d.ts.map +0 -1
  262. package/dist/src/packlets/services/services.js.map +0 -1
  263. package/dist/src/packlets/services/testing/halo.test.d.ts +0 -2
  264. package/dist/src/packlets/services/testing/halo.test.d.ts.map +0 -1
  265. package/dist/src/packlets/services/testing/halo.test.js.map +0 -1
  266. package/dist/src/packlets/services/testing/spaces.test.d.ts +0 -2
  267. package/dist/src/packlets/services/testing/spaces.test.d.ts.map +0 -1
  268. package/dist/src/packlets/services/testing/spaces.test.js +0 -68
  269. package/dist/src/packlets/services/testing/spaces.test.js.map +0 -1
  270. package/dist/src/packlets/services/testing/testing.d.ts +0 -8
  271. package/dist/src/packlets/services/testing/testing.d.ts.map +0 -1
  272. package/dist/src/packlets/services/testing/testing.js +0 -23
  273. package/dist/src/packlets/services/testing/testing.js.map +0 -1
  274. package/src/packlets/devtools/devtools-host-events.ts +0 -8
  275. package/src/packlets/invitations/invitation-wrapper.ts +0 -140
  276. package/src/packlets/invitations/space-invitations.ts +0 -159
  277. package/src/packlets/services/impl/halo.ts +0 -107
  278. package/src/packlets/services/impl/party.ts +0 -305
  279. package/src/packlets/services/service-factory.ts +0 -35
  280. package/src/packlets/services/services.ts +0 -39
  281. package/src/packlets/services/testing/spaces.test.ts +0 -87
  282. package/src/packlets/services/testing/testing.ts +0 -28
@@ -1,305 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import assert from 'node:assert';
6
- import { v4 } from 'uuid';
7
-
8
- import { latch } from '@dxos/async';
9
- import { Stream } from '@dxos/codec-protobuf';
10
- import { todo } from '@dxos/debug';
11
- import {
12
- AuthenticateInvitationRequest,
13
- CreateInvitationRequest,
14
- CreateSnapshotRequest,
15
- GetPartyDetailsRequest,
16
- InvitationRequest,
17
- InvitationState,
18
- Party,
19
- PartyDetails,
20
- PartyService as PartyServiceRpc,
21
- RedeemedInvitation,
22
- SetPartyStateRequest,
23
- SubscribeMembersRequest,
24
- SubscribeMembersResponse,
25
- SubscribePartiesResponse,
26
- SubscribePartyRequest,
27
- SubscribePartyResponse
28
- } from '@dxos/protocols/proto/dxos/client';
29
- import { PartySnapshot } from '@dxos/protocols/proto/dxos/echo/snapshot';
30
- import { InvitationDescriptor } from '@dxos/protocols/proto/dxos/halo/invitations';
31
-
32
- import { InvitationWrapper, InviteeInvitation, InviteeInvitations } from '../../invitations';
33
- import { ServiceContext } from '../service-context';
34
-
35
- /**
36
- * Party service implementation.
37
- */
38
- // TODO(burdon): Rename Space.
39
- export class PartyService implements PartyServiceRpc {
40
- private inviteeInvitations: InviteeInvitations = new Map();
41
-
42
- constructor(private readonly serviceContext: ServiceContext) {}
43
-
44
- subscribeToParty(request: SubscribePartyRequest): Stream<SubscribePartyResponse> {
45
- return new Stream(({ next }) => {
46
- next({
47
- party: {
48
- publicKey: request.partyKey,
49
- isOpen: true,
50
- isActive: true,
51
- members: []
52
- }
53
- });
54
- });
55
- // const update = (next: (message: SubscribePartyResponse) => void) => {
56
- // try {
57
- // const party = this.echo.getParty(request.party_key);
58
- // next({
59
- // party: party && {
60
- // public_key: party.key,
61
- // is_open: party.is_open,
62
- // is_active: party.is_active,
63
- // members: party.queryMembers().value
64
- // }
65
- // });
66
- // } catch (err) {
67
- // if (err instanceof InvalidStateError) {
68
- // // Do nothing.
69
- // } else {
70
- // throw err;
71
- // }
72
- // }
73
- // };
74
-
75
- // const party = this.serviceContext.brane.getParty(request.party_key);
76
- // if (party) {
77
- // return new Stream(({ next }) => party.update.on(() => update(next)));
78
- // } else {
79
- // return new Stream(({ next }) => {
80
- // let unsubscribeParty: () => void;
81
- // const unsubscribeParties = this.echo.queryParties().subscribe((parties) => {
82
- // const party = parties.find((party) => party.key.equals(request.party_key));
83
- // if (party && !unsubscribeParty) {
84
- // unsubscribeParty = party.update.on(() => update(next));
85
- // }
86
- // });
87
-
88
- // update(next);
89
-
90
- // return () => {
91
- // unsubscribeParties();
92
- // unsubscribeParty?.();
93
- // };
94
- // });
95
- // }
96
- }
97
-
98
- subscribeParties() {
99
- return new Stream<SubscribePartiesResponse>(({ next }) => {
100
- const update = () => {
101
- next({
102
- parties: Array.from(this.serviceContext.spaceManager!.spaces.values()).map((space) => ({
103
- publicKey: space.key,
104
- isOpen: true,
105
- isActive: true
106
- }))
107
- });
108
- };
109
-
110
- setTimeout(async () => {
111
- if (!this.serviceContext.spaceManager) {
112
- next({ parties: [] });
113
- }
114
-
115
- await this.serviceContext.initialized.wait();
116
-
117
- update();
118
- return this.serviceContext.spaceManager!.update.on(update);
119
- });
120
- });
121
- }
122
-
123
- async getPartyDetails(request: GetPartyDetailsRequest): Promise<PartyDetails> {
124
- return todo();
125
- // const party = this.echo.getParty(request.party_key) ?? raise(new SpaceNotFoundError(request.party_key));
126
- // return {
127
- // processedTimeframe: party.timeframe
128
- // };
129
- }
130
-
131
- async createParty(): Promise<Party> {
132
- await this.serviceContext.initialized.wait();
133
- const space = await this.serviceContext.spaceManager!.createSpace();
134
- return {
135
- publicKey: space.key,
136
- isOpen: true,
137
- isActive: true
138
- };
139
- }
140
-
141
- async cloneParty(snapshot: PartySnapshot): Promise<Party> {
142
- return todo();
143
- // const party = await this.echo.cloneParty(snapshot);
144
- // return {
145
- // public_key: party.key,
146
- // is_open: party.is_open,
147
- // is_active: party.is_active
148
- // };
149
- }
150
-
151
- async setPartyState(request: SetPartyStateRequest) {
152
- return todo();
153
- // const party = this.echo.getParty(request.party_key);
154
- // if (!party) {
155
- // throw new Error('Party not found');
156
- // }
157
-
158
- // if (request.open === true) {
159
- // await party.open();
160
- // } else if (request.open === false) {
161
- // await party.close();
162
- // } // Undefined preserves previous state.
163
-
164
- // if (request.active_global === true) {
165
- // await party.activate({ global: true });
166
- // } else if (request.active_global === false) {
167
- // await party.deactivate({ global: true });
168
- // } // Undefined preserves previous state.
169
-
170
- // if (request.active_device === true) {
171
- // await party.activate({ device: true });
172
- // } else if (request.active_device === false) {
173
- // await party.deactivate({ device: true });
174
- // } // Undefined preserves previous state.
175
- // return {
176
- // public_key: party.key,
177
- // is_open: party.is_open,
178
- // is_active: party.is_active
179
- // };
180
- }
181
-
182
- createInvitation(request: CreateInvitationRequest): Stream<InvitationRequest> {
183
- return new Stream(({ next, close }) => {
184
- setTimeout(async () => {
185
- try {
186
- let invitation: InvitationWrapper;
187
- if (!request.inviteeKey) {
188
- // const secret = Buffer.from(generatePasscode());
189
- // const secretProvider = async () => {
190
- // next({ state: InvitationState.CONNECTED });
191
- // return Buffer.from(secret);
192
- // };
193
- invitation = await this.serviceContext.createInvitation(request.partyKey, () => {
194
- next({ state: InvitationState.SUCCESS });
195
- close();
196
- });
197
-
198
- assert(invitation.type === InvitationDescriptor.Type.INTERACTIVE);
199
- // invitation.secret = Buffer.from(secret);
200
- } else {
201
- todo();
202
- // invitation = await party.invitationManager.createOfflineInvitation(request.invitee_key);
203
- }
204
-
205
- // TODO(burdon): Change stream type.
206
- next({
207
- state: InvitationState.WAITING_FOR_CONNECTION,
208
- descriptor: invitation!.toProto()
209
- });
210
-
211
- // if (invitation.type === InvitationDescriptor.Type.OFFLINE) {
212
- // close();
213
- // }
214
- } catch (err: any) {
215
- next({ state: InvitationState.ERROR, error: err.message });
216
- close();
217
- }
218
- });
219
- });
220
- }
221
-
222
- acceptInvitation(request: InvitationDescriptor): Stream<RedeemedInvitation> {
223
- return new Stream(({ next, close }) => {
224
- const id = v4();
225
- const [, secretTrigger] = latch();
226
- const inviteeInvitation: InviteeInvitation = { secretTrigger };
227
-
228
- // Secret will be provided separately (in AuthenticateInvitation).
229
- // Process will continue when `secretLatch` resolves, triggered by `secretTrigger`.
230
- // const secretProvider: SecretProvider = async () => {
231
- // await secretLatch;
232
- // const secret = inviteeInvitation.secret;
233
- // if (!secret) {
234
- // throw new Error('Secret not provided.');
235
- // }
236
-
237
- // return Buffer.from(secret);
238
- // };
239
-
240
- // Joining process is kicked off, and will await authentication with a secret.
241
- const partyPromise = this.serviceContext.acceptInvitation(InvitationWrapper.fromProto(request));
242
- this.inviteeInvitations.set(id, inviteeInvitation);
243
- next({ id, state: InvitationState.CONNECTED });
244
-
245
- partyPromise
246
- .then((party) => {
247
- next({ id, state: InvitationState.SUCCESS, partyKey: party.key });
248
- })
249
- .catch((err) => {
250
- console.error(err);
251
- next({ id, state: InvitationState.ERROR, error: String(err) });
252
- })
253
- .finally(() => {
254
- close();
255
- });
256
- });
257
- }
258
-
259
- async authenticateInvitation(request: AuthenticateInvitationRequest) {
260
- assert(request.processId, 'Process ID is missing.');
261
- const invitation = this.inviteeInvitations.get(request.processId);
262
- assert(invitation, 'Invitation not found.');
263
- assert(request.secret, 'Secret not provided.');
264
-
265
- // Supply the secret, and move the internal invitation process by triggering the secretTrigger.
266
- invitation.secret = request.secret;
267
- invitation.secretTrigger?.();
268
- }
269
-
270
- subscribeMembers(request: SubscribeMembersRequest): Stream<SubscribeMembersResponse> {
271
- return new Stream(({ next }) => {
272
- next({
273
- members: []
274
- });
275
- });
276
- // const party = this.echo.getParty(request.party_key);
277
- // if (party) {
278
- // return resultSetToStream(party.queryMembers(), (members): SubscribeMembersResponse => ({ members }));
279
- // } else {
280
- // return new Stream(({ next }) => {
281
- // let unsubscribeMembers: () => void;
282
- // const unsubscribeParties = this.echo.queryParties().subscribe((parties) => {
283
- // const party = parties.find((party) => party.key.equals(request.party_key));
284
- // if (!unsubscribeMembers && party) {
285
- // const resultSet = party.queryMembers();
286
- // next({ members: resultSet.value });
287
- // unsubscribeMembers = resultSet.update.on(() => next({ members: resultSet.value }));
288
- // }
289
- // });
290
-
291
- // return () => {
292
- // unsubscribeParties();
293
- // unsubscribeMembers();
294
- // };
295
- // });
296
- // }
297
- }
298
-
299
- async createSnapshot(request: CreateSnapshotRequest): Promise<PartySnapshot> {
300
- return todo();
301
- // assert(request.party_key);
302
- // const party = this.echo.getParty(request.party_key) ?? raise(new SpaceNotFoundError(request.party_key));
303
- // return party.createSnapshot();
304
- }
305
- }
@@ -1,35 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import { Config } from '@dxos/config';
6
- import { NetworkManager } from '@dxos/network-manager';
7
-
8
- import { DevtoolsHostEvents } from '../devtools';
9
- import { HaloService, PartyService, ProfileService, SystemService, TracingService } from './impl';
10
- import { DevtoolsService } from './impl/devtools';
11
- import { ServiceContext } from './service-context';
12
- import { ClientServices } from './services';
13
- import { HaloSigner } from './signer';
14
-
15
- /**
16
- * Service factory.
17
- */
18
- export const createServices = ({
19
- config,
20
- context, // TODO(burdon): Too big to pass into services.?
21
- signer // TODO(burdon): Remove (legacy?)
22
- }: {
23
- config: Config;
24
- context: ServiceContext;
25
- networkManager: NetworkManager;
26
- signer?: HaloSigner;
27
- }): ClientServices => ({
28
- DataService: context.dataService,
29
- HaloService: new HaloService(null, signer), // TODO(burdon): Remove.
30
- PartyService: new PartyService(context),
31
- ProfileService: new ProfileService(context),
32
- SystemService: new SystemService(config),
33
- TracingService: new TracingService(config),
34
- DevtoolsHost: new DevtoolsService({ events: new DevtoolsHostEvents(), config, context })
35
- });
@@ -1,39 +0,0 @@
1
- //
2
- // Copyright 2020 DXOS.org
3
- //
4
-
5
- import { schema } from '@dxos/protocols';
6
- import { PartyService, ProfileService, SystemService, HaloService } from '@dxos/protocols/proto/dxos/client';
7
- import { DevtoolsHost, TracingService } from '@dxos/protocols/proto/dxos/devtools/host';
8
- import { DataService } from '@dxos/protocols/proto/dxos/echo/service';
9
- import { createServiceBundle } from '@dxos/rpc';
10
-
11
- // TODO(burdon): Is there a way to mark TS (generics) so cast isn't required for result of stream?
12
- export type ClientServices = {
13
- DataService: DataService;
14
- HaloService: HaloService;
15
- PartyService: PartyService;
16
- ProfileService: ProfileService;
17
- SystemService: SystemService;
18
-
19
- DevtoolsHost: DevtoolsHost;
20
- TracingService: TracingService;
21
- };
22
-
23
- // TODO(burdon): Rethink name/factory.
24
- export const clientServiceBundle = createServiceBundle<ClientServices>({
25
- DataService: schema.getService('dxos.echo.service.DataService'),
26
- HaloService: schema.getService('dxos.client.HaloService'),
27
- PartyService: schema.getService('dxos.client.PartyService'),
28
- ProfileService: schema.getService('dxos.client.ProfileService'),
29
- SystemService: schema.getService('dxos.client.SystemService'),
30
-
31
- DevtoolsHost: schema.getService('dxos.devtools.host.DevtoolsHost'),
32
- TracingService: schema.getService('dxos.devtools.host.TracingService')
33
- });
34
-
35
- export interface ClientServiceProvider {
36
- services: ClientServices;
37
- open(onProgressCallback?: ((progress: any) => void) | undefined): Promise<void>;
38
- close(): Promise<void>;
39
- }
@@ -1,87 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import { expect } from 'chai';
6
-
7
- import { MemorySignalManagerContext } from '@dxos/messaging';
8
- import { ObjectModel } from '@dxos/object-model';
9
- import { afterTest } from '@dxos/testutils';
10
-
11
- import { createServiceContext } from './testing';
12
-
13
- describe('services/spaces', function () {
14
- it('space genesis', async function () {
15
- const peer = await createServiceContext();
16
- await peer.open();
17
- afterTest(() => peer.close());
18
-
19
- await peer.createIdentity();
20
-
21
- const space = await peer.spaceManager!.createSpace();
22
- expect(space.database).not.to.be.undefined;
23
- expect(peer.spaceManager!.spaces.has(space.key)).to.be.true;
24
- await space.close();
25
- });
26
-
27
- it('space genesis with database', async function () {
28
- const peer = await createServiceContext();
29
- await peer.open();
30
- afterTest(() => peer.close());
31
-
32
- await peer.createIdentity();
33
- const space = await peer.spaceManager!.createSpace();
34
-
35
- {
36
- const item = await space.database!.createItem<ObjectModel>({ type: 'test' });
37
- void item.model.set('name', 'test');
38
- }
39
-
40
- {
41
- const [item] = space.database!.select({ type: 'test' }).exec().entities;
42
- expect(item.model.get('name')).to.eq('test');
43
- }
44
-
45
- await space.close();
46
- });
47
-
48
- it('create and accepts space invitations', async function () {
49
- const signalContext = new MemorySignalManagerContext();
50
-
51
- const peer1 = await createServiceContext({ signalContext });
52
- const peer2 = await createServiceContext({ signalContext });
53
-
54
- await peer1.open();
55
- await peer2.open();
56
- afterTest(() => peer1.close());
57
- afterTest(() => peer2.close());
58
-
59
- await peer1.createIdentity();
60
- await peer2.createIdentity();
61
-
62
- const space1 = await peer1.spaceManager!.createSpace();
63
- const invitation = await peer1.createInvitation(space1.key);
64
-
65
- const space2 = await peer2.acceptInvitation(invitation);
66
- expect(space1.key).to.deep.eq(space2.key);
67
-
68
- // TODO(burdon): Write multiple items.
69
-
70
- {
71
- // Check item replicated from 1 => 2.
72
- const item1 = await space1.database!.createItem({ type: 'dxos.example.1' });
73
- const item2 = await space2.database!.waitForItem({ type: 'dxos.example.1' });
74
- expect(item1.id).to.eq(item2.id);
75
- }
76
-
77
- {
78
- // Check item replicated from 2 => 1.
79
- const item1 = await space2.database!.createItem({ type: 'dxos.example.2' });
80
- const item2 = await space1.database!.waitForItem({ type: 'dxos.example.2' });
81
- expect(item1.id).to.eq(item2.id);
82
- }
83
-
84
- await space1.close();
85
- await space2.close();
86
- });
87
- });
@@ -1,28 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
6
- import { ModelFactory } from '@dxos/model-factory';
7
- import { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';
8
- import { ObjectModel } from '@dxos/object-model';
9
- import { createStorage, Storage, StorageType } from '@dxos/random-access-storage';
10
-
11
- import { ServiceContext } from '../service-context';
12
-
13
- // TODO(burdon): Create test builder.
14
- export const createServiceContext = async ({
15
- signalContext = new MemorySignalManagerContext(),
16
- storage = createStorage({ type: StorageType.RAM })
17
- }: {
18
- signalContext?: MemorySignalManagerContext;
19
- storage?: Storage;
20
- } = {}) => {
21
- const networkManager = new NetworkManager({
22
- signalManager: new MemorySignalManager(signalContext),
23
- transportFactory: MemoryTransportFactory
24
- });
25
-
26
- const modelFactory = new ModelFactory().registerModel(ObjectModel);
27
- return new ServiceContext(storage, networkManager, modelFactory);
28
- };