@dxos/client-services 0.1.53-main.75474bf → 0.1.53-main.8f662cd

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 (45) hide show
  1. package/dist/lib/browser/{chunk-6ITWCQIT.mjs → chunk-O5T3BZYP.mjs} +83 -76
  2. package/dist/lib/browser/chunk-O5T3BZYP.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +8 -37
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +6 -6
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +88 -112
  9. package/dist/lib/node/index.cjs.map +3 -3
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +86 -81
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/services/service-host.d.ts +1 -0
  14. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  15. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  16. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  17. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
  18. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  19. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +1 -1
  20. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
  21. package/dist/types/src/packlets/vault/shell-runtime.d.ts +1 -21
  22. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
  23. package/package.json +33 -32
  24. package/src/packlets/identity/identity-manager.test.ts +1 -1
  25. package/src/packlets/identity/identity-manager.ts +8 -8
  26. package/src/packlets/identity/identity-service.ts +2 -2
  27. package/src/packlets/identity/identity.test.ts +1 -1
  28. package/src/packlets/identity/identity.ts +2 -2
  29. package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
  30. package/src/packlets/invitations/invitation-extension.ts +5 -5
  31. package/src/packlets/invitations/invitations-handler.ts +6 -6
  32. package/src/packlets/invitations/invitations-service.ts +3 -3
  33. package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
  34. package/src/packlets/locks/node.ts +2 -2
  35. package/src/packlets/services/service-context.ts +3 -3
  36. package/src/packlets/services/service-host.ts +16 -9
  37. package/src/packlets/spaces/data-space-manager.ts +5 -6
  38. package/src/packlets/spaces/notarization-plugin.ts +4 -4
  39. package/src/packlets/testing/invitation-utils.ts +2 -2
  40. package/src/packlets/testing/test-builder.ts +1 -2
  41. package/src/packlets/vault/iframe-host-runtime.ts +2 -2
  42. package/src/packlets/vault/iframe-proxy-runtime.ts +2 -2
  43. package/src/packlets/vault/shell-runtime.ts +3 -49
  44. package/src/packlets/vault/worker-session.ts +2 -2
  45. package/dist/lib/browser/chunk-6ITWCQIT.mjs.map +0 -7
