@dxos/client-services 0.1.25 → 0.1.27-next.a0dff21

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 (155) hide show
  1. package/dist/lib/browser/{chunk-R2FEBB66.mjs → chunk-OTSGRZZI.mjs} +796 -579
  2. package/dist/lib/browser/chunk-OTSGRZZI.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +19 -15
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +46 -46
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +4 -4
  7. package/dist/lib/node/index.cjs +864 -641
  8. package/dist/lib/node/index.cjs.map +4 -4
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +753 -631
  11. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  12. package/dist/types/src/index.d.ts +0 -1
  13. package/dist/types/src/index.d.ts.map +1 -1
  14. package/dist/types/src/packlets/deprecated/index.d.ts +0 -3
  15. package/dist/types/src/packlets/deprecated/index.d.ts.map +1 -1
  16. package/dist/types/src/packlets/{identity/devices-service-impl.d.ts → devices/devices-service.d.ts} +4 -3
  17. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -0
  18. package/dist/types/src/packlets/devices/index.d.ts +2 -0
  19. package/dist/types/src/packlets/devices/index.d.ts.map +1 -0
  20. package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
  21. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  22. package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -2
  23. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  24. package/dist/types/src/packlets/identity/identity-service.d.ts +14 -0
  25. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -0
  26. package/dist/types/src/packlets/identity/identity.d.ts +2 -2
  27. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  28. package/dist/types/src/packlets/identity/index.d.ts +1 -0
  29. package/dist/types/src/packlets/identity/index.d.ts.map +1 -1
  30. package/dist/types/src/packlets/invitations/{halo-invitations-handler.d.ts → device-invitations-handler.d.ts} +5 -5
  31. package/dist/types/src/packlets/invitations/device-invitations-handler.d.ts.map +1 -0
  32. package/dist/types/src/packlets/invitations/device-invitations-handler.test.d.ts +2 -0
  33. package/dist/types/src/packlets/invitations/device-invitations-handler.test.d.ts.map +1 -0
  34. package/dist/types/src/packlets/invitations/{halo-invitations-proxy.d.ts → device-invitations-proxy.d.ts} +2 -2
  35. package/dist/types/src/packlets/invitations/device-invitations-proxy.d.ts.map +1 -0
  36. package/dist/types/src/packlets/invitations/{halo-invitations-service.d.ts → device-invitations-service.d.ts} +2 -2
  37. package/dist/types/src/packlets/invitations/device-invitations-service.d.ts.map +1 -0
  38. package/dist/types/src/packlets/invitations/device-invitations-service.test.d.ts +2 -0
  39. package/dist/types/src/packlets/invitations/device-invitations-service.test.d.ts.map +1 -0
  40. package/dist/types/src/packlets/invitations/index.d.ts +3 -3
  41. package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
  42. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +6 -0
  43. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  44. package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts +1 -1
  45. package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
  46. package/dist/types/src/packlets/services/index.d.ts +0 -1
  47. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  48. package/dist/types/src/packlets/services/service-context.d.ts +3 -3
  49. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  50. package/dist/types/src/packlets/services/service-definitions.d.ts +5 -7
  51. package/dist/types/src/packlets/services/service-definitions.d.ts.map +1 -1
  52. package/dist/types/src/packlets/services/service-host.d.ts +1 -0
  53. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  54. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +1 -1
  55. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  56. package/dist/types/src/packlets/spaces/data-space.d.ts +1 -1
  57. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  58. package/dist/types/src/packlets/spaces/spaces-service.d.ts +12 -5
  59. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  60. package/dist/types/src/packlets/system/index.d.ts +2 -0
  61. package/dist/types/src/packlets/system/index.d.ts.map +1 -0
  62. package/dist/types/src/packlets/system/system-service.d.ts +28 -0
  63. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -0
  64. package/dist/types/src/packlets/system/system-service.test.d.ts +2 -0
  65. package/dist/types/src/packlets/system/system-service.test.d.ts.map +1 -0
  66. package/dist/types/src/packlets/testing/index.d.ts +1 -1
  67. package/dist/types/src/packlets/testing/index.d.ts.map +1 -1
  68. package/dist/types/src/packlets/testing/test-builder.d.ts +1 -1
  69. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  70. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +11 -4
  71. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  72. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +6 -1
  73. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
  74. package/dist/types/src/packlets/vault/index.d.ts +2 -0
  75. package/dist/types/src/packlets/vault/index.d.ts.map +1 -1
  76. package/dist/types/src/packlets/vault/services.d.ts +9 -1
  77. package/dist/types/src/packlets/vault/services.d.ts.map +1 -1
  78. package/dist/types/src/packlets/vault/shell-controller.d.ts +18 -0
  79. package/dist/types/src/packlets/vault/shell-controller.d.ts.map +1 -0
  80. package/dist/types/src/packlets/vault/shell-runtime.d.ts +45 -0
  81. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -0
  82. package/dist/types/src/packlets/vault/worker-runtime.d.ts +2 -1
  83. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  84. package/dist/types/src/packlets/vault/worker-session.d.ts +4 -1
  85. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  86. package/package.json +29 -28
  87. package/src/index.ts +0 -1
  88. package/src/packlets/deprecated/index.ts +0 -3
  89. package/src/packlets/{identity/devices-service-impl.ts → devices/devices-service.ts} +10 -8
  90. package/src/packlets/devices/index.ts +5 -0
  91. package/src/packlets/devtools/spaces.ts +1 -1
  92. package/src/packlets/identity/authenticator.ts +1 -1
  93. package/src/packlets/identity/identity-manager.test.ts +1 -1
  94. package/src/packlets/identity/identity-manager.ts +2 -2
  95. package/src/packlets/identity/identity-service.ts +67 -0
  96. package/src/packlets/identity/identity.test.ts +1 -1
  97. package/src/packlets/identity/identity.ts +1 -1
  98. package/src/packlets/identity/index.ts +1 -0
  99. package/src/packlets/invitations/{halo-invitations-handler.test.ts → device-invitations-handler.test.ts} +2 -2
  100. package/src/packlets/invitations/{halo-invitations-handler.ts → device-invitations-handler.ts} +4 -4
  101. package/src/packlets/invitations/{halo-invitations-proxy.ts → device-invitations-proxy.ts} +1 -1
  102. package/src/packlets/invitations/{halo-invitations-service.test.ts → device-invitations-service.test.ts} +10 -10
  103. package/src/packlets/invitations/{halo-invitations-service.ts → device-invitations-service.ts} +1 -1
  104. package/src/packlets/invitations/index.ts +3 -3
  105. package/src/packlets/invitations/invitations-handler.ts +6 -0
  106. package/src/packlets/invitations/invitations-service.ts +2 -2
  107. package/src/packlets/invitations/space-invitations-handler.test.ts +1 -1
  108. package/src/packlets/invitations/space-invitations-handler.ts +55 -20
  109. package/src/packlets/services/index.ts +0 -1
  110. package/src/packlets/services/service-context.test.ts +3 -3
  111. package/src/packlets/services/service-context.ts +5 -5
  112. package/src/packlets/services/service-definitions.ts +14 -14
  113. package/src/packlets/services/service-host.test.ts +9 -9
  114. package/src/packlets/services/service-host.ts +40 -25
  115. package/src/packlets/spaces/data-space-manager.test.ts +1 -1
  116. package/src/packlets/spaces/data-space-manager.ts +4 -4
  117. package/src/packlets/spaces/data-space.ts +3 -3
  118. package/src/packlets/spaces/spaces-service.ts +93 -11
  119. package/src/packlets/system/index.ts +5 -0
  120. package/src/packlets/system/system-service.test.ts +80 -0
  121. package/src/packlets/system/system-service.ts +70 -0
  122. package/src/packlets/testing/index.ts +1 -1
  123. package/src/packlets/testing/test-builder.ts +3 -3
  124. package/src/packlets/vault/iframe-host-runtime.ts +28 -10
  125. package/src/packlets/vault/iframe-proxy-runtime.ts +16 -1
  126. package/src/packlets/vault/index.ts +2 -0
  127. package/src/packlets/vault/services.ts +17 -1
  128. package/src/packlets/vault/shell-controller.ts +56 -0
  129. package/src/packlets/vault/shell-runtime.ts +121 -0
  130. package/src/packlets/vault/worker-runtime.ts +3 -1
  131. package/src/packlets/vault/worker-session.ts +28 -19
  132. package/dist/lib/browser/chunk-R2FEBB66.mjs.map +0 -7
  133. package/dist/types/src/packlets/deprecated/invitations.d.ts +0 -47
  134. package/dist/types/src/packlets/deprecated/invitations.d.ts.map +0 -1
  135. package/dist/types/src/packlets/deprecated/profile.d.ts +0 -18
  136. package/dist/types/src/packlets/deprecated/profile.d.ts.map +0 -1
  137. package/dist/types/src/packlets/deprecated/space.d.ts +0 -23
  138. package/dist/types/src/packlets/deprecated/space.d.ts.map +0 -1
  139. package/dist/types/src/packlets/deprecated/system.d.ts +0 -24
  140. package/dist/types/src/packlets/deprecated/system.d.ts.map +0 -1
  141. package/dist/types/src/packlets/identity/devices-service-impl.d.ts.map +0 -1
  142. package/dist/types/src/packlets/invitations/halo-invitations-handler.d.ts.map +0 -1
  143. package/dist/types/src/packlets/invitations/halo-invitations-handler.test.d.ts +0 -2
  144. package/dist/types/src/packlets/invitations/halo-invitations-handler.test.d.ts.map +0 -1
  145. package/dist/types/src/packlets/invitations/halo-invitations-proxy.d.ts.map +0 -1
  146. package/dist/types/src/packlets/invitations/halo-invitations-service.d.ts.map +0 -1
  147. package/dist/types/src/packlets/invitations/halo-invitations-service.test.d.ts +0 -2
  148. package/dist/types/src/packlets/invitations/halo-invitations-service.test.d.ts.map +0 -1
  149. package/dist/types/src/packlets/services/signer.d.ts +0 -6
  150. package/dist/types/src/packlets/services/signer.d.ts.map +0 -1
  151. package/src/packlets/deprecated/invitations.ts +0 -63
  152. package/src/packlets/deprecated/profile.ts +0 -85
  153. package/src/packlets/deprecated/space.ts +0 -258
  154. package/src/packlets/deprecated/system.ts +0 -48
  155. package/src/packlets/services/signer.ts +0 -11
