@dxos/client-services 0.3.11-main.8feb6a5 → 0.3.11-main.927e4ba

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/lib/browser/{chunk-NL2YAECI.mjs → chunk-D5MCMADP.mjs} +79 -59
  2. package/dist/lib/browser/chunk-D5MCMADP.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +4 -11
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-72F5Z47S.cjs → chunk-XVKOKG24.cjs} +137 -117
  9. package/dist/lib/node/chunk-XVKOKG24.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +37 -37
  11. package/dist/lib/node/index.cjs.map +1 -1
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/packlets/testing/index.cjs +11 -18
  14. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  15. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +2 -0
  16. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  17. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +28 -3
  18. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
  19. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  20. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -0
  21. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  22. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  23. package/dist/types/src/version.d.ts +1 -1
  24. package/package.json +35 -35
  25. package/src/packlets/invitations/device-invitation-protocol.test.ts +14 -0
  26. package/src/packlets/invitations/device-invitation-protocol.ts +14 -0
  27. package/src/packlets/invitations/invitation-protocol.ts +44 -6
  28. package/src/packlets/invitations/invitations-handler.ts +19 -17
  29. package/src/packlets/invitations/space-invitation-protocol.test.ts +28 -0
  30. package/src/packlets/invitations/space-invitation-protocol.ts +11 -0
  31. package/src/packlets/spaces/spaces-service.ts +1 -1
  32. package/src/packlets/testing/invitation-utils.ts +2 -10
  33. package/src/version.ts +1 -1
  34. package/dist/lib/browser/chunk-NL2YAECI.mjs.map +0 -7
  35. package/dist/lib/node/chunk-72F5Z47S.cjs.map +0 -7
@@ -483,7 +483,7 @@ function _ts_decorate(decorators, target, key, desc) {
483
483
  return c > 3 && r && Object.defineProperty(target, key, r), r;
484
484
  }