@@ -44,7 +44,6 @@ __export(src_exports, {
44
44
  InvitationsHandler: () => InvitationsHandler,
45
45
  InvitationsServiceImpl: () => InvitationsServiceImpl,
46
46
  Lock: () => Lock,
47
- MemoryShellRuntime: () => MemoryShellRuntime,
48
47
  ServiceContext: () => ServiceContext,
49
48
  ServiceRegistry: () => ServiceRegistry,
50
49
  ShellRuntimeImpl: () => ShellRuntimeImpl,
@@ -54,6 +53,7 @@ __export(src_exports, {
54
53
  WorkerRuntime: () => WorkerRuntime,
55
54
  WorkerSession: () => WorkerSession,
56
55
  createAuthProvider: () => createAuthProvider,
56
+ createDefaultModelFactory: () => createDefaultModelFactory,
57
57
  createStorageObjects: () => createStorageObjects,
58
58
  getNetworkPeers: () => getNetworkPeers,
59
59
  isLocked: () => isLocked,
@@ -528,7 +528,7 @@ var TrustedKeySetAuthVerifier = class {
528
528
  };
529
529
 
530
530
  // packages/sdk/client-services/src/packlets/identity/identity.ts
531
- var import_node_assert = __toESM(require("node:assert"));
531
+ var import_tiny_invariant = __toESM(require("tiny-invariant"));
532
532
  var import_async5 = require("@dxos/async");
533
533
  var import_client_protocol = require("@dxos/client-protocol");
534
534
  var import_credentials2 = require("@dxos/credentials");
@@ -610,7 +610,7 @@ var Identity = class {
610
610
  * Requires identity to be ready.
611
611
  */
612
612
  getIdentityCredentialSigner() {
613
- (0, import_node_assert.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
613
+ (0, import_tiny_invariant.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
614
614
  return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
615
615
  }
616
616
  /**
@@ -671,7 +671,7 @@ var Identity = class {
671
671
  };
672
672
 
673
673
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
674
- var import_node_assert2 = __toESM(require("node:assert"));
674
+ var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
675
675
  var import_async6 = require("@dxos/async");
676
676
  var import_credentials4 = require("@dxos/credentials");
677
677
  var import_keys4 = require("@dxos/keys");
@@ -743,7 +743,7 @@ var IdentityManager = class {
743
743
  }
744
744
  async createIdentity({ displayName } = {}) {
745
745
  var _a;
746
- (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
746
+ (0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
747
747
  (0, import_log3.log)("creating identity...", {}, {
748
748
  file: "identity-manager.ts",
749
749
  line: 94,
@@ -765,8 +765,8 @@ var IdentityManager = class {
765
765
  await identity.open();
766
766
  {
767
767
  const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
768
- (0, import_node_assert2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
769
- (0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
768
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
769
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
770
770
  const credentials = [
771
771
  // Space genesis.
772
772
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
@@ -824,7 +824,7 @@ var IdentityManager = class {
824
824
  scope: this,
825
825
  callSite: (f, a) => f(...a)
826
826
  });
827
- (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
827
+ (0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
828
828
  const identityRecord = {
829
829
  identityKey: params.identityKey,
830
830
  deviceKey: params.deviceKey,
@@ -863,7 +863,7 @@ var IdentityManager = class {
863
863
  return identity;
864
864
  }
865
865
  async _constructIdentity(identityRecord) {
866
- (0, import_node_assert2.default)(!this._identity);
866
+ (0, import_tiny_invariant2.default)(!this._identity);
867
867
  (0, import_log3.log)("constructing identity", {
868
868
  identityRecord
869
869
  }, {
@@ -872,11 +872,11 @@ var IdentityManager = class {
872
872
  scope: this,
873
873
  callSite: (f, a) => f(...a)
874
874
  });
875
- (0, import_node_assert2.default)(identityRecord.haloSpace.controlFeedKey);
875
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.controlFeedKey);
876
876
  const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
877
877
  writable: true
878
878
  });
879
- (0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey);
879
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey);
880
880
  const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
881
881
  writable: true,
882
882
  sparse: true
@@ -934,7 +934,7 @@ var IdentityManager = class {
934
934
  };
935
935
 
936
936
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
937
- var import_node_assert3 = __toESM(require("node:assert"));
937
+ var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
938
938
  var import_codec_protobuf7 = require("@dxos/codec-protobuf");
939
939
  var import_credentials6 = require("@dxos/credentials");
940
940
  var import_debug2 = require("@dxos/debug");
@@ -970,7 +970,7 @@ var IdentityServiceImpl = class {
970
970
  };
971
971
  }
972
972
  async signPresentation({ presentation, nonce }) {
973
- (0, import_node_assert3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
973
+ (0, import_tiny_invariant3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
974
974
  return await (0, import_credentials6.signPresentation)({
975
975
  presentation,
976
976
  signer: this._serviceContext.keyring,
@@ -982,7 +982,7 @@ var IdentityServiceImpl = class {
982
982
  };
983
983
 
984
984
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
985
- var import_node_assert4 = __toESM(require("node:assert"));
985
+ var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
986
986
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
987
987
  var DeviceInvitationProtocol = class {
988
988
  constructor(_keyring, _getIdentity, _acceptIdentity) {
@@ -999,7 +999,7 @@ var DeviceInvitationProtocol = class {
999
999
  };
1000
1000
  }
1001
1001
  async admit(request) {
1002
- (0, import_node_assert4.default)(request.device);
1002
+ (0, import_tiny_invariant4.default)(request.device);
1003
1003
  const identity = this._getIdentity();
1004
1004
  await identity.admitDevice(request.device);
1005
1005
  return {
@@ -1027,9 +1027,9 @@ var DeviceInvitationProtocol = class {
1027
1027
  };
1028
1028
  }
1029
1029
  async accept(response, request) {
1030
- (0, import_node_assert4.default)(response.device);
1030
+ (0, import_tiny_invariant4.default)(response.device);
1031
1031
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1032
- (0, import_node_assert4.default)(request.device);
1032
+ (0, import_tiny_invariant4.default)(request.device);
1033
1033
  const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
1034
1034
  await this._acceptIdentity({
1035
1035
  identityKey,
@@ -1047,7 +1047,7 @@ var DeviceInvitationProtocol = class {
1047
1047
  };
1048
1048
 
1049
1049
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1050
- var import_node_assert6 = __toESM(require("node:assert"));
1050
+ var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
1051
1051
  var import_async8 = require("@dxos/async");
1052
1052
  var import_client_protocol2 = require("@dxos/client-protocol");
1053
1053
  var import_context4 = require("@dxos/context");
@@ -1061,7 +1061,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
1061
1061
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
1062
1062
 
1063
1063
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
1064
- var import_node_assert5 = __toESM(require("node:assert"));
1064
+ var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
1065
1065
  var import_async7 = require("@dxos/async");
1066
1066
  var import_context3 = require("@dxos/context");
1067
1067
  var import_errors = require("@dxos/errors");
@@ -1098,7 +1098,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1098
1098
  // Perhaps in the future we will have more complex logic here.
1099
1099
  InvitationHostService: {
1100
1100
  options: async (options) => {
1101
- (0, import_node_assert5.default)(!this._remoteOptions, "Remote options already set.");
1101
+ (0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
1102
1102
  this._remoteOptions = options;
1103
1103
  this._remoteOptionsTrigger.wake();
1104
1104
  },
@@ -1174,7 +1174,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1174
1174
  callSite: (f, a) => f(...a)
1175
1175
  });
1176
1176
  let status = import_invitations.AuthenticationResponse.Status.OK;
1177
- (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
1177
+ (0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
1178
1178
  switch (this.invitation.authMethod) {
1179
1179
  case import_services2.Invitation.AuthMethod.NONE: {
1180
1180
  (0, import_log4.log)("authentication not required", {}, {
@@ -1238,7 +1238,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1238
1238
  callSite: (f, a) => f(...a)
1239
1239
  });
1240
1240
  try {
1241
- (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
1241
+ (0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
1242
1242
  if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
1243
1243
  throw new Error("Not authenticated");
1244
1244
  }
@@ -1303,7 +1303,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1303
1303
  return {
1304
1304
  InvitationHostService: {
1305
1305
  options: async (options) => {
1306
- (0, import_node_assert5.default)(!this._remoteOptions, "Remote options already set.");
1306
+ (0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
1307
1307
  this._remoteOptions = options;
1308
1308
  this._remoteOptionsTrigger.wake();
1309
1309
  },
@@ -1382,7 +1382,7 @@ var InvitationsHandler = class {
1382
1382
  var _a;
1383
1383
  const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys6.PublicKey.random() } = options != null ? options : {};
1384
1384
  const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1385
- (0, import_node_assert6.default)(protocol);
1385
+ (0, import_tiny_invariant6.default)(protocol);
1386
1386
  const invitation = {
1387
1387
  invitationId,
1388
1388
  type,
@@ -1429,7 +1429,7 @@ var InvitationsHandler = class {
1429
1429
  var _a2, _b, _c;
1430
1430
  try {
1431
1431
  const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1432
- (0, import_node_assert6.default)(deviceKey);
1432
+ (0, import_tiny_invariant6.default)(deviceKey);
1433
1433
  const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1434
1434
  extension.completedTrigger.wake(deviceKey);
1435
1435
  return admissionResponse;
@@ -1588,13 +1588,13 @@ var InvitationsHandler = class {
1588
1588
  }
1589
1589
  acceptInvitation(protocol, invitation) {
1590
1590
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
1591
- (0, import_node_assert6.default)(protocol);
1591
+ (0, import_tiny_invariant6.default)(protocol);
1592
1592
  const authenticated = new import_async8.Trigger();
1593
1593
  let admitted = false;
1594
1594
  let currentState;
1595
1595
  const stream = new import_async8.PushStream();
1596
1596
  const setState = (newData) => {
1597
- (0, import_node_assert6.default)(newData.state !== void 0);
1597
+ (0, import_tiny_invariant6.default)(newData.state !== void 0);
1598
1598
  currentState = newData.state;
1599
1599
  stream.next({
1600
1600
  ...invitation,
@@ -1851,7 +1851,7 @@ var InvitationsHandler = class {
1851
1851
  return extension;
1852
1852
  };
1853
1853
  (0, import_async8.scheduleTask)(ctx, async () => {
1854
- (0, import_node_assert6.default)(invitation.swarmKey);
1854
+ (0, import_tiny_invariant6.default)(invitation.swarmKey);
1855
1855
  const topic = invitation.swarmKey;
1856
1856
  const swarmConnection = await this._networkManager.joinSwarm({
1857
1857
  topic,
@@ -1884,7 +1884,7 @@ var InvitationsHandler = class {
1884
1884
  };
1885
1885
 
1886
1886
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1887
- var import_node_assert7 = __toESM(require("node:assert"));
1887
+ var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
1888
1888
  var import_async9 = require("@dxos/async");
1889
1889
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
1890
1890
  var import_log6 = require("@dxos/log");
@@ -1955,7 +1955,7 @@ var InvitationsServiceImpl = class {
1955
1955
  scope: this,
1956
1956
  callSite: (f, a) => f(...a)
1957
1957
  });
1958
- (0, import_node_assert7.default)(invitationId);
1958
+ (0, import_tiny_invariant7.default)(invitationId);
1959
1959
  const observable = this._acceptInvitations.get(invitationId);
1960
1960
  if (!observable) {
1961
1961
  import_log6.log.warn("invalid invitation", {
@@ -1977,7 +1977,7 @@ var InvitationsServiceImpl = class {
1977
1977
  scope: this,
1978
1978
  callSite: (f, a) => f(...a)
1979
1979
  });
1980
- (0, import_node_assert7.default)(invitationId);
1980
+ (0, import_tiny_invariant7.default)(invitationId);
1981
1981
  const created = this._createInvitations.get(invitationId);
1982
1982
  const accepted = this._acceptInvitations.get(invitationId);
1983
1983
  if (created) {
@@ -2052,7 +2052,7 @@ var InvitationsServiceImpl = class {
2052
2052
  };
2053
2053
 
2054
2054
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
2055
- var import_node_assert8 = __toESM(require("node:assert"));
2055
+ var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
2056
2056
  var import_credentials8 = require("@dxos/credentials");
2057
2057
  var import_feed_store3 = require("@dxos/feed-store");
2058
2058
  var import_log7 = require("@dxos/log");
@@ -2078,10 +2078,10 @@ var SpaceInvitationProtocol = class {
2078
2078
  }
2079
2079
  async admit(request, guestProfile) {
2080
2080
  var _a;
2081
- (0, import_node_assert8.default)(this._spaceKey);
2081
+ (0, import_tiny_invariant8.default)(this._spaceKey);
2082
2082
  const space = await this._spaceManager.spaces.get(this._spaceKey);
2083
- (0, import_node_assert8.default)(space);
2084
- (0, import_node_assert8.default)(request.space);
2083
+ (0, import_tiny_invariant8.default)(space);
2084
+ (0, import_tiny_invariant8.default)(request.space);
2085
2085
  const { identityKey, deviceKey } = request.space;
2086
2086
  (0, import_log7.log)("writing guest credentials", {
2087
2087
  host: this._signingContext.deviceKey,
@@ -2093,9 +2093,9 @@ var SpaceInvitationProtocol = class {
2093
2093
  callSite: (f, a) => f(...a)
2094
2094
  });
2095
2095
  const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
2096
- (0, import_node_assert8.default)(credentials[0].credential);
2096
+ (0, import_tiny_invariant8.default)(credentials[0].credential);
2097
2097
  const spaceMemberCredential = credentials[0].credential.credential;
2098
- (0, import_node_assert8.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2098
+ (0, import_tiny_invariant8.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2099
2099
  await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
2100
2100
  return {
2101
2101
  space: {
@@ -2123,11 +2123,11 @@ var SpaceInvitationProtocol = class {
2123
2123
  };
2124
2124
  }
2125
2125
  async accept(response) {
2126
- (0, import_node_assert8.default)(response.space);
2126
+ (0, import_tiny_invariant8.default)(response.space);
2127
2127
  const { credential, controlTimeframe, dataTimeframe } = response.space;
2128
2128
  const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
2129
- (0, import_node_assert8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2130
- (0, import_node_assert8.default)(credential.subject.id.equals(this._signingContext.identityKey));
2129
+ (0, import_tiny_invariant8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2130
+ (0, import_tiny_invariant8.default)(credential.subject.id.equals(this._signingContext.identityKey));
2131
2131
  await this._spaceManager.acceptSpace({
2132
2132
  spaceKey: assertion.spaceKey,
2133
2133
  genesisFeedKey: assertion.genesisFeedKey,
@@ -2142,7 +2142,7 @@ var SpaceInvitationProtocol = class {
2142
2142
  };
2143
2143
 
2144
2144
  // packages/sdk/client-services/src/packlets/services/service-context.ts
2145
- var import_node_assert11 = __toESM(require("node:assert"));
2145
+ var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
2146
2146
  var import_async14 = require("@dxos/async");
2147
2147
  var import_credentials13 = require("@dxos/credentials");
2148
2148
  var import_debug6 = require("@dxos/debug");
@@ -2156,7 +2156,7 @@ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
2156
2156
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
2157
2157
 
2158
2158
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2159
- var import_node_assert10 = __toESM(require("node:assert"));
2159
+ var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
2160
2160
  var import_async12 = require("@dxos/async");
2161
2161
  var import_context7 = require("@dxos/context");
2162
2162
  var import_credentials12 = require("@dxos/credentials");
@@ -2182,7 +2182,7 @@ var import_timeframe = require("@dxos/timeframe");
2182
2182
  var import_util4 = require("@dxos/util");
2183
2183
 
2184
2184
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2185
- var import_node_assert9 = __toESM(require("node:assert"));
2185
+ var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
2186
2186
  var import_async10 = require("@dxos/async");
2187
2187
  var import_context5 = require("@dxos/context");
2188
2188
  var import_keys7 = require("@dxos/keys");
@@ -2219,7 +2219,7 @@ var NotarizationPlugin = class {
2219
2219
  scope: this,
2220
2220
  callSite: (f, a) => f(...a)
2221
2221
  });
2222
- (0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2222
+ (0, import_tiny_invariant9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2223
2223
  const errors = new import_async10.Trigger();
2224
2224
  const ctx = this._ctx.derive({
2225
2225
  onError: (err) => {
@@ -2337,7 +2337,7 @@ var NotarizationPlugin = class {
2337
2337
  this._processCredentialsTriggers.delete(credential.id);
2338
2338
  }
2339
2339
  setWriter(writer) {
2340
- (0, import_node_assert9.default)(!this._writer, "Writer already set.");
2340
+ (0, import_tiny_invariant9.default)(!this._writer, "Writer already set.");
2341
2341
  this._writer = writer;
2342
2342
  }
2343
2343
  async _waitUntilProcessed(id) {
@@ -2355,7 +2355,7 @@ var NotarizationPlugin = class {
2355
2355
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2356
2356
  }
2357
2357
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2358
- (0, import_node_assert9.default)(credential.id, "Credential must have an id");
2358
+ (0, import_tiny_invariant9.default)(credential.id, "Credential must have an id");
2359
2359
  if (this._processedCredentials.has(credential.id)) {
2360
2360
  continue;
2361
2361
  }
@@ -2844,7 +2844,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2844
2844
  * Creates a new space writing the genesis credentials to the control feed.
2845
2845
  */
2846
2846
  async createSpace() {
2847
- (0, import_node_assert10.default)(this._isOpen, "Not open.");
2847
+ (0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
2848
2848
  const spaceKey = await this._keyring.createKey();
2849
2849
  const controlFeedKey = await this._keyring.createKey();
2850
2850
  const dataFeedKey = await this._keyring.createKey();
@@ -2866,7 +2866,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2866
2866
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
2867
2867
  await this._metadataStore.addSpace(metadata);
2868
2868
  const memberCredential = credentials[1];
2869
- (0, import_node_assert10.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2869
+ (0, import_tiny_invariant10.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2870
2870
  await this._signingContext.recordCredential(memberCredential);
2871
2871
  await space.initializeDataPipeline();
2872
2872
  this.updated.emit();
@@ -2882,8 +2882,8 @@ var DataSpaceManager = class DataSpaceManager2 {
2882
2882
  scope: this,
2883
2883
  callSite: (f, a) => f(...a)
2884
2884
  });
2885
- (0, import_node_assert10.default)(this._isOpen, "Not open.");
2886
- (0, import_node_assert10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2885
+ (0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
2886
+ (0, import_tiny_invariant10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2887
2887
  const metadata = {
2888
2888
  key: opts.spaceKey,
2889
2889
  genesisFeedKey: opts.genesisFeedKey,
@@ -2912,7 +2912,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2912
2912
  metadata
2913
2913
  }, {
2914
2914
  file: "data-space-manager.ts",
2915
- line: 181,
2915
+ line: 180,
2916
2916
  scope: this,
2917
2917
  callSite: (f, a) => f(...a)
2918
2918
  });
@@ -2948,7 +2948,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2948
2948
  onAuthFailure: () => {
2949
2949
  import_log10.log.warn("auth failure", {}, {
2950
2950
  file: "data-space-manager.ts",
2951
- line: 212,
2951
+ line: 211,
2952
2952
  scope: this,
2953
2953
  callSite: (f, a) => f(...a)
2954
2954
  });
@@ -2971,7 +2971,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2971
2971
  space: space.key
2972
2972
  }, {
2973
2973
  file: "data-space-manager.ts",
2974
- line: 229,
2974
+ line: 228,
2975
2975
  scope: this,
2976
2976
  callSite: (f, a) => f(...a)
2977
2977
  });
@@ -2983,7 +2983,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2983
2983
  open: this._isOpen
2984
2984
  }, {
2985
2985
  file: "data-space-manager.ts",
2986
- line: 236,
2986
+ line: 235,
2987
2987
  scope: this,
2988
2988
  callSite: (f, a) => f(...a)
2989
2989
  });
@@ -3293,7 +3293,7 @@ var ServiceContext = class {
3293
3293
  }
3294
3294
  getInvitationHandler(invitation) {
3295
3295
  const factory = this._handlerFactories.get(invitation.kind);
3296
- (0, import_node_assert11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3296
+ (0, import_tiny_invariant11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3297
3297
  return factory(invitation);
3298
3298
  }
3299
3299
  async _acceptIdentity(params) {
@@ -3333,7 +3333,7 @@ var ServiceContext = class {
3333
3333
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3334
3334
  await this.dataSpaceManager.open();
3335
3335
  this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
3336
- (0, import_node_assert11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3336
+ (0, import_tiny_invariant11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3337
3337
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
3338
3338
  });
3339
3339
  this.initialized.wake();
@@ -3396,16 +3396,19 @@ var ServiceContext = class {
3396
3396
  };
3397
3397
 
3398
3398
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3399
- var import_node_assert13 = __toESM(require("node:assert"));
3399
+ var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
3400
3400
  var import_async17 = require("@dxos/async");
3401
3401
  var import_client_protocol5 = require("@dxos/client-protocol");
3402
+ var import_document_model = require("@dxos/document-model");
3402
3403
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3403
3404
  var import_keys11 = require("@dxos/keys");
3404
3405
  var import_log15 = require("@dxos/log");
3405
3406
  var import_messaging = require("@dxos/messaging");
3407
+ var import_model_factory = require("@dxos/model-factory");
3406
3408
  var import_network_manager2 = require("@dxos/network-manager");
3407
3409
  var import_protocols9 = require("@dxos/protocols");
3408
3410
  var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3411
+ var import_text_model = require("@dxos/text-model");
3409
3412
 
3410
3413
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3411
3414
  var import_async15 = require("@dxos/async");
@@ -3455,7 +3458,7 @@ var DevicesServiceImpl = class {
3455
3458
  };
3456
3459
 
3457
3460
  // packages/sdk/client-services/src/packlets/locks/node.ts
3458
- var import_node_assert12 = __toESM(require("node:assert"));
3461
+ var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
3459
3462
  var import_lock_file = require("@dxos/lock-file");
3460
3463
  var import_log13 = require("@dxos/log");
3461
3464
  var __decorate3 = function(decorators, target, key, desc) {
@@ -3497,7 +3500,7 @@ var Lock = class {
3497
3500
  async release() {
3498
3501
  var _a;
3499
3502
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3500
- (0, import_node_assert12.default)(this._fileHandle, "Lock is not acquired");
3503
+ (0, import_tiny_invariant12.default)(this._fileHandle, "Lock is not acquired");
3501
3504
  await import_lock_file.LockFile.release(this._fileHandle);
3502
3505
  }
3503
3506
  };
@@ -3736,10 +3739,13 @@ var __decorate4 = function(decorators, target, key, desc) {
3736
3739
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3737
3740
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3738
3741
  };
3742
+ var createDefaultModelFactory = () => {
3743
+ return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
3744
+ };
3739
3745
  var ClientServicesHost = class {
3740
3746
  constructor({
3741
3747
  config,
3742
- modelFactory = (0, import_client_protocol5.createDefaultModelFactory)(),
3748
+ modelFactory = createDefaultModelFactory(),
3743
3749
  // TODO(burdon): Create ApolloLink abstraction (see Client).
3744
3750
  transportFactory,
3745
3751
  signalManager,
@@ -3811,9 +3817,9 @@ var ClientServicesHost = class {
3811
3817
  */
3812
3818
  initialize({ config, ...options }) {
3813
3819
  var _a, _b, _c;
3814
- (0, import_node_assert13.default)(!this._open, "service host is open");
3820
+ (0, import_tiny_invariant13.default)(!this._open, "service host is open");
3815
3821
  if (config) {
3816
- (0, import_node_assert13.default)(!this._config, "config already set");
3822
+ (0, import_tiny_invariant13.default)(!this._config, "config already set");
3817
3823
  this._config = config;
3818
3824
  if (!this._storage) {
3819
3825
  this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
@@ -3823,7 +3829,7 @@ var ClientServicesHost = class {
3823
3829
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
3824
3830
  }), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
3825
3831
  this._signalManager = signalManager;
3826
- (0, import_node_assert13.default)(!this._networkManager, "network manager already set");
3832
+ (0, import_tiny_invariant13.default)(!this._networkManager, "network manager already set");
3827
3833
  this._networkManager = new import_network_manager2.NetworkManager({
3828
3834
  log: connectionLog,
3829
3835
  transportFactory,
@@ -3840,20 +3846,20 @@ var ClientServicesHost = class {
3840
3846
  id: traceId
3841
3847
  }), {
3842
3848
  file: "service-host.ts",
3843
- line: 188,
3849
+ line: 195,
3844
3850
  scope: this,
3845
3851
  callSite: (f, a) => f(...a)
3846
3852
  });
3847
- (0, import_node_assert13.default)(this._config, "config not set");
3848
- (0, import_node_assert13.default)(this._storage, "storage not set");
3849
- (0, import_node_assert13.default)(this._signalManager, "signal manager not set");
3850
- (0, import_node_assert13.default)(this._networkManager, "network manager not set");
3853
+ (0, import_tiny_invariant13.default)(this._config, "config not set");
3854
+ (0, import_tiny_invariant13.default)(this._storage, "storage not set");
3855
+ (0, import_tiny_invariant13.default)(this._signalManager, "signal manager not set");
3856
+ (0, import_tiny_invariant13.default)(this._networkManager, "network manager not set");
3851
3857
  this._opening = true;
3852
3858
  (0, import_log15.log)("opening...", {
3853
3859
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
3854
3860
  }, {
3855
3861
  file: "service-host.ts",
3856
- line: 196,
3862
+ line: 203,
3857
3863
  scope: this,
3858
3864
  callSite: (f, a) => f(...a)
3859
3865
  });
@@ -3888,7 +3894,7 @@ var ClientServicesHost = class {
3888
3894
  deviceKey
3889
3895
  }, {
3890
3896
  file: "service-host.ts",
3891
- line: 251,
3897
+ line: 258,
3892
3898
  scope: this,
3893
3899
  callSite: (f, a) => f(...a)
3894
3900
  });
@@ -3896,7 +3902,7 @@ var ClientServicesHost = class {
3896
3902
  id: traceId
3897
3903
  }), {
3898
3904
  file: "service-host.ts",
3899
- line: 252,
3905
+ line: 259,
3900
3906
  scope: this,
3901
3907
  callSite: (f, a) => f(...a)
3902
3908
  });
@@ -3911,7 +3917,7 @@ var ClientServicesHost = class {
3911
3917
  deviceKey
3912
3918
  }, {
3913
3919
  file: "service-host.ts",
3914
- line: 262,
3920
+ line: 269,
3915
3921
  scope: this,
3916
3922
  callSite: (f, a) => f(...a)
3917
3923
  });
@@ -3926,7 +3932,7 @@ var ClientServicesHost = class {
3926
3932
  deviceKey
3927
3933
  }, {
3928
3934
  file: "service-host.ts",
3929
- line: 268,
3935
+ line: 275,
3930
3936
  scope: this,
3931
3937
  callSite: (f, a) => f(...a)
3932
3938
  });
@@ -3938,13 +3944,13 @@ var ClientServicesHost = class {
3938
3944
  id: traceId
3939
3945
  }), {
3940
3946
  file: "service-host.ts",
3941
- line: 273,
3947
+ line: 280,
3942
3948
  scope: this,
3943
3949
  callSite: (f, a) => f(...a)
3944
3950
  });
3945
3951
  (0, import_log15.log)("resetting...", {}, {
3946
3952
  file: "service-host.ts",
3947
- line: 275,
3953
+ line: 282,
3948
3954
  scope: this,
3949
3955
  callSite: (f, a) => f(...a)
3950
3956
  });
@@ -3952,7 +3958,7 @@ var ClientServicesHost = class {
3952
3958
  await this._storage.reset();
3953
3959
  (0, import_log15.log)("reset", {}, {
3954
3960
  file: "service-host.ts",
3955
- line: 278,
3961
+ line: 285,
3956
3962
  scope: this,
3957
3963
  callSite: (f, a) => f(...a)
3958
3964
  });
@@ -3960,7 +3966,7 @@ var ClientServicesHost = class {
3960
3966
  id: traceId
3961
3967
  }), {
3962
3968
  file: "service-host.ts",
3963
- line: 279,
3969
+ line: 286,
3964
3970
  scope: this,
3965
3971
  callSite: (f, a) => f(...a)
3966
3972
  });
@@ -4035,7 +4041,7 @@ var ClientRpcServer = class {
4035
4041
  };
4036
4042
 
4037
4043
  // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
4038
- var import_node_assert14 = __toESM(require("node:assert"));
4044
+ var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
4039
4045
  var import_async18 = require("@dxos/async");
4040
4046
  var import_client_protocol6 = require("@dxos/client-protocol");
4041
4047
  var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
@@ -4065,7 +4071,7 @@ var ShellRuntimeImpl = class {
4065
4071
  });
4066
4072
  }
4067
4073
  async setAppContext(context) {
4068
- (0, import_node_assert14.default)(this._appRpc, "runtime not open");
4074
+ (0, import_tiny_invariant14.default)(this._appRpc, "runtime not open");
4069
4075
  await this._appRpc.rpc.AppService.setContext(context);
4070
4076
  }
4071
4077
  async open() {
@@ -4092,36 +4098,6 @@ var ShellRuntimeImpl = class {
4092
4098
  this._appRpc = void 0;
4093
4099
  }
4094
4100
  };
4095
- var MemoryShellRuntime = class {
4096
- constructor({ layout, invitationCode, spaceKey } = {}) {
4097
- this.layoutUpdate = new import_async18.Event();
4098
- this.contextUpdate = new import_async18.Event();
4099
- this._layout = layout != null ? layout : import_iframe.ShellLayout.DEFAULT;
4100
- this._invitationCode = invitationCode;
4101
- this._spaceKey = spaceKey;
4102
- }
4103
- get layout() {
4104
- return this._layout;
4105
- }
4106
- get invitationCode() {
4107
- return this._invitationCode;
4108
- }
4109
- get spaceKey() {
4110
- return this._spaceKey;
4111
- }
4112
- setLayout(layout, options = {}) {
4113
- this._layout = layout;
4114
- this._invitationCode = options.invitationCode;
4115
- this._spaceKey = options.spaceKey;
4116
- this.layoutUpdate.emit({
4117
- layout,
4118
- ...options
4119
- });
4120
- }
4121
- async setAppContext(context) {
4122
- this.contextUpdate.emit(context);
4123
- }
4124
- };
4125
4101
 
4126
4102
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
4127
4103
  var __decorate5 = function(decorators, target, key, desc) {
@@ -4326,7 +4302,7 @@ var import_messaging3 = require("@dxos/messaging");
4326
4302
  var import_network_manager5 = require("@dxos/network-manager");
4327
4303
 
4328
4304
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
4329
- var import_node_assert15 = __toESM(require("node:assert"));
4305
+ var import_tiny_invariant15 = __toESM(require("tiny-invariant"));
4330
4306
  var import_async21 = require("@dxos/async");
4331
4307
  var import_client_protocol9 = require("@dxos/client-protocol");
4332
4308
  var import_log18 = require("@dxos/log");
@@ -4346,7 +4322,7 @@ var WorkerSession = class {
4346
4322
  constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
4347
4323
  this._startTrigger = new import_async21.Trigger();
4348
4324
  this.onClose = new import_util11.Callback();
4349
- (0, import_node_assert15.default)(serviceHost);
4325
+ (0, import_tiny_invariant15.default)(serviceHost);
4350
4326
  this._serviceHost = serviceHost;
4351
4327
  const middleware = {
4352
4328
  handleCall: async (method, params, handler) => {
@@ -4584,7 +4560,6 @@ var WorkerRuntime = class {
4584
4560
  InvitationsHandler,
4585
4561
  InvitationsServiceImpl,
4586
4562
  Lock,
4587
- MemoryShellRuntime,
4588
4563
  ServiceContext,
4589
4564
  ServiceRegistry,
4590
4565
  ShellRuntimeImpl,
@@ -4594,6 +4569,7 @@ var WorkerRuntime = class {
4594
4569
  WorkerRuntime,
4595
4570
  WorkerSession,
4596
4571
  createAuthProvider,
4572
+ createDefaultModelFactory,
4597
4573
  createStorageObjects,
4598
4574
  getNetworkPeers,
4599
4575
  isLocked,