@dxos/client-services 0.1.2 → 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
@@ -4,33 +4,34 @@
4
4
 
5
5
  import { Stream } from '@dxos/codec-protobuf';
6
6
  import { Space } from '@dxos/echo-db';
7
- import { SubscribeToPartiesRequest, SubscribeToPartiesResponse } from '@dxos/protocols/proto/dxos/devtools/host';
8
- import { PartyMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';
7
+ import { SubscribeToSpacesRequest, SubscribeToSpacesResponse } from '@dxos/protocols/proto/dxos/devtools/host';
8
+ import { SpaceMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';
9
9
 
10
10
  import { ServiceContext } from '../services';
11
11
 
12
- export const subscribeToSpaces = (context: ServiceContext, { partyKeys = [] }: SubscribeToPartiesRequest) =>
13
- new Stream<SubscribeToPartiesResponse>(({ next }) => {
12
+ export const subscribeToSpaces = (context: ServiceContext, { spaceKeys = [] }: SubscribeToSpacesRequest) =>
13
+ new Stream<SubscribeToSpacesResponse>(({ next }) => {
14
14
  let unsubscribe: () => void;
15
15
 
16
16
  const update = async () => {
17
- const parties: Space[] = [...context.spaceManager!.spaces.values()];
18
- const filteredParties = parties.filter(
19
- (party) => !partyKeys?.length || partyKeys.some((partyKey) => partyKey.equals(party.key))
17
+ const spaces: Space[] = [...context.spaceManager!.spaces.values()];
18
+ const filteredSpaces = spaces.filter(
19
+ (space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key))
20
20
  );
21
21
 
22
22
  next({
23
- parties: filteredParties.map((party) => {
24
- const partyMetadata = context.metadataStore.parties.find((partyMetadata: PartyMetadata) =>
25
- partyMetadata.key.equals(party.key)
23
+ spaces: filteredSpaces.map((space) => {
24
+ const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata: SpaceMetadata) =>
25
+ spaceMetadata.key.equals(space.key)
26
26
  );
27
+
27
28
  return {
28
- key: party.key,
29
- isOpen: party.isOpen,
30
- timeframe: partyMetadata!.latestTimeframe!,
31
- genesisFeed: party.genesisFeedKey,
32
- controlFeed: party.controlFeedKey,
33
- dataFeed: party.dataFeedKey
29
+ key: space.key,
30
+ isOpen: space.isOpen,
31
+ timeframe: spaceMetadata!.latestTimeframe!,
32
+ genesisFeed: space.genesisFeedKey,
33
+ controlFeed: space.controlFeedKey,
34
+ dataFeed: space.dataFeedKey
34
35
  };
35
36
  })
36
37
  });
@@ -38,9 +39,9 @@ export const subscribeToSpaces = (context: ServiceContext, { partyKeys = [] }: S
38
39
 
39
40
  setImmediate(async () => {
40
41
  await context.initialized.wait();
41
- unsubscribe = context.spaceManager!.update.on(() => update());
42
+ unsubscribe = context.spaceManager!.updated.on(() => update());
42
43
 
43
- // Send initial parties.
44
+ // Send initial spaces.
44
45
  await update();
45
46
  });
46
47
 
@@ -0,0 +1,54 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { EventSubscriptions } from '@dxos/async';
6
+ import { Stream } from '@dxos/codec-protobuf';
7
+ import { Device, DevicesService, QueryDevicesResponse } from '@dxos/protocols/proto/dxos/client/services';
8
+
9
+ import { IdentityManager } from './identity-manager';
10
+
11
+ export class DevicesServiceImpl implements DevicesService {
12
+ constructor(private readonly _identityManager: IdentityManager) {}
13
+
14
+ updateDevice(): Promise<Device> {
15
+ throw new Error('Method not implemented.');
16
+ }
17
+
18
+ queryDevices(): Stream<QueryDevicesResponse> {
19
+ return new Stream(({ next }) => {
20
+ const update = () => {
21
+ const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
22
+ if (!deviceKeys) {
23
+ next({ devices: [] });
24
+ } else {
25
+ next({
26
+ devices: Array.from(deviceKeys.values()).map((key) => ({
27
+ deviceKey: key
28
+ }))
29
+ });
30
+ }
31
+ };
32
+
33
+ const dispose = new EventSubscriptions();
34
+
35
+ dispose.add(
36
+ this._identityManager.stateUpdate.on(() => {
37
+ update();
38
+
39
+ if (this._identityManager.identity) {
40
+ dispose.add(
41
+ this._identityManager.identity.stateUpdate.on(() => {
42
+ update();
43
+ })
44
+ );
45
+ }
46
+ })
47
+ );
48
+
49
+ update();
50
+
51
+ return () => dispose.clear();
52
+ });
53
+ }
54
+ }
@@ -2,19 +2,18 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import expect from 'expect';
5
+ import { expect } from 'chai';
6
6
 
7
7
  import { valueEncoding, MetadataStore } from '@dxos/echo-db';
8
8
  import { FeedFactory, FeedStore } from '@dxos/feed-store';
9
9
  import { Keyring } from '@dxos/keyring';
10
10
  import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
11
- import { ModelFactory } from '@dxos/model-factory';
12
11
  import { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';
13
- import { ObjectModel } from '@dxos/object-model';
14
12
  import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
15
13
  import { createStorage, Storage, StorageType } from '@dxos/random-access-storage';
16
14
  import { afterTest } from '@dxos/testutils';
17
15
 
16
+ import { createDefaultModelFactory } from '../services';
18
17
  import { IdentityManager } from './identity-manager';
19
18
 
20
19
  describe('identity/identity-manager', function () {
@@ -50,7 +49,7 @@ describe('identity/identity-manager', function () {
50
49
  feedStore,
51
50
  keyring,
52
51
  networkManager,
53
- new ModelFactory().registerModel(ObjectModel)
52
+ createDefaultModelFactory()
54
53
  );
55
54
 
56
55
  return {
@@ -65,7 +64,7 @@ describe('identity/identity-manager', function () {
65
64
  afterTest(() => identityManager.close());
66
65
 
67
66
  const identity = await identityManager.createIdentity();
68
- expect(identity).toBeTruthy();
67
+ expect(identity).to.exist;
69
68
  });
70
69
 
71
70
  it('reload from storage', async function () {
@@ -80,9 +79,9 @@ describe('identity/identity-manager', function () {
80
79
  const peer2 = await setupPeer({ storage });
81
80
  await peer2.identityManager.open();
82
81
 
83
- expect(peer2.identityManager.identity).toBeDefined();
84
- expect(peer2.identityManager.identity!.identityKey).toEqual(identity1.identityKey);
85
- expect(peer2.identityManager.identity!.deviceKey).toEqual(identity1.deviceKey);
82
+ expect(peer2.identityManager.identity).to.exist;
83
+ expect(peer2.identityManager.identity!.identityKey).to.deep.eq(identity1.identityKey);
84
+ expect(peer2.identityManager.identity!.deviceKey).to.deep.eq(identity1.deviceKey);
86
85
 
87
86
  // TODO(dmaretskyi): Check that identity is "alive" (space is working and can write mutations).
88
87
  });
@@ -10,18 +10,17 @@ import { FeedFactory, FeedStore } from '@dxos/feed-store';
10
10
  import { Keyring } from '@dxos/keyring';
11
11
  import { PublicKey } from '@dxos/keys';
12
12
  import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
13
- import { ModelFactory } from '@dxos/model-factory';
14
13
  import { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';
15
- import { ObjectModel } from '@dxos/object-model';
16
14
  import { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
17
15
  import { AdmittedFeed } from '@dxos/protocols/proto/dxos/halo/credentials';
18
16
  import { createStorage, StorageType } from '@dxos/random-access-storage';
19
17
  import { afterTest } from '@dxos/testutils';
20
18
 
19
+ import { createDefaultModelFactory } from '../services';
21
20
  import { createHaloAuthProvider, createHaloAuthVerifier } from './authenticator';
22
21
  import { Identity } from './identity';
23
22
 
24
- const modelFactory = new ModelFactory().registerModel(ObjectModel);
23
+ const modelFactory = createDefaultModelFactory();
25
24
 
26
25
  describe('identity/identity', function () {
27
26
  it('create', async function () {
@@ -4,6 +4,7 @@
4
4
 
5
5
  import assert from 'assert';
6
6
 
7
+ import { Event } from '@dxos/async';
7
8
  import {
8
9
  DeviceStateMachine,
9
10
  CredentialSigner,
@@ -34,6 +35,8 @@ export class Identity {
34
35
  public readonly identityKey: PublicKey;
35
36
  public readonly deviceKey: PublicKey;
36
37
 
38
+ public readonly stateUpdate = new Event();
39
+
37
40
  constructor({ space, signer, identityKey, deviceKey }: IdentityParams) {
38
41
  this._space = space;
39
42
  this._signer = signer;
@@ -43,9 +46,10 @@ export class Identity {
43
46
 
44
47
  this._deviceStateMachine = new DeviceStateMachine(this.identityKey, this.deviceKey);
45
48
 
46
- // Save device key chain credential when processed by the party state machine.
49
+ // Save device key chain credential when processed by the space state machine.
47
50
  this._space.onCredentialProcessed.set(async (credential) => {
48
51
  await this._deviceStateMachine.process(credential);
52
+ this.stateUpdate.emit();
49
53
  });
50
54
  }
51
55
 
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { expect } from 'chai';
6
+
7
+ import { PublicKey } from '@dxos/keys';
8
+ import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
9
+
10
+ import { InvitationEncoder } from './encoder';
11
+
12
+ describe('Invitation utils', function () {
13
+ it('encodes and decodes an invitation', function () {
14
+ const invitation: Invitation = {
15
+ swarmKey: PublicKey.random()
16
+ };
17
+
18
+ const encoded = InvitationEncoder.encode(invitation);
19
+ const decoded = InvitationEncoder.decode(encoded);
20
+ expect(decoded.swarmKey).to.deep.eq(invitation.swarmKey);
21
+ });
22
+ });
@@ -0,0 +1,26 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import base from 'base-x';
6
+
7
+ import { schema } from '@dxos/protocols';
8
+ import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
9
+
10
+ // Encode with URL-safe alpha-numeric characters.
11
+ const base62 = base('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
12
+
13
+ const codec = schema.getCodecForType('dxos.client.services.Invitation');
14
+
15
+ /**
16
+ * Encodes and decodes an invitation proto into/from alphanumeric chars.
17
+ */
18
+ export class InvitationEncoder {
19
+ static decode(text: string): Invitation {
20
+ return codec.decode(base62.decode(text));
21
+ }
22
+
23
+ static encode(invitation: Invitation): string {
24
+ return base62.encode(codec.encode(invitation));
25
+ }
26
+ }
@@ -7,11 +7,11 @@ import { expect } from 'chai';
7
7
  import { MemorySignalManagerContext } from '@dxos/messaging';
8
8
  import { afterTest } from '@dxos/testutils';
9
9
 
10
- import { createServiceContext } from './testing';
10
+ import { createServiceContext } from '../testing';
11
11
 
12
12
  describe('services/halo', function () {
13
13
  it('creates identity', async function () {
14
- const peer = await createServiceContext();
14
+ const peer = createServiceContext();
15
15
  await peer.open();
16
16
  afterTest(() => peer.close());
17
17
 
@@ -19,11 +19,11 @@ describe('services/halo', function () {
19
19
  expect(identity).not.to.be.undefined;
20
20
  });
21
21
 
22
- it('device invitations', async function () {
22
+ it('invitations', async function () {
23
23
  const signalContext = new MemorySignalManagerContext();
24
24
 
25
- const peer1 = await createServiceContext({ signalContext });
26
- const peer2 = await createServiceContext({ signalContext });
25
+ const peer1 = createServiceContext({ signalContext });
26
+ const peer2 = createServiceContext({ signalContext });
27
27
  await peer1.open();
28
28
  await peer2.open();
29
29
  afterTest(() => peer1.close());
@@ -2,6 +2,8 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
+ import assert from 'assert';
6
+
5
7
  import { Trigger } from '@dxos/async';
6
8
  import { failUndefined } from '@dxos/debug';
7
9
  import { PublicKey } from '@dxos/keys';
@@ -9,7 +11,7 @@ import { log } from '@dxos/log';
9
11
  import { createProtocolFactory, NetworkManager, StarTopology } from '@dxos/network-manager';
10
12
  import { createRpcPlugin } from '@dxos/protocol-plugin-rpc';
11
13
  import { schema } from '@dxos/protocols';
12
- import { InvitationDescriptor } from '@dxos/protocols/proto/dxos/halo/invitations';
14
+ import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
13
15
  import { createProtoRpcPeer } from '@dxos/rpc';
14
16
 
15
17
  import { Identity, IdentityManager } from '../identity';
@@ -27,12 +29,11 @@ export class HaloInvitations {
27
29
  /**
28
30
  * Sends a HALO admission offer and waits for guest to accept.
29
31
  */
30
- async createInvitation({ onFinish }: { onFinish?: () => void } = {}): Promise<InvitationDescriptor> {
32
+ async createInvitation({ onFinish }: { onFinish?: () => void } = {}): Promise<Invitation> {
31
33
  const identity = this._identityManager.identity ?? failUndefined();
32
34
 
33
35
  const plugin = createRpcPlugin(async (port) => {
34
36
  const peer = createProtoRpcPeer({
35
- port,
36
37
  requested: {
37
38
  HaloGuestService: schema.getService('dxos.halo.invitations.HaloGuestService')
38
39
  },
@@ -61,7 +62,8 @@ export class HaloInvitations {
61
62
  // TODO(dmaretskyi): Admit guest's feeds otherwise messages from them won't be processed by the pipeline.
62
63
  }
63
64
  }
64
- }
65
+ },
66
+ port
65
67
  });
66
68
 
67
69
  await peer.open();
@@ -90,21 +92,19 @@ export class HaloInvitations {
90
92
  });
91
93
 
92
94
  return {
93
- type: InvitationDescriptor.Type.INTERACTIVE,
94
- swarmKey: topic.asUint8Array(),
95
- invitation: new Uint8Array() // TODO(burdon): Remove.
95
+ type: Invitation.Type.INTERACTIVE,
96
+ swarmKey: topic
96
97
  };
97
98
  }
98
99
 
99
100
  /**
100
101
  * Joins an existing identity HALO by invitation.
101
102
  */
102
- async acceptInvitation(invitation: InvitationDescriptor): Promise<Identity> {
103
+ async acceptInvitation(invitation: Invitation): Promise<Identity> {
103
104
  const admitted = new Trigger<Identity>(); // TODO(burdon): Must not share across multiple connections.
104
105
 
105
106
  const plugin = createRpcPlugin(async (port) => {
106
107
  const peer = createProtoRpcPeer({
107
- port,
108
108
  requested: {
109
109
  // TODO(burdon): Rename in-bound.
110
110
  HaloHostService: schema.getService('dxos.halo.invitations.HaloHostService')
@@ -136,7 +136,8 @@ export class HaloInvitations {
136
136
  admitted.wake(identity);
137
137
  }
138
138
  }
139
- }
139
+ },
140
+ port
140
141
  });
141
142
 
142
143
  await peer.open();
@@ -144,6 +145,7 @@ export class HaloInvitations {
144
145
  await peer.close();
145
146
  });
146
147
 
148
+ assert(invitation.swarmKey);
147
149
  const topic = PublicKey.from(invitation.swarmKey);
148
150
  const peerId = PublicKey.random(); // TODO(burdon): Fails if using the actual peer key.
149
151
  const connection = await this._networkManager.openSwarmConnection({
@@ -2,7 +2,10 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- export * from './common';
5
+ export * from './encoder';
6
6
  export * from './halo-invitations';
7
- export * from './invitation-wrapper';
8
- export * from './space-invitations';
7
+ export * from './invitations';
8
+ export * from './invitations-proxy';
9
+ export * from './space-invitations-handler';
10
+ export * from './space-invitations-proxy';
11
+ export * from './space-invitations-service';
@@ -0,0 +1,157 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import assert from 'assert';
6
+
7
+ import { observableError } from '@dxos/async';
8
+ import { Stream } from '@dxos/codec-protobuf';
9
+ import { log } from '@dxos/log';
10
+ import { Invitation, InvitationsService } from '@dxos/protocols/proto/dxos/client/services';
11
+
12
+ import {
13
+ AuthenticatingInvitationObservable,
14
+ AuthenticatingInvitationProvider,
15
+ CreateInvitationsOptions,
16
+ InvitationsProxy,
17
+ InvitationObservable,
18
+ InvitationObservableProvider
19
+ } from './invitations';
20
+
21
+ /**
22
+ * Adapts invitations service observable to client/service stream.
23
+ * Used by both HALO and Spaces client/service interfaces.
24
+ */
25
+ export abstract class AbstractInvitationsProxy<T> implements InvitationsProxy<T> {
26
+ // prettier-ignore
27
+ constructor(
28
+ private readonly _invitationsService: InvitationsService
29
+ ) {}
30
+
31
+ abstract createInvitationObject(context: T): Invitation;
32
+
33
+ createInvitation(context: T, options?: CreateInvitationsOptions): InvitationObservable {
34
+ assert(context);
35
+
36
+ let invitationId: string;
37
+ const observable = new InvitationObservableProvider(async () => {
38
+ if (invitationId) {
39
+ await this._invitationsService.cancelInvitation({ invitationId });
40
+ }
41
+ });
42
+
43
+ const invitation = { ...this.createInvitationObject(context), ...options };
44
+ const stream: Stream<Invitation> = this._invitationsService.createInvitation(invitation);
45
+
46
+ stream.subscribe(
47
+ (invitation: Invitation) => {
48
+ observable.setInvitation(invitation);
49
+
50
+ switch (invitation.state) {
51
+ case Invitation.State.CONNECTING: {
52
+ assert(invitation.invitationId);
53
+ invitationId = invitation.invitationId;
54
+ observable.callback.onConnecting?.(invitation);
55
+ break;
56
+ }
57
+
58
+ case Invitation.State.CONNECTED: {
59
+ observable.callback.onConnected?.(invitation);
60
+ break;
61
+ }
62
+
63
+ case Invitation.State.AUTHENTICATING: {
64
+ observable.callback.onAuthenticating?.(invitation);
65
+ break;
66
+ }
67
+
68
+ case Invitation.State.SUCCESS: {
69
+ observable.callback.onSuccess?.(invitation);
70
+ break;
71
+ }
72
+
73
+ case Invitation.State.CANCELLED: {
74
+ observable.callback.onCancelled?.();
75
+ break;
76
+ }
77
+
78
+ default: {
79
+ log.error(`Invalid state: ${invitation.state}`);
80
+ }
81
+ }
82
+ },
83
+ (err) => {
84
+ if (err) {
85
+ observableError(observable, err);
86
+ }
87
+ }
88
+ );
89
+
90
+ return observable;
91
+ }
92
+
93
+ acceptInvitation(invitation: Invitation): AuthenticatingInvitationObservable {
94
+ assert(invitation && invitation.swarmKey);
95
+
96
+ const observable = new AuthenticatingInvitationProvider({
97
+ onCancel: async () => {
98
+ const invitationId = observable.invitation?.invitationId;
99
+ assert(invitationId);
100
+ await this._invitationsService.cancelInvitation({ invitationId });
101
+ },
102
+
103
+ onAuthenticate: async (authenticationCode: string) => {
104
+ const invitationId = observable.invitation?.invitationId;
105
+ assert(invitationId);
106
+ await this._invitationsService.authenticate({ invitationId, authenticationCode });
107
+ }
108
+ });
109
+
110
+ const stream: Stream<Invitation> = this._invitationsService.acceptInvitation(invitation);
111
+
112
+ stream.subscribe(
113
+ (invitation: Invitation) => {
114
+ assert(invitation.invitationId);
115
+ observable.setInvitation(invitation);
116
+
117
+ switch (invitation.state) {
118
+ case Invitation.State.CONNECTING: {
119
+ observable.callback.onConnecting?.(invitation);
120
+ break;
121
+ }
122
+
123
+ case Invitation.State.CONNECTED: {
124
+ observable.callback.onConnected?.(invitation);
125
+ break;
126
+ }
127
+
128
+ case Invitation.State.AUTHENTICATING: {
129
+ observable.callback.onAuthenticating?.(invitation);
130
+ break;
131
+ }
132
+
133
+ case Invitation.State.SUCCESS: {
134
+ observable.callback.onSuccess?.(invitation);
135
+ break;
136
+ }
137
+
138
+ case Invitation.State.CANCELLED: {
139
+ observable.callback.onCancelled?.();
140
+ break;
141
+ }
142
+
143
+ default: {
144
+ log.error(`Invalid state: ${invitation.state}`);
145
+ }
146
+ }
147
+ },
148
+ (err) => {
149
+ if (err) {
150
+ observableError(observable, err);
151
+ }
152
+ }
153
+ );
154
+
155
+ return observable;
156
+ }
157
+ }