@dxos/client-services 0.1.28 → 0.1.29-next.1bc50d4

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 (150) hide show
  1. package/dist/lib/browser/{chunk-OTSGRZZI.mjs → chunk-ILMYW75X.mjs} +740 -1043
  2. package/dist/lib/browser/chunk-ILMYW75X.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +7 -41
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +163 -50
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +4 -4
  7. package/dist/lib/node/index.cjs +645 -969
  8. package/dist/lib/node/index.cjs.map +4 -4
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +2686 -2637
  11. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  12. package/dist/types/src/packlets/devices/devices-service.test.d.ts +2 -0
  13. package/dist/types/src/packlets/devices/devices-service.test.d.ts.map +1 -0
  14. package/dist/types/src/packlets/identity/identity-service.test.d.ts +2 -0
  15. package/dist/types/src/packlets/identity/identity-service.test.d.ts.map +1 -0
  16. package/dist/types/src/packlets/invitations/device-invitations-handler.d.ts +1 -2
  17. package/dist/types/src/packlets/invitations/device-invitations-handler.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/device-invitations-service.d.ts +1 -1
  19. package/dist/types/src/packlets/invitations/device-invitations-service.d.ts.map +1 -1
  20. package/dist/types/src/packlets/invitations/index.d.ts +0 -6
  21. package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
  22. package/dist/types/src/packlets/invitations/invitations-service.d.ts +2 -3
  23. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  24. package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts +2 -4
  25. package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
  26. package/dist/types/src/packlets/invitations/space-invitations-service.d.ts +2 -3
  27. package/dist/types/src/packlets/invitations/space-invitations-service.d.ts.map +1 -1
  28. package/dist/types/src/packlets/network/network-service.test.d.ts +2 -0
  29. package/dist/types/src/packlets/network/network-service.test.d.ts.map +1 -0
  30. package/dist/types/src/packlets/services/index.d.ts +2 -2
  31. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  32. package/dist/types/src/packlets/services/local-client-services.d.ts +15 -0
  33. package/dist/types/src/packlets/services/local-client-services.d.ts.map +1 -0
  34. package/dist/types/src/packlets/services/service-context.d.ts +1 -1
  35. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  36. package/dist/types/src/packlets/services/service-host.d.ts +3 -5
  37. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  38. package/dist/types/src/packlets/services/utils.d.ts +7 -0
  39. package/dist/types/src/packlets/services/utils.d.ts.map +1 -0
  40. package/dist/types/src/packlets/spaces/index.d.ts +2 -0
  41. package/dist/types/src/packlets/spaces/index.d.ts.map +1 -1
  42. package/dist/types/src/packlets/spaces/spaces-service.test.d.ts +2 -0
  43. package/dist/types/src/packlets/spaces/spaces-service.test.d.ts.map +1 -0
  44. package/dist/types/src/packlets/testing/host-test-builder.d.ts +43 -0
  45. package/dist/types/src/packlets/testing/host-test-builder.d.ts.map +1 -0
  46. package/dist/types/src/packlets/testing/index.d.ts +1 -0
  47. package/dist/types/src/packlets/testing/index.d.ts.map +1 -1
  48. package/dist/types/src/packlets/testing/invitation-utils.d.ts +1 -1
  49. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  50. package/dist/types/src/packlets/testing/test-builder.d.ts +30 -34
  51. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  52. package/dist/types/src/packlets/tests/client-services.test.d.ts +2 -0
  53. package/dist/types/src/packlets/tests/client-services.test.d.ts.map +1 -0
  54. package/dist/types/src/packlets/tests/client.test.d.ts +2 -0
  55. package/dist/types/src/packlets/tests/client.test.d.ts.map +1 -0
  56. package/dist/types/src/packlets/tests/halo-credentials.test.d.ts +2 -0
  57. package/dist/types/src/packlets/tests/halo-credentials.test.d.ts.map +1 -0
  58. package/dist/types/src/packlets/tests/halo-persistent.test.d.ts +2 -0
  59. package/dist/types/src/packlets/tests/halo-persistent.test.d.ts.map +1 -0
  60. package/dist/types/src/packlets/tests/halo-profile.test.d.ts +2 -0
  61. package/dist/types/src/packlets/tests/halo-profile.test.d.ts.map +1 -0
  62. package/dist/types/src/packlets/tests/shared-worker.test.d.ts +2 -0
  63. package/dist/types/src/packlets/tests/shared-worker.test.d.ts.map +1 -0
  64. package/dist/types/src/packlets/tests/spaces-invitations.test.d.ts +2 -0
  65. package/dist/types/src/packlets/tests/spaces-invitations.test.d.ts.map +1 -0
  66. package/dist/types/src/packlets/tests/spaces.test.d.ts +2 -0
  67. package/dist/types/src/packlets/tests/spaces.test.d.ts.map +1 -0
  68. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +2 -2
  69. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  70. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
  71. package/dist/types/src/packlets/vault/index.d.ts +0 -2
  72. package/dist/types/src/packlets/vault/index.d.ts.map +1 -1
  73. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
  74. package/dist/types/src/packlets/vault/worker-session.d.ts +1 -1
  75. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  76. package/package.json +30 -30
  77. package/src/packlets/devices/devices-service.test.ts +56 -0
  78. package/src/packlets/identity/identity-service.test.ts +82 -0
  79. package/src/packlets/invitations/device-invitations-handler.ts +10 -9
  80. package/src/packlets/invitations/device-invitations-service.test.ts +1 -1
  81. package/src/packlets/invitations/device-invitations-service.ts +1 -1
  82. package/src/packlets/invitations/index.ts +0 -6
  83. package/src/packlets/invitations/invitations-service.ts +7 -2
  84. package/src/packlets/invitations/space-invitations-handler.test.ts +3 -3
  85. package/src/packlets/invitations/space-invitations-handler.ts +11 -11
  86. package/src/packlets/invitations/space-invitations-service.test.ts +1 -1
  87. package/src/packlets/invitations/space-invitations-service.ts +2 -3
  88. package/src/packlets/network/network-service.test.ts +52 -0
  89. package/src/packlets/services/index.ts +2 -2
  90. package/src/packlets/services/local-client-services.ts +35 -0
  91. package/src/packlets/services/service-context.test.ts +4 -4
  92. package/src/packlets/services/service-context.ts +1 -1
  93. package/src/packlets/services/service-host.ts +3 -11
  94. package/src/packlets/services/service-registry.test.ts +2 -2
  95. package/src/packlets/services/utils.ts +53 -0
  96. package/src/packlets/spaces/data-space-manager.test.ts +4 -4
  97. package/src/packlets/spaces/data-space-manager.ts +1 -1
  98. package/src/packlets/spaces/index.ts +2 -0
  99. package/src/packlets/spaces/spaces-service.test.ts +107 -0
  100. package/src/packlets/testing/host-test-builder.ts +163 -0
  101. package/src/packlets/testing/index.ts +1 -0
  102. package/src/packlets/testing/invitation-utils.ts +1 -2
  103. package/src/packlets/testing/test-builder.ts +118 -140
  104. package/src/packlets/tests/client-services.test.ts +252 -0
  105. package/src/packlets/tests/client.test.ts +143 -0
  106. package/src/packlets/tests/halo-credentials.test.ts +94 -0
  107. package/src/packlets/tests/halo-persistent.test.ts +53 -0
  108. package/src/packlets/tests/halo-profile.test.ts +74 -0
  109. package/src/packlets/tests/shared-worker.test.ts +96 -0
  110. package/src/packlets/tests/spaces-invitations.test.ts +24 -0
  111. package/src/packlets/tests/spaces.test.ts +68 -0
  112. package/src/packlets/vault/iframe-host-runtime.ts +6 -3
  113. package/src/packlets/vault/iframe-proxy-runtime.ts +1 -1
  114. package/src/packlets/vault/index.ts +0 -2
  115. package/src/packlets/vault/shell-runtime.ts +1 -2
  116. package/src/packlets/vault/worker-session.ts +7 -3
  117. package/dist/lib/browser/chunk-OTSGRZZI.mjs.map +0 -7
  118. package/dist/types/src/packlets/invitations/device-invitations-proxy.d.ts +0 -8
  119. package/dist/types/src/packlets/invitations/device-invitations-proxy.d.ts.map +0 -1
  120. package/dist/types/src/packlets/invitations/encoder.d.ts +0 -9
  121. package/dist/types/src/packlets/invitations/encoder.d.ts.map +0 -1
  122. package/dist/types/src/packlets/invitations/encoder.test.d.ts +0 -2
  123. package/dist/types/src/packlets/invitations/encoder.test.d.ts.map +0 -1
  124. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +0 -56
  125. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +0 -1
  126. package/dist/types/src/packlets/invitations/invitations-proxy.d.ts +0 -18
  127. package/dist/types/src/packlets/invitations/invitations-proxy.d.ts.map +0 -1
  128. package/dist/types/src/packlets/invitations/invitations.d.ts +0 -55
  129. package/dist/types/src/packlets/invitations/invitations.d.ts.map +0 -1
  130. package/dist/types/src/packlets/invitations/space-invitations-proxy.d.ts +0 -11
  131. package/dist/types/src/packlets/invitations/space-invitations-proxy.d.ts.map +0 -1
  132. package/dist/types/src/packlets/services/service-definitions.d.ts +0 -30
  133. package/dist/types/src/packlets/services/service-definitions.d.ts.map +0 -1
  134. package/dist/types/src/packlets/services/service-proxy.d.ts +0 -17
  135. package/dist/types/src/packlets/services/service-proxy.d.ts.map +0 -1
  136. package/dist/types/src/packlets/vault/services.d.ts +0 -21
  137. package/dist/types/src/packlets/vault/services.d.ts.map +0 -1
  138. package/dist/types/src/packlets/vault/shell-controller.d.ts +0 -18
  139. package/dist/types/src/packlets/vault/shell-controller.d.ts.map +0 -1
  140. package/src/packlets/invitations/device-invitations-proxy.ts +0 -14
  141. package/src/packlets/invitations/encoder.test.ts +0 -23
  142. package/src/packlets/invitations/encoder.ts +0 -26
  143. package/src/packlets/invitations/invitations-handler.ts +0 -68
  144. package/src/packlets/invitations/invitations-proxy.ts +0 -159
  145. package/src/packlets/invitations/invitations.ts +0 -113
  146. package/src/packlets/invitations/space-invitations-proxy.ts +0 -16
  147. package/src/packlets/services/service-definitions.ts +0 -68
  148. package/src/packlets/services/service-proxy.ts +0 -54
  149. package/src/packlets/vault/services.ts +0 -42
  150. package/src/packlets/vault/shell-controller.ts +0 -56
