@dxos/client-services 0.8.3 → 0.8.4-main.1068cf700f
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-NQSC7HOE.mjs +22 -0
- package/dist/lib/browser/chunk-NQSC7HOE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LBG3C332.mjs → chunk-OZGICTH7.mjs} +3864 -3786
- package/dist/lib/browser/chunk-OZGICTH7.mjs.map +7 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs +24 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +474 -80
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/browser.mjs +126 -0
- package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/node.mjs +66 -0
- package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +39 -27
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +24 -0
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs +22 -0
- package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SKGQLRKS.mjs → chunk-RXHISBCS.mjs} +3551 -3341
- package/dist/lib/node-esm/chunk-RXHISBCS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +474 -80
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs +126 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs +66 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +39 -27
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts +1 -1
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +20 -20
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +2 -2
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +3 -3
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +5 -5
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -3
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +4 -4
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +3 -4
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -4
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +3 -3
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
- package/dist/types/src/packlets/locks/index.d.ts +2 -2
- package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +5 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +2 -2
- 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/feed-syncer.d.ts +41 -0
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +14 -8
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +20 -6
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.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 +6 -6
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -2
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -6
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/storage.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/invitation-utils.d.ts +6 -3
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +8 -7
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts +31 -4
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-session.d.ts +2 -2
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +72 -48
- package/src/packlets/agents/edge-agent-manager.ts +2 -2
- package/src/packlets/agents/edge-agent-service.ts +13 -3
- package/src/packlets/devices/devices-service.test.ts +4 -3
- package/src/packlets/devices/devices-service.ts +2 -2
- package/src/packlets/devtools/devtools.ts +30 -29
- package/src/packlets/devtools/feeds.ts +2 -2
- package/src/packlets/devtools/network.ts +1 -1
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +1 -1
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +1 -1
- package/src/packlets/diagnostics/diagnostics-collector.ts +1 -1
- package/src/packlets/diagnostics/diagnostics.ts +1 -1
- package/src/packlets/diagnostics/index.ts +1 -1
- package/src/packlets/identity/authenticator.node.test.ts +1 -1
- package/src/packlets/identity/authenticator.ts +3 -3
- package/src/packlets/identity/contacts-service.ts +3 -2
- package/src/packlets/identity/default-space-state-machine.ts +3 -3
- package/src/packlets/identity/identity-manager.test.ts +3 -3
- package/src/packlets/identity/identity-manager.ts +9 -9
- package/src/packlets/identity/identity-recovery-manager.ts +2 -2
- package/src/packlets/identity/identity-service.test.ts +3 -2
- package/src/packlets/identity/identity-service.ts +2 -1
- package/src/packlets/identity/identity.test.ts +9 -9
- package/src/packlets/identity/identity.ts +9 -8
- package/src/packlets/invitations/device-invitation-protocol.test.ts +4 -4
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -5
- package/src/packlets/invitations/edge-invitation-handler.ts +1 -1
- package/src/packlets/invitations/index.ts +1 -1
- package/src/packlets/invitations/invitation-guest-extenstion.ts +7 -5
- package/src/packlets/invitations/invitation-host-extension.ts +8 -6
- package/src/packlets/invitations/invitation-protocol.ts +3 -4
- package/src/packlets/invitations/invitations-handler.test.ts +302 -292
- package/src/packlets/invitations/invitations-handler.ts +10 -10
- package/src/packlets/invitations/invitations-manager.ts +3 -3
- package/src/packlets/invitations/invitations-service.ts +1 -1
- package/src/packlets/invitations/space-invitation-protocol.test.ts +9 -9
- package/src/packlets/invitations/space-invitation-protocol.ts +10 -15
- package/src/packlets/invitations/utils.ts +1 -1
- package/src/packlets/locks/browser.ts +1 -1
- package/src/packlets/locks/index.ts +2 -2
- package/src/packlets/logging/logging-service.ts +8 -3
- package/src/packlets/logging/logging.test.ts +1 -1
- package/src/packlets/network/network-service.test.ts +4 -3
- package/src/packlets/network/network-service.ts +2 -2
- package/src/packlets/services/client-rpc-server.ts +5 -5
- package/src/packlets/services/feed-syncer.ts +227 -0
- package/src/packlets/services/platform.ts +7 -1
- package/src/packlets/services/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +56 -29
- package/src/packlets/services/service-host.test.ts +3 -2
- package/src/packlets/services/service-host.ts +78 -29
- package/src/packlets/services/service-registry.test.ts +2 -1
- package/src/packlets/space-export/space-archive-reader.ts +2 -2
- package/src/packlets/space-export/space-archive-writer.ts +7 -5
- package/src/packlets/space-export/tar.test.ts +1 -1
- package/src/packlets/spaces/automerge-space-state.ts +1 -1
- package/src/packlets/spaces/data-space-manager.ts +76 -36
- package/src/packlets/spaces/data-space.ts +18 -13
- package/src/packlets/spaces/edge-feed-replicator.test.ts +3 -3
- package/src/packlets/spaces/edge-feed-replicator.ts +4 -4
- package/src/packlets/spaces/epoch-migrations.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.test.ts +3 -3
- package/src/packlets/spaces/notarization-plugin.ts +11 -11
- package/src/packlets/spaces/spaces-service.test.ts +3 -2
- package/src/packlets/spaces/spaces-service.ts +27 -23
- package/src/packlets/storage/profile-archive.ts +1 -1
- package/src/packlets/storage/storage.ts +7 -8
- package/src/packlets/system/system-service.test.ts +1 -1
- package/src/packlets/system/system-service.ts +4 -4
- package/src/packlets/testing/invitation-utils.ts +8 -5
- package/src/packlets/testing/test-builder.ts +39 -13
- package/src/packlets/worker/worker-runtime.ts +151 -12
- package/src/packlets/worker/worker-session.ts +7 -7
- package/src/version.ts +1 -5
- package/README.yml +0 -5
- package/dist/lib/browser/chunk-LBG3C332.mjs.map +0 -7
- package/dist/lib/node/chunk-LMGLGOUU.cjs +0 -9311
- package/dist/lib/node/chunk-LMGLGOUU.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -437
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/testing/index.cjs +0 -452
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-SKGQLRKS.mjs.map +0 -7
|
@@ -5,7 +5,7 @@ import platform from 'platform';
|
|
|
5
5
|
|
|
6
6
|
import { Event } from '@dxos/async';
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
|
-
import { createCredentialSignerWithKey, createDidFromIdentityKey
|
|
8
|
+
import { CredentialGenerator, createCredentialSignerWithKey, createDidFromIdentityKey } from '@dxos/credentials';
|
|
9
9
|
import { type MetadataStore, type SpaceManager, type SwarmIdentity } from '@dxos/echo-pipeline';
|
|
10
10
|
import { type EdgeConnection } from '@dxos/edge-client';
|
|
11
11
|
import { type FeedStore } from '@dxos/feed-store';
|
|
@@ -20,15 +20,15 @@ import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
|
20
20
|
import { type IdentityRecord, type SpaceMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
21
21
|
import {
|
|
22
22
|
AdmittedFeed,
|
|
23
|
+
type Credential,
|
|
23
24
|
type DeviceProfileDocument,
|
|
24
25
|
DeviceType,
|
|
25
26
|
type ProfileDocument,
|
|
26
|
-
type Credential,
|
|
27
27
|
} from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
28
28
|
import { Gossip, Presence } from '@dxos/teleport-extension-gossip';
|
|
29
29
|
import { Timeframe } from '@dxos/timeframe';
|
|
30
30
|
import { trace as Trace } from '@dxos/tracing';
|
|
31
|
-
import {
|
|
31
|
+
import { deferFunction, isNode } from '@dxos/util';
|
|
32
32
|
|
|
33
33
|
import { createAuthProvider } from './authenticator';
|
|
34
34
|
import { Identity } from './identity';
|
|
@@ -36,14 +36,14 @@ import { Identity } from './identity';
|
|
|
36
36
|
const DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 10_000;
|
|
37
37
|
const DEVICE_PRESENCE_OFFLINE_TIMEOUT = 20_000;
|
|
38
38
|
|
|
39
|
-
interface
|
|
39
|
+
interface ConstructSpaceProps {
|
|
40
40
|
spaceRecord: SpaceMetadata;
|
|
41
41
|
swarmIdentity: SwarmIdentity;
|
|
42
42
|
identityKey: PublicKey;
|
|
43
43
|
gossip: Gossip;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export type
|
|
46
|
+
export type JoinIdentityProps = {
|
|
47
47
|
identityKey: PublicKey;
|
|
48
48
|
deviceKey: PublicKey;
|
|
49
49
|
haloSpaceKey: PublicKey;
|
|
@@ -67,7 +67,7 @@ export type CreateIdentityOptions = {
|
|
|
67
67
|
deviceProfile?: DeviceProfileDocument;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
export type
|
|
70
|
+
export type IdentityManagerProps = {
|
|
71
71
|
metadataStore: MetadataStore;
|
|
72
72
|
keyring: Keyring;
|
|
73
73
|
feedStore: FeedStore<FeedMessage>;
|
|
@@ -95,7 +95,7 @@ export class IdentityManager {
|
|
|
95
95
|
private _identity?: Identity;
|
|
96
96
|
|
|
97
97
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
98
|
-
constructor(params:
|
|
98
|
+
constructor(params: IdentityManagerProps) {
|
|
99
99
|
this._metadataStore = params.metadataStore;
|
|
100
100
|
this._keyring = params.keyring;
|
|
101
101
|
this._feedStore = params.feedStore;
|
|
@@ -240,7 +240,7 @@ export class IdentityManager {
|
|
|
240
240
|
/**
|
|
241
241
|
* Prepare an identity object as the first step of acceptIdentity flow.
|
|
242
242
|
*/
|
|
243
|
-
async prepareIdentity(params:
|
|
243
|
+
async prepareIdentity(params: JoinIdentityProps) {
|
|
244
244
|
log('accepting identity', { params });
|
|
245
245
|
invariant(!this._identity, 'Identity already exists.');
|
|
246
246
|
|
|
@@ -395,7 +395,7 @@ export class IdentityManager {
|
|
|
395
395
|
return identity;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
private async _constructSpace({ spaceRecord, swarmIdentity, identityKey, gossip }:
|
|
398
|
+
private async _constructSpace({ spaceRecord, swarmIdentity, identityKey, gossip }: ConstructSpaceProps) {
|
|
399
399
|
return this._spaceManager.constructSpace({
|
|
400
400
|
metadata: {
|
|
401
401
|
key: spaceRecord.key,
|
|
@@ -22,14 +22,14 @@ import {
|
|
|
22
22
|
import { Timeframe } from '@dxos/timeframe';
|
|
23
23
|
|
|
24
24
|
import { type Identity } from './identity';
|
|
25
|
-
import { type
|
|
25
|
+
import { type JoinIdentityProps } from './identity-manager';
|
|
26
26
|
|
|
27
27
|
export class EdgeIdentityRecoveryManager {
|
|
28
28
|
constructor(
|
|
29
29
|
private readonly _keyring: Keyring,
|
|
30
30
|
private readonly _edgeClient: EdgeHttpClient | undefined,
|
|
31
31
|
private readonly _identityProvider: () => Identity | undefined,
|
|
32
|
-
private readonly _acceptRecoveredIdentity: (params:
|
|
32
|
+
private readonly _acceptRecoveredIdentity: (params: JoinIdentityProps) => Promise<Identity>,
|
|
33
33
|
) {}
|
|
34
34
|
|
|
35
35
|
public async createRecoveryCredential({
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { afterEach,
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { type Identity, type IdentityService } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
11
|
|
|
12
|
-
import { IdentityServiceImpl } from './identity-service';
|
|
13
12
|
import { type ServiceContext } from '../services';
|
|
14
13
|
import { createServiceContext } from '../testing';
|
|
15
14
|
|
|
15
|
+
import { IdentityServiceImpl } from './identity-service';
|
|
16
|
+
|
|
16
17
|
describe('IdentityService', () => {
|
|
17
18
|
let serviceContext: ServiceContext;
|
|
18
19
|
let identityService: IdentityService;
|
|
@@ -22,10 +22,11 @@ import {
|
|
|
22
22
|
import { type Presentation, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
23
23
|
import { safeAwaitAll } from '@dxos/util';
|
|
24
24
|
|
|
25
|
+
import { type DataSpaceManager } from '../spaces';
|
|
26
|
+
|
|
25
27
|
import { type Identity } from './identity';
|
|
26
28
|
import { type CreateIdentityOptions, type IdentityManager } from './identity-manager';
|
|
27
29
|
import { type EdgeIdentityRecoveryManager } from './identity-recovery-manager';
|
|
28
|
-
import { type DataSpaceManager } from '../spaces';
|
|
29
30
|
|
|
30
31
|
const DEFAULT_SPACE_SEARCH_TIMEOUT = 10_000;
|
|
31
32
|
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Event } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
|
-
import {
|
|
9
|
+
import { CredentialGenerator, createDidFromIdentityKey, verifyCredential } from '@dxos/credentials';
|
|
10
10
|
import {
|
|
11
|
-
createIdFromSpaceKey,
|
|
12
|
-
MetadataStore,
|
|
13
11
|
MOCK_AUTH_PROVIDER,
|
|
14
12
|
MOCK_AUTH_VERIFIER,
|
|
13
|
+
MetadataStore,
|
|
15
14
|
Space,
|
|
16
15
|
SpaceProtocol,
|
|
16
|
+
createIdFromSpaceKey,
|
|
17
17
|
valueEncoding,
|
|
18
18
|
} from '@dxos/echo-pipeline';
|
|
19
19
|
import { type EdgeConnection, type MessageListener } from '@dxos/edge-client';
|
|
@@ -26,7 +26,7 @@ import { MemoryTransportFactory, SwarmNetworkManager } from '@dxos/network-manag
|
|
|
26
26
|
import { EdgeStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
27
27
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
28
28
|
import { AdmittedFeed } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
29
|
-
import {
|
|
29
|
+
import { StorageType, createStorage } from '@dxos/random-access-storage';
|
|
30
30
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
31
31
|
|
|
32
32
|
import { Identity } from './identity';
|
|
@@ -109,16 +109,16 @@ describe('identity/identity', () => {
|
|
|
109
109
|
|
|
110
110
|
test('edge feed replicator', async () => {
|
|
111
111
|
let replicationStarted = false;
|
|
112
|
-
let status = EdgeStatus.NOT_CONNECTED;
|
|
112
|
+
let status = EdgeStatus.ConnectionState.NOT_CONNECTED;
|
|
113
113
|
const listeners: Array<() => void> = [];
|
|
114
114
|
const setup = await setupIdentity({
|
|
115
115
|
edgeConnection: {
|
|
116
116
|
statusChanged: new Event(),
|
|
117
117
|
get status() {
|
|
118
|
-
return status;
|
|
118
|
+
return { state: status };
|
|
119
119
|
},
|
|
120
120
|
onReconnected: (listener) => {
|
|
121
|
-
if (status === EdgeStatus.CONNECTED) {
|
|
121
|
+
if (status === EdgeStatus.ConnectionState.CONNECTED) {
|
|
122
122
|
listener();
|
|
123
123
|
} else {
|
|
124
124
|
listeners.push(listener);
|
|
@@ -138,7 +138,7 @@ describe('identity/identity', () => {
|
|
|
138
138
|
|
|
139
139
|
await writeGenesisCredential(setup);
|
|
140
140
|
listeners.forEach((callback) => callback());
|
|
141
|
-
status = EdgeStatus.CONNECTED;
|
|
141
|
+
status = EdgeStatus.ConnectionState.CONNECTED;
|
|
142
142
|
|
|
143
143
|
await expect.poll(() => replicationStarted).toBeTruthy();
|
|
144
144
|
});
|
|
@@ -6,16 +6,16 @@ import { Event } from '@dxos/async';
|
|
|
6
6
|
import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from '@dxos/client-protocol';
|
|
7
7
|
import { type Context } from '@dxos/context';
|
|
8
8
|
import {
|
|
9
|
-
DeviceStateMachine,
|
|
10
9
|
type CredentialSigner,
|
|
11
|
-
|
|
12
|
-
createCredentialSignerWithChain,
|
|
10
|
+
DeviceStateMachine,
|
|
13
11
|
ProfileStateMachine,
|
|
12
|
+
createCredentialSignerWithChain,
|
|
13
|
+
createCredentialSignerWithKey,
|
|
14
14
|
} from '@dxos/credentials';
|
|
15
15
|
import { type Signer } from '@dxos/crypto';
|
|
16
16
|
import { type Space } from '@dxos/echo-pipeline';
|
|
17
17
|
import { type EdgeConnection } from '@dxos/edge-client';
|
|
18
|
-
import {
|
|
18
|
+
import { type FeedWrapper, writeMessages } from '@dxos/feed-store';
|
|
19
19
|
import { invariant } from '@dxos/invariant';
|
|
20
20
|
import { type IdentityDid, PublicKey, type SpaceId } from '@dxos/keys';
|
|
21
21
|
import { log } from '@dxos/log';
|
|
@@ -23,9 +23,9 @@ import { type Runtime } from '@dxos/protocols/proto/dxos/config';
|
|
|
23
23
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
24
24
|
import {
|
|
25
25
|
AdmittedFeed,
|
|
26
|
+
type Credential,
|
|
26
27
|
type DeviceProfileDocument,
|
|
27
28
|
type ProfileDocument,
|
|
28
|
-
type Credential,
|
|
29
29
|
} from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
30
30
|
import { type DeviceAdmissionRequest } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
31
31
|
import { type Presence } from '@dxos/teleport-extension-gossip';
|
|
@@ -33,11 +33,12 @@ import { Timeframe } from '@dxos/timeframe';
|
|
|
33
33
|
import { trace } from '@dxos/tracing';
|
|
34
34
|
import { type ComplexMap, ComplexSet } from '@dxos/util';
|
|
35
35
|
|
|
36
|
+
import { EdgeFeedReplicator } from '../spaces';
|
|
37
|
+
|
|
36
38
|
import { TrustedKeySetAuthVerifier } from './authenticator';
|
|
37
39
|
import { DefaultSpaceStateMachine } from './default-space-state-machine';
|
|
38
|
-
import { EdgeFeedReplicator } from '../spaces';
|
|
39
40
|
|
|
40
|
-
export type
|
|
41
|
+
export type IdentityProps = {
|
|
41
42
|
did: IdentityDid;
|
|
42
43
|
identityKey: PublicKey;
|
|
43
44
|
deviceKey: PublicKey;
|
|
@@ -70,7 +71,7 @@ export class Identity {
|
|
|
70
71
|
|
|
71
72
|
public readonly stateUpdate = new Event();
|
|
72
73
|
|
|
73
|
-
constructor(params:
|
|
74
|
+
constructor(params: IdentityProps) {
|
|
74
75
|
this.space = params.space;
|
|
75
76
|
this._signer = params.signer;
|
|
76
77
|
this._presence = params.presence;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { describe, expect,
|
|
5
|
+
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { chain } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
10
10
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
@@ -32,7 +32,7 @@ describe('services/device', () => {
|
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
test('creates and accepts invitation', async () => {
|
|
35
|
-
const [host, guest] = await
|
|
35
|
+
const [host, guest] = await chain<ServiceContext>([closeAfterTest])(createPeers(2));
|
|
36
36
|
|
|
37
37
|
const identity1 = await host.createIdentity();
|
|
38
38
|
expect(host.identityManager.identity).to.eq(identity1);
|
|
@@ -42,7 +42,7 @@ describe('services/device', () => {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
test('invitation when already joined', async () => {
|
|
45
|
-
const [host, guest] = await
|
|
45
|
+
const [host, guest] = await chain<ServiceContext>([closeAfterTest])(createPeers(2));
|
|
46
46
|
|
|
47
47
|
const identity1 = await host.createIdentity();
|
|
48
48
|
expect(host.identityManager.identity).to.eq(identity1);
|
|
@@ -6,7 +6,7 @@ import { getCredentialAssertion } from '@dxos/credentials';
|
|
|
6
6
|
import { invariant } from '@dxos/invariant';
|
|
7
7
|
import { type Keyring } from '@dxos/keyring';
|
|
8
8
|
import { type PublicKey } from '@dxos/keys';
|
|
9
|
-
import { AlreadyJoinedError
|
|
9
|
+
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
10
10
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
11
|
import type { DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
12
12
|
import {
|
|
@@ -15,14 +15,15 @@ import {
|
|
|
15
15
|
type IntroductionRequest,
|
|
16
16
|
} from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
17
17
|
|
|
18
|
+
import { type Identity, type JoinIdentityProps } from '../identity';
|
|
19
|
+
|
|
18
20
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
19
|
-
import { type Identity, type JoinIdentityParams } from '../identity';
|
|
20
21
|
|
|
21
22
|
export class DeviceInvitationProtocol implements InvitationProtocol {
|
|
22
23
|
constructor(
|
|
23
24
|
private readonly _keyring: Keyring,
|
|
24
25
|
private readonly _getIdentity: () => Identity,
|
|
25
|
-
private readonly _acceptIdentity: (identity:
|
|
26
|
+
private readonly _acceptIdentity: (identity: JoinIdentityProps) => Promise<Identity>,
|
|
26
27
|
) {}
|
|
27
28
|
|
|
28
29
|
toJSON(): object {
|
|
@@ -31,7 +32,7 @@ export class DeviceInvitationProtocol implements InvitationProtocol {
|
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
checkCanInviteNewMembers():
|
|
35
|
+
checkCanInviteNewMembers(): Error | undefined {
|
|
35
36
|
return undefined;
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -70,7 +71,7 @@ export class DeviceInvitationProtocol implements InvitationProtocol {
|
|
|
70
71
|
try {
|
|
71
72
|
const identity = this._getIdentity();
|
|
72
73
|
if (identity) {
|
|
73
|
-
return new AlreadyJoinedError('Currently only one identity per client is supported.');
|
|
74
|
+
return new AlreadyJoinedError({ message: 'Currently only one identity per client is supported.' });
|
|
74
75
|
}
|
|
75
76
|
} catch {
|
|
76
77
|
// No identity.
|
|
@@ -19,8 +19,8 @@ import { schema } from '@dxos/protocols/proto';
|
|
|
19
19
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
20
20
|
import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
21
21
|
import {
|
|
22
|
-
type AdmissionResponse,
|
|
23
22
|
type AdmissionRequest,
|
|
23
|
+
type AdmissionResponse,
|
|
24
24
|
type SpaceAdmissionRequest,
|
|
25
25
|
} from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
26
26
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
export * from './device-invitation-protocol';
|
|
6
|
-
export * from './invitation-protocol';
|
|
6
|
+
export type * from './invitation-protocol';
|
|
7
7
|
export * from './invitations-handler';
|
|
8
8
|
export * from './invitations-service';
|
|
9
9
|
export * from './space-invitation-protocol';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Mutex, type MutexGuard, Trigger } from '@dxos/async';
|
|
6
|
-
import {
|
|
6
|
+
import { Context, cancelWithContext } from '@dxos/context';
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
import { InvalidInvitationExtensionRoleError } from '@dxos/protocols';
|
|
@@ -97,10 +97,12 @@ export class InvitationGuestExtension
|
|
|
97
97
|
await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({ timeout: OPTIONS_TIMEOUT }));
|
|
98
98
|
log.verbose('options received');
|
|
99
99
|
if (this._remoteOptions?.role !== InvitationOptions.Role.HOST) {
|
|
100
|
-
throw new InvalidInvitationExtensionRoleError(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
throw new InvalidInvitationExtensionRoleError({
|
|
101
|
+
context: {
|
|
102
|
+
expected: InvitationOptions.Role.HOST,
|
|
103
|
+
remoteOptions: this._remoteOptions,
|
|
104
|
+
remotePeerId: context.remotePeerId,
|
|
105
|
+
},
|
|
104
106
|
});
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Mutex, type MutexGuard, Trigger, scheduleTask } from '@dxos/async';
|
|
6
|
-
import {
|
|
6
|
+
import { Context, cancelWithContext } from '@dxos/context';
|
|
7
7
|
import { randomBytes, verify } from '@dxos/crypto';
|
|
8
|
-
import {
|
|
8
|
+
import { InvariantViolation, invariant } from '@dxos/invariant';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { InvalidInvitationExtensionRoleError, trace } from '@dxos/protocols';
|
|
@@ -245,10 +245,12 @@ export class InvitationHostExtension
|
|
|
245
245
|
await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({ timeout: OPTIONS_TIMEOUT }));
|
|
246
246
|
log.verbose('options received');
|
|
247
247
|
if (this._remoteOptions?.role !== InvitationOptions.Role.GUEST) {
|
|
248
|
-
throw new InvalidInvitationExtensionRoleError(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
throw new InvalidInvitationExtensionRoleError({
|
|
249
|
+
context: {
|
|
250
|
+
expected: InvitationOptions.Role.GUEST,
|
|
251
|
+
remoteOptions: this._remoteOptions,
|
|
252
|
+
remotePeerId: context.remotePeerId,
|
|
253
|
+
},
|
|
252
254
|
});
|
|
253
255
|
}
|
|
254
256
|
this._callbacks.onStateUpdate(Invitation.State.CONNECTED);
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type PublicKey } from '@dxos/keys';
|
|
6
|
-
import type { ApiError } from '@dxos/protocols';
|
|
7
6
|
import type { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
8
|
-
import type {
|
|
7
|
+
import type { DeviceProfileDocument, ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
9
8
|
import type {
|
|
10
9
|
AdmissionRequest,
|
|
11
10
|
AdmissionResponse,
|
|
@@ -26,7 +25,7 @@ export interface InvitationProtocol {
|
|
|
26
25
|
// Host
|
|
27
26
|
//
|
|
28
27
|
|
|
29
|
-
checkCanInviteNewMembers():
|
|
28
|
+
checkCanInviteNewMembers(): Error | undefined;
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* Protocol-specific information to include in the invitation.
|
|
@@ -58,7 +57,7 @@ export interface InvitationProtocol {
|
|
|
58
57
|
*
|
|
59
58
|
* For example, the guest may already be a member of the space.
|
|
60
59
|
*/
|
|
61
|
-
checkInvitation(invitation: Partial<Invitation>):
|
|
60
|
+
checkInvitation(invitation: Partial<Invitation>): Error | undefined;
|
|
62
61
|
|
|
63
62
|
/**
|
|
64
63
|
* Get profile information to send to the host to identify the guest.
|