@dxos/client-services 0.8.4-main.b97322e → 0.8.4-main.bc674ce
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-WKKP35EC.mjs → chunk-J33W6T4Q.mjs} +3625 -3714
- package/dist/lib/browser/chunk-J33W6T4Q.mjs.map +7 -0
- package/dist/lib/browser/chunk-NQSC7HOE.mjs +22 -0
- package/dist/lib/browser/chunk-NQSC7HOE.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 +462 -76
- 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 +34 -22
- 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-ZE2HYS56.mjs → chunk-34HKLADW.mjs} +2633 -2590
- package/dist/lib/node-esm/chunk-34HKLADW.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/index.mjs +462 -76
- 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 +34 -22
- 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/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 +1 -1
- package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +1 -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/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 +19 -5
- 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 +23 -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/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 +1 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -5
- package/src/packlets/invitations/edge-invitation-handler.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 +4 -3
- 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 +2 -2
- 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 +1 -1
- package/src/packlets/logging/logging-service.ts +3 -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/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +39 -27
- package/src/packlets/services/service-host.test.ts +3 -2
- package/src/packlets/services/service-host.ts +72 -24
- 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 +15 -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 +143 -12
- package/src/packlets/worker/worker-session.ts +7 -7
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-WKKP35EC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZE2HYS56.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;
|
|
@@ -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
|
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.
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { beforeEach,
|
|
5
|
+
import { beforeEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import { type PushStream,
|
|
7
|
+
import { type PushStream, Trigger, sleep, waitForCondition } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
11
|
import { openAndClose } from '@dxos/test-utils';
|
|
12
12
|
import { range } from '@dxos/util';
|
|
13
13
|
|
|
14
|
+
import { TestBuilder, type TestPeer } from '../testing';
|
|
15
|
+
|
|
14
16
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
15
17
|
import { InvitationsHandler } from './invitations-handler';
|
|
16
18
|
import { SpaceInvitationProtocol } from './space-invitation-protocol';
|
|
17
|
-
import { TestBuilder, type TestPeer } from '../testing';
|
|
18
19
|
|
|
19
20
|
interface PeerSetup {
|
|
20
21
|
ctx: Context;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type PushStream,
|
|
5
|
+
import { type PushStream, TimeoutError, type Trigger, scheduleTask } from '@dxos/async';
|
|
6
6
|
import { INVITATION_TIMEOUT, getExpirationTime } from '@dxos/client-protocol';
|
|
7
7
|
import { type Context, ContextDisposedError } from '@dxos/context';
|
|
8
8
|
import { createKeyPair, sign } from '@dxos/crypto';
|
|
@@ -10,19 +10,19 @@ import { type EdgeHttpClient } from '@dxos/edge-client';
|
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { PublicKey } from '@dxos/keys';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
|
-
import {
|
|
13
|
+
import { type SwarmConnection, type SwarmNetworkManager, createTeleportProtocolFactory } from '@dxos/network-manager';
|
|
14
14
|
import { InvalidInvitationError, InvalidInvitationExtensionRoleError, trace } from '@dxos/protocols';
|
|
15
15
|
import { type AdmissionKeypair, Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
16
16
|
import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
17
17
|
import { AuthenticationResponse, type IntroductionResponse } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
18
18
|
import { InvitationOptions } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
19
|
-
import { type ExtensionContext, type TeleportExtension, type
|
|
19
|
+
import { type ExtensionContext, type TeleportExtension, type TeleportProps } from '@dxos/teleport';
|
|
20
20
|
import { trace as _trace } from '@dxos/tracing';
|
|
21
21
|
import { ComplexSet } from '@dxos/util';
|
|
22
22
|
|
|
23
23
|
import { type EdgeInvitationConfig, EdgeInvitationHandler } from './edge-invitation-handler';
|
|
24
24
|
import { InvitationGuestExtension } from './invitation-guest-extenstion';
|
|
25
|
-
import { InvitationHostExtension,
|
|
25
|
+
import { InvitationHostExtension, MAX_OTP_ATTEMPTS, isAuthenticationRequired } from './invitation-host-extension';
|
|
26
26
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
27
27
|
import { createGuardedInvitationState } from './invitation-state';
|
|
28
28
|
import { InvitationTopology } from './invitation-topology';
|
|
@@ -31,8 +31,8 @@ const metrics = _trace.metrics;
|
|
|
31
31
|
|
|
32
32
|
const MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
|
|
33
33
|
|
|
34
|
-
export type
|
|
35
|
-
teleport: Partial<
|
|
34
|
+
export type InvitationConnectionProps = {
|
|
35
|
+
teleport: Partial<TeleportProps>;
|
|
36
36
|
edgeInvitations?: EdgeInvitationConfig;
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -71,7 +71,7 @@ export class InvitationsHandler {
|
|
|
71
71
|
constructor(
|
|
72
72
|
private readonly _networkManager: SwarmNetworkManager,
|
|
73
73
|
private readonly _edgeClient?: EdgeHttpClient,
|
|
74
|
-
private readonly
|
|
74
|
+
private readonly _connectionProps?: InvitationConnectionProps,
|
|
75
75
|
) {}
|
|
76
76
|
|
|
77
77
|
handleInvitationFlow(
|
|
@@ -388,7 +388,7 @@ export class InvitationsHandler {
|
|
|
388
388
|
return extension;
|
|
389
389
|
};
|
|
390
390
|
|
|
391
|
-
const edgeInvitationHandler = new EdgeInvitationHandler(this.
|
|
391
|
+
const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionProps?.edgeInvitations, this._edgeClient, {
|
|
392
392
|
onInvitationSuccess: async (admissionResponse, admissionRequest) => {
|
|
393
393
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
394
394
|
log.info('admitted by edge', { ...protocol.toJSON() });
|
|
@@ -440,7 +440,7 @@ export class InvitationsHandler {
|
|
|
440
440
|
topic: invitation.swarmKey,
|
|
441
441
|
protocolProvider: createTeleportProtocolFactory(async (teleport) => {
|
|
442
442
|
teleport.addExtension('dxos.halo.invitations', extensionFactory());
|
|
443
|
-
}, this.
|
|
443
|
+
}, this._connectionProps?.teleport),
|
|
444
444
|
topology: new InvitationTopology(role),
|
|
445
445
|
label,
|
|
446
446
|
});
|
|
@@ -503,7 +503,7 @@ export class InvitationsHandler {
|
|
|
503
503
|
const checkInvitation = (protocol: InvitationProtocol, invitation: Partial<Invitation>) => {
|
|
504
504
|
const expiresOn = getExpirationTime(invitation);
|
|
505
505
|
if (expiresOn && expiresOn.getTime() < Date.now()) {
|
|
506
|
-
return new InvalidInvitationError('Invitation already expired.');
|
|
506
|
+
return new InvalidInvitationError({ message: 'Invitation already expired.' });
|
|
507
507
|
}
|
|
508
508
|
return protocol.checkInvitation(invitation);
|
|
509
509
|
};
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import { Event, PushStream, TimeoutError, Trigger } from '@dxos/async';
|
|
6
6
|
import {
|
|
7
|
-
AuthenticatingInvitation,
|
|
8
7
|
AUTHENTICATION_CODE_LENGTH,
|
|
8
|
+
AuthenticatingInvitation,
|
|
9
9
|
CancellableInvitation,
|
|
10
10
|
INVITATION_TIMEOUT,
|
|
11
11
|
} from '@dxos/client-protocol';
|
|
12
12
|
import { Context } from '@dxos/context';
|
|
13
13
|
import { generatePasscode } from '@dxos/credentials';
|
|
14
|
-
import {
|
|
14
|
+
import { type MetadataStore, hasInvitationExpired } from '@dxos/echo-pipeline';
|
|
15
15
|
import { invariant } from '@dxos/invariant';
|
|
16
16
|
import { PublicKey } from '@dxos/keys';
|
|
17
17
|
import { log } from '@dxos/log';
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import { SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
24
24
|
|
|
25
25
|
import type { InvitationProtocol } from './invitation-protocol';
|
|
26
|
-
import {
|
|
26
|
+
import { type InvitationsHandler, createAdmissionKeypair } from './invitations-handler';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Entry point for creating and accepting invitations, keeps track of existing invitation set and
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Trigger, chain } from '@dxos/async';
|
|
8
8
|
import { raise } from '@dxos/debug';
|
|
9
9
|
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
10
10
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
@@ -12,24 +12,19 @@ import { invariant } from '@dxos/invariant';
|
|
|
12
12
|
import { type Keyring } from '@dxos/keyring';
|
|
13
13
|
import { type PublicKey } from '@dxos/keys';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
15
|
-
import {
|
|
16
|
-
AlreadyJoinedError,
|
|
17
|
-
type ApiError,
|
|
18
|
-
AuthorizationError,
|
|
19
|
-
InvalidInvitationError,
|
|
20
|
-
SpaceNotFoundError,
|
|
21
|
-
} from '@dxos/protocols';
|
|
15
|
+
import { AlreadyJoinedError, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from '@dxos/protocols';
|
|
22
16
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
23
|
-
import {
|
|
17
|
+
import { type ProfileDocument, SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
24
18
|
import {
|
|
25
19
|
type AdmissionRequest,
|
|
26
20
|
type AdmissionResponse,
|
|
27
21
|
type IntroductionRequest,
|
|
28
22
|
} from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
29
23
|
|
|
24
|
+
import { type DataSpaceManager, type SigningContext } from '../spaces';
|
|
25
|
+
|
|
30
26
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
31
27
|
import { computeExpirationTime } from './utils';
|
|
32
|
-
import { type DataSpaceManager, type SigningContext } from '../spaces';
|
|
33
28
|
|
|
34
29
|
export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
35
30
|
constructor(
|
|
@@ -47,16 +42,16 @@ export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
47
42
|
};
|
|
48
43
|
}
|
|
49
44
|
|
|
50
|
-
checkCanInviteNewMembers():
|
|
45
|
+
checkCanInviteNewMembers(): Error | undefined {
|
|
51
46
|
if (this._spaceKey == null) {
|
|
52
|
-
return new InvalidInvitationError('No spaceKey was provided for a space invitation.');
|
|
47
|
+
return new InvalidInvitationError({ message: 'No spaceKey was provided for a space invitation.' });
|
|
53
48
|
}
|
|
54
49
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
55
50
|
if (space == null) {
|
|
56
51
|
return new SpaceNotFoundError(this._spaceKey);
|
|
57
52
|
}
|
|
58
53
|
if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
|
|
59
|
-
return new AuthorizationError('No member management permission.');
|
|
54
|
+
return new AuthorizationError({ message: 'No member management permission.' });
|
|
60
55
|
}
|
|
61
56
|
return undefined;
|
|
62
57
|
}
|
|
@@ -147,10 +142,10 @@ export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
147
142
|
|
|
148
143
|
checkInvitation(invitation: Partial<Invitation>): InvalidInvitationError | AlreadyJoinedError | undefined {
|
|
149
144
|
if (invitation.spaceKey == null) {
|
|
150
|
-
return new InvalidInvitationError('No spaceKey was provided for a space invitation.');
|
|
145
|
+
return new InvalidInvitationError({ message: 'No spaceKey was provided for a space invitation.' });
|
|
151
146
|
}
|
|
152
147
|
if (this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
153
|
-
return new AlreadyJoinedError('Already joined space.');
|
|
148
|
+
return new AlreadyJoinedError({ message: 'Already joined space.' });
|
|
154
149
|
}
|
|
155
150
|
}
|
|
156
151
|
|
|
@@ -183,7 +178,7 @@ export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
183
178
|
invariant(credential.subject.id.equals(this._signingContext.identityKey));
|
|
184
179
|
|
|
185
180
|
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
186
|
-
throw new AlreadyJoinedError('Already joined space.');
|
|
181
|
+
throw new AlreadyJoinedError({ message: 'Already joined space.' });
|
|
187
182
|
}
|
|
188
183
|
|
|
189
184
|
// Create local space.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Mutex, type MutexGuard } from '@dxos/async';
|
|
6
|
-
import {
|
|
6
|
+
import { type Context, ContextDisposedError, cancelWithContext } from '@dxos/context';
|
|
7
7
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
8
8
|
|
|
9
9
|
export const stateToString = (state: Invitation.State): string => {
|