@dxos/client-services 0.1.2 → 0.1.4

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 (287) hide show
  1. package/dist/src/index.d.ts +3 -1
  2. package/dist/src/index.d.ts.map +1 -1
  3. package/dist/src/index.js +3 -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/iframe-service-proxy.d.ts +23 -0
  105. package/dist/src/packlets/services/iframe-service-proxy.d.ts.map +1 -0
  106. package/dist/src/packlets/services/iframe-service-proxy.js +53 -0
  107. package/dist/src/packlets/services/iframe-service-proxy.js.map +1 -0
  108. package/dist/src/packlets/services/index.d.ts +3 -2
  109. package/dist/src/packlets/services/index.d.ts.map +1 -1
  110. package/dist/src/packlets/services/index.js +3 -2
  111. package/dist/src/packlets/services/index.js.map +1 -1
  112. package/dist/src/packlets/services/service-context.d.ts +4 -7
  113. package/dist/src/packlets/services/service-context.d.ts.map +1 -1
  114. package/dist/src/packlets/services/service-context.js +9 -25
  115. package/dist/src/packlets/services/service-context.js.map +1 -1
  116. package/dist/src/packlets/services/service-definitions.d.ts +30 -0
  117. package/dist/src/packlets/services/service-definitions.d.ts.map +1 -0
  118. package/dist/src/packlets/services/{services.js → service-definitions.js} +9 -5
  119. package/dist/src/packlets/services/service-definitions.js.map +1 -0
  120. package/dist/src/packlets/services/service-host.d.ts +9 -12
  121. package/dist/src/packlets/services/service-host.d.ts.map +1 -1
  122. package/dist/src/packlets/services/service-host.js +55 -54
  123. package/dist/src/packlets/services/service-host.js.map +1 -1
  124. package/dist/src/packlets/services/service-host.test.js +7 -17
  125. package/dist/src/packlets/services/service-host.test.js.map +1 -1
  126. package/dist/src/packlets/services/service-proxy.d.ts +17 -0
  127. package/dist/src/packlets/services/service-proxy.d.ts.map +1 -0
  128. package/dist/src/packlets/services/service-proxy.js +48 -0
  129. package/dist/src/packlets/services/service-proxy.js.map +1 -0
  130. package/dist/src/packlets/services/service-registry.d.ts +12 -0
  131. package/dist/src/packlets/services/service-registry.d.ts.map +1 -0
  132. package/dist/src/packlets/services/service-registry.js +24 -0
  133. package/dist/src/packlets/services/service-registry.js.map +1 -0
  134. package/dist/src/packlets/services/service-registry.test.d.ts +2 -0
  135. package/dist/src/packlets/services/service-registry.test.d.ts.map +1 -0
  136. package/dist/src/packlets/services/service-registry.test.js +75 -0
  137. package/dist/src/packlets/services/service-registry.test.js.map +1 -0
  138. package/dist/src/packlets/services/signer.d.ts +0 -3
  139. package/dist/src/packlets/services/signer.d.ts.map +1 -1
  140. package/dist/src/packlets/spaces/index.d.ts +2 -0
  141. package/dist/src/packlets/spaces/index.d.ts.map +1 -0
  142. package/dist/src/packlets/spaces/index.js +21 -0
  143. package/dist/src/packlets/spaces/index.js.map +1 -0
  144. package/dist/src/packlets/spaces/spaces-service.d.ts +11 -0
  145. package/dist/src/packlets/spaces/spaces-service.d.ts.map +1 -0
  146. package/dist/src/packlets/spaces/spaces-service.js +22 -0
  147. package/dist/src/packlets/spaces/spaces-service.js.map +1 -0
  148. package/dist/src/packlets/storage/storage.js +1 -1
  149. package/dist/src/packlets/storage/storage.js.map +1 -1
  150. package/dist/src/packlets/testing/index.d.ts +2 -0
  151. package/dist/src/packlets/testing/index.d.ts.map +1 -0
  152. package/dist/src/packlets/testing/index.js +21 -0
  153. package/dist/src/packlets/testing/index.js.map +1 -0
  154. package/dist/src/packlets/testing/test-builder.d.ts +14 -0
  155. package/dist/src/packlets/testing/test-builder.d.ts.map +1 -0
  156. package/dist/src/packlets/testing/test-builder.js +66 -0
  157. package/dist/src/packlets/testing/test-builder.js.map +1 -0
  158. package/dist/src/packlets/vault/iframe-runtime.d.ts +19 -0
  159. package/dist/src/packlets/vault/iframe-runtime.d.ts.map +1 -0
  160. package/dist/src/packlets/vault/iframe-runtime.js +54 -0
  161. package/dist/src/packlets/vault/iframe-runtime.js.map +1 -0
  162. package/dist/src/packlets/vault/index.d.ts +4 -0
  163. package/dist/src/packlets/vault/index.d.ts.map +1 -0
  164. package/dist/src/packlets/vault/index.js +23 -0
  165. package/dist/src/packlets/vault/index.js.map +1 -0
  166. package/dist/src/packlets/vault/services.d.ts +13 -0
  167. package/dist/src/packlets/vault/services.d.ts.map +1 -0
  168. package/dist/src/packlets/vault/services.js +15 -0
  169. package/dist/src/packlets/vault/services.js.map +1 -0
  170. package/dist/src/packlets/vault/worker-runtime.d.ts +32 -0
  171. package/dist/src/packlets/vault/worker-runtime.d.ts.map +1 -0
  172. package/dist/src/packlets/vault/worker-runtime.js +94 -0
  173. package/dist/src/packlets/vault/worker-runtime.js.map +1 -0
  174. package/dist/src/packlets/vault/worker-session.d.ts +29 -0
  175. package/dist/src/packlets/vault/worker-session.d.ts.map +1 -0
  176. package/dist/src/packlets/vault/worker-session.js +84 -0
  177. package/dist/src/packlets/vault/worker-session.js.map +1 -0
  178. package/package.json +26 -26
  179. package/src/index.ts +4 -2
  180. package/src/packlets/{services/impl → deprecated}/index.ts +1 -4
  181. package/src/packlets/{invitations/common.ts → deprecated/invitations.ts} +18 -3
  182. package/src/packlets/{services/impl → deprecated}/profile.ts +13 -13
  183. package/src/packlets/deprecated/space.ts +245 -0
  184. package/src/packlets/{services/impl → deprecated}/system.ts +2 -2
  185. package/src/packlets/{services/impl → deprecated}/tracing.ts +2 -2
  186. package/src/packlets/{services/impl → devtools}/devtools.ts +33 -34
  187. package/src/packlets/devtools/feeds.ts +31 -27
  188. package/src/packlets/devtools/index.ts +1 -1
  189. package/src/packlets/devtools/spaces.ts +19 -18
  190. package/src/packlets/identity/devices-service-impl.ts +54 -0
  191. package/src/packlets/identity/identity-manager.test.ts +7 -8
  192. package/src/packlets/identity/identity.test.ts +2 -3
  193. package/src/packlets/identity/identity.ts +5 -1
  194. package/src/packlets/invitations/encoder.test.ts +22 -0
  195. package/src/packlets/invitations/encoder.ts +26 -0
  196. package/src/packlets/{services/testing/halo.test.ts → invitations/halo-invitations.test.ts} +5 -5
  197. package/src/packlets/invitations/halo-invitations.ts +12 -10
  198. package/src/packlets/invitations/index.ts +6 -3
  199. package/src/packlets/invitations/invitations-proxy.ts +157 -0
  200. package/src/packlets/invitations/invitations.ts +149 -0
  201. package/src/packlets/invitations/space-invitations-handler.test.ts +154 -0
  202. package/src/packlets/invitations/space-invitations-handler.ts +266 -0
  203. package/src/packlets/invitations/space-invitations-proxy.ts +16 -0
  204. package/src/packlets/invitations/space-invitations-service.test.ts +129 -0
  205. package/src/packlets/invitations/space-invitations-service.ts +196 -0
  206. package/src/packlets/services/iframe-service-proxy.ts +71 -0
  207. package/src/packlets/services/index.ts +3 -2
  208. package/src/packlets/services/service-context.ts +9 -31
  209. package/src/packlets/services/service-definitions.ts +54 -0
  210. package/src/packlets/services/service-host.test.ts +12 -24
  211. package/src/packlets/services/service-host.ts +64 -64
  212. package/src/packlets/services/service-proxy.ts +54 -0
  213. package/src/packlets/services/service-registry.test.ts +95 -0
  214. package/src/packlets/services/service-registry.ts +24 -0
  215. package/src/packlets/services/signer.ts +1 -3
  216. package/src/packlets/spaces/index.ts +5 -0
  217. package/src/packlets/spaces/spaces-service.ts +28 -0
  218. package/src/packlets/storage/storage.ts +1 -1
  219. package/src/packlets/testing/index.ts +5 -0
  220. package/src/packlets/testing/test-builder.ts +80 -0
  221. package/src/packlets/vault/iframe-runtime.ts +68 -0
  222. package/src/packlets/vault/index.ts +7 -0
  223. package/src/packlets/vault/services.ts +26 -0
  224. package/src/packlets/vault/worker-runtime.ts +111 -0
  225. package/src/packlets/vault/worker-session.ts +113 -0
  226. package/dist/src/packlets/devtools/devtools-host-events.d.ts +0 -5
  227. package/dist/src/packlets/devtools/devtools-host-events.d.ts.map +0 -1
  228. package/dist/src/packlets/devtools/devtools-host-events.js +0 -14
  229. package/dist/src/packlets/devtools/devtools-host-events.js.map +0 -1
  230. package/dist/src/packlets/invitations/common.d.ts.map +0 -1
  231. package/dist/src/packlets/invitations/common.js.map +0 -1
  232. package/dist/src/packlets/invitations/invitation-wrapper.d.ts +0 -36
  233. package/dist/src/packlets/invitations/invitation-wrapper.d.ts.map +0 -1
  234. package/dist/src/packlets/invitations/invitation-wrapper.js +0 -104
  235. package/dist/src/packlets/invitations/invitation-wrapper.js.map +0 -1
  236. package/dist/src/packlets/invitations/space-invitations.d.ts +0 -25
  237. package/dist/src/packlets/invitations/space-invitations.d.ts.map +0 -1
  238. package/dist/src/packlets/invitations/space-invitations.js +0 -136
  239. package/dist/src/packlets/invitations/space-invitations.js.map +0 -1
  240. package/dist/src/packlets/services/impl/devtools.d.ts.map +0 -1
  241. package/dist/src/packlets/services/impl/devtools.js +0 -77
  242. package/dist/src/packlets/services/impl/devtools.js.map +0 -1
  243. package/dist/src/packlets/services/impl/halo.d.ts +0 -20
  244. package/dist/src/packlets/services/impl/halo.d.ts.map +0 -1
  245. package/dist/src/packlets/services/impl/halo.js +0 -93
  246. package/dist/src/packlets/services/impl/halo.js.map +0 -1
  247. package/dist/src/packlets/services/impl/index.d.ts +0 -6
  248. package/dist/src/packlets/services/impl/index.d.ts.map +0 -1
  249. package/dist/src/packlets/services/impl/index.js.map +0 -1
  250. package/dist/src/packlets/services/impl/party.d.ts +0 -25
  251. package/dist/src/packlets/services/impl/party.d.ts.map +0 -1
  252. package/dist/src/packlets/services/impl/party.js +0 -265
  253. package/dist/src/packlets/services/impl/party.js.map +0 -1
  254. package/dist/src/packlets/services/impl/profile.d.ts.map +0 -1
  255. package/dist/src/packlets/services/impl/profile.js.map +0 -1
  256. package/dist/src/packlets/services/impl/system.d.ts.map +0 -1
  257. package/dist/src/packlets/services/impl/system.js.map +0 -1
  258. package/dist/src/packlets/services/impl/tracing.d.ts +0 -12
  259. package/dist/src/packlets/services/impl/tracing.d.ts.map +0 -1
  260. package/dist/src/packlets/services/impl/tracing.js.map +0 -1
  261. package/dist/src/packlets/services/service-factory.d.ts +0 -15
  262. package/dist/src/packlets/services/service-factory.d.ts.map +0 -1
  263. package/dist/src/packlets/services/service-factory.js +0 -25
  264. package/dist/src/packlets/services/service-factory.js.map +0 -1
  265. package/dist/src/packlets/services/services.d.ts +0 -19
  266. package/dist/src/packlets/services/services.d.ts.map +0 -1
  267. package/dist/src/packlets/services/services.js.map +0 -1
  268. package/dist/src/packlets/services/testing/halo.test.d.ts +0 -2
  269. package/dist/src/packlets/services/testing/halo.test.d.ts.map +0 -1
  270. package/dist/src/packlets/services/testing/halo.test.js.map +0 -1
  271. package/dist/src/packlets/services/testing/spaces.test.d.ts +0 -2
  272. package/dist/src/packlets/services/testing/spaces.test.d.ts.map +0 -1
  273. package/dist/src/packlets/services/testing/spaces.test.js +0 -68
  274. package/dist/src/packlets/services/testing/spaces.test.js.map +0 -1
  275. package/dist/src/packlets/services/testing/testing.d.ts +0 -8
  276. package/dist/src/packlets/services/testing/testing.d.ts.map +0 -1
  277. package/dist/src/packlets/services/testing/testing.js +0 -23
  278. package/dist/src/packlets/services/testing/testing.js.map +0 -1
  279. package/src/packlets/devtools/devtools-host-events.ts +0 -8
  280. package/src/packlets/invitations/invitation-wrapper.ts +0 -140
  281. package/src/packlets/invitations/space-invitations.ts +0 -159
  282. package/src/packlets/services/impl/halo.ts +0 -107
  283. package/src/packlets/services/impl/party.ts +0 -305
  284. package/src/packlets/services/service-factory.ts +0 -35
  285. package/src/packlets/services/services.ts +0 -39
  286. package/src/packlets/services/testing/spaces.test.ts +0 -87
  287. package/src/packlets/services/testing/testing.ts +0 -28
