@dxos/client-services 0.5.9-main.eacfffa → 0.5.9-main.f099efe
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-J4DDMC6A.mjs → chunk-H3XJK6ZN.mjs} +483 -187
- package/dist/lib/browser/{chunk-J4DDMC6A.mjs.map → chunk-H3XJK6ZN.mjs.map} +4 -4
- package/dist/lib/browser/index.mjs +9 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-6HFQ2SQ5.cjs → chunk-JRDM7NQS.cjs} +502 -206
- package/dist/lib/node/chunk-JRDM7NQS.cjs.map +7 -0
- package/dist/lib/node/index.cjs +49 -41
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +8 -8
- package/dist/types/src/packlets/identity/contacts-service.d.ts +14 -0
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +10 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +4 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/index.d.ts +1 -0
- package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/profile-archive.d.ts +14 -0
- package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -0
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/identity/contacts-service.ts +85 -0
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -32
- package/src/packlets/services/service-host.ts +12 -4
- package/src/packlets/spaces/data-space-manager.ts +55 -2
- package/src/packlets/spaces/spaces-service.ts +38 -0
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/profile-archive.ts +97 -0
- package/src/version.ts +1 -1
- package/dist/lib/node/chunk-6HFQ2SQ5.cjs.map +0 -7
|
@@ -30,7 +30,7 @@ __export(testing_exports, {
|
|
|
30
30
|
sanitizeInvitation: () => sanitizeInvitation
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(testing_exports);
|
|
33
|
-
var
|
|
33
|
+
var import_chunk_JRDM7NQS = require("../../chunk-JRDM7NQS.cjs");
|
|
34
34
|
var import_credentials = require("@dxos/credentials");
|
|
35
35
|
var import_keys = require("@dxos/keys");
|
|
36
36
|
var import_async = require("@dxos/async");
|
|
@@ -227,7 +227,7 @@ var createInvitation = async (host, options) => {
|
|
|
227
227
|
authMethod: import_services.Invitation.AuthMethod.NONE,
|
|
228
228
|
...options ?? {}
|
|
229
229
|
};
|
|
230
|
-
if (host instanceof
|
|
230
|
+
if (host instanceof import_chunk_JRDM7NQS.ServiceContext) {
|
|
231
231
|
return host.invitationsManager.createInvitation({
|
|
232
232
|
kind: import_services.Invitation.Kind.SPACE,
|
|
233
233
|
...options
|
|
@@ -237,7 +237,7 @@ var createInvitation = async (host, options) => {
|
|
|
237
237
|
};
|
|
238
238
|
var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
239
239
|
invitation = sanitizeInvitation(invitation);
|
|
240
|
-
if (guest instanceof
|
|
240
|
+
if (guest instanceof import_chunk_JRDM7NQS.ServiceContext) {
|
|
241
241
|
return guest.invitationsManager.acceptInvitation({
|
|
242
242
|
invitation,
|
|
243
243
|
deviceProfile: guestDeviceProfile
|
|
@@ -247,7 +247,7 @@ var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
|
247
247
|
};
|
|
248
248
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/test-builder.ts";
|
|
249
249
|
var createServiceHost = (config, signalManagerContext) => {
|
|
250
|
-
return new
|
|
250
|
+
return new import_chunk_JRDM7NQS.ClientServicesHost({
|
|
251
251
|
config,
|
|
252
252
|
signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
|
|
253
253
|
transportFactory: import_network_manager.MemoryTransportFactory
|
|
@@ -263,7 +263,7 @@ var createServiceContext = async ({ signalContext = new import_messaging.MemoryS
|
|
|
263
263
|
});
|
|
264
264
|
const level = (0, import_testing.createTestLevel)();
|
|
265
265
|
await level.open();
|
|
266
|
-
return new
|
|
266
|
+
return new import_chunk_JRDM7NQS.ServiceContext(storage, level, networkManager, signalManager, {
|
|
267
267
|
invitationConnectionDefaultParams: {
|
|
268
268
|
controlHeartbeatInterval: 200
|
|
269
269
|
},
|
|
@@ -370,12 +370,12 @@ var TestPeer = class {
|
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
372
|
get dataSpaceManager() {
|
|
373
|
-
return this._props.dataSpaceManager ??= new
|
|
373
|
+
return this._props.dataSpaceManager ??= new import_chunk_JRDM7NQS.DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, this.identity, this.feedStore, this.echoHost, this.invitationsManager, this._opts.dataSpaceParams);
|
|
374
374
|
}
|
|
375
375
|
get invitationsManager() {
|
|
376
|
-
return this._props.invitationsManager ??= new
|
|
376
|
+
return this._props.invitationsManager ??= new import_chunk_JRDM7NQS.InvitationsManager(new import_chunk_JRDM7NQS.InvitationsHandler(this.networkManager), (invitation) => {
|
|
377
377
|
if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
|
|
378
|
-
return new
|
|
378
|
+
return new import_chunk_JRDM7NQS.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
|
|
379
379
|
} else {
|
|
380
380
|
throw new Error("not implemented");
|
|
381
381
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Stream } from '@dxos/codec-protobuf';
|
|
2
|
+
import type { SpaceManager } from '@dxos/echo-pipeline';
|
|
3
|
+
import { type ContactBook, type ContactsService } from '@dxos/protocols/proto/dxos/client/services';
|
|
4
|
+
import { type IdentityManager } from './identity-manager';
|
|
5
|
+
import { type DataSpaceManager } from '../spaces';
|
|
6
|
+
export declare class ContactsServiceImpl implements ContactsService {
|
|
7
|
+
private readonly _identityManager;
|
|
8
|
+
private readonly _spaceManager;
|
|
9
|
+
private readonly _dataSpaceManagerProvider;
|
|
10
|
+
constructor(_identityManager: IdentityManager, _spaceManager: SpaceManager, _dataSpaceManagerProvider: () => Promise<DataSpaceManager>);
|
|
11
|
+
getContacts(): Promise<ContactBook>;
|
|
12
|
+
queryContacts(): Stream<ContactBook>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=contacts-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contacts-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/identity/contacts-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAgB,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAGlH,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,qBAAa,mBAAoB,YAAW,eAAe;IAEvD,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,yBAAyB;gBAFzB,gBAAgB,EAAE,eAAe,EACjC,aAAa,EAAE,YAAY,EAC3B,yBAAyB,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC;IAGvE,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IA8BzC,aAAa,IAAI,MAAM,CAAC,WAAW,CAAC;CAgCrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space-invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/space-invitation-protocol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"space-invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/space-invitation-protocol.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EACL,kBAAkB,EAClB,KAAK,QAAQ,EAEb,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAChG,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAEvE,qBAAa,uBAAwB,YAAW,kBAAkB;IAE9D,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAHV,aAAa,EAAE,gBAAgB,EAC/B,eAAe,EAAE,cAAc,EAC/B,QAAQ,EAAE,OAAO,EACjB,SAAS,CAAC,uBAAW;IAGxC,MAAM,IAAI,MAAM;IAOhB,wBAAwB,IAAI,QAAQ,GAAG,SAAS;IAchD,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;IAOhE,KAAK,CACT,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,gBAAgB,EACzB,YAAY,CAAC,EAAE,eAAe,GAAG,SAAS,GACzC,OAAO,CAAC,iBAAiB,CAAC;IAqBvB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;IAiCpD,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB7D,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;IAS/C,kBAAkB,IAAI,mBAAmB;IAMnC,sBAAsB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAenD,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;CAuBxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-host.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/services/service-host.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAyD,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGrH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAI3D,OAAO,EAAE,cAAc,EAAE,KAAK,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"service-host.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/services/service-host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store';
|
|
|
6
6
|
import { type Keyring } from '@dxos/keyring';
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
8
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
9
|
-
import { type Credential, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
9
|
+
import { SpaceMember, type Credential, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
10
10
|
import { type Timeframe } from '@dxos/timeframe';
|
|
11
11
|
import { ComplexMap } from '@dxos/util';
|
|
12
12
|
import { DataSpace } from './data-space';
|
|
@@ -32,6 +32,13 @@ export type AcceptSpaceOptions = {
|
|
|
32
32
|
*/
|
|
33
33
|
dataTimeframe?: Timeframe;
|
|
34
34
|
};
|
|
35
|
+
export type AdmitMemberOptions = {
|
|
36
|
+
spaceKey: PublicKey;
|
|
37
|
+
identityKey: PublicKey;
|
|
38
|
+
role: SpaceMember.Role;
|
|
39
|
+
profile?: ProfileDocument;
|
|
40
|
+
delegationCredentialId?: PublicKey;
|
|
41
|
+
};
|
|
35
42
|
export type DataSpaceManagerRuntimeParams = {
|
|
36
43
|
spaceMemberPresenceAnnounceInterval?: number;
|
|
37
44
|
spaceMemberPresenceOfflineTimeout?: number;
|
|
@@ -62,12 +69,14 @@ export declare class DataSpaceManager {
|
|
|
62
69
|
createDefaultSpace(): Promise<DataSpace>;
|
|
63
70
|
private _getSpaceRootDocument;
|
|
64
71
|
acceptSpace(opts: AcceptSpaceOptions): Promise<DataSpace>;
|
|
72
|
+
admitMember(options: AdmitMemberOptions): Promise<Credential>;
|
|
65
73
|
/**
|
|
66
74
|
* Wait until the space data pipeline is fully initialized.
|
|
67
75
|
* Used by invitation handler.
|
|
68
76
|
* TODO(dmaretskyi): Consider removing.
|
|
69
77
|
*/
|
|
70
78
|
waitUntilSpaceReady(spaceKey: PublicKey): Promise<void>;
|
|
79
|
+
requestSpaceAdmissionCredential(spaceKey: PublicKey): Promise<Credential>;
|
|
71
80
|
private _constructSpace;
|
|
72
81
|
private _handleMemberRoleChanges;
|
|
73
82
|
private _handleNewPeerConnected;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-space-manager.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/data-space-manager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAA4B,MAAM,aAAa,CAAC;AAK9D,OAAO,EAEL,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"data-space-manager.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/data-space-manager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAA4B,MAAM,aAAa,CAAC;AAK9D,OAAO,EAEL,KAAK,gBAAgB,EAItB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAmD,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,YAAY,EAGlB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAIjH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAA2C,MAAM,YAAY,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAQzD,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,SAAS,CAAC;IACvB,SAAS,EAAE,SAAS,CAAC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AAC,QAAQ,CAAC,WAAW,CAA8B;gBAGvC,aAAa,EAAE,YAAY,EAC3B,cAAc,EAAE,aAAa,EAC7B,QAAQ,EAAE,OAAO,EACjB,eAAe,EAAE,cAAc,EAC/B,UAAU,EAAE,SAAS,CAAC,WAAW,CAAC,EAClC,SAAS,EAAE,QAAQ,EACnB,mBAAmB,EAAE,kBAAkB,EACvC,OAAO,CAAC,2CAA+B;IA6B1D,IAAI,MAAM,qCAET;IAGK,IAAI;IAqBJ,KAAK;IAUX;;OAEG;IAEG,WAAW;IAgCX,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAqBlD,kBAAkB;YA0BV,qBAAqB;IAU7B,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;IAqBzD,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;IA6BnE;;;;OAIG;IACG,mBAAmB,CAAC,QAAQ,EAAE,SAAS;IAUhC,+BAA+B,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;YAaxE,eAAe;IAiG7B,OAAO,CAAC,wBAAwB;IAyBhC,OAAO,CAAC,uBAAuB;YAWjB,6BAA6B;YAiB7B,2BAA2B;CAqB1C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Stream } from '@dxos/codec-protobuf';
|
|
2
2
|
import { type SpaceManager } from '@dxos/echo-pipeline';
|
|
3
|
-
import { type CreateEpochRequest, type PostMessageRequest, type QueryCredentialsRequest, type QuerySpacesResponse, type Space, type SpacesService, type SubscribeMessagesRequest, type UpdateSpaceRequest, type WriteCredentialsRequest, type UpdateMemberRoleRequest, type CreateEpochResponse } from '@dxos/protocols/proto/dxos/client/services';
|
|
3
|
+
import { type CreateEpochRequest, type PostMessageRequest, type QueryCredentialsRequest, type QuerySpacesResponse, type Space, type SpacesService, type SubscribeMessagesRequest, type UpdateSpaceRequest, type WriteCredentialsRequest, type UpdateMemberRoleRequest, type AdmitContactRequest, type JoinSpaceResponse, type JoinBySpaceKeyRequest, type CreateEpochResponse } from '@dxos/protocols/proto/dxos/client/services';
|
|
4
4
|
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
5
5
|
import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
|
|
6
6
|
import { type Provider } from '@dxos/util';
|
|
@@ -20,6 +20,9 @@ export declare class SpacesServiceImpl implements SpacesService {
|
|
|
20
20
|
queryCredentials({ spaceKey, noTail }: QueryCredentialsRequest): Stream<Credential>;
|
|
21
21
|
writeCredentials({ spaceKey, credentials }: WriteCredentialsRequest): Promise<void>;
|
|
22
22
|
createEpoch({ spaceKey, migration, automergeRootUrl }: CreateEpochRequest): Promise<CreateEpochResponse>;
|
|
23
|
+
admitContact(request: AdmitContactRequest): Promise<void>;
|
|
24
|
+
joinBySpaceKey({ spaceKey }: JoinBySpaceKeyRequest): Promise<JoinSpaceResponse>;
|
|
25
|
+
private _joinByAdmission;
|
|
23
26
|
private _serializeSpace;
|
|
24
27
|
private _requireIdentity;
|
|
25
28
|
private _updateMetrics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spaces-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/spaces-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAWxD,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACzB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EA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I,CAAC;IA0BvE,WAAW,IAAI,MAAM,CAAC,mBAAmB,CAAC;IA6DpC,WAAW,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,kBAAkB;IAMpE,iBAAiB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,wBAAwB;IAajE,gBAAgB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC;IAmB7E,gBAAgB,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,uBAAuB;IAmBnE,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOxG,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IASzD,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;YAMvE,gBAAgB;IAmB9B,OAAO,CAAC,eAAe;IA6CvB,OAAO,CAAC,gBAAgB;YASV,cAAc;CAS7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/storage/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/storage/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LevelDB } from '@dxos/kv-store';
|
|
2
|
+
import { type ProfileArchive } from '@dxos/protocols';
|
|
3
|
+
import type { Storage } from '@dxos/random-access-storage';
|
|
4
|
+
export declare const encodeProfileArchive: (profile: ProfileArchive) => Uint8Array;
|
|
5
|
+
export declare const decodeProfileArchive: (data: Uint8Array) => ProfileArchive;
|
|
6
|
+
export declare const exportProfileData: ({ storage, level, }: {
|
|
7
|
+
storage: Storage;
|
|
8
|
+
level: LevelDB;
|
|
9
|
+
}) => Promise<ProfileArchive>;
|
|
10
|
+
export declare const importProfileData: ({ storage, level, }: {
|
|
11
|
+
storage: Storage;
|
|
12
|
+
level: LevelDB;
|
|
13
|
+
}, archive: ProfileArchive) => Promise<void>;
|
|
14
|
+
//# sourceMappingURL=profile-archive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-archive.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/storage/profile-archive.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAA2B,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAG3D,eAAO,MAAM,oBAAoB,YAAa,cAAc,KAAG,UAAkC,CAAC;AAElG,eAAO,MAAM,oBAAoB,SAAU,UAAU,KAAG,cAAmC,CAAC;AAE5F,eAAO,MAAM,iBAAiB,wBAG3B;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB,KAAG,QAAQ,cAAc,CAqCzB,CAAC;AAEF,eAAO,MAAM,iBAAiB,wBAIzB;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB,WACQ,cAAc,KACtB,QAAQ,IAAI,CA0Bd,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DXOS_VERSION = "0.5.9-main.
|
|
1
|
+
export declare const DXOS_VERSION = "0.5.9-main.f099efe";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client-services",
|
|
3
|
-
"version": "0.5.9-main.
|
|
3
|
+
"version": "0.5.9-main.f099efe",
|
|
4
4
|
"description": "DXOS client services implementation",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -23,45 +23,45 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"platform": "^1.3.6",
|
|
26
|
-
"@dxos/async": "0.5.9-main.
|
|
27
|
-
"@dxos/
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/credentials": "0.5.9-main.
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/echo-db": "0.5.9-main.
|
|
36
|
-
"@dxos/echo-pipeline": "0.5.9-main.
|
|
37
|
-
"@dxos/echo-protocol": "0.5.9-main.
|
|
38
|
-
"@dxos/echo-schema": "0.5.9-main.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/keys": "0.5.9-main.
|
|
44
|
-
"@dxos/kv-store": "0.5.9-main.
|
|
45
|
-
"@dxos/lock-file": "0.5.9-main.
|
|
46
|
-
"@dxos/log": "0.5.9-main.
|
|
47
|
-
"@dxos/messaging": "0.5.9-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/random-access-storage": "0.5.9-main.
|
|
52
|
-
"@dxos/rpc": "0.5.9-main.
|
|
53
|
-
"@dxos/teleport
|
|
54
|
-
"@dxos/teleport": "0.5.9-main.
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/util": "0.5.9-main.
|
|
59
|
-
"@dxos/websocket-rpc": "0.5.9-main.
|
|
26
|
+
"@dxos/async": "0.5.9-main.f099efe",
|
|
27
|
+
"@dxos/client-protocol": "0.5.9-main.f099efe",
|
|
28
|
+
"@dxos/automerge": "0.5.9-main.f099efe",
|
|
29
|
+
"@dxos/config": "0.5.9-main.f099efe",
|
|
30
|
+
"@dxos/context": "0.5.9-main.f099efe",
|
|
31
|
+
"@dxos/codec-protobuf": "0.5.9-main.f099efe",
|
|
32
|
+
"@dxos/credentials": "0.5.9-main.f099efe",
|
|
33
|
+
"@dxos/crypto": "0.5.9-main.f099efe",
|
|
34
|
+
"@dxos/debug": "0.5.9-main.f099efe",
|
|
35
|
+
"@dxos/echo-db": "0.5.9-main.f099efe",
|
|
36
|
+
"@dxos/echo-pipeline": "0.5.9-main.f099efe",
|
|
37
|
+
"@dxos/echo-protocol": "0.5.9-main.f099efe",
|
|
38
|
+
"@dxos/echo-schema": "0.5.9-main.f099efe",
|
|
39
|
+
"@dxos/indexing": "0.5.9-main.f099efe",
|
|
40
|
+
"@dxos/feed-store": "0.5.9-main.f099efe",
|
|
41
|
+
"@dxos/keyring": "0.5.9-main.f099efe",
|
|
42
|
+
"@dxos/invariant": "0.5.9-main.f099efe",
|
|
43
|
+
"@dxos/keys": "0.5.9-main.f099efe",
|
|
44
|
+
"@dxos/kv-store": "0.5.9-main.f099efe",
|
|
45
|
+
"@dxos/lock-file": "0.5.9-main.f099efe",
|
|
46
|
+
"@dxos/log": "0.5.9-main.f099efe",
|
|
47
|
+
"@dxos/messaging": "0.5.9-main.f099efe",
|
|
48
|
+
"@dxos/network-manager": "0.5.9-main.f099efe",
|
|
49
|
+
"@dxos/protocols": "0.5.9-main.f099efe",
|
|
50
|
+
"@dxos/node-std": "0.5.9-main.f099efe",
|
|
51
|
+
"@dxos/random-access-storage": "0.5.9-main.f099efe",
|
|
52
|
+
"@dxos/rpc": "0.5.9-main.f099efe",
|
|
53
|
+
"@dxos/teleport": "0.5.9-main.f099efe",
|
|
54
|
+
"@dxos/teleport-extension-gossip": "0.5.9-main.f099efe",
|
|
55
|
+
"@dxos/timeframe": "0.5.9-main.f099efe",
|
|
56
|
+
"@dxos/teleport-extension-object-sync": "0.5.9-main.f099efe",
|
|
57
|
+
"@dxos/tracing": "0.5.9-main.f099efe",
|
|
58
|
+
"@dxos/util": "0.5.9-main.f099efe",
|
|
59
|
+
"@dxos/websocket-rpc": "0.5.9-main.f099efe"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/platform": "^1.3.4",
|
|
63
63
|
"@types/readable-stream": "^2.3.9",
|
|
64
|
-
"@dxos/signal": "0.5.9-main.
|
|
64
|
+
"@dxos/signal": "0.5.9-main.f099efe"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { EventSubscriptions, scheduleTask, UpdateScheduler } from '@dxos/async';
|
|
6
|
+
import { Stream } from '@dxos/codec-protobuf';
|
|
7
|
+
import { type MemberInfo } from '@dxos/credentials';
|
|
8
|
+
import type { SpaceManager } from '@dxos/echo-pipeline';
|
|
9
|
+
import { PublicKey } from '@dxos/keys';
|
|
10
|
+
import { type Contact, type ContactBook, type ContactsService } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
|
+
import { ComplexMap, ComplexSet } from '@dxos/util';
|
|
12
|
+
|
|
13
|
+
import { type IdentityManager } from './identity-manager';
|
|
14
|
+
import { type DataSpaceManager } from '../spaces';
|
|
15
|
+
|
|
16
|
+
export class ContactsServiceImpl implements ContactsService {
|
|
17
|
+
constructor(
|
|
18
|
+
private readonly _identityManager: IdentityManager,
|
|
19
|
+
private readonly _spaceManager: SpaceManager,
|
|
20
|
+
private readonly _dataSpaceManagerProvider: () => Promise<DataSpaceManager>,
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
async getContacts(): Promise<ContactBook> {
|
|
24
|
+
const identity = this._identityManager.identity;
|
|
25
|
+
if (identity == null) {
|
|
26
|
+
return { contacts: [] };
|
|
27
|
+
}
|
|
28
|
+
const contacts = [...this._spaceManager.spaces.values()]
|
|
29
|
+
.flatMap((s) => [...s.spaceState.members.values()].map((m) => [s.key, m]))
|
|
30
|
+
.reduce((acc, v) => {
|
|
31
|
+
const [spaceKey, memberInfo] = v as [PublicKey, MemberInfo];
|
|
32
|
+
if (memberInfo.key.equals(identity.identityKey)) {
|
|
33
|
+
return acc;
|
|
34
|
+
}
|
|
35
|
+
const existing = acc.get(memberInfo.key);
|
|
36
|
+
if (existing != null) {
|
|
37
|
+
existing.profile ??= memberInfo.profile;
|
|
38
|
+
existing.commonSpaces?.push(spaceKey);
|
|
39
|
+
} else {
|
|
40
|
+
acc.set(memberInfo.key, {
|
|
41
|
+
identityKey: memberInfo.key,
|
|
42
|
+
profile: memberInfo.profile,
|
|
43
|
+
commonSpaces: [spaceKey],
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return acc;
|
|
47
|
+
}, new ComplexMap<PublicKey, Contact>(PublicKey.hash));
|
|
48
|
+
return {
|
|
49
|
+
contacts: [...contacts.values()],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
queryContacts(): Stream<ContactBook> {
|
|
54
|
+
const subscribedSpaceKeySet = new ComplexSet(PublicKey.hash);
|
|
55
|
+
return new Stream<ContactBook>(({ next, ctx }) => {
|
|
56
|
+
const pushUpdateTask = new UpdateScheduler(
|
|
57
|
+
ctx,
|
|
58
|
+
async () => {
|
|
59
|
+
const contacts = await this.getContacts();
|
|
60
|
+
next(contacts);
|
|
61
|
+
},
|
|
62
|
+
{ maxFrequency: 2 },
|
|
63
|
+
);
|
|
64
|
+
scheduleTask(ctx, async () => {
|
|
65
|
+
const subscriptions = new EventSubscriptions();
|
|
66
|
+
ctx.onDispose(() => subscriptions.clear());
|
|
67
|
+
const subscribeToSpaceAndUpdate = () => {
|
|
68
|
+
const oldSetSize = subscribedSpaceKeySet.size;
|
|
69
|
+
for (const space of this._spaceManager.spaces.values()) {
|
|
70
|
+
if (!subscribedSpaceKeySet.has(space.key)) {
|
|
71
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => pushUpdateTask.trigger()));
|
|
72
|
+
subscribedSpaceKeySet.add(space.key);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (oldSetSize !== subscribedSpaceKeySet.size) {
|
|
76
|
+
pushUpdateTask.trigger();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const unsubscribe = (await this._dataSpaceManagerProvider()).updated.on(ctx, subscribeToSpaceAndUpdate);
|
|
80
|
+
ctx.onDispose(unsubscribe);
|
|
81
|
+
subscribeToSpaceAndUpdate();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
createAdmissionCredentials,
|
|
7
6
|
createCancelDelegatedSpaceInvitationCredential,
|
|
8
7
|
createDelegatedSpaceInvitationCredential,
|
|
9
8
|
getCredentialAssertion,
|
|
@@ -21,7 +20,6 @@ import {
|
|
|
21
20
|
SpaceNotFoundError,
|
|
22
21
|
} from '@dxos/protocols';
|
|
23
22
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
24
|
-
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
25
23
|
import { SpaceMember, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
26
24
|
import {
|
|
27
25
|
type AdmissionRequest,
|
|
@@ -73,41 +71,22 @@ export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
73
71
|
request: AdmissionRequest,
|
|
74
72
|
guestProfile?: ProfileDocument | undefined,
|
|
75
73
|
): Promise<AdmissionResponse> {
|
|
76
|
-
invariant(this._spaceKey);
|
|
77
|
-
|
|
78
|
-
invariant(space);
|
|
79
|
-
|
|
80
|
-
invariant(request.space);
|
|
81
|
-
const { identityKey, deviceKey } = request.space;
|
|
74
|
+
invariant(this._spaceKey && request.space);
|
|
75
|
+
log('writing guest credentials', { host: this._signingContext.deviceKey, guest: request.space.deviceKey });
|
|
82
76
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this._signingContext.credentialSigner,
|
|
91
|
-
identityKey,
|
|
92
|
-
space.key,
|
|
93
|
-
space.inner.genesisFeedKey,
|
|
94
|
-
invitation.role ?? SpaceMember.Role.ADMIN,
|
|
95
|
-
space.inner.spaceState.membershipChainHeads,
|
|
96
|
-
guestProfile,
|
|
97
|
-
invitation.delegationCredentialId,
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
// TODO(dmaretskyi): Refactor.
|
|
101
|
-
invariant(credentials[0].credential);
|
|
102
|
-
const spaceMemberCredential = credentials[0].credential.credential;
|
|
103
|
-
invariant(getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember');
|
|
104
|
-
|
|
105
|
-
await writeMessages(space.inner.controlPipeline.writer, credentials);
|
|
77
|
+
const spaceMemberCredential = await this._spaceManager.admitMember({
|
|
78
|
+
spaceKey: this._spaceKey,
|
|
79
|
+
identityKey: request.space.identityKey,
|
|
80
|
+
role: invitation.role ?? SpaceMember.Role.ADMIN,
|
|
81
|
+
profile: guestProfile,
|
|
82
|
+
delegationCredentialId: invitation.delegationCredentialId,
|
|
83
|
+
});
|
|
106
84
|
|
|
85
|
+
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
107
86
|
return {
|
|
108
87
|
space: {
|
|
109
88
|
credential: spaceMemberCredential,
|
|
110
|
-
controlTimeframe: space
|
|
89
|
+
controlTimeframe: space?.inner.controlPipeline.state.timeframe,
|
|
111
90
|
},
|
|
112
91
|
};
|
|
113
92
|
}
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
createDiagnostics,
|
|
29
29
|
} from '../diagnostics';
|
|
30
30
|
import { IdentityServiceImpl, type CreateIdentityOptions } from '../identity';
|
|
31
|
+
import { ContactsServiceImpl } from '../identity/contacts-service';
|
|
31
32
|
import { InvitationsServiceImpl } from '../invitations';
|
|
32
33
|
import { Lock, type ResourceLock } from '../locks';
|
|
33
34
|
import { LoggingServiceImpl } from '../logging';
|
|
@@ -251,6 +252,11 @@ export class ClientServicesHost {
|
|
|
251
252
|
this._runtimeParams,
|
|
252
253
|
);
|
|
253
254
|
|
|
255
|
+
const dataSpaceManagerProvider = async () => {
|
|
256
|
+
await this._serviceContext.initialized.wait();
|
|
257
|
+
return this._serviceContext.dataSpaceManager!;
|
|
258
|
+
};
|
|
259
|
+
|
|
254
260
|
const identityService = new IdentityServiceImpl(
|
|
255
261
|
this._serviceContext.identityManager,
|
|
256
262
|
this._serviceContext.keyring,
|
|
@@ -262,6 +268,11 @@ export class ClientServicesHost {
|
|
|
262
268
|
this._serviceRegistry.setServices({
|
|
263
269
|
SystemService: this._systemService,
|
|
264
270
|
IdentityService: identityService,
|
|
271
|
+
ContactsService: new ContactsServiceImpl(
|
|
272
|
+
this._serviceContext.identityManager,
|
|
273
|
+
this._serviceContext.spaceManager,
|
|
274
|
+
dataSpaceManagerProvider,
|
|
275
|
+
),
|
|
265
276
|
|
|
266
277
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
267
278
|
|
|
@@ -270,10 +281,7 @@ export class ClientServicesHost {
|
|
|
270
281
|
SpacesService: new SpacesServiceImpl(
|
|
271
282
|
this._serviceContext.identityManager,
|
|
272
283
|
this._serviceContext.spaceManager,
|
|
273
|
-
|
|
274
|
-
await this._serviceContext.initialized.wait();
|
|
275
|
-
return this._serviceContext.dataSpaceManager!;
|
|
276
|
-
},
|
|
284
|
+
dataSpaceManagerProvider,
|
|
277
285
|
),
|
|
278
286
|
|
|
279
287
|
DataService: this._serviceContext.echoHost.dataService,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getCredentialAssertion,
|
|
12
12
|
type CredentialSigner,
|
|
13
13
|
type DelegateInvitationCredential,
|
|
14
|
+
createAdmissionCredentials,
|
|
14
15
|
type MemberInfo,
|
|
15
16
|
} from '@dxos/credentials';
|
|
16
17
|
import { convertLegacyReferences, findInlineObjectOfType, type EchoHost } from '@dxos/echo-db';
|
|
@@ -22,6 +23,7 @@ import {
|
|
|
22
23
|
type SpaceProtocol,
|
|
23
24
|
type SpaceProtocolSession,
|
|
24
25
|
} from '@dxos/echo-pipeline';
|
|
26
|
+
import { CredentialServerExtension } from '@dxos/echo-pipeline';
|
|
25
27
|
import {
|
|
26
28
|
LEGACY_TYPE_PROPERTIES,
|
|
27
29
|
SpaceDocVersion,
|
|
@@ -30,12 +32,12 @@ import {
|
|
|
30
32
|
type SpaceDoc,
|
|
31
33
|
} from '@dxos/echo-protocol';
|
|
32
34
|
import { TYPE_PROPERTIES, generateEchoId, getTypeReference } from '@dxos/echo-schema';
|
|
33
|
-
import { type FeedStore } from '@dxos/feed-store';
|
|
35
|
+
import { type FeedStore, writeMessages } from '@dxos/feed-store';
|
|
34
36
|
import { invariant } from '@dxos/invariant';
|
|
35
37
|
import { type Keyring } from '@dxos/keyring';
|
|
36
38
|
import { PublicKey } from '@dxos/keys';
|
|
37
39
|
import { log } from '@dxos/log';
|
|
38
|
-
import { trace as Trace } from '@dxos/protocols';
|
|
40
|
+
import { trace as Trace, AlreadyJoinedError } from '@dxos/protocols';
|
|
39
41
|
import { Invitation, SpaceState } from '@dxos/protocols/proto/dxos/client/services';
|
|
40
42
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
41
43
|
import { type SpaceMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
@@ -84,6 +86,14 @@ export type AcceptSpaceOptions = {
|
|
|
84
86
|
dataTimeframe?: Timeframe;
|
|
85
87
|
};
|
|
86
88
|
|
|
89
|
+
export type AdmitMemberOptions = {
|
|
90
|
+
spaceKey: PublicKey;
|
|
91
|
+
identityKey: PublicKey;
|
|
92
|
+
role: SpaceMember.Role;
|
|
93
|
+
profile?: ProfileDocument;
|
|
94
|
+
delegationCredentialId?: PublicKey;
|
|
95
|
+
};
|
|
96
|
+
|
|
87
97
|
export type DataSpaceManagerRuntimeParams = {
|
|
88
98
|
spaceMemberPresenceAnnounceInterval?: number;
|
|
89
99
|
spaceMemberPresenceOfflineTimeout?: number;
|
|
@@ -287,6 +297,35 @@ export class DataSpaceManager {
|
|
|
287
297
|
return space;
|
|
288
298
|
}
|
|
289
299
|
|
|
300
|
+
async admitMember(options: AdmitMemberOptions): Promise<Credential> {
|
|
301
|
+
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
302
|
+
invariant(space);
|
|
303
|
+
|
|
304
|
+
if (space.spaceState.getMemberRole(options.identityKey) !== SpaceMember.Role.REMOVED) {
|
|
305
|
+
throw new AlreadyJoinedError();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// TODO(burdon): Check if already admitted.
|
|
309
|
+
const credentials: FeedMessage.Payload[] = await createAdmissionCredentials(
|
|
310
|
+
this._signingContext.credentialSigner,
|
|
311
|
+
options.identityKey,
|
|
312
|
+
space.key,
|
|
313
|
+
space.genesisFeedKey,
|
|
314
|
+
options.role,
|
|
315
|
+
space.spaceState.membershipChainHeads,
|
|
316
|
+
options.profile,
|
|
317
|
+
options.delegationCredentialId,
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
// TODO(dmaretskyi): Refactor.
|
|
321
|
+
invariant(credentials[0].credential);
|
|
322
|
+
const spaceMemberCredential = credentials[0].credential.credential;
|
|
323
|
+
invariant(getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember');
|
|
324
|
+
await writeMessages(space.controlPipeline.writer, credentials);
|
|
325
|
+
|
|
326
|
+
return spaceMemberCredential;
|
|
327
|
+
}
|
|
328
|
+
|
|
290
329
|
/**
|
|
291
330
|
* Wait until the space data pipeline is fully initialized.
|
|
292
331
|
* Used by invitation handler.
|
|
@@ -302,6 +341,19 @@ export class DataSpaceManager {
|
|
|
302
341
|
);
|
|
303
342
|
}
|
|
304
343
|
|
|
344
|
+
public async requestSpaceAdmissionCredential(spaceKey: PublicKey): Promise<Credential> {
|
|
345
|
+
return this._spaceManager.requestSpaceAdmissionCredential({
|
|
346
|
+
spaceKey,
|
|
347
|
+
identityKey: this._signingContext.identityKey,
|
|
348
|
+
timeout: 15_000,
|
|
349
|
+
swarmIdentity: {
|
|
350
|
+
peerKey: this._signingContext.deviceKey,
|
|
351
|
+
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
352
|
+
credentialAuthenticator: async () => true,
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
305
357
|
private async _constructSpace(metadata: SpaceMetadata) {
|
|
306
358
|
log('construct space', { metadata });
|
|
307
359
|
const gossip = new Gossip({
|
|
@@ -331,6 +383,7 @@ export class DataSpaceManager {
|
|
|
331
383
|
credentialAuthenticator: deferFunction(() => dataSpace.authVerifier.verifier),
|
|
332
384
|
},
|
|
333
385
|
onAuthorizedConnection: (session) => {
|
|
386
|
+
session.addExtension('dxos.mesh.teleport.admission-discovery', new CredentialServerExtension(space));
|
|
334
387
|
session.addExtension(
|
|
335
388
|
'dxos.mesh.teleport.gossip',
|
|
336
389
|
gossip.createExtension({ remotePeerId: session.remotePeerId }),
|