@dxos/client-services 0.1.56-main.28af2e2 → 0.1.56-main.390ac2a

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 (73) hide show
  1. package/dist/lib/browser/{chunk-CSJSC47N.mjs → chunk-KSADD5WV.mjs} +978 -385
  2. package/dist/lib/browser/chunk-KSADD5WV.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +50 -31
  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 +12 -3
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +1121 -512
  9. package/dist/lib/node/index.cjs.map +4 -4
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +1268 -669
  12. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  14. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  16. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  17. package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  19. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  20. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  21. package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
  22. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  23. package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
  24. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
  25. package/dist/types/src/packlets/services/index.d.ts +1 -0
  26. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  27. package/dist/types/src/packlets/services/platform.d.ts +16 -0
  28. package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
  29. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  30. package/dist/types/src/packlets/services/service-host.d.ts +4 -2
  31. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  32. package/dist/types/src/packlets/services/util.d.ts +6 -0
  33. package/dist/types/src/packlets/services/util.d.ts.map +1 -0
  34. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  35. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  36. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  37. package/dist/types/src/packlets/system/system-service.d.ts +12 -2
  38. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  39. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  40. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
  41. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  42. package/dist/types/src/version.d.ts +2 -0
  43. package/dist/types/src/version.d.ts.map +1 -0
  44. package/package.json +33 -33
  45. package/src/packlets/identity/authenticator.test.ts +2 -2
  46. package/src/packlets/identity/identity-manager.ts +1 -2
  47. package/src/packlets/identity/identity-service.ts +1 -2
  48. package/src/packlets/identity/identity.ts +1 -2
  49. package/src/packlets/invitations/device-invitation-protocol.ts +1 -2
  50. package/src/packlets/invitations/invitation-extension.ts +1 -2
  51. package/src/packlets/invitations/invitations-handler.ts +1 -2
  52. package/src/packlets/invitations/invitations-service.ts +1 -2
  53. package/src/packlets/invitations/space-invitation-protocol.ts +1 -2
  54. package/src/packlets/locks/node.ts +1 -1
  55. package/src/packlets/logging/logging-service.ts +17 -9
  56. package/src/packlets/services/diagnostics.ts +211 -0
  57. package/src/packlets/services/index.ts +1 -0
  58. package/src/packlets/services/platform.ts +48 -0
  59. package/src/packlets/services/service-context.ts +3 -5
  60. package/src/packlets/services/service-host.test.ts +5 -5
  61. package/src/packlets/services/service-host.ts +23 -20
  62. package/src/packlets/services/service-registry.test.ts +1 -0
  63. package/src/packlets/services/util.ts +33 -0
  64. package/src/packlets/spaces/data-space-manager.ts +2 -3
  65. package/src/packlets/spaces/notarization-plugin.ts +1 -2
  66. package/src/packlets/spaces/spaces-service.ts +18 -12
  67. package/src/packlets/system/system-service.test.ts +1 -0
  68. package/src/packlets/system/system-service.ts +34 -2
  69. package/src/packlets/testing/invitation-utils.ts +1 -2
  70. package/src/packlets/vault/shell-runtime.ts +1 -2
  71. package/src/packlets/vault/worker-session.ts +7 -3
  72. package/src/version.ts +1 -0
  73. package/dist/lib/browser/chunk-CSJSC47N.mjs.map +0 -7
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // packages/sdk/client-services/src/packlets/testing/index.ts
@@ -61,37 +51,203 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
61
51
  });
62
52
 
63
53
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
64
- var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
65
54
  var import_async18 = require("@dxos/async");
66
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
55
+ var import_invariant15 = require("@dxos/invariant");
56
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
67
57
 
68
58
  // packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
69
59
  var import_codec_protobuf = require("@dxos/codec-protobuf");
70
60
  var import_debug = require("@dxos/debug");
71
61
  var import_rpc = require("@dxos/rpc");
72
62
 
63
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
64
+ var import_codec_protobuf2 = require("@dxos/codec-protobuf");
65
+ var import_credentials2 = require("@dxos/credentials");
66
+ var import_document_model = require("@dxos/document-model");
67
+ var import_invariant = require("@dxos/invariant");
68
+ var import_log = require("@dxos/log");
69
+ var import_protocols = require("@dxos/protocols");
70
+ var import_services = require("@dxos/protocols/proto/dxos/client/services");
71
+
72
+ // packages/sdk/client-services/src/version.ts
73
+ var DXOS_VERSION = "0.1.56-main.390ac2a";
74
+
75
+ // packages/sdk/client-services/src/packlets/services/platform.ts
76
+ var getPlatform = () => {
77
+ if (process.browser) {
78
+ if (typeof window !== "undefined") {
79
+ const { userAgent } = window.navigator;
80
+ return {
81
+ type: "browser",
82
+ userAgent,
83
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
84
+ };
85
+ } else {
86
+ return {
87
+ type: "shared-worker",
88
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
89
+ };
90
+ }
91
+ } else {
92
+ const { platform, version, arch } = process;
93
+ return {
94
+ type: "node",
95
+ platform: `${platform} ${version} ${arch}`,
96
+ runtime: process.version,
97
+ uptime: Math.floor(process.uptime()),
98
+ memory: process.memoryUsage()
99
+ };
100
+ }
101
+ };
102
+
103
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
104
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
105
+ var DEFAULT_TIMEOUT = 1e3;
106
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
107
+ var _a, _b, _c;
108
+ const diagnostics = {
109
+ created: new Date().toISOString(),
110
+ platform: getPlatform(),
111
+ client: {
112
+ version: DXOS_VERSION,
113
+ storage: {
114
+ version: import_protocols.STORAGE_VERSION
115
+ }
116
+ }
117
+ };
118
+ {
119
+ (0, import_invariant.invariant)(clientServices.LoggingService, "SystemService is not available.", {
120
+ F: __dxlog_file,
121
+ L: 87,
122
+ S: void 0,
123
+ A: [
124
+ "clientServices.LoggingService",
125
+ "'SystemService is not available.'"
126
+ ]
127
+ });
128
+ diagnostics.metrics = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
129
+ timeout: DEFAULT_TIMEOUT
130
+ }).catch(() => void 0);
131
+ }
132
+ const identity = serviceContext.identityManager.identity;
133
+ if (identity) {
134
+ diagnostics.identity = {
135
+ identityKey: identity.identityKey,
136
+ spaceKey: identity.space.key,
137
+ profile: identity.profileDocument
138
+ };
139
+ const { devices } = (_a = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
140
+ timeout: DEFAULT_TIMEOUT
141
+ }).catch(() => void 0)) != null ? _a : {};
142
+ diagnostics.devices = devices;
143
+ if (serviceContext.dataSpaceManager) {
144
+ diagnostics.spaces = await Promise.all((_b = Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space))) != null ? _b : []);
145
+ }
146
+ const { feeds = [] } = (_c = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
147
+ timeout: DEFAULT_TIMEOUT
148
+ }).catch(() => void 0)) != null ? _c : {};
149
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
150
+ feedKey,
151
+ bytes,
152
+ length
153
+ }));
154
+ }
155
+ diagnostics.config = config.values;
156
+ return diagnostics;
157
+ };
158
+ var getProperties = (space) => {
159
+ let properties = {};
160
+ try {
161
+ const propertiesItem = space.dataPipeline.itemManager.items.find((item) => {
162
+ var _a, _b;
163
+ return ((_a = item.modelMeta) == null ? void 0 : _a.type) === import_document_model.DocumentModel.meta.type && ((_b = item.state) == null ? void 0 : _b.type) === "dxos.sdk.client.Properties";
164
+ });
165
+ const state = propertiesItem == null ? void 0 : propertiesItem.state;
166
+ properties = state == null ? void 0 : state.data;
167
+ } catch (err) {
168
+ import_log.log.warn(err.message, void 0, {
169
+ F: __dxlog_file,
170
+ L: 144,
171
+ S: void 0,
172
+ C: (f, a) => f(...a)
173
+ });
174
+ }
175
+ return properties;
176
+ };
177
+ var getSpaceStats = async (space) => {
178
+ var _a, _b, _c, _d, _e, _f;
179
+ const stats = {
180
+ key: space.key,
181
+ metrics: space.metrics,
182
+ epochs: space.inner.spaceState.credentials.filter((0, import_credentials2.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
183
+ ...credential.subject.assertion,
184
+ id: credential.id
185
+ })),
186
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => {
187
+ var _a2;
188
+ return {
189
+ identity: {
190
+ identityKey: member.key,
191
+ profile: {
192
+ displayName: (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName
193
+ }
194
+ },
195
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services.SpaceMember.PresenceState.ONLINE : import_services.SpaceMember.PresenceState.OFFLINE
196
+ };
197
+ }),
198
+ pipeline: {
199
+ // TODO(burdon): Pick properties from credentials if needed.
200
+ // currentEpoch: space.dataPipeline.currentEpoch,
201
+ // appliedEpoch: space.dataPipeline.appliedEpoch,
202
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
203
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
204
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
205
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
206
+ // TODO(burdon): Empty?
207
+ dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
208
+ startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
209
+ currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
210
+ targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
211
+ totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
212
+ }
213
+ };
214
+ if (space.dataPipeline.itemManager) {
215
+ Object.assign(stats, {
216
+ properties: getProperties(space),
217
+ db: {
218
+ objects: space.dataPipeline.itemManager.entities.size
219
+ }
220
+ });
221
+ }
222
+ if (stats.metrics) {
223
+ const { open, ready } = stats.metrics;
224
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
225
+ }
226
+ return stats;
227
+ };
228
+
73
229
  // packages/sdk/client-services/src/packlets/services/service-context.ts
74
- var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
75
230
  var import_async11 = require("@dxos/async");
76
- var import_credentials14 = require("@dxos/credentials");
231
+ var import_credentials15 = require("@dxos/credentials");
77
232
  var import_debug7 = require("@dxos/debug");
78
233
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
79
234
  var import_feed_store3 = require("@dxos/feed-store");
235
+ var import_invariant12 = require("@dxos/invariant");
80
236
  var import_keyring = require("@dxos/keyring");
81
237
  var import_keys8 = require("@dxos/keys");
82
- var import_log12 = require("@dxos/log");
83
- var import_protocols8 = require("@dxos/protocols");
84
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
238
+ var import_log13 = require("@dxos/log");
239
+ var import_protocols9 = require("@dxos/protocols");
240
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
85
241
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
86
242
 
87
243
  // packages/sdk/client-services/src/packlets/identity/authenticator.ts
88
244
  var import_async = require("@dxos/async");
89
245
  var import_context = require("@dxos/context");