@@ -1,19 +0,0 @@
1
- import { PartyService, ProfileService, SystemService, HaloService } from '@dxos/protocols/proto/dxos/client';
2
- import { DevtoolsHost, TracingService } from '@dxos/protocols/proto/dxos/devtools/host';
3
- import { DataService } from '@dxos/protocols/proto/dxos/echo/service';
4
- export declare type ClientServices = {
5
- DataService: DataService;
6
- HaloService: HaloService;
7
- PartyService: PartyService;
8
- ProfileService: ProfileService;
9
- SystemService: SystemService;
10
- DevtoolsHost: DevtoolsHost;
11
- TracingService: TracingService;
12
- };
13
- export declare const clientServiceBundle: import("@dxos/rpc").ServiceBundle<ClientServices>;
14
- export interface ClientServiceProvider {
15
- services: ClientServices;
16
- open(onProgressCallback?: ((progress: any) => void) | undefined): Promise<void>;
17
- close(): Promise<void>;
18
- }
19
- //# sourceMappingURL=services.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/packlets/services/services.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAItE,oBAAY,cAAc,GAAG;IAC3B,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,aAAa,CAAC;IAE7B,YAAY,EAAE,YAAY,CAAC;IAC3B,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAGF,eAAO,MAAM,mBAAmB,mDAS9B,CAAC;AAEH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,cAAc,CAAC;IACzB,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"services.js","sourceRoot":"","sources":["../../../../src/packlets/services/services.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,+CAAyC;AAIzC,mCAAgD;AAchD,sCAAsC;AACzB,QAAA,mBAAmB,GAAG,IAAA,yBAAmB,EAAiB;IACrE,WAAW,EAAE,kBAAM,CAAC,UAAU,CAAC,+BAA+B,CAAC;IAC/D,WAAW,EAAE,kBAAM,CAAC,UAAU,CAAC,yBAAyB,CAAC;IACzD,YAAY,EAAE,kBAAM,CAAC,UAAU,CAAC,0BAA0B,CAAC;IAC3D,cAAc,EAAE,kBAAM,CAAC,UAAU,CAAC,4BAA4B,CAAC;IAC/D,aAAa,EAAE,kBAAM,CAAC,UAAU,CAAC,2BAA2B,CAAC;IAE7D,YAAY,EAAE,kBAAM,CAAC,UAAU,CAAC,iCAAiC,CAAC;IAClE,cAAc,EAAE,kBAAM,CAAC,UAAU,CAAC,mCAAmC,CAAC;CACvE,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=halo.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"halo.test.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/services/testing/halo.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"halo.test.js","sourceRoot":"","sources":["../../../../../src/packlets/services/testing/halo.test.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;AAEF,+BAA8B;AAE9B,+CAA6D;AAC7D,+CAA4C;AAE5C,uCAAiD;AAEjD,QAAQ,CAAC,eAAe,EAAE;IACxB,EAAE,CAAC,kBAAkB,EAAE,KAAK;QAC1B,MAAM,IAAI,GAAG,MAAM,IAAA,8BAAoB,GAAE,CAAC;QAC1C,MAAM,IAAI,CAAC,IAAI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C,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=spaces.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spaces.test.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/services/testing/spaces.test.ts"],"names":[],"mappings":""}
@@ -1,68 +0,0 @@
1
- "use strict";
2
- //
3
- // Copyright 2022 DXOS.org
4
- //
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const chai_1 = require("chai");
7
- const messaging_1 = require("@dxos/messaging");
8
- const testutils_1 = require("@dxos/testutils");
9
- const testing_1 = require("./testing");
10
- describe('services/spaces', function () {
11
- it('space genesis', async function () {
12
- const peer = await (0, testing_1.createServiceContext)();
13
- await peer.open();
14
- (0, testutils_1.afterTest)(() => peer.close());
15
- await peer.createIdentity();
16
- const space = await peer.spaceManager.createSpace();
17
- (0, chai_1.expect)(space.database).not.to.be.undefined;
18
- (0, chai_1.expect)(peer.spaceManager.spaces.has(space.key)).to.be.true;
19
- await space.close();
20
- });
21
- it('space genesis with database', async function () {
22
- const peer = await (0, testing_1.createServiceContext)();
23
- await peer.open();
24
- (0, testutils_1.afterTest)(() => peer.close());
25
- await peer.createIdentity();
26
- const space = await peer.spaceManager.createSpace();
27
- {
28
- const item = await space.database.createItem({ type: 'test' });
29
- void item.model.set('name', 'test');
30
- }
31
- {
32
- const [item] = space.database.select({ type: 'test' }).exec().entities;
33
- (0, chai_1.expect)(item.model.get('name')).to.eq('test');
34
- }
35
- await space.close();
36
- });
37
- it('create and accepts space invitations', async function () {
38
- const signalContext = new messaging_1.MemorySignalManagerContext();
39
- const peer1 = await (0, testing_1.createServiceContext)({ signalContext });
40
- const peer2 = await (0, testing_1.createServiceContext)({ signalContext });
41
- await peer1.open();
42
- await peer2.open();
43
- (0, testutils_1.afterTest)(() => peer1.close());
44
- (0, testutils_1.afterTest)(() => peer2.close());
45
- await peer1.createIdentity();
46
- await peer2.createIdentity();
47
- const space1 = await peer1.spaceManager.createSpace();
48
- const invitation = await peer1.createInvitation(space1.key);
49
- const space2 = await peer2.acceptInvitation(invitation);
50
- (0, chai_1.expect)(space1.key).to.deep.eq(space2.key);
51
- // TODO(burdon): Write multiple items.
52
- {
53
- // Check item replicated from 1 => 2.
54
- const item1 = await space1.database.createItem({ type: 'dxos.example.1' });
55
- const item2 = await space2.database.waitForItem({ type: 'dxos.example.1' });
56
- (0, chai_1.expect)(item1.id).to.eq(item2.id);
57
- }
58
- {
59
- // Check item replicated from 2 => 1.
60
- const item1 = await space2.database.createItem({ type: 'dxos.example.2' });
61
- const item2 = await space1.database.waitForItem({ type: 'dxos.example.2' });
62
- (0, chai_1.expect)(item1.id).to.eq(item2.id);
63
- }
64
- await space1.close();
65
- await space2.close();
66
- });
67
- });
68
- //# sourceMappingURL=spaces.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spaces.test.js","sourceRoot":"","sources":["../../../../../src/packlets/services/testing/spaces.test.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;AAEF,+BAA8B;AAE9B,+CAA6D;AAE7D,+CAA4C;AAE5C,uCAAiD;AAEjD,QAAQ,CAAC,iBAAiB,EAAE;IAC1B,EAAE,CAAC,eAAe,EAAE,KAAK;QACvB,MAAM,IAAI,GAAG,MAAM,IAAA,8BAAoB,GAAE,CAAC;QAC1C,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAE9B,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAE5B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAa,CAAC,WAAW,EAAE,CAAC;QACrD,IAAA,aAAM,EAAC,KAAK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E,CAAC,CAAC;SAClC;QAED;YACE,qCAAqC;YACrC,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAS,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;YAC5E,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAS,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;YAC7E,IAAA,aAAM,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;SAClC;QAED,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- import { MemorySignalManagerContext } from '@dxos/messaging';
2
- import { Storage } from '@dxos/random-access-storage';
3
- import { ServiceContext } from '../service-context';
4
- export declare const createServiceContext: ({ signalContext, storage }?: {
5
- signalContext?: MemorySignalManagerContext | undefined;
6
- storage?: Storage | undefined;
7
- }) => Promise<ServiceContext>;
8
- //# sourceMappingURL=testing.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/services/testing/testing.ts"],"names":[],"mappings":"AAIA,OAAO,EAAuB,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAIlF,OAAO,EAAiB,OAAO,EAAe,MAAM,6BAA6B,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,eAAO,MAAM,oBAAoB;;;6BAchC,CAAC"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- //
3
- // Copyright 2022 DXOS.org
4
- //
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createServiceContext = void 0;
7
- const messaging_1 = require("@dxos/messaging");
8
- const model_factory_1 = require("@dxos/model-factory");
9
- const network_manager_1 = require("@dxos/network-manager");
10
- const object_model_1 = require("@dxos/object-model");
11
- const random_access_storage_1 = require("@dxos/random-access-storage");
12
- const service_context_1 = require("../service-context");
13
- // TODO(burdon): Create test builder.
14
- const createServiceContext = async ({ signalContext = new messaging_1.MemorySignalManagerContext(), storage = (0, random_access_storage_1.createStorage)({ type: random_access_storage_1.StorageType.RAM }) } = {}) => {
15
- const networkManager = new network_manager_1.NetworkManager({
16
- signalManager: new messaging_1.MemorySignalManager(signalContext),
17
- transportFactory: network_manager_1.MemoryTransportFactory
18
- });
19
- const modelFactory = new model_factory_1.ModelFactory().registerModel(object_model_1.ObjectModel);
20
- return new service_context_1.ServiceContext(storage, networkManager, modelFactory);
21
- };
22
- exports.createServiceContext = createServiceContext;
23
- //# sourceMappingURL=testing.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testing.js","sourceRoot":"","sources":["../../../../../src/packlets/services/testing/testing.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,+CAAkF;AAClF,uDAAmD;AACnD,2DAA+E;AAC/E,qDAAiD;AACjD,uEAAkF;AAElF,wDAAoD;AAEpD,qCAAqC;AAC9B,MAAM,oBAAoB,GAAG,KAAK,EAAE,EACzC,aAAa,GAAG,IAAI,sCAA0B,EAAE,EAChD,OAAO,GAAG,IAAA,qCAAa,EAAC,EAAE,IAAI,EAAE,mCAAW,CAAC,GAAG,EAAE,CAAC,KAIhD,EAAE,EAAE,EAAE;IACR,MAAM,cAAc,GAAG,IAAI,gCAAc,CAAC;QACxC,aAAa,EAAE,IAAI,+BAAmB,CAAC,aAAa,CAAC;QACrD,gBAAgB,EAAE,wCAAsB;KACzC,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,IAAI,4BAAY,EAAE,CAAC,aAAa,CAAC,0BAAW,CAAC,CAAC;IACnE,OAAO,IAAI,gCAAc,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AACnE,CAAC,CAAC;AAdW,QAAA,oBAAoB,wBAc/B"}
@@ -1,8 +0,0 @@
1
- //
2
- // Copyright 2021 DXOS.org
3
- //
4
- import { Event } from '@dxos/async';
5
-
6
- export class DevtoolsHostEvents {
7
- readonly ready = new Event();
8
- }
@@ -1,140 +0,0 @@
1
- //
2
- // Copyright 2020 DXOS.org
3
- //
4
-
5
- import base from 'base-x';
6
- import stableStringify from 'json-stable-stringify';
7
- import assert from 'node:assert';
8
-
9
- import { ripemd160 } from '@dxos/crypto';
10
- import { InvalidInvitationError } from '@dxos/echo-db';
11
- import { PublicKey } from '@dxos/keys';
12
- import { InvitationDescriptor } from '@dxos/protocols/proto/dxos/halo/invitations';
13
-
14
- // TODO(burdon): Move to Client API.
15
-
16
- // Encode with only alpha-numeric characters.
17
- const base62 = base('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
18
-
19
- /**
20
- * A serialized version of InvitationWrapper that's suitable to be encoded as an URL query string.
21
- */
22
- export interface InvitationQueryParameters {
23
- hash: string;
24
- swarmKey: string;
25
- invitation: string;
26
- identityKey?: string;
27
- type: string;
28
- }
29
-
30
- /**
31
- * Describes an issued invitation.
32
- *
33
- * Can be serialized to protobuf or JSON.
34
- * Invitations can be interactive or offline.
35
- *
36
- * This descriptor might also have a bundled secret for authentication in interactive mode.
37
- */
38
- // TODO(burdon): Move to Client API (and/or remove).
39
- export class InvitationWrapper {
40
- static decode(code: string): InvitationWrapper {
41
- const json = base62.decode(code).toString();
42
- return InvitationWrapper.fromQueryParameters(JSON.parse(json));
43
- }
44
-
45
- static encode(invitation: InvitationWrapper): string {
46
- const buffer = Buffer.from(JSON.stringify(invitation.toQueryParameters()));
47
- return base62.encode(buffer);
48
- }
49
-
50
- static fromQueryParameters(queryParameters: InvitationQueryParameters): InvitationWrapper {
51
- const { hash, swarmKey, invitation, identityKey, type } = queryParameters;
52
- const descriptor = new InvitationWrapper(
53
- parseInvitationType(type),
54
- PublicKey.from(swarmKey),
55
- PublicKey.bufferize(invitation),
56
- identityKey ? PublicKey.from(identityKey) : undefined
57
- );
58
-
59
- if (hash !== descriptor.hash) {
60
- throw new InvalidInvitationError();
61
- }
62
-
63
- return descriptor;
64
- }
65
-
66
- static fromProto(invitation: InvitationDescriptor): InvitationWrapper {
67
- assert(invitation.type !== undefined);
68
- assert(invitation.swarmKey, 'Missing swarm key');
69
- assert(invitation.invitation);
70
-
71
- return new InvitationWrapper(
72
- invitation.type,
73
- PublicKey.from(invitation.swarmKey),
74
- Buffer.from(invitation.invitation),
75
- invitation.identityKey ? PublicKey.from(invitation.identityKey) : undefined,
76
- invitation.secret ? Buffer.from(invitation.secret) : undefined
77
- );
78
- }
79
-
80
- constructor(
81
- public readonly type: InvitationDescriptor.Type,
82
- public readonly swarmKey: PublicKey,
83
- public readonly invitation: Uint8Array,
84
- public readonly identityKey?: PublicKey,
85
- public secret?: Uint8Array
86
- ) {
87
- assert(type !== undefined);
88
- assert(PublicKey.isPublicKey(swarmKey));
89
- assert(invitation instanceof Uint8Array);
90
- if (identityKey) {
91
- PublicKey.assertValidPublicKey(identityKey);
92
- }
93
- if (secret) {
94
- assert(secret instanceof Uint8Array);
95
- }
96
- }
97
-
98
- get hash() {
99
- const query = this.toQueryParameters();
100
- return query.hash;
101
- }
102
-
103
- toProto(): InvitationDescriptor {
104
- return {
105
- type: this.type,
106
- swarmKey: this.swarmKey.asUint8Array(),
107
- invitation: this.invitation,
108
- identityKey: this.identityKey?.asUint8Array(),
109
- secret: this.secret
110
- };
111
- }
112
-
113
- toQueryParameters(): InvitationQueryParameters {
114
- const query: Partial<InvitationQueryParameters> = {
115
- swarmKey: this.swarmKey.toHex(),
116
- invitation: PublicKey.stringify(this.invitation),
117
- type: stringifyInvitationType(this.type)
118
- };
119
-
120
- if (this.identityKey) {
121
- query.identityKey = this.identityKey.toHex();
122
- }
123
-
124
- query.hash = ripemd160(stableStringify(query));
125
- return query as InvitationQueryParameters;
126
- }
127
- }
128
-
129
- // TODO(burdon): Move to client API.
130
- const parseInvitationType = (str: string): InvitationDescriptor.Type => {
131
- const type = parseInt(str);
132
- assert(
133
- type === InvitationDescriptor.Type.INTERACTIVE || type === InvitationDescriptor.Type.OFFLINE,
134
- 'Invalid invitation type'
135
- );
136
- return type;
137
- };
138
-
139
- // TODO(burdon): Move to client API.
140
- const stringifyInvitationType = (type: InvitationDescriptor.Type): string => type.toString();
@@ -1,159 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import { Trigger } from '@dxos/async';
6
- import { createAdmissionCredentials } from '@dxos/credentials';
7
- import { SigningContext, Space, SpaceManager } from '@dxos/echo-db';
8
- import { writeMessages } from '@dxos/feed-store';
9
- import { PublicKey } from '@dxos/keys';
10
- import { log } from '@dxos/log';
11
- import { createProtocolFactory, NetworkManager, StarTopology } from '@dxos/network-manager';
12
- import { createRpcPlugin } from '@dxos/protocol-plugin-rpc';
13
- import { schema } from '@dxos/protocols';
14
- import { InvitationDescriptor } from '@dxos/protocols/proto/dxos/halo/invitations';
15
- import { createProtoRpcPeer } from '@dxos/rpc';
16
-
17
- /**
18
- * Manages the life-cycle of Space invitations between peers.
19
- */
20
- // TODO(burdon): Rename factory.
21
- export class SpaceInvitations {
22
- constructor(
23
- private readonly _spaceManager: SpaceManager,
24
- private readonly _networkManager: NetworkManager,
25
- private readonly _signingContext: SigningContext
26
- ) {}
27
-
28
- /**
29
- * Creates an invitation and listens for a join request from the invited (guest) peer.
30
- */
31
- // TODO(burdon): Replace callback with cancelable observable.
32
- async createInvitation(space: Space, { onFinish }: { onFinish?: () => void } = {}): Promise<InvitationDescriptor> {
33
- const admitted = new Trigger();
34
-
35
- const plugin = createRpcPlugin(async (port) => {
36
- const peer = createProtoRpcPeer({
37
- port,
38
- requested: {
39
- SpaceGuestService: schema.getService('dxos.halo.invitations.SpaceGuestService')
40
- },
41
- exposed: {
42
- SpaceHostService: schema.getService('dxos.halo.invitations.SpaceHostService')
43
- },
44
- handlers: {
45
- SpaceHostService: {
46
- presentAdmissionCredentials: async ({ identityKey, deviceKey, controlFeedKey, dataFeedKey }) => {
47
- log('processing admission request', { identityKey, deviceKey });
48
-
49
- await writeMessages(
50
- space.controlPipeline.writer,
51
- await createAdmissionCredentials(
52
- this._signingContext.credentialSigner,
53
- identityKey,
54
- deviceKey,
55
- space.key,
56
- controlFeedKey,
57
- dataFeedKey
58
- )
59
- );
60
-
61
- admitted.wake();
62
- }
63
- }
64
- }
65
- });
66
-
67
- // TODO(burdon): Error handling and timeout.
68
- await peer.open();
69
- {
70
- log('sending admission offer', { spaceKey: space.key });
71
- await peer.rpc.SpaceGuestService.presentAdmissionOffer({
72
- spaceKey: space.key,
73
- genesisFeedKey: space.genesisFeedKey
74
- });
75
-
76
- onFinish?.();
77
- }
78
- await peer.close();
79
- await connection.close();
80
- });
81
-
82
- const topic = PublicKey.random();
83
- const peerId = PublicKey.random(); // TODO(burdon): Use actual key.
84
- const connection = await this._networkManager.openSwarmConnection({
85
- topic,
86
- peerId: topic, // TODO(burdon): Why???
87
- // peerId,
88
- protocol: createProtocolFactory(topic, peerId, [plugin]),
89
- topology: new StarTopology(topic)
90
- });
91
-
92
- return {
93
- type: InvitationDescriptor.Type.INTERACTIVE, // TODO(burdon): Remove (default).
94
- swarmKey: topic.asUint8Array(),
95
- invitation: new Uint8Array() // TODO(burdon): Remove.
96
- };
97
- }
98
-
99
- /**
100
- * Waits for the host peer (inviter) to accept our join request.
101
- * The local guest peer (invitee) then sends the local party invitation to the host,
102
- * which then writes the guest's credentials to the space.
103
- */
104
- async acceptInvitation(invitation: InvitationDescriptor): Promise<Space> {
105
- const admitted = new Trigger<Space>();
106
-
107
- const plugin = createRpcPlugin(async (port) => {
108
- const peer = createProtoRpcPeer({
109
- port,
110
- requested: {
111
- SpaceHostService: schema.getService('dxos.halo.invitations.SpaceHostService')
112
- },
113
- exposed: {
114
- SpaceGuestService: schema.getService('dxos.halo.invitations.SpaceGuestService')
115
- },
116
- handlers: {
117
- SpaceGuestService: {
118
- presentAdmissionOffer: async ({ spaceKey, genesisFeedKey }) => {
119
- log('processing admission offer', { spaceKey });
120
- // Create local space.
121
- const space = await this._spaceManager.acceptSpace({ spaceKey, genesisFeedKey });
122
-
123
- // Send local space's details to host (inviter).
124
- // TODO(burdon): Space is orphaned if we crash before other side ACKs. Retry from cold start possible?
125
- log('sending admission request', { identityKey: invitation.identityKey });
126
- await peer.rpc.SpaceHostService.presentAdmissionCredentials({
127
- identityKey: this._signingContext.identityKey,
128
- deviceKey: this._signingContext.deviceKey,
129
- controlFeedKey: space.controlFeedKey,
130
- dataFeedKey: space.dataFeedKey
131
- });
132
-
133
- // TODO(burdon): Error: Writable stream closed prematurely
134
- admitted.wake(space);
135
- }
136
- }
137
- }
138
- });
139
-
140
- await peer.open();
141
- await admitted.wait();
142
- await peer.close();
143
- });
144
-
145
- const topic = PublicKey.from(invitation.swarmKey);
146
- const peerId = PublicKey.random(); // TODO(burdon): Use actual key.
147
- const connection = await this._networkManager.openSwarmConnection({
148
- topic,
149
- peerId: PublicKey.random(), // TODO(burdon): Why???
150
- // peerId,
151
- protocol: createProtocolFactory(topic, peerId, [plugin]),
152
- topology: new StarTopology(topic)
153
- });
154
-
155
- const space = await admitted.wait();
156
- await connection.close();
157
- return space;
158
- }
159
- }
@@ -1,107 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import assert from 'node:assert';
6
-
7
- import { EventSubscriptions } from '@dxos/async';
8
- import { Stream } from '@dxos/codec-protobuf';
9
- import { ObjectModel } from '@dxos/object-model';
10
- import {
11
- AddKeyRecordRequest,
12
- Contacts,
13
- HaloService as HaloServiceRpc,
14
- SignRequest,
15
- SignResponse,
16
- SetPreferenceRequest,
17
- GetPreferenceRequest,
18
- GetPreferenceResponse
19
- } from '@dxos/protocols/proto/dxos/client';
20
-
21
- import { HaloSigner } from '../signer';
22
-
23
- /**
24
- * HALO service implementation.
25
- */
26
- export class HaloService implements HaloServiceRpc {
27
- constructor(
28
- private readonly echo: any, // TODO(burdon): Remove.
29
- private readonly signer?: HaloSigner
30
- ) {}
31
-
32
- // TODO(burdon): Rename signMessage? (in interface).
33
- // TODO(burdon): Why is this part of the interface? (Can it be factored out completely?)
34
- async sign(request: SignRequest): Promise<SignResponse> {
35
- assert(this.signer, 'Signer not set.');
36
- assert(request.publicKey, 'Provide a public_key of the key that should be used for signing.');
37
- const key = await this.echo.halo.keyring.getFullKey(request.publicKey);
38
- assert(key, `Key not found: ${request.publicKey.toHex()}`);
39
- return this.signer.sign(request, key);
40
- }
41
-
42
- async addKeyRecord(request: AddKeyRecordRequest): Promise<void> {
43
- assert(request.keyRecord && request.keyRecord.publicKey, 'Missing key record.');
44
- await this.echo.halo.keyring.addKeyRecord(request.keyRecord);
45
- assert(await this.echo.halo.keyring.getKey(request.keyRecord.publicKey), 'Key not inserted correctly.');
46
- }
47
-
48
- // TODO(burdon): subscribeToContacts or just query/contacts with subscription object.
49
- // ResultSet vs Stream?
50
- subscribeContacts(): Stream<Contacts> {
51
- return new Stream(({ next }) => {
52
- next({ contacts: [] });
53
- });
54
- if (this.echo.halo.identity) {
55
- // return resultSetToStream(this.echo.halo.queryContacts(), (contacts): Contacts => ({ contacts }));
56
- }
57
-
58
- // TODO(burdon): Explain non-initialized path.
59
- return new Stream(({ next }) => {
60
- // If profile does not exist, send an empty array.
61
- if (!this.echo.halo.identity) {
62
- next({ contacts: [] });
63
- }
64
-
65
- const subscriptions = new EventSubscriptions();
66
- setTimeout(async () => {
67
- await this.echo.halo.identityReady.waitForCondition(() => !!this.echo.halo.identity);
68
-
69
- const resultSet = this.echo.halo.queryContacts();
70
- next({ contacts: resultSet.value });
71
- subscriptions.add(resultSet.update.on(() => next({ contacts: resultSet.value })));
72
- });
73
-
74
- return () => subscriptions.clear();
75
- });
76
- }
77
-
78
- async setGlobalPreference(request: SetPreferenceRequest): Promise<void> {
79
- assert(request.key, 'Missing key of property.');
80
- const preferences: ObjectModel | undefined = this.echo.halo.identity?.preferences?.getGlobalPreferences()?.model;
81
- assert(preferences, 'Preferences failed to load.');
82
- await preferences.setProperty(request.key, request.value);
83
- }
84
-
85
- async getGlobalPreference(request: GetPreferenceRequest): Promise<GetPreferenceResponse> {
86
- assert(request.key, 'Missing key of property.');
87
- const preferences: ObjectModel | undefined = this.echo.halo.identity?.preferences?.getGlobalPreferences()?.model;
88
- return {
89
- value: preferences?.getProperty(request.key)
90
- };
91
- }
92
-
93
- async setDevicePreference(request: SetPreferenceRequest): Promise<void> {
94
- assert(request.key, 'Missing key of property.');
95
- const preferences: ObjectModel | undefined = this.echo.halo.identity?.preferences?.getDevicePreferences()?.model;
96
- assert(preferences, 'Preferences failed to load.');
97
- await preferences.setProperty(request.key, request.value);
98
- }
99
-
100
- async getDevicePreference(request: GetPreferenceRequest): Promise<GetPreferenceResponse> {
101
- assert(request.key, 'Missing key of property.');
102
- const preferences: ObjectModel | undefined = this.echo.halo.identity?.preferences?.getDevicePreferences()?.model;
103
- return {
104
- value: preferences?.getProperty(request.key)
105
- };
106
- }
107
- }