@dxos/client-services 0.3.11-main.c8e9429 → 0.3.11-main.cc2fe2c

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 (36) hide show
  1. package/dist/lib/browser/{chunk-OZ4IMR73.mjs → chunk-RGWEY4Z2.mjs} +87 -52
  2. package/dist/lib/browser/chunk-RGWEY4Z2.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +4 -11
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-46ZYQFO5.cjs → chunk-Q5PLF45D.cjs} +147 -112
  8. package/dist/lib/node/chunk-Q5PLF45D.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +37 -37
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +11 -18
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +2 -0
  14. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  15. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +28 -3
  16. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
  17. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -0
  19. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/diagnostics.d.ts +4 -0
  21. package/dist/types/src/packlets/services/diagnostics.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/services/diagnostics.ts +18 -0
  32. package/src/packlets/spaces/spaces-service.ts +1 -1
  33. package/src/packlets/testing/invitation-utils.ts +2 -10
  34. package/src/version.ts +1 -1
  35. package/dist/lib/browser/chunk-OZ4IMR73.mjs.map +0 -7
  36. package/dist/lib/node/chunk-46ZYQFO5.cjs.map +0 -7
@@ -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,
@@ -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.c8e9429";
2566
+ var DXOS_VERSION = "0.3.11-main.cc2fe2c";
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";
@@ -2562,7 +2582,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
2562
2582
  {
2563
2583
  invariant9(clientServices.LoggingService, "SystemService is not available.", {
2564
2584
  F: __dxlog_file10,
2565
- L: 92,
2585
+ L: 93,
2566
2586
  S: void 0,
2567
2587
  A: [
2568
2588
  "clientServices.LoggingService",
@@ -2573,6 +2593,21 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
2573
2593
  timeout: DEFAULT_TIMEOUT
2574
2594
  }).catch(() => void 0);
2575
2595
  }
2596
+ if (typeof navigator !== "undefined" && navigator.storage) {
2597
+ const map = /* @__PURE__ */ new Map();
2598
+ const dir = await navigator.storage.getDirectory();
2599
+ for await (const filename of dir?.keys()) {
2600
+ const idx = filename.indexOf("-", filename.indexOf("-") + 1);
2601
+ if (idx === -1) {
2602
+ continue;
2603
+ }
2604
+ map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
2605
+ }
2606
+ diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
2607
+ file,
2608
+ count
2609
+ }));
2610
+ }
2576
2611
  const identity = serviceContext.identityManager.identity;
2577
2612
  if (identity) {
2578
2613
  diagnostics.identity = {
@@ -2613,7 +2648,7 @@ var getProperties = (space) => {
2613
2648
  } catch (err) {
2614
2649
  log8.warn(err.message, void 0, {
2615
2650
  F: __dxlog_file10,
2616
- L: 160,
2651
+ L: 178,
2617
2652
  S: void 0,
2618
2653
  C: (f, a) => f(...a)
2619
2654
  });
@@ -3814,7 +3849,7 @@ var SpacesServiceImpl = class {
3814
3849
  }
3815
3850
  async createSpace() {
3816
3851
  if (!this._identityManager.identity) {
3817
- throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
3852
+ throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
3818
3853
  }
3819
3854
  const dataSpaceManager = await this._getDataSpaceManager();
3820
3855
  const space = await dataSpaceManager.createSpace();
@@ -5187,4 +5222,4 @@ export {
5187
5222
  createDefaultModelFactory,
5188
5223
  ClientServicesHost
5189
5224
  };
5190
- //# sourceMappingURL=chunk-OZ4IMR73.mjs.map
5225
+ //# sourceMappingURL=chunk-RGWEY4Z2.mjs.map