@@ -1 +1 @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B,QAAQ,IAAI,CAAC,EAAI;IAGvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,aAAa,CAAC,EAAE,aAAa,CAAC;gBAEzB,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,SAAS,EACT,OAEC,EACF,EAAE,mBAAmB;IAkDhB,IAAI;IAuBJ,KAAK;YAeG,eAAe;CAO9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/client-services",
3
- "version": "0.1.28",
3
+ "version": "0.1.29-next.1bc50d4",
4
4
  "description": "DXOS client services implementation",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -20,38 +20,38 @@
20
20
  "src"
21
21
  ],
22
22
  "dependencies": {
23
- "base-x": "~3.0.9",
24
- "@dxos/async": "0.1.28",
25
- "@dxos/codec-protobuf": "0.1.28",
26
- "@dxos/config": "0.1.28",
27
- "@dxos/context": "0.1.28",
28
- "@dxos/credentials": "0.1.28",
29
- "@dxos/crypto": "0.1.28",
30
- "@dxos/debug": "0.1.28",
31
- "@dxos/document-model": "0.1.28",
32
- "@dxos/echo-db": "0.1.28",
33
- "@dxos/echo-pipeline": "0.1.28",
34
- "@dxos/errors": "0.1.28",
35
- "@dxos/feed-store": "0.1.28",
36
- "@dxos/keyring": "0.1.28",
37
- "@dxos/keys": "0.1.28",
38
- "@dxos/log": "0.1.28",
39
- "@dxos/messaging": "0.1.28",
40
- "@dxos/model-factory": "0.1.28",
41
- "@dxos/network-manager": "0.1.28",
42
- "@dxos/node-std": "0.1.28",
43
- "@dxos/protocols": "0.1.28",
44
- "@dxos/random-access-storage": "0.1.28",
45
- "@dxos/rpc": "0.1.28",
46
- "@dxos/teleport": "0.1.28",
47
- "@dxos/teleport-extension-presence": "0.1.28",
48
- "@dxos/text-model": "0.1.28",
49
- "@dxos/timeframe": "0.1.28",
50
- "@dxos/util": "0.1.28"
23
+ "@dxos/async": "0.1.29-next.1bc50d4",
24
+ "@dxos/client": "0.1.29-next.1bc50d4",
25
+ "@dxos/codec-protobuf": "0.1.29-next.1bc50d4",
26
+ "@dxos/config": "0.1.29-next.1bc50d4",
27
+ "@dxos/context": "0.1.29-next.1bc50d4",
28
+ "@dxos/credentials": "0.1.29-next.1bc50d4",
29
+ "@dxos/crypto": "0.1.29-next.1bc50d4",
30
+ "@dxos/debug": "0.1.29-next.1bc50d4",
31
+ "@dxos/document-model": "0.1.29-next.1bc50d4",
32
+ "@dxos/echo-db": "0.1.29-next.1bc50d4",
33
+ "@dxos/echo-pipeline": "0.1.29-next.1bc50d4",
34
+ "@dxos/errors": "0.1.29-next.1bc50d4",
35
+ "@dxos/feed-store": "0.1.29-next.1bc50d4",
36
+ "@dxos/keyring": "0.1.29-next.1bc50d4",
37
+ "@dxos/keys": "0.1.29-next.1bc50d4",
38
+ "@dxos/log": "0.1.29-next.1bc50d4",
39
+ "@dxos/messaging": "0.1.29-next.1bc50d4",
40
+ "@dxos/model-factory": "0.1.29-next.1bc50d4",
41
+ "@dxos/network-manager": "0.1.29-next.1bc50d4",
42
+ "@dxos/node-std": "0.1.29-next.1bc50d4",
43
+ "@dxos/protocols": "0.1.29-next.1bc50d4",
44
+ "@dxos/random-access-storage": "0.1.29-next.1bc50d4",
45
+ "@dxos/rpc": "0.1.29-next.1bc50d4",
46
+ "@dxos/teleport": "0.1.29-next.1bc50d4",
47
+ "@dxos/teleport-extension-presence": "0.1.29-next.1bc50d4",
48
+ "@dxos/text-model": "0.1.29-next.1bc50d4",
49
+ "@dxos/timeframe": "0.1.29-next.1bc50d4",
50
+ "@dxos/util": "0.1.29-next.1bc50d4"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/readable-stream": "^2.3.9",
54
- "@dxos/signal": "0.1.28"
54
+ "@dxos/signal": "0.1.29-next.1bc50d4"
55
55
  },