485
485
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
486
- var Identity = class Identity2 {
486
+ var Identity = class {
487
487
  constructor({ space, signer, identityKey, deviceKey }) {
488
488
  this.stateUpdate = new Event();
489
489
  this.space = space;
@@ -665,7 +665,7 @@ function _ts_decorate2(decorators, target, key, desc) {
665
665
  return c > 3 && r && Object.defineProperty(target, key, r), r;
666
666
  }
667
667
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
668
- var IdentityManager = class IdentityManager2 {
668
+ var IdentityManager = class {
669
669
  // TODO(burdon): IdentityManagerParams.
670
670
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
671
671
  constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
@@ -1095,6 +1095,7 @@ var IdentityServiceImpl = class {
1095
1095
 
1096
1096
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
1097
1097
  import { invariant as invariant4 } from "@dxos/invariant";
1098
+ import { AlreadyJoinedError } from "@dxos/protocols";
1098
1099
  import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
1099
1100
  var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1100
1101
  var DeviceInvitationProtocol = class {
@@ -1114,7 +1115,7 @@ var DeviceInvitationProtocol = class {
1114
1115
  async admit(request) {
1115
1116
  invariant4(request.device, void 0, {
1116
1117
  F: __dxlog_file5,
1117
- L: 35,
1118
+ L: 36,
1118
1119
  S: this,
1119
1120
  A: [
1120
1121
  "request.device",
@@ -1132,6 +1133,15 @@ var DeviceInvitationProtocol = class {
1132
1133
  }
1133
1134
  };
1134
1135
  }
1136
+ checkInvitation(invitation) {
1137
+ try {
1138
+ const identity = this._getIdentity();
1139
+ if (identity) {
1140
+ return new AlreadyJoinedError("Currently only one identity per client is supported.");
1141
+ }
1142
+ } catch {
1143
+ }
1144
+ }
1135
1145
  createIntroduction() {
1136
1146
  return {};
1137
1147
  }
@@ -1150,7 +1160,7 @@ var DeviceInvitationProtocol = class {
1150
1160
  async accept(response, request) {
1151
1161
  invariant4(response.device, void 0, {
1152
1162
  F: __dxlog_file5,
1153
- L: 68,
1163
+ L: 80,
1154
1164
  S: this,
1155
1165
  A: [
1156
1166
  "response.device",
@@ -1160,7 +1170,7 @@ var DeviceInvitationProtocol = class {
1160
1170
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1161
1171
  invariant4(request.device, void 0, {
1162
1172
  F: __dxlog_file5,
1163
- L: 71,
1173
+ L: 83,
1164
1174
  S: this,
1165
1175
  A: [
1166
1176
  "request.device",
@@ -1942,16 +1952,12 @@ var InvitationsHandler = class {
1942
1952
  }
1943
1953
  }
1944
1954
  }
1945
- } else {
1946
- setState({
1947
- state: Invitation3.State.READY_FOR_AUTHENTICATION
1948
- });
1949
1955
  }
1950
1956
  log5("request admission", {
1951
1957
  ...protocol.toJSON()
1952
1958
  }, {
1953
1959
  F: __dxlog_file7,
1954
- L: 312,
1960
+ L: 309,
1955
1961
  S: this,
1956
1962
  C: (f, a) => f(...a)
1957
1963
  });
@@ -1963,7 +1969,7 @@ var InvitationsHandler = class {
1963
1969
  ...protocol.toJSON()
1964
1970
  }, {
1965
1971
  F: __dxlog_file7,
1966
- L: 323,
1972
+ L: 320,
1967
1973
  S: this,
1968
1974
  C: (f, a) => f(...a)
1969
1975
  });
@@ -1976,7 +1982,7 @@ var InvitationsHandler = class {
1976
1982
  id: traceId
1977
1983
  }), {
1978
1984
  F: __dxlog_file7,
1979
- L: 325,
1985
+ L: 322,
1980
1986
  S: this,
1981
1987
  C: (f, a) => f(...a)
1982
1988
  });
@@ -1986,7 +1992,7 @@ var InvitationsHandler = class {
1986
1992
  ...protocol.toJSON()
1987
1993
  }, {
1988
1994
  F: __dxlog_file7,
1989
- L: 328,
1995
+ L: 325,
1990
1996
  S: this,
1991
1997
  C: (f, a) => f(...a)
1992
1998
  });
@@ -1996,7 +2002,7 @@ var InvitationsHandler = class {
1996
2002
  } else {
1997
2003
  log5("auth failed", err, {
1998
2004
  F: __dxlog_file7,
1999
- L: 331,
2005
+ L: 328,
2000
2006
  S: this,
2001
2007
  C: (f, a) => f(...a)
2002
2008
  });
@@ -2007,7 +2013,7 @@ var InvitationsHandler = class {
2007
2013
  error: err
2008
2014
  }), {
2009
2015
  F: __dxlog_file7,
2010
- L: 334,
2016
+ L: 331,
2011
2017
  S: this,
2012
2018
  C: (f, a) => f(...a)
2013
2019
  });
@@ -2025,7 +2031,7 @@ var InvitationsHandler = class {
2025
2031
  ...protocol.toJSON()
2026
2032
  }, {
2027
2033
  F: __dxlog_file7,
2028
- L: 345,
2034
+ L: 342,
2029
2035
  S: this,
2030
2036
  C: (f, a) => f(...a)
2031
2037
  });
@@ -2035,7 +2041,7 @@ var InvitationsHandler = class {
2035
2041
  } else {
2036
2042
  log5("auth failed", err, {
2037
2043
  F: __dxlog_file7,
2038
- L: 348,
2044
+ L: 345,
2039
2045
  S: this,
2040
2046
  C: (f, a) => f(...a)
2041
2047
  });
@@ -2046,29 +2052,34 @@ var InvitationsHandler = class {
2046
2052
  return extension;
2047
2053
  };
2048
2054
  scheduleTask2(ctx, async () => {
2049
- invariant6(invitation.swarmKey, void 0, {
2050
- F: __dxlog_file7,
2051
- L: 358,
2052
- S: this,
2053
- A: [
2054
- "invitation.swarmKey",
2055
- ""
2056
- ]
2057
- });
2058
- const topic = invitation.swarmKey;
2059
- const swarmConnection = await this._networkManager.joinSwarm({
2060
- topic,
2061
- peerId: PublicKey6.random(),
2062
- protocolProvider: createTeleportProtocolFactory(async (teleport) => {
2063
- teleport.addExtension("dxos.halo.invitations", createExtension());
2064
- }),
2065
- topology: new StarTopology(topic),
2066
- label: "invitation guest"
2067
- });
2068
- ctx.onDispose(() => swarmConnection.close());
2069
- setState({
2070
- state: Invitation3.State.CONNECTING
2071
- });
2055
+ const error = protocol.checkInvitation(invitation);
2056
+ if (error) {
2057
+ stream.error(error);
2058
+ } else {
2059
+ invariant6(invitation.swarmKey, void 0, {
2060
+ F: __dxlog_file7,
2061
+ L: 359,
2062
+ S: this,
2063
+ A: [
2064
+ "invitation.swarmKey",
2065
+ ""
2066
+ ]
2067
+ });
2068
+ const topic = invitation.swarmKey;
2069
+ const swarmConnection = await this._networkManager.joinSwarm({
2070
+ topic,
2071
+ peerId: PublicKey6.random(),
2072
+ protocolProvider: createTeleportProtocolFactory(async (teleport) => {
2073
+ teleport.addExtension("dxos.halo.invitations", createExtension());
2074
+ }),
2075
+ topology: new StarTopology(topic),
2076
+ label: "invitation guest"
2077
+ });
2078
+ ctx.onDispose(() => swarmConnection.close());
2079
+ setState({
2080
+ state: Invitation3.State.CONNECTING
2081
+ });
2082
+ }
2072
2083
  });
2073
2084
  const observable = new AuthenticatingInvitation({
2074
2085
  initialInvitation: invitation,
@@ -2274,6 +2285,7 @@ import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/creden
2274
2285
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
2275
2286
  import { invariant as invariant8 } from "@dxos/invariant";
2276
2287
  import { log as log7 } from "@dxos/log";
2288
+ import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
2277
2289
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
2278
2290
  var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2279
2291
  var SpaceInvitationProtocol = class {
@@ -2298,7 +2310,7 @@ var SpaceInvitationProtocol = class {
2298
2310
  async admit(request, guestProfile) {
2299
2311
  invariant8(this._spaceKey, void 0, {
2300
2312
  F: __dxlog_file9,
2301
- L: 46,
2313
+ L: 47,
2302
2314
  S: this,
2303
2315
  A: [
2304
2316
  "this._spaceKey",
@@ -2308,7 +2320,7 @@ var SpaceInvitationProtocol = class {
2308
2320
  const space = await this._spaceManager.spaces.get(this._spaceKey);
2309
2321
  invariant8(space, void 0, {
2310
2322
  F: __dxlog_file9,
2311
- L: 48,
2323
+ L: 49,
2312
2324
  S: this,
2313
2325
  A: [
2314
2326
  "space",
@@ -2317,7 +2329,7 @@ var SpaceInvitationProtocol = class {
2317
2329
  });
2318
2330
  invariant8(request.space, void 0, {
2319
2331
  F: __dxlog_file9,
2320
- L: 50,
2332
+ L: 51,
2321
2333
  S: this,
2322
2334
  A: [
2323
2335
  "request.space",
@@ -2330,14 +2342,14 @@ var SpaceInvitationProtocol = class {
2330
2342
  guest: deviceKey
2331
2343
  }, {
2332
2344
  F: __dxlog_file9,
2333
- L: 53,
2345
+ L: 54,
2334
2346
  S: this,
2335
2347
  C: (f, a) => f(...a)
2336
2348
  });
2337
2349
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
2338
2350
  invariant8(credentials[0].credential, void 0, {
2339
2351
  F: __dxlog_file9,
2340
- L: 64,
2352
+ L: 65,
2341
2353
  S: this,
2342
2354
  A: [
2343
2355
  "credentials[0].credential",
@@ -2347,7 +2359,7 @@ var SpaceInvitationProtocol = class {
2347
2359
  const spaceMemberCredential = credentials[0].credential.credential;
2348
2360
  invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2349
2361
  F: __dxlog_file9,
2350
- L: 66,
2362
+ L: 67,
2351
2363
  S: this,
2352
2364
  A: [
2353
2365
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2363,6 +2375,11 @@ var SpaceInvitationProtocol = class {
2363
2375
  }
2364
2376
  };
2365
2377
  }
2378
+ checkInvitation(invitation) {
2379
+ if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
2380
+ return new AlreadyJoinedError2("Already joined space.");
2381
+ }
2382
+ }
2366
2383
  createIntroduction() {
2367
2384
  return {
2368
2385
  profile: this._signingContext.getProfile()
@@ -2383,7 +2400,7 @@ var SpaceInvitationProtocol = class {
2383
2400
  async accept(response) {
2384
2401
  invariant8(response.space, void 0, {
2385
2402
  F: __dxlog_file9,
2386
- L: 101,
2403
+ L: 108,
2387
2404
  S: this,
2388
2405
  A: [
2389
2406
  "response.space",
@@ -2394,7 +2411,7 @@ var SpaceInvitationProtocol = class {
2394
2411
  const assertion = getCredentialAssertion(credential);
2395
2412
  invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2396
2413
  F: __dxlog_file9,
2397
- L: 104,
2414
+ L: 111,
2398
2415
  S: this,
2399
2416
  A: [
2400
2417
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2403,13 +2420,16 @@ var SpaceInvitationProtocol = class {
2403
2420
  });
2404
2421
  invariant8(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
2405
2422
  F: __dxlog_file9,
2406
- L: 105,
2423
+ L: 112,
2407
2424
  S: this,
2408
2425
  A: [
2409
2426
  "credential.subject.id.equals(this._signingContext.identityKey)",
2410
2427
  ""
2411
2428
  ]
2412
2429
  });
2430
+ if (this._spaceManager.spaces.has(assertion.spaceKey)) {
2431
+ throw new AlreadyJoinedError2("Already joined space.");
2432
+ }
2413
2433
  await this._spaceManager.acceptSpace({
2414
2434
  spaceKey: assertion.spaceKey,
2415
2435
  genesisFeedKey: assertion.genesisFeedKey,
@@ -2438,7 +2458,7 @@ function _ts_decorate3(decorators, target, key, desc) {
2438
2458
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2439
2459
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2440
2460
  }
2441
- var ClientRpcServer = class ClientRpcServer2 {
2461
+ var ClientRpcServer = class {
2442
2462
  constructor(params) {
2443
2463
  this._handlerCache = /* @__PURE__ */ new Map();
2444
2464
  this._callMetrics = new MapCounter();
@@ -2543,7 +2563,7 @@ var getPlatform = () => {
2543
2563
  };
2544
2564
 
2545
2565
  // packages/sdk/client-services/src/version.ts
2546
- var DXOS_VERSION = "0.3.11-main.8feb6a5";
2566
+ var DXOS_VERSION = "0.3.11-main.927e4ba";
2547
2567
 
2548
2568
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2549
2569
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -2982,7 +3002,7 @@ function _ts_decorate4(decorators, target, key, desc) {
2982
3002
  }
2983
3003
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2984
3004
  var ENABLE_FEED_PURGE = false;
2985
- var DataSpace = class DataSpace2 {
3005
+ var DataSpace = class {
2986
3006
  constructor(params) {
2987
3007
  this._ctx = new Context7();
2988
3008
  this._notarizationPlugin = new NotarizationPlugin();
@@ -3471,7 +3491,7 @@ function _ts_decorate5(decorators, target, key, desc) {
3471
3491
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3472
3492
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3473
3493
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3474
- var DataSpaceManager = class DataSpaceManager2 {
3494
+ var DataSpaceManager = class {
3475
3495
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
3476
3496
  this._spaceManager = _spaceManager;
3477
3497
  this._metadataStore = _metadataStore;
@@ -3814,7 +3834,7 @@ var SpacesServiceImpl = class {
3814
3834
  }
3815
3835
  async createSpace() {
3816
3836
  if (!this._identityManager.identity) {
3817
- throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
3837
+ throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
3818
3838
  }
3819
3839
  const dataSpaceManager = await this._getDataSpaceManager();
3820
3840
  const space = await dataSpaceManager.createSpace();
@@ -4044,7 +4064,7 @@ function _ts_decorate6(decorators, target, key, desc) {
4044
4064
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4045
4065
  }
4046
4066
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4047
- var ServiceContext = class ServiceContext2 {
4067
+ var ServiceContext = class {
4048
4068
  constructor(storage, networkManager, signalManager, modelFactory) {
4049
4069
  this.storage = storage;
4050
4070
  this.networkManager = networkManager;
@@ -4345,7 +4365,7 @@ var Lock = class {
4345
4365
  }
4346
4366
  async acquire() {
4347
4367
  this._broadcastChannel.postMessage({
4348
- message: Message.ACQUIRING
4368
+ message: "acquiring"
4349
4369
  });
4350
4370
  try {
4351
4371
  log14("aquiring lock...", void 0, {
@@ -4381,7 +4401,7 @@ var Lock = class {
4381
4401
  this._releaseTrigger.wake();
4382
4402
  }
4383
4403
  _onMessage(event) {
4384
- if (event.data.message === Message.ACQUIRING) {
4404
+ if (event.data.message === "acquiring") {
4385
4405
  this._releaseTrigger.wake();
4386
4406
  }
4387
4407
  }
@@ -4778,7 +4798,7 @@ var createGenesisMutationFromTypedObject = (obj) => {
4778
4798
  }
4779
4799
  };
4780
4800
  };
4781
- var ClientServicesHost = class ClientServicesHost2 {
4801
+ var ClientServicesHost = class {
4782
4802
  constructor({
4783
4803
  config,
4784
4804
  modelFactory = createDefaultModelFactory(),
@@ -5187,4 +5207,4 @@ export {
5187
5207
  createDefaultModelFactory,
5188
5208
  ClientServicesHost
5189
5209
  };
5190
- //# sourceMappingURL=chunk-NL2YAECI.mjs.map
5210
+ //# sourceMappingURL=chunk-D5MCMADP.mjs.map