@dxos/client-services 0.1.41 → 0.1.45-next.45667d4
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.
- package/dist/lib/browser/{chunk-T73F4MV4.mjs → chunk-IHSMRQ3L.mjs} +985 -867
- package/dist/lib/browser/chunk-IHSMRQ3L.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +7 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +121 -297
- package/dist/lib/browser/packlets/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +589 -469
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +688 -740
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +4 -2
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +5 -4
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts +2 -3
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +1 -3
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +1 -2
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +6 -4
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +2 -2
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +0 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/local-client-services.d.ts +1 -1
- package/dist/types/src/packlets/services/local-client-services.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +4 -2
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +16 -9
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +12 -7
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +15 -10
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +5 -0
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +4 -4
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/credential-utils.d.ts +1 -1
- package/dist/types/src/packlets/testing/index.d.ts +0 -1
- package/dist/types/src/packlets/testing/index.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +13 -7
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +35 -32
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +5 -2
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts +1 -1
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +4 -7
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +30 -31
- package/src/index.ts +1 -0
- package/src/packlets/devices/devices-service.ts +5 -5
- package/src/packlets/devtools/devtools.ts +25 -4
- package/src/packlets/devtools/feeds.ts +10 -10
- package/src/packlets/devtools/keys.ts +6 -6
- package/src/packlets/devtools/network.ts +14 -13
- package/src/packlets/devtools/spaces.ts +4 -4
- package/src/packlets/identity/authenticator.test.ts +1 -1
- package/src/packlets/identity/authenticator.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +17 -13
- package/src/packlets/identity/identity-manager.ts +21 -22
- package/src/packlets/identity/identity-service.ts +3 -3
- package/src/packlets/identity/identity.test.ts +65 -36
- package/src/packlets/identity/identity.ts +17 -17
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +7 -7
- package/src/packlets/invitations/invitation-extension.ts +16 -27
- package/src/packlets/invitations/invitations-handler.ts +17 -25
- package/src/packlets/invitations/invitations-service.ts +11 -11
- package/src/packlets/invitations/space-invitation-protocol.test.ts +9 -9
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -12
- package/src/packlets/logging/logging-service.ts +8 -3
- package/src/packlets/network/network-service.test.ts +8 -8
- package/src/packlets/network/network-service.ts +20 -8
- package/src/packlets/services/client-rpc-server.ts +5 -5
- package/src/packlets/services/index.ts +0 -1
- package/src/packlets/services/local-client-services.ts +1 -1
- package/src/packlets/services/service-context.test.ts +3 -3
- package/src/packlets/services/service-context.ts +26 -24
- package/src/packlets/services/service-host.test.ts +6 -6
- package/src/packlets/services/service-host.ts +57 -31
- package/src/packlets/services/service-registry.test.ts +20 -38
- package/src/packlets/spaces/data-space-manager.test.ts +17 -29
- package/src/packlets/spaces/data-space-manager.ts +29 -35
- package/src/packlets/spaces/data-space.ts +73 -47
- package/src/packlets/spaces/genesis.ts +81 -0
- package/src/packlets/spaces/notarization-plugin.test.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.ts +12 -12
- package/src/packlets/spaces/spaces-service.test.ts +2 -2
- package/src/packlets/spaces/spaces-service.ts +21 -10
- package/src/packlets/storage/storage.ts +3 -3
- package/src/packlets/system/system-service.test.ts +1 -1
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/credential-utils.ts +4 -4
- package/src/packlets/testing/index.ts +0 -1
- package/src/packlets/testing/invitation-utils.ts +28 -33
- package/src/packlets/testing/test-builder.ts +132 -168
- package/src/packlets/vault/iframe-host-runtime.ts +8 -11
- package/src/packlets/vault/iframe-proxy-runtime.ts +25 -9
- package/src/packlets/vault/shell-runtime.ts +4 -4
- package/src/packlets/vault/vault-resource-lock.ts +2 -2
- package/src/packlets/vault/worker-runtime.ts +7 -9
- package/src/packlets/vault/worker-session.ts +24 -45
- package/dist/lib/browser/chunk-T73F4MV4.mjs.map +0 -7
- package/dist/types/src/packlets/services/utils.d.ts +0 -7
- package/dist/types/src/packlets/services/utils.d.ts.map +0 -1
- package/dist/types/src/packlets/testing/host-test-builder.d.ts +0 -43
- package/dist/types/src/packlets/testing/host-test-builder.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/client-services.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/client-services.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/client.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/client.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/halo-credentials.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/halo-credentials.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/halo-persistent.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/halo-persistent.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/halo-profile.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/halo-profile.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/invitations.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/invitations.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/shared-worker.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/shared-worker.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/spaces-invitations.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/spaces-invitations.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/spaces.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/spaces.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/text.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/text.test.d.ts.map +0 -1
- package/src/packlets/services/utils.ts +0 -53
- package/src/packlets/testing/host-test-builder.ts +0 -163
- package/src/packlets/tests/client-services.test.ts +0 -222
- package/src/packlets/tests/client.test.ts +0 -140
- package/src/packlets/tests/halo-credentials.test.ts +0 -94
- package/src/packlets/tests/halo-persistent.test.ts +0 -53
- package/src/packlets/tests/halo-profile.test.ts +0 -48
- package/src/packlets/tests/invitations.test.ts +0 -389
- package/src/packlets/tests/shared-worker.test.ts +0 -92
- package/src/packlets/tests/spaces-invitations.test.ts +0 -46
- package/src/packlets/tests/spaces.test.ts +0 -147
- package/src/packlets/tests/text.test.ts +0 -206
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2020 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import chai, { expect } from 'chai';
|
|
6
|
-
import chaiAsPromised from 'chai-as-promised';
|
|
7
|
-
|
|
8
|
-
import { Client } from '@dxos/client';
|
|
9
|
-
import { Config } from '@dxos/config';
|
|
10
|
-
import { Runtime } from '@dxos/protocols/proto/dxos/config';
|
|
11
|
-
import { createStorage, StorageType } from '@dxos/random-access-storage';
|
|
12
|
-
import { describe, test, afterTest } from '@dxos/test';
|
|
13
|
-
|
|
14
|
-
import { TestBuilder } from '../testing';
|
|
15
|
-
|
|
16
|
-
chai.use(chaiAsPromised);
|
|
17
|
-
|
|
18
|
-
describe('Client', () => {
|
|
19
|
-
test('creates client with embedded services', async () => {
|
|
20
|
-
const testBuilder = new TestBuilder();
|
|
21
|
-
|
|
22
|
-
const client = new Client({ services: testBuilder.createLocal() });
|
|
23
|
-
await client.initialize();
|
|
24
|
-
afterTest(() => client.destroy());
|
|
25
|
-
expect(client.initialized).to.be.true;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('initialize and destroy multiple times', async () => {
|
|
29
|
-
const testBuilder = new TestBuilder();
|
|
30
|
-
|
|
31
|
-
const client = new Client({ services: testBuilder.createLocal() });
|
|
32
|
-
await client.initialize();
|
|
33
|
-
await client.initialize();
|
|
34
|
-
expect(client.initialized).to.be.true;
|
|
35
|
-
|
|
36
|
-
await client.destroy();
|
|
37
|
-
await client.destroy();
|
|
38
|
-
expect(client.initialized).to.be.false;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('closes and reopens', async () => {
|
|
42
|
-
const testBuilder = new TestBuilder();
|
|
43
|
-
|
|
44
|
-
const client = new Client({ services: testBuilder.createLocal() });
|
|
45
|
-
await client.initialize();
|
|
46
|
-
expect(client.initialized).to.be.true;
|
|
47
|
-
|
|
48
|
-
await client.destroy();
|
|
49
|
-
expect(client.initialized).to.be.false;
|
|
50
|
-
|
|
51
|
-
await client.initialize();
|
|
52
|
-
expect(client.initialized).to.be.true;
|
|
53
|
-
|
|
54
|
-
await client.destroy();
|
|
55
|
-
expect(client.initialized).to.be.false;
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('create space before identity', async () => {
|
|
59
|
-
const testBuilder = new TestBuilder();
|
|
60
|
-
|
|
61
|
-
const client = new Client({ services: testBuilder.createLocal() });
|
|
62
|
-
await client.initialize();
|
|
63
|
-
afterTest(() => client.destroy());
|
|
64
|
-
await expect(client.createSpace()).to.eventually.be.rejectedWith('This device has no HALO identity available.');
|
|
65
|
-
}).timeout(1_000);
|
|
66
|
-
|
|
67
|
-
// TODO(burdon): Memory store is reset on close (feed store is closed).
|
|
68
|
-
test.skip('creates identity then resets the memory storage', async () => {
|
|
69
|
-
const config = new Config();
|
|
70
|
-
const testBuilder = new TestBuilder(config);
|
|
71
|
-
await runTest(testBuilder);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test('creates identity then resets the node storage', async () => {
|
|
75
|
-
const config = await getNodeConfig(true);
|
|
76
|
-
const testBuilder = new TestBuilder(config);
|
|
77
|
-
await runTest(testBuilder);
|
|
78
|
-
}).onlyEnvironments('nodejs');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// TODO(burdon): Factor out.
|
|
82
|
-
const getNodeConfig = async (reset = false) => {
|
|
83
|
-
const path = '/tmp/dxos/client/test/packlets/test';
|
|
84
|
-
if (reset) {
|
|
85
|
-
// TODO(burdon): Reconcile StorageType and ConfigProto types.
|
|
86
|
-
const storage = createStorage({ type: StorageType.NODE, root: path });
|
|
87
|
-
await storage.reset();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// TODO(burdon): Update API.
|
|
91
|
-
// TODO(burdon): Config not required if remote.
|
|
92
|
-
return new Config({
|
|
93
|
-
version: 1,
|
|
94
|
-
runtime: {
|
|
95
|
-
client: {
|
|
96
|
-
storage: {
|
|
97
|
-
persistent: true,
|
|
98
|
-
storageType: Runtime.Client.Storage.StorageDriver.NODE,
|
|
99
|
-
path // TODO(burdon): Change to root.
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// TODO(burdon): Develop test-suite.
|
|
107
|
-
const runTest = async (testBuilder: TestBuilder) => {
|
|
108
|
-
const client = new Client({ services: testBuilder.createLocal() });
|
|
109
|
-
const displayName = 'test-user';
|
|
110
|
-
{
|
|
111
|
-
// Create identity.
|
|
112
|
-
await client.initialize();
|
|
113
|
-
expect(client.halo.identity.get()).not.to.exist;
|
|
114
|
-
const identity = await client.halo.createIdentity({ displayName });
|
|
115
|
-
expect(client.halo.identity.get()).to.deep.eq(identity);
|
|
116
|
-
await client.destroy();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
{
|
|
120
|
-
// Should throw trying to create another.
|
|
121
|
-
await client.initialize();
|
|
122
|
-
expect(client.halo.identity).to.exist;
|
|
123
|
-
// TODO(burdon): Error type.
|
|
124
|
-
await expect(client.halo.createIdentity({ displayName })).to.be.rejected;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
// Reset storage.
|
|
129
|
-
// TODO(burdon): Reset doesn't work in memory (create store test).
|
|
130
|
-
await client.reset();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
{
|
|
134
|
-
// Start again.
|
|
135
|
-
await client.initialize();
|
|
136
|
-
await client.halo.createIdentity({ displayName });
|
|
137
|
-
expect(client.halo.identity).to.exist;
|
|
138
|
-
await client.destroy();
|
|
139
|
-
}
|
|
140
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2020 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// @dxos/test platform=nodejs
|
|
6
|
-
|
|
7
|
-
import { expect } from 'chai';
|
|
8
|
-
|
|
9
|
-
import { asyncTimeout, Trigger } from '@dxos/async';
|
|
10
|
-
import { Client } from '@dxos/client';
|
|
11
|
-
import { Config } from '@dxos/config';
|
|
12
|
-
import { verifyPresentation } from '@dxos/credentials';
|
|
13
|
-
import { PublicKey } from '@dxos/keys';
|
|
14
|
-
import { log } from '@dxos/log';
|
|
15
|
-
import { describe, test, afterTest } from '@dxos/test';
|
|
16
|
-
|
|
17
|
-
import { TestBuilder } from '../testing';
|
|
18
|
-
|
|
19
|
-
describe('Halo', () => {
|
|
20
|
-
test('presentation', async () => {
|
|
21
|
-
const config = new Config({
|
|
22
|
-
version: 1,
|
|
23
|
-
runtime: {
|
|
24
|
-
client: {
|
|
25
|
-
storage: {
|
|
26
|
-
persistent: true, // TODO(burdon): Note required if path set.
|
|
27
|
-
path: `/tmp/dxos/client/${PublicKey.random().toHex()}`
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const testBuilder = new TestBuilder(config);
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
const client = new Client({ config, services: testBuilder.createLocal() });
|
|
37
|
-
afterTest(() => client.destroy());
|
|
38
|
-
await client.initialize();
|
|
39
|
-
|
|
40
|
-
await client.halo.createIdentity({ displayName: 'test-user' });
|
|
41
|
-
expect(client.halo.identity).exist;
|
|
42
|
-
|
|
43
|
-
const credentials = client.halo.queryCredentials({ type: 'dxos.halo.credentials.AdmittedFeed' });
|
|
44
|
-
const trigger = new Trigger();
|
|
45
|
-
credentials.subscribe({
|
|
46
|
-
onUpdate: (credentials) => {
|
|
47
|
-
if (credentials.length >= 2) {
|
|
48
|
-
trigger.wake();
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
onError: (err) => log.catch(err)
|
|
52
|
-
});
|
|
53
|
-
await asyncTimeout(trigger.wait(), 500);
|
|
54
|
-
|
|
55
|
-
const nonce = new Uint8Array([0, 0, 0, 0]);
|
|
56
|
-
const presentation = await client.halo.presentCredentials({
|
|
57
|
-
ids: credentials.value!.map(({ id }) => id!),
|
|
58
|
-
nonce: new Uint8Array([0, 0, 0, 0])
|
|
59
|
-
});
|
|
60
|
-
expect(presentation.credentials?.length).to.equal(2);
|
|
61
|
-
expect(await verifyPresentation(presentation)).to.deep.equal({ kind: 'pass' });
|
|
62
|
-
expect(presentation.proofs![0].nonce).to.deep.equal(nonce);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('query credentials', async () => {
|
|
67
|
-
const testBuilder = new TestBuilder();
|
|
68
|
-
|
|
69
|
-
const client = new Client({ services: testBuilder.createLocal() });
|
|
70
|
-
afterTest(() => client.destroy());
|
|
71
|
-
await client.initialize();
|
|
72
|
-
|
|
73
|
-
await client.halo.createIdentity({ displayName: 'test-user' });
|
|
74
|
-
expect(client.halo.identity).exist;
|
|
75
|
-
|
|
76
|
-
const credentials = client.halo.queryCredentials({ type: 'dxos.halo.credentials.AdmittedFeed' });
|
|
77
|
-
|
|
78
|
-
const trigger = new Trigger();
|
|
79
|
-
credentials.subscribe({
|
|
80
|
-
onUpdate: () => {
|
|
81
|
-
if (credentials.value?.length === 2) {
|
|
82
|
-
trigger.wake();
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
onError: (error) => {
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
await asyncTimeout(trigger.wait(), 500);
|
|
90
|
-
|
|
91
|
-
expect(credentials.value!.every((cred) => cred.subject.assertion['@type'] === 'dxos.halo.credentials.AdmittedFeed'))
|
|
92
|
-
.to.be.true;
|
|
93
|
-
});
|
|
94
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2020 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// @dxos/test platform=nodejs
|
|
6
|
-
|
|
7
|
-
import { expect } from 'chai';
|
|
8
|
-
|
|
9
|
-
import { waitForCondition } from '@dxos/async';
|
|
10
|
-
import { Client } from '@dxos/client';
|
|
11
|
-
import { Config } from '@dxos/config';
|
|
12
|
-
import { PublicKey } from '@dxos/keys';
|
|
13
|
-
import { describe, test, afterTest } from '@dxos/test';
|
|
14
|
-
|
|
15
|
-
import { TestBuilder } from '../testing';
|
|
16
|
-
|
|
17
|
-
describe('Halo', () => {
|
|
18
|
-
test('reopens with persistent storage', async () => {
|
|
19
|
-
const config = new Config({
|
|
20
|
-
version: 1,
|
|
21
|
-
runtime: {
|
|
22
|
-
client: {
|
|
23
|
-
storage: {
|
|
24
|
-
persistent: true, // TODO(burdon): Note required if path set.
|
|
25
|
-
path: `/tmp/dxos/client/${PublicKey.random().toHex()}`
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const testBuilder = new TestBuilder(config);
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
const client = new Client({ config, services: testBuilder.createLocal() });
|
|
35
|
-
afterTest(() => client.destroy());
|
|
36
|
-
await client.initialize();
|
|
37
|
-
|
|
38
|
-
await client.halo.createIdentity({ displayName: 'test-user' });
|
|
39
|
-
expect(client.halo.identity).exist;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
const client = new Client({ config, services: testBuilder.createLocal() });
|
|
44
|
-
afterTest(() => client.destroy());
|
|
45
|
-
await client.initialize();
|
|
46
|
-
|
|
47
|
-
await waitForCondition(() => !!client.halo.identity);
|
|
48
|
-
expect(client.halo.identity).exist;
|
|
49
|
-
// TODO(burdon): Not working.
|
|
50
|
-
// expect(client.halo.identity!.displayName).to.eq('test-user');
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2021 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { expect } from 'chai';
|
|
6
|
-
|
|
7
|
-
import { Client } from '@dxos/client';
|
|
8
|
-
import { describe, test, afterTest } from '@dxos/test';
|
|
9
|
-
|
|
10
|
-
import { performInvitation, TestBuilder } from '../testing';
|
|
11
|
-
|
|
12
|
-
describe('Halo', () => {
|
|
13
|
-
test('creates a identity', async () => {
|
|
14
|
-
const testBuilder = new TestBuilder();
|
|
15
|
-
|
|
16
|
-
const client = new Client({ services: testBuilder.createLocal() });
|
|
17
|
-
afterTest(() => client.destroy());
|
|
18
|
-
await client.initialize();
|
|
19
|
-
|
|
20
|
-
await client.halo.createIdentity({ displayName: 'test-user' });
|
|
21
|
-
expect(client.halo.identity).exist;
|
|
22
|
-
|
|
23
|
-
expect(await client.halo.devices.get()).to.have.lengthOf(1);
|
|
24
|
-
expect(client.halo.identity.get()!.profile?.displayName).to.equal('test-user');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('device invitations', async () => {
|
|
28
|
-
const testBuilder = new TestBuilder();
|
|
29
|
-
|
|
30
|
-
const client1 = new Client({ services: testBuilder.createLocal() });
|
|
31
|
-
afterTest(() => client1.destroy());
|
|
32
|
-
await client1.initialize();
|
|
33
|
-
|
|
34
|
-
await client1.halo.createIdentity({ displayName: 'test-user' });
|
|
35
|
-
expect(client1.halo.identity).exist;
|
|
36
|
-
|
|
37
|
-
expect(await client1.halo.devices.get()).to.have.lengthOf(1);
|
|
38
|
-
|
|
39
|
-
const client2 = new Client({ services: testBuilder.createLocal() });
|
|
40
|
-
afterTest(() => client2.destroy());
|
|
41
|
-
await client2.initialize();
|
|
42
|
-
|
|
43
|
-
await Promise.all(performInvitation({ host: client1.halo, guest: client2.halo }));
|
|
44
|
-
|
|
45
|
-
expect(await client1.halo.devices.get()).to.have.lengthOf(2);
|
|
46
|
-
expect(await client2.halo.devices.get()).to.have.lengthOf(2);
|
|
47
|
-
});
|
|
48
|
-
});
|