90
- var import_credentials2 = require("@dxos/credentials");
91
- var import_log = require("@dxos/log");
92
- var import_protocols = require("@dxos/protocols");
93
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
94
- var Credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential");
246
+ var import_credentials3 = require("@dxos/credentials");
247
+ var import_log2 = require("@dxos/log");
248
+ var import_protocols2 = require("@dxos/protocols");
249
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
250
+ var Credential = import_protocols2.schema.getCodecForType("dxos.halo.credentials.Credential");
95
251
  var createAuthProvider = (signer) => async (nonce) => {
96
252
  const credential = await signer.createCredential({
97
253
  assertion: {
@@ -114,20 +270,20 @@ var TrustedKeySetAuthVerifier = class {
114
270
  get verifier() {
115
271
  return async (nonce, auth) => {
116
272
  const credential = Credential.decode(auth);
117
- (0, import_log.log)("authenticating...", {
273
+ (0, import_log2.log)("authenticating...", {
118
274
  credential
119
275
  }, {
120
- F: __dxlog_file,
276
+ F: __dxlog_file2,
121
277
  L: 59,
122
278
  S: this,
123
279
  C: (f, a) => f(...a)
124
280
  });
125
- const result = await (0, import_credentials2.verifyCredential)(credential);
281
+ const result = await (0, import_credentials3.verifyCredential)(credential);
126
282
  if (result.kind === "fail") {
127
- (0, import_log.log)("Invalid credential", {
283
+ (0, import_log2.log)("Invalid credential", {
128
284
  result
129
285
  }, {
130
- F: __dxlog_file,
286
+ F: __dxlog_file2,
131
287
  L: 63,
132
288
  S: this,
133
289
  C: (f, a) => f(...a)
@@ -135,11 +291,11 @@ var TrustedKeySetAuthVerifier = class {
135
291
  return false;
136
292
  }
137
293
  if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
138
- (0, import_log.log)("Invalid nonce", {
294
+ (0, import_log2.log)("Invalid nonce", {
139
295
  nonce,
140
296
  credential
141
297
  }, {
142
- F: __dxlog_file,
298
+ F: __dxlog_file2,
143
299
  L: 68,
144
300
  S: this,
145
301
  C: (f, a) => f(...a)
@@ -147,10 +303,10 @@ var TrustedKeySetAuthVerifier = class {
147
303
  return false;
148
304
  }
149
305
  if (this._isTrustedKey(credential.issuer)) {
150
- (0, import_log.log)("key is not currently in trusted set, waiting...", {
306
+ (0, import_log2.log)("key is not currently in trusted set, waiting...", {
151
307
  key: credential.issuer
152
308
  }, {
153
- F: __dxlog_file,
309
+ F: __dxlog_file2,
154
310
  L: 73,
155
311
  S: this,
156
312
  C: (f, a) => f(...a)
@@ -163,20 +319,20 @@ var TrustedKeySetAuthVerifier = class {
163
319
  });
164
320
  const clear = this._params.update.on(this._ctx, () => {
165
321
  if (this._isTrustedKey(credential.issuer)) {
166
- (0, import_log.log)("auth success", {
322
+ (0, import_log2.log)("auth success", {
167
323
  key: credential.issuer
168
324
  }, {
169
- F: __dxlog_file,
325
+ F: __dxlog_file2,
170
326
  L: 84,
171
327
  S: this,
172
328
  C: (f, a) => f(...a)
173
329
  });
174
330
  trigger.wake(true);
175
331
  } else {
176
- (0, import_log.log)("key is not currently in trusted set, waiting...", {
332
+ (0, import_log2.log)("key is not currently in trusted set, waiting...", {
177
333
  key: credential.issuer
178
334
  }, {
179
- F: __dxlog_file,
335
+ F: __dxlog_file2,
180
336
  L: 87,
181
337
  S: this,
182
338
  C: (f, a) => f(...a)
@@ -201,15 +357,15 @@ var TrustedKeySetAuthVerifier = class {
201
357
  };
202
358
 
203
359
  // packages/sdk/client-services/src/packlets/identity/identity.ts
204
- var import_tiny_invariant = __toESM(require("tiny-invariant"));
205
360
  var import_async2 = require("@dxos/async");
206
361
  var import_client_protocol = require("@dxos/client-protocol");
207
- var import_credentials3 = require("@dxos/credentials");
362
+ var import_credentials4 = require("@dxos/credentials");
208
363
  var import_debug2 = require("@dxos/debug");
209
364
  var import_feed_store = require("@dxos/feed-store");
210
- var import_log2 = require("@dxos/log");
211
- var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
212
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
365
+ var import_invariant2 = require("@dxos/invariant");
366
+ var import_log3 = require("@dxos/log");
367
+ var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
368
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
213
369
  var Identity = class {
214
370
  constructor({ space, signer, identityKey, deviceKey }) {
215
371
  this.stateUpdate = new import_async2.Event();
@@ -217,12 +373,12 @@ var Identity = class {
217
373
  this._signer = signer;
218
374
  this.identityKey = identityKey;
219
375
  this.deviceKey = deviceKey;
220
- this._deviceStateMachine = new import_credentials3.DeviceStateMachine({
376
+ this._deviceStateMachine = new import_credentials4.DeviceStateMachine({
221
377
  identityKey: this.identityKey,
222
378
  deviceKey: this.deviceKey,
223
379
  onUpdate: () => this.stateUpdate.emit()
224
380
  });
225
- this._profileStateMachine = new import_credentials3.ProfileStateMachine({
381
+ this._profileStateMachine = new import_credentials4.ProfileStateMachine({
226
382
  identityKey: this.identityKey,
227
383
  onUpdate: () => this.stateUpdate.emit()
228
384
  });
@@ -284,25 +440,33 @@ var Identity = class {
284
440
  * Requires identity to be ready.
285
441
  */
286
442
  getIdentityCredentialSigner() {
287
- (0, import_tiny_invariant.default)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
288
- return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
443
+ (0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
444
+ F: __dxlog_file3,
445
+ L: 134,
446
+ S: this,
447
+ A: [
448
+ "this._deviceStateMachine.deviceCredentialChain",
449
+ "'Device credential chain is not ready.'"
450
+ ]
451
+ });
452
+ return (0, import_credentials4.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
289
453
  }
290
454
  /**
291
455
  * Issues credentials as device.
292
456
  */
293
457
  getDeviceCredentialSigner() {
294
- return (0, import_credentials3.createCredentialSignerWithKey)(this._signer, this.deviceKey);
458
+ return (0, import_credentials4.createCredentialSignerWithKey)(this._signer, this.deviceKey);
295
459
  }
296
460
  async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
297
- (0, import_log2.log)("Admitting device:", {
461
+ (0, import_log3.log)("Admitting device:", {
298
462
  identityKey: this.identityKey,
299
463
  hostDevice: this.deviceKey,
300
464
  deviceKey,
301
465
  controlFeedKey,
302
466
  dataFeedKey
303
467
  }, {
304
- F: __dxlog_file2,
305
- L: 151,
468
+ F: __dxlog_file3,
469
+ L: 150,
306
470
  S: this,
307
471
  C: (f, a) => f(...a)
308
472
  });
@@ -323,7 +487,7 @@ var Identity = class {
323
487
  spaceKey: this.haloSpaceKey,
324
488
  deviceKey,
325
489
  identityKey: this.identityKey,
326
- designation: import_credentials4.AdmittedFeed.Designation.CONTROL
490
+ designation: import_credentials5.AdmittedFeed.Designation.CONTROL
327
491
  }
328
492
  }),
329
493
  await signer.createCredential({
@@ -333,7 +497,7 @@ var Identity = class {
333
497
  spaceKey: this.haloSpaceKey,
334
498
  deviceKey,
335
499
  identityKey: this.identityKey,
336
- designation: import_credentials4.AdmittedFeed.Designation.DATA
500
+ designation: import_credentials5.AdmittedFeed.Designation.DATA
337
501
  }
338
502
  })
339
503
  ].map((credential) => ({
@@ -345,15 +509,15 @@ var Identity = class {
345
509
  };
346
510
 
347
511
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
348
- var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
349
512
  var import_async3 = require("@dxos/async");
350
- var import_credentials5 = require("@dxos/credentials");
513
+ var import_credentials6 = require("@dxos/credentials");
514
+ var import_invariant3 = require("@dxos/invariant");
351
515
  var import_keys2 = require("@dxos/keys");
352
- var import_log3 = require("@dxos/log");
353
- var import_protocols2 = require("@dxos/protocols");
354
- var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
516
+ var import_log4 = require("@dxos/log");
517
+ var import_protocols3 = require("@dxos/protocols");
518
+ var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
355
519
  var import_util = require("@dxos/util");
356
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
520
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
357
521
  var IdentityManager = class {
358
522
  // TODO(burdon): IdentityManagerParams.
359
523
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
@@ -370,21 +534,21 @@ var IdentityManager = class {
370
534
  async open() {
371
535
  var _a;
372
536
  const traceId = import_keys2.PublicKey.random().toHex();
373
- import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
537
+ import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
374
538
  id: traceId
375
539
  }), {
376
- F: __dxlog_file3,
377
- L: 70,
540
+ F: __dxlog_file4,
541
+ L: 69,
378
542
  S: this,
379
543
  C: (f, a) => f(...a)
380
544
  });
381
545
  await this._metadataStore.load();
382
546
  const identityRecord = this._metadataStore.getIdentityRecord();
383
- (0, import_log3.log)("identity record", {
547
+ (0, import_log4.log)("identity record", {
384
548
  identityRecord
385
549
  }, {
386
- F: __dxlog_file3,
387
- L: 74,
550
+ F: __dxlog_file4,
551
+ L: 73,
388
552
  S: this,
389
553
  C: (f, a) => f(...a)
390
554
  });
@@ -392,22 +556,22 @@ var IdentityManager = class {
392
556
  this._identity = await this._constructIdentity(identityRecord);
393
557
  await this._identity.open();
394
558
  await this._identity.ready();
395
- import_log3.log.trace("dxos.halo.identity", {
559
+ import_log4.log.trace("dxos.halo.identity", {
396
560
  identityKey: identityRecord.identityKey,
397
561
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
398
562
  }, {
399
- F: __dxlog_file3,
400
- L: 79,
563
+ F: __dxlog_file4,
564
+ L: 78,
401
565
  S: this,
402
566
  C: (f, a) => f(...a)
403
567
  });
404
568
  this.stateUpdate.emit();
405
569
  }
406
- import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
570
+ import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
407
571
  id: traceId
408
572
  }), {
409
- F: __dxlog_file3,
410
- L: 85,
573
+ F: __dxlog_file4,
574
+ L: 84,
411
575
  S: this,
412
576
  C: (f, a) => f(...a)
413
577
  });
@@ -418,10 +582,18 @@ var IdentityManager = class {
418
582
  }
419
583
  async createIdentity({ displayName } = {}) {
420
584
  var _a;
421
- (0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
422
- (0, import_log3.log)("creating identity...", void 0, {
423
- F: __dxlog_file3,
424
- L: 94,
585
+ (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
586
+ F: __dxlog_file4,
587
+ L: 92,
588
+ S: this,
589
+ A: [
590
+ "!this._identity",
591
+ "'Identity already exists.'"
592
+ ]
593
+ });
594
+ (0, import_log4.log)("creating identity...", void 0, {
595
+ F: __dxlog_file4,
596
+ L: 93,
425
597
  S: this,
426
598
  C: (f, a) => f(...a)
427
599
  });
@@ -439,14 +611,30 @@ var IdentityManager = class {
439
611
  const identity = await this._constructIdentity(identityRecord);
440
612
  await identity.open();
441
613
  {
442
- const generator = new import_credentials5.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
443
- (0, import_tiny_invariant2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
444
- (0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
614
+ const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
615
+ (0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
616
+ F: __dxlog_file4,
617
+ L: 112,
618
+ S: this,
619
+ A: [
620
+ "identityRecord.haloSpace.genesisFeedKey",
621
+ "'Genesis feed key is required.'"
622
+ ]
623
+ });
624
+ (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
625
+ F: __dxlog_file4,
626
+ L: 113,
627
+ S: this,
628
+ A: [
629
+ "identityRecord.haloSpace.dataFeedKey",
630
+ "'Data feed key is required.'"
631
+ ]
632
+ });
445
633
  const credentials = [
446
634
  // Space genesis.
447
635
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
448
636
  // Feed admission.
449
- await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials6.AdmittedFeed.Designation.DATA)
637
+ await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials7.AdmittedFeed.Designation.DATA)
450
638
  ];
451
639
  if (displayName) {
452
640
  credentials.push(await generator.createProfileCredential({
@@ -465,22 +653,22 @@ var IdentityManager = class {
465
653
  await this._metadataStore.setIdentityRecord(identityRecord);
466
654
  this._identity = identity;
467
655
  await this._identity.ready();
468
- import_log3.log.trace("dxos.halo.identity", {
656
+ import_log4.log.trace("dxos.halo.identity", {
469
657
  identityKey: identityRecord.identityKey,
470
658
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
471
659
  }, {
472
- F: __dxlog_file3,
473
- L: 149,
660
+ F: __dxlog_file4,
661
+ L: 148,
474
662
  S: this,
475
663
  C: (f, a) => f(...a)
476
664
  });
477
665
  this.stateUpdate.emit();
478
- (0, import_log3.log)("created identity", {
666
+ (0, import_log4.log)("created identity", {
479
667
  identityKey: identity.identityKey,
480
668
  deviceKey: identity.deviceKey
481
669
  }, {
482
- F: __dxlog_file3,
483
- L: 155,
670
+ F: __dxlog_file4,
671
+ L: 154,
484
672
  S: this,
485
673
  C: (f, a) => f(...a)
486
674
  });
@@ -491,15 +679,23 @@ var IdentityManager = class {
491
679
  */
492
680
  async acceptIdentity(params) {
493
681
  var _a;
494
- (0, import_log3.log)("accepting identity", {
682
+ (0, import_log4.log)("accepting identity", {
495
683
  params
496
684
  }, {
497
- F: __dxlog_file3,
498
- L: 163,
685
+ F: __dxlog_file4,
686
+ L: 162,
499
687
  S: this,
500
688
  C: (f, a) => f(...a)
501
689
  });
502
- (0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
690
+ (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
691
+ F: __dxlog_file4,
692
+ L: 163,
693
+ S: this,
694
+ A: [
695
+ "!this._identity",
696
+ "'Identity already exists.'"
697
+ ]
698
+ });
503
699
  const identityRecord = {
504
700
  identityKey: params.identityKey,
505
701
  deviceKey: params.deviceKey,
@@ -516,42 +712,66 @@ var IdentityManager = class {
516
712
  this._identity = identity;
517
713
  await this._metadataStore.setIdentityRecord(identityRecord);
518
714
  await this._identity.ready();
519
- import_log3.log.trace("dxos.halo.identity", {
715
+ import_log4.log.trace("dxos.halo.identity", {
520
716
  identityKey: identityRecord.identityKey,
521
717
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
522
718
  }, {
523
- F: __dxlog_file3,
524
- L: 183,
719
+ F: __dxlog_file4,
720
+ L: 182,
525
721
  S: this,
526
722
  C: (f, a) => f(...a)
527
723
  });
528
724
  this.stateUpdate.emit();
529
- (0, import_log3.log)("accepted identity", {
725
+ (0, import_log4.log)("accepted identity", {
530
726
  identityKey: identity.identityKey,
531
727
  deviceKey: identity.deviceKey
532
728
  }, {
533
- F: __dxlog_file3,
534
- L: 189,
729
+ F: __dxlog_file4,
730
+ L: 188,
535
731
  S: this,
536
732
  C: (f, a) => f(...a)
537
733
  });
538
734
  return identity;
539
735
  }
540
736
  async _constructIdentity(identityRecord) {
541
- (0, import_tiny_invariant2.default)(!this._identity);
542
- (0, import_log3.log)("constructing identity", {
737
+ (0, import_invariant3.invariant)(!this._identity, void 0, {
738
+ F: __dxlog_file4,
739
+ L: 193,
740
+ S: this,
741
+ A: [
742
+ "!this._identity",
743
+ ""
744
+ ]
745
+ });
746
+ (0, import_log4.log)("constructing identity", {
543
747
  identityRecord
544
748
  }, {
545
- F: __dxlog_file3,
546
- L: 195,
749
+ F: __dxlog_file4,
750
+ L: 194,
547
751
  S: this,
548
752
  C: (f, a) => f(...a)
549
753
  });
550
- (0, import_tiny_invariant2.default)(identityRecord.haloSpace.controlFeedKey);
754
+ (0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
755
+ F: __dxlog_file4,
756
+ L: 197,
757
+ S: this,
758
+ A: [
759
+ "identityRecord.haloSpace.controlFeedKey",
760
+ ""
761
+ ]
762
+ });
551
763
  const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
552
764
  writable: true
553
765
  });
554
- (0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey);
766
+ (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
767
+ F: __dxlog_file4,
768
+ L: 201,
769
+ S: this,
770
+ A: [
771
+ "identityRecord.haloSpace.dataFeedKey",
772
+ ""
773
+ ]
774
+ });
555
775
  const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
556
776
  writable: true,
557
777
  sparse: true
@@ -560,7 +780,7 @@ var IdentityManager = class {
560
780
  spaceRecord: identityRecord.haloSpace,
561
781
  swarmIdentity: {
562
782
  peerKey: identityRecord.deviceKey,
563
- credentialProvider: createAuthProvider((0, import_credentials5.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
783
+ credentialProvider: createAuthProvider((0, import_credentials6.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
564
784
  credentialAuthenticator: (0, import_util.deferFunction)(() => identity.authVerifier.verifier)
565
785
  },
566
786
  identityKey: identityRecord.identityKey
@@ -573,11 +793,11 @@ var IdentityManager = class {
573
793
  identityKey: identityRecord.identityKey,
574
794
  deviceKey: identityRecord.deviceKey
575
795
  });
576
- (0, import_log3.log)("done", {
796
+ (0, import_log4.log)("done", {
577
797
  identityKey: identityRecord.identityKey
578
798
  }, {
579
- F: __dxlog_file3,
580
- L: 226,
799
+ F: __dxlog_file4,
800
+ L: 225,
581
801
  S: this,
582
802
  C: (f, a) => f(...a)
583
803
  });
@@ -596,9 +816,9 @@ var IdentityManager = class {
596
816
  onNetworkConnection: () => {
597
817
  },
598
818
  onAuthFailure: () => {
599
- import_log3.log.warn("auth failure", void 0, {
600
- F: __dxlog_file3,
601
- L: 245,
819
+ import_log4.log.warn("auth failure", void 0, {
820
+ F: __dxlog_file4,
821
+ L: 244,
602
822
  S: this,
603
823
  C: (f, a) => f(...a)
604
824
  });
@@ -609,10 +829,11 @@ var IdentityManager = class {
609
829
  };
610
830
 
611
831
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
612
- var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
613
- var import_codec_protobuf2 = require("@dxos/codec-protobuf");
614
- var import_credentials7 = require("@dxos/credentials");
832
+ var import_codec_protobuf3 = require("@dxos/codec-protobuf");
833
+ var import_credentials8 = require("@dxos/credentials");
615
834
  var import_debug3 = require("@dxos/debug");
835
+ var import_invariant4 = require("@dxos/invariant");
836
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
616
837
  var IdentityServiceImpl = class {
617
838
  // TODO(wittjosiah): Remove dependency on service context.
618
839
  constructor(_serviceContext) {
@@ -626,7 +847,7 @@ var IdentityServiceImpl = class {
626
847
  return (0, import_debug3.todo)();
627
848
  }
628
849
  queryIdentity() {
629
- return new import_codec_protobuf2.Stream(({ next }) => {
850
+ return new import_codec_protobuf3.Stream(({ next }) => {
630
851
  const emitNext = () => next({
631
852
  identity: this._getIdentity()
632
853
  });
@@ -645,8 +866,16 @@ var IdentityServiceImpl = class {
645
866
  };
646
867
  }
647
868
  async signPresentation({ presentation, nonce }) {
648
- (0, import_tiny_invariant3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
649
- return await (0, import_credentials7.signPresentation)({
869
+ (0, import_invariant4.invariant)(this._serviceContext.identityManager.identity, "Identity not initialized.", {
870
+ F: __dxlog_file5,
871
+ L: 56,
872
+ S: this,
873
+ A: [
874
+ "this._serviceContext.identityManager.identity",
875
+ "'Identity not initialized.'"
876
+ ]
877
+ });
878
+ return await (0, import_credentials8.signPresentation)({
650
879
  presentation,
651
880
  signer: this._serviceContext.keyring,
652
881
  signerKey: this._serviceContext.identityManager.identity.deviceKey,
@@ -657,8 +886,9 @@ var IdentityServiceImpl = class {
657
886
  };
658
887
 
659
888
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
660
- var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
661
- var import_services = require("@dxos/protocols/proto/dxos/client/services");
889
+ var import_invariant5 = require("@dxos/invariant");
890
+ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
891
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
662
892
  var DeviceInvitationProtocol = class {
663
893
  constructor(_keyring, _getIdentity, _acceptIdentity) {
664
894
  this._keyring = _keyring;
@@ -670,11 +900,19 @@ var DeviceInvitationProtocol = class {
670
900
  }
671
901
  getInvitationContext() {
672
902
  return {
673
- kind: import_services.Invitation.Kind.DEVICE
903
+ kind: import_services2.Invitation.Kind.DEVICE
674
904
  };
675
905
  }
676
906
  async admit(request) {
677
- (0, import_tiny_invariant4.default)(request.device);
907
+ (0, import_invariant5.invariant)(request.device, void 0, {
908
+ F: __dxlog_file6,
909
+ L: 31,
910
+ S: this,
911
+ A: [
912
+ "request.device",
913
+ ""
914
+ ]
915
+ });
678
916
  const identity = this._getIdentity();
679
917
  await identity.admitDevice(request.device);
680
918
  return {
@@ -702,9 +940,25 @@ var DeviceInvitationProtocol = class {
702
940
  };
703
941
  }
704
942
  async accept(response, request) {
705
- (0, import_tiny_invariant4.default)(response.device);
943
+ (0, import_invariant5.invariant)(response.device, void 0, {
944
+ F: __dxlog_file6,
945
+ L: 64,
946
+ S: this,
947
+ A: [
948
+ "response.device",
949
+ ""
950
+ ]
951
+ });
706
952
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
707
- (0, import_tiny_invariant4.default)(request.device);
953
+ (0, import_invariant5.invariant)(request.device, void 0, {
954
+ F: __dxlog_file6,
955
+ L: 67,
956
+ S: this,
957
+ A: [
958
+ "request.device",
959
+ ""
960
+ ]
961
+ });
708
962
  const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
709
963
  await this._acceptIdentity({
710
964
  identityKey,
@@ -722,41 +976,41 @@ var DeviceInvitationProtocol = class {
722
976
  };
723
977
 
724
978
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
725
- var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
726
979
  var import_async5 = require("@dxos/async");
727
980
  var import_client_protocol2 = require("@dxos/client-protocol");
728
981
  var import_context3 = require("@dxos/context");
729
- var import_credentials8 = require("@dxos/credentials");
982
+ var import_credentials9 = require("@dxos/credentials");
730
983
  var import_errors2 = require("@dxos/errors");
984
+ var import_invariant7 = require("@dxos/invariant");
731
985
  var import_keys4 = require("@dxos/keys");
732
- var import_log5 = require("@dxos/log");
986
+ var import_log6 = require("@dxos/log");
733
987
  var import_network_manager = require("@dxos/network-manager");
734
- var import_protocols4 = require("@dxos/protocols");
735
- var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
988
+ var import_protocols5 = require("@dxos/protocols");
989
+ var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
736
990
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
737
991
 
738
992
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
739
- var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
740
993
  var import_async4 = require("@dxos/async");
741
994
  var import_context2 = require("@dxos/context");
742
995
  var import_errors = require("@dxos/errors");
996
+ var import_invariant6 = require("@dxos/invariant");
743
997
  var import_keys3 = require("@dxos/keys");
744
- var import_log4 = require("@dxos/log");
745
- var import_protocols3 = require("@dxos/protocols");
746
- var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
998
+ var import_log5 = require("@dxos/log");
999
+ var import_protocols4 = require("@dxos/protocols");
1000
+ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
747
1001
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
748
1002
  var import_teleport = require("@dxos/teleport");
749
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
1003
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
750
1004
  var OPTIONS_TIMEOUT = 1e4;
751
1005
  var MAX_OTP_ATTEMPTS = 3;
752
1006
  var InvitationHostExtension = class extends import_teleport.RpcExtension {
753
1007
  constructor(_callbacks) {
754
1008
  super({
755
1009
  requested: {
756
- InvitationHostService: import_protocols3.schema.getService("dxos.halo.invitations.InvitationHostService")
1010
+ InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
757
1011
  },
758
1012
  exposed: {
759
- InvitationHostService: import_protocols3.schema.getService("dxos.halo.invitations.InvitationHostService")
1013
+ InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
760
1014
  }
761
1015
  });
762
1016
  this._callbacks = _callbacks;
@@ -774,88 +1028,104 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
774
1028
  // Perhaps in the future we will have more complex logic here.
775
1029
  InvitationHostService: {
776
1030
  options: async (options) => {
777
- (0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
1031
+ (0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
1032
+ F: __dxlog_file7,
1033
+ L: 88,
1034
+ S: this,
1035
+ A: [
1036
+ "!this._remoteOptions",
1037
+ "'Remote options already set.'"
1038
+ ]
1039
+ });
778
1040
  this._remoteOptions = options;
779
1041
  this._remoteOptionsTrigger.wake();
780
1042
  },
781
1043
  introduce: async (request) => {
782
1044
  const { profile, invitationId } = request;
783
1045
  const traceId = import_keys3.PublicKey.random().toHex();
784
- import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
1046
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols4.trace.begin({
785
1047
  id: traceId
786
1048
  }), {
787
- F: __dxlog_file4,
788
- L: 98,
1049
+ F: __dxlog_file7,
1050
+ L: 97,
789
1051
  S: this,
790
1052
  C: (f, a) => f(...a)
791
1053
  });
792
1054
  const invitation = await this._callbacks.resolveInvitation(request);
793
1055
  if (!invitation) {
794
- import_log4.log.warn("invitation not found", {
1056
+ import_log5.log.warn("invitation not found", {
795
1057
  invitationId
796
1058
  }, {
797
- F: __dxlog_file4,
798
- L: 102,
1059
+ F: __dxlog_file7,
1060
+ L: 101,
799
1061
  S: this,
800
1062
  C: (f, a) => f(...a)
801
1063
  });
802
1064
  this._callbacks.onError(new Error("Invitation not found."));
803
1065
  return {
804
- authMethod: import_services2.Invitation.AuthMethod.NONE
1066
+ authMethod: import_services3.Invitation.AuthMethod.NONE
805
1067
  };
806
1068
  }
807
1069
  this.invitation = invitation;
808
- (0, import_log4.log)("guest introduced itself", {
1070
+ (0, import_log5.log)("guest introduced itself", {
809
1071
  guestProfile: profile
810
1072
  }, {
811
- F: __dxlog_file4,
812
- L: 111,
1073
+ F: __dxlog_file7,
1074
+ L: 110,
813
1075
  S: this,
814
1076
  C: (f, a) => f(...a)
815
1077
  });
816
1078
  this.guestProfile = profile;
817
1079
  this._callbacks.onStateUpdate({
818
1080
  ...this.invitation,
819
- state: import_services2.Invitation.State.READY_FOR_AUTHENTICATION
1081
+ state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
820
1082
  });
821
- import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
1083
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols4.trace.end({
822
1084
  id: traceId
823
1085
  }), {
824
- F: __dxlog_file4,
825
- L: 118,
1086
+ F: __dxlog_file7,
1087
+ L: 117,
826
1088
  S: this,
827
1089
  C: (f, a) => f(...a)
828
1090
  });
829
1091
  return {
830
- spaceKey: this.invitation.authMethod === import_services2.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
1092
+ spaceKey: this.invitation.authMethod === import_services3.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
831
1093
  authMethod: this.invitation.authMethod
832
1094
  };
833
1095
  },
834
1096
  authenticate: async ({ authCode: code }) => {
835
1097
  const traceId = import_keys3.PublicKey.random().toHex();
836
- import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
1098
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols4.trace.begin({
837
1099
  id: traceId
838
1100
  }), {
839
- F: __dxlog_file4,
840
- L: 127,
1101
+ F: __dxlog_file7,
1102
+ L: 126,
841
1103
  S: this,
842
1104
  C: (f, a) => f(...a)
843
1105
  });
844
- (0, import_log4.log)("received authentication request", {
1106
+ (0, import_log5.log)("received authentication request", {
845
1107
  authCode: code
846
1108
  }, {
847
- F: __dxlog_file4,
848
- L: 128,
1109
+ F: __dxlog_file7,
1110
+ L: 127,
849
1111
  S: this,
850
1112
  C: (f, a) => f(...a)
851
1113
  });
852
1114
  let status = import_invitations.AuthenticationResponse.Status.OK;
853
- (0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
1115
+ (0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
1116
+ F: __dxlog_file7,
1117
+ L: 130,
1118
+ S: this,
1119
+ A: [
1120
+ "this.invitation",
1121
+ "'Invitation is not set.'"
1122
+ ]
1123
+ });
854
1124
  switch (this.invitation.authMethod) {
855
- case import_services2.Invitation.AuthMethod.NONE: {
856
- (0, import_log4.log)("authentication not required", void 0, {
857
- F: __dxlog_file4,
858
- L: 134,
1125
+ case import_services3.Invitation.AuthMethod.NONE: {
1126
+ (0, import_log5.log)("authentication not required", void 0, {
1127
+ F: __dxlog_file7,
1128
+ L: 133,
859
1129
  S: this,
860
1130
  C: (f, a) => f(...a)
861
1131
  });
@@ -863,7 +1133,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
863
1133
  status: import_invitations.AuthenticationResponse.Status.OK
864
1134
  };
865
1135
  }
866
- case import_services2.Invitation.AuthMethod.SHARED_SECRET: {
1136
+ case import_services3.Invitation.AuthMethod.SHARED_SECRET: {
867
1137
  if (this.invitation.authCode) {
868
1138
  if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
869
1139
  status = import_invitations.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
@@ -876,11 +1146,11 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
876
1146
  break;
877
1147
  }
878
1148
  default: {
879
- import_log4.log.error("invalid authentication method", {
1149
+ import_log5.log.error("invalid authentication method", {
880
1150
  authMethod: this.invitation.authMethod
881
1151
  }, {
882
- F: __dxlog_file4,
883
- L: 152,
1152
+ F: __dxlog_file7,
1153
+ L: 151,
884
1154
  S: this,
885
1155
  C: (f, a) => f(...a)
886
1156
  });
@@ -888,14 +1158,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
888
1158
  break;
889
1159
  }
890
1160
  }
891
- import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.end({
1161
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols4.trace.end({
892
1162
  id: traceId,
893
1163
  data: {
894
1164
  status
895
1165
  }
896
1166
  }), {
897
- F: __dxlog_file4,
898
- L: 158,
1167
+ F: __dxlog_file7,
1168
+ L: 157,
899
1169
  S: this,
900
1170
  C: (f, a) => f(...a)
901
1171
  });
@@ -905,25 +1175,33 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
905
1175
  },
906
1176
  admit: async (request) => {
907
1177
  const traceId = import_keys3.PublicKey.random().toHex();
908
- import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
1178
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols4.trace.begin({
909
1179
  id: traceId
910
1180
  }), {
911
- F: __dxlog_file4,
912
- L: 164,
1181
+ F: __dxlog_file7,
1182
+ L: 163,
913
1183
  S: this,
914
1184
  C: (f, a) => f(...a)
915
1185
  });
916
1186
  try {
917
- (0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
1187
+ (0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
1188
+ F: __dxlog_file7,
1189
+ L: 166,
1190
+ S: this,
1191
+ A: [
1192
+ "this.invitation",
1193
+ "'Invitation is not set.'"
1194
+ ]
1195
+ });
918
1196
  if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
919
1197
  throw new Error("Not authenticated");
920
1198
  }
921
1199
  const response = await this._callbacks.admit(request);
922
- import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
1200
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols4.trace.end({
923
1201
  id: traceId
924
1202
  }), {
925
- F: __dxlog_file4,
926
- L: 175,
1203
+ F: __dxlog_file7,
1204
+ L: 174,
927
1205
  S: this,
928
1206
  C: (f, a) => f(...a)
929
1207
  });
@@ -965,10 +1243,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
965
1243
  constructor(_callbacks) {
966
1244
  super({
967
1245
  requested: {
968
- InvitationHostService: import_protocols3.schema.getService("dxos.halo.invitations.InvitationHostService")
1246
+ InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
969
1247
  },
970
1248
  exposed: {
971
- InvitationHostService: import_protocols3.schema.getService("dxos.halo.invitations.InvitationHostService")
1249
+ InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
972
1250
  }
973
1251
  });
974
1252
  this._callbacks = _callbacks;
@@ -979,7 +1257,15 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
979
1257
  return {
980
1258
  InvitationHostService: {
981
1259
  options: async (options) => {
982
- (0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
1260
+ (0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
1261
+ F: __dxlog_file7,
1262
+ L: 241,
1263
+ S: this,
1264
+ A: [
1265
+ "!this._remoteOptions",
1266
+ "'Remote options already set.'"
1267
+ ]
1268
+ });
983
1269
  this._remoteOptions = options;
984
1270
  this._remoteOptionsTrigger.wake();
985
1271
  },
@@ -999,9 +1285,9 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
999
1285
  var _a;
1000
1286
  await super.onOpen(context);
1001
1287
  try {
1002
- (0, import_log4.log)("begin options", void 0, {
1003
- F: __dxlog_file4,
1004
- L: 263,
1288
+ (0, import_log5.log)("begin options", void 0, {
1289
+ F: __dxlog_file7,
1290
+ L: 262,
1005
1291
  S: this,
1006
1292
  C: (f, a) => f(...a)
1007
1293
  });
@@ -1011,9 +1297,9 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1011
1297
  await (0, import_context2.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1012
1298
  timeout: OPTIONS_TIMEOUT
1013
1299
  }));
1014
- (0, import_log4.log)("end options", void 0, {
1015
- F: __dxlog_file4,
1016
- L: 266,
1300
+ (0, import_log5.log)("end options", void 0, {
1301
+ F: __dxlog_file7,
1302
+ L: 265,
1017
1303
  S: this,
1018
1304
  C: (f, a) => f(...a)
1019
1305
  });
@@ -1025,9 +1311,9 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1025
1311
  }
1026
1312
  this._callbacks.onOpen(this._ctx);
1027
1313
  } catch (err) {
1028
- (0, import_log4.log)("openError", err, {
1029
- F: __dxlog_file4,
1030
- L: 276,
1314
+ (0, import_log5.log)("openError", err, {
1315
+ F: __dxlog_file7,
1316
+ L: 275,
1031
1317
  S: this,
1032
1318
  C: (f, a) => f(...a)
1033
1319
  });
@@ -1035,19 +1321,19 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1035
1321
  }
1036
1322
  }
1037
1323
  async onClose() {
1038
- (0, import_log4.log)("onClose", void 0, {
1039
- F: __dxlog_file4,
1040
- L: 282,
1324
+ (0, import_log5.log)("onClose", void 0, {
1325
+ F: __dxlog_file7,
1326
+ L: 281,
1041
1327
  S: this,
1042
1328
  C: (f, a) => f(...a)
1043
1329
  });
1044
1330
  await this._ctx.dispose();
1045
1331
  }
1046
1332
  };
1047
- var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
1333
+ var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services3.Invitation.AuthMethod.NONE;
1048
1334
 
1049
1335
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1050
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1336
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1051
1337
  var InvitationsHandler = class {
1052
1338
  /**
1053
1339
  * @internal
@@ -1057,9 +1343,17 @@ var InvitationsHandler = class {
1057
1343
  }
1058
1344
  createInvitation(protocol, options) {
1059
1345
  var _a;
1060
- const { invitationId = import_keys4.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_keys4.PublicKey.random() } = options != null ? options : {};
1061
- const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials8.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1062
- (0, import_tiny_invariant6.default)(protocol);
1346
+ const { invitationId = import_keys4.PublicKey.random().toHex(), type = import_services4.Invitation.Type.INTERACTIVE, authMethod = import_services4.Invitation.AuthMethod.SHARED_SECRET, state = import_services4.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys4.PublicKey.random() } = options != null ? options : {};
1347
+ const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services4.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1348
+ (0, import_invariant7.invariant)(protocol, void 0, {
1349
+ F: __dxlog_file8,
1350
+ L: 76,
1351
+ S: this,
1352
+ A: [
1353
+ "protocol",
1354
+ ""
1355
+ ]
1356
+ });
1063
1357
  const invitation = {
1064
1358
  invitationId,
1065
1359
  type,
@@ -1078,11 +1372,11 @@ var InvitationsHandler = class {
1078
1372
  }
1079
1373
  });
1080
1374
  ctx.onDispose(() => {
1081
- (0, import_log5.log)("complete", {
1375
+ (0, import_log6.log)("complete", {
1082
1376
  ...protocol.toJSON()
1083
1377
  }, {
1084
- F: __dxlog_file5,
1085
- L: 99,
1378
+ F: __dxlog_file8,
1379
+ L: 98,
1086
1380
  S: this,
1087
1381
  C: (f, a) => f(...a)
1088
1382
  });
@@ -1093,7 +1387,7 @@ var InvitationsHandler = class {
1093
1387
  onStateUpdate: (invitation2) => {
1094
1388
  stream.next({
1095
1389
  ...invitation2,
1096
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1390
+ state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1097
1391
  });
1098
1392
  },
1099
1393
  resolveInvitation: async ({ invitationId: invitationId2 }) => {
@@ -1106,7 +1400,15 @@ var InvitationsHandler = class {
1106
1400
  var _a2, _b, _c;
1107
1401
  try {
1108
1402
  const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1109
- (0, import_tiny_invariant6.default)(deviceKey);
1403
+ (0, import_invariant7.invariant)(deviceKey, void 0, {
1404
+ F: __dxlog_file8,
1405
+ L: 119,
1406
+ S: this,
1407
+ A: [
1408
+ "deviceKey",
1409
+ ""
1410
+ ]
1411
+ });
1110
1412
  const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1111
1413
  extension.completedTrigger.wake(deviceKey);
1112
1414
  return admissionResponse;
@@ -1119,84 +1421,84 @@ var InvitationsHandler = class {
1119
1421
  (0, import_async5.scheduleTask)(ctx, async () => {
1120
1422
  const traceId = import_keys4.PublicKey.random().toHex();
1121
1423
  try {
1122
- import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
1424
+ import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
1123
1425
  id: traceId
1124
1426
  }), {
1125
- F: __dxlog_file5,
1126
- L: 138,
1427
+ F: __dxlog_file8,
1428
+ L: 137,
1127
1429
  S: this,
1128
1430
  C: (f, a) => f(...a)
1129
1431
  });
1130
- (0, import_log5.log)("connected", {
1432
+ (0, import_log6.log)("connected", {
1131
1433
  ...protocol.toJSON()
1132
1434
  }, {
1133
- F: __dxlog_file5,
1134
- L: 139,
1435
+ F: __dxlog_file8,
1436
+ L: 138,
1135
1437
  S: this,
1136
1438
  C: (f, a) => f(...a)
1137
1439
  });
1138
1440
  stream.next({
1139
1441
  ...invitation,
1140
- state: import_services3.Invitation.State.CONNECTED
1442
+ state: import_services4.Invitation.State.CONNECTED
1141
1443
  });
1142
1444
  const deviceKey = await extension.completedTrigger.wait({
1143
1445
  timeout
1144
1446
  });
1145
- (0, import_log5.log)("admitted guest", {
1447
+ (0, import_log6.log)("admitted guest", {
1146
1448
  guest: deviceKey,
1147
1449
  ...protocol.toJSON()
1148
1450
  }, {
1149
- F: __dxlog_file5,
1150
- L: 142,
1451
+ F: __dxlog_file8,
1452
+ L: 141,
1151
1453
  S: this,
1152
1454
  C: (f, a) => f(...a)
1153
1455
  });
1154
1456
  stream.next({
1155
1457
  ...invitation,
1156
- state: import_services3.Invitation.State.SUCCESS
1458
+ state: import_services4.Invitation.State.SUCCESS
1157
1459
  });
1158
- import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
1460
+ import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
1159
1461
  id: traceId
1160
1462
  }), {
1161
- F: __dxlog_file5,
1162
- L: 144,
1463
+ F: __dxlog_file8,
1464
+ L: 143,
1163
1465
  S: this,
1164
1466
  C: (f, a) => f(...a)
1165
1467
  });
1166
1468
  } catch (err) {
1167
1469
  if (err instanceof import_async5.TimeoutError) {
1168
- (0, import_log5.log)("timeout", {
1470
+ (0, import_log6.log)("timeout", {
1169
1471
  ...protocol.toJSON()
1170
1472
  }, {
1171
- F: __dxlog_file5,
1172
- L: 147,
1473
+ F: __dxlog_file8,
1474
+ L: 146,
1173
1475
  S: this,
1174
1476
  C: (f, a) => f(...a)
1175
1477
  });
1176
1478
  stream.next({
1177
1479
  ...invitation,
1178
- state: import_services3.Invitation.State.TIMEOUT
1480
+ state: import_services4.Invitation.State.TIMEOUT
1179
1481
  });
1180
1482
  } else {
1181
- import_log5.log.error("failed", err, {
1182
- F: __dxlog_file5,
1183
- L: 150,
1483
+ import_log6.log.error("failed", err, {
1484
+ F: __dxlog_file8,
1485
+ L: 149,
1184
1486
  S: this,
1185
1487
  C: (f, a) => f(...a)
1186
1488
  });
1187
1489
  stream.error(err);
1188
1490
  }
1189
- import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.error({
1491
+ import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
1190
1492
  id: traceId,
1191
1493
  error: err
1192
1494
  }), {
1193
- F: __dxlog_file5,
1194
- L: 153,
1495
+ F: __dxlog_file8,
1496
+ L: 152,
1195
1497
  S: this,
1196
1498
  C: (f, a) => f(...a)
1197
1499
  });
1198
1500
  } finally {
1199
- if (type !== import_services3.Invitation.Type.MULTIUSE) {
1501
+ if (type !== import_services4.Invitation.Type.MULTIUSE) {
1200
1502
  await swarmConnection.close();
1201
1503
  await ctx.dispose();
1202
1504
  }
@@ -1208,22 +1510,22 @@ var InvitationsHandler = class {
1208
1510
  return;
1209
1511
  }
1210
1512
  if (err instanceof import_async5.TimeoutError) {
1211
- (0, import_log5.log)("timeout", {
1513
+ (0, import_log6.log)("timeout", {
1212
1514
  ...protocol.toJSON()
1213
1515
  }, {
1214
- F: __dxlog_file5,
1215
- L: 168,
1516
+ F: __dxlog_file8,
1517
+ L: 167,
1216
1518
  S: this,
1217
1519
  C: (f, a) => f(...a)
1218
1520
  });
1219
1521
  stream.next({
1220
1522
  ...invitation,
1221
- state: import_services3.Invitation.State.TIMEOUT
1523
+ state: import_services4.Invitation.State.TIMEOUT
1222
1524
  });
1223
1525
  } else {
1224
- import_log5.log.error("failed", err, {
1225
- F: __dxlog_file5,
1226
- L: 171,
1526
+ import_log6.log.error("failed", err, {
1527
+ F: __dxlog_file8,
1528
+ L: 170,
1227
1529
  S: this,
1228
1530
  C: (f, a) => f(...a)
1229
1531
  });
@@ -1247,7 +1549,7 @@ var InvitationsHandler = class {
1247
1549
  ctx.onDispose(() => swarmConnection.close());
1248
1550
  stream.next({
1249
1551
  ...invitation,
1250
- state: import_services3.Invitation.State.CONNECTING
1552
+ state: import_services4.Invitation.State.CONNECTING
1251
1553
  });
1252
1554
  });
1253
1555
  const observable = new import_client_protocol2.CancellableInvitationObservable({
@@ -1256,7 +1558,7 @@ var InvitationsHandler = class {
1256
1558
  onCancel: async () => {
1257
1559
  stream.next({
1258
1560
  ...invitation,
1259
- state: import_services3.Invitation.State.CANCELLED
1561
+ state: import_services4.Invitation.State.CANCELLED
1260
1562
  });
1261
1563
  await ctx.dispose();
1262
1564
  }
@@ -1265,13 +1567,29 @@ var InvitationsHandler = class {
1265
1567
  }
1266
1568
  acceptInvitation(protocol, invitation) {
1267
1569
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
1268
- (0, import_tiny_invariant6.default)(protocol);
1570
+ (0, import_invariant7.invariant)(protocol, void 0, {
1571
+ F: __dxlog_file8,
1572
+ L: 210,
1573
+ S: this,
1574
+ A: [
1575
+ "protocol",
1576
+ ""
1577
+ ]
1578
+ });
1269
1579
  const authenticated = new import_async5.Trigger();
1270
1580
  let admitted = false;
1271
1581
  let currentState;
1272
1582
  const stream = new import_async5.PushStream();
1273
1583
  const setState = (newData) => {
1274
- (0, import_tiny_invariant6.default)(newData.state !== void 0);
1584
+ (0, import_invariant7.invariant)(newData.state !== void 0, void 0, {
1585
+ F: __dxlog_file8,
1586
+ L: 221,
1587
+ S: this,
1588
+ A: [
1589
+ "newData.state !== undefined",
1590
+ ""
1591
+ ]
1592
+ });
1275
1593
  currentState = newData.state;
1276
1594
  stream.next({
1277
1595
  ...invitation,
@@ -1281,21 +1599,21 @@ var InvitationsHandler = class {
1281
1599
  const ctx = new import_context3.Context({
1282
1600
  onError: (err) => {
1283
1601
  if (err instanceof import_async5.TimeoutError) {
1284
- (0, import_log5.log)("timeout", {
1602
+ (0, import_log6.log)("timeout", {
1285
1603
  ...protocol.toJSON()
1286
1604
  }, {
1287
- F: __dxlog_file5,
1288
- L: 230,
1605
+ F: __dxlog_file8,
1606
+ L: 229,
1289
1607
  S: this,
1290
1608
  C: (f, a) => f(...a)
1291
1609
  });
1292
1610
  setState({
1293
- state: import_services3.Invitation.State.TIMEOUT
1611
+ state: import_services4.Invitation.State.TIMEOUT
1294
1612
  });
1295
1613
  } else {
1296
- import_log5.log.warn("auth failed", err, {
1297
- F: __dxlog_file5,
1298
- L: 233,
1614
+ import_log6.log.warn("auth failed", err, {
1615
+ F: __dxlog_file8,
1616
+ L: 232,
1299
1617
  S: this,
1300
1618
  C: (f, a) => f(...a)
1301
1619
  });
@@ -1305,11 +1623,11 @@ var InvitationsHandler = class {
1305
1623
  }
1306
1624
  });
1307
1625
  ctx.onDispose(() => {
1308
- (0, import_log5.log)("complete", {
1626
+ (0, import_log6.log)("complete", {
1309
1627
  ...protocol.toJSON()
1310
1628
  }, {
1311
- F: __dxlog_file5,
1312
- L: 241,
1629
+ F: __dxlog_file8,
1630
+ L: 240,
1313
1631
  S: this,
1314
1632
  C: (f, a) => f(...a)
1315
1633
  });
@@ -1320,11 +1638,11 @@ var InvitationsHandler = class {
1320
1638
  const extension = new InvitationGuestExtension({
1321
1639
  onOpen: (extensionCtx) => {
1322
1640
  extensionCtx.onDispose(async () => {
1323
- (0, import_log5.log)("extension disposed", {
1641
+ (0, import_log6.log)("extension disposed", {
1324
1642
  currentState
1325
1643
  }, {
1326
- F: __dxlog_file5,
1327
- L: 251,
1644
+ F: __dxlog_file8,
1645
+ L: 250,
1328
1646
  S: this,
1329
1647
  C: (f, a) => f(...a)
1330
1648
  });
@@ -1335,11 +1653,11 @@ var InvitationsHandler = class {
1335
1653
  (0, import_async5.scheduleTask)(ctx, async () => {
1336
1654
  const traceId = import_keys4.PublicKey.random().toHex();
1337
1655
  try {
1338
- import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
1656
+ import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
1339
1657
  id: traceId
1340
1658
  }), {
1341
- F: __dxlog_file5,
1342
- L: 260,
1659
+ F: __dxlog_file8,
1660
+ L: 259,
1343
1661
  S: this,
1344
1662
  C: (f, a) => f(...a)
1345
1663
  });
@@ -1347,32 +1665,32 @@ var InvitationsHandler = class {
1347
1665
  throw new Error(`multiple connections detected: ${connectionCount}`);
1348
1666
  }
1349
1667
  (0, import_async5.scheduleTask)(ctx, () => ctx.raise(new import_async5.TimeoutError(timeout)), timeout);
1350
- (0, import_log5.log)("connected", {
1668
+ (0, import_log6.log)("connected", {
1351
1669
  ...protocol.toJSON()
1352
1670
  }, {
1353
- F: __dxlog_file5,
1354
- L: 268,
1671
+ F: __dxlog_file8,
1672
+ L: 267,
1355
1673
  S: this,
1356
1674
  C: (f, a) => f(...a)
1357
1675
  });
1358
1676
  setState({
1359
- state: import_services3.Invitation.State.CONNECTED
1677
+ state: import_services4.Invitation.State.CONNECTED
1360
1678
  });
1361
- (0, import_log5.log)("introduce", {
1679
+ (0, import_log6.log)("introduce", {
1362
1680
  ...protocol.toJSON()
1363
1681
  }, {
1364
- F: __dxlog_file5,
1365
- L: 272,
1682
+ F: __dxlog_file8,
1683
+ L: 271,
1366
1684
  S: this,
1367
1685
  C: (f, a) => f(...a)
1368
1686
  });
1369
1687
  const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
1370
- (0, import_log5.log)("introduce response", {
1688
+ (0, import_log6.log)("introduce response", {
1371
1689
  ...protocol.toJSON(),
1372
1690
  response: introductionResponse
1373
1691
  }, {
1374
- F: __dxlog_file5,
1375
- L: 276,
1692
+ F: __dxlog_file8,
1693
+ L: 275,
1376
1694
  S: this,
1377
1695
  C: (f, a) => f(...a)
1378
1696
  });
@@ -1382,26 +1700,26 @@ var InvitationsHandler = class {
1382
1700
  }
1383
1701
  if (isAuthenticationRequired(invitation)) {
1384
1702
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1385
- (0, import_log5.log)("guest waiting for authentication code...", void 0, {
1386
- F: __dxlog_file5,
1387
- L: 285,
1703
+ (0, import_log6.log)("guest waiting for authentication code...", void 0, {
1704
+ F: __dxlog_file8,
1705
+ L: 284,
1388
1706
  S: this,
1389
1707
  C: (f, a) => f(...a)
1390
1708
  });
1391
1709
  setState({
1392
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1710
+ state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1393
1711
  });
1394
1712
  const authCode = await authenticated.wait({
1395
1713
  timeout
1396
1714
  });
1397
- (0, import_log5.log)("sending authentication request", void 0, {
1398
- F: __dxlog_file5,
1399
- L: 289,
1715
+ (0, import_log6.log)("sending authentication request", void 0, {
1716
+ F: __dxlog_file8,
1717
+ L: 288,
1400
1718
  S: this,
1401
1719
  C: (f, a) => f(...a)
1402
1720
  });
1403
1721
  setState({
1404
- state: import_services3.Invitation.State.AUTHENTICATING
1722
+ state: import_services4.Invitation.State.AUTHENTICATING
1405
1723
  });
1406
1724
  const response = await extension.rpc.InvitationHostService.authenticate({
1407
1725
  authCode
@@ -1413,11 +1731,11 @@ var InvitationsHandler = class {
1413
1731
  if (attempt === MAX_OTP_ATTEMPTS) {
1414
1732
  throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
1415
1733
  } else {
1416
- (0, import_log5.log)("retrying invalid code", {
1734
+ (0, import_log6.log)("retrying invalid code", {
1417
1735
  attempt
1418
1736
  }, {
1419
- F: __dxlog_file5,
1420
- L: 300,
1737
+ F: __dxlog_file8,
1738
+ L: 299,
1421
1739
  S: this,
1422
1740
  C: (f, a) => f(...a)
1423
1741
  });
@@ -1427,14 +1745,14 @@ var InvitationsHandler = class {
1427
1745
  }
1428
1746
  } else {
1429
1747
  setState({
1430
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1748
+ state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1431
1749
  });
1432
1750
  }
1433
- (0, import_log5.log)("request admission", {
1751
+ (0, import_log6.log)("request admission", {
1434
1752
  ...protocol.toJSON()
1435
1753
  }, {
1436
- F: __dxlog_file5,
1437
- L: 311,
1754
+ F: __dxlog_file8,
1755
+ L: 310,
1438
1756
  S: this,
1439
1757
  C: (f, a) => f(...a)
1440
1758
  });
@@ -1442,54 +1760,54 @@ var InvitationsHandler = class {
1442
1760
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
1443
1761
  admitted = true;
1444
1762
  const result = await protocol.accept(admissionResponse, admissionRequest);
1445
- (0, import_log5.log)("admitted by host", {
1763
+ (0, import_log6.log)("admitted by host", {
1446
1764
  ...protocol.toJSON()
1447
1765
  }, {
1448
- F: __dxlog_file5,
1449
- L: 322,
1766
+ F: __dxlog_file8,
1767
+ L: 321,
1450
1768
  S: this,
1451
1769
  C: (f, a) => f(...a)
1452
1770
  });
1453
1771
  setState({
1454
1772
  ...result,
1455
- state: import_services3.Invitation.State.SUCCESS
1773
+ state: import_services4.Invitation.State.SUCCESS
1456
1774
  });
1457
- import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
1775
+ import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
1458
1776
  id: traceId
1459
1777
  }), {
1460
- F: __dxlog_file5,
1461
- L: 324,
1778
+ F: __dxlog_file8,
1779
+ L: 323,
1462
1780
  S: this,
1463
1781
  C: (f, a) => f(...a)
1464
1782
  });
1465
1783
  } catch (err) {
1466
1784
  if (err instanceof import_async5.TimeoutError) {
1467
- (0, import_log5.log)("timeout", {
1785
+ (0, import_log6.log)("timeout", {
1468
1786
  ...protocol.toJSON()
1469
1787
  }, {
1470
- F: __dxlog_file5,
1471
- L: 327,
1788
+ F: __dxlog_file8,
1789
+ L: 326,
1472
1790
  S: this,
1473
1791
  C: (f, a) => f(...a)
1474
1792
  });
1475
1793
  setState({
1476
- state: import_services3.Invitation.State.TIMEOUT
1794
+ state: import_services4.Invitation.State.TIMEOUT
1477
1795
  });
1478
1796
  } else {
1479
- (0, import_log5.log)("auth failed", err, {
1480
- F: __dxlog_file5,
1481
- L: 330,
1797
+ (0, import_log6.log)("auth failed", err, {
1798
+ F: __dxlog_file8,
1799
+ L: 329,
1482
1800
  S: this,
1483
1801
  C: (f, a) => f(...a)
1484
1802
  });
1485
1803
  stream.error(err);
1486
1804
  }
1487
- import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.error({
1805
+ import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
1488
1806
  id: traceId,
1489
1807
  error: err
1490
1808
  }), {
1491
- F: __dxlog_file5,
1492
- L: 333,
1809
+ F: __dxlog_file8,
1810
+ L: 332,
1493
1811
  S: this,
1494
1812
  C: (f, a) => f(...a)
1495
1813
  });
@@ -1503,21 +1821,21 @@ var InvitationsHandler = class {
1503
1821
  return;
1504
1822
  }
1505
1823
  if (err instanceof import_async5.TimeoutError) {
1506
- (0, import_log5.log)("timeout", {
1824
+ (0, import_log6.log)("timeout", {
1507
1825
  ...protocol.toJSON()
1508
1826
  }, {
1509
- F: __dxlog_file5,
1510
- L: 344,
1827
+ F: __dxlog_file8,
1828
+ L: 343,
1511
1829
  S: this,
1512
1830
  C: (f, a) => f(...a)
1513
1831
  });
1514
1832
  setState({
1515
- state: import_services3.Invitation.State.TIMEOUT
1833
+ state: import_services4.Invitation.State.TIMEOUT
1516
1834
  });
1517
1835
  } else {
1518
- (0, import_log5.log)("auth failed", err, {
1519
- F: __dxlog_file5,
1520
- L: 347,
1836
+ (0, import_log6.log)("auth failed", err, {
1837
+ F: __dxlog_file8,
1838
+ L: 346,
1521
1839
  S: this,
1522
1840
  C: (f, a) => f(...a)
1523
1841
  });
@@ -1528,7 +1846,15 @@ var InvitationsHandler = class {
1528
1846
  return extension;
1529
1847
  };
1530
1848
  (0, import_async5.scheduleTask)(ctx, async () => {
1531
- (0, import_tiny_invariant6.default)(invitation.swarmKey);
1849
+ (0, import_invariant7.invariant)(invitation.swarmKey, void 0, {
1850
+ F: __dxlog_file8,
1851
+ L: 356,
1852
+ S: this,
1853
+ A: [
1854
+ "invitation.swarmKey",
1855
+ ""
1856
+ ]
1857
+ });
1532
1858
  const topic = invitation.swarmKey;
1533
1859
  const swarmConnection = await this._networkManager.joinSwarm({
1534
1860
  topic,
@@ -1540,7 +1866,7 @@ var InvitationsHandler = class {
1540
1866
  });
1541
1867
  ctx.onDispose(() => swarmConnection.close());
1542
1868
  setState({
1543
- state: import_services3.Invitation.State.CONNECTING
1869
+ state: import_services4.Invitation.State.CONNECTING
1544
1870
  });
1545
1871
  });
1546
1872
  const observable = new import_client_protocol2.AuthenticatingInvitationObservable({
@@ -1548,7 +1874,7 @@ var InvitationsHandler = class {
1548
1874
  subscriber: stream.observable,
1549
1875
  onCancel: async () => {
1550
1876
  setState({
1551
- state: import_services3.Invitation.State.CANCELLED
1877
+ state: import_services4.Invitation.State.CANCELLED
1552
1878
  });
1553
1879
  await ctx.dispose();
1554
1880
  },
@@ -1561,12 +1887,12 @@ var InvitationsHandler = class {
1561
1887
  };
1562
1888
 
1563
1889
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1564
- var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
1565
1890
  var import_async6 = require("@dxos/async");
1566
- var import_codec_protobuf3 = require("@dxos/codec-protobuf");
1567
- var import_log6 = require("@dxos/log");
1568
- var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
1569
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
1891
+ var import_codec_protobuf4 = require("@dxos/codec-protobuf");
1892
+ var import_invariant8 = require("@dxos/invariant");
1893
+ var import_log7 = require("@dxos/log");
1894
+ var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
1895
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
1570
1896
  var InvitationsServiceImpl = class {
1571
1897
  constructor(_invitationsHandler, _getHandler) {
1572
1898
  this._invitationsHandler = _invitationsHandler;
@@ -1593,7 +1919,7 @@ var InvitationsServiceImpl = class {
1593
1919
  this._createInvitations.set(invitation.get().invitationId, invitation);
1594
1920
  this._invitationCreated.emit(invitation.get());
1595
1921
  }
1596
- return new import_codec_protobuf3.Stream(({ next, close }) => {
1922
+ return new import_codec_protobuf4.Stream(({ next, close }) => {
1597
1923
  invitation.subscribe((invitation2) => {
1598
1924
  next(invitation2);
1599
1925
  }, (err) => {
@@ -1615,7 +1941,7 @@ var InvitationsServiceImpl = class {
1615
1941
  this._acceptInvitations.set(invitation.get().invitationId, invitation);
1616
1942
  this._invitationAccepted.emit(invitation.get());
1617
1943
  }
1618
- return new import_codec_protobuf3.Stream(({ next, close }) => {
1944
+ return new import_codec_protobuf4.Stream(({ next, close }) => {
1619
1945
  invitation.subscribe((invitation2) => {
1620
1946
  next(invitation2);
1621
1947
  }, (err) => {
@@ -1627,20 +1953,28 @@ var InvitationsServiceImpl = class {
1627
1953
  });
1628
1954
  }
1629
1955
  async authenticate({ invitationId, authCode }) {
1630
- (0, import_log6.log)("authenticating...", void 0, {
1631
- F: __dxlog_file6,
1632
- L: 103,
1956
+ (0, import_log7.log)("authenticating...", void 0, {
1957
+ F: __dxlog_file9,
1958
+ L: 102,
1633
1959
  S: this,
1634
1960
  C: (f, a) => f(...a)
1635
1961
  });
1636
- (0, import_tiny_invariant7.default)(invitationId);
1962
+ (0, import_invariant8.invariant)(invitationId, void 0, {
1963
+ F: __dxlog_file9,
1964
+ L: 103,
1965
+ S: this,
1966
+ A: [
1967
+ "invitationId",
1968
+ ""
1969
+ ]
1970
+ });
1637
1971
  const observable = this._acceptInvitations.get(invitationId);
1638
1972
  if (!observable) {
1639
- import_log6.log.warn("invalid invitation", {
1973
+ import_log7.log.warn("invalid invitation", {
1640
1974
  invitationId
1641
1975
  }, {
1642
- F: __dxlog_file6,
1643
- L: 107,
1976
+ F: __dxlog_file9,
1977
+ L: 106,
1644
1978
  S: this,
1645
1979
  C: (f, a) => f(...a)
1646
1980
  });
@@ -1649,13 +1983,21 @@ var InvitationsServiceImpl = class {
1649
1983
  }
1650
1984
  }
1651
1985
  async cancelInvitation({ invitationId }) {
1652
- (0, import_log6.log)("deleting...", void 0, {
1653
- F: __dxlog_file6,
1654
- L: 114,
1986
+ (0, import_log7.log)("deleting...", void 0, {
1987
+ F: __dxlog_file9,
1988
+ L: 113,
1655
1989
  S: this,
1656
1990
  C: (f, a) => f(...a)
1657
1991
  });
1658
- (0, import_tiny_invariant7.default)(invitationId);
1992
+ (0, import_invariant8.invariant)(invitationId, void 0, {
1993
+ F: __dxlog_file9,
1994
+ L: 114,
1995
+ S: this,
1996
+ A: [
1997
+ "invitationId",
1998
+ ""
1999
+ ]
2000
+ });
1659
2001
  const created = this._createInvitations.get(invitationId);
1660
2002
  const accepted = this._acceptInvitations.get(invitationId);
1661
2003
  if (created) {
@@ -1667,22 +2009,22 @@ var InvitationsServiceImpl = class {
1667
2009
  this._acceptInvitations.delete(invitationId);
1668
2010
  this._removedAccepted.emit(accepted.get());
1669
2011
  } else {
1670
- import_log6.log.warn("invalid invitation", {
2012
+ import_log7.log.warn("invalid invitation", {
1671
2013
  invitationId
1672
2014
  }, {
1673
- F: __dxlog_file6,
1674
- L: 127,
2015
+ F: __dxlog_file9,
2016
+ L: 126,
1675
2017
  S: this,
1676
2018
  C: (f, a) => f(...a)
1677
2019
  });
1678
2020
  }
1679
2021
  }
1680
2022
  queryInvitations() {
1681
- return new import_codec_protobuf3.Stream(({ next, ctx }) => {
2023
+ return new import_codec_protobuf4.Stream(({ next, ctx }) => {
1682
2024
  this._invitationCreated.on(ctx, (invitation) => {
1683
2025
  next({
1684
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1685
- type: import_services4.QueryInvitationsResponse.Type.CREATED,
2026
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2027
+ type: import_services5.QueryInvitationsResponse.Type.CREATED,
1686
2028
  invitations: [
1687
2029
  invitation
1688
2030
  ]
@@ -1690,8 +2032,8 @@ var InvitationsServiceImpl = class {
1690
2032
  });
1691
2033
  this._invitationAccepted.on(ctx, (invitation) => {
1692
2034
  next({
1693
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1694
- type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
2035
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2036
+ type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
1695
2037
  invitations: [
1696
2038
  invitation
1697
2039
  ]
@@ -1699,8 +2041,8 @@ var InvitationsServiceImpl = class {
1699
2041
  });
1700
2042
  this._removedCreated.on(ctx, (invitation) => {
1701
2043
  next({
1702
- action: import_services4.QueryInvitationsResponse.Action.REMOVED,
1703
- type: import_services4.QueryInvitationsResponse.Type.CREATED,
2044
+ action: import_services5.QueryInvitationsResponse.Action.REMOVED,
2045
+ type: import_services5.QueryInvitationsResponse.Type.CREATED,
1704
2046
  invitations: [
1705
2047
  invitation
1706
2048
  ]
@@ -1708,21 +2050,21 @@ var InvitationsServiceImpl = class {
1708
2050
  });
1709
2051
  this._removedAccepted.on(ctx, (invitation) => {
1710
2052
  next({
1711
- action: import_services4.QueryInvitationsResponse.Action.REMOVED,
1712
- type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
2053
+ action: import_services5.QueryInvitationsResponse.Action.REMOVED,
2054
+ type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
1713
2055
  invitations: [
1714
2056
  invitation
1715
2057
  ]
1716
2058
  });
1717
2059
  });
1718
2060
  next({
1719
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1720
- type: import_services4.QueryInvitationsResponse.Type.CREATED,
2061
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2062
+ type: import_services5.QueryInvitationsResponse.Type.CREATED,
1721
2063
  invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get())
1722
2064
  });
1723
2065
  next({
1724
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1725
- type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
2066
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2067
+ type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
1726
2068
  invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get())
1727
2069
  });
1728
2070
  });
@@ -1730,12 +2072,12 @@ var InvitationsServiceImpl = class {
1730
2072
  };
1731
2073
 
1732
2074
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
1733
- var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
1734
- var import_credentials9 = require("@dxos/credentials");
2075
+ var import_credentials10 = require("@dxos/credentials");
1735
2076
  var import_feed_store2 = require("@dxos/feed-store");
1736
- var import_log7 = require("@dxos/log");
1737
- var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
1738
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2077
+ var import_invariant9 = require("@dxos/invariant");
2078
+ var import_log8 = require("@dxos/log");
2079
+ var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2080
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
1739
2081
  var SpaceInvitationProtocol = class {
1740
2082
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
1741
2083
  this._spaceManager = _spaceManager;
@@ -1751,30 +2093,70 @@ var SpaceInvitationProtocol = class {
1751
2093
  }
1752
2094
  getInvitationContext() {
1753
2095
  return {
1754
- kind: import_services5.Invitation.Kind.SPACE,
2096
+ kind: import_services6.Invitation.Kind.SPACE,
1755
2097
  spaceKey: this._spaceKey
1756
2098
  };
1757
2099
  }
1758
2100
  async admit(request, guestProfile) {
1759
2101
  var _a;
1760
- (0, import_tiny_invariant8.default)(this._spaceKey);
2102
+ (0, import_invariant9.invariant)(this._spaceKey, void 0, {
2103
+ F: __dxlog_file10,
2104
+ L: 42,
2105
+ S: this,
2106
+ A: [
2107
+ "this._spaceKey",
2108
+ ""
2109
+ ]
2110
+ });
1761
2111
  const space = await this._spaceManager.spaces.get(this._spaceKey);
1762
- (0, import_tiny_invariant8.default)(space);
1763
- (0, import_tiny_invariant8.default)(request.space);
2112
+ (0, import_invariant9.invariant)(space, void 0, {
2113
+ F: __dxlog_file10,
2114
+ L: 44,
2115
+ S: this,
2116
+ A: [
2117
+ "space",
2118
+ ""
2119
+ ]
2120
+ });
2121
+ (0, import_invariant9.invariant)(request.space, void 0, {
2122
+ F: __dxlog_file10,
2123
+ L: 46,
2124
+ S: this,
2125
+ A: [
2126
+ "request.space",
2127
+ ""
2128
+ ]
2129
+ });
1764
2130
  const { identityKey, deviceKey } = request.space;
1765
- (0, import_log7.log)("writing guest credentials", {
2131
+ (0, import_log8.log)("writing guest credentials", {
1766
2132
  host: this._signingContext.deviceKey,
1767
2133
  guest: deviceKey
1768
2134
  }, {
1769
- F: __dxlog_file7,
1770
- L: 50,
2135
+ F: __dxlog_file10,
2136
+ L: 49,
1771
2137
  S: this,
1772
2138
  C: (f, a) => f(...a)
1773
2139
  });
1774
- const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
1775
- (0, import_tiny_invariant8.default)(credentials[0].credential);
2140
+ const credentials = await (0, import_credentials10.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
2141
+ (0, import_invariant9.invariant)(credentials[0].credential, void 0, {
2142
+ F: __dxlog_file10,
2143
+ L: 60,
2144
+ S: this,
2145
+ A: [
2146
+ "credentials[0].credential",
2147
+ ""
2148
+ ]
2149
+ });
1776
2150
  const spaceMemberCredential = credentials[0].credential.credential;
1777
- (0, import_tiny_invariant8.default)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2151
+ (0, import_invariant9.invariant)((0, import_credentials10.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2152
+ F: __dxlog_file10,
2153
+ L: 62,
2154
+ S: this,
2155
+ A: [
2156
+ "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
2157
+ ""
2158
+ ]
2159
+ });
1778
2160
  await (0, import_feed_store2.writeMessages)(space.inner.controlPipeline.writer, credentials);
1779
2161
  return {
1780
2162
  space: {
@@ -1802,11 +2184,35 @@ var SpaceInvitationProtocol = class {
1802
2184
  };
1803
2185
  }
1804
2186
  async accept(response) {
1805
- (0, import_tiny_invariant8.default)(response.space);
2187
+ (0, import_invariant9.invariant)(response.space, void 0, {
2188
+ F: __dxlog_file10,
2189
+ L: 97,
2190
+ S: this,
2191
+ A: [
2192
+ "response.space",
2193
+ ""
2194
+ ]
2195
+ });
1806
2196
  const { credential, controlTimeframe, dataTimeframe } = response.space;
1807
- const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
1808
- (0, import_tiny_invariant8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
1809
- (0, import_tiny_invariant8.default)(credential.subject.id.equals(this._signingContext.identityKey));
2197
+ const assertion = (0, import_credentials10.getCredentialAssertion)(credential);
2198
+ (0, import_invariant9.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2199
+ F: __dxlog_file10,
2200
+ L: 100,
2201
+ S: this,
2202
+ A: [
2203
+ "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
2204
+ "'Invalid credential'"
2205
+ ]
2206
+ });
2207
+ (0, import_invariant9.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
2208
+ F: __dxlog_file10,
2209
+ L: 101,
2210
+ S: this,
2211
+ A: [
2212
+ "credential.subject.id.equals(this._signingContext.identityKey)",
2213
+ ""
2214
+ ]
2215
+ });
1810
2216
  await this._spaceManager.acceptSpace({
1811
2217
  spaceKey: assertion.spaceKey,
1812
2218
  genesisFeedKey: assertion.genesisFeedKey,
@@ -1821,14 +2227,14 @@ var SpaceInvitationProtocol = class {
1821
2227
  };
1822
2228
 
1823
2229
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
1824
- var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
1825
2230
  var import_async9 = require("@dxos/async");
1826
2231
  var import_context6 = require("@dxos/context");
1827
- var import_credentials13 = require("@dxos/credentials");
2232
+ var import_credentials14 = require("@dxos/credentials");
2233
+ var import_invariant11 = require("@dxos/invariant");
1828
2234
  var import_keys7 = require("@dxos/keys");
1829
- var import_log10 = require("@dxos/log");
1830
- var import_protocols6 = require("@dxos/protocols");
1831
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2235
+ var import_log11 = require("@dxos/log");
2236
+ var import_protocols7 = require("@dxos/protocols");
2237
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
1832
2238
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
1833
2239
  var import_util4 = require("@dxos/util");
1834
2240
 
@@ -1840,22 +2246,22 @@ var import_debug4 = require("@dxos/debug");
1840
2246
  var import_echo_pipeline = require("@dxos/echo-pipeline");
1841
2247
  var import_errors3 = require("@dxos/errors");
1842
2248
  var import_keys6 = require("@dxos/keys");
1843
- var import_log9 = require("@dxos/log");
1844
- var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
1845
- var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
2249
+ var import_log10 = require("@dxos/log");
2250
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2251
+ var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
1846
2252
  var import_timeframe = require("@dxos/timeframe");
1847
2253
  var import_util3 = require("@dxos/util");
1848
2254
 
1849
2255
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
1850
- var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
1851
2256
  var import_async7 = require("@dxos/async");
1852
2257
  var import_context4 = require("@dxos/context");
2258
+ var import_invariant10 = require("@dxos/invariant");
1853
2259
  var import_keys5 = require("@dxos/keys");
1854
- var import_log8 = require("@dxos/log");
1855
- var import_protocols5 = require("@dxos/protocols");
2260
+ var import_log9 = require("@dxos/log");
2261
+ var import_protocols6 = require("@dxos/protocols");
1856
2262
  var import_teleport2 = require("@dxos/teleport");
1857
2263
  var import_util2 = require("@dxos/util");
1858
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2264
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
1859
2265
  var DEFAULT_RETRY_TIMEOUT = 1e3;
1860
2266
  var DEFAULT_SUCCESS_DELAY = 1e3;
1861
2267
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -1880,23 +2286,31 @@ var NotarizationPlugin = class {
1880
2286
  * Request credentials to be notarized.
1881
2287
  */
1882
2288
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
1883
- (0, import_log8.log)("notarize", {
2289
+ (0, import_log9.log)("notarize", {
1884
2290
  credentials
1885
2291
  }, {
1886
- F: __dxlog_file8,
1887
- L: 91,
2292
+ F: __dxlog_file11,
2293
+ L: 90,
1888
2294
  S: this,
1889
2295
  C: (f, a) => f(...a)
1890
2296
  });
1891
- (0, import_tiny_invariant9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2297
+ (0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
2298
+ F: __dxlog_file11,
2299
+ L: 91,
2300
+ S: this,
2301
+ A: [
2302
+ "credentials.every((credential) => credential.id)",
2303
+ "'Credentials must have an id'"
2304
+ ]
2305
+ });
1892
2306
  const errors = new import_async7.Trigger();
1893
2307
  const ctx = this._ctx.derive({
1894
2308
  onError: (err) => {
1895
- import_log8.log.warn("Notarization error", {
2309
+ import_log9.log.warn("Notarization error", {
1896
2310
  err
1897
2311
  }, {
1898
- F: __dxlog_file8,
1899
- L: 100,
2312
+ F: __dxlog_file11,
2313
+ L: 99,
1900
2314
  S: this,
1901
2315
  C: (f, a) => f(...a)
1902
2316
  });
@@ -1907,12 +2321,12 @@ var NotarizationPlugin = class {
1907
2321
  opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
1908
2322
  if (timeout !== 0) {
1909
2323
  (0, import_async7.scheduleTask)(ctx, () => {
1910
- import_log8.log.warn("Notarization timeout", {
2324
+ import_log9.log.warn("Notarization timeout", {
1911
2325
  timeout,
1912
2326
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1913
2327
  }, {
1914
- F: __dxlog_file8,
1915
- L: 112,
2328
+ F: __dxlog_file11,
2329
+ L: 111,
1916
2330
  S: this,
1917
2331
  C: (f, a) => f(...a)
1918
2332
  });
@@ -1931,11 +2345,11 @@ var NotarizationPlugin = class {
1931
2345
  ...this._extensions
1932
2346
  ].find((peer2) => !peersTried.has(peer2));
1933
2347
  if (!peer) {
1934
- import_log8.log.warn("Exhausted all peers to notarize with", {
2348
+ import_log9.log.warn("Exhausted all peers to notarize with", {
1935
2349
  retryIn: retryTimeout
1936
2350
  }, {
1937
- F: __dxlog_file8,
1938
- L: 137,
2351
+ F: __dxlog_file11,
2352
+ L: 136,
1939
2353
  S: this,
1940
2354
  C: (f, a) => f(...a)
1941
2355
  });
@@ -1944,30 +2358,30 @@ var NotarizationPlugin = class {
1944
2358
  return;
1945
2359
  }
1946
2360
  peersTried.add(peer);
1947
- (0, import_log8.log)("try notarizing", {
2361
+ (0, import_log9.log)("try notarizing", {
1948
2362
  peer: peer.localPeerId,
1949
2363
  credentialId: credentials.map((credential) => credential.id)
1950
2364
  }, {
1951
- F: __dxlog_file8,
1952
- L: 144,
2365
+ F: __dxlog_file11,
2366
+ L: 143,
1953
2367
  S: this,
1954
2368
  C: (f, a) => f(...a)
1955
2369
  });
1956
2370
  await peer.rpc.NotarizationService.notarize({
1957
2371
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
1958
2372
  });
1959
- (0, import_log8.log)("success", void 0, {
1960
- F: __dxlog_file8,
1961
- L: 148,
2373
+ (0, import_log9.log)("success", void 0, {
2374
+ F: __dxlog_file11,
2375
+ L: 147,
1962
2376
  S: this,
1963
2377
  C: (f, a) => f(...a)
1964
2378
  });
1965
2379
  await (0, import_async7.sleep)(successDelay);
1966
2380
  } catch (err) {
1967
2381
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
1968
- import_log8.log.warn("error notarizing (recoverable)", err, {
1969
- F: __dxlog_file8,
1970
- L: 152,
2382
+ import_log9.log.warn("error notarizing (recoverable)", err, {
2383
+ F: __dxlog_file11,
2384
+ L: 151,
1971
2385
  S: this,
1972
2386
  C: (f, a) => f(...a)
1973
2387
  });
@@ -1983,9 +2397,9 @@ var NotarizationPlugin = class {
1983
2397
  allNotarized,
1984
2398
  errors.wait()
1985
2399
  ]);
1986
- (0, import_log8.log)("done", void 0, {
1987
- F: __dxlog_file8,
1988
- L: 163,
2400
+ (0, import_log9.log)("done", void 0, {
2401
+ F: __dxlog_file11,
2402
+ L: 162,
1989
2403
  S: this,
1990
2404
  C: (f, a) => f(...a)
1991
2405
  });
@@ -2006,7 +2420,15 @@ var NotarizationPlugin = class {
2006
2420
  this._processCredentialsTriggers.delete(credential.id);
2007
2421
  }
2008
2422
  setWriter(writer) {
2009
- (0, import_tiny_invariant9.default)(!this._writer, "Writer already set.");
2423
+ (0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
2424
+ F: __dxlog_file11,
2425
+ L: 181,
2426
+ S: this,
2427
+ A: [
2428
+ "!this._writer",
2429
+ "'Writer already set.'"
2430
+ ]
2431
+ });
2010
2432
  this._writer = writer;
2011
2433
  }
2012
2434
  async _waitUntilProcessed(id) {
@@ -2024,7 +2446,15 @@ var NotarizationPlugin = class {
2024
2446
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2025
2447
  }
2026
2448
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2027
- (0, import_tiny_invariant9.default)(credential.id, "Credential must have an id");
2449
+ (0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
2450
+ F: __dxlog_file11,
2451
+ L: 200,
2452
+ S: this,
2453
+ A: [
2454
+ "credential.id",
2455
+ "'Credential must have an id'"
2456
+ ]
2457
+ });
2028
2458
  if (this._processedCredentials.has(credential.id)) {
2029
2459
  continue;
2030
2460
  }
@@ -2034,11 +2464,11 @@ var NotarizationPlugin = class {
2034
2464
  createExtension() {
2035
2465
  const extension = new NotarizationTeleportExtension({
2036
2466
  onOpen: async () => {
2037
- (0, import_log8.log)("extension opened", {
2467
+ (0, import_log9.log)("extension opened", {
2038
2468
  peer: extension.localPeerId
2039
2469
  }, {
2040
- F: __dxlog_file8,
2041
- L: 212,
2470
+ F: __dxlog_file11,
2471
+ L: 211,
2042
2472
  S: this,
2043
2473
  C: (f, a) => f(...a)
2044
2474
  });
@@ -2046,11 +2476,11 @@ var NotarizationPlugin = class {
2046
2476
  this._extensionOpened.emit();
2047
2477
  },
2048
2478
  onClose: async () => {
2049
- (0, import_log8.log)("extension closed", {
2479
+ (0, import_log9.log)("extension closed", {
2050
2480
  peer: extension.localPeerId
2051
2481
  }, {
2052
- F: __dxlog_file8,
2053
- L: 217,
2482
+ F: __dxlog_file11,
2483
+ L: 216,
2054
2484
  S: this,
2055
2485
  C: (f, a) => f(...a)
2056
2486
  });
@@ -2065,10 +2495,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2065
2495
  constructor(_params) {
2066
2496
  super({
2067
2497
  requested: {
2068
- NotarizationService: import_protocols5.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2498
+ NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2069
2499
  },
2070
2500
  exposed: {
2071
- NotarizationService: import_protocols5.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2501
+ NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2072
2502
  }
2073
2503
  });
2074
2504
  this._params = _params;
@@ -2103,12 +2533,12 @@ function _ts_decorate(decorators, target, key, desc) {
2103
2533
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2104
2534
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2105
2535
  }
2106
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2536
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2107
2537
  var DataSpace = class DataSpace2 {
2108
2538
  constructor(params) {
2109
2539
  this._ctx = new import_context5.Context();
2110
2540
  this._notarizationPlugin = new NotarizationPlugin();
2111
- this._state = import_services6.SpaceState.CLOSED;
2541
+ this._state = import_services7.SpaceState.CLOSED;
2112
2542
  /**
2113
2543
  * Error for _state === SpaceState.ERROR.
2114
2544
  */
@@ -2165,7 +2595,7 @@ var DataSpace = class DataSpace2 {
2165
2595
  await this._notarizationPlugin.open();
2166
2596
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2167
2597
  await this._inner.open();
2168
- this._state = import_services6.SpaceState.CONTROL_ONLY;
2598
+ this._state = import_services7.SpaceState.CONTROL_ONLY;
2169
2599
  this.stateUpdate.emit();
2170
2600
  this.metrics = {};
2171
2601
  this.metrics.open = new Date();
@@ -2176,7 +2606,7 @@ var DataSpace = class DataSpace2 {
2176
2606
  async _close() {
2177
2607
  var _a, _b;
2178
2608
  await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2179
- this._state = import_services6.SpaceState.CLOSED;
2609
+ this._state = import_services7.SpaceState.CLOSED;
2180
2610
  await this._ctx.dispose();
2181
2611
  this._ctx = new import_context5.Context();
2182
2612
  await this.authVerifier.close();
@@ -2201,21 +2631,21 @@ var DataSpace = class DataSpace2 {
2201
2631
  await this.initializeDataPipeline();
2202
2632
  } catch (err) {
2203
2633
  if (err instanceof import_errors3.CancelledError) {
2204
- (0, import_log9.log)("data pipeline initialization cancelled", err, {
2205
- F: __dxlog_file9,
2634
+ (0, import_log10.log)("data pipeline initialization cancelled", err, {
2635
+ F: __dxlog_file12,
2206
2636
  L: 193,
2207
2637
  S: this,
2208
2638
  C: (f, a) => f(...a)
2209
2639
  });
2210
2640
  return;
2211
2641
  }
2212
- import_log9.log.error("Error initializing data pipeline", err, {
2213
- F: __dxlog_file9,
2642
+ import_log10.log.error("Error initializing data pipeline", err, {
2643
+ F: __dxlog_file12,
2214
2644
  L: 197,
2215
2645
  S: this,
2216
2646
  C: (f, a) => f(...a)
2217
2647
  });
2218
- this._state = import_services6.SpaceState.ERROR;
2648
+ this._state = import_services7.SpaceState.ERROR;
2219
2649
  this.error = err;
2220
2650
  this.stateUpdate.emit();
2221
2651
  } finally {
@@ -2225,18 +2655,18 @@ var DataSpace = class DataSpace2 {
2225
2655
  }
2226
2656
  async initializeDataPipeline() {
2227
2657
  var _a, _b, _c, _d;
2228
- if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
2658
+ if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
2229
2659
  throw new import_errors3.SystemError("Invalid operation");
2230
2660
  }
2231
- this._state = import_services6.SpaceState.INITIALIZING;
2661
+ this._state = import_services7.SpaceState.INITIALIZING;
2232
2662
  await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
2233
2663
  ctx: this._ctx,
2234
2664
  breakOnStall: false
2235
2665
  });
2236
2666
  this.metrics.controlPipelineReady = new Date();
2237
2667
  await this._createWritableFeeds();
2238
- (0, import_log9.log)("writable feeds created", void 0, {
2239
- F: __dxlog_file9,
2668
+ (0, import_log10.log)("writable feeds created", void 0, {
2669
+ F: __dxlog_file12,
2240
2670
  L: 221,
2241
2671
  S: this,
2242
2672
  C: (f, a) => f(...a)
@@ -2252,8 +2682,8 @@ var DataSpace = class DataSpace2 {
2252
2682
  await this._inner.initializeDataPipeline();
2253
2683
  this.metrics.dataPipelineOpen = new Date();
2254
2684
  await (0, import_context5.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2255
- (0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
2256
- F: __dxlog_file9,
2685
+ (0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
2686
+ F: __dxlog_file12,
2257
2687
  L: 242,
2258
2688
  S: this,
2259
2689
  C: (f, a) => f(...a)
@@ -2263,14 +2693,14 @@ var DataSpace = class DataSpace2 {
2263
2693
  breakOnStall: false
2264
2694
  });
2265
2695
  this.metrics.dataPipelineReady = new Date();
2266
- (0, import_log9.log)("data pipeline ready", void 0, {
2267
- F: __dxlog_file9,
2696
+ (0, import_log10.log)("data pipeline ready", void 0, {
2697
+ F: __dxlog_file12,
2268
2698
  L: 251,
2269
2699
  S: this,
2270
2700
  C: (f, a) => f(...a)
2271
2701
  });
2272
2702
  await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
2273
- this._state = import_services6.SpaceState.READY;
2703
+ this._state = import_services7.SpaceState.READY;
2274
2704
  this.stateUpdate.emit();
2275
2705
  await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
2276
2706
  }
@@ -2288,7 +2718,7 @@ var DataSpace = class DataSpace2 {
2288
2718
  spaceKey: this.key,
2289
2719
  deviceKey: this._signingContext.deviceKey,
2290
2720
  identityKey: this._signingContext.identityKey,
2291
- designation: import_credentials10.AdmittedFeed.Designation.CONTROL
2721
+ designation: import_credentials11.AdmittedFeed.Designation.CONTROL
2292
2722
  }
2293
2723
  }));
2294
2724
  }
@@ -2305,7 +2735,7 @@ var DataSpace = class DataSpace2 {
2305
2735
  spaceKey: this.key,
2306
2736
  deviceKey: this._signingContext.deviceKey,
2307
2737
  identityKey: this._signingContext.identityKey,
2308
- designation: import_credentials10.AdmittedFeed.Designation.DATA
2738
+ designation: import_credentials11.AdmittedFeed.Designation.DATA
2309
2739
  }
2310
2740
  }));
2311
2741
  }
@@ -2346,20 +2776,20 @@ var DataSpace = class DataSpace2 {
2346
2776
  }
2347
2777
  }
2348
2778
  async activate() {
2349
- if (this._state !== import_services6.SpaceState.INACTIVE) {
2779
+ if (this._state !== import_services7.SpaceState.INACTIVE) {
2350
2780
  return;
2351
2781
  }
2352
- await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
2782
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
2353
2783
  await this._open();
2354
2784
  this.initializeDataPipelineAsync();
2355
2785
  }
2356
2786
  async deactivate() {
2357
- if (this._state === import_services6.SpaceState.INACTIVE) {
2787
+ if (this._state === import_services7.SpaceState.INACTIVE) {
2358
2788
  return;
2359
2789
  }
2360
- await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
2790
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
2361
2791
  await this._close();
2362
- this._state = import_services6.SpaceState.INACTIVE;
2792
+ this._state = import_services7.SpaceState.INACTIVE;
2363
2793
  this.stateUpdate.emit();
2364
2794
  }
2365
2795
  };
@@ -2383,14 +2813,14 @@ DataSpace = _ts_decorate([
2383
2813
  ], DataSpace);
2384
2814
 
2385
2815
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
2386
- var import_credentials11 = require("@dxos/credentials");
2816
+ var import_credentials12 = require("@dxos/credentials");
2387
2817
  var import_debug5 = require("@dxos/debug");
2388
- var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
2818
+ var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
2389
2819
  var import_timeframe2 = require("@dxos/timeframe");
2390
2820
  var spaceGenesis = async (keyring, signingContext, space) => {
2391
2821
  var _a, _b, _c, _d;
2392
2822
  const credentials = [
2393
- await (0, import_credentials11.createCredential)({
2823
+ await (0, import_credentials12.createCredential)({
2394
2824
  signer: keyring,
2395
2825
  issuer: space.key,
2396
2826
  subject: space.key,
@@ -2399,14 +2829,14 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2399
2829
  spaceKey: space.key
2400
2830
  }
2401
2831
  }),
2402
- await (0, import_credentials11.createCredential)({
2832
+ await (0, import_credentials12.createCredential)({
2403
2833
  signer: keyring,
2404
2834
  issuer: space.key,
2405
2835
  subject: signingContext.identityKey,
2406
2836
  assertion: {
2407
2837
  "@type": "dxos.halo.credentials.SpaceMember",
2408
2838
  spaceKey: space.key,
2409
- role: import_credentials12.SpaceMember.Role.ADMIN,
2839
+ role: import_credentials13.SpaceMember.Role.ADMIN,
2410
2840
  profile: signingContext.profile,
2411
2841
  genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug5.failUndefined)()
2412
2842
  }
@@ -2418,7 +2848,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2418
2848
  spaceKey: space.key,
2419
2849
  identityKey: signingContext.identityKey,
2420
2850
  deviceKey: signingContext.deviceKey,
2421
- designation: import_credentials12.AdmittedFeed.Designation.CONTROL
2851
+ designation: import_credentials13.AdmittedFeed.Designation.CONTROL
2422
2852
  }
2423
2853
  }),
2424
2854
  await signingContext.credentialSigner.createCredential({
@@ -2428,7 +2858,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2428
2858
  spaceKey: space.key,
2429
2859
  identityKey: signingContext.identityKey,
2430
2860
  deviceKey: signingContext.deviceKey,
2431
- designation: import_credentials12.AdmittedFeed.Designation.DATA
2861
+ designation: import_credentials13.AdmittedFeed.Designation.DATA
2432
2862
  }
2433
2863
  }),
2434
2864
  await signingContext.credentialSigner.createCredential({
@@ -2463,7 +2893,7 @@ function _ts_decorate2(decorators, target, key, desc) {
2463
2893
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2464
2894
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2465
2895
  }
2466
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
2896
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
2467
2897
  var DataSpaceManager = class DataSpaceManager2 {
2468
2898
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
2469
2899
  this._spaceManager = _spaceManager;
@@ -2483,50 +2913,50 @@ var DataSpaceManager = class DataSpaceManager2 {
2483
2913
  return this._spaces;
2484
2914
  }
2485
2915
  async open() {
2486
- (0, import_log10.log)("open", void 0, {
2487
- F: __dxlog_file10,
2488
- L: 80,
2916
+ (0, import_log11.log)("open", void 0, {
2917
+ F: __dxlog_file13,
2918
+ L: 79,
2489
2919
  S: this,
2490
2920
  C: (f, a) => f(...a)
2491
2921
  });
2492
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
2922
+ import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.begin({
2493
2923
  id: this._instanceId
2494
2924
  }), {
2495
- F: __dxlog_file10,
2496
- L: 81,
2925
+ F: __dxlog_file13,
2926
+ L: 80,
2497
2927
  S: this,
2498
2928
  C: (f, a) => f(...a)
2499
2929
  });
2500
2930
  await this._metadataStore.load();
2501
- (0, import_log10.log)("metadata loaded", {
2931
+ (0, import_log11.log)("metadata loaded", {
2502
2932
  spaces: this._metadataStore.spaces.length
2503
2933
  }, {
2504
- F: __dxlog_file10,
2505
- L: 83,
2934
+ F: __dxlog_file13,
2935
+ L: 82,
2506
2936
  S: this,
2507
2937
  C: (f, a) => f(...a)
2508
2938
  });
2509
2939
  for (const spaceMetadata of this._metadataStore.spaces) {
2510
2940
  try {
2511
- (0, import_log10.log)("load space", {
2941
+ (0, import_log11.log)("load space", {
2512
2942
  spaceMetadata
2513
2943
  }, {
2514
- F: __dxlog_file10,
2515
- L: 87,
2944
+ F: __dxlog_file13,
2945
+ L: 86,
2516
2946
  S: this,
2517
2947
  C: (f, a) => f(...a)
2518
2948
  });
2519
2949
  const space = await this._constructSpace(spaceMetadata);
2520
- if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
2950
+ if (spaceMetadata.state !== import_services8.SpaceState.INACTIVE) {
2521
2951
  space.initializeDataPipelineAsync();
2522
2952
  }
2523
2953
  } catch (err) {
2524
- import_log10.log.error("Error loading space", {
2954
+ import_log11.log.error("Error loading space", {
2525
2955
  spaceMetadata,
2526
2956
  err
2527
2957
  }, {
2528
- F: __dxlog_file10,
2529
- L: 93,
2958
+ F: __dxlog_file13,
2959
+ L: 92,
2530
2960
  S: this,
2531
2961
  C: (f, a) => f(...a)
2532
2962
  });
@@ -2534,19 +2964,19 @@ var DataSpaceManager = class DataSpaceManager2 {
2534
2964
  }
2535
2965
  this._isOpen = true;
2536
2966
  this.updated.emit();
2537
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
2967
+ import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.end({
2538
2968
  id: this._instanceId
2539
2969
  }), {
2540
- F: __dxlog_file10,
2541
- L: 99,
2970
+ F: __dxlog_file13,
2971
+ L: 98,
2542
2972
  S: this,
2543
2973
  C: (f, a) => f(...a)
2544
2974
  });
2545
2975
  }
2546
2976
  async close() {
2547
- (0, import_log10.log)("close", void 0, {
2548
- F: __dxlog_file10,
2549
- L: 104,
2977
+ (0, import_log11.log)("close", void 0, {
2978
+ F: __dxlog_file13,
2979
+ L: 103,
2550
2980
  S: this,
2551
2981
  C: (f, a) => f(...a)
2552
2982
  });
@@ -2560,7 +2990,15 @@ var DataSpaceManager = class DataSpaceManager2 {
2560
2990
  * Creates a new space writing the genesis credentials to the control feed.
2561
2991
  */
2562
2992
  async createSpace() {
2563
- (0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
2993
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
2994
+ F: __dxlog_file13,
2995
+ L: 116,
2996
+ S: this,
2997
+ A: [
2998
+ "this._isOpen",
2999
+ "'Not open.'"
3000
+ ]
3001
+ });
2564
3002
  const spaceKey = await this._keyring.createKey();
2565
3003
  const controlFeedKey = await this._keyring.createKey();
2566
3004
  const dataFeedKey = await this._keyring.createKey();
@@ -2569,13 +3007,13 @@ var DataSpaceManager = class DataSpaceManager2 {
2569
3007
  genesisFeedKey: controlFeedKey,
2570
3008
  controlFeedKey,
2571
3009
  dataFeedKey,
2572
- state: import_services7.SpaceState.ACTIVE
3010
+ state: import_services8.SpaceState.ACTIVE
2573
3011
  };
2574
- (0, import_log10.log)("creating space...", {
3012
+ (0, import_log11.log)("creating space...", {
2575
3013
  spaceKey
2576
3014
  }, {
2577
- F: __dxlog_file10,
2578
- L: 129,
3015
+ F: __dxlog_file13,
3016
+ L: 128,
2579
3017
  S: this,
2580
3018
  C: (f, a) => f(...a)
2581
3019
  });
@@ -2583,7 +3021,15 @@ var DataSpaceManager = class DataSpaceManager2 {
2583
3021
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
2584
3022
  await this._metadataStore.addSpace(metadata);
2585
3023
  const memberCredential = credentials[1];
2586
- (0, import_tiny_invariant10.default)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
3024
+ (0, import_invariant11.invariant)((0, import_credentials14.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3025
+ F: __dxlog_file13,
3026
+ L: 135,
3027
+ S: this,
3028
+ A: [
3029
+ "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
3030
+ ""
3031
+ ]
3032
+ });
2587
3033
  await this._signingContext.recordCredential(memberCredential);
2588
3034
  await space.initializeDataPipeline();
2589
3035
  this.updated.emit();
@@ -2591,16 +3037,32 @@ var DataSpaceManager = class DataSpaceManager2 {
2591
3037
  }
2592
3038
  // TODO(burdon): Rename join space.
2593
3039
  async acceptSpace(opts) {
2594
- (0, import_log10.log)("accept space", {
3040
+ (0, import_log11.log)("accept space", {
2595
3041
  opts
2596
3042
  }, {
2597
- F: __dxlog_file10,
2598
- L: 148,
3043
+ F: __dxlog_file13,
3044
+ L: 147,
2599
3045
  S: this,
2600
3046
  C: (f, a) => f(...a)
2601
3047
  });
2602
- (0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
2603
- (0, import_tiny_invariant10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
3048
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3049
+ F: __dxlog_file13,
3050
+ L: 148,
3051
+ S: this,
3052
+ A: [
3053
+ "this._isOpen",
3054
+ "'Not open.'"
3055
+ ]
3056
+ });
3057
+ (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3058
+ F: __dxlog_file13,
3059
+ L: 149,
3060
+ S: this,
3061
+ A: [
3062
+ "!this._spaces.has(opts.spaceKey)",
3063
+ "'Space already exists.'"
3064
+ ]
3065
+ });
2604
3066
  const metadata = {
2605
3067
  key: opts.spaceKey,
2606
3068
  genesisFeedKey: opts.genesisFeedKey,
@@ -2621,15 +3083,15 @@ var DataSpaceManager = class DataSpaceManager2 {
2621
3083
  async waitUntilSpaceReady(spaceKey) {
2622
3084
  await (0, import_context6.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
2623
3085
  const space = this._spaces.get(spaceKey);
2624
- return !!space && space.state === import_services7.SpaceState.READY;
3086
+ return !!space && space.state === import_services8.SpaceState.READY;
2625
3087
  }));
2626
3088
  }
2627
3089
  async _constructSpace(metadata) {
2628
- (0, import_log10.log)("construct space", {
3090
+ (0, import_log11.log)("construct space", {
2629
3091
  metadata
2630
3092
  }, {
2631
- F: __dxlog_file10,
2632
- L: 183,
3093
+ F: __dxlog_file13,
3094
+ L: 182,
2633
3095
  S: this,
2634
3096
  C: (f, a) => f(...a)
2635
3097
  });
@@ -2637,7 +3099,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2637
3099
  localPeerId: this._signingContext.deviceKey
2638
3100
  });
2639
3101
  const presence = new import_teleport_extension_gossip.Presence({
2640
- announceInterval: 500,
3102
+ announceInterval: 1e3,
2641
3103
  offlineTimeout: 5e3,
2642
3104
  identityKey: this._signingContext.identityKey,
2643
3105
  gossip
@@ -2663,9 +3125,9 @@ var DataSpaceManager = class DataSpaceManager2 {
2663
3125
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
2664
3126
  },
2665
3127
  onAuthFailure: () => {
2666
- import_log10.log.warn("auth failure", void 0, {
2667
- F: __dxlog_file10,
2668
- L: 214,
3128
+ import_log11.log.warn("auth failure", void 0, {
3129
+ F: __dxlog_file13,
3130
+ L: 213,
2669
3131
  S: this,
2670
3132
  C: (f, a) => f(...a)
2671
3133
  });
@@ -2676,7 +3138,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2676
3138
  dataFeed && space.setDataFeed(dataFeed);
2677
3139
  const dataSpace = new DataSpace({
2678
3140
  inner: space,
2679
- initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
3141
+ initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
2680
3142
  metadataStore: this._metadataStore,
2681
3143
  gossip,
2682
3144
  presence,
@@ -2685,23 +3147,23 @@ var DataSpaceManager = class DataSpaceManager2 {
2685
3147
  signingContext: this._signingContext,
2686
3148
  callbacks: {
2687
3149
  beforeReady: async () => {
2688
- (0, import_log10.log)("before space ready", {
3150
+ (0, import_log11.log)("before space ready", {
2689
3151
  space: space.key
2690
3152
  }, {
2691
- F: __dxlog_file10,
2692
- L: 232,
3153
+ F: __dxlog_file13,
3154
+ L: 231,
2693
3155
  S: this,
2694
3156
  C: (f, a) => f(...a)
2695
3157
  });
2696
3158
  await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
2697
3159
  },
2698
3160
  afterReady: async () => {
2699
- (0, import_log10.log)("after space ready", {
3161
+ (0, import_log11.log)("after space ready", {
2700
3162
  space: space.key,
2701
3163
  open: this._isOpen
2702
3164
  }, {
2703
- F: __dxlog_file10,
2704
- L: 239,
3165
+ F: __dxlog_file13,
3166
+ L: 238,
2705
3167
  S: this,
2706
3168
  C: (f, a) => f(...a)
2707
3169
  });
@@ -2710,11 +3172,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2710
3172
  }
2711
3173
  },
2712
3174
  beforeClose: async () => {
2713
- (0, import_log10.log)("before space close", {
3175
+ (0, import_log11.log)("before space close", {
2714
3176
  space: space.key
2715
3177
  }, {
2716
- F: __dxlog_file10,
2717
- L: 245,
3178
+ F: __dxlog_file13,
3179
+ L: 244,
2718
3180
  S: this,
2719
3181
  C: (f, a) => f(...a)
2720
3182
  });
@@ -2723,7 +3185,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2723
3185
  },
2724
3186
  cache: metadata.cache
2725
3187
  });
2726
- if (metadata.state !== import_services7.SpaceState.INACTIVE) {
3188
+ if (metadata.state !== import_services8.SpaceState.INACTIVE) {
2727
3189
  await dataSpace.open();
2728
3190
  }
2729
3191
  if (metadata.controlTimeframe) {
@@ -2754,15 +3216,15 @@ DataSpaceManager = _ts_decorate2([
2754
3216
 
2755
3217
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2756
3218
  var import_async10 = require("@dxos/async");
2757
- var import_codec_protobuf4 = require("@dxos/codec-protobuf");
3219
+ var import_codec_protobuf5 = require("@dxos/codec-protobuf");
2758
3220
  var import_debug6 = require("@dxos/debug");
2759
3221
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
2760
3222
  var import_errors4 = require("@dxos/errors");
2761
- var import_log11 = require("@dxos/log");
2762
- var import_protocols7 = require("@dxos/protocols");
2763
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
3223
+ var import_log12 = require("@dxos/log");
3224
+ var import_protocols8 = require("@dxos/protocols");
3225
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
2764
3226
  var import_util5 = require("@dxos/util");
2765
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3227
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2766
3228
  var SpacesServiceImpl = class {
2767
3229
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
2768
3230
  this._identityManager = _identityManager;
@@ -2784,10 +3246,10 @@ var SpacesServiceImpl = class {
2784
3246
  const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
2785
3247
  if (state) {
2786
3248
  switch (state) {
2787
- case import_services8.SpaceState.ACTIVE:
3249
+ case import_services9.SpaceState.ACTIVE:
2788
3250
  await space.activate();
2789
3251
  break;
2790
- case import_services8.SpaceState.INACTIVE:
3252
+ case import_services9.SpaceState.INACTIVE:
2791
3253
  await space.deactivate();
2792
3254
  break;
2793
3255
  default:
@@ -2796,14 +3258,14 @@ var SpacesServiceImpl = class {
2796
3258
  }
2797
3259
  }
2798
3260
  querySpaces() {
2799
- return new import_codec_protobuf4.Stream(({ next, ctx }) => {
3261
+ return new import_codec_protobuf5.Stream(({ next, ctx }) => {
2800
3262
  const scheduler = new import_async10.UpdateScheduler(ctx, async () => {
2801
3263
  const dataSpaceManager = await this._getDataSpaceManager();
2802
3264
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
2803
- (0, import_log11.log)("update", {
3265
+ (0, import_log12.log)("update", {
2804
3266
  spaces
2805
3267
  }, {
2806
- F: __dxlog_file11,
3268
+ F: __dxlog_file14,
2807
3269
  L: 78,
2808
3270
  S: this,
2809
3271
  C: (f, a) => f(...a)
@@ -2851,7 +3313,7 @@ var SpacesServiceImpl = class {
2851
3313
  await space.postMessage(getChannelId(channel), message);
2852
3314
  }
2853
3315
  subscribeMessages({ spaceKey, channel }) {
2854
- return new import_codec_protobuf4.Stream(({ ctx, next }) => {
3316
+ return new import_codec_protobuf5.Stream(({ ctx, next }) => {
2855
3317
  (0, import_async10.scheduleTask)(ctx, async () => {
2856
3318
  var _a;
2857
3319
  const dataSpaceManager = await this._getDataSpaceManager();
@@ -2864,7 +3326,7 @@ var SpacesServiceImpl = class {
2864
3326
  });
2865
3327
  }
2866
3328
  queryCredentials({ spaceKey }) {
2867
- return new import_codec_protobuf4.Stream(({ ctx, next }) => {
3329
+ return new import_codec_protobuf5.Stream(({ ctx, next }) => {
2868
3330
  var _a;
2869
3331
  const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
2870
3332
  const processor = {
@@ -2898,7 +3360,7 @@ var SpacesServiceImpl = class {
2898
3360
  return {
2899
3361
  spaceKey: space.key,
2900
3362
  state: space.state,
2901
- error: space.error ? (0, import_protocols7.encodeError)(space.error) : void 0,
3363
+ error: space.error ? (0, import_protocols8.encodeError)(space.error) : void 0,
2902
3364
  pipeline: {
2903
3365
  currentEpoch: space.dataPipeline.currentEpoch,
2904
3366
  appliedEpoch: space.dataPipeline.appliedEpoch,
@@ -2914,14 +3376,20 @@ var SpacesServiceImpl = class {
2914
3376
  },
2915
3377
  members: Array.from(space.inner.spaceState.members.values()).map((member) => {
2916
3378
  var _a2, _b2, _c2;
3379
+ const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
3380
+ const isMe = (_a2 = this._identityManager.identity) == null ? void 0 : _a2.identityKey.equals(member.key);
3381
+ if (isMe) {
3382
+ peers.push(space.presence.getLocalState());
3383
+ }
2917
3384
  return {
2918
3385
  identity: {
2919
3386
  identityKey: member.key,
2920
3387
  profile: {
2921
- displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util5.humanize)(member.key)
3388
+ displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : (0, import_util5.humanize)(member.key)
2922
3389
  }
2923
3390
  },
2924
- presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services8.SpaceMember.PresenceState.ONLINE : import_services8.SpaceMember.PresenceState.OFFLINE
3391
+ presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
3392
+ peerStates: peers
2925
3393
  };
2926
3394
  }),
2927
3395
  creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
@@ -2933,7 +3401,7 @@ var SpacesServiceImpl = class {
2933
3401
  var getChannelId = (channel) => `user-channel/${channel}`;
2934
3402
 
2935
3403
  // packages/sdk/client-services/src/packlets/services/service-context.ts
2936
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3404
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
2937
3405
  var ServiceContext = class {
2938
3406
  // prettier-ignore
2939
3407
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -2968,24 +3436,24 @@ var ServiceContext = class {
2968
3436
  });
2969
3437
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
2970
3438
  this.invitations = new InvitationsHandler(this.networkManager);
2971
- this._handlerFactories.set(import_services9.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3439
+ this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
2972
3440
  var _a;
2973
3441
  return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
2974
3442
  }, this._acceptIdentity.bind(this)));
2975
3443
  }
2976
3444
  async open() {
2977
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
2978
- id: this._instanceId
2979
- }), {
2980
- F: __dxlog_file12,
2981
- L: 126,
3445
+ await this._checkStorageVersion();
3446
+ (0, import_log13.log)("opening...", void 0, {
3447
+ F: __dxlog_file15,
3448
+ L: 127,
2982
3449
  S: this,
2983
3450
  C: (f, a) => f(...a)
2984
3451
  });
2985
- await this._checkStorageVersion();
2986
- (0, import_log12.log)("opening...", void 0, {
2987
- F: __dxlog_file12,
2988
- L: 130,
3452
+ import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.begin({
3453
+ id: this._instanceId
3454
+ }), {
3455
+ F: __dxlog_file15,
3456
+ L: 128,
2989
3457
  S: this,
2990
3458
  C: (f, a) => f(...a)
2991
3459
  });
@@ -2996,26 +3464,26 @@ var ServiceContext = class {
2996
3464
  if (this.identityManager.identity) {
2997
3465
  await this._initialize();
2998
3466
  }
2999
- (0, import_log12.log)("opened", void 0, {
3000
- F: __dxlog_file12,
3001
- L: 138,
3467
+ import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
3468
+ id: this._instanceId
3469
+ }), {
3470
+ F: __dxlog_file15,
3471
+ L: 136,
3002
3472
  S: this,
3003
3473
  C: (f, a) => f(...a)
3004
3474
  });
3005
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
3006
- id: this._instanceId
3007
- }), {
3008
- F: __dxlog_file12,
3009
- L: 139,
3475
+ (0, import_log13.log)("opened", void 0, {
3476
+ F: __dxlog_file15,
3477
+ L: 137,
3010
3478
  S: this,
3011
3479
  C: (f, a) => f(...a)
3012
3480
  });
3013
3481
  }
3014
3482
  async close() {
3015
3483
  var _a;
3016
- (0, import_log12.log)("closing...", void 0, {
3017
- F: __dxlog_file12,
3018
- L: 143,
3484
+ (0, import_log13.log)("closing...", void 0, {
3485
+ F: __dxlog_file15,
3486
+ L: 141,
3019
3487
  S: this,
3020
3488
  C: (f, a) => f(...a)
3021
3489
  });
@@ -3029,9 +3497,9 @@ var ServiceContext = class {
3029
3497
  await this.networkManager.close();
3030
3498
  await this.signalManager.close();
3031
3499
  this.dataServiceSubscriptions.clear();
3032
- (0, import_log12.log)("closed", void 0, {
3033
- F: __dxlog_file12,
3034
- L: 154,
3500
+ (0, import_log13.log)("closed", void 0, {
3501
+ F: __dxlog_file15,
3502
+ L: 152,
3035
3503
  S: this,
3036
3504
  C: (f, a) => f(...a)
3037
3505
  });
@@ -3043,7 +3511,15 @@ var ServiceContext = class {
3043
3511
  }
3044
3512
  getInvitationHandler(invitation) {
3045
3513
  const factory = this._handlerFactories.get(invitation.kind);
3046
- (0, import_tiny_invariant11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3514
+ (0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
3515
+ F: __dxlog_file15,
3516
+ L: 164,
3517
+ S: this,
3518
+ A: [
3519
+ "factory",
3520
+ "`Unknown invitation kind: ${invitation.kind}`"
3521
+ ]
3522
+ });
3047
3523
  return factory(invitation);
3048
3524
  }
3049
3525
  async _acceptIdentity(params) {
@@ -3053,16 +3529,16 @@ var ServiceContext = class {
3053
3529
  }
3054
3530
  async _checkStorageVersion() {
3055
3531
  await this.metadataStore.load();
3056
- if (this.metadataStore.version !== import_protocols8.STORAGE_VERSION) {
3057
- throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols8.STORAGE_VERSION}`);
3532
+ if (this.metadataStore.version !== import_protocols9.STORAGE_VERSION) {
3533
+ throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols9.STORAGE_VERSION}`);
3058
3534
  }
3059
3535
  }
3060
3536
  // Called when identity is created.
3061
3537
  async _initialize() {
3062
3538
  var _a;
3063
- (0, import_log12.log)("initializing spaces...", void 0, {
3064
- F: __dxlog_file12,
3065
- L: 187,
3539
+ (0, import_log13.log)("initializing spaces...", void 0, {
3540
+ F: __dxlog_file15,
3541
+ L: 185,
3066
3542
  S: this,
3067
3543
  C: (f, a) => f(...a)
3068
3544
  });
@@ -3082,14 +3558,22 @@ var ServiceContext = class {
3082
3558
  };
3083
3559
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3084
3560
  await this.dataSpaceManager.open();
3085
- this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
3086
- (0, import_tiny_invariant11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3561
+ this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
3562
+ (0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3563
+ F: __dxlog_file15,
3564
+ L: 208,
3565
+ S: this,
3566
+ A: [
3567
+ "this.dataSpaceManager",
3568
+ "'dataSpaceManager not initialized yet'"
3569
+ ]
3570
+ });
3087
3571
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
3088
3572
  });
3089
3573
  this.initialized.wake();
3090
3574
  this._deviceSpaceSync = {
3091
3575
  processCredential: async (credential) => {
3092
- const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
3576
+ const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
3093
3577
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
3094
3578
  return;
3095
3579
  }
@@ -3097,33 +3581,33 @@ var ServiceContext = class {
3097
3581
  return;
3098
3582
  }
3099
3583
  if (!this.dataSpaceManager) {
3100
- (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3584
+ (0, import_log13.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3101
3585
  details: assertion
3102
3586
  }, {
3103
- F: __dxlog_file12,
3104
- L: 226,
3587
+ F: __dxlog_file15,
3588
+ L: 224,
3105
3589
  S: this,
3106
3590
  C: (f, a) => f(...a)
3107
3591
  });
3108
3592
  return;
3109
3593
  }
3110
3594
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
3111
- (0, import_log12.log)("space already exists, ignoring space admission", {
3595
+ (0, import_log13.log)("space already exists, ignoring space admission", {
3112
3596
  details: assertion
3113
3597
  }, {
3114
- F: __dxlog_file12,
3115
- L: 230,
3598
+ F: __dxlog_file15,
3599
+ L: 228,
3116
3600
  S: this,
3117
3601
  C: (f, a) => f(...a)
3118
3602
  });
3119
3603
  return;
3120
3604
  }
3121
3605
  try {
3122
- (0, import_log12.log)("accepting space recorded in halo", {
3606
+ (0, import_log13.log)("accepting space recorded in halo", {
3123
3607
  details: assertion
3124
3608
  }, {
3125
- F: __dxlog_file12,
3126
- L: 235,
3609
+ F: __dxlog_file15,
3610
+ L: 233,
3127
3611
  S: this,
3128
3612
  C: (f, a) => f(...a)
3129
3613
  });
@@ -3132,9 +3616,9 @@ var ServiceContext = class {
3132
3616
  genesisFeedKey: assertion.genesisFeedKey
3133
3617
  });
3134
3618
  } catch (err) {
3135
- import_log12.log.catch(err, void 0, {
3136
- F: __dxlog_file12,
3137
- L: 241,
3619
+ import_log13.log.catch(err, void 0, {
3620
+ F: __dxlog_file15,
3621
+ L: 239,
3138
3622
  S: this,
3139
3623
  C: (f, a) => f(...a)
3140
3624
  });
@@ -3146,24 +3630,24 @@ var ServiceContext = class {
3146
3630
  };
3147
3631
 
3148
3632
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3149
- var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
3150
3633
  var import_async17 = require("@dxos/async");
3151
3634
  var import_client_protocol5 = require("@dxos/client-protocol");
3152
- var import_document_model = require("@dxos/document-model");
3635
+ var import_document_model2 = require("@dxos/document-model");
3153
3636
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3637
+ var import_invariant14 = require("@dxos/invariant");
3154
3638
  var import_keys12 = require("@dxos/keys");
3155
- var import_log15 = require("@dxos/log");
3639
+ var import_log16 = require("@dxos/log");
3156
3640
  var import_messaging = require("@dxos/messaging");
3157
3641
  var import_model_factory = require("@dxos/model-factory");
3158
3642
  var import_network_manager2 = require("@dxos/network-manager");
3159
- var import_protocols9 = require("@dxos/protocols");
3160
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3643
+ var import_protocols10 = require("@dxos/protocols");
3644
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
3161
3645
  var import_text_model = require("@dxos/text-model");
3162
3646
 
3163
3647
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3164
3648
  var import_async12 = require("@dxos/async");
3165
- var import_codec_protobuf5 = require("@dxos/codec-protobuf");
3166
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
3649
+ var import_codec_protobuf6 = require("@dxos/codec-protobuf");
3650
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
3167
3651
  var DevicesServiceImpl = class {
3168
3652
  constructor(_identityManager) {
3169
3653
  this._identityManager = _identityManager;
@@ -3172,7 +3656,7 @@ var DevicesServiceImpl = class {
3172
3656
  throw new Error("Method not implemented.");
3173
3657
  }
3174
3658
  queryDevices() {
3175
- return new import_codec_protobuf5.Stream(({ next }) => {
3659
+ return new import_codec_protobuf6.Stream(({ next }) => {
3176
3660
  const update = () => {
3177
3661
  var _a;
3178
3662
  const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
@@ -3186,7 +3670,7 @@ var DevicesServiceImpl = class {
3186
3670
  var _a2;
3187
3671
  return {
3188
3672
  deviceKey: key,
3189
- kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services10.DeviceKind.CURRENT : import_services10.DeviceKind.TRUSTED
3673
+ kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
3190
3674
  };
3191
3675
  })
3192
3676
  });
@@ -3209,16 +3693,16 @@ var DevicesServiceImpl = class {
3209
3693
 
3210
3694
  // packages/sdk/client-services/src/packlets/devtools/devtools.ts
3211
3695
  var import_async15 = require("@dxos/async");
3212
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3696
+ var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3213
3697
 
3214
3698
  // packages/sdk/client-services/src/packlets/devtools/feeds.ts
3215
3699
  var import_async13 = require("@dxos/async");
3216
- var import_codec_protobuf6 = require("@dxos/codec-protobuf");
3700
+ var import_codec_protobuf7 = require("@dxos/codec-protobuf");
3217
3701
  var import_feed_store4 = require("@dxos/feed-store");
3218
3702
  var import_keys9 = require("@dxos/keys");
3219
3703
  var import_util6 = require("@dxos/util");
3220
3704
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
3221
- return new import_codec_protobuf6.Stream(({ next }) => {
3705
+ return new import_codec_protobuf7.Stream(({ next }) => {
3222
3706
  const subscriptions = new import_async13.EventSubscriptions();
3223
3707
  const feedMap = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
3224
3708
  const update = () => {
@@ -3250,7 +3734,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
3250
3734
  });
3251
3735
  };
3252
3736
  var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
3253
- return new import_codec_protobuf6.Stream(({ next }) => {
3737
+ return new import_codec_protobuf7.Stream(({ next }) => {
3254
3738
  if (!feedKey) {
3255
3739
  return;
3256
3740
  }
@@ -3290,8 +3774,8 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
3290
3774
 
3291
3775
  // packages/sdk/client-services/src/packlets/devtools/keys.ts
3292
3776
  var import_async14 = require("@dxos/async");
3293
- var import_codec_protobuf7 = require("@dxos/codec-protobuf");
3294
- var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf7.Stream(({ next, ctx }) => {
3777
+ var import_codec_protobuf8 = require("@dxos/codec-protobuf");
3778
+ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf8.Stream(({ next, ctx }) => {
3295
3779
  const update = async () => {
3296
3780
  next({
3297
3781
  keys: await keyring.list()
@@ -3302,8 +3786,8 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf7.Stream(
3302
3786
  });
3303
3787
 
3304
3788
  // packages/sdk/client-services/src/packlets/devtools/metadata.ts
3305
- var import_codec_protobuf8 = require("@dxos/codec-protobuf");
3306
- var subscribeToMetadata = ({ context }) => new import_codec_protobuf8.Stream(({ next, ctx }) => {
3789
+ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
3790
+ var subscribeToMetadata = ({ context }) => new import_codec_protobuf9.Stream(({ next, ctx }) => {
3307
3791
  context.metadataStore.update.on(ctx, (data) => next({
3308
3792
  metadata: data
3309
3793
  }));
@@ -3313,10 +3797,10 @@ var subscribeToMetadata = ({ context }) => new import_codec_protobuf8.Stream(({
3313
3797
  });
3314
3798
 
3315
3799
  // packages/sdk/client-services/src/packlets/devtools/network.ts
3316
- var import_codec_protobuf9 = require("@dxos/codec-protobuf");
3800
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3317
3801
  var import_context7 = require("@dxos/context");
3318
3802
  var import_keys10 = require("@dxos/keys");
3319
- var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf9.Stream(({ next, close }) => {
3803
+ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next, close }) => {
3320
3804
  const update = () => {
3321
3805
  try {
3322
3806
  const status = signalManager.getStatus();
@@ -3330,7 +3814,7 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf9
3330
3814
  signalManager.statusChanged.on(() => update());
3331
3815
  update();
3332
3816
  });
3333
- var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf9.Stream(({ next }) => {
3817
+ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next }) => {
3334
3818
  const ctx = new import_context7.Context();
3335
3819
  signalManager.onMessage.on(ctx, (message) => {
3336
3820
  next({
@@ -3352,7 +3836,7 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf9.Stream
3352
3836
  return ctx.dispose();
3353
3837
  };
3354
3838
  });
3355
- var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf9.Stream(({ next }) => {
3839
+ var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf10.Stream(({ next }) => {
3356
3840
  var _a;
3357
3841
  const update = () => {
3358
3842
  var _a2;
@@ -3368,9 +3852,9 @@ var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf9.St
3368
3852
  });
3369
3853
 
3370
3854
  // packages/sdk/client-services/src/packlets/devtools/spaces.ts
3371
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3855
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3372
3856
  var subscribeToSpaces = (context, { spaceKeys = [] }) => {
3373
- return new import_codec_protobuf10.Stream(({ next }) => {
3857
+ return new import_codec_protobuf11.Stream(({ next }) => {
3374
3858
  let unsubscribe;
3375
3859
  const update = async () => {
3376
3860
  const spaces = [
@@ -3414,7 +3898,7 @@ var DevtoolsServiceImpl = class {
3414
3898
  this.params = params;
3415
3899
  }
3416
3900
  events(request) {
3417
- return new import_codec_protobuf11.Stream(({ next }) => {
3901
+ return new import_codec_protobuf12.Stream(({ next }) => {
3418
3902
  this.params.events.ready.on(() => {
3419
3903
  next({
3420
3904
  ready: {}
@@ -3521,9 +4005,9 @@ var DevtoolsServiceImpl = class {
3521
4005
  };
3522
4006
 
3523
4007
  // packages/sdk/client-services/src/packlets/locks/node.ts
3524
- var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
4008
+ var import_invariant13 = require("@dxos/invariant");
3525
4009
  var import_lock_file = require("@dxos/lock-file");
3526
- var import_log13 = require("@dxos/log");
4010
+ var import_log14 = require("@dxos/log");
3527
4011
  function _ts_decorate3(decorators, target, key, desc) {
3528
4012
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3529
4013
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3534,7 +4018,7 @@ function _ts_decorate3(decorators, target, key, desc) {
3534
4018
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3535
4019
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3536
4020
  }
3537
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
4021
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
3538
4022
  var Lock = class {
3539
4023
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
3540
4024
  this._lockPath = lockPath;
@@ -3546,16 +4030,16 @@ var Lock = class {
3546
4030
  }
3547
4031
  async acquire() {
3548
4032
  var _a;
3549
- (0, import_log13.log)("acquiring lock...", void 0, {
3550
- F: __dxlog_file13,
4033
+ (0, import_log14.log)("acquiring lock...", void 0, {
4034
+ F: __dxlog_file16,
3551
4035
  L: 32,
3552
4036
  S: this,
3553
4037
  C: (f, a) => f(...a)
3554
4038
  });
3555
4039
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
3556
4040
  await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3557
- (0, import_log13.log)("acquired lock", void 0, {
3558
- F: __dxlog_file13,
4041
+ (0, import_log14.log)("acquired lock", void 0, {
4042
+ F: __dxlog_file16,
3559
4043
  L: 37,
3560
4044
  S: this,
3561
4045
  C: (f, a) => f(...a)
@@ -3564,33 +4048,42 @@ var Lock = class {
3564
4048
  async release() {
3565
4049
  var _a;
3566
4050
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3567
- (0, import_tiny_invariant12.default)(this._fileHandle, "Lock is not acquired");
4051
+ (0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
4052
+ F: __dxlog_file16,
4053
+ L: 42,
4054
+ S: this,
4055
+ A: [
4056
+ "this._fileHandle",
4057
+ "'Lock is not acquired'"
4058
+ ]
4059
+ });
3568
4060
  await import_lock_file.LockFile.release(this._fileHandle);
3569
4061
  }
3570
4062
  };
3571
4063
  _ts_decorate3([
3572
- import_log13.logInfo
4064
+ import_log14.logInfo
3573
4065
  ], Lock.prototype, "lockKey", null);
3574
4066
 
3575
4067
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
3576
4068
  var import_async16 = require("@dxos/async");
3577
- var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3578
- var import_log14 = require("@dxos/log");
3579
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
4069
+ var import_codec_protobuf13 = require("@dxos/codec-protobuf");
4070
+ var import_log15 = require("@dxos/log");
4071
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3580
4072
  var import_util7 = require("@dxos/util");
3581
4073
  var LoggingServiceImpl = class {
3582
4074
  constructor() {
3583
4075
  this._logs = new import_async16.Event();
4076
+ this._started = new Date();
3584
4077
  this._logProcessor = (_config, entry2) => {
3585
4078
  this._logs.emit(entry2);
3586
4079
  };
3587
4080
  }
3588
4081
  async open() {
3589
- import_log14.log.runtimeConfig.processors.push(this._logProcessor);
4082
+ import_log15.log.runtimeConfig.processors.push(this._logProcessor);
3590
4083
  }
3591
4084
  async close() {
3592
- const index = import_log14.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
3593
- import_log14.log.runtimeConfig.processors.splice(index, 1);
4085
+ const index = import_log15.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
4086
+ import_log15.log.runtimeConfig.processors.splice(index, 1);
3594
4087
  }
3595
4088
  async controlMetrics({ reset, record }) {
3596
4089
  if (reset) {
@@ -3605,35 +4098,41 @@ var LoggingServiceImpl = class {
3605
4098
  recording: import_util7.tracer.recording
3606
4099
  };
3607
4100
  }
3608
- queryMetrics({ interval }) {
3609
- const createNumericalValues = (key) => {
4101
+ /**
4102
+ * @deprecated (Move to diagnostics).
4103
+ */
4104
+ queryMetrics({ interval = 5e3 }) {
4105
+ const getNumericalValues = (key) => {
3610
4106
  var _a;
3611
- const consume = (_a = import_util7.tracer.get(key)) != null ? _a : [];
4107
+ const events = (_a = import_util7.tracer.get(key)) != null ? _a : [];
3612
4108
  return {
3613
4109
  key,
3614
- stats: (0, import_util7.numericalValues)(consume, "duration")
4110
+ stats: (0, import_util7.numericalValues)(events, "duration")
3615
4111
  };
3616
4112
  };
3617
- return new import_codec_protobuf12.Stream(({ next }) => {
4113
+ return new import_codec_protobuf13.Stream(({ next }) => {
3618
4114
  const update = () => {
3619
4115
  const metrics = {
3620
4116
  timestamp: new Date(),
3621
4117
  values: [
3622
- createNumericalValues("dxos.echo.pipeline.control"),
3623
- createNumericalValues("dxos.echo.pipeline.data")
3624
- ]
4118
+ getNumericalValues("dxos.echo.pipeline.control"),
4119
+ getNumericalValues("dxos.echo.pipeline.data")
4120
+ ].filter(Boolean)
3625
4121
  };
3626
- next(metrics);
4122
+ next({
4123
+ timestamp: new Date(),
4124
+ metrics
4125
+ });
3627
4126
  };
3628
4127
  update();
3629
- const i = setInterval(update, interval);
4128
+ const i = setInterval(update, Math.max(interval, 1e3));
3630
4129
  return () => {
3631
4130
  clearInterval(i);
3632
4131
  };
3633
4132
  });
3634
4133
  }
3635
4134
  queryLogs(request) {
3636
- return new import_codec_protobuf12.Stream(({ ctx, next }) => {
4135
+ return new import_codec_protobuf13.Stream(({ ctx, next }) => {
3637
4136
  const handler = (entry2) => {
3638
4137
  var _a, _b, _c, _d, _e;
3639
4138
  if (LOG_PROCESSING > 0) {
@@ -3647,7 +4146,7 @@ var LoggingServiceImpl = class {
3647
4146
  }
3648
4147
  const record = {
3649
4148
  ...entry2,
3650
- context: (0, import_util7.jsonify)((0, import_log14.getContextFromEntry)(entry2)),
4149
+ context: (0, import_util7.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
3651
4150
  timestamp: new Date(),
3652
4151
  meta: {
3653
4152
  // TODO(dmaretskyi): Fix proto.
@@ -3668,17 +4167,17 @@ var LoggingServiceImpl = class {
3668
4167
  };
3669
4168
  var matchFilter = (filter, level, path, options) => {
3670
4169
  switch (options) {
3671
- case import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE:
4170
+ case import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE:
3672
4171
  return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
3673
- case import_services11.QueryLogsRequest.MatchingOptions.EXPLICIT:
4172
+ case import_services12.QueryLogsRequest.MatchingOptions.EXPLICIT:
3674
4173
  return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
3675
4174
  }
3676
4175
  };
3677
4176
  var shouldLog = (entry2, request) => {
3678
4177
  var _a;
3679
- const options = (_a = request.options) != null ? _a : import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4178
+ const options = (_a = request.options) != null ? _a : import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
3680
4179
  if (request.filters === void 0) {
3681
- return options === import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4180
+ return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
3682
4181
  } else {
3683
4182
  return request.filters.some((filter) => {
3684
4183
  var _a2, _b;
@@ -3689,14 +4188,14 @@ var shouldLog = (entry2, request) => {
3689
4188
  var LOG_PROCESSING = 0;
3690
4189
 
3691
4190
  // packages/sdk/client-services/src/packlets/network/network-service.ts
3692
- var import_codec_protobuf13 = require("@dxos/codec-protobuf");
4191
+ var import_codec_protobuf14 = require("@dxos/codec-protobuf");
3693
4192
  var NetworkServiceImpl = class {
3694
4193
  constructor(networkManager, signalManager) {
3695
4194
  this.networkManager = networkManager;
3696
4195
  this.signalManager = signalManager;
3697
4196
  }
3698
4197
  queryStatus() {
3699
- return new import_codec_protobuf13.Stream(({ next }) => {
4198
+ return new import_codec_protobuf14.Stream(({ next }) => {
3700
4199
  const update = () => {
3701
4200
  next({
3702
4201
  swarm: this.networkManager.connectionState,
@@ -3770,12 +4269,15 @@ var toStorageType = (type) => {
3770
4269
  };
3771
4270
 
3772
4271
  // packages/sdk/client-services/src/packlets/system/system-service.ts
3773
- var import_codec_protobuf14 = require("@dxos/codec-protobuf");
4272
+ var import_codec_protobuf15 = require("@dxos/codec-protobuf");
4273
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
4274
+ var import_util9 = require("@dxos/util");
3774
4275
  var SystemServiceImpl = class {
3775
- constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
4276
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
3776
4277
  this._config = config;
3777
4278
  this._statusUpdate = statusUpdate;
3778
4279
  this._getCurrentStatus = getCurrentStatus;
4280
+ this._getDiagnostics = getDiagnostics;
3779
4281
  this._onUpdateStatus = onUpdateStatus;
3780
4282
  this._onReset = onReset;
3781
4283
  }
@@ -3783,12 +4285,25 @@ var SystemServiceImpl = class {
3783
4285
  var _a, _b;
3784
4286
  return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
3785
4287
  }
4288
+ /**
4289
+ * NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
4290
+ */
4291
+ async getDiagnostics({ keys } = {}) {
4292
+ const diagnostics = await this._getDiagnostics();
4293
+ return {
4294
+ timestamp: new Date(),
4295
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util9.jsonKeyReplacer)({
4296
+ truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4297
+ humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4298
+ })))
4299
+ };
4300
+ }
3786
4301
  async updateStatus({ status }) {
3787
4302
  await this._onUpdateStatus(status);
3788
4303
  }
3789
4304
  // TODO(burdon): Standardize interval option in stream request?
3790
4305
  queryStatus({ interval = 3e3 } = {}) {
3791
- return new import_codec_protobuf14.Stream(({ next }) => {
4306
+ return new import_codec_protobuf15.Stream(({ next }) => {
3792
4307
  const update = () => {
3793
4308
  next({
3794
4309
  status: this._getCurrentStatus()
@@ -3843,18 +4358,16 @@ function _ts_decorate4(decorators, target, key, desc) {
3843
4358
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3844
4359
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3845
4360
  }
3846
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
4361
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
3847
4362
  var createDefaultModelFactory = () => {
3848
- return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
4363
+ return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
3849
4364
  };
3850
4365
  var ClientServicesHost = class {
3851
4366
  constructor({
3852
4367
  config,
3853
4368
  modelFactory = createDefaultModelFactory(),
3854
- // TODO(burdon): Create ApolloLink abstraction (see Client).
3855
4369
  transportFactory,
3856
4370
  signalManager,
3857
- connectionLog,
3858
4371
  storage,
3859
4372
  // TODO(wittjosiah): Turn this on by default.
3860
4373
  lockKey,
@@ -3887,12 +4400,15 @@ var ClientServicesHost = class {
3887
4400
  this._systemService = new SystemServiceImpl({
3888
4401
  config: this._config,
3889
4402
  statusUpdate: this._statusUpdate,
3890
- getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
4403
+ getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
4404
+ getDiagnostics: () => {
4405
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
4406
+ },
3891
4407
  onUpdateStatus: async (status) => {
3892
4408
  var _a, _b;
3893
- if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
4409
+ if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
3894
4410
  await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
3895
- } else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
4411
+ } else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
3896
4412
  await ((_b = this._resourceLock) == null ? void 0 : _b.release());
3897
4413
  }
3898
4414
  },
@@ -3908,6 +4424,12 @@ var ClientServicesHost = class {
3908
4424
  get isOpen() {
3909
4425
  return this._open;
3910
4426
  }
4427
+ get config() {
4428
+ return this._config;
4429
+ }
4430
+ get context() {
4431
+ return this._serviceContext;
4432
+ }
3911
4433
  get serviceRegistry() {
3912
4434
  return this._serviceRegistry;
3913
4435
  }
@@ -3924,9 +4446,31 @@ var ClientServicesHost = class {
3924
4446
  */
3925
4447
  initialize({ config, ...options }) {
3926
4448
  var _a, _b, _c;
3927
- (0, import_tiny_invariant13.default)(!this._open, "service host is open");
4449
+ (0, import_invariant14.invariant)(!this._open, "service host is open", {
4450
+ F: __dxlog_file17,
4451
+ L: 172,
4452
+ S: this,
4453
+ A: [
4454
+ "!this._open",
4455
+ "'service host is open'"
4456
+ ]
4457
+ });
4458
+ import_log16.log.info("initializing...", void 0, {
4459
+ F: __dxlog_file17,
4460
+ L: 173,
4461
+ S: this,
4462
+ C: (f, a) => f(...a)
4463
+ });
3928
4464
  if (config) {
3929
- (0, import_tiny_invariant13.default)(!this._config, "config already set");
4465
+ (0, import_invariant14.invariant)(!this._config, "config already set", {
4466
+ F: __dxlog_file17,
4467
+ L: 176,
4468
+ S: this,
4469
+ A: [
4470
+ "!this._config",
4471
+ "'config already set'"
4472
+ ]
4473
+ });
3930
4474
  this._config = config;
3931
4475
  if (!this._storage) {
3932
4476
  this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
@@ -3936,12 +4480,26 @@ var ClientServicesHost = class {
3936
4480
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
3937
4481
  }), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
3938
4482
  this._signalManager = signalManager;
3939
- (0, import_tiny_invariant13.default)(!this._networkManager, "network manager already set");
4483
+ (0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
4484
+ F: __dxlog_file17,
4485
+ L: 192,
4486
+ S: this,
4487
+ A: [
4488
+ "!this._networkManager",
4489
+ "'network manager already set'"
4490
+ ]
4491
+ });
3940
4492
  this._networkManager = new import_network_manager2.NetworkManager({
3941
4493
  log: connectionLog,
3942
4494
  transportFactory,
3943
4495
  signalManager
3944
4496
  });
4497
+ import_log16.log.info("initialized", void 0, {
4498
+ F: __dxlog_file17,
4499
+ L: 199,
4500
+ S: this,
4501
+ C: (f, a) => f(...a)
4502
+ });
3945
4503
  }
3946
4504
  async open() {
3947
4505
  var _a, _b, _c;
@@ -3949,24 +4507,56 @@ var ClientServicesHost = class {
3949
4507
  return;
3950
4508
  }
3951
4509
  const traceId = import_keys12.PublicKey.random().toHex();
3952
- import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
4510
+ import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.begin({
3953
4511
  id: traceId
3954
4512
  }), {
3955
- F: __dxlog_file14,
3956
- L: 203,
4513
+ F: __dxlog_file17,
4514
+ L: 209,
3957
4515
  S: this,
3958
4516
  C: (f, a) => f(...a)
3959
4517
  });
3960
- (0, import_tiny_invariant13.default)(this._config, "config not set");
3961
- (0, import_tiny_invariant13.default)(this._storage, "storage not set");
3962
- (0, import_tiny_invariant13.default)(this._signalManager, "signal manager not set");
3963
- (0, import_tiny_invariant13.default)(this._networkManager, "network manager not set");
4518
+ (0, import_invariant14.invariant)(this._config, "config not set", {
4519
+ F: __dxlog_file17,
4520
+ L: 211,
4521
+ S: this,
4522
+ A: [
4523
+ "this._config",
4524
+ "'config not set'"
4525
+ ]
4526
+ });
4527
+ (0, import_invariant14.invariant)(this._storage, "storage not set", {
4528
+ F: __dxlog_file17,
4529
+ L: 212,
4530
+ S: this,
4531
+ A: [
4532
+ "this._storage",
4533
+ "'storage not set'"
4534
+ ]
4535
+ });
4536
+ (0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
4537
+ F: __dxlog_file17,
4538
+ L: 213,
4539
+ S: this,
4540
+ A: [
4541
+ "this._signalManager",
4542
+ "'signal manager not set'"
4543
+ ]
4544
+ });
4545
+ (0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
4546
+ F: __dxlog_file17,
4547
+ L: 214,
4548
+ S: this,
4549
+ A: [
4550
+ "this._networkManager",
4551
+ "'network manager not set'"
4552
+ ]
4553
+ });
3964
4554
  this._opening = true;
3965
- (0, import_log15.log)("opening...", {
4555
+ import_log16.log.info("opening...", {
3966
4556
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
3967
4557
  }, {
3968
- F: __dxlog_file14,
3969
- L: 211,
4558
+ F: __dxlog_file17,
4559
+ L: 217,
3970
4560
  S: this,
3971
4561
  C: (f, a) => f(...a)
3972
4562
  });
@@ -3997,19 +4587,19 @@ var ClientServicesHost = class {
3997
4587
  this._open = true;
3998
4588
  this._statusUpdate.emit();
3999
4589
  const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4000
- (0, import_log15.log)("opened", {
4590
+ import_log16.log.info("opened", {
4001
4591
  deviceKey
4002
4592
  }, {
4003
- F: __dxlog_file14,
4004
- L: 266,
4593
+ F: __dxlog_file17,
4594
+ L: 269,
4005
4595
  S: this,
4006
4596
  C: (f, a) => f(...a)
4007
4597
  });
4008
- import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
4598
+ import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.end({
4009
4599
  id: traceId
4010
4600
  }), {
4011
- F: __dxlog_file14,
4012
- L: 267,
4601
+ F: __dxlog_file17,
4602
+ L: 270,
4013
4603
  S: this,
4014
4604
  C: (f, a) => f(...a)
4015
4605
  });
@@ -4020,11 +4610,11 @@ var ClientServicesHost = class {
4020
4610
  return;
4021
4611
  }
4022
4612
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4023
- (0, import_log15.log)("closing...", {
4613
+ import_log16.log.info("closing...", {
4024
4614
  deviceKey
4025
4615
  }, {
4026
- F: __dxlog_file14,
4027
- L: 277,
4616
+ F: __dxlog_file17,
4617
+ L: 280,
4028
4618
  S: this,
4029
4619
  C: (f, a) => f(...a)
4030
4620
  });
@@ -4035,11 +4625,11 @@ var ClientServicesHost = class {
4035
4625
  await this._serviceContext.close();
4036
4626
  this._open = false;
4037
4627
  this._statusUpdate.emit();
4038
- (0, import_log15.log)("closed", {
4628
+ import_log16.log.info("closed", {
4039
4629
  deviceKey
4040
4630
  }, {
4041
- F: __dxlog_file14,
4042
- L: 283,
4631
+ F: __dxlog_file17,
4632
+ L: 286,
4043
4633
  S: this,
4044
4634
  C: (f, a) => f(...a)
4045
4635
  });
@@ -4047,33 +4637,33 @@ var ClientServicesHost = class {
4047
4637
  async reset() {
4048
4638
  var _a, _b, _c;
4049
4639
  const traceId = import_keys12.PublicKey.random().toHex();
4050
- import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
4640
+ import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
4051
4641
  id: traceId
4052
4642
  }), {
4053
- F: __dxlog_file14,
4054
- L: 288,
4643
+ F: __dxlog_file17,
4644
+ L: 291,
4055
4645
  S: this,
4056
4646
  C: (f, a) => f(...a)
4057
4647
  });
4058
- (0, import_log15.log)("resetting...", void 0, {
4059
- F: __dxlog_file14,
4060
- L: 290,
4648
+ (0, import_log16.log)("resetting...", void 0, {
4649
+ F: __dxlog_file17,
4650
+ L: 293,
4061
4651
  S: this,
4062
4652
  C: (f, a) => f(...a)
4063
4653
  });
4064
4654
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4065
4655
  await this._storage.reset();
4066
- (0, import_log15.log)("reset", void 0, {
4067
- F: __dxlog_file14,
4068
- L: 293,
4656
+ (0, import_log16.log)("reset", void 0, {
4657
+ F: __dxlog_file17,
4658
+ L: 296,
4069
4659
  S: this,
4070
4660
  C: (f, a) => f(...a)
4071
4661
  });
4072
- import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
4662
+ import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.end({
4073
4663
  id: traceId
4074
4664
  }), {
4075
- F: __dxlog_file14,
4076
- L: 294,
4665
+ F: __dxlog_file17,
4666
+ L: 297,
4077
4667
  S: this,
4078
4668
  C: (f, a) => f(...a)
4079
4669
  });
@@ -4088,6 +4678,7 @@ _ts_decorate4([
4088
4678
  ], ClientServicesHost.prototype, "close", null);
4089
4679
 
4090
4680
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
4681
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/invitation-utils.ts";
4091
4682
  var sanitizeInvitation = (invitation) => {
4092
4683
  return {
4093
4684
  invitationId: invitation.invitationId,
@@ -4107,7 +4698,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4107
4698
  hostObservable.subscribe(async (hostInvitation) => {
4108
4699
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
4109
4700
  switch (hostInvitation.state) {
4110
- case import_services13.Invitation.State.CONNECTING: {
4701
+ case import_services15.Invitation.State.CONNECTING: {
4111
4702
  if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onConnecting) == null ? void 0 : _b.call(_a, hostObservable)) {
4112
4703
  break;
4113
4704
  }
@@ -4115,29 +4706,37 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4115
4706
  guestObservable.subscribe(async (guestInvitation) => {
4116
4707
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
4117
4708
  switch (guestInvitation.state) {
4118
- case import_services13.Invitation.State.CONNECTING: {
4709
+ case import_services15.Invitation.State.CONNECTING: {
4119
4710
  if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
4120
4711
  break;
4121
4712
  }
4122
- (0, import_tiny_invariant14.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
4713
+ (0, import_invariant15.invariant)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey), void 0, {
4714
+ F: __dxlog_file18,
4715
+ L: 84,
4716
+ S: void 0,
4717
+ A: [
4718
+ "hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!)",
4719
+ ""
4720
+ ]
4721
+ });
4123
4722
  break;
4124
4723
  }
4125
- case import_services13.Invitation.State.CONNECTED: {
4724
+ case import_services15.Invitation.State.CONNECTED: {
4126
4725
  (_d2 = (_c2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _c2.onConnected) == null ? void 0 : _d2.call(_c2, guestObservable);
4127
4726
  break;
4128
4727
  }
4129
- case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
4728
+ case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
4130
4729
  if ((_f2 = (_e2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _e2.onReady) == null ? void 0 : _f2.call(_e2, guestObservable)) {
4131
4730
  break;
4132
4731
  }
4133
4732
  await guestObservable.authenticate(await authCode.wait());
4134
4733
  break;
4135
4734
  }
4136
- case import_services13.Invitation.State.AUTHENTICATING: {
4735
+ case import_services15.Invitation.State.AUTHENTICATING: {
4137
4736
  (_h2 = (_g2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _g2.onAuthenticating) == null ? void 0 : _h2.call(_g2, guestObservable);
4138
4737
  break;
4139
4738
  }
4140
- case import_services13.Invitation.State.SUCCESS: {
4739
+ case import_services15.Invitation.State.SUCCESS: {
4141
4740
  if ((_j2 = (_i2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _i2.onSuccess) == null ? void 0 : _j2.call(_i2, guestObservable)) {
4142
4741
  break;
4143
4742
  }
@@ -4146,7 +4745,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4146
4745
  });
4147
4746
  break;
4148
4747
  }
4149
- case import_services13.Invitation.State.CANCELLED: {
4748
+ case import_services15.Invitation.State.CANCELLED: {
4150
4749
  if ((_l2 = (_k2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _k2.onCancelled) == null ? void 0 : _l2.call(_k2, guestObservable)) {
4151
4750
  break;
4152
4751
  }
@@ -4155,7 +4754,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4155
4754
  });
4156
4755
  break;
4157
4756
  }
4158
- case import_services13.Invitation.State.TIMEOUT: {
4757
+ case import_services15.Invitation.State.TIMEOUT: {
4159
4758
  if ((_n2 = (_m2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _m2.onTimeout) == null ? void 0 : _n2.call(_m2, guestObservable)) {
4160
4759
  return;
4161
4760
  }
@@ -4175,11 +4774,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4175
4774
  });
4176
4775
  break;
4177
4776
  }
4178
- case import_services13.Invitation.State.CONNECTED: {
4777
+ case import_services15.Invitation.State.CONNECTED: {
4179
4778
  (_d = (_c = hooks == null ? void 0 : hooks.host) == null ? void 0 : _c.onConnected) == null ? void 0 : _d.call(_c, hostObservable);
4180
4779
  break;
4181
4780
  }
4182
- case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
4781
+ case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
4183
4782
  if ((_f = (_e = hooks == null ? void 0 : hooks.host) == null ? void 0 : _e.onReady) == null ? void 0 : _f.call(_e, hostObservable)) {
4184
4783
  break;
4185
4784
  }
@@ -4188,11 +4787,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4188
4787
  }
4189
4788
  break;
4190
4789
  }
4191
- case import_services13.Invitation.State.AUTHENTICATING: {
4790
+ case import_services15.Invitation.State.AUTHENTICATING: {
4192
4791
  (_h = (_g = hooks == null ? void 0 : hooks.host) == null ? void 0 : _g.onAuthenticating) == null ? void 0 : _h.call(_g, hostObservable);
4193
4792
  break;
4194
4793
  }
4195
- case import_services13.Invitation.State.SUCCESS: {
4794
+ case import_services15.Invitation.State.SUCCESS: {
4196
4795
  if ((_j = (_i = hooks == null ? void 0 : hooks.host) == null ? void 0 : _i.onSuccess) == null ? void 0 : _j.call(_i, hostObservable)) {
4197
4796
  break;
4198
4797
  }
@@ -4201,7 +4800,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4201
4800
  });
4202
4801
  break;
4203
4802
  }
4204
- case import_services13.Invitation.State.CANCELLED: {
4803
+ case import_services15.Invitation.State.CANCELLED: {
4205
4804
  if ((_l = (_k = hooks == null ? void 0 : hooks.host) == null ? void 0 : _k.onCancelled) == null ? void 0 : _l.call(_k, hostObservable)) {
4206
4805
  break;
4207
4806
  }
@@ -4210,7 +4809,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4210
4809
  });
4211
4810
  break;
4212
4811
  }
4213
- case import_services13.Invitation.State.TIMEOUT: {
4812
+ case import_services15.Invitation.State.TIMEOUT: {
4214
4813
  if ((_n = (_m = hooks == null ? void 0 : hooks.host) == null ? void 0 : _m.onTimeout) == null ? void 0 : _n.call(_m, hostObservable)) {
4215
4814
  break;
4216
4815
  }
@@ -4236,12 +4835,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4236
4835
  };
4237
4836
  var createInvitation = (host, options) => {
4238
4837
  options != null ? options : options = {
4239
- authMethod: import_services13.Invitation.AuthMethod.NONE,
4838
+ authMethod: import_services15.Invitation.AuthMethod.NONE,
4240
4839
  ...options != null ? options : {}
4241
4840
  };
4242
4841
  if (host instanceof ServiceContext) {
4243
4842
  const hostHandler = host.getInvitationHandler({
4244
- kind: import_services13.Invitation.Kind.SPACE,
4843
+ kind: import_services15.Invitation.Kind.SPACE,
4245
4844
  ...options
4246
4845
  });
4247
4846
  return host.invitations.createInvitation(hostHandler, options);
@@ -4261,7 +4860,7 @@ var acceptInvitation = (guest, invitation) => {
4261
4860
 
4262
4861
  // packages/sdk/client-services/src/packlets/testing/test-builder.ts
4263
4862
  var import_context8 = require("@dxos/context");
4264
- var import_credentials15 = require("@dxos/credentials");
4863
+ var import_credentials16 = require("@dxos/credentials");
4265
4864
  var import_debug8 = require("@dxos/debug");
4266
4865
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
4267
4866
  var import_testing = require("@dxos/echo-pipeline/testing");
@@ -4406,8 +5005,8 @@ var createSigningContext = async (keyring) => {
4406
5005
  return {
4407
5006
  identityKey,
4408
5007
  deviceKey,
4409
- credentialSigner: (0, import_credentials15.createCredentialSignerWithChain)(keyring, {
4410
- credential: await new import_credentials15.CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey)
5008
+ credentialSigner: (0, import_credentials16.createCredentialSignerWithChain)(keyring, {
5009
+ credential: await new import_credentials16.CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey)
4411
5010
  }, deviceKey),
4412
5011
  recordCredential: async () => {
4413
5012
  }