56
56
  "publishConfig": {
57
57
  "access": "public"
@@ -0,0 +1,56 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { expect } from 'chai';
6
+
7
+ import { Trigger } from '@dxos/async';
8
+ import { DevicesService, Device } from '@dxos/protocols/proto/dxos/client/services';
9
+ import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
10
+
11
+ import { ServiceContext } from '../services';
12
+ import { createServiceContext } from '../testing';
13
+ import { DevicesServiceImpl } from './devices-service';
14
+
15
+ describe('DevicesService', () => {
16
+ let serviceContext: ServiceContext;
17
+ let devicesService: DevicesService;
18
+
19
+ beforeEach(async () => {
20
+ serviceContext = createServiceContext();
21
+ await serviceContext.open();
22
+ devicesService = new DevicesServiceImpl(serviceContext.identityManager);
23
+ });
24
+
25
+ afterEach(async () => {
26
+ await serviceContext.close();
27
+ });
28
+
29
+ describe.skip('updateDevice', () => {});
30
+
31
+ describe('queryDevices', () => {
32
+ test('returns empty list if no identity is available', async () => {
33
+ const query = devicesService.queryDevices();
34
+ const result = new Trigger<Device[] | undefined>();
35
+ query.subscribe(({ devices }) => {
36
+ result.wake(devices);
37
+ });
38
+ afterTest(() => query.close());
39
+ expect(await result.wait()).to.be.length(0);
40
+ });
41
+
42
+ test('updates when identity is created', async () => {
43
+ const query = devicesService.queryDevices();
44
+ let result = new Trigger<Device[] | undefined>();
45
+ query.subscribe(({ devices }) => {
46
+ result.wake(devices);
47
+ });
48
+ afterTest(() => query.close());
49
+ expect(await result.wait()).to.be.length(0);
50
+
51
+ result = new Trigger<Device[] | undefined>();
52
+ await serviceContext.createIdentity();
53
+ expect(await result.wait()).to.be.length(1);
54
+ });
55
+ });
56
+ });
@@ -0,0 +1,82 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import chai, { expect } from 'chai';
6
+ import chaiAsPromised from 'chai-as-promised';
7
+
8
+ import { Trigger } from '@dxos/async';
9
+ import { PublicKey } from '@dxos/keys';
10
+ import { Identity, IdentityService } from '@dxos/protocols/proto/dxos/client/services';
11
+ import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
12
+
13
+ import { ServiceContext } from '../services';
14
+ import { createServiceContext } from '../testing';
15
+ import { IdentityServiceImpl } from './identity-service';
16
+
17
+ chai.use(chaiAsPromised);
18
+
19
+ describe('IdentityService', () => {
20
+ let serviceContext: ServiceContext;
21
+ let identityService: IdentityService;
22
+
23
+ beforeEach(async () => {
24
+ serviceContext = createServiceContext();
25
+ await serviceContext.open();
26
+ identityService = new IdentityServiceImpl(serviceContext);
27
+ });
28
+
29
+ afterEach(async () => {
30
+ await serviceContext.close();
31
+ });
32
+
33
+ describe('createIdentity', () => {
34
+ test('creates a new identity', async () => {
35
+ const identity = await identityService.createIdentity({});
36
+
37
+ expect(identity.identityKey).to.be.instanceof(PublicKey);
38
+ expect(identity.spaceKey).to.be.instanceof(PublicKey);
39
+ });
40
+
41
+ test('creates a new identity with a display name', async () => {
42
+ const identity = await identityService.createIdentity({ displayName: 'Example' });
43
+
44
+ expect(identity.identityKey).to.be.instanceof(PublicKey);
45
+ expect(identity.spaceKey).to.be.instanceof(PublicKey);
46
+ expect(identity.profile?.displayName).to.equal('Example');
47
+ });
48
+
49
+ test('fails to create identity if one already exists', async () => {
50
+ await identityService.createIdentity({});
51
+ await expect(identityService.createIdentity({})).to.be.rejectedWith('Identity already exists');
52
+ });
53
+ });
54
+
55
+ describe.skip('recoverIdentity', () => {});
56
+
57
+ describe('queryIdentity', () => {
58
+ test('returns undefined if no identity is available', async () => {
59
+ const query = identityService.queryIdentity();
60
+ const result = new Trigger<Identity | undefined>();
61
+ query.subscribe(({ identity }) => {
62
+ result.wake(identity);
63
+ });
64
+ afterTest(() => query.close());
65
+ expect(await result.wait()).to.be.undefined;
66
+ });
67
+
68
+ test('updates when identity is created', async () => {
69
+ const query = identityService.queryIdentity();
70
+ let result = new Trigger<Identity | undefined>();
71
+ query.subscribe(({ identity }) => {
72
+ result.wake(identity);
73
+ });
74
+ afterTest(() => query.close());
75
+ expect(await result.wait()).to.be.undefined;
76
+
77
+ result = new Trigger<Identity | undefined>();
78
+ const identity = await identityService.createIdentity({});
79
+ expect(await result.wait()).to.deep.equal(identity);
80
+ });
81
+ });
82
+ });
@@ -5,6 +5,16 @@
5
5
  import assert from 'node:assert';
6
6
 
7
7
  import { scheduleTask, sleep, Trigger } from '@dxos/async';
8
+ import {
9
+ AbstractInvitationsHandler,
10
+ AuthenticatingInvitationProvider,
11
+ AUTHENTICATION_CODE_LENGTH,
12
+ CancellableInvitationObservable,
13
+ InvitationObservableProvider,
14
+ InvitationsOptions,
15
+ INVITATION_TIMEOUT,
16
+ ON_CLOSE_DELAY
17
+ } from '@dxos/client';
8
18
  import { Context } from '@dxos/context';
9
19
  import { generatePasscode } from '@dxos/credentials';
10
20
  import { Keyring } from '@dxos/keyring';
@@ -23,15 +33,6 @@ import {
23
33
  import { ExtensionContext, RpcExtension } from '@dxos/teleport';
24
34
 
25
35
  import { Identity, JoinIdentityParams } from '../identity';
26
- import {
27
- AuthenticatingInvitationProvider,
28
- AUTHENTICATION_CODE_LENGTH,
29
- CancellableInvitationObservable,
30
- InvitationObservableProvider,
31
- INVITATION_TIMEOUT,
32
- ON_CLOSE_DELAY
33
- } from './invitations';
34
- import { AbstractInvitationsHandler, InvitationsOptions } from './invitations-handler';
35
36
 
36
37
  type DeviceInvitationsHandlerParams = {
37
38
  networkManager: NetworkManager;
@@ -7,13 +7,13 @@ import assert from 'node:assert';
7
7
  import waitForExpect from 'wait-for-expect';
8
8
 
9
9
  import { asyncChain, Trigger } from '@dxos/async';
10
+ import { DeviceInvitationsProxy } from '@dxos/client';
10
11
  import { raise } from '@dxos/debug';
11
12
  import { Invitation, DeviceInvitationsService } from '@dxos/protocols/proto/dxos/client/services';
12
13
  import { describe, test, afterTest } from '@dxos/test';
13
14
 
14
15
  import { ServiceContext } from '../services';
15
16
  import { createPeers } from '../testing';
16
- import { DeviceInvitationsProxy } from './device-invitations-proxy';
17
17
  import { DeviceInvitationsServiceImpl } from './device-invitations-service';
18
18
 
19
19
  const closeAfterTest = async (peer: ServiceContext) => {
@@ -2,10 +2,10 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
+ import { InvitationsHandler } from '@dxos/client';
5
6
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
6
7
 
7
8
  import { IdentityManager } from '../identity';
8
- import { InvitationsHandler } from './invitations-handler';
9
9
  import { AbstractInvitationsService } from './invitations-service';
10
10
 
11
11
  /**
@@ -2,14 +2,8 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- export * from './encoder';
6
5
  export * from './device-invitations-handler';
7
- export * from './device-invitations-proxy';
8
6
  export * from './device-invitations-service';
9
- export * from './invitations';
10
- export * from './invitations-handler';
11
- export * from './invitations-proxy';
12
7
  export * from './invitations-service';
13
8
  export * from './space-invitations-handler';
14
- export * from './space-invitations-proxy';
15
9
  export * from './space-invitations-service';
@@ -5,14 +5,19 @@
5
5
  import assert from 'node:assert';
6
6
 
7
7
  import { TimeoutError } from '@dxos/async';
8
+ import {
9
+ AuthenticatingInvitationObservable,
10
+ CancellableInvitationObservable,
11
+ InvitationsService,
12
+ InvitationsHandler,
13
+ InvitationsOptions
14
+ } from '@dxos/client';
8
15
  import { Stream } from '@dxos/codec-protobuf';
9
16
  import { log } from '@dxos/log';
10
17
  import { AuthenticationRequest, Invitation } from '@dxos/protocols/proto/dxos/client/services';
11
18
  import { Provider } from '@dxos/util';
12
19
 
13
20
  import { IdentityManager } from '../identity';
14
- import { AuthenticatingInvitationObservable, CancellableInvitationObservable, InvitationsService } from './invitations';
15
- import { InvitationsHandler, InvitationsOptions } from './invitations-handler';
16
21
 
17
22
  /**
18
23
  * Adapts invitation service observable to client/service stream.
@@ -14,7 +14,7 @@ import { afterTest, describe, test } from '@dxos/test';
14
14
  import { range } from '@dxos/util';
15
15
 
16
16
  import { ServiceContext } from '../services';
17
- import { createIdentity, createPeers, syncItems } from '../testing';
17
+ import { createIdentity, createPeers, syncItemsLocal } from '../testing';
18
18
  import { performInvitation } from '../testing/invitation-utils';
19
19
 
20
20
  const closeAfterTest = async (peer: ServiceContext) => {
@@ -53,7 +53,7 @@ describe('services/space-invitations-handler', () => {
53
53
  expect(space1).not.to.be.undefined;
54
54
  expect(space2).not.to.be.undefined;
55
55
 
56
- await syncItems(space1.dataPipelineController, space2.dataPipelineController);
56
+ await syncItemsLocal(space1.dataPipelineController, space2.dataPipelineController);
57
57
 
58
58
  await space1.close();
59
59
  await space2.close();
@@ -116,7 +116,7 @@ describe('services/space-invitations-handler', () => {
116
116
  expect(space1).not.to.be.undefined;
117
117
  expect(space2).not.to.be.undefined;
118
118
 
119
- await syncItems(space1.dataPipelineController, space2.dataPipelineController);
119
+ await syncItemsLocal(space1.dataPipelineController, space2.dataPipelineController);
120
120
 
121
121
  await space1.close();
122
122
  await space2.close();
@@ -5,6 +5,16 @@
5
5
  import assert from 'node:assert';
6
6
 
7
7
  import { scheduleTask, sleep, Trigger } from '@dxos/async';
8
+ import {
9
+ AuthenticatingInvitationProvider,
10
+ AUTHENTICATION_CODE_LENGTH,
11
+ CancellableInvitationObservable,
12
+ InvitationObservableProvider,
13
+ INVITATION_TIMEOUT,
14
+ ON_CLOSE_DELAY,
15
+ AbstractInvitationsHandler,
16
+ InvitationsOptions
17
+ } from '@dxos/client';
8
18
  import { Context } from '@dxos/context';
9
19
  import { createAdmissionCredentials, generatePasscode, getCredentialAssertion } from '@dxos/credentials';
10
20
  import { SigningContext } from '@dxos/echo-pipeline';
@@ -29,17 +39,7 @@ import {
29
39
  } from '@dxos/protocols/proto/dxos/halo/invitations';
30
40
  import { ExtensionContext, RpcExtension } from '@dxos/teleport';
31
41
 
32
- import { DataSpace } from '../spaces/data-space';
33
- import { DataSpaceManager } from '../spaces/data-space-manager';
34
- import {
35
- AuthenticatingInvitationProvider,
36
- AUTHENTICATION_CODE_LENGTH,
37
- CancellableInvitationObservable,
38
- InvitationObservableProvider,
39
- INVITATION_TIMEOUT,
40
- ON_CLOSE_DELAY
41
- } from './invitations';
42
- import { AbstractInvitationsHandler, InvitationsOptions } from './invitations-handler';
42
+ import { DataSpace, DataSpaceManager } from '../spaces';
43
43
 
44
44
  const MAX_OTP_ATTEMPTS = 3;
45
45
 
@@ -6,13 +6,13 @@ import { expect } from 'chai';
6
6
  import assert from 'node:assert';
7
7
 
8
8
  import { asyncChain, Trigger } from '@dxos/async';
9
+ import { SpaceInvitationsProxy } from '@dxos/client';
9
10
  import { raise } from '@dxos/debug';
10
11
  import { Invitation, SpaceInvitationsService } from '@dxos/protocols/proto/dxos/client/services';
11
12
  import { describe, test, afterTest } from '@dxos/test';
12
13
 
13
14
  import { ServiceContext } from '../services';
14
15
  import { createIdentity, createPeers } from '../testing';
15
- import { SpaceInvitationsProxy } from './space-invitations-proxy';
16
16
  import { SpaceInvitationsServiceImpl } from './space-invitations-service';
17
17
 
18
18
  const closeAfterTest = async (peer: ServiceContext) => {
@@ -4,13 +4,12 @@
4
4
 
5
5
  import assert from 'node:assert';
6
6
 
7
+ import { InvitationsHandler } from '@dxos/client';
7
8
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
8
9
  import { Provider } from '@dxos/util';
9
10
 
10
11
  import { IdentityManager } from '../identity';
11
- import { DataSpace } from '../spaces/data-space';
12
- import { DataSpaceManager } from '../spaces/data-space-manager';
13
- import { InvitationsHandler } from './invitations-handler';
12
+ import { DataSpace, DataSpaceManager } from '../spaces';
14
13
  import { AbstractInvitationsService } from './invitations-service';
15
14
 
16
15
  /**
@@ -0,0 +1,52 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { expect } from 'chai';
6
+
7
+ import { Trigger } from '@dxos/async';
8
+ import { NetworkService, ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
9
+ import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
10
+
11
+ import { ServiceContext } from '../services';
12
+ import { createServiceContext } from '../testing';
13
+ import { NetworkServiceImpl } from './network-service';
14
+
15
+ describe('NetworkService', () => {
16
+ let serviceContext: ServiceContext;
17
+ let networkService: NetworkService;
18
+
19
+ beforeEach(async () => {
20
+ serviceContext = createServiceContext();
21
+ await serviceContext.open();
22
+ networkService = new NetworkServiceImpl(serviceContext.networkManager);
23
+ });
24
+
25
+ afterEach(async () => {
26
+ await serviceContext.close();
27
+ });
28
+
29
+ test('setNetworkOptions changes network status', async () => {
30
+ await networkService.setNetworkOptions({
31
+ state: ConnectionState.OFFLINE
32
+ });
33
+
34
+ expect(serviceContext.networkManager.connectionState).to.equal(ConnectionState.OFFLINE);
35
+ });
36
+
37
+ test('subscribeToNetworkStatus returns current network status', async () => {
38
+ const query = networkService.subscribeToNetworkStatus();
39
+ let result = new Trigger<ConnectionState | undefined>();
40
+ query.subscribe(({ state }) => {
41
+ result.wake(state);
42
+ });
43
+ afterTest(() => query.close());
44
+ expect(await result.wait()).to.equal(ConnectionState.ONLINE);
45
+
46
+ result = new Trigger<ConnectionState | undefined>();
47
+ await networkService.setNetworkOptions({
48
+ state: ConnectionState.OFFLINE
49
+ });
50
+ expect(await result.wait()).to.equal(ConnectionState.OFFLINE);
51
+ });
52
+ });
@@ -2,8 +2,8 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
+ export * from './local-client-services';
5
6
  export * from './service-context';
6
- export * from './service-definitions';
7
7
  export * from './service-host';
8
- export * from './service-proxy';
9
8
  export * from './service-registry';
9
+ export * from './utils';
@@ -0,0 +1,35 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { ClientServices, ClientServicesProvider } from '@dxos/client';
6
+ import { ServiceBundle } from '@dxos/rpc';
7
+
8
+ import { ClientServicesHost, ClientServicesHostParams } from './service-host';
9
+
10
+ /**
11
+ * Starts a local instance of the service host.
12
+ */
13
+ export class LocalClientServices implements ClientServicesProvider {
14
+ private readonly _host: ClientServicesHost;
15
+
16
+ constructor(params: ClientServicesHostParams) {
17
+ this._host = new ClientServicesHost(params);
18
+ }
19
+
20
+ get descriptors(): ServiceBundle<ClientServices> {
21
+ return this._host.descriptors;
22
+ }
23
+
24
+ get services(): Partial<ClientServices> {
25
+ return this._host.services;
26
+ }
27
+
28
+ async open(): Promise<void> {
29
+ await this._host.open();
30
+ }
31
+
32
+ async close(): Promise<void> {
33
+ await this._host.close();
34
+ }
35
+ }
@@ -5,7 +5,7 @@
5
5
  import { MemorySignalManagerContext } from '@dxos/messaging';
6
6
  import { describe, test } from '@dxos/test';
7
7
 
8
- import { createServiceContext, syncItems } from '../testing';
8
+ import { createServiceContext, syncItemsLocal } from '../testing';
9
9
  import { performInvitation } from '../testing/invitation-utils';
10
10
 
11
11
  describe('services/ServiceContext', () => {
@@ -19,7 +19,7 @@ describe('services/ServiceContext', () => {
19
19
  await performInvitation(device1.deviceInvitations, device2.deviceInvitations, undefined);
20
20
 
21
21
  const space2 = await device2.dataSpaceManager!.spaces.get(space1.key);
22
- await syncItems(space1.dataPipelineController, space2!.dataPipelineController);
22
+ await syncItemsLocal(space1.dataPipelineController, space2!.dataPipelineController);
23
23
  });
24
24
 
25
25
  test('new space is synchronized on device invitations', async () => {
@@ -33,7 +33,7 @@ describe('services/ServiceContext', () => {
33
33
  const space1 = await device1.dataSpaceManager!.createSpace();
34
34
  await device2.dataSpaceManager?.updated.waitForCondition(() => !!device2.dataSpaceManager!.spaces.get(space1.key));
35
35
  const space2 = await device2.dataSpaceManager!.spaces.get(space1.key);
36
- await syncItems(space1.dataPipelineController, space2!.dataPipelineController);
36
+ await syncItemsLocal(space1.dataPipelineController, space2!.dataPipelineController);
37
37
  });
38
38
 
39
39
  test('joined space is synchronized on device invitations', async () => {
@@ -51,6 +51,6 @@ describe('services/ServiceContext', () => {
51
51
 
52
52
  await device2.dataSpaceManager?.updated.waitForCondition(() => !!device2.dataSpaceManager!.spaces.get(space1.key));
53
53
  const space2 = await device2.dataSpaceManager!.spaces.get(space1.key);
54
- await syncItems(space1.dataPipelineController, space2!.dataPipelineController);
54
+ await syncItemsLocal(space1.dataPipelineController, space2!.dataPipelineController);
55
55
  });
56
56
  });
@@ -24,7 +24,7 @@ import { Storage } from '@dxos/random-access-storage';
24
24
 
25
25
  import { CreateIdentityOptions, IdentityManager, JoinIdentityParams } from '../identity';
26
26
  import { DeviceInvitationsHandler, SpaceInvitationsHandler } from '../invitations';
27
- import { DataSpaceManager } from '../spaces/data-space-manager';
27
+ import { DataSpaceManager } from '../spaces';
28
28
 
29
29
  /**
30
30
  * Shared backend for all client services.
@@ -5,16 +5,15 @@
5
5
  import assert from 'node:assert';
6
6
 
7
7
  import { Event } from '@dxos/async';
8
+ import { clientServiceBundle, ClientServices, createDefaultModelFactory } from '@dxos/client';
8
9
  import { Config } from '@dxos/config';
9
10
  import { raise } from '@dxos/debug';
10
- import { DocumentModel } from '@dxos/document-model';
11
11
  import { DataServiceImpl } from '@dxos/echo-pipeline';
12
12
  import { log } from '@dxos/log';
13
13
  import { ModelFactory } from '@dxos/model-factory';
14
14
  import { NetworkManager } from '@dxos/network-manager';
15
15
  import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
16
16
  import { Storage } from '@dxos/random-access-storage';
17
- import { TextModel } from '@dxos/text-model';
18
17
 
19
18
  import { TracingServiceImpl } from '../deprecated';
20
19
  import { DevicesServiceImpl } from '../devices';
@@ -27,16 +26,9 @@ import { createStorageObjects } from '../storage';
27
26
  import { SystemServiceImpl } from '../system';
28
27
  import { VaultResourceLock } from '../vault';
29
28
  import { ServiceContext } from './service-context';
30
- import { ClientServicesProvider, ClientServices, clientServiceBundle } from './service-definitions';
31
29
  import { ServiceRegistry } from './service-registry';
32
30
 
33
- // TODO(burdon): Factor out to spaces.
34
- // TODO(burdon): Defaults (with TextModel).
35
- export const createDefaultModelFactory = () => {
36
- return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
37
- };
38
-
39
- type ClientServicesHostParams = {
31
+ export type ClientServicesHostParams = {
40
32
  config: Config;
41
33
  modelFactory?: ModelFactory;
42
34
  networkManager: NetworkManager;
@@ -47,7 +39,7 @@ type ClientServicesHostParams = {
47
39
  /**
48
40
  * Remote service implementation.
49
41
  */
50
- export class ClientServicesHost implements ClientServicesProvider {
42
+ export class ClientServicesHost {
51
43
  private readonly _resourceLock?: VaultResourceLock;
52
44
  private readonly _serviceRegistry: ServiceRegistry<ClientServices>;
53
45
  private readonly _systemService: SystemServiceImpl;
@@ -5,15 +5,15 @@
5
5
  import assert from 'node:assert';
6
6
 
7
7
  import { Trigger } from '@dxos/async';
8
+ import { ClientServices, SpaceInvitationsProxy } from '@dxos/client';
8
9
  import { log } from '@dxos/log';
9
10
  import { schema } from '@dxos/protocols';
10
11
  import { Invitation, SpaceInvitationsService } from '@dxos/protocols/proto/dxos/client/services';
11
12
  import { createLinkedPorts, createProtoRpcPeer, createServiceBundle } from '@dxos/rpc';
12
13
  import { describe, test } from '@dxos/test';
13
14
 
14
- import { SpaceInvitationsProxy, SpaceInvitationsServiceImpl } from '../invitations';
15
+ import { SpaceInvitationsServiceImpl } from '../invitations';
15
16
  import { createServiceContext } from '../testing';
16
- import { ClientServices } from './service-definitions';
17
17
  import { ServiceRegistry } from './service-registry';
18
18
 
19
19
  // TODO(burdon): Create TestService (that doesn't require peers).