@@ -37,38 +37,40 @@ __export(src_exports, {
37
37
  AuthenticatingInvitationProvider: () => AuthenticatingInvitationProvider,
38
38
  ClientServicesHost: () => ClientServicesHost,
39
39
  ClientServicesProxy: () => ClientServicesProxy,
40
+ DeviceInvitationsHandler: () => DeviceInvitationsHandler,
41
+ DeviceInvitationsProxy: () => DeviceInvitationsProxy,
42
+ DeviceInvitationsServiceImpl: () => DeviceInvitationsServiceImpl,
40
43
  DevtoolsHostEvents: () => DevtoolsHostEvents,
41
44
  DevtoolsServiceImpl: () => DevtoolsServiceImpl,
42
- HaloInvitationsHandler: () => HaloInvitationsHandler,
43
- HaloInvitationsProxy: () => HaloInvitationsProxy,
44
- HaloInvitationsServiceImpl: () => HaloInvitationsServiceImpl,
45
45
  IFrameHostRuntime: () => IFrameHostRuntime,
46
46
  IFrameProxyRuntime: () => IFrameProxyRuntime,
47
47
  INVITATION_TIMEOUT: () => INVITATION_TIMEOUT,
48
48
  Identity: () => Identity,
49
49
  IdentityManager: () => IdentityManager,
50
+ IdentityServiceImpl: () => IdentityServiceImpl,
50
51
  InvitationEncoder: () => InvitationEncoder,
51
52
  InvitationObservableProvider: () => InvitationObservableProvider,
53
+ MemoryShellRuntime: () => MemoryShellRuntime,
52
54
  ON_CLOSE_DELAY: () => ON_CLOSE_DELAY,
53
- ProfileServiceImpl: () => ProfileServiceImpl,
54
55
  ServiceContext: () => ServiceContext,
55
56
  ServiceRegistry: () => ServiceRegistry,
57
+ ShellController: () => ShellController,
58
+ ShellRuntimeImpl: () => ShellRuntimeImpl,
56
59
  SpaceInvitationsHandler: () => SpaceInvitationsHandler,
57
60
  SpaceInvitationsProxy: () => SpaceInvitationsProxy,
58
61
  SpaceInvitationsServiceImpl: () => SpaceInvitationsServiceImpl,
59
- SpaceServiceImpl: () => SpaceServiceImpl,
60
- SystemServiceImpl: () => SystemServiceImpl,
61
- TracingServiceImpl: () => TracingServiceImpl,
62
62
  TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
63
63
  VaultResourceLock: () => VaultResourceLock,
64
64
  WorkerRuntime: () => WorkerRuntime,
65
65
  WorkerSession: () => WorkerSession,
66
+ appServiceBundle: () => appServiceBundle,
66
67
  clientServiceBundle: () => clientServiceBundle,
67
68
  createAuthProvider: () => createAuthProvider,
68
69
  createDefaultModelFactory: () => createDefaultModelFactory,
69
70
  createStorageObjects: () => createStorageObjects,
70
71
  getNetworkPeers: () => getNetworkPeers,
71
72
  iframeServiceBundle: () => iframeServiceBundle,
73
+ shellServiceBundle: () => shellServiceBundle,
72
74
  subscribeToFeedBlocks: () => subscribeToFeedBlocks,
73
75
  subscribeToFeeds: () => subscribeToFeeds,
74
76
  subscribeToNetworkStatus: () => subscribeToNetworkStatus,
@@ -81,234 +83,23 @@ __export(src_exports, {
81
83
  });
82
84
  module.exports = __toCommonJS(src_exports);
83
85
 
84
- // packages/sdk/client-services/src/packlets/deprecated/space.ts
85
- var import_node_assert = __toESM(require("node:assert"));
86
- var import_codec_protobuf = require("@dxos/codec-protobuf");
87
- var import_debug = require("@dxos/debug");
88
- var import_log = require("@dxos/log");
89
- var import_client = require("@dxos/protocols/proto/dxos/client");
90
- var import_util = require("@dxos/util");
91
- var SpaceServiceImpl = class {
92
- constructor(serviceContext) {
93
- this.serviceContext = serviceContext;
94
- this.inviteeInvitations = /* @__PURE__ */ new Map();
95
- }
96
- subscribeToSpace(request) {
97
- return new import_codec_protobuf.Stream(({ next }) => {
98
- next({
99
- space: {
100
- publicKey: request.spaceKey,
101
- isOpen: true,
102
- isActive: true,
103
- members: []
104
- }
105
- });
106
- });
107
- }
108
- subscribeSpaces() {
109
- return new import_codec_protobuf.Stream(({ next, ctx }) => {
110
- const onUpdate = () => {
111
- const spaces = Array.from(this.serviceContext.dataSpaceManager.spaces.values()).filter((space) => this.serviceContext.dataServiceSubscriptions.getDataService(space.key)).map((space) => ({
112
- publicKey: space.key,
113
- isOpen: true,
114
- isActive: true,
115
- members: Array.from(space.inner.spaceState.members.values()).map((member) => {
116
- var _a, _b, _c;
117
- return {
118
- identityKey: member.key,
119
- profile: {
120
- identityKey: member.key,
121
- displayName: (_b = (_a = member.assertion.profile) == null ? void 0 : _a.displayName) != null ? _b : (0, import_util.humanize)(member.key)
122
- },
123
- presence: ((_c = this.serviceContext.identityManager.identity) == null ? void 0 : _c.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_client.SpaceMember.PresenceState.ONLINE : import_client.SpaceMember.PresenceState.OFFLINE
124
- };
125
- })
126
- }));
127
- (0, import_log.log)("update", {
128
- spaces
129
- }, {
130
- file: "space.ts",
131
- line: 119,
132
- scope: this,
133
- callSite: (f, a) => f(...a)
134
- });
135
- next({
136
- spaces
137
- });
138
- };
139
- setTimeout(async () => {
140
- if (!this.serviceContext.dataSpaceManager) {
141
- next({
142
- spaces: []
143
- });
144
- }
145
- await this.serviceContext.initialized.wait();
146
- const subscribeSpaces = () => {
147
- for (const space of this.serviceContext.dataSpaceManager.spaces.values()) {
148
- if (!this.serviceContext.dataServiceSubscriptions.getDataService(space.key)) {
149
- continue;
150
- }
151
- space.stateUpdate.on(ctx, onUpdate);
152
- space.presence.updated.on(ctx, onUpdate);
153
- }
154
- };
155
- this.serviceContext.dataSpaceManager.updated.on(ctx, () => {
156
- subscribeSpaces();
157
- onUpdate();
158
- });
159
- subscribeSpaces();
160
- onUpdate();
161
- });
162
- });
163
- }
164
- async getSpaceDetails(request) {
165
- return (0, import_debug.todo)();
166
- }
167
- async createSpace() {
168
- if (!this.serviceContext.identityManager.identity) {
169
- throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
170
- }
171
- await this.serviceContext.initialized.wait();
172
- const space = await this.serviceContext.dataSpaceManager.createSpace();
173
- return {
174
- publicKey: space.key,
175
- isOpen: true,
176
- isActive: true
177
- };
178
- }
179
- async cloneSpace(snapshot) {
180
- return (0, import_debug.todo)();
181
- }
182
- async setSpaceState(request) {
183
- return (0, import_debug.todo)();
184
- }
185
- async authenticateInvitation(request) {
186
- var _a;
187
- (0, import_node_assert.default)(request.processId, "Process ID is missing.");
188
- const invitation = this.inviteeInvitations.get(request.processId);
189
- (0, import_node_assert.default)(invitation, "Invitation not found.");
190
- (0, import_node_assert.default)(request.secret, "Secret not provided.");
191
- invitation.secret = request.secret;
192
- (_a = invitation.secretTrigger) == null ? void 0 : _a.call(invitation);
193
- }
194
- subscribeMembers(request) {
195
- return (0, import_debug.todo)();
196
- }
197
- async createSnapshot(request) {
198
- return (0, import_debug.todo)();
199
- }
200
- };
201
-
202
- // packages/sdk/client-services/src/packlets/deprecated/profile.ts
203
- var import_node_assert2 = __toESM(require("node:assert"));
204
- var import_codec_protobuf2 = require("@dxos/codec-protobuf");
205
- var import_credentials = require("@dxos/credentials");
206
- var import_debug2 = require("@dxos/debug");
207
- var ProfileServiceImpl = class {
208
- constructor(context) {
209
- this.context = context;
210
- this.inviteeInvitations = /* @__PURE__ */ new Map();
211
- }
212
- subscribeProfile() {
213
- return new import_codec_protobuf2.Stream(({ next }) => {
214
- const emitNext = () => {
215
- var _a;
216
- return next({
217
- profile: this.context.identityManager.identity ? {
218
- identityKey: this.context.identityManager.identity.identityKey,
219
- deviceKey: this.context.identityManager.identity.deviceKey,
220
- displayName: (_a = this.context.identityManager.identity.profileDocument) == null ? void 0 : _a.displayName,
221
- haloSpace: this.context.identityManager.identity.space.key
222
- } : void 0
223
- });
224
- };
225
- emitNext();
226
- return this.context.identityManager.stateUpdate.on(emitNext);
227
- });
228
- }
229
- async createProfile(request) {
230
- var _a;
231
- await this.context.createIdentity({
232
- displayName: request.displayName
233
- });
234
- return {
235
- identityKey: this.context.identityManager.identity.identityKey,
236
- deviceKey: this.context.identityManager.identity.deviceKey,
237
- displayName: (_a = this.context.identityManager.identity.profileDocument) == null ? void 0 : _a.displayName,
238
- haloSpace: this.context.identityManager.identity.space.key
239
- };
240
- }
241
- async recoverProfile(request) {
242
- return (0, import_debug2.todo)();
243
- if (!request.seedPhrase) {
244
- throw new Error("Recovery SeedPhrase not provided.");
245
- }
246
- }
247
- async signPresentation({ presentation, nonce }) {
248
- (0, import_node_assert2.default)(this.context.identityManager.identity, "Identity not initialized.");
249
- return await (0, import_credentials.signPresentation)({
250
- presentation,
251
- signer: this.context.keyring,
252
- signerKey: this.context.identityManager.identity.deviceKey,
253
- chain: this.context.identityManager.identity.deviceCredentialChain,
254
- nonce
255
- });
256
- }
257
- };
258
-
259
- // packages/sdk/client-services/src/packlets/deprecated/system.ts
260
- var SystemServiceImpl = class {
261
- constructor({ config, onInit, onStatus, onReset }) {
262
- this._config = config;
263
- this._onInit = onInit;
264
- this._onStatus = onStatus;
265
- this._onReset = onReset;
266
- }
267
- async getConfig() {
268
- return this._config.values;
269
- }
270
- // TODO(burdon): Connect to iframe RPC heartbeat for network status?
271
- async getStatus() {
272
- return this._onStatus();
273
- }
274
- async initSession() {
275
- await this._onInit();
276
- }
277
- async reset() {
278
- await this._onReset();
279
- }
280
- };
281
-
282
- // packages/sdk/client-services/src/packlets/deprecated/tracing.ts
283
- var TracingServiceImpl = class {
284
- constructor(_config) {
285
- this._config = _config;
286
- }
287
- async setTracingOptions() {
288
- throw new Error("Tracing not available.");
289
- }
290
- subscribeToRpcTrace() {
291
- throw new Error("Tracing not available.");
292
- }
293
- };
294
-
295
86
  // packages/sdk/client-services/src/packlets/devtools/devtools.ts
296
87
  var import_async2 = require("@dxos/async");
297
- var import_codec_protobuf7 = require("@dxos/codec-protobuf");
88
+ var import_codec_protobuf5 = require("@dxos/codec-protobuf");
298
89
 
299
90
  // packages/sdk/client-services/src/packlets/devtools/feeds.ts
300
91
  var import_async = require("@dxos/async");
301
- var import_codec_protobuf3 = require("@dxos/codec-protobuf");
92
+ var import_codec_protobuf = require("@dxos/codec-protobuf");
302
93
  var import_feed_store = require("@dxos/feed-store");
303
94
  var import_keys = require("@dxos/keys");
304
- var import_util2 = require("@dxos/util");
95
+ var import_util = require("@dxos/util");
305
96
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
306
- return new import_codec_protobuf3.Stream(({ next }) => {
97
+ return new import_codec_protobuf.Stream(({ next }) => {
307
98
  if ((feedKeys == null ? void 0 : feedKeys.length) === 0) {
308
99
  return;
309
100
  }
310
101
  const subscriptions = new import_async.EventSubscriptions();
311
- const feedMap = new import_util2.ComplexMap(import_keys.PublicKey.hash);
102
+ const feedMap = new import_util.ComplexMap(import_keys.PublicKey.hash);
312
103
  const update = () => {
313
104
  const { feeds } = feedStore;
314
105
  feeds.filter((feed) => !(feedKeys == null ? void 0 : feedKeys.length) || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
@@ -333,7 +124,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
333
124
  });
334
125
  };
335
126
  var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
336
- return new import_codec_protobuf3.Stream(({ next }) => {
127
+ return new import_codec_protobuf.Stream(({ next }) => {
337
128
  if (!feedKey) {
338
129
  return;
339
130
  }
@@ -372,8 +163,8 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
372
163
  };
373
164
 
374
165
  // packages/sdk/client-services/src/packlets/devtools/keys.ts
375
- var import_codec_protobuf4 = require("@dxos/codec-protobuf");
376
- var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf4.Stream(({ next }) => {
166
+ var import_codec_protobuf2 = require("@dxos/codec-protobuf");
167
+ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf2.Stream(({ next }) => {
377
168
  const update = () => {
378
169
  next({
379
170
  keys: keyring.list()
@@ -385,10 +176,10 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf4.Stream(
385
176
  });
386
177
 
387
178
  // packages/sdk/client-services/src/packlets/devtools/network.ts
388
- var import_codec_protobuf5 = require("@dxos/codec-protobuf");
179
+ var import_codec_protobuf3 = require("@dxos/codec-protobuf");
389
180
  var import_context = require("@dxos/context");
390
181
  var import_keys2 = require("@dxos/keys");
391
- var subscribeToNetworkStatus = ({ networkManager }) => new import_codec_protobuf5.Stream(({ next, close }) => {
182
+ var subscribeToNetworkStatus = ({ networkManager }) => new import_codec_protobuf3.Stream(({ next, close }) => {
392
183
  const update = () => {
393
184
  try {
394
185
  const status = networkManager.signalManager.getStatus();
@@ -402,7 +193,7 @@ var subscribeToNetworkStatus = ({ networkManager }) => new import_codec_protobuf
402
193
  networkManager.signalManager.statusChanged.on(update);
403
194
  update();
404
195
  });
405
- var subscribeToSignal = ({ networkManager }) => new import_codec_protobuf5.Stream(({ next }) => {
196
+ var subscribeToSignal = ({ networkManager }) => new import_codec_protobuf3.Stream(({ next }) => {
406
197
  const ctx = new import_context.Context();
407
198
  networkManager.signalManager.onMessage.on(ctx, (message) => {
408
199
  next({
@@ -424,7 +215,7 @@ var subscribeToSignal = ({ networkManager }) => new import_codec_protobuf5.Strea
424
215
  return ctx.dispose();
425
216
  };
426
217
  });
427
- var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf5.Stream(({ next, close }) => {
218
+ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf3.Stream(({ next, close }) => {
428
219
  const update = () => {
429
220
  try {
430
221
  const topics = networkManager.topics;
@@ -445,7 +236,7 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
445
236
  networkManager.topicsUpdated.on(update);
446
237
  update();
447
238
  });
448
- var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf5.Stream(({ next }) => {
239
+ var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf3.Stream(({ next }) => {
449
240
  var _a;
450
241
  const update = () => {
451
242
  var _a2;
@@ -473,9 +264,9 @@ var getNetworkPeers = ({ networkManager }, request) => {
473
264
  };
474
265
 
475
266
  // packages/sdk/client-services/src/packlets/devtools/spaces.ts
476
- var import_codec_protobuf6 = require("@dxos/codec-protobuf");
267
+ var import_codec_protobuf4 = require("@dxos/codec-protobuf");
477
268
  var subscribeToSpaces = (context, { spaceKeys = [] }) => {
478
- return new import_codec_protobuf6.Stream(({ next }) => {
269
+ return new import_codec_protobuf4.Stream(({ next }) => {
479
270
  let unsubscribe;
480
271
  const update = async () => {
481
272
  const spaces = [
@@ -519,7 +310,7 @@ var DevtoolsServiceImpl = class {
519
310
  this.params = params;
520
311
  }
521
312
  events(request) {
522
- return new import_codec_protobuf7.Stream(({ next }) => {
313
+ return new import_codec_protobuf5.Stream(({ next }) => {
523
314
  this.params.events.ready.on(() => {
524
315
  next({
525
316
  ready: {}
@@ -598,8 +389,8 @@ var DevtoolsServiceImpl = class {
598
389
  // packages/sdk/client-services/src/packlets/identity/authenticator.ts
599
390
  var import_async3 = require("@dxos/async");
600
391
  var import_context2 = require("@dxos/context");
601
- var import_credentials2 = require("@dxos/credentials");
602
- var import_log2 = require("@dxos/log");
392
+ var import_credentials = require("@dxos/credentials");
393
+ var import_log = require("@dxos/log");
603
394
  var import_protocols = require("@dxos/protocols");
604
395
  var createAuthProvider = (signer) => async (nonce) => {
605
396
  const credential = await signer.createCredential({
@@ -623,7 +414,7 @@ var TrustedKeySetAuthVerifier = class {
623
414
  get verifier() {
624
415
  return async (nonce, auth) => {
625
416
  const credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential").decode(auth);
626
- (0, import_log2.log)("authenticating...", {
417
+ (0, import_log.log)("authenticating...", {
627
418
  credential
628
419
  }, {
629
420
  file: "authenticator.ts",
@@ -631,9 +422,9 @@ var TrustedKeySetAuthVerifier = class {
631
422
  scope: this,
632
423
  callSite: (f, a) => f(...a)
633
424
  });
634
- const result = await (0, import_credentials2.verifyCredential)(credential);
425
+ const result = await (0, import_credentials.verifyCredential)(credential);
635
426
  if (result.kind === "fail") {
636
- (0, import_log2.log)("Invalid credential", {
427
+ (0, import_log.log)("Invalid credential", {
637
428
  result
638
429
  }, {
639
430
  file: "authenticator.ts",
@@ -644,7 +435,7 @@ var TrustedKeySetAuthVerifier = class {
644
435
  return false;
645
436
  }
646
437
  if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
647
- (0, import_log2.log)("Invalid nonce", {
438
+ (0, import_log.log)("Invalid nonce", {
648
439
  nonce,
649
440
  credential
650
441
  }, {
@@ -656,7 +447,7 @@ var TrustedKeySetAuthVerifier = class {
656
447
  return false;
657
448
  }
658
449
  if (this._isTrustedKey(credential.issuer)) {
659
- (0, import_log2.log)("key is not currently in trusted set, waiting...", {
450
+ (0, import_log.log)("key is not currently in trusted set, waiting...", {
660
451
  key: credential.issuer
661
452
  }, {
662
453
  file: "authenticator.ts",
@@ -672,7 +463,7 @@ var TrustedKeySetAuthVerifier = class {
672
463
  });
673
464
  const clear = this._params.update.on(this._ctx, () => {
674
465
  if (this._isTrustedKey(credential.issuer)) {
675
- (0, import_log2.log)("auth success", {
466
+ (0, import_log.log)("auth success", {
676
467
  key: credential.issuer
677
468
  }, {
678
469
  file: "authenticator.ts",
@@ -682,7 +473,7 @@ var TrustedKeySetAuthVerifier = class {
682
473
  });
683
474
  trigger.wake(true);
684
475
  } else {
685
- (0, import_log2.log)("key is not currently in trusted set, waiting...", {
476
+ (0, import_log.log)("key is not currently in trusted set, waiting...", {
686
477
  key: credential.issuer
687
478
  }, {
688
479
  file: "authenticator.ts",
@@ -710,13 +501,13 @@ var TrustedKeySetAuthVerifier = class {
710
501
  };
711
502
 
712
503
  // packages/sdk/client-services/src/packlets/identity/identity.ts
713
- var import_node_assert3 = __toESM(require("node:assert"));
504
+ var import_node_assert = __toESM(require("node:assert"));
714
505
  var import_async4 = require("@dxos/async");
715
- var import_credentials3 = require("@dxos/credentials");
716
- var import_debug3 = require("@dxos/debug");
506
+ var import_credentials2 = require("@dxos/credentials");
507
+ var import_debug = require("@dxos/debug");
717
508
  var import_feed_store2 = require("@dxos/feed-store");
718
- var import_log3 = require("@dxos/log");
719
- var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
509
+ var import_log2 = require("@dxos/log");
510
+ var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
720
511
  var AUTH_TIMEOUT = 3e4;
721
512
  var Identity = class {
722
513
  constructor({ space, signer, identityKey, deviceKey }) {
@@ -725,12 +516,12 @@ var Identity = class {
725
516
  this._signer = signer;
726
517
  this.identityKey = identityKey;
727
518
  this.deviceKey = deviceKey;
728
- this._deviceStateMachine = this.space.spaceState.registerProcessor(new import_credentials3.DeviceStateMachine({
519
+ this._deviceStateMachine = this.space.spaceState.registerProcessor(new import_credentials2.DeviceStateMachine({
729
520
  identityKey: this.identityKey,
730
521
  deviceKey: this.deviceKey,
731
522
  onUpdate: () => this.stateUpdate.emit()
732
523
  }));
733
- this._profileStateMachine = this.space.spaceState.registerProcessor(new import_credentials3.ProfileStateMachine({
524
+ this._profileStateMachine = this.space.spaceState.registerProcessor(new import_credentials2.ProfileStateMachine({
734
525
  identityKey: this.identityKey,
735
526
  onUpdate: () => this.stateUpdate.emit()
736
527
  }));
@@ -783,8 +574,8 @@ var Identity = class {
783
574
  var _a, _b;
784
575
  return {
785
576
  deviceKey: this.deviceKey,
786
- controlFeedKey: (_a = this.space.controlFeedKey) != null ? _a : (0, import_debug3.failUndefined)(),
787
- dataFeedKey: (_b = this.space.dataFeedKey) != null ? _b : (0, import_debug3.failUndefined)()
577
+ controlFeedKey: (_a = this.space.controlFeedKey) != null ? _a : (0, import_debug.failUndefined)(),
578
+ dataFeedKey: (_b = this.space.dataFeedKey) != null ? _b : (0, import_debug.failUndefined)()
788
579
  };
789
580
  }
790
581
  /**
@@ -792,17 +583,17 @@ var Identity = class {
792
583
  * Requires identity to be ready.
793
584
  */
794
585
  getIdentityCredentialSigner() {
795
- (0, import_node_assert3.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
796
- return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
586
+ (0, import_node_assert.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
587
+ return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
797
588
  }
798
589
  /**
799
590
  * Issues credentials as device.
800
591
  */
801
592
  getDeviceCredentialSigner() {
802
- return (0, import_credentials3.createCredentialSignerWithKey)(this._signer, this.deviceKey);
593
+ return (0, import_credentials2.createCredentialSignerWithKey)(this._signer, this.deviceKey);
803
594
  }
804
595
  async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
805
- (0, import_log3.log)("Admitting device:", {
596
+ (0, import_log2.log)("Admitting device:", {
806
597
  identityKey: this.identityKey,
807
598
  hostDevice: this.deviceKey,
808
599
  deviceKey,
@@ -831,7 +622,7 @@ var Identity = class {
831
622
  spaceKey: this.haloSpaceKey,
832
623
  deviceKey,
833
624
  identityKey: this.identityKey,
834
- designation: import_credentials4.AdmittedFeed.Designation.CONTROL
625
+ designation: import_credentials3.AdmittedFeed.Designation.CONTROL
835
626
  }
836
627
  }),
837
628
  await signer.createCredential({
@@ -841,7 +632,7 @@ var Identity = class {
841
632
  spaceKey: this.haloSpaceKey,
842
633
  deviceKey,
843
634
  identityKey: this.identityKey,
844
- designation: import_credentials4.AdmittedFeed.Designation.DATA
635
+ designation: import_credentials3.AdmittedFeed.Designation.DATA
845
636
  }
846
637
  })
847
638
  ].map((credential) => ({
@@ -853,12 +644,12 @@ var Identity = class {
853
644
  };
854
645
 
855
646
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
856
- var import_node_assert4 = __toESM(require("node:assert"));
647
+ var import_node_assert2 = __toESM(require("node:assert"));
857
648
  var import_async5 = require("@dxos/async");
858
- var import_credentials5 = require("@dxos/credentials");
859
- var import_log4 = require("@dxos/log");
860
- var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
861
- var import_util3 = require("@dxos/util");
649
+ var import_credentials4 = require("@dxos/credentials");
650
+ var import_log3 = require("@dxos/log");
651
+ var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
652
+ var import_util2 = require("@dxos/util");
862
653
  var IdentityManager = class {
863
654
  // TODO(burdon): IdentityManagerParams.
864
655
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
@@ -875,7 +666,7 @@ var IdentityManager = class {
875
666
  async open() {
876
667
  await this._metadataStore.load();
877
668
  const identityRecord = this._metadataStore.getIdentityRecord();
878
- (0, import_log4.log)("identity record", {
669
+ (0, import_log3.log)("identity record", {
879
670
  identityRecord
880
671
  }, {
881
672
  file: "identity-manager.ts",
@@ -895,8 +686,8 @@ var IdentityManager = class {
895
686
  await ((_a = this._identity) == null ? void 0 : _a.close());
896
687
  }
897
688
  async createIdentity({ displayName } = {}) {
898
- (0, import_node_assert4.default)(!this._identity, "Identity already exists.");
899
- (0, import_log4.log)("creating identity...", {}, {
689
+ (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
690
+ (0, import_log3.log)("creating identity...", {}, {
900
691
  file: "identity-manager.ts",
901
692
  line: 78,
902
693
  scope: this,
@@ -916,12 +707,12 @@ var IdentityManager = class {
916
707
  const identity = await this._constructIdentity(identityRecord);
917
708
  await identity.open();
918
709
  {
919
- const generator = new import_credentials5.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
710
+ const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
920
711
  const credentials = [
921
712
  // Space genesis.
922
713
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.spaceKey, identityRecord.haloSpace.genesisFeedKey),
923
714
  // Feed admission.
924
- await generator.createFeedAdmission(identityRecord.haloSpace.spaceKey, identityRecord.haloSpace.writeDataFeedKey, import_credentials6.AdmittedFeed.Designation.DATA)
715
+ await generator.createFeedAdmission(identityRecord.haloSpace.spaceKey, identityRecord.haloSpace.writeDataFeedKey, import_credentials5.AdmittedFeed.Designation.DATA)
925
716
  ];
926
717
  if (displayName) {
927
718
  credentials.push(await generator.createProfileCredential({
@@ -941,7 +732,7 @@ var IdentityManager = class {
941
732
  this._identity = identity;
942
733
  await this._identity.ready();
943
734
  this.stateUpdate.emit();
944
- (0, import_log4.log)("created identity", {
735
+ (0, import_log3.log)("created identity", {
945
736
  identityKey: identity.identityKey,
946
737
  deviceKey: identity.deviceKey
947
738
  }, {
@@ -956,7 +747,7 @@ var IdentityManager = class {
956
747
  * Accept an existing identity. Expects it's device key to be authorized (now or later).
957
748
  */
958
749
  async acceptIdentity(params) {
959
- (0, import_log4.log)("accepting identity", {
750
+ (0, import_log3.log)("accepting identity", {
960
751
  params
961
752
  }, {
962
753
  file: "identity-manager.ts",
@@ -964,7 +755,7 @@ var IdentityManager = class {
964
755
  scope: this,
965
756
  callSite: (f, a) => f(...a)
966
757
  });
967
- (0, import_node_assert4.default)(!this._identity, "Identity already exists.");
758
+ (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
968
759
  const identityRecord = {
969
760
  identityKey: params.identityKey,
970
761
  deviceKey: params.deviceKey,
@@ -981,7 +772,7 @@ var IdentityManager = class {
981
772
  await this._metadataStore.setIdentityRecord(identityRecord);
982
773
  await this._identity.ready();
983
774
  this.stateUpdate.emit();
984
- (0, import_log4.log)("accepted identity", {
775
+ (0, import_log3.log)("accepted identity", {
985
776
  identityKey: identity.identityKey,
986
777
  deviceKey: identity.deviceKey
987
778
  }, {
@@ -993,8 +784,8 @@ var IdentityManager = class {
993
784
  return identity;
994
785
  }
995
786
  async _constructIdentity(identityRecord) {
996
- (0, import_node_assert4.default)(!this._identity);
997
- (0, import_log4.log)("constructing identity", {
787
+ (0, import_node_assert2.default)(!this._identity);
788
+ (0, import_log3.log)("constructing identity", {
998
789
  identityRecord
999
790
  }, {
1000
791
  file: "identity-manager.ts",
@@ -1012,8 +803,8 @@ var IdentityManager = class {
1012
803
  spaceRecord: identityRecord.haloSpace,
1013
804
  swarmIdentity: {
1014
805
  peerKey: identityRecord.deviceKey,
1015
- credentialProvider: createAuthProvider((0, import_credentials5.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
1016
- credentialAuthenticator: (0, import_util3.deferFunction)(() => identity.authVerifier.verifier)
806
+ credentialProvider: createAuthProvider((0, import_credentials4.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
807
+ credentialAuthenticator: (0, import_util2.deferFunction)(() => identity.authVerifier.verifier)
1017
808
  },
1018
809
  identityKey: identityRecord.identityKey
1019
810
  });
@@ -1025,7 +816,7 @@ var IdentityManager = class {
1025
816
  identityKey: identityRecord.identityKey,
1026
817
  deviceKey: identityRecord.deviceKey
1027
818
  });
1028
- (0, import_log4.log)("done", {
819
+ (0, import_log3.log)("done", {
1029
820
  identityKey: identityRecord.identityKey
1030
821
  }, {
1031
822
  file: "identity-manager.ts",
@@ -1048,6 +839,54 @@ var IdentityManager = class {
1048
839
  }
1049
840
  };
1050
841
 
842
+ // packages/sdk/client-services/src/packlets/identity/identity-service.ts
843
+ var import_node_assert3 = __toESM(require("node:assert"));
844
+ var import_codec_protobuf6 = require("@dxos/codec-protobuf");
845
+ var import_credentials6 = require("@dxos/credentials");
846
+ var import_debug2 = require("@dxos/debug");
847
+ var IdentityServiceImpl = class {
848
+ // TODO(wittjosiah): Remove dependency on service context.
849
+ constructor(_serviceContext) {
850
+ this._serviceContext = _serviceContext;
851
+ }
852
+ async createIdentity(request) {
853
+ await this._serviceContext.createIdentity(request);
854
+ return this._getIdentity();
855
+ }
856
+ async recoverIdentity(request) {
857
+ return (0, import_debug2.todo)();
858
+ }
859
+ queryIdentity() {
860
+ return new import_codec_protobuf6.Stream(({ next }) => {
861
+ const emitNext = () => next({
862
+ identity: this._getIdentity()
863
+ });
864
+ emitNext();
865
+ return this._serviceContext.identityManager.stateUpdate.on(emitNext);
866
+ });
867
+ }
868
+ _getIdentity() {
869
+ if (!this._serviceContext.identityManager.identity) {
870
+ return void 0;
871
+ }
872
+ return {
873
+ identityKey: this._serviceContext.identityManager.identity.identityKey,
874
+ spaceKey: this._serviceContext.identityManager.identity.space.key,
875
+ profile: this._serviceContext.identityManager.identity.profileDocument
876
+ };
877
+ }
878
+ async signPresentation({ presentation, nonce }) {
879
+ (0, import_node_assert3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
880
+ return await (0, import_credentials6.signPresentation)({
881
+ presentation,
882
+ signer: this._serviceContext.keyring,
883
+ signerKey: this._serviceContext.identityManager.identity.deviceKey,
884
+ chain: this._serviceContext.identityManager.identity.deviceCredentialChain,
885
+ nonce
886
+ });
887
+ }
888
+ };
889
+
1051
890
  // packages/sdk/client-services/src/packlets/invitations/encoder.ts
1052
891
  var import_base_x = __toESM(require("base-x"));
1053
892
  var import_protocols2 = require("@dxos/protocols");
@@ -1062,13 +901,13 @@ var InvitationEncoder = class {
1062
901
  }
1063
902
  };
1064
903
 
1065
- // packages/sdk/client-services/src/packlets/invitations/halo-invitations-handler.ts
1066
- var import_node_assert6 = __toESM(require("node:assert"));
904
+ // packages/sdk/client-services/src/packlets/invitations/device-invitations-handler.ts
905
+ var import_node_assert5 = __toESM(require("node:assert"));
1067
906
  var import_async7 = require("@dxos/async");
1068
907
  var import_context3 = require("@dxos/context");
1069
908
  var import_credentials7 = require("@dxos/credentials");
1070
909
  var import_keys4 = require("@dxos/keys");
1071
- var import_log5 = require("@dxos/log");
910
+ var import_log4 = require("@dxos/log");
1072
911
  var import_network_manager = require("@dxos/network-manager");
1073
912
  var import_protocols3 = require("@dxos/protocols");
1074
913
  var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
@@ -1076,7 +915,7 @@ var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
1076
915
  var import_teleport = require("@dxos/teleport");
1077
916
 
1078
917
  // packages/sdk/client-services/src/packlets/invitations/invitations.ts
1079
- var import_node_assert5 = __toESM(require("node:assert"));
918
+ var import_node_assert4 = __toESM(require("node:assert"));
1080
919
  var import_async6 = require("@dxos/async");
1081
920
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
1082
921
  var AUTHENTICATION_CODE_LENGTH = 6;
@@ -1104,7 +943,7 @@ var wrapObservable = async (observable) => {
1104
943
  return new Promise((resolve, reject) => {
1105
944
  const unsubscribe = observable.subscribe({
1106
945
  onSuccess: (invitation) => {
1107
- (0, import_node_assert5.default)(invitation.state === import_services.Invitation.State.SUCCESS);
946
+ (0, import_node_assert4.default)(invitation.state === import_services.Invitation.State.SUCCESS);
1108
947
  unsubscribe();
1109
948
  resolve(invitation);
1110
949
  },
@@ -1124,8 +963,8 @@ var AbstractInvitationsHandler = class {
1124
963
  }
1125
964
  };
1126
965
 
1127
- // packages/sdk/client-services/src/packlets/invitations/halo-invitations-handler.ts
1128
- var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
966
+ // packages/sdk/client-services/src/packlets/invitations/device-invitations-handler.ts
967
+ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
1129
968
  // prettier-ignore
1130
969
  constructor(_params) {
1131
970
  super(_params.networkManager);
@@ -1136,7 +975,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1136
975
  */
1137
976
  createInvitation(context, options) {
1138
977
  const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
1139
- (0, import_node_assert6.default)(type !== import_services2.Invitation.Type.OFFLINE);
978
+ (0, import_node_assert5.default)(type !== import_services2.Invitation.Type.OFFLINE);
1140
979
  const identity = this._params.getIdentity();
1141
980
  const invitation = {
1142
981
  type,
@@ -1158,10 +997,10 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1158
997
  const createExtension = () => new HostHaloInvitationExtension({
1159
998
  requestAdmission: async () => {
1160
999
  var _a, _b;
1161
- (0, import_log5.log)("responding with admission offer", {
1000
+ (0, import_log4.log)("responding with admission offer", {
1162
1001
  host: identity.deviceKey
1163
1002
  }, {
1164
- file: "halo-invitations-handler.ts",
1003
+ file: "device-invitations-handler.ts",
1165
1004
  line: 91,
1166
1005
  scope: this,
1167
1006
  callSite: (f, a) => f(...a)
@@ -1174,10 +1013,10 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1174
1013
  };
1175
1014
  },
1176
1015
  authenticate: async ({ authenticationCode: code }) => {
1177
- (0, import_log5.log)("received authentication request", {
1016
+ (0, import_log4.log)("received authentication request", {
1178
1017
  authenticationCode: code
1179
1018
  }, {
1180
- file: "halo-invitations-handler.ts",
1019
+ file: "device-invitations-handler.ts",
1181
1020
  line: 105,
1182
1021
  scope: this,
1183
1022
  callSite: (f, a) => f(...a)
@@ -1195,11 +1034,11 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1195
1034
  throw new Error(`invalid authentication code: ${authenticationCode}`);
1196
1035
  }
1197
1036
  }
1198
- (0, import_log5.log)("writing guest credentials", {
1037
+ (0, import_log4.log)("writing guest credentials", {
1199
1038
  host: identity.deviceKey,
1200
1039
  guest: credentials.deviceKey
1201
1040
  }, {
1202
- file: "halo-invitations-handler.ts",
1041
+ file: "device-invitations-handler.ts",
1203
1042
  line: 120,
1204
1043
  scope: this,
1205
1044
  callSite: (f, a) => f(...a)
@@ -1215,10 +1054,10 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1215
1054
  (0, import_async7.scheduleTask)(ctx, async () => {
1216
1055
  var _a, _b;
1217
1056
  try {
1218
- (0, import_log5.log)("connected", {
1057
+ (0, import_log4.log)("connected", {
1219
1058
  host: identity.deviceKey
1220
1059
  }, {
1221
- file: "halo-invitations-handler.ts",
1060
+ file: "device-invitations-handler.ts",
1222
1061
  line: 136,
1223
1062
  scope: this,
1224
1063
  callSite: (f, a) => f(...a)
@@ -1227,11 +1066,11 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1227
1066
  const deviceKey = await complete.wait({
1228
1067
  timeout
1229
1068
  });
1230
- (0, import_log5.log)("admitted guest", {
1069
+ (0, import_log4.log)("admitted guest", {
1231
1070
  host: identity.deviceKey,
1232
1071
  guest: deviceKey
1233
1072
  }, {
1234
- file: "halo-invitations-handler.ts",
1073
+ file: "device-invitations-handler.ts",
1235
1074
  line: 139,
1236
1075
  scope: this,
1237
1076
  callSite: (f, a) => f(...a)
@@ -1239,8 +1078,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1239
1078
  observable.callback.onSuccess(invitation);
1240
1079
  } catch (err) {
1241
1080
  if (!observable.cancelled) {
1242
- import_log5.log.error("failed", err, {
1243
- file: "halo-invitations-handler.ts",
1081
+ import_log4.log.error("failed", err, {
1082
+ file: "device-invitations-handler.ts",
1244
1083
  line: 143,
1245
1084
  scope: this,
1246
1085
  callSite: (f, a) => f(...a)
@@ -1304,23 +1143,23 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1304
1143
  if (++connectionCount > 1) {
1305
1144
  throw new Error(`multiple connections detected: ${connectionCount}`);
1306
1145
  }
1307
- (0, import_log5.log)("connected", {}, {
1308
- file: "halo-invitations-handler.ts",
1146
+ (0, import_log4.log)("connected", {}, {
1147
+ file: "device-invitations-handler.ts",
1309
1148
  line: 214,
1310
1149
  scope: this,
1311
1150
  callSite: (f, a) => f(...a)
1312
1151
  });
1313
1152
  (_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
1314
- (0, import_log5.log)("sending admission request", {}, {
1315
- file: "halo-invitations-handler.ts",
1153
+ (0, import_log4.log)("sending admission request", {}, {
1154
+ file: "device-invitations-handler.ts",
1316
1155
  line: 218,
1317
1156
  scope: this,
1318
1157
  callSite: (f, a) => f(...a)
1319
1158
  });
1320
1159
  const { identityKey, haloSpaceKey, genesisFeedKey } = await extension.rpc.HaloHostService.requestAdmission();
1321
1160
  if (invitation.type === void 0 || invitation.type === import_services2.Invitation.Type.INTERACTIVE) {
1322
- (0, import_log5.log)("guest waiting for authentication code...", {}, {
1323
- file: "halo-invitations-handler.ts",
1161
+ (0, import_log4.log)("guest waiting for authentication code...", {}, {
1162
+ file: "device-invitations-handler.ts",
1324
1163
  line: 225,
1325
1164
  scope: this,
1326
1165
  callSite: (f, a) => f(...a)
@@ -1329,8 +1168,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1329
1168
  const authenticationCode = await authenticated.wait({
1330
1169
  timeout
1331
1170
  });
1332
- (0, import_log5.log)("sending authentication request", {}, {
1333
- file: "halo-invitations-handler.ts",
1171
+ (0, import_log4.log)("sending authentication request", {}, {
1172
+ file: "device-invitations-handler.ts",
1334
1173
  line: 228,
1335
1174
  scope: this,
1336
1175
  callSite: (f, a) => f(...a)
@@ -1342,13 +1181,13 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1342
1181
  const deviceKey = await this._params.keyring.createKey();
1343
1182
  const controlFeedKey = await this._params.keyring.createKey();
1344
1183
  const dataFeedKey = await this._params.keyring.createKey();
1345
- (0, import_log5.log)("presenting admission credentials", {
1184
+ (0, import_log4.log)("presenting admission credentials", {
1346
1185
  identityKey,
1347
1186
  deviceKey,
1348
1187
  controlFeedKey,
1349
1188
  dataFeedKey
1350
1189
  }, {
1351
- file: "halo-invitations-handler.ts",
1190
+ file: "device-invitations-handler.ts",
1352
1191
  line: 237,
1353
1192
  scope: this,
1354
1193
  callSite: (f, a) => f(...a)
@@ -1366,11 +1205,11 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1366
1205
  controlFeedKey,
1367
1206
  dataFeedKey
1368
1207
  });
1369
- (0, import_log5.log)("admitted by host", {
1208
+ (0, import_log4.log)("admitted by host", {
1370
1209
  guest: identity.deviceKey,
1371
1210
  identityKey
1372
1211
  }, {
1373
- file: "halo-invitations-handler.ts",
1212
+ file: "device-invitations-handler.ts",
1374
1213
  line: 256,
1375
1214
  scope: this,
1376
1215
  callSite: (f, a) => f(...a)
@@ -1378,8 +1217,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1378
1217
  complete.wake(identityKey);
1379
1218
  } catch (err) {
1380
1219
  if (!observable.cancelled) {
1381
- import_log5.log.warn("auth failed", err, {
1382
- file: "halo-invitations-handler.ts",
1220
+ import_log4.log.warn("auth failed", err, {
1221
+ file: "device-invitations-handler.ts",
1383
1222
  line: 260,
1384
1223
  scope: this,
1385
1224
  callSite: (f, a) => f(...a)
@@ -1396,7 +1235,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1396
1235
  };
1397
1236
  (0, import_async7.scheduleTask)(ctx, async () => {
1398
1237
  var _a, _b;
1399
- (0, import_node_assert6.default)(invitation.swarmKey);
1238
+ (0, import_node_assert5.default)(invitation.swarmKey);
1400
1239
  const topic = invitation.swarmKey;
1401
1240
  const swarmConnection = await this._networkManager.joinSwarm({
1402
1241
  topic,
@@ -1466,9 +1305,9 @@ var GuestHaloInvitationExtension = class extends import_teleport.RpcExtension {
1466
1305
  };
1467
1306
 
1468
1307
  // packages/sdk/client-services/src/packlets/invitations/invitations-proxy.ts
1469
- var import_node_assert7 = __toESM(require("node:assert"));
1308
+ var import_node_assert6 = __toESM(require("node:assert"));
1470
1309
  var import_async8 = require("@dxos/async");
1471
- var import_log6 = require("@dxos/log");
1310
+ var import_log5 = require("@dxos/log");
1472
1311
  var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
1473
1312
  var AbstractInvitationsProxy = class {
1474
1313
  // prettier-ignore
@@ -1494,7 +1333,7 @@ var AbstractInvitationsProxy = class {
1494
1333
  observable.setInvitation(invitation2);
1495
1334
  switch (invitation2.state) {
1496
1335
  case import_services3.Invitation.State.CONNECTING: {
1497
- (0, import_node_assert7.default)(invitation2.invitationId);
1336
+ (0, import_node_assert6.default)(invitation2.invitationId);
1498
1337
  invitationId = invitation2.invitationId;
1499
1338
  (_b = (_a = observable.callback).onConnecting) == null ? void 0 : _b.call(_a, invitation2);
1500
1339
  break;
@@ -1516,7 +1355,7 @@ var AbstractInvitationsProxy = class {
1516
1355
  break;
1517
1356
  }
1518
1357
  default: {
1519
- import_log6.log.error(`Invalid state: ${invitation2.state}`, {}, {
1358
+ import_log5.log.error(`Invalid state: ${invitation2.state}`, {}, {
1520
1359
  file: "invitations-proxy.ts",
1521
1360
  line: 81,
1522
1361
  scope: this,
@@ -1532,12 +1371,12 @@ var AbstractInvitationsProxy = class {
1532
1371
  return observable;
1533
1372
  }
1534
1373
  acceptInvitation(invitation, options) {
1535
- (0, import_node_assert7.default)(invitation && invitation.swarmKey);
1374
+ (0, import_node_assert6.default)(invitation && invitation.swarmKey);
1536
1375
  const observable = new AuthenticatingInvitationProvider({
1537
1376
  onCancel: async () => {
1538
1377
  var _a;
1539
1378
  const invitationId = (_a = observable.invitation) == null ? void 0 : _a.invitationId;
1540
- (0, import_node_assert7.default)(invitationId);
1379
+ (0, import_node_assert6.default)(invitationId);
1541
1380
  await this._invitationsService.cancelInvitation({
1542
1381
  invitationId
1543
1382
  });
@@ -1545,7 +1384,7 @@ var AbstractInvitationsProxy = class {
1545
1384
  onAuthenticate: async (authenticationCode) => {
1546
1385
  var _a;
1547
1386
  const invitationId = (_a = observable.invitation) == null ? void 0 : _a.invitationId;
1548
- (0, import_node_assert7.default)(invitationId);
1387
+ (0, import_node_assert6.default)(invitationId);
1549
1388
  await this._invitationsService.authenticate({
1550
1389
  invitationId,
1551
1390
  authenticationCode
@@ -1558,7 +1397,7 @@ var AbstractInvitationsProxy = class {
1558
1397
  });
1559
1398
  stream.subscribe((invitation2) => {
1560
1399
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1561
- (0, import_node_assert7.default)(invitation2.invitationId);
1400
+ (0, import_node_assert6.default)(invitation2.invitationId);
1562
1401
  observable.setInvitation(invitation2);
1563
1402
  switch (invitation2.state) {
1564
1403
  case import_services3.Invitation.State.CONNECTING: {
@@ -1582,7 +1421,7 @@ var AbstractInvitationsProxy = class {
1582
1421
  break;
1583
1422
  }
1584
1423
  default: {
1585
- import_log6.log.error(`Invalid state: ${invitation2.state}`, {}, {
1424
+ import_log5.log.error(`Invalid state: ${invitation2.state}`, {}, {
1586
1425
  file: "invitations-proxy.ts",
1587
1426
  line: 146,
1588
1427
  scope: this,
@@ -1599,17 +1438,17 @@ var AbstractInvitationsProxy = class {
1599
1438
  }
1600
1439
  };
1601
1440
 
1602
- // packages/sdk/client-services/src/packlets/invitations/halo-invitations-proxy.ts
1603
- var HaloInvitationsProxy = class extends AbstractInvitationsProxy {
1441
+ // packages/sdk/client-services/src/packlets/invitations/device-invitations-proxy.ts
1442
+ var DeviceInvitationsProxy = class extends AbstractInvitationsProxy {
1604
1443
  getInvitationOptions() {
1605
1444
  return {};
1606
1445
  }
1607
1446
  };
1608
1447
 
1609
1448
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1610
- var import_node_assert8 = __toESM(require("node:assert"));
1611
- var import_codec_protobuf8 = require("@dxos/codec-protobuf");
1612
- var import_log7 = require("@dxos/log");
1449
+ var import_node_assert7 = __toESM(require("node:assert"));
1450
+ var import_codec_protobuf7 = require("@dxos/codec-protobuf");
1451
+ var import_log6 = require("@dxos/log");
1613
1452
  var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
1614
1453
  var AbstractInvitationsService = class {
1615
1454
  // prettier-ignore
@@ -1627,47 +1466,48 @@ var AbstractInvitationsService = class {
1627
1466
  };
1628
1467
  }
1629
1468
  createInvitation(invitation) {
1630
- return new import_codec_protobuf8.Stream(({ next, close }) => {
1469
+ return new import_codec_protobuf7.Stream(({ next, close }) => {
1631
1470
  const invitationsHandler = this._getInvitationsHandler();
1632
1471
  const context = this.getContext(invitation);
1633
- (0, import_log7.log)("stream opened", this.getLoggingContext(), {
1472
+ (0, import_log6.log)("stream opened", this.getLoggingContext(), {
1634
1473
  file: "invitations-service.ts",
1635
1474
  line: 43,
1636
1475
  scope: this,
1637
1476
  callSite: (f, a) => f(...a)
1638
1477
  });
1639
1478
  let invitationId;
1640
- const { type, swarmKey } = invitation;
1479
+ const { type, swarmKey, authMethod } = invitation;
1641
1480
  const observable = invitationsHandler.createInvitation(context, {
1642
1481
  type,
1643
- swarmKey
1482
+ swarmKey,
1483
+ authMethod
1644
1484
  });
1645
1485
  observable.subscribe({
1646
1486
  onConnecting: (invitation2) => {
1647
- (0, import_node_assert8.default)(invitation2.invitationId);
1487
+ (0, import_node_assert7.default)(invitation2.invitationId);
1648
1488
  invitationId = invitation2.invitationId;
1649
1489
  this._createInvitations.set(invitation2.invitationId, observable);
1650
1490
  invitation2.state = import_services4.Invitation.State.CONNECTING;
1651
1491
  next(invitation2);
1652
1492
  },
1653
1493
  onConnected: (invitation2) => {
1654
- (0, import_node_assert8.default)(invitation2.invitationId);
1494
+ (0, import_node_assert7.default)(invitation2.invitationId);
1655
1495
  invitation2.state = import_services4.Invitation.State.CONNECTED;
1656
1496
  next(invitation2);
1657
1497
  },
1658
1498
  onAuthenticating: (invitation2) => {
1659
- (0, import_node_assert8.default)(invitation2.invitationId);
1499
+ (0, import_node_assert7.default)(invitation2.invitationId);
1660
1500
  invitation2.state = import_services4.Invitation.State.AUTHENTICATING;
1661
1501
  next(invitation2);
1662
1502
  },
1663
1503
  onSuccess: (invitation2) => {
1664
- (0, import_node_assert8.default)(invitation2.invitationId);
1504
+ (0, import_node_assert7.default)(invitation2.invitationId);
1665
1505
  invitation2.state = import_services4.Invitation.State.SUCCESS;
1666
1506
  next(invitation2);
1667
1507
  close();
1668
1508
  },
1669
1509
  onCancelled: () => {
1670
- (0, import_node_assert8.default)(invitationId);
1510
+ (0, import_node_assert7.default)(invitationId);
1671
1511
  invitation.invitationId = invitationId;
1672
1512
  invitation.state = import_services4.Invitation.State.CANCELLED;
1673
1513
  next(invitation);
@@ -1685,7 +1525,7 @@ var AbstractInvitationsService = class {
1685
1525
  return (err) => {
1686
1526
  const context2 = this.getLoggingContext();
1687
1527
  if (err) {
1688
- import_log7.log.warn("stream closed", {
1528
+ import_log6.log.warn("stream closed", {
1689
1529
  ...context2,
1690
1530
  err
1691
1531
  }, {
@@ -1695,7 +1535,7 @@ var AbstractInvitationsService = class {
1695
1535
  callSite: (f, a) => f(...a)
1696
1536
  });
1697
1537
  } else {
1698
- (0, import_log7.log)("stream closed", context2, {
1538
+ (0, import_log6.log)("stream closed", context2, {
1699
1539
  file: "invitations-service.ts",
1700
1540
  line: 94,
1701
1541
  scope: this,
@@ -1707,8 +1547,8 @@ var AbstractInvitationsService = class {
1707
1547
  });
1708
1548
  }
1709
1549
  acceptInvitation(invitation, options) {
1710
- return new import_codec_protobuf8.Stream(({ next, close }) => {
1711
- (0, import_log7.log)("stream opened", this.getLoggingContext(), {
1550
+ return new import_codec_protobuf7.Stream(({ next, close }) => {
1551
+ (0, import_log6.log)("stream opened", this.getLoggingContext(), {
1712
1552
  file: "invitations-service.ts",
1713
1553
  line: 104,
1714
1554
  scope: this,
@@ -1719,19 +1559,19 @@ var AbstractInvitationsService = class {
1719
1559
  const observable = invitationsHandler.acceptInvitation(invitation, options);
1720
1560
  observable.subscribe({
1721
1561
  onConnecting: (invitation2) => {
1722
- (0, import_node_assert8.default)(invitation2.invitationId);
1562
+ (0, import_node_assert7.default)(invitation2.invitationId);
1723
1563
  invitationId = invitation2.invitationId;
1724
1564
  this._acceptInvitations.set(invitation2.invitationId, observable);
1725
1565
  invitation2.state = import_services4.Invitation.State.CONNECTING;
1726
1566
  next(invitation2);
1727
1567
  },
1728
1568
  onConnected: (invitation2) => {
1729
- (0, import_node_assert8.default)(invitation2.invitationId);
1569
+ (0, import_node_assert7.default)(invitation2.invitationId);
1730
1570
  invitation2.state = import_services4.Invitation.State.CONNECTED;
1731
1571
  next(invitation2);
1732
1572
  },
1733
1573
  onAuthenticating: (invitation2) => {
1734
- (0, import_node_assert8.default)(invitation2.invitationId);
1574
+ (0, import_node_assert7.default)(invitation2.invitationId);
1735
1575
  invitation2.state = import_services4.Invitation.State.AUTHENTICATING;
1736
1576
  next(invitation2);
1737
1577
  },
@@ -1741,7 +1581,7 @@ var AbstractInvitationsService = class {
1741
1581
  close();
1742
1582
  },
1743
1583
  onCancelled: () => {
1744
- (0, import_node_assert8.default)(invitationId);
1584
+ (0, import_node_assert7.default)(invitationId);
1745
1585
  invitation.invitationId = invitationId;
1746
1586
  invitation.state = import_services4.Invitation.State.CANCELLED;
1747
1587
  next(invitation);
@@ -1759,7 +1599,7 @@ var AbstractInvitationsService = class {
1759
1599
  return (err) => {
1760
1600
  const context = this.getLoggingContext();
1761
1601
  if (err) {
1762
- import_log7.log.warn("stream closed", {
1602
+ import_log6.log.warn("stream closed", {
1763
1603
  ...context,
1764
1604
  err
1765
1605
  }, {
@@ -1769,7 +1609,7 @@ var AbstractInvitationsService = class {
1769
1609
  callSite: (f, a) => f(...a)
1770
1610
  });
1771
1611
  } else {
1772
- (0, import_log7.log)("stream closed", context, {
1612
+ (0, import_log6.log)("stream closed", context, {
1773
1613
  file: "invitations-service.ts",
1774
1614
  line: 154,
1775
1615
  scope: this,
@@ -1781,16 +1621,16 @@ var AbstractInvitationsService = class {
1781
1621
  });
1782
1622
  }
1783
1623
  async authenticate({ invitationId, authenticationCode }) {
1784
- (0, import_log7.log)("authenticating...", {}, {
1624
+ (0, import_log6.log)("authenticating...", {}, {
1785
1625
  file: "invitations-service.ts",
1786
1626
  line: 163,
1787
1627
  scope: this,
1788
1628
  callSite: (f, a) => f(...a)
1789
1629
  });
1790
- (0, import_node_assert8.default)(invitationId);
1630
+ (0, import_node_assert7.default)(invitationId);
1791
1631
  const observable = this._acceptInvitations.get(invitationId);
1792
1632
  if (!observable) {
1793
- import_log7.log.warn("invalid invitation", {
1633
+ import_log6.log.warn("invalid invitation", {
1794
1634
  invitationId
1795
1635
  }, {
1796
1636
  file: "invitations-service.ts",
@@ -1804,16 +1644,16 @@ var AbstractInvitationsService = class {
1804
1644
  }
1805
1645
  async cancelInvitation(invitation) {
1806
1646
  var _a;
1807
- (0, import_log7.log)("cancelling...", {}, {
1647
+ (0, import_log6.log)("cancelling...", {}, {
1808
1648
  file: "invitations-service.ts",
1809
1649
  line: 174,
1810
1650
  scope: this,
1811
1651
  callSite: (f, a) => f(...a)
1812
1652
  });
1813
- (0, import_node_assert8.default)(invitation.invitationId);
1653
+ (0, import_node_assert7.default)(invitation.invitationId);
1814
1654
  const observable = (_a = this._createInvitations.get(invitation.invitationId)) != null ? _a : this._acceptInvitations.get(invitation.invitationId);
1815
1655
  if (!observable) {
1816
- import_log7.log.warn("invalid invitation", {
1656
+ import_log6.log.warn("invalid invitation", {
1817
1657
  invitationId: invitation.invitationId
1818
1658
  }, {
1819
1659
  file: "invitations-service.ts",
@@ -1827,8 +1667,8 @@ var AbstractInvitationsService = class {
1827
1667
  }
1828
1668
  };
1829
1669
 
1830
- // packages/sdk/client-services/src/packlets/invitations/halo-invitations-service.ts
1831
- var HaloInvitationsServiceImpl = class extends AbstractInvitationsService {
1670
+ // packages/sdk/client-services/src/packlets/invitations/device-invitations-service.ts
1671
+ var DeviceInvitationsServiceImpl = class extends AbstractInvitationsService {
1832
1672
  // prettier-ignore
1833
1673
  constructor(identityManager, invitationsHandler) {
1834
1674
  super(identityManager, () => invitationsHandler);
@@ -1839,13 +1679,13 @@ var HaloInvitationsServiceImpl = class extends AbstractInvitationsService {
1839
1679
  };
1840
1680
 
1841
1681
  // packages/sdk/client-services/src/packlets/invitations/space-invitations-handler.ts
1842
- var import_node_assert9 = __toESM(require("node:assert"));
1682
+ var import_node_assert8 = __toESM(require("node:assert"));
1843
1683
  var import_async9 = require("@dxos/async");
1844
1684
  var import_context4 = require("@dxos/context");
1845
1685
  var import_credentials8 = require("@dxos/credentials");
1846
1686
  var import_feed_store3 = require("@dxos/feed-store");
1847
1687
  var import_keys5 = require("@dxos/keys");
1848
- var import_log8 = require("@dxos/log");
1688
+ var import_log7 = require("@dxos/log");
1849
1689
  var import_network_manager2 = require("@dxos/network-manager");
1850
1690
  var import_protocols4 = require("@dxos/protocols");
1851
1691
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
@@ -1863,16 +1703,19 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1863
1703
  * Creates an invitation and listens for a join request from the invited (guest) peer.
1864
1704
  */
1865
1705
  createInvitation(space, options) {
1706
+ var _a;
1866
1707
  let swarmConnection;
1867
1708
  const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
1868
- (0, import_node_assert9.default)(type !== import_services5.Invitation.Type.OFFLINE);
1869
- (0, import_node_assert9.default)(space);
1709
+ (0, import_node_assert8.default)(type !== import_services5.Invitation.Type.OFFLINE);
1710
+ (0, import_node_assert8.default)(space);
1870
1711
  const invitation = {
1871
1712
  type,
1872
1713
  invitationId: import_keys5.PublicKey.random().toHex(),
1873
1714
  swarmKey: swarmKey != null ? swarmKey : import_keys5.PublicKey.random(),
1874
1715
  spaceKey: space.key,
1716
+ authMethod: (_a = options == null ? void 0 : options.authMethod) != null ? _a : import_invitations4.AuthMethod.SHARED_SECRET,
1875
1717
  authenticationCode: (0, import_credentials8.generatePasscode)(AUTHENTICATION_CODE_LENGTH)
1718
+ // TODO(dmaretskyi): Don't generate if authMethod === NONE .
1876
1719
  };
1877
1720
  const ctx = new import_context4.Context({
1878
1721
  onError: (err) => {
@@ -1883,44 +1726,76 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1883
1726
  const observable = new InvitationObservableProvider(async () => {
1884
1727
  await (swarmConnection == null ? void 0 : swarmConnection.close());
1885
1728
  });
1886
- let authenticationCode;
1729
+ let authenticationPassed = false;
1887
1730
  let authenticationRetry = 0;
1888
1731
  const createExtension = () => {
1889
1732
  const complete = new import_async9.Trigger();
1890
1733
  let guestProfile;
1891
1734
  const hostInvitationExtension = new HostSpaceInvitationExtension({
1892
1735
  introduce: async ({ profile }) => {
1893
- var _a, _b;
1894
- (0, import_log8.log)("guest introduced itself", {
1736
+ var _a2, _b;
1737
+ (0, import_log7.log)("guest introduced itself", {
1895
1738
  guestProfile: profile,
1896
1739
  host: this._signingContext.deviceKey,
1897
1740
  spaceKey: space.key
1898
1741
  }, {
1899
1742
  file: "space-invitations-handler.ts",
1900
- line: 98,
1743
+ line: 101,
1901
1744
  scope: this,
1902
1745
  callSite: (f, a) => f(...a)
1903
1746
  });
1904
1747
  guestProfile = profile;
1905
- (_b = (_a = observable.callback).onAuthenticating) == null ? void 0 : _b.call(_a, invitation);
1748
+ (_b = (_a2 = observable.callback).onAuthenticating) == null ? void 0 : _b.call(_a2, invitation);
1749
+ return {
1750
+ spaceKey: type === import_services5.Invitation.Type.INTERACTIVE_TESTING || type === import_services5.Invitation.Type.MULTIUSE_TESTING ? space.key : void 0,
1751
+ authMethod: invitation.authMethod
1752
+ };
1906
1753
  },
1907
1754
  authenticate: async ({ authenticationCode: code }) => {
1908
- (0, import_log8.log)("received authentication request", {
1755
+ (0, import_log7.log)("received authentication request", {
1909
1756
  authenticationCode: code
1910
1757
  }, {
1911
1758
  file: "space-invitations-handler.ts",
1912
- line: 112,
1759
+ line: 123,
1913
1760
  scope: this,
1914
1761
  callSite: (f, a) => f(...a)
1915
1762
  });
1916
1763
  let status = import_invitations4.AuthenticationResponse.Status.OK;
1917
- if (invitation.authenticationCode) {
1918
- if (authenticationRetry++ > MAX_OTP_ATTEMPTS) {
1919
- status = import_invitations4.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
1920
- } else if (code !== invitation.authenticationCode) {
1921
- status = import_invitations4.AuthenticationResponse.Status.INVALID_OTP;
1922
- } else {
1923
- authenticationCode = code;
1764
+ switch (invitation.authMethod) {
1765
+ case import_invitations4.AuthMethod.NONE: {
1766
+ (0, import_log7.log)("authentication not required", {}, {
1767
+ file: "space-invitations-handler.ts",
1768
+ line: 128,
1769
+ scope: this,
1770
+ callSite: (f, a) => f(...a)
1771
+ });
1772
+ return {
1773
+ status: import_invitations4.AuthenticationResponse.Status.OK
1774
+ };
1775
+ }
1776
+ case import_invitations4.AuthMethod.SHARED_SECRET: {
1777
+ if (invitation.authenticationCode) {
1778
+ if (authenticationRetry++ > MAX_OTP_ATTEMPTS) {
1779
+ status = import_invitations4.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
1780
+ } else if (code !== invitation.authenticationCode) {
1781
+ status = import_invitations4.AuthenticationResponse.Status.INVALID_OTP;
1782
+ } else {
1783
+ authenticationPassed = true;
1784
+ }
1785
+ }
1786
+ break;
1787
+ }
1788
+ default: {
1789
+ import_log7.log.error("invalid authentication method", {
1790
+ authMethod: invitation.authMethod
1791
+ }, {
1792
+ file: "space-invitations-handler.ts",
1793
+ line: 144,
1794
+ scope: this,
1795
+ callSite: (f, a) => f(...a)
1796
+ });
1797
+ status = import_invitations4.AuthenticationResponse.Status.INTERNAL_ERROR;
1798
+ break;
1924
1799
  }
1925
1800
  }
1926
1801
  return {
@@ -1929,24 +1804,22 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1929
1804
  },
1930
1805
  requestAdmission: async ({ identityKey, deviceKey, controlFeedKey, dataFeedKey }) => {
1931
1806
  try {
1932
- if (invitation.type !== import_services5.Invitation.Type.INTERACTIVE_TESTING && invitation.type !== import_services5.Invitation.Type.MULTIUSE_TESTING) {
1933
- if (invitation.authenticationCode === void 0 || invitation.authenticationCode !== authenticationCode) {
1934
- throw new Error(`invalid authentication code: ${authenticationCode}`);
1935
- }
1807
+ if (isAuthenticationRequired(invitation) && !authenticationPassed) {
1808
+ throw new Error("Not authenticated");
1936
1809
  }
1937
- (0, import_log8.log)("writing guest credentials", {
1810
+ (0, import_log7.log)("writing guest credentials", {
1938
1811
  host: this._signingContext.deviceKey,
1939
1812
  guest: deviceKey
1940
1813
  }, {
1941
1814
  file: "space-invitations-handler.ts",
1942
- line: 139,
1815
+ line: 160,
1943
1816
  scope: this,
1944
1817
  callSite: (f, a) => f(...a)
1945
1818
  });
1946
1819
  const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
1947
- (0, import_node_assert9.default)(credentials[0].credential);
1820
+ (0, import_node_assert8.default)(credentials[0].credential);
1948
1821
  const spaceMemberCredential = credentials[0].credential.credential;
1949
- (0, import_node_assert9.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
1822
+ (0, import_node_assert8.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
1950
1823
  await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
1951
1824
  complete.wake(deviceKey);
1952
1825
  return {
@@ -1959,35 +1832,35 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1959
1832
  },
1960
1833
  onOpen: () => {
1961
1834
  (0, import_async9.scheduleTask)(ctx, async () => {
1962
- var _a, _b;
1835
+ var _a2, _b;
1963
1836
  try {
1964
- (0, import_log8.log)("connected", {
1837
+ (0, import_log7.log)("connected", {
1965
1838
  host: this._signingContext.deviceKey
1966
1839
  }, {
1967
1840
  file: "space-invitations-handler.ts",
1968
- line: 170,
1841
+ line: 191,
1969
1842
  scope: this,
1970
1843
  callSite: (f, a) => f(...a)
1971
1844
  });
1972
- (_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
1845
+ (_b = (_a2 = observable.callback).onConnected) == null ? void 0 : _b.call(_a2, invitation);
1973
1846
  const deviceKey = await complete.wait({
1974
1847
  timeout
1975
1848
  });
1976
- (0, import_log8.log)("admitted guest", {
1849
+ (0, import_log7.log)("admitted guest", {
1977
1850
  host: this._signingContext.deviceKey,
1978
1851
  guest: deviceKey
1979
1852
  }, {
1980
1853
  file: "space-invitations-handler.ts",
1981
- line: 173,
1854
+ line: 194,
1982
1855
  scope: this,
1983
1856
  callSite: (f, a) => f(...a)
1984
1857
  });
1985
1858
  observable.callback.onSuccess(invitation);
1986
1859
  } catch (err) {
1987
1860
  if (!observable.cancelled) {
1988
- import_log8.log.error("failed", err, {
1861
+ import_log7.log.error("failed", err, {
1989
1862
  file: "space-invitations-handler.ts",
1990
- line: 177,
1863
+ line: 198,
1991
1864
  scope: this,
1992
1865
  callSite: (f, a) => f(...a)
1993
1866
  });
@@ -2005,7 +1878,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2005
1878
  return hostInvitationExtension;
2006
1879
  };
2007
1880
  (0, import_async9.scheduleTask)(ctx, async () => {
2008
- var _a, _b;
1881
+ var _a2, _b;
2009
1882
  const topic = invitation.swarmKey;
2010
1883
  const swarmConnection2 = await this._networkManager.joinSwarm({
2011
1884
  topic,
@@ -2016,7 +1889,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2016
1889
  topology: new import_network_manager2.StarTopology(topic)
2017
1890
  });
2018
1891
  ctx.onDispose(() => swarmConnection2.close());
2019
- (_b = (_a = observable.callback).onConnecting) == null ? void 0 : _b.call(_a, invitation);
1892
+ (_b = (_a2 = observable.callback).onConnecting) == null ? void 0 : _b.call(_a2, invitation);
2020
1893
  });
2021
1894
  return observable;
2022
1895
  }
@@ -2048,46 +1921,60 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2048
1921
  const extension = new GuestSpaceInvitationExtension({
2049
1922
  onOpen: () => {
2050
1923
  (0, import_async9.scheduleTask)(ctx, async () => {
2051
- var _a, _b, _c, _d;
1924
+ var _a, _b, _c, _d, _e, _f;
2052
1925
  try {
2053
1926
  if (++connectionCount > 1) {
2054
1927
  throw new Error(`multiple connections detected: ${connectionCount}`);
2055
1928
  }
2056
- (0, import_log8.log)("connected", {
1929
+ (0, import_log7.log)("connected", {
2057
1930
  guest: this._signingContext.deviceKey
2058
1931
  }, {
2059
1932
  file: "space-invitations-handler.ts",
2060
- line: 250,
1933
+ line: 271,
2061
1934
  scope: this,
2062
1935
  callSite: (f, a) => f(...a)
2063
1936
  });
2064
1937
  (_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
2065
- (0, import_log8.log)("introduce", {
1938
+ (0, import_log7.log)("introduce", {
2066
1939
  guest: this._signingContext.deviceKey
2067
1940
  }, {
2068
1941
  file: "space-invitations-handler.ts",
2069
- line: 254,
1942
+ line: 275,
2070
1943
  scope: this,
2071
1944
  callSite: (f, a) => f(...a)
2072
1945
  });
2073
- await extension.rpc.SpaceHostService.introduce({
1946
+ const introductionResponse = await extension.rpc.SpaceHostService.introduce({
2074
1947
  profile: this._signingContext.profile
2075
1948
  });
2076
- if (invitation.type === void 0 || invitation.type === import_services5.Invitation.Type.INTERACTIVE) {
1949
+ (0, import_log7.log)("introduce response", {
1950
+ guest: this._signingContext.deviceKey,
1951
+ response: introductionResponse
1952
+ }, {
1953
+ file: "space-invitations-handler.ts",
1954
+ line: 279,
1955
+ scope: this,
1956
+ callSite: (f, a) => f(...a)
1957
+ });
1958
+ invitation.authMethod = introductionResponse.authMethod;
1959
+ if (introductionResponse.spaceKey) {
1960
+ invitation.spaceKey = introductionResponse.spaceKey;
1961
+ }
1962
+ if (isAuthenticationRequired(invitation)) {
1963
+ (_d = (_c = observable.callback).onAuthenticating) == null ? void 0 : _d.call(_c, invitation);
2077
1964
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2078
- (0, import_log8.log)("guest waiting for authentication code...", {}, {
1965
+ (0, import_log7.log)("guest waiting for authentication code...", {}, {
2079
1966
  file: "space-invitations-handler.ts",
2080
- line: 263,
1967
+ line: 293,
2081
1968
  scope: this,
2082
1969
  callSite: (f, a) => f(...a)
2083
1970
  });
2084
- (_d = (_c = observable.callback).onAuthenticating) == null ? void 0 : _d.call(_c, invitation);
1971
+ (_f = (_e = observable.callback).onAuthenticating) == null ? void 0 : _f.call(_e, invitation);
2085
1972
  const authenticationCode = await authenticated.wait({
2086
1973
  timeout
2087
1974
  });
2088
- (0, import_log8.log)("sending authentication request", {}, {
1975
+ (0, import_log7.log)("sending authentication request", {}, {
2089
1976
  file: "space-invitations-handler.ts",
2090
- line: 267,
1977
+ line: 297,
2091
1978
  scope: this,
2092
1979
  callSite: (f, a) => f(...a)
2093
1980
  });
@@ -2101,11 +1988,11 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2101
1988
  if (attempt === MAX_OTP_ATTEMPTS) {
2102
1989
  throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2103
1990
  } else {
2104
- (0, import_log8.log)("retrying invalid code", {
1991
+ (0, import_log7.log)("retrying invalid code", {
2105
1992
  attempt
2106
1993
  }, {
2107
1994
  file: "space-invitations-handler.ts",
2108
- line: 277,
1995
+ line: 307,
2109
1996
  scope: this,
2110
1997
  callSite: (f, a) => f(...a)
2111
1998
  });
@@ -2116,11 +2003,11 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2116
2003
  }
2117
2004
  const controlFeedKey = await this._keyring.createKey();
2118
2005
  const dataFeedKey = await this._keyring.createKey();
2119
- (0, import_log8.log)("request admission", {
2006
+ (0, import_log7.log)("request admission", {
2120
2007
  guest: this._signingContext.deviceKey
2121
2008
  }, {
2122
2009
  file: "space-invitations-handler.ts",
2123
- line: 288,
2010
+ line: 318,
2124
2011
  scope: this,
2125
2012
  callSite: (f, a) => f(...a)
2126
2013
  });
@@ -2131,28 +2018,28 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2131
2018
  dataFeedKey
2132
2019
  });
2133
2020
  const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
2134
- (0, import_node_assert9.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2135
- (0, import_node_assert9.default)(credential.subject.id.equals(this._signingContext.identityKey));
2021
+ (0, import_node_assert8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2022
+ (0, import_node_assert8.default)(credential.subject.id.equals(this._signingContext.identityKey));
2136
2023
  const space = await this._spaceManager.acceptSpace({
2137
2024
  spaceKey: assertion.spaceKey,
2138
2025
  genesisFeedKey: assertion.genesisFeedKey
2139
2026
  });
2140
2027
  await this._signingContext.recordCredential(credential);
2141
- (0, import_log8.log)("admitted by host", {
2028
+ (0, import_log7.log)("admitted by host", {
2142
2029
  guest: this._signingContext.deviceKey,
2143
2030
  spaceKey: space.key
2144
2031
  }, {
2145
2032
  file: "space-invitations-handler.ts",
2146
- line: 310,
2033
+ line: 340,
2147
2034
  scope: this,
2148
2035
  callSite: (f, a) => f(...a)
2149
2036
  });
2150
2037
  complete.wake();
2151
2038
  } catch (err) {
2152
2039
  if (!observable.cancelled) {
2153
- import_log8.log.warn("auth failed", err, {
2040
+ import_log7.log.warn("auth failed", err, {
2154
2041
  file: "space-invitations-handler.ts",
2155
- line: 314,
2042
+ line: 344,
2156
2043
  scope: this,
2157
2044
  callSite: (f, a) => f(...a)
2158
2045
  });
@@ -2168,7 +2055,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2168
2055
  };
2169
2056
  (0, import_async9.scheduleTask)(ctx, async () => {
2170
2057
  var _a, _b;
2171
- (0, import_node_assert9.default)(invitation.swarmKey);
2058
+ (0, import_node_assert8.default)(invitation.swarmKey);
2172
2059
  const topic = invitation.swarmKey;
2173
2060
  const swarmConnection = await this._networkManager.joinSwarm({
2174
2061
  topic,
@@ -2187,6 +2074,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2187
2074
  return observable;
2188
2075
  }
2189
2076
  };
2077
+ var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_invitations4.AuthMethod.NONE && invitation.type !== import_services5.Invitation.Type.INTERACTIVE_TESTING && invitation.type !== import_services5.Invitation.Type.MULTIUSE_TESTING;
2190
2078
  var HostSpaceInvitationExtension = class extends import_teleport2.RpcExtension {
2191
2079
  constructor(_callbacks) {
2192
2080
  super({
@@ -2246,7 +2134,7 @@ var SpaceInvitationsProxy = class extends AbstractInvitationsProxy {
2246
2134
  };
2247
2135
 
2248
2136
  // packages/sdk/client-services/src/packlets/invitations/space-invitations-service.ts
2249
- var import_node_assert10 = __toESM(require("node:assert"));
2137
+ var import_node_assert9 = __toESM(require("node:assert"));
2250
2138
  var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
2251
2139
  // prettier-ignore
2252
2140
  constructor(identityManager, invitationsHandler, _getSpaceManager) {
@@ -2255,10 +2143,10 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
2255
2143
  this._getSpaceManager = _getSpaceManager;
2256
2144
  }
2257
2145
  getContext(invitation) {
2258
- (0, import_node_assert10.default)(invitation.spaceKey);
2146
+ (0, import_node_assert9.default)(invitation.spaceKey);
2259
2147
  const spaceManager = this._getSpaceManager();
2260
2148
  const space = spaceManager.spaces.get(invitation.spaceKey);
2261
- (0, import_node_assert10.default)(space);
2149
+ (0, import_node_assert9.default)(space);
2262
2150
  return space;
2263
2151
  }
2264
2152
  };
@@ -2266,41 +2154,41 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
2266
2154
  // packages/sdk/client-services/src/packlets/services/service-context.ts
2267
2155
  var import_async13 = require("@dxos/async");
2268
2156
  var import_credentials11 = require("@dxos/credentials");
2269
- var import_debug5 = require("@dxos/debug");
2270
- var import_echo_db3 = require("@dxos/echo-db");
2157
+ var import_debug4 = require("@dxos/debug");
2158
+ var import_echo_pipeline3 = require("@dxos/echo-pipeline");
2271
2159
  var import_feed_store4 = require("@dxos/feed-store");
2272
2160
  var import_keyring = require("@dxos/keyring");
2273
- var import_log11 = require("@dxos/log");
2161
+ var import_log10 = require("@dxos/log");
2274
2162
 
2275
2163
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2276
- var import_node_assert12 = __toESM(require("node:assert"));
2164
+ var import_node_assert11 = __toESM(require("node:assert"));
2277
2165
  var import_async12 = require("@dxos/async");
2278
2166
  var import_context7 = require("@dxos/context");
2279
2167
  var import_credentials10 = require("@dxos/credentials");
2280
- var import_echo_db2 = require("@dxos/echo-db");
2168
+ var import_echo_pipeline2 = require("@dxos/echo-pipeline");
2281
2169
  var import_keys8 = require("@dxos/keys");
2282
- var import_log10 = require("@dxos/log");
2170
+ var import_log9 = require("@dxos/log");
2283
2171
  var import_teleport_extension_presence = require("@dxos/teleport-extension-presence");
2284
- var import_util6 = require("@dxos/util");
2172
+ var import_util5 = require("@dxos/util");
2285
2173
 
2286
2174
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2287
2175
  var import_async11 = require("@dxos/async");
2288
2176
  var import_context6 = require("@dxos/context");
2289
- var import_debug4 = require("@dxos/debug");
2290
- var import_echo_db = require("@dxos/echo-db");
2177
+ var import_debug3 = require("@dxos/debug");
2178
+ var import_echo_pipeline = require("@dxos/echo-pipeline");
2291
2179
  var import_keys7 = require("@dxos/keys");
2292
2180
  var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
2293
- var import_util5 = require("@dxos/util");
2181
+ var import_util4 = require("@dxos/util");
2294
2182
 
2295
2183
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2296
- var import_node_assert11 = __toESM(require("node:assert"));
2184
+ var import_node_assert10 = __toESM(require("node:assert"));
2297
2185
  var import_async10 = require("@dxos/async");
2298
2186
  var import_context5 = require("@dxos/context");
2299
2187
  var import_keys6 = require("@dxos/keys");
2300
- var import_log9 = require("@dxos/log");
2188
+ var import_log8 = require("@dxos/log");
2301
2189
  var import_protocols5 = require("@dxos/protocols");
2302
2190
  var import_teleport3 = require("@dxos/teleport");
2303
- var import_util4 = require("@dxos/util");
2191
+ var import_util3 = require("@dxos/util");
2304
2192
  var RETRY_TIMEOUT = 1e3;
2305
2193
  var NOTARIZE_TIMEOUT = 1e4;
2306
2194
  var NotarizationPlugin = class {
@@ -2308,8 +2196,8 @@ var NotarizationPlugin = class {
2308
2196
  this._ctx = new import_context5.Context();
2309
2197
  this._extensionOpened = new import_async10.Event();
2310
2198
  this._extensions = /* @__PURE__ */ new Set();
2311
- this._processedCredentials = new import_util4.ComplexSet(import_keys6.PublicKey.hash);
2312
- this._processCredentialsTriggers = new import_util4.ComplexMap(import_keys6.PublicKey.hash);
2199
+ this._processedCredentials = new import_util3.ComplexSet(import_keys6.PublicKey.hash);
2200
+ this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys6.PublicKey.hash);
2313
2201
  }
2314
2202
  async open() {
2315
2203
  }
@@ -2320,7 +2208,7 @@ var NotarizationPlugin = class {
2320
2208
  * Request credentials to be notarized.
2321
2209
  */
2322
2210
  async notarize(credentials) {
2323
- (0, import_log9.log)("notarize", {
2211
+ (0, import_log8.log)("notarize", {
2324
2212
  credentials
2325
2213
  }, {
2326
2214
  file: "notarization-plugin.ts",
@@ -2328,11 +2216,11 @@ var NotarizationPlugin = class {
2328
2216
  scope: this,
2329
2217
  callSite: (f, a) => f(...a)
2330
2218
  });
2331
- (0, import_node_assert11.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2219
+ (0, import_node_assert10.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2332
2220
  const errors = new import_async10.Trigger();
2333
2221
  const ctx = this._ctx.derive({
2334
2222
  onError: (err) => {
2335
- import_log9.log.warn("Notarization error", {
2223
+ import_log8.log.warn("Notarization error", {
2336
2224
  err
2337
2225
  }, {
2338
2226
  file: "notarization-plugin.ts",
@@ -2345,7 +2233,7 @@ var NotarizationPlugin = class {
2345
2233
  }
2346
2234
  });
2347
2235
  (0, import_async10.scheduleTask)(ctx, () => {
2348
- import_log9.log.warn("Notarization timeout", {}, {
2236
+ import_log8.log.warn("Notarization timeout", {}, {
2349
2237
  file: "notarization-plugin.ts",
2350
2238
  line: 61,
2351
2239
  scope: this,
@@ -2359,7 +2247,7 @@ var NotarizationPlugin = class {
2359
2247
  const notarizeTask = new import_async10.DeferredTask(ctx, async () => {
2360
2248
  try {
2361
2249
  if (this._extensions.size === 0) {
2362
- import_log9.log.warn("No peers to notarize with", {}, {
2250
+ import_log8.log.warn("No peers to notarize with", {}, {
2363
2251
  file: "notarization-plugin.ts",
2364
2252
  line: 76,
2365
2253
  scope: this,
@@ -2371,7 +2259,7 @@ var NotarizationPlugin = class {
2371
2259
  ...this._extensions
2372
2260
  ].find((peer2) => !peersTried.has(peer2));
2373
2261
  if (!peer) {
2374
- import_log9.log.warn("Exhausted all peers to notarize with", {
2262
+ import_log8.log.warn("Exhausted all peers to notarize with", {
2375
2263
  retryIn: RETRY_TIMEOUT
2376
2264
  }, {
2377
2265
  file: "notarization-plugin.ts",
@@ -2384,7 +2272,7 @@ var NotarizationPlugin = class {
2384
2272
  return;
2385
2273
  }
2386
2274
  peersTried.add(peer);
2387
- (0, import_log9.log)("try notarizing", {
2275
+ (0, import_log8.log)("try notarizing", {
2388
2276
  peer: peer.localPeerId,
2389
2277
  credentialId: credentials.map((credential) => credential.id)
2390
2278
  }, {
@@ -2396,14 +2284,14 @@ var NotarizationPlugin = class {
2396
2284
  await peer.rpc.NotarizationService.notarize({
2397
2285
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2398
2286
  });
2399
- (0, import_log9.log)("success", {}, {
2287
+ (0, import_log8.log)("success", {}, {
2400
2288
  file: "notarization-plugin.ts",
2401
2289
  line: 94,
2402
2290
  scope: this,
2403
2291
  callSite: (f, a) => f(...a)
2404
2292
  });
2405
2293
  } catch (err) {
2406
- import_log9.log.warn("error notarizing (recoverable)", err, {
2294
+ import_log8.log.warn("error notarizing (recoverable)", err, {
2407
2295
  file: "notarization-plugin.ts",
2408
2296
  line: 96,
2409
2297
  scope: this,
@@ -2419,7 +2307,7 @@ var NotarizationPlugin = class {
2419
2307
  allNotarized,
2420
2308
  errors.wait()
2421
2309
  ]);
2422
- (0, import_log9.log)("done", {}, {
2310
+ (0, import_log8.log)("done", {}, {
2423
2311
  file: "notarization-plugin.ts",
2424
2312
  line: 107,
2425
2313
  scope: this,
@@ -2442,14 +2330,14 @@ var NotarizationPlugin = class {
2442
2330
  this._processCredentialsTriggers.delete(credential.id);
2443
2331
  }
2444
2332
  setWriter(writer) {
2445
- (0, import_node_assert11.default)(!this._writer, "Writer already set.");
2333
+ (0, import_node_assert10.default)(!this._writer, "Writer already set.");
2446
2334
  this._writer = writer;
2447
2335
  }
2448
2336
  async _waitUntilProcessed(id) {
2449
2337
  if (this._processedCredentials.has(id)) {
2450
2338
  return;
2451
2339
  }
2452
- await (0, import_util4.entry)(this._processCredentialsTriggers, id).orInsert(new import_async10.Trigger()).value.wait();
2340
+ await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new import_async10.Trigger()).value.wait();
2453
2341
  }
2454
2342
  /**
2455
2343
  * Requests from other peers to notarize credentials.
@@ -2460,7 +2348,7 @@ var NotarizationPlugin = class {
2460
2348
  throw new Error("Writer not set");
2461
2349
  }
2462
2350
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2463
- (0, import_node_assert11.default)(credential.id, "Credential must have an id");
2351
+ (0, import_node_assert10.default)(credential.id, "Credential must have an id");
2464
2352
  if (this._processedCredentials.has(credential.id)) {
2465
2353
  continue;
2466
2354
  }
@@ -2470,7 +2358,7 @@ var NotarizationPlugin = class {
2470
2358
  createExtension() {
2471
2359
  const extension = new NotarizationTeleportExtension({
2472
2360
  onOpen: async () => {
2473
- (0, import_log9.log)("extension opened", {
2361
+ (0, import_log8.log)("extension opened", {
2474
2362
  peer: extension.localPeerId
2475
2363
  }, {
2476
2364
  file: "notarization-plugin.ts",
@@ -2482,7 +2370,7 @@ var NotarizationPlugin = class {
2482
2370
  this._extensionOpened.emit();
2483
2371
  },
2484
2372
  onClose: async () => {
2485
- (0, import_log9.log)("extension closed", {
2373
+ (0, import_log8.log)("extension closed", {
2486
2374
  peer: extension.localPeerId
2487
2375
  }, {
2488
2376
  file: "notarization-plugin.ts",
@@ -2550,7 +2438,7 @@ var DataSpace = class DataSpace2 {
2550
2438
  this._feedStore = params.feedStore;
2551
2439
  this._metadataStore = params.metadataStore;
2552
2440
  this._signingContext = params.signingContext;
2553
- this._dataPipelineController = new import_echo_db.DataPipelineControllerImpl({
2441
+ this._dataPipelineController = new import_echo_pipeline.DataPipelineControllerImpl({
2554
2442
  modelFactory: params.modelFactory,
2555
2443
  metadataStore: params.metadataStore,
2556
2444
  snapshotManager: params.snapshotManager,
@@ -2560,7 +2448,7 @@ var DataSpace = class DataSpace2 {
2560
2448
  snapshotId: params.snapshotId
2561
2449
  });
2562
2450
  this.authVerifier = new TrustedKeySetAuthVerifier({
2563
- trustedKeysProvider: () => new import_util5.ComplexSet(import_keys7.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
2451
+ trustedKeysProvider: () => new import_util4.ComplexSet(import_keys7.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
2564
2452
  update: this._inner.stateUpdate,
2565
2453
  authTimeout: AUTH_TIMEOUT2
2566
2454
  });
@@ -2606,7 +2494,7 @@ var DataSpace = class DataSpace2 {
2606
2494
  timeout: CONTROL_PIPELINE_READY_TIMEFRAME
2607
2495
  });
2608
2496
  await this._createWritableFeeds();
2609
- this.notarizationPlugin.setWriter((0, import_echo_db.createMappedFeedWriter)((credential) => ({
2497
+ this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
2610
2498
  credential: {
2611
2499
  credential
2612
2500
  }
@@ -2654,7 +2542,7 @@ var DataSpace = class DataSpace2 {
2654
2542
  }
2655
2543
  };
2656
2544
  __decorate([
2657
- (0, import_debug4.timed)(1e4)
2545
+ (0, import_debug3.timed)(1e4)
2658
2546
  ], DataSpace.prototype, "_createWritableFeeds", null);
2659
2547
  DataSpace = __decorate([
2660
2548
  (0, import_async11.trackLeaks)("open", "close")
@@ -2684,7 +2572,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2684
2572
  this._snapshotStore = _snapshotStore;
2685
2573
  this._ctx = new import_context7.Context();
2686
2574
  this.updated = new import_async12.Event();
2687
- this._spaces = new import_util6.ComplexMap(import_keys8.PublicKey.hash);
2575
+ this._spaces = new import_util5.ComplexMap(import_keys8.PublicKey.hash);
2688
2576
  }
2689
2577
  // TODO(burdon): Remove.
2690
2578
  get spaces() {
@@ -2692,7 +2580,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2692
2580
  }
2693
2581
  async open() {
2694
2582
  await this._metadataStore.load();
2695
- (0, import_log10.log)("metadata loaded", {
2583
+ (0, import_log9.log)("metadata loaded", {
2696
2584
  spaces: this._metadataStore.spaces.length
2697
2585
  }, {
2698
2586
  file: "data-space-manager.ts",
@@ -2701,7 +2589,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2701
2589
  callSite: (f, a) => f(...a)
2702
2590
  });
2703
2591
  for (const spaceMetadata of this._metadataStore.spaces) {
2704
- (0, import_log10.log)("load space", {
2592
+ (0, import_log9.log)("load space", {
2705
2593
  spaceMetadata
2706
2594
  }, {
2707
2595
  file: "data-space-manager.ts",
@@ -2712,7 +2600,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2712
2600
  const space = await this._constructSpace(spaceMetadata);
2713
2601
  await space.initializeDataPipeline();
2714
2602
  if (spaceMetadata.dataTimeframe) {
2715
- (0, import_log10.log)("waiting for latest timeframe", {
2603
+ (0, import_log9.log)("waiting for latest timeframe", {
2716
2604
  spaceMetadata
2717
2605
  }, {
2718
2606
  file: "data-space-manager.ts",
@@ -2747,7 +2635,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2747
2635
  controlFeedKey,
2748
2636
  dataFeedKey
2749
2637
  };
2750
- (0, import_log10.log)("creating space...", {
2638
+ (0, import_log9.log)("creating space...", {
2751
2639
  spaceKey
2752
2640
  }, {
2753
2641
  file: "data-space-manager.ts",
@@ -2756,10 +2644,10 @@ var DataSpaceManager = class DataSpaceManager2 {
2756
2644
  callSite: (f, a) => f(...a)
2757
2645
  });
2758
2646
  const space = await this._constructSpace(metadata);
2759
- const credentials = await (0, import_echo_db2.spaceGenesis)(this._keyring, this._signingContext, space.inner);
2647
+ const credentials = await (0, import_echo_pipeline2.spaceGenesis)(this._keyring, this._signingContext, space.inner);
2760
2648
  await this._metadataStore.addSpace(metadata);
2761
2649
  const memberCredential = credentials[1];
2762
- (0, import_node_assert12.default)((0, import_credentials10.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2650
+ (0, import_node_assert11.default)((0, import_credentials10.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2763
2651
  await this._signingContext.recordCredential(memberCredential);
2764
2652
  await space.initializeDataPipeline();
2765
2653
  this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
@@ -2768,7 +2656,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2768
2656
  }
2769
2657
  // TODO(burdon): Rename join space.
2770
2658
  async acceptSpace(opts) {
2771
- (0, import_node_assert12.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2659
+ (0, import_node_assert11.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2772
2660
  const metadata = {
2773
2661
  key: opts.spaceKey,
2774
2662
  genesisFeedKey: opts.genesisFeedKey
@@ -2787,7 +2675,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2787
2675
  offlineTimeout: 3e4,
2788
2676
  identityKey: this._signingContext.identityKey
2789
2677
  });
2790
- const snapshotManager = new import_echo_db2.SnapshotManager(this._snapshotStore);
2678
+ const snapshotManager = new import_echo_pipeline2.SnapshotManager(this._snapshotStore);
2791
2679
  const controlFeed = metadata.controlFeedKey && await this._feedStore.openFeed(metadata.controlFeedKey, {
2792
2680
  writable: true
2793
2681
  });
@@ -2799,7 +2687,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2799
2687
  swarmIdentity: {
2800
2688
  peerKey: this._signingContext.deviceKey,
2801
2689
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
2802
- credentialAuthenticator: (0, import_util6.deferFunction)(() => dataSpace.authVerifier.verifier)
2690
+ credentialAuthenticator: (0, import_util5.deferFunction)(() => dataSpace.authVerifier.verifier)
2803
2691
  },
2804
2692
  onNetworkConnection: (session) => {
2805
2693
  session.addExtension("dxos.mesh.teleport.presence", presence.createExtension({
@@ -2852,36 +2740,36 @@ var ServiceContext = class {
2852
2740
  this.networkManager = networkManager;
2853
2741
  this.modelFactory = modelFactory;
2854
2742
  this.initialized = new import_async13.Trigger();
2855
- this.dataServiceSubscriptions = new import_echo_db3.DataServiceSubscriptions();
2856
- this.metadataStore = new import_echo_db3.MetadataStore(storage.createDirectory("metadata"));
2857
- this.snapshotStore = new import_echo_db3.SnapshotStore(storage.createDirectory("snapshots"));
2743
+ this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
2744
+ this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
2745
+ this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
2858
2746
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
2859
2747
  this.feedStore = new import_feed_store4.FeedStore({
2860
2748
  factory: new import_feed_store4.FeedFactory({
2861
2749
  root: storage.createDirectory("feeds"),
2862
2750
  signer: this.keyring,
2863
2751
  hypercore: {
2864
- valueEncoding: import_echo_db3.valueEncoding
2752
+ valueEncoding: import_echo_pipeline3.valueEncoding
2865
2753
  }
2866
2754
  })
2867
2755
  });
2868
- this.spaceManager = new import_echo_db3.SpaceManager({
2756
+ this.spaceManager = new import_echo_pipeline3.SpaceManager({
2869
2757
  feedStore: this.feedStore,
2870
2758
  networkManager: this.networkManager
2871
2759
  });
2872
2760
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
2873
- this.haloInvitations = new HaloInvitationsHandler({
2761
+ this.deviceInvitations = new DeviceInvitationsHandler({
2874
2762
  networkManager: this.networkManager,
2875
2763
  getIdentity: () => {
2876
2764
  var _a;
2877
- return (_a = this.identityManager.identity) != null ? _a : (0, import_debug5.failUndefined)();
2765
+ return (_a = this.identityManager.identity) != null ? _a : (0, import_debug4.failUndefined)();
2878
2766
  },
2879
2767
  acceptIdentity: this._acceptIdentity.bind(this),
2880
2768
  keyring: this.keyring
2881
2769
  });
2882
2770
  }
2883
2771
  async open() {
2884
- (0, import_log11.log)("opening...", {}, {
2772
+ (0, import_log10.log)("opening...", {}, {
2885
2773
  file: "service-context.ts",
2886
2774
  line: 94,
2887
2775
  scope: this,
@@ -2893,7 +2781,7 @@ var ServiceContext = class {
2893
2781
  if (this.identityManager.identity) {
2894
2782
  await this._initialize();
2895
2783
  }
2896
- (0, import_log11.log)("opened", {}, {
2784
+ (0, import_log10.log)("opened", {}, {
2897
2785
  file: "service-context.ts",
2898
2786
  line: 101,
2899
2787
  scope: this,
@@ -2902,7 +2790,7 @@ var ServiceContext = class {
2902
2790
  }
2903
2791
  async close() {
2904
2792
  var _a, _b;
2905
- (0, import_log11.log)("closing...", {}, {
2793
+ (0, import_log10.log)("closing...", {}, {
2906
2794
  file: "service-context.ts",
2907
2795
  line: 105,
2908
2796
  scope: this,
@@ -2915,7 +2803,7 @@ var ServiceContext = class {
2915
2803
  await this.feedStore.close();
2916
2804
  await this.networkManager.close();
2917
2805
  this.dataServiceSubscriptions.clear();
2918
- (0, import_log11.log)("closed", {}, {
2806
+ (0, import_log10.log)("closed", {}, {
2919
2807
  file: "service-context.ts",
2920
2808
  line: 113,
2921
2809
  scope: this,
@@ -2923,7 +2811,7 @@ var ServiceContext = class {
2923
2811
  });
2924
2812
  }
2925
2813
  async reset() {
2926
- (0, import_log11.log)("resetting...", {}, {
2814
+ (0, import_log10.log)("resetting...", {}, {
2927
2815
  file: "service-context.ts",
2928
2816
  line: 117,
2929
2817
  scope: this,
@@ -2931,7 +2819,7 @@ var ServiceContext = class {
2931
2819
  });
2932
2820
  await this.close();
2933
2821
  await this.storage.reset();
2934
- (0, import_log11.log)("reset", {}, {
2822
+ (0, import_log10.log)("reset", {}, {
2935
2823
  file: "service-context.ts",
2936
2824
  line: 120,
2937
2825
  scope: this,
@@ -2951,13 +2839,13 @@ var ServiceContext = class {
2951
2839
  // Called when identity is created.
2952
2840
  async _initialize() {
2953
2841
  var _a;
2954
- (0, import_log11.log)("initializing spaces...", {}, {
2842
+ (0, import_log10.log)("initializing spaces...", {}, {
2955
2843
  file: "service-context.ts",
2956
2844
  line: 139,
2957
2845
  scope: this,
2958
2846
  callSite: (f, a) => f(...a)
2959
2847
  });
2960
- const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug5.failUndefined)();
2848
+ const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug4.failUndefined)();
2961
2849
  const signingContext = {
2962
2850
  credentialSigner: identity.getIdentityCredentialSigner(),
2963
2851
  identityKey: identity.identityKey,
@@ -2985,7 +2873,7 @@ var ServiceContext = class {
2985
2873
  return;
2986
2874
  }
2987
2875
  if (!this.dataSpaceManager) {
2988
- (0, import_log11.log)("dataSpaceManager not initialized yet, ignoring space admission", {
2876
+ (0, import_log10.log)("dataSpaceManager not initialized yet, ignoring space admission", {
2989
2877
  details: assertion
2990
2878
  }, {
2991
2879
  file: "service-context.ts",
@@ -2996,7 +2884,7 @@ var ServiceContext = class {
2996
2884
  return;
2997
2885
  }
2998
2886
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
2999
- (0, import_log11.log)("space already exists, ignoring space admission", {
2887
+ (0, import_log10.log)("space already exists, ignoring space admission", {
3000
2888
  details: assertion
3001
2889
  }, {
3002
2890
  file: "service-context.ts",
@@ -3007,7 +2895,7 @@ var ServiceContext = class {
3007
2895
  return;
3008
2896
  }
3009
2897
  try {
3010
- (0, import_log11.log)("accepting space recorded in halo", {
2898
+ (0, import_log10.log)("accepting space recorded in halo", {
3011
2899
  details: assertion
3012
2900
  }, {
3013
2901
  file: "service-context.ts",
@@ -3020,7 +2908,7 @@ var ServiceContext = class {
3020
2908
  genesisFeedKey: assertion.genesisFeedKey
3021
2909
  });
3022
2910
  } catch (err) {
3023
- import_log11.log.catch(err, {}, {
2911
+ import_log10.log.catch(err, {}, {
3024
2912
  file: "service-context.ts",
3025
2913
  line: 197,
3026
2914
  scope: this,
@@ -3037,41 +2925,56 @@ var ServiceContext = class {
3037
2925
  var import_protocols6 = require("@dxos/protocols");
3038
2926
  var import_rpc = require("@dxos/rpc");
3039
2927
  var clientServiceBundle = (0, import_rpc.createServiceBundle)({
3040
- HaloInvitationsService: import_protocols6.schema.getService("dxos.client.services.HaloInvitationsService"),
2928
+ SystemService: import_protocols6.schema.getService("dxos.client.services.SystemService"),
2929
+ IdentityService: import_protocols6.schema.getService("dxos.client.services.IdentityService"),
2930
+ DeviceInvitationsService: import_protocols6.schema.getService("dxos.client.services.DeviceInvitationsService"),
3041
2931
  DevicesService: import_protocols6.schema.getService("dxos.client.services.DevicesService"),
3042
2932
  SpaceInvitationsService: import_protocols6.schema.getService("dxos.client.services.SpaceInvitationsService"),
3043
2933
  SpacesService: import_protocols6.schema.getService("dxos.client.services.SpacesService"),
2934
+ DataService: import_protocols6.schema.getService("dxos.echo.service.DataService"),
3044
2935
  NetworkService: import_protocols6.schema.getService("dxos.client.services.NetworkService"),
3045
2936
  // TODO(burdon): Deprecated.
3046
- SpaceService: import_protocols6.schema.getService("dxos.client.SpaceService"),
3047
- DataService: import_protocols6.schema.getService("dxos.echo.service.DataService"),
3048
- ProfileService: import_protocols6.schema.getService("dxos.client.ProfileService"),
3049
- SystemService: import_protocols6.schema.getService("dxos.client.SystemService"),
3050
2937
  DevtoolsHost: import_protocols6.schema.getService("dxos.devtools.host.DevtoolsHost"),
3051
2938
  TracingService: import_protocols6.schema.getService("dxos.devtools.host.TracingService")
3052
2939
  });
3053
2940
 
3054
2941
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3055
- var import_debug7 = require("@dxos/debug");
2942
+ var import_node_assert14 = __toESM(require("node:assert"));
2943
+ var import_async22 = require("@dxos/async");
2944
+ var import_debug6 = require("@dxos/debug");
3056
2945
  var import_document_model = require("@dxos/document-model");
3057
- var import_echo_db5 = require("@dxos/echo-db");
3058
- var import_log16 = require("@dxos/log");
2946
+ var import_echo_pipeline5 = require("@dxos/echo-pipeline");
2947
+ var import_log17 = require("@dxos/log");
3059
2948
  var import_model_factory = require("@dxos/model-factory");
3060
- var import_client2 = require("@dxos/protocols/proto/dxos/client");
2949
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
3061
2950
  var import_text_model = require("@dxos/text-model");
3062
2951
 
3063
- // packages/sdk/client-services/src/packlets/identity/devices-service-impl.ts
2952
+ // packages/sdk/client-services/src/packlets/deprecated/tracing.ts
2953
+ var TracingServiceImpl = class {
2954
+ constructor(_config) {
2955
+ this._config = _config;
2956
+ }
2957
+ async setTracingOptions() {
2958
+ throw new Error("Tracing not available.");
2959
+ }
2960
+ subscribeToRpcTrace() {
2961
+ throw new Error("Tracing not available.");
2962
+ }
2963
+ };
2964
+
2965
+ // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3064
2966
  var import_async14 = require("@dxos/async");
3065
- var import_codec_protobuf9 = require("@dxos/codec-protobuf");
2967
+ var import_codec_protobuf8 = require("@dxos/codec-protobuf");
2968
+ var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
3066
2969
  var DevicesServiceImpl = class {
3067
2970
  constructor(_identityManager) {
3068
2971
  this._identityManager = _identityManager;
3069
2972
  }
3070
- updateDevice() {
2973
+ updateDevice(request) {
3071
2974
  throw new Error("Method not implemented.");
3072
2975
  }
3073
2976
  queryDevices() {
3074
- return new import_codec_protobuf9.Stream(({ next }) => {
2977
+ return new import_codec_protobuf8.Stream(({ next }) => {
3075
2978
  const update = () => {
3076
2979
  var _a;
3077
2980
  const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
@@ -3081,35 +2984,39 @@ var DevicesServiceImpl = class {
3081
2984
  });
3082
2985
  } else {
3083
2986
  next({
3084
- devices: Array.from(deviceKeys.values()).map((key) => ({
3085
- deviceKey: key
3086
- }))
2987
+ devices: Array.from(deviceKeys.values()).map((key) => {
2988
+ var _a2;
2989
+ return {
2990
+ deviceKey: key,
2991
+ kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services6.DeviceKind.CURRENT : import_services6.DeviceKind.TRUSTED
2992
+ };
2993
+ })
3087
2994
  });
3088
2995
  }
3089
2996
  };
3090
- const dispose = new import_async14.EventSubscriptions();
3091
- dispose.add(this._identityManager.stateUpdate.on(() => {
2997
+ const subscriptions = new import_async14.EventSubscriptions();
2998
+ subscriptions.add(this._identityManager.stateUpdate.on(() => {
3092
2999
  update();
3093
3000
  if (this._identityManager.identity) {
3094
- dispose.add(this._identityManager.identity.stateUpdate.on(() => {
3001
+ subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
3095
3002
  update();
3096
3003
  }));
3097
3004
  }
3098
3005
  }));
3099
3006
  update();
3100
- return () => dispose.clear();
3007
+ return () => subscriptions.clear();
3101
3008
  });
3102
3009
  }
3103
3010
  };
3104
3011
 
3105
3012
  // packages/sdk/client-services/src/packlets/network/network-service.ts
3106
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3013
+ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
3107
3014
  var NetworkServiceImpl = class {
3108
3015
  constructor(networkManager) {
3109
3016
  this.networkManager = networkManager;
3110
3017
  }
3111
3018
  subscribeToNetworkStatus() {
3112
- return new import_codec_protobuf10.Stream(({ next }) => {
3019
+ return new import_codec_protobuf9.Stream(({ next }) => {
3113
3020
  const unsubscribe = this.networkManager.connectionStateChanged.on((state) => next({
3114
3021
  state
3115
3022
  }));
@@ -3126,26 +3033,81 @@ var NetworkServiceImpl = class {
3126
3033
 
3127
3034
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
3128
3035
  var import_async15 = require("@dxos/async");
3129
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3130
- var import_debug6 = require("@dxos/debug");
3131
- var import_echo_db4 = require("@dxos/echo-db");
3036
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3037
+ var import_debug5 = require("@dxos/debug");
3038
+ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3039
+ var import_log11 = require("@dxos/log");
3040
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
3041
+ var import_util6 = require("@dxos/util");
3132
3042
  var SpacesServiceImpl = class {
3133
- constructor(_spaceManager) {
3043
+ constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
3044
+ this._identityManager = _identityManager;
3134
3045
  this._spaceManager = _spaceManager;
3046
+ this._dataServiceSubscriptions = _dataServiceSubscriptions;
3047
+ this._getDataSpaceManager = _getDataSpaceManager;
3135
3048
  }
3136
3049
  async createSpace() {
3137
- throw new Error();
3050
+ if (!this._identityManager.identity) {
3051
+ throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
3052
+ }
3053
+ const dataSpaceManager = await this._getDataSpaceManager();
3054
+ const space = await dataSpaceManager.createSpace();
3055
+ return this._transformSpace(space);
3138
3056
  }
3139
- querySpaces() {
3140
- throw new Error();
3057
+ async updateSpace(request) {
3058
+ (0, import_debug5.todo)();
3141
3059
  }
3142
- queryMembers(query) {
3143
- throw new Error();
3060
+ querySpaces() {
3061
+ return new import_codec_protobuf10.Stream(({ next, ctx }) => {
3062
+ const onUpdate = async () => {
3063
+ const dataSpaceManager = await this._getDataSpaceManager();
3064
+ const spaces = Array.from(dataSpaceManager.spaces.values()).filter((space) => this._dataServiceSubscriptions.getDataService(space.key)).map((space) => this._transformSpace(space));
3065
+ (0, import_log11.log)("update", {
3066
+ spaces
3067
+ }, {
3068
+ file: "spaces-service.ts",
3069
+ line: 59,
3070
+ scope: this,
3071
+ callSite: (f, a) => f(...a)
3072
+ });
3073
+ next({
3074
+ spaces
3075
+ });
3076
+ };
3077
+ setTimeout(async () => {
3078
+ const dataSpaceManager = await this._getDataSpaceManager();
3079
+ const subscriptions = new import_async15.EventSubscriptions();
3080
+ const subscribeSpaces = () => {
3081
+ subscriptions.clear();
3082
+ for (const space of dataSpaceManager.spaces.values()) {
3083
+ if (!this._dataServiceSubscriptions.getDataService(space.key)) {
3084
+ continue;
3085
+ }
3086
+ subscriptions.add(space.stateUpdate.on(ctx, onUpdate));
3087
+ subscriptions.add(space.presence.updated.on(ctx, onUpdate));
3088
+ }
3089
+ };
3090
+ dataSpaceManager.updated.on(ctx, () => {
3091
+ subscribeSpaces();
3092
+ void onUpdate();
3093
+ });
3094
+ ctx.onDispose(() => subscriptions.clear());
3095
+ (0, import_async15.scheduleTask)(ctx, () => {
3096
+ subscribeSpaces();
3097
+ void onUpdate();
3098
+ });
3099
+ });
3100
+ if (!this._identityManager.identity) {
3101
+ next({
3102
+ spaces: []
3103
+ });
3104
+ }
3105
+ });
3144
3106
  }
3145
3107
  queryCredentials({ spaceKey }) {
3146
- return new import_codec_protobuf11.Stream(({ ctx, next }) => {
3108
+ return new import_codec_protobuf10.Stream(({ ctx, next }) => {
3147
3109
  var _a;
3148
- const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_db4.SpaceNotFoundError(spaceKey));
3110
+ const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline4.SpaceNotFoundError(spaceKey));
3149
3111
  const processor = space.spaceState.registerProcessor({
3150
3112
  process: async (credential) => {
3151
3113
  next(credential);
@@ -3157,7 +3119,7 @@ var SpacesServiceImpl = class {
3157
3119
  }
3158
3120
  async writeCredentials({ spaceKey, credentials }) {
3159
3121
  var _a;
3160
- const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_db4.SpaceNotFoundError(spaceKey));
3122
+ const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline4.SpaceNotFoundError(spaceKey));
3161
3123
  for (const credential of credentials != null ? credentials : []) {
3162
3124
  await space.controlPipeline.writer.write({
3163
3125
  credential: {
@@ -3166,6 +3128,24 @@ var SpacesServiceImpl = class {
3166
3128
  });
3167
3129
  }
3168
3130
  }
3131
+ _transformSpace(space) {
3132
+ return {
3133
+ spaceKey: space.key,
3134
+ status: space.isOpen ? import_services7.SpaceStatus.ACTIVE : import_services7.SpaceStatus.INACTIVE,
3135
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => {
3136
+ var _a, _b, _c;
3137
+ return {
3138
+ identity: {
3139
+ identityKey: member.key,
3140
+ profile: {
3141
+ displayName: (_b = (_a = member.assertion.profile) == null ? void 0 : _a.displayName) != null ? _b : (0, import_util6.humanize)(member.key)
3142
+ }
3143
+ },
3144
+ presence: ((_c = this._identityManager.identity) == null ? void 0 : _c.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
3145
+ };
3146
+ })
3147
+ };
3148
+ }
3169
3149
  };
3170
3150
 
3171
3151
  // packages/sdk/client-services/src/packlets/storage/storage.ts
@@ -3213,12 +3193,158 @@ var toStorageType = (type) => {
3213
3193
  }
3214
3194
  };
3215
3195
 
3196
+ // packages/sdk/client-services/src/packlets/system/system-service.ts
3197
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3198
+ var SystemServiceImpl = class {
3199
+ constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
3200
+ this._config = config;
3201
+ this._statusUpdate = statusUpdate;
3202
+ this._getCurrentStatus = getCurrentStatus;
3203
+ this._onUpdateStatus = onUpdateStatus;
3204
+ this._onReset = onReset;
3205
+ }
3206
+ async getConfig() {
3207
+ return this._config.values;
3208
+ }
3209
+ async updateStatus({ status }) {
3210
+ await this._onUpdateStatus(status);
3211
+ }
3212
+ queryStatus() {
3213
+ return new import_codec_protobuf11.Stream(({ next }) => {
3214
+ const update = () => {
3215
+ next({
3216
+ status: this._getCurrentStatus()
3217
+ });
3218
+ };
3219
+ update();
3220
+ const unsubscribe = this._statusUpdate.on(() => update());
3221
+ const interval = setInterval(update, 3e3);
3222
+ return () => {
3223
+ clearInterval(interval);
3224
+ unsubscribe();
3225
+ };
3226
+ });
3227
+ }
3228
+ async reset() {
3229
+ await this._onReset();
3230
+ }
3231
+ };
3232
+
3216
3233
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3217
- var import_async16 = require("@dxos/async");
3234
+ var import_async17 = require("@dxos/async");
3218
3235
  var import_log12 = require("@dxos/log");
3219
3236
  var import_messaging = require("@dxos/messaging");
3220
3237
  var import_network_manager3 = require("@dxos/network-manager");
3238
+ var import_rpc3 = require("@dxos/rpc");
3239
+ var import_util7 = require("@dxos/util");
3240
+
3241
+ // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
3242
+ var import_node_assert12 = __toESM(require("node:assert"));
3243
+ var import_async16 = require("@dxos/async");
3244
+ var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
3221
3245
  var import_rpc2 = require("@dxos/rpc");
3246
+
3247
+ // packages/sdk/client-services/src/packlets/vault/services.ts
3248
+ var import_protocols7 = require("@dxos/protocols");
3249
+ var iframeServiceBundle = {
3250
+ IframeService: import_protocols7.schema.getService("dxos.iframe.IframeService"),
3251
+ BridgeService: import_protocols7.schema.getService("dxos.mesh.bridge.BridgeService")
3252
+ };
3253
+ var workerServiceBundle = {
3254
+ WorkerService: import_protocols7.schema.getService("dxos.iframe.WorkerService")
3255
+ };
3256
+ var appServiceBundle = {
3257
+ AppService: import_protocols7.schema.getService("dxos.iframe.AppService")
3258
+ };
3259
+ var shellServiceBundle = {
3260
+ ShellService: import_protocols7.schema.getService("dxos.iframe.ShellService")
3261
+ };
3262
+
3263
+ // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
3264
+ var ShellRuntimeImpl = class {
3265
+ constructor(_port) {
3266
+ this._port = _port;
3267
+ this.layoutUpdate = new import_async16.Event();
3268
+ this._layout = import_iframe.ShellLayout.DEFAULT;
3269
+ }
3270
+ get layout() {
3271
+ return this._layout;
3272
+ }
3273
+ get invitationCode() {
3274
+ return this._invitationCode;
3275
+ }
3276
+ get spaceKey() {
3277
+ return this._spaceKey;
3278
+ }
3279
+ setLayout(layout, options = {}) {
3280
+ this._layout = layout;
3281
+ this._invitationCode = options.invitationCode;
3282
+ this._spaceKey = options.spaceKey;
3283
+ this.layoutUpdate.emit({
3284
+ layout,
3285
+ ...options
3286
+ });
3287
+ }
3288
+ async setAppContext(context) {
3289
+ (0, import_node_assert12.default)(this._appRpc, "runtime not open");
3290
+ await this._appRpc.rpc.AppService.setContext(context);
3291
+ }
3292
+ async open() {
3293
+ this._appRpc = (0, import_rpc2.createProtoRpcPeer)({
3294
+ requested: appServiceBundle,
3295
+ exposed: shellServiceBundle,
3296
+ handlers: {
3297
+ ShellService: {
3298
+ setLayout: async (request) => {
3299
+ this._layout = request.layout;
3300
+ this._invitationCode = request.invitationCode;
3301
+ this._spaceKey = request.spaceKey;
3302
+ this.layoutUpdate.emit(request);
3303
+ }
3304
+ }
3305
+ },
3306
+ port: this._port
3307
+ });
3308
+ await this._appRpc.open();
3309
+ }
3310
+ async close() {
3311
+ var _a;
3312
+ await ((_a = this._appRpc) == null ? void 0 : _a.close());
3313
+ this._appRpc = void 0;
3314
+ }
3315
+ };
3316
+ var MemoryShellRuntime = class {
3317
+ constructor({ layout, invitationCode, spaceKey } = {}) {
3318
+ this.layoutUpdate = new import_async16.Event();
3319
+ this.contextUpdate = new import_async16.Event();
3320
+ this._layout = layout != null ? layout : import_iframe.ShellLayout.DEFAULT;
3321
+ this._invitationCode = invitationCode;
3322
+ this._spaceKey = spaceKey;
3323
+ }
3324
+ get layout() {
3325
+ return this._layout;
3326
+ }
3327
+ get invitationCode() {
3328
+ return this._invitationCode;
3329
+ }
3330
+ get spaceKey() {
3331
+ return this._spaceKey;
3332
+ }
3333
+ setLayout(layout, options = {}) {
3334
+ this._layout = layout;
3335
+ this._invitationCode = options.invitationCode;
3336
+ this._spaceKey = options.spaceKey;
3337
+ this.layoutUpdate.emit({
3338
+ layout,
3339
+ ...options
3340
+ });
3341
+ }
3342
+ async setAppContext(context) {
3343
+ this.contextUpdate.emit(context);
3344
+ }
3345
+ };
3346
+
3347
+ // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3222
3348
  var __decorate3 = function(decorators, target, key, desc) {
3223
3349
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3224
3350
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3231,11 +3357,12 @@ var __decorate3 = function(decorators, target, key, desc) {
3231
3357
  };
3232
3358
  var LOCK_KEY = "DXOS_RESOURCE_LOCK";
3233
3359
  var IFrameHostRuntime = class {
3234
- constructor({ configProvider, appPort }) {
3360
+ constructor({ configProvider, appPort, shellPort }) {
3235
3361
  this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)();
3236
- this._ready = new import_async16.Trigger();
3362
+ this._ready = new import_async17.Trigger();
3237
3363
  this._configProvider = configProvider;
3238
3364
  this._appPort = appPort;
3365
+ this._shellPort = shellPort;
3239
3366
  this._getService = async (find) => {
3240
3367
  const error = await this._ready.wait();
3241
3368
  if (error) {
@@ -3247,16 +3374,26 @@ var IFrameHostRuntime = class {
3247
3374
  }
3248
3375
  return service;
3249
3376
  };
3377
+ if (this._shellPort) {
3378
+ this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3379
+ }
3380
+ }
3381
+ get services() {
3382
+ return this._clientServices;
3383
+ }
3384
+ get shell() {
3385
+ return this._shellRuntime;
3250
3386
  }
3251
3387
  async start() {
3388
+ var _a;
3252
3389
  (0, import_log12.log)("starting...", {}, {
3253
3390
  file: "iframe-host-runtime.ts",
3254
- line: 63,
3391
+ line: 81,
3255
3392
  scope: this,
3256
3393
  callSite: (f, a) => f(...a)
3257
3394
  });
3258
3395
  try {
3259
- this._config = await this._configProvider();
3396
+ this._config = await (0, import_util7.getAsyncValue)(this._configProvider);
3260
3397
  const signalServer = this._config.get("runtime.services.signal.server");
3261
3398
  this._clientServices = new ClientServicesHost({
3262
3399
  lockKey: LOCK_KEY,
@@ -3269,17 +3406,16 @@ var IFrameHostRuntime = class {
3269
3406
  transportFactory: this._transportFactory
3270
3407
  })
3271
3408
  });
3272
- this._clientRpc = (0, import_rpc2.createProtoRpcPeer)({
3409
+ this._clientRpc = (0, import_rpc3.createProtoRpcPeer)({
3273
3410
  exposed: clientServiceBundle,
3274
3411
  handlers: {
3275
3412
  DataService: async () => await this._getService((services) => services.DataService),
3413
+ DeviceInvitationsService: async () => await this._getService((services) => services.DeviceInvitationsService),
3276
3414
  DevicesService: async () => await this._getService((services) => services.DevicesService),
3277
3415
  DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
3278
- HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
3279
3416
  NetworkService: async () => await this._getService((services) => services.NetworkService),
3280
- ProfileService: async () => await this._getService((services) => services.ProfileService),
3417
+ IdentityService: async () => await this._getService((services) => services.IdentityService),
3281
3418
  SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
3282
- SpaceService: async () => await this._getService((services) => services.SpaceService),
3283
3419
  SpacesService: async () => await this._getService((services) => services.SpacesService),
3284
3420
  SystemService: async () => await this._getService((services) => services.SystemService),
3285
3421
  TracingService: async () => await this._getService((services) => services.TracingService)
@@ -3288,12 +3424,13 @@ var IFrameHostRuntime = class {
3288
3424
  });
3289
3425
  await Promise.all([
3290
3426
  this._clientServices.open(),
3291
- this._clientRpc.open()
3427
+ this._clientRpc.open(),
3428
+ (_a = this._shellRuntime) == null ? void 0 : _a.open()
3292
3429
  ]);
3293
3430
  this._ready.wake(void 0);
3294
3431
  (0, import_log12.log)("started", {}, {
3295
3432
  file: "iframe-host-runtime.ts",
3296
- line: 99,
3433
+ line: 116,
3297
3434
  scope: this,
3298
3435
  callSite: (f, a) => f(...a)
3299
3436
  });
@@ -3301,24 +3438,26 @@ var IFrameHostRuntime = class {
3301
3438
  this._ready.wake(err);
3302
3439
  import_log12.log.catch(err, {}, {
3303
3440
  file: "iframe-host-runtime.ts",
3304
- line: 102,
3441
+ line: 119,
3305
3442
  scope: this,
3306
3443
  callSite: (f, a) => f(...a)
3307
3444
  });
3308
3445
  }
3309
3446
  }
3310
3447
  async stop() {
3448
+ var _a;
3311
3449
  (0, import_log12.log)("stopping...", {}, {
3312
3450
  file: "iframe-host-runtime.ts",
3313
- line: 107,
3451
+ line: 124,
3314
3452
  scope: this,
3315
3453
  callSite: (f, a) => f(...a)
3316
3454
  });
3317
3455
  await this._clientRpc.close();
3318
3456
  await this._clientServices.close();
3457
+ await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
3319
3458
  (0, import_log12.log)("stopped", {}, {
3320
3459
  file: "iframe-host-runtime.ts",
3321
- line: 110,
3460
+ line: 128,
3322
3461
  scope: this,
3323
3462
  callSite: (f, a) => f(...a)
3324
3463
  });
@@ -3330,26 +3469,15 @@ __decorate3([
3330
3469
 
3331
3470
  // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
3332
3471
  var import_network_manager4 = require("@dxos/network-manager");
3333
- var import_rpc3 = require("@dxos/rpc");
3334
-
3335
- // packages/sdk/client-services/src/packlets/vault/services.ts
3336
- var import_protocols7 = require("@dxos/protocols");
3337
- var iframeServiceBundle = {
3338
- IframeService: import_protocols7.schema.getService("dxos.iframe.IframeService"),
3339
- BridgeService: import_protocols7.schema.getService("dxos.mesh.bridge.BridgeService")
3340
- };
3341
- var workerServiceBundle = {
3342
- WorkerService: import_protocols7.schema.getService("dxos.iframe.WorkerService")
3343
- };
3344
-
3345
- // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
3472
+ var import_rpc4 = require("@dxos/rpc");
3346
3473
  var IFrameProxyRuntime = class {
3347
- constructor({ systemPort, workerAppPort, windowAppPort }) {
3474
+ constructor({ systemPort, workerAppPort, windowAppPort, shellPort }) {
3348
3475
  this._transportService = new import_network_manager4.WebRTCTransportService();
3349
3476
  this._systemPort = systemPort;
3350
3477
  this._windowAppPort = windowAppPort;
3351
3478
  this._workerAppPort = workerAppPort;
3352
- this._systemRpc = (0, import_rpc3.createProtoRpcPeer)({
3479
+ this._shellPort = shellPort;
3480
+ this._systemRpc = (0, import_rpc4.createProtoRpcPeer)({
3353
3481
  requested: workerServiceBundle,
3354
3482
  exposed: iframeServiceBundle,
3355
3483
  handlers: {
@@ -3364,22 +3492,95 @@ var IFrameProxyRuntime = class {
3364
3492
  });
3365
3493
  this._workerAppPort.subscribe((msg) => this._windowAppPort.send(msg));
3366
3494
  this._windowAppPort.subscribe((msg) => this._workerAppPort.send(msg));
3495
+ if (this._shellPort) {
3496
+ this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3497
+ }
3498
+ }
3499
+ get shell() {
3500
+ return this._shellRuntime;
3367
3501
  }
3368
3502
  async open(origin) {
3503
+ var _a;
3369
3504
  await this._systemRpc.open();
3370
3505
  await this._systemRpc.rpc.WorkerService.start({
3371
3506
  origin
3372
3507
  });
3508
+ await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
3373
3509
  }
3374
3510
  async close() {
3511
+ var _a;
3512
+ await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
3375
3513
  await this._systemRpc.rpc.WorkerService.stop();
3376
3514
  await this._systemRpc.close();
3377
3515
  }
3378
3516
  };
3379
3517
 
3380
- // packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
3381
- var import_async17 = require("@dxos/async");
3518
+ // packages/sdk/client-services/src/packlets/vault/shell-controller.ts
3519
+ var import_async18 = require("@dxos/async");
3382
3520
  var import_log13 = require("@dxos/log");
3521
+ var import_iframe2 = require("@dxos/protocols/proto/dxos/iframe");
3522
+ var import_rpc5 = require("@dxos/rpc");
3523
+ var ShellController = class {
3524
+ constructor(_port) {
3525
+ this._port = _port;
3526
+ this.contextUpdate = new import_async18.Event();
3527
+ this._display = import_iframe2.ShellDisplay.NONE;
3528
+ }
3529
+ get display() {
3530
+ return this._display;
3531
+ }
3532
+ async setLayout(layout, options = {}) {
3533
+ var _a;
3534
+ (0, import_log13.log)("set layout", {
3535
+ layout,
3536
+ ...options
3537
+ }, {
3538
+ file: "shell-controller.ts",
3539
+ line: 27,
3540
+ scope: this,
3541
+ callSite: (f, a) => f(...a)
3542
+ });
3543
+ this._display = import_iframe2.ShellDisplay.FULLSCREEN;
3544
+ this.contextUpdate.emit({
3545
+ display: this._display
3546
+ });
3547
+ await ((_a = this._shellRpc) == null ? void 0 : _a.rpc.ShellService.setLayout({
3548
+ layout,
3549
+ ...options
3550
+ }));
3551
+ }
3552
+ async open() {
3553
+ this._shellRpc = (0, import_rpc5.createProtoRpcPeer)({
3554
+ requested: shellServiceBundle,
3555
+ exposed: appServiceBundle,
3556
+ handlers: {
3557
+ AppService: {
3558
+ setContext: async (request) => {
3559
+ (0, import_log13.log)("set context", request, {
3560
+ file: "shell-controller.ts",
3561
+ line: 40,
3562
+ scope: this,
3563
+ callSite: (f, a) => f(...a)
3564
+ });
3565
+ this._display = request.display;
3566
+ this.contextUpdate.emit(request);
3567
+ }
3568
+ }
3569
+ },
3570
+ port: this._port
3571
+ });
3572
+ await this._shellRpc.open();
3573
+ }
3574
+ async close() {
3575
+ var _a;
3576
+ await ((_a = this._shellRpc) == null ? void 0 : _a.close());
3577
+ this._shellRpc = void 0;
3578
+ }
3579
+ };
3580
+
3581
+ // packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
3582
+ var import_async19 = require("@dxos/async");
3583
+ var import_log14 = require("@dxos/log");
3383
3584
  var Message;
3384
3585
  (function(Message2) {
3385
3586
  Message2["ACQUIRING"] = "acquiring";
@@ -3387,7 +3588,7 @@ var Message;
3387
3588
  var VaultResourceLock = class {
3388
3589
  constructor({ lockKey, onAcquire, onRelease }) {
3389
3590
  this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
3390
- this._releaseTrigger = new import_async17.Trigger();
3591
+ this._releaseTrigger = new import_async19.Trigger();
3391
3592
  this._lockKey = lockKey;
3392
3593
  this._onAcquire = onAcquire;
3393
3594
  this._onRelease = onRelease;
@@ -3398,7 +3599,7 @@ var VaultResourceLock = class {
3398
3599
  message: Message.ACQUIRING
3399
3600
  });
3400
3601
  try {
3401
- await (0, import_async17.asyncTimeout)(this._requestLock(), 3e3);
3602
+ await (0, import_async19.asyncTimeout)(this._requestLock(), 3e3);
3402
3603
  } catch (e) {
3403
3604
  await this._requestLock(true);
3404
3605
  }
@@ -3412,7 +3613,7 @@ var VaultResourceLock = class {
3412
3613
  }
3413
3614
  }
3414
3615
  async _requestLock(steal = false) {
3415
- (0, import_log13.log)("requesting lock...", {
3616
+ (0, import_log14.log)("requesting lock...", {
3416
3617
  steal
3417
3618
  }, {
3418
3619
  file: "vault-resource-lock.ts",
@@ -3420,23 +3621,23 @@ var VaultResourceLock = class {
3420
3621
  scope: this,
3421
3622
  callSite: (f, a) => f(...a)
3422
3623
  });
3423
- const acquired = new import_async17.Trigger();
3624
+ const acquired = new import_async19.Trigger();
3424
3625
  void navigator.locks.request(this._lockKey, {
3425
3626
  steal
3426
3627
  }, async () => {
3427
3628
  var _a, _b;
3428
3629
  await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3429
3630
  acquired.wake();
3430
- this._releaseTrigger = new import_async17.Trigger();
3631
+ this._releaseTrigger = new import_async19.Trigger();
3431
3632
  await this._releaseTrigger.wait();
3432
- (0, import_log13.log)("releasing lock...", {}, {
3633
+ (0, import_log14.log)("releasing lock...", {}, {
3433
3634
  file: "vault-resource-lock.ts",
3434
3635
  line: 65,
3435
3636
  scope: this,
3436
3637
  callSite: (f, a) => f(...a)
3437
3638
  });
3438
3639
  await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3439
- (0, import_log13.log)("released lock", {}, {
3640
+ (0, import_log14.log)("released lock", {}, {
3440
3641
  file: "vault-resource-lock.ts",
3441
3642
  line: 67,
3442
3643
  scope: this,
@@ -3447,7 +3648,7 @@ var VaultResourceLock = class {
3447
3648
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3448
3649
  });
3449
3650
  await acquired.wait();
3450
- (0, import_log13.log)("recieved lock", {
3651
+ (0, import_log14.log)("recieved lock", {
3451
3652
  steal
3452
3653
  }, {
3453
3654
  file: "vault-resource-lock.ts",
@@ -3459,17 +3660,17 @@ var VaultResourceLock = class {
3459
3660
  };
3460
3661
 
3461
3662
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
3462
- var import_async19 = require("@dxos/async");
3463
- var import_log15 = require("@dxos/log");
3663
+ var import_async21 = require("@dxos/async");
3664
+ var import_log16 = require("@dxos/log");
3464
3665
  var import_messaging2 = require("@dxos/messaging");
3465
3666
  var import_network_manager5 = require("@dxos/network-manager");
3466
3667
 
3467
3668
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
3468
3669
  var import_node_assert13 = __toESM(require("node:assert"));
3469
- var import_async18 = require("@dxos/async");
3470
- var import_log14 = require("@dxos/log");
3471
- var import_rpc4 = require("@dxos/rpc");
3472
- var import_util7 = require("@dxos/util");
3670
+ var import_async20 = require("@dxos/async");
3671
+ var import_log15 = require("@dxos/log");
3672
+ var import_rpc6 = require("@dxos/rpc");
3673
+ var import_util8 = require("@dxos/util");
3473
3674
  var __decorate4 = function(decorators, target, key, desc) {
3474
3675
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3475
3676
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3481,33 +3682,38 @@ var __decorate4 = function(decorators, target, key, desc) {
3481
3682
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3482
3683
  };
3483
3684
  var WorkerSession = class {
3484
- constructor({ getService, systemPort, appPort, options = {
3685
+ constructor({ getService, systemPort, appPort, shellPort, options = {
3485
3686
  heartbeatInterval: 1e3
3486
3687
  } }) {
3487
- this._startTrigger = new import_async18.Trigger();
3488
- this.onClose = new import_util7.Callback();
3688
+ this._startTrigger = new import_async20.Trigger();
3689
+ this.onClose = new import_util8.Callback();
3489
3690
  (0, import_node_assert13.default)(options);
3490
3691
  (0, import_node_assert13.default)(getService);
3491
3692
  this._options = options;
3492
3693
  this._getService = getService;
3493
- this._clientRpc = (0, import_rpc4.createProtoRpcPeer)({
3694
+ const handlers = {
3695
+ DataService: () => this._getService((services) => services.DataService),
3696
+ DeviceInvitationsService: () => this._getService((services) => services.DeviceInvitationsService),
3697
+ DevicesService: () => this._getService((services) => services.DevicesService),
3698
+ DevtoolsHost: () => this._getService((services) => services.DevtoolsHost),
3699
+ NetworkService: () => this._getService((services) => services.NetworkService),
3700
+ IdentityService: () => this._getService((services) => services.IdentityService),
3701
+ SpaceInvitationsService: () => this._getService((services) => services.SpaceInvitationsService),
3702
+ SpacesService: () => this._getService((services) => services.SpacesService),
3703
+ SystemService: () => this._getService((services) => services.SystemService),
3704
+ TracingService: () => this._getService((services) => services.TracingService)
3705
+ };
3706
+ this._clientRpc = (0, import_rpc6.createProtoRpcPeer)({
3494
3707
  exposed: clientServiceBundle,
3495
- handlers: {
3496
- DataService: async () => await this._getService((services) => services.DataService),
3497
- DevicesService: async () => await this._getService((services) => services.DevicesService),
3498
- DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
3499
- HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
3500
- NetworkService: async () => await this._getService((services) => services.NetworkService),
3501
- ProfileService: async () => await this._getService((services) => services.ProfileService),
3502
- SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
3503
- SpaceService: async () => await this._getService((services) => services.SpaceService),
3504
- SpacesService: async () => await this._getService((services) => services.SpacesService),
3505
- SystemService: async () => await this._getService((services) => services.SystemService),
3506
- TracingService: async () => await this._getService((services) => services.TracingService)
3507
- },
3708
+ handlers,
3508
3709
  port: appPort
3509
3710
  });
3510
- this._iframeRpc = (0, import_rpc4.createProtoRpcPeer)({
3711
+ this._shellClientRpc = (0, import_rpc6.createProtoRpcPeer)({
3712
+ exposed: clientServiceBundle,
3713
+ handlers,
3714
+ port: shellPort
3715
+ });
3716
+ this._iframeRpc = (0, import_rpc6.createProtoRpcPeer)({
3511
3717
  requested: iframeServiceBundle,
3512
3718
  exposed: workerServiceBundle,
3513
3719
  handlers: {
@@ -3521,9 +3727,9 @@ var WorkerSession = class {
3521
3727
  try {
3522
3728
  await this.close();
3523
3729
  } catch (err) {
3524
- import_log14.log.catch(err, {}, {
3730
+ import_log15.log.catch(err, {}, {
3525
3731
  file: "worker-session.ts",
3526
- line: 90,
3732
+ line: 91,
3527
3733
  scope: this,
3528
3734
  callSite: (f, a) => f(...a)
3529
3735
  });
@@ -3539,15 +3745,16 @@ var WorkerSession = class {
3539
3745
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
3540
3746
  }
3541
3747
  async open() {
3542
- import_log14.log.info("opening..", {}, {
3748
+ import_log15.log.info("opening..", {}, {
3543
3749
  file: "worker-session.ts",
3544
- line: 104,
3750
+ line: 105,
3545
3751
  scope: this,
3546
3752
  callSite: (f, a) => f(...a)
3547
3753
  });
3548
3754
  await Promise.all([
3549
3755
  this._clientRpc.open(),
3550
- this._iframeRpc.open()
3756
+ this._iframeRpc.open(),
3757
+ this._maybeOpenShell()
3551
3758
  ]);
3552
3759
  await this._startTrigger.wait({
3553
3760
  timeout: 3e3
@@ -3556,20 +3763,20 @@ var WorkerSession = class {
3556
3763
  try {
3557
3764
  await this._iframeRpc.rpc.IframeService.heartbeat();
3558
3765
  } catch (err1) {
3559
- import_log14.log.warn("Heartbeat failed", {
3766
+ import_log15.log.warn("Heartbeat failed", {
3560
3767
  err: err1
3561
3768
  }, {
3562
3769
  file: "worker-session.ts",
3563
- line: 116,
3770
+ line: 117,
3564
3771
  scope: this,
3565
3772
  callSite: (f, a) => f(...a)
3566
3773
  });
3567
3774
  try {
3568
3775
  await this.close();
3569
3776
  } catch (err) {
3570
- import_log14.log.catch(err, {}, {
3777
+ import_log15.log.catch(err, {}, {
3571
3778
  file: "worker-session.ts",
3572
- line: 120,
3779
+ line: 121,
3573
3780
  scope: this,
3574
3781
  callSite: (f, a) => f(...a)
3575
3782
  });
@@ -3578,18 +3785,18 @@ var WorkerSession = class {
3578
3785
  }, this._options.heartbeatInterval);
3579
3786
  }
3580
3787
  async close() {
3581
- import_log14.log.info("closing..", {}, {
3788
+ import_log15.log.info("closing..", {}, {
3582
3789
  file: "worker-session.ts",
3583
- line: 127,
3790
+ line: 128,
3584
3791
  scope: this,
3585
3792
  callSite: (f, a) => f(...a)
3586
3793
  });
3587
3794
  try {
3588
3795
  await this.onClose.callIfSet();
3589
3796
  } catch (err) {
3590
- import_log14.log.catch(err, {}, {
3797
+ import_log15.log.catch(err, {}, {
3591
3798
  file: "worker-session.ts",
3592
- line: 131,
3799
+ line: 132,
3593
3800
  scope: this,
3594
3801
  callSite: (f, a) => f(...a)
3595
3802
  });
@@ -3602,9 +3809,21 @@ var WorkerSession = class {
3602
3809
  this._iframeRpc.close()
3603
3810
  ]);
3604
3811
  }
3812
+ async _maybeOpenShell() {
3813
+ try {
3814
+ await (0, import_async20.asyncTimeout)(this._shellClientRpc.open(), 1e3);
3815
+ } catch (e) {
3816
+ import_log15.log.info("No shell connected.", {}, {
3817
+ file: "worker-session.ts",
3818
+ line: 146,
3819
+ scope: this,
3820
+ callSite: (f, a) => f(...a)
3821
+ });
3822
+ }
3823
+ }
3605
3824
  };
3606
3825
  __decorate4([
3607
- import_log14.logInfo
3826
+ import_log15.logInfo
3608
3827
  ], WorkerSession.prototype, "origin", void 0);
3609
3828
 
3610
3829
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
@@ -3613,13 +3832,13 @@ var WorkerRuntime = class {
3613
3832
  constructor(_configProvider) {
3614
3833
  this._configProvider = _configProvider;
3615
3834
  this._transportFactory = new import_network_manager5.WebRTCTransportProxyFactory();
3616
- this._ready = new import_async19.Trigger();
3835
+ this._ready = new import_async21.Trigger();
3617
3836
  this.sessions = /* @__PURE__ */ new Set();
3618
3837
  }
3619
3838
  async start() {
3620
- (0, import_log15.log)("starting...", {}, {
3839
+ (0, import_log16.log)("starting...", {}, {
3621
3840
  file: "worker-runtime.ts",
3622
- line: 41,
3841
+ line: 42,
3623
3842
  scope: this,
3624
3843
  callSite: (f, a) => f(...a)
3625
3844
  });
@@ -3638,17 +3857,17 @@ var WorkerRuntime = class {
3638
3857
  });
3639
3858
  await this._clientServices.open();
3640
3859
  this._ready.wake(void 0);
3641
- (0, import_log15.log)("started", {}, {
3860
+ (0, import_log16.log)("started", {}, {
3642
3861
  file: "worker-runtime.ts",
3643
- line: 58,
3862
+ line: 59,
3644
3863
  scope: this,
3645
3864
  callSite: (f, a) => f(...a)
3646
3865
  });
3647
3866
  } catch (err) {
3648
3867
  this._ready.wake(err);
3649
- import_log15.log.catch(err, {}, {
3868
+ import_log16.log.catch(err, {}, {
3650
3869
  file: "worker-runtime.ts",
3651
- line: 61,
3870
+ line: 62,
3652
3871
  scope: this,
3653
3872
  callSite: (f, a) => f(...a)
3654
3873
  });
@@ -3660,7 +3879,7 @@ var WorkerRuntime = class {
3660
3879
  /**
3661
3880
  * Create a new session.
3662
3881
  */
3663
- async createSession({ appPort, systemPort }) {
3882
+ async createSession({ appPort, systemPort, shellPort }) {
3664
3883
  const session = new WorkerSession({
3665
3884
  getService: async (find) => {
3666
3885
  const error = await this._ready.wait();
@@ -3675,6 +3894,7 @@ var WorkerRuntime = class {
3675
3894
  },
3676
3895
  appPort,
3677
3896
  systemPort,
3897
+ shellPort,
3678
3898
  readySignal: this._ready
3679
3899
  });
3680
3900
  session.onClose.set(async () => {
@@ -3735,8 +3955,10 @@ var ClientServicesHost = class {
3735
3955
  // TODO(burdon): Create ApolloLink abstraction (see Client).
3736
3956
  networkManager,
3737
3957
  storage = createStorageObjects(config.get("runtime.client.storage", {})).storage,
3958
+ // TODO(wittjosiah): Turn this on by default.
3738
3959
  lockKey
3739
3960
  }) {
3961
+ this._statusUpdate = new import_async22.Event();
3740
3962
  this._open = false;
3741
3963
  this._config = config;
3742
3964
  this._modelFactory = modelFactory;
@@ -3749,23 +3971,19 @@ var ClientServicesHost = class {
3749
3971
  }) : void 0;
3750
3972
  this._systemService = new SystemServiceImpl({
3751
3973
  config: this._config,
3752
- onInit: async () => {
3753
- var _a;
3754
- await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
3755
- },
3756
- onStatus: async () => {
3757
- if (!this.isOpen) {
3758
- return {
3759
- status: import_client2.Status.INACTIVE
3760
- };
3974
+ statusUpdate: this._statusUpdate,
3975
+ getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
3976
+ onUpdateStatus: async (status) => {
3977
+ var _a, _b;
3978
+ if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
3979
+ await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
3980
+ } else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
3981
+ await ((_b = this._resourceLock) == null ? void 0 : _b.release());
3761
3982
  }
3762
- return {
3763
- status: import_client2.Status.ACTIVE
3764
- };
3765
3983
  },
3766
3984
  onReset: async () => {
3767
- var _a;
3768
- await ((_a = this._serviceContext) == null ? void 0 : _a.reset());
3985
+ (0, import_node_assert14.default)(this._serviceContext, "service host is closed");
3986
+ await this._serviceContext.reset();
3769
3987
  }
3770
3988
  });
3771
3989
  this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
@@ -3782,36 +4000,37 @@ var ClientServicesHost = class {
3782
4000
  return this._serviceRegistry.services;
3783
4001
  }
3784
4002
  async open() {
3785
- var _a;
4003
+ var _a, _b;
3786
4004
  if (this._open) {
3787
4005
  return;
3788
4006
  }
3789
- (0, import_log16.log)("opening...", {}, {
4007
+ (0, import_log17.log)("opening...", {}, {
3790
4008
  file: "service-host.ts",
3791
- line: 125,
4009
+ line: 133,
3792
4010
  scope: this,
3793
4011
  callSite: (f, a) => f(...a)
3794
4012
  });
4013
+ await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
3795
4014
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
3796
4015
  this._serviceRegistry.setServices({
3797
- // TODO(burdon): Move to new protobuf definitions.
3798
4016
  SystemService: this._systemService,
3799
- HaloInvitationsService: new HaloInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.haloInvitations),
4017
+ IdentityService: new IdentityServiceImpl(this._serviceContext),
3800
4018
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
4019
+ DeviceInvitationsService: new DeviceInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.deviceInvitations),
3801
4020
  SpaceInvitationsService: new SpaceInvitationsServiceImpl(this._serviceContext.identityManager, () => {
3802
4021
  var _a2;
3803
- return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceInvitations not initialized"));
4022
+ return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : (0, import_debug6.raise)(new Error("SpaceInvitations not initialized"));
3804
4023
  }, () => {
3805
4024
  var _a2;
3806
- return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceManager not initialized"));
4025
+ return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0, import_debug6.raise)(new Error("SpaceManager not initialized"));
4026
+ }),
4027
+ SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
4028
+ await this._serviceContext.initialized.wait();
4029
+ return this._serviceContext.dataSpaceManager;
3807
4030
  }),
3808
- SpacesService: new SpacesServiceImpl(this._serviceContext.spaceManager),
3809
- DataService: new import_echo_db5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4031
+ DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
3810
4032
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
3811
4033
  // TODO(burdon): Move to new protobuf definitions.
3812
- ProfileService: new ProfileServiceImpl(this._serviceContext),
3813
- // TODO(burdon): Port old SubscribeSpaces to QueryServices>
3814
- SpaceService: new SpaceServiceImpl(this._serviceContext),
3815
4034
  TracingService: new TracingServiceImpl(this._config),
3816
4035
  DevtoolsHost: new DevtoolsServiceImpl({
3817
4036
  events: new DevtoolsHostEvents(),
@@ -3821,12 +4040,13 @@ var ClientServicesHost = class {
3821
4040
  });
3822
4041
  await this._serviceContext.open();
3823
4042
  this._open = true;
3824
- const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
3825
- (0, import_log16.log)("opened", {
4043
+ this._statusUpdate.emit();
4044
+ const deviceKey = (_b = this._serviceContext.identityManager.identity) == null ? void 0 : _b.deviceKey;
4045
+ (0, import_log17.log)("opened", {
3826
4046
  deviceKey
3827
4047
  }, {
3828
4048
  file: "service-host.ts",
3829
- line: 172,
4049
+ line: 186,
3830
4050
  scope: this,
3831
4051
  callSite: (f, a) => f(...a)
3832
4052
  });
@@ -3837,11 +4057,11 @@ var ClientServicesHost = class {
3837
4057
  return;
3838
4058
  }
3839
4059
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
3840
- (0, import_log16.log)("closing...", {
4060
+ (0, import_log17.log)("closing...", {
3841
4061
  deviceKey
3842
4062
  }, {
3843
4063
  file: "service-host.ts",
3844
- line: 181,
4064
+ line: 195,
3845
4065
  scope: this,
3846
4066
  callSite: (f, a) => f(...a)
3847
4067
  });
@@ -3850,11 +4070,12 @@ var ClientServicesHost = class {
3850
4070
  });
3851
4071
  await this._serviceContext.close();
3852
4072
  this._open = false;
3853
- (0, import_log16.log)("closed", {
4073
+ this._statusUpdate.emit();
4074
+ (0, import_log17.log)("closed", {
3854
4075
  deviceKey
3855
4076
  }, {
3856
4077
  file: "service-host.ts",
3857
- line: 185,
4078
+ line: 200,
3858
4079
  scope: this,
3859
4080
  callSite: (f, a) => f(...a)
3860
4081
  });
@@ -3862,14 +4083,14 @@ var ClientServicesHost = class {
3862
4083
  };
3863
4084
 
3864
4085
  // packages/sdk/client-services/src/packlets/services/service-proxy.ts
3865
- var import_async20 = require("@dxos/async");
4086
+ var import_async23 = require("@dxos/async");
3866
4087
  var import_errors2 = require("@dxos/errors");
3867
- var import_rpc5 = require("@dxos/rpc");
4088
+ var import_rpc7 = require("@dxos/rpc");
3868
4089
  var ClientServicesProxy = class {
3869
4090
  // prettier-ignore
3870
4091
  constructor(port, _timeout = 3e4) {
3871
4092
  this._timeout = _timeout;
3872
- this._proxy = (0, import_rpc5.createProtoRpcPeer)({
4093
+ this._proxy = (0, import_rpc7.createProtoRpcPeer)({
3873
4094
  requested: clientServiceBundle,
3874
4095
  exposed: {},
3875
4096
  handlers: {},
@@ -3886,7 +4107,7 @@ var ClientServicesProxy = class {
3886
4107
  return this._proxy.rpc;
3887
4108
  }
3888
4109
  async open() {
3889
- await (0, import_async20.asyncTimeout)(this._proxy.open(), this._timeout, new import_errors2.RemoteServiceConnectionTimeout());
4110
+ await (0, import_async23.asyncTimeout)(this._proxy.open(), this._timeout, new import_errors2.RemoteServiceConnectionTimeout());
3890
4111
  }
3891
4112
  async close() {
3892
4113
  await this._proxy.close();
@@ -3901,38 +4122,40 @@ var ClientServicesProxy = class {
3901
4122
  AuthenticatingInvitationProvider,
3902
4123
  ClientServicesHost,
3903
4124
  ClientServicesProxy,
4125
+ DeviceInvitationsHandler,
4126
+ DeviceInvitationsProxy,
4127
+ DeviceInvitationsServiceImpl,
3904
4128
  DevtoolsHostEvents,
3905
4129
  DevtoolsServiceImpl,
3906
- HaloInvitationsHandler,
3907
- HaloInvitationsProxy,
3908
- HaloInvitationsServiceImpl,
3909
4130
  IFrameHostRuntime,
3910
4131
  IFrameProxyRuntime,
3911
4132
  INVITATION_TIMEOUT,
3912
4133
  Identity,
3913
4134
  IdentityManager,
4135
+ IdentityServiceImpl,
3914
4136
  InvitationEncoder,
3915
4137
  InvitationObservableProvider,
4138
+ MemoryShellRuntime,
3916
4139
  ON_CLOSE_DELAY,
3917
- ProfileServiceImpl,
3918
4140
  ServiceContext,
3919
4141
  ServiceRegistry,
4142
+ ShellController,
4143
+ ShellRuntimeImpl,
3920
4144
  SpaceInvitationsHandler,
3921
4145
  SpaceInvitationsProxy,
3922
4146
  SpaceInvitationsServiceImpl,
3923
- SpaceServiceImpl,
3924
- SystemServiceImpl,
3925
- TracingServiceImpl,
3926
4147
  TrustedKeySetAuthVerifier,
3927
4148
  VaultResourceLock,
3928
4149
  WorkerRuntime,
3929
4150
  WorkerSession,
4151
+ appServiceBundle,
3930
4152
  clientServiceBundle,
3931
4153
  createAuthProvider,
3932
4154
  createDefaultModelFactory,
3933
4155
  createStorageObjects,
3934
4156
  getNetworkPeers,
3935
4157
  iframeServiceBundle,
4158
+ shellServiceBundle,
3936
4159
  subscribeToFeedBlocks,
3937
4160
  subscribeToFeeds,
3938
4161
  subscribeToNetworkStatus,