@dxos/client-services 0.1.26 → 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
@@ -1,224 +1,13 @@
1
1
  import "@dxos/node-std/globals"
2
2
 
3
- // packages/sdk/client-services/src/packlets/deprecated/space.ts
4
- import assert from "@dxos/node-std/assert";
5
- import { Stream } from "@dxos/codec-protobuf";
6
- import { todo } from "@dxos/debug";
7
- import { log } from "@dxos/log";
8
- import { SpaceMember } from "@dxos/protocols/proto/dxos/client";
9
- import { humanize } from "@dxos/util";
10
- var SpaceServiceImpl = class {
11
- constructor(serviceContext) {
12
- this.serviceContext = serviceContext;
13
- this.inviteeInvitations = /* @__PURE__ */ new Map();
14
- }
15
- subscribeToSpace(request) {
16
- return new Stream(({ next }) => {
17
- next({
18
- space: {
19
- publicKey: request.spaceKey,
20
- isOpen: true,
21
- isActive: true,
22
- members: []
23
- }
24
- });
25
- });
26
- }
27
- subscribeSpaces() {
28
- return new Stream(({ next, ctx }) => {
29
- const onUpdate = () => {
30
- const spaces = Array.from(this.serviceContext.dataSpaceManager.spaces.values()).filter((space) => this.serviceContext.dataServiceSubscriptions.getDataService(space.key)).map((space) => ({
31
- publicKey: space.key,
32
- isOpen: true,
33
- isActive: true,
34
- members: Array.from(space.inner.spaceState.members.values()).map((member) => {
35
- var _a, _b, _c;
36
- return {
37
- identityKey: member.key,
38
- profile: {
39
- identityKey: member.key,
40
- displayName: (_b = (_a = member.assertion.profile) == null ? void 0 : _a.displayName) != null ? _b : humanize(member.key)
41
- },
42
- 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 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
43
- };
44
- })
45
- }));
46
- log("update", {
47
- spaces
48
- }, {
49
- file: "space.ts",
50
- line: 119,
51
- scope: this,
52
- callSite: (f, a) => f(...a)
53
- });
54
- next({
55
- spaces
56
- });
57
- };
58
- setTimeout(async () => {
59
- if (!this.serviceContext.dataSpaceManager) {
60
- next({
61
- spaces: []
62
- });
63
- }
64
- await this.serviceContext.initialized.wait();
65
- const subscribeSpaces = () => {
66
- for (const space of this.serviceContext.dataSpaceManager.spaces.values()) {
67
- if (!this.serviceContext.dataServiceSubscriptions.getDataService(space.key)) {
68
- continue;
69
- }
70
- space.stateUpdate.on(ctx, onUpdate);
71
- space.presence.updated.on(ctx, onUpdate);
72
- }
73
- };
74
- this.serviceContext.dataSpaceManager.updated.on(ctx, () => {
75
- subscribeSpaces();
76
- onUpdate();
77
- });
78
- subscribeSpaces();
79
- onUpdate();
80
- });
81
- });
82
- }
83
- async getSpaceDetails(request) {
84
- return todo();
85
- }
86
- async createSpace() {
87
- if (!this.serviceContext.identityManager.identity) {
88
- throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
89
- }
90
- await this.serviceContext.initialized.wait();
91
- const space = await this.serviceContext.dataSpaceManager.createSpace();
92
- return {
93
- publicKey: space.key,
94
- isOpen: true,
95
- isActive: true
96
- };
97
- }
98
- async cloneSpace(snapshot) {
99
- return todo();
100
- }
101
- async setSpaceState(request) {
102
- return todo();
103
- }
104
- async authenticateInvitation(request) {
105
- var _a;
106
- assert(request.processId, "Process ID is missing.");
107
- const invitation = this.inviteeInvitations.get(request.processId);
108
- assert(invitation, "Invitation not found.");
109
- assert(request.secret, "Secret not provided.");
110
- invitation.secret = request.secret;
111
- (_a = invitation.secretTrigger) == null ? void 0 : _a.call(invitation);
112
- }
113
- subscribeMembers(request) {
114
- return todo();
115
- }
116
- async createSnapshot(request) {
117
- return todo();
118
- }
119
- };
120
-
121
- // packages/sdk/client-services/src/packlets/deprecated/profile.ts
122
- import assert2 from "@dxos/node-std/assert";
123
- import { Stream as Stream2 } from "@dxos/codec-protobuf";
124
- import { signPresentation } from "@dxos/credentials";
125
- import { todo as todo2 } from "@dxos/debug";
126
- var ProfileServiceImpl = class {
127
- constructor(context) {
128
- this.context = context;
129
- this.inviteeInvitations = /* @__PURE__ */ new Map();
130
- }
131
- subscribeProfile() {
132
- return new Stream2(({ next }) => {
133
- const emitNext = () => {
134
- var _a;
135
- return next({
136
- profile: this.context.identityManager.identity ? {
137
- identityKey: this.context.identityManager.identity.identityKey,
138
- deviceKey: this.context.identityManager.identity.deviceKey,
139
- displayName: (_a = this.context.identityManager.identity.profileDocument) == null ? void 0 : _a.displayName,
140
- haloSpace: this.context.identityManager.identity.space.key
141
- } : void 0
142
- });
143
- };
144
- emitNext();
145
- return this.context.identityManager.stateUpdate.on(emitNext);
146
- });
147
- }
148
- async createProfile(request) {
149
- var _a;
150
- await this.context.createIdentity({
151
- displayName: request.displayName
152
- });
153
- return {
154
- identityKey: this.context.identityManager.identity.identityKey,
155
- deviceKey: this.context.identityManager.identity.deviceKey,
156
- displayName: (_a = this.context.identityManager.identity.profileDocument) == null ? void 0 : _a.displayName,
157
- haloSpace: this.context.identityManager.identity.space.key
158
- };
159
- }
160
- async recoverProfile(request) {
161
- return todo2();
162
- if (!request.seedPhrase) {
163
- throw new Error("Recovery SeedPhrase not provided.");
164
- }
165
- }
166
- async signPresentation({ presentation, nonce }) {
167
- assert2(this.context.identityManager.identity, "Identity not initialized.");
168
- return await signPresentation({
169
- presentation,
170
- signer: this.context.keyring,
171
- signerKey: this.context.identityManager.identity.deviceKey,
172
- chain: this.context.identityManager.identity.deviceCredentialChain,
173
- nonce
174
- });
175
- }
176
- };
177
-
178
- // packages/sdk/client-services/src/packlets/deprecated/system.ts
179
- var SystemServiceImpl = class {
180
- constructor({ config, onInit, onStatus, onReset }) {
181
- this._config = config;
182
- this._onInit = onInit;
183
- this._onStatus = onStatus;
184
- this._onReset = onReset;
185
- }
186
- async getConfig() {
187
- return this._config.values;
188
- }
189
- // TODO(burdon): Connect to iframe RPC heartbeat for network status?
190
- async getStatus() {
191
- return this._onStatus();
192
- }
193
- async initSession() {
194
- await this._onInit();
195
- }
196
- async reset() {
197
- await this._onReset();
198
- }
199
- };
200
-
201
- // packages/sdk/client-services/src/packlets/deprecated/tracing.ts
202
- var TracingServiceImpl = class {
203
- constructor(_config) {
204
- this._config = _config;
205
- }
206
- async setTracingOptions() {
207
- throw new Error("Tracing not available.");
208
- }
209
- subscribeToRpcTrace() {
210
- throw new Error("Tracing not available.");
211
- }
212
- };
213
-
214
3
  // packages/sdk/client-services/src/packlets/devtools/feeds.ts
215
4
  import { EventSubscriptions } from "@dxos/async";
216
- import { Stream as Stream3 } from "@dxos/codec-protobuf";
5
+ import { Stream } from "@dxos/codec-protobuf";
217
6
  import { FeedIterator } from "@dxos/feed-store";
218
7
  import { PublicKey } from "@dxos/keys";
219
8
  import { ComplexMap } from "@dxos/util";
220
9
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
221
- return new Stream3(({ next }) => {
10
+ return new Stream(({ next }) => {
222
11
  if ((feedKeys == null ? void 0 : feedKeys.length) === 0) {
223
12
  return;
224
13
  }
@@ -248,7 +37,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
248
37
  });
249
38
  };
250
39
  var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
251
- return new Stream3(({ next }) => {
40
+ return new Stream(({ next }) => {
252
41
  if (!feedKey) {
253
42
  return;
254
43
  }
@@ -287,10 +76,10 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
287
76
  };
288
77
 
289
78
  // packages/sdk/client-services/src/packlets/devtools/network.ts
290
- import { Stream as Stream4 } from "@dxos/codec-protobuf";
79
+ import { Stream as Stream2 } from "@dxos/codec-protobuf";
291
80
  import { Context } from "@dxos/context";
292
81
  import { PublicKey as PublicKey2 } from "@dxos/keys";
293
- var subscribeToNetworkStatus = ({ networkManager }) => new Stream4(({ next, close }) => {
82
+ var subscribeToNetworkStatus = ({ networkManager }) => new Stream2(({ next, close }) => {
294
83
  const update = () => {
295
84
  try {
296
85
  const status = networkManager.signalManager.getStatus();
@@ -304,7 +93,7 @@ var subscribeToNetworkStatus = ({ networkManager }) => new Stream4(({ next, clos
304
93
  networkManager.signalManager.statusChanged.on(update);
305
94
  update();
306
95
  });
307
- var subscribeToSignal = ({ networkManager }) => new Stream4(({ next }) => {
96
+ var subscribeToSignal = ({ networkManager }) => new Stream2(({ next }) => {
308
97
  const ctx = new Context();
309
98
  networkManager.signalManager.onMessage.on(ctx, (message) => {
310
99
  next({
@@ -326,7 +115,7 @@ var subscribeToSignal = ({ networkManager }) => new Stream4(({ next }) => {
326
115
  return ctx.dispose();
327
116
  };
328
117
  });
329
- var subscribeToNetworkTopics = ({ networkManager }) => new Stream4(({ next, close }) => {
118
+ var subscribeToNetworkTopics = ({ networkManager }) => new Stream2(({ next, close }) => {
330
119
  const update = () => {
331
120
  try {
332
121
  const topics = networkManager.topics;
@@ -347,7 +136,7 @@ var subscribeToNetworkTopics = ({ networkManager }) => new Stream4(({ next, clos
347
136
  networkManager.topicsUpdated.on(update);
348
137
  update();
349
138
  });
350
- var subscribeToSwarmInfo = ({ networkManager }) => new Stream4(({ next }) => {
139
+ var subscribeToSwarmInfo = ({ networkManager }) => new Stream2(({ next }) => {
351
140
  var _a;
352
141
  const update = () => {
353
142
  var _a2;
@@ -375,9 +164,9 @@ var getNetworkPeers = ({ networkManager }, request) => {
375
164
  };
376
165
 
377
166
  // packages/sdk/client-services/src/packlets/devtools/spaces.ts
378
- import { Stream as Stream5 } from "@dxos/codec-protobuf";
167
+ import { Stream as Stream3 } from "@dxos/codec-protobuf";
379
168
  var subscribeToSpaces = (context, { spaceKeys = [] }) => {
380
- return new Stream5(({ next }) => {
169
+ return new Stream3(({ next }) => {
381
170
  let unsubscribe;
382
171
  const update = async () => {
383
172
  const spaces = [
@@ -412,11 +201,11 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
412
201
 
413
202
  // packages/sdk/client-services/src/packlets/devtools/devtools.ts
414
203
  import { Event as AsyncEvent } from "@dxos/async";
415
- import { Stream as Stream7 } from "@dxos/codec-protobuf";
204
+ import { Stream as Stream5 } from "@dxos/codec-protobuf";
416
205
 
417
206
  // packages/sdk/client-services/src/packlets/devtools/keys.ts
418
- import { Stream as Stream6 } from "@dxos/codec-protobuf";
419
- var subscribeToKeyringKeys = ({ keyring }) => new Stream6(({ next }) => {
207
+ import { Stream as Stream4 } from "@dxos/codec-protobuf";
208
+ var subscribeToKeyringKeys = ({ keyring }) => new Stream4(({ next }) => {
420
209
  const update = () => {
421
210
  next({
422
211
  keys: keyring.list()
@@ -438,7 +227,7 @@ var DevtoolsServiceImpl = class {
438
227
  this.params = params;
439
228
  }
440
229
  events(request) {
441
- return new Stream7(({ next }) => {
230
+ return new Stream5(({ next }) => {
442
231
  this.params.events.ready.on(() => {
443
232
  next({
444
233
  ready: {}
@@ -518,7 +307,7 @@ var DevtoolsServiceImpl = class {
518
307
  import { Trigger } from "@dxos/async";
519
308
  import { Context as Context2 } from "@dxos/context";
520
309
  import { verifyCredential } from "@dxos/credentials";
521
- import { log as log2 } from "@dxos/log";
310
+ import { log } from "@dxos/log";
522
311
  import { schema } from "@dxos/protocols";
523
312
  var createAuthProvider = (signer) => async (nonce) => {
524
313
  const credential = await signer.createCredential({
@@ -542,7 +331,7 @@ var TrustedKeySetAuthVerifier = class {
542
331
  get verifier() {
543
332
  return async (nonce, auth) => {
544
333
  const credential = schema.getCodecForType("dxos.halo.credentials.Credential").decode(auth);
545
- log2("authenticating...", {
334
+ log("authenticating...", {
546
335
  credential
547
336
  }, {
548
337
  file: "authenticator.ts",
@@ -552,7 +341,7 @@ var TrustedKeySetAuthVerifier = class {
552
341
  });
553
342
  const result = await verifyCredential(credential);
554
343
  if (result.kind === "fail") {
555
- log2("Invalid credential", {
344
+ log("Invalid credential", {
556
345
  result
557
346
  }, {
558
347
  file: "authenticator.ts",
@@ -563,7 +352,7 @@ var TrustedKeySetAuthVerifier = class {
563
352
  return false;
564
353
  }
565
354
  if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
566
- log2("Invalid nonce", {
355
+ log("Invalid nonce", {
567
356
  nonce,
568
357
  credential
569
358
  }, {
@@ -575,7 +364,7 @@ var TrustedKeySetAuthVerifier = class {
575
364
  return false;
576
365
  }
577
366
  if (this._isTrustedKey(credential.issuer)) {
578
- log2("key is not currently in trusted set, waiting...", {
367
+ log("key is not currently in trusted set, waiting...", {
579
368
  key: credential.issuer
580
369
  }, {
581
370
  file: "authenticator.ts",
@@ -591,7 +380,7 @@ var TrustedKeySetAuthVerifier = class {
591
380
  });
592
381
  const clear = this._params.update.on(this._ctx, () => {
593
382
  if (this._isTrustedKey(credential.issuer)) {
594
- log2("auth success", {
383
+ log("auth success", {
595
384
  key: credential.issuer
596
385
  }, {
597
386
  file: "authenticator.ts",
@@ -601,7 +390,7 @@ var TrustedKeySetAuthVerifier = class {
601
390
  });
602
391
  trigger.wake(true);
603
392
  } else {
604
- log2("key is not currently in trusted set, waiting...", {
393
+ log("key is not currently in trusted set, waiting...", {
605
394
  key: credential.issuer
606
395
  }, {
607
396
  file: "authenticator.ts",
@@ -629,12 +418,12 @@ var TrustedKeySetAuthVerifier = class {
629
418
  };
630
419
 
631
420
  // packages/sdk/client-services/src/packlets/identity/identity.ts
632
- import assert3 from "@dxos/node-std/assert";
421
+ import assert from "@dxos/node-std/assert";
633
422
  import { Event } from "@dxos/async";
634
423
  import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
635
424
  import { failUndefined } from "@dxos/debug";
636
425
  import { writeMessages } from "@dxos/feed-store";
637
- import { log as log3 } from "@dxos/log";
426
+ import { log as log2 } from "@dxos/log";
638
427
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
639
428
  var AUTH_TIMEOUT = 3e4;
640
429
  var Identity = class {
@@ -711,7 +500,7 @@ var Identity = class {
711
500
  * Requires identity to be ready.
712
501
  */
713
502
  getIdentityCredentialSigner() {
714
- assert3(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
503
+ assert(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
715
504
  return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
716
505
  }
717
506
  /**
@@ -721,7 +510,7 @@ var Identity = class {
721
510
  return createCredentialSignerWithKey(this._signer, this.deviceKey);
722
511
  }
723
512
  async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
724
- log3("Admitting device:", {
513
+ log2("Admitting device:", {
725
514
  identityKey: this.identityKey,
726
515
  hostDevice: this.deviceKey,
727
516
  deviceKey,
@@ -772,10 +561,10 @@ var Identity = class {
772
561
  };
773
562
 
774
563
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
775
- import assert4 from "@dxos/node-std/assert";
564
+ import assert2 from "@dxos/node-std/assert";
776
565
  import { Event as Event2 } from "@dxos/async";
777
566
  import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
778
- import { log as log4 } from "@dxos/log";
567
+ import { log as log3 } from "@dxos/log";
779
568
  import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
780
569
  import { deferFunction } from "@dxos/util";
781
570
  var IdentityManager = class {
@@ -794,7 +583,7 @@ var IdentityManager = class {
794
583
  async open() {
795
584
  await this._metadataStore.load();
796
585
  const identityRecord = this._metadataStore.getIdentityRecord();
797
- log4("identity record", {
586
+ log3("identity record", {
798
587
  identityRecord
799
588
  }, {
800
589
  file: "identity-manager.ts",
@@ -814,8 +603,8 @@ var IdentityManager = class {
814
603
  await ((_a = this._identity) == null ? void 0 : _a.close());
815
604
  }
816
605
  async createIdentity({ displayName } = {}) {
817
- assert4(!this._identity, "Identity already exists.");
818
- log4("creating identity...", {}, {
606
+ assert2(!this._identity, "Identity already exists.");
607
+ log3("creating identity...", {}, {
819
608
  file: "identity-manager.ts",
820
609
  line: 78,
821
610
  scope: this,
@@ -860,7 +649,7 @@ var IdentityManager = class {
860
649
  this._identity = identity;
861
650
  await this._identity.ready();
862
651
  this.stateUpdate.emit();
863
- log4("created identity", {
652
+ log3("created identity", {
864
653
  identityKey: identity.identityKey,
865
654
  deviceKey: identity.deviceKey
866
655
  }, {
@@ -875,7 +664,7 @@ var IdentityManager = class {
875
664
  * Accept an existing identity. Expects it's device key to be authorized (now or later).
876
665
  */
877
666
  async acceptIdentity(params) {
878
- log4("accepting identity", {
667
+ log3("accepting identity", {
879
668
  params
880
669
  }, {
881
670
  file: "identity-manager.ts",
@@ -883,7 +672,7 @@ var IdentityManager = class {
883
672
  scope: this,
884
673
  callSite: (f, a) => f(...a)
885
674
  });
886
- assert4(!this._identity, "Identity already exists.");
675
+ assert2(!this._identity, "Identity already exists.");
887
676
  const identityRecord = {
888
677
  identityKey: params.identityKey,
889
678
  deviceKey: params.deviceKey,
@@ -900,7 +689,7 @@ var IdentityManager = class {
900
689
  await this._metadataStore.setIdentityRecord(identityRecord);
901
690
  await this._identity.ready();
902
691
  this.stateUpdate.emit();
903
- log4("accepted identity", {
692
+ log3("accepted identity", {
904
693
  identityKey: identity.identityKey,
905
694
  deviceKey: identity.deviceKey
906
695
  }, {
@@ -912,8 +701,8 @@ var IdentityManager = class {
912
701
  return identity;
913
702
  }
914
703
  async _constructIdentity(identityRecord) {
915
- assert4(!this._identity);
916
- log4("constructing identity", {
704
+ assert2(!this._identity);
705
+ log3("constructing identity", {
917
706
  identityRecord
918
707
  }, {
919
708
  file: "identity-manager.ts",
@@ -944,7 +733,7 @@ var IdentityManager = class {
944
733
  identityKey: identityRecord.identityKey,
945
734
  deviceKey: identityRecord.deviceKey
946
735
  });
947
- log4("done", {
736
+ log3("done", {
948
737
  identityKey: identityRecord.identityKey
949
738
  }, {
950
739
  file: "identity-manager.ts",
@@ -967,6 +756,54 @@ var IdentityManager = class {
967
756
  }
968
757
  };
969
758
 
759
+ // packages/sdk/client-services/src/packlets/identity/identity-service.ts
760
+ import assert3 from "@dxos/node-std/assert";
761
+ import { Stream as Stream6 } from "@dxos/codec-protobuf";
762
+ import { signPresentation } from "@dxos/credentials";
763
+ import { todo } from "@dxos/debug";
764
+ var IdentityServiceImpl = class {
765
+ // TODO(wittjosiah): Remove dependency on service context.
766
+ constructor(_serviceContext) {
767
+ this._serviceContext = _serviceContext;
768
+ }
769
+ async createIdentity(request) {
770
+ await this._serviceContext.createIdentity(request);
771
+ return this._getIdentity();
772
+ }
773
+ async recoverIdentity(request) {
774
+ return todo();
775
+ }
776
+ queryIdentity() {
777
+ return new Stream6(({ next }) => {
778
+ const emitNext = () => next({
779
+ identity: this._getIdentity()
780
+ });
781
+ emitNext();
782
+ return this._serviceContext.identityManager.stateUpdate.on(emitNext);
783
+ });
784
+ }
785
+ _getIdentity() {
786
+ if (!this._serviceContext.identityManager.identity) {
787
+ return void 0;
788
+ }
789
+ return {
790
+ identityKey: this._serviceContext.identityManager.identity.identityKey,
791
+ spaceKey: this._serviceContext.identityManager.identity.space.key,
792
+ profile: this._serviceContext.identityManager.identity.profileDocument
793
+ };
794
+ }
795
+ async signPresentation({ presentation, nonce }) {
796
+ assert3(this._serviceContext.identityManager.identity, "Identity not initialized.");
797
+ return await signPresentation({
798
+ presentation,
799
+ signer: this._serviceContext.keyring,
800
+ signerKey: this._serviceContext.identityManager.identity.deviceKey,
801
+ chain: this._serviceContext.identityManager.identity.deviceCredentialChain,
802
+ nonce
803
+ });
804
+ }
805
+ };
806
+
970
807
  // packages/sdk/client-services/src/packlets/invitations/encoder.ts
971
808
  import base from "base-x";
972
809
  import { schema as schema2 } from "@dxos/protocols";
@@ -982,7 +819,7 @@ var InvitationEncoder = class {
982
819
  };
983
820
 
984
821
  // packages/sdk/client-services/src/packlets/invitations/invitations.ts
985
- import assert5 from "@dxos/node-std/assert";
822
+ import assert4 from "@dxos/node-std/assert";
986
823
  import { CancellableObservableProvider } from "@dxos/async";
987
824
  import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
988
825
  var AUTHENTICATION_CODE_LENGTH = 6;
@@ -1010,7 +847,7 @@ var wrapObservable = async (observable) => {
1010
847
  return new Promise((resolve, reject) => {
1011
848
  const unsubscribe = observable.subscribe({
1012
849
  onSuccess: (invitation) => {
1013
- assert5(invitation.state === Invitation.State.SUCCESS);
850
+ assert4(invitation.state === Invitation.State.SUCCESS);
1014
851
  unsubscribe();
1015
852
  resolve(invitation);
1016
853
  },
@@ -1030,19 +867,19 @@ var AbstractInvitationsHandler = class {
1030
867
  }
1031
868
  };
1032
869
 
1033
- // packages/sdk/client-services/src/packlets/invitations/halo-invitations-handler.ts
1034
- import assert6 from "@dxos/node-std/assert";
870
+ // packages/sdk/client-services/src/packlets/invitations/device-invitations-handler.ts
871
+ import assert5 from "@dxos/node-std/assert";
1035
872
  import { scheduleTask, sleep, Trigger as Trigger2 } from "@dxos/async";
1036
873
  import { Context as Context3 } from "@dxos/context";
1037
874
  import { generatePasscode } from "@dxos/credentials";
1038
875
  import { PublicKey as PublicKey3 } from "@dxos/keys";
1039
- import { log as log5 } from "@dxos/log";
876
+ import { log as log4 } from "@dxos/log";
1040
877
  import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
1041
878
  import { schema as schema3 } from "@dxos/protocols";
1042
879
  import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
1043
880
  import { AuthenticationResponse } from "@dxos/protocols/proto/dxos/halo/invitations";
1044
881
  import { RpcExtension } from "@dxos/teleport";
1045
- var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
882
+ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
1046
883
  // prettier-ignore
1047
884
  constructor(_params) {
1048
885
  super(_params.networkManager);
@@ -1053,7 +890,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1053
890
  */
1054
891
  createInvitation(context, options) {
1055
892
  const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
1056
- assert6(type !== Invitation2.Type.OFFLINE);
893
+ assert5(type !== Invitation2.Type.OFFLINE);
1057
894
  const identity = this._params.getIdentity();
1058
895
  const invitation = {
1059
896
  type,
@@ -1075,10 +912,10 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1075
912
  const createExtension = () => new HostHaloInvitationExtension({
1076
913
  requestAdmission: async () => {
1077
914
  var _a, _b;
1078
- log5("responding with admission offer", {
915
+ log4("responding with admission offer", {
1079
916
  host: identity.deviceKey
1080
917
  }, {
1081
- file: "halo-invitations-handler.ts",
918
+ file: "device-invitations-handler.ts",
1082
919
  line: 91,
1083
920
  scope: this,
1084
921
  callSite: (f, a) => f(...a)
@@ -1091,10 +928,10 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1091
928
  };
1092
929
  },
1093
930
  authenticate: async ({ authenticationCode: code }) => {
1094
- log5("received authentication request", {
931
+ log4("received authentication request", {
1095
932
  authenticationCode: code
1096
933
  }, {
1097
- file: "halo-invitations-handler.ts",
934
+ file: "device-invitations-handler.ts",
1098
935
  line: 105,
1099
936
  scope: this,
1100
937
  callSite: (f, a) => f(...a)
@@ -1112,11 +949,11 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1112
949
  throw new Error(`invalid authentication code: ${authenticationCode}`);
1113
950
  }
1114
951
  }
1115
- log5("writing guest credentials", {
952
+ log4("writing guest credentials", {
1116
953
  host: identity.deviceKey,
1117
954
  guest: credentials.deviceKey
1118
955
  }, {
1119
- file: "halo-invitations-handler.ts",
956
+ file: "device-invitations-handler.ts",
1120
957
  line: 120,
1121
958
  scope: this,
1122
959
  callSite: (f, a) => f(...a)
@@ -1132,10 +969,10 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1132
969
  scheduleTask(ctx, async () => {
1133
970
  var _a, _b;
1134
971
  try {
1135
- log5("connected", {
972
+ log4("connected", {
1136
973
  host: identity.deviceKey
1137
974
  }, {
1138
- file: "halo-invitations-handler.ts",
975
+ file: "device-invitations-handler.ts",
1139
976
  line: 136,
1140
977
  scope: this,
1141
978
  callSite: (f, a) => f(...a)
@@ -1144,11 +981,11 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1144
981
  const deviceKey = await complete.wait({
1145
982
  timeout
1146
983
  });
1147
- log5("admitted guest", {
984
+ log4("admitted guest", {
1148
985
  host: identity.deviceKey,
1149
986
  guest: deviceKey
1150
987
  }, {
1151
- file: "halo-invitations-handler.ts",
988
+ file: "device-invitations-handler.ts",
1152
989
  line: 139,
1153
990
  scope: this,
1154
991
  callSite: (f, a) => f(...a)
@@ -1156,8 +993,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1156
993
  observable.callback.onSuccess(invitation);
1157
994
  } catch (err) {
1158
995
  if (!observable.cancelled) {
1159
- log5.error("failed", err, {
1160
- file: "halo-invitations-handler.ts",
996
+ log4.error("failed", err, {
997
+ file: "device-invitations-handler.ts",
1161
998
  line: 143,
1162
999
  scope: this,
1163
1000
  callSite: (f, a) => f(...a)
@@ -1221,23 +1058,23 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1221
1058
  if (++connectionCount > 1) {
1222
1059
  throw new Error(`multiple connections detected: ${connectionCount}`);
1223
1060
  }
1224
- log5("connected", {}, {
1225
- file: "halo-invitations-handler.ts",
1061
+ log4("connected", {}, {
1062
+ file: "device-invitations-handler.ts",
1226
1063
  line: 214,
1227
1064
  scope: this,
1228
1065
  callSite: (f, a) => f(...a)
1229
1066
  });
1230
1067
  (_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
1231
- log5("sending admission request", {}, {
1232
- file: "halo-invitations-handler.ts",
1068
+ log4("sending admission request", {}, {
1069
+ file: "device-invitations-handler.ts",
1233
1070
  line: 218,
1234
1071
  scope: this,
1235
1072
  callSite: (f, a) => f(...a)
1236
1073
  });
1237
1074
  const { identityKey, haloSpaceKey, genesisFeedKey } = await extension.rpc.HaloHostService.requestAdmission();
1238
1075
  if (invitation.type === void 0 || invitation.type === Invitation2.Type.INTERACTIVE) {
1239
- log5("guest waiting for authentication code...", {}, {
1240
- file: "halo-invitations-handler.ts",
1076
+ log4("guest waiting for authentication code...", {}, {
1077
+ file: "device-invitations-handler.ts",
1241
1078
  line: 225,
1242
1079
  scope: this,
1243
1080
  callSite: (f, a) => f(...a)
@@ -1246,8 +1083,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1246
1083
  const authenticationCode = await authenticated.wait({
1247
1084
  timeout
1248
1085
  });
1249
- log5("sending authentication request", {}, {
1250
- file: "halo-invitations-handler.ts",
1086
+ log4("sending authentication request", {}, {
1087
+ file: "device-invitations-handler.ts",
1251
1088
  line: 228,
1252
1089
  scope: this,
1253
1090
  callSite: (f, a) => f(...a)
@@ -1259,13 +1096,13 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1259
1096
  const deviceKey = await this._params.keyring.createKey();
1260
1097
  const controlFeedKey = await this._params.keyring.createKey();
1261
1098
  const dataFeedKey = await this._params.keyring.createKey();
1262
- log5("presenting admission credentials", {
1099
+ log4("presenting admission credentials", {
1263
1100
  identityKey,
1264
1101
  deviceKey,
1265
1102
  controlFeedKey,
1266
1103
  dataFeedKey
1267
1104
  }, {
1268
- file: "halo-invitations-handler.ts",
1105
+ file: "device-invitations-handler.ts",
1269
1106
  line: 237,
1270
1107
  scope: this,
1271
1108
  callSite: (f, a) => f(...a)
@@ -1283,11 +1120,11 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1283
1120
  controlFeedKey,
1284
1121
  dataFeedKey
1285
1122
  });
1286
- log5("admitted by host", {
1123
+ log4("admitted by host", {
1287
1124
  guest: identity.deviceKey,
1288
1125
  identityKey
1289
1126
  }, {
1290
- file: "halo-invitations-handler.ts",
1127
+ file: "device-invitations-handler.ts",
1291
1128
  line: 256,
1292
1129
  scope: this,
1293
1130
  callSite: (f, a) => f(...a)
@@ -1295,8 +1132,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1295
1132
  complete.wake(identityKey);
1296
1133
  } catch (err) {
1297
1134
  if (!observable.cancelled) {
1298
- log5.warn("auth failed", err, {
1299
- file: "halo-invitations-handler.ts",
1135
+ log4.warn("auth failed", err, {
1136
+ file: "device-invitations-handler.ts",
1300
1137
  line: 260,
1301
1138
  scope: this,
1302
1139
  callSite: (f, a) => f(...a)
@@ -1313,7 +1150,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
1313
1150
  };
1314
1151
  scheduleTask(ctx, async () => {
1315
1152
  var _a, _b;
1316
- assert6(invitation.swarmKey);
1153
+ assert5(invitation.swarmKey);
1317
1154
  const topic = invitation.swarmKey;
1318
1155
  const swarmConnection = await this._networkManager.joinSwarm({
1319
1156
  topic,
@@ -1383,9 +1220,9 @@ var GuestHaloInvitationExtension = class extends RpcExtension {
1383
1220
  };
1384
1221
 
1385
1222
  // packages/sdk/client-services/src/packlets/invitations/invitations-proxy.ts
1386
- import assert7 from "@dxos/node-std/assert";
1223
+ import assert6 from "@dxos/node-std/assert";
1387
1224
  import { observableError } from "@dxos/async";
1388
- import { log as log6 } from "@dxos/log";
1225
+ import { log as log5 } from "@dxos/log";
1389
1226
  import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
1390
1227
  var AbstractInvitationsProxy = class {
1391
1228
  // prettier-ignore
@@ -1411,7 +1248,7 @@ var AbstractInvitationsProxy = class {
1411
1248
  observable.setInvitation(invitation2);
1412
1249
  switch (invitation2.state) {
1413
1250
  case Invitation3.State.CONNECTING: {
1414
- assert7(invitation2.invitationId);
1251
+ assert6(invitation2.invitationId);
1415
1252
  invitationId = invitation2.invitationId;
1416
1253
  (_b = (_a = observable.callback).onConnecting) == null ? void 0 : _b.call(_a, invitation2);
1417
1254
  break;
@@ -1433,7 +1270,7 @@ var AbstractInvitationsProxy = class {
1433
1270
  break;
1434
1271
  }
1435
1272
  default: {
1436
- log6.error(`Invalid state: ${invitation2.state}`, {}, {
1273
+ log5.error(`Invalid state: ${invitation2.state}`, {}, {
1437
1274
  file: "invitations-proxy.ts",
1438
1275
  line: 81,
1439
1276
  scope: this,
@@ -1449,12 +1286,12 @@ var AbstractInvitationsProxy = class {
1449
1286
  return observable;
1450
1287
  }
1451
1288
  acceptInvitation(invitation, options) {
1452
- assert7(invitation && invitation.swarmKey);
1289
+ assert6(invitation && invitation.swarmKey);
1453
1290
  const observable = new AuthenticatingInvitationProvider({
1454
1291
  onCancel: async () => {
1455
1292
  var _a;
1456
1293
  const invitationId = (_a = observable.invitation) == null ? void 0 : _a.invitationId;
1457
- assert7(invitationId);
1294
+ assert6(invitationId);
1458
1295
  await this._invitationsService.cancelInvitation({
1459
1296
  invitationId
1460
1297
  });
@@ -1462,7 +1299,7 @@ var AbstractInvitationsProxy = class {
1462
1299
  onAuthenticate: async (authenticationCode) => {
1463
1300
  var _a;
1464
1301
  const invitationId = (_a = observable.invitation) == null ? void 0 : _a.invitationId;
1465
- assert7(invitationId);
1302
+ assert6(invitationId);
1466
1303
  await this._invitationsService.authenticate({
1467
1304
  invitationId,
1468
1305
  authenticationCode
@@ -1475,7 +1312,7 @@ var AbstractInvitationsProxy = class {
1475
1312
  });
1476
1313
  stream.subscribe((invitation2) => {
1477
1314
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1478
- assert7(invitation2.invitationId);
1315
+ assert6(invitation2.invitationId);
1479
1316
  observable.setInvitation(invitation2);
1480
1317
  switch (invitation2.state) {
1481
1318
  case Invitation3.State.CONNECTING: {
@@ -1499,7 +1336,7 @@ var AbstractInvitationsProxy = class {
1499
1336
  break;
1500
1337
  }
1501
1338
  default: {
1502
- log6.error(`Invalid state: ${invitation2.state}`, {}, {
1339
+ log5.error(`Invalid state: ${invitation2.state}`, {}, {
1503
1340
  file: "invitations-proxy.ts",
1504
1341
  line: 146,
1505
1342
  scope: this,
@@ -1516,17 +1353,17 @@ var AbstractInvitationsProxy = class {
1516
1353
  }
1517
1354
  };
1518
1355
 
1519
- // packages/sdk/client-services/src/packlets/invitations/halo-invitations-proxy.ts
1520
- var HaloInvitationsProxy = class extends AbstractInvitationsProxy {
1356
+ // packages/sdk/client-services/src/packlets/invitations/device-invitations-proxy.ts
1357
+ var DeviceInvitationsProxy = class extends AbstractInvitationsProxy {
1521
1358
  getInvitationOptions() {
1522
1359
  return {};
1523
1360
  }
1524
1361
  };
1525
1362
 
1526
1363
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1527
- import assert8 from "@dxos/node-std/assert";
1528
- import { Stream as Stream8 } from "@dxos/codec-protobuf";
1529
- import { log as log7 } from "@dxos/log";
1364
+ import assert7 from "@dxos/node-std/assert";
1365
+ import { Stream as Stream7 } from "@dxos/codec-protobuf";
1366
+ import { log as log6 } from "@dxos/log";
1530
1367
  import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
1531
1368
  var AbstractInvitationsService = class {
1532
1369
  // prettier-ignore
@@ -1544,47 +1381,48 @@ var AbstractInvitationsService = class {
1544
1381
  };
1545
1382
  }
1546
1383
  createInvitation(invitation) {
1547
- return new Stream8(({ next, close }) => {
1384
+ return new Stream7(({ next, close }) => {
1548
1385
  const invitationsHandler = this._getInvitationsHandler();
1549
1386
  const context = this.getContext(invitation);
1550
- log7("stream opened", this.getLoggingContext(), {
1387
+ log6("stream opened", this.getLoggingContext(), {
1551
1388
  file: "invitations-service.ts",
1552
1389
  line: 43,
1553
1390
  scope: this,
1554
1391
  callSite: (f, a) => f(...a)
1555
1392
  });
1556
1393
  let invitationId;
1557
- const { type, swarmKey } = invitation;
1394
+ const { type, swarmKey, authMethod } = invitation;
1558
1395
  const observable = invitationsHandler.createInvitation(context, {
1559
1396
  type,
1560
- swarmKey
1397
+ swarmKey,
1398
+ authMethod
1561
1399
  });
1562
1400
  observable.subscribe({
1563
1401
  onConnecting: (invitation2) => {
1564
- assert8(invitation2.invitationId);
1402
+ assert7(invitation2.invitationId);
1565
1403
  invitationId = invitation2.invitationId;
1566
1404
  this._createInvitations.set(invitation2.invitationId, observable);
1567
1405
  invitation2.state = Invitation4.State.CONNECTING;
1568
1406
  next(invitation2);
1569
1407
  },
1570
1408
  onConnected: (invitation2) => {
1571
- assert8(invitation2.invitationId);
1409
+ assert7(invitation2.invitationId);
1572
1410
  invitation2.state = Invitation4.State.CONNECTED;
1573
1411
  next(invitation2);
1574
1412
  },
1575
1413
  onAuthenticating: (invitation2) => {
1576
- assert8(invitation2.invitationId);
1414
+ assert7(invitation2.invitationId);
1577
1415
  invitation2.state = Invitation4.State.AUTHENTICATING;
1578
1416
  next(invitation2);
1579
1417
  },
1580
1418
  onSuccess: (invitation2) => {
1581
- assert8(invitation2.invitationId);
1419
+ assert7(invitation2.invitationId);
1582
1420
  invitation2.state = Invitation4.State.SUCCESS;
1583
1421
  next(invitation2);
1584
1422
  close();
1585
1423
  },
1586
1424
  onCancelled: () => {
1587
- assert8(invitationId);
1425
+ assert7(invitationId);
1588
1426
  invitation.invitationId = invitationId;
1589
1427
  invitation.state = Invitation4.State.CANCELLED;
1590
1428
  next(invitation);
@@ -1602,7 +1440,7 @@ var AbstractInvitationsService = class {
1602
1440
  return (err) => {
1603
1441
  const context2 = this.getLoggingContext();
1604
1442
  if (err) {
1605
- log7.warn("stream closed", {
1443
+ log6.warn("stream closed", {
1606
1444
  ...context2,
1607
1445
  err
1608
1446
  }, {
@@ -1612,7 +1450,7 @@ var AbstractInvitationsService = class {
1612
1450
  callSite: (f, a) => f(...a)
1613
1451
  });
1614
1452
  } else {
1615
- log7("stream closed", context2, {
1453
+ log6("stream closed", context2, {
1616
1454
  file: "invitations-service.ts",
1617
1455
  line: 94,
1618
1456
  scope: this,
@@ -1624,8 +1462,8 @@ var AbstractInvitationsService = class {
1624
1462
  });
1625
1463
  }
1626
1464
  acceptInvitation(invitation, options) {
1627
- return new Stream8(({ next, close }) => {
1628
- log7("stream opened", this.getLoggingContext(), {
1465
+ return new Stream7(({ next, close }) => {
1466
+ log6("stream opened", this.getLoggingContext(), {
1629
1467
  file: "invitations-service.ts",
1630
1468
  line: 104,
1631
1469
  scope: this,
@@ -1636,19 +1474,19 @@ var AbstractInvitationsService = class {
1636
1474
  const observable = invitationsHandler.acceptInvitation(invitation, options);
1637
1475
  observable.subscribe({
1638
1476
  onConnecting: (invitation2) => {
1639
- assert8(invitation2.invitationId);
1477
+ assert7(invitation2.invitationId);
1640
1478
  invitationId = invitation2.invitationId;
1641
1479
  this._acceptInvitations.set(invitation2.invitationId, observable);
1642
1480
  invitation2.state = Invitation4.State.CONNECTING;
1643
1481
  next(invitation2);
1644
1482
  },
1645
1483
  onConnected: (invitation2) => {
1646
- assert8(invitation2.invitationId);
1484
+ assert7(invitation2.invitationId);
1647
1485
  invitation2.state = Invitation4.State.CONNECTED;
1648
1486
  next(invitation2);
1649
1487
  },
1650
1488
  onAuthenticating: (invitation2) => {
1651
- assert8(invitation2.invitationId);
1489
+ assert7(invitation2.invitationId);
1652
1490
  invitation2.state = Invitation4.State.AUTHENTICATING;
1653
1491
  next(invitation2);
1654
1492
  },
@@ -1658,7 +1496,7 @@ var AbstractInvitationsService = class {
1658
1496
  close();
1659
1497
  },
1660
1498
  onCancelled: () => {
1661
- assert8(invitationId);
1499
+ assert7(invitationId);
1662
1500
  invitation.invitationId = invitationId;
1663
1501
  invitation.state = Invitation4.State.CANCELLED;
1664
1502
  next(invitation);
@@ -1676,7 +1514,7 @@ var AbstractInvitationsService = class {
1676
1514
  return (err) => {
1677
1515
  const context = this.getLoggingContext();
1678
1516
  if (err) {
1679
- log7.warn("stream closed", {
1517
+ log6.warn("stream closed", {
1680
1518
  ...context,
1681
1519
  err
1682
1520
  }, {
@@ -1686,7 +1524,7 @@ var AbstractInvitationsService = class {
1686
1524
  callSite: (f, a) => f(...a)
1687
1525
  });
1688
1526
  } else {
1689
- log7("stream closed", context, {
1527
+ log6("stream closed", context, {
1690
1528
  file: "invitations-service.ts",
1691
1529
  line: 154,
1692
1530
  scope: this,
@@ -1698,16 +1536,16 @@ var AbstractInvitationsService = class {
1698
1536
  });
1699
1537
  }
1700
1538
  async authenticate({ invitationId, authenticationCode }) {
1701
- log7("authenticating...", {}, {
1539
+ log6("authenticating...", {}, {
1702
1540
  file: "invitations-service.ts",
1703
1541
  line: 163,
1704
1542
  scope: this,
1705
1543
  callSite: (f, a) => f(...a)
1706
1544
  });
1707
- assert8(invitationId);
1545
+ assert7(invitationId);
1708
1546
  const observable = this._acceptInvitations.get(invitationId);
1709
1547
  if (!observable) {
1710
- log7.warn("invalid invitation", {
1548
+ log6.warn("invalid invitation", {
1711
1549
  invitationId
1712
1550
  }, {
1713
1551
  file: "invitations-service.ts",
@@ -1721,16 +1559,16 @@ var AbstractInvitationsService = class {
1721
1559
  }
1722
1560
  async cancelInvitation(invitation) {
1723
1561
  var _a;
1724
- log7("cancelling...", {}, {
1562
+ log6("cancelling...", {}, {
1725
1563
  file: "invitations-service.ts",
1726
1564
  line: 174,
1727
1565
  scope: this,
1728
1566
  callSite: (f, a) => f(...a)
1729
1567
  });
1730
- assert8(invitation.invitationId);
1568
+ assert7(invitation.invitationId);
1731
1569
  const observable = (_a = this._createInvitations.get(invitation.invitationId)) != null ? _a : this._acceptInvitations.get(invitation.invitationId);
1732
1570
  if (!observable) {
1733
- log7.warn("invalid invitation", {
1571
+ log6.warn("invalid invitation", {
1734
1572
  invitationId: invitation.invitationId
1735
1573
  }, {
1736
1574
  file: "invitations-service.ts",
@@ -1744,8 +1582,8 @@ var AbstractInvitationsService = class {
1744
1582
  }
1745
1583
  };
1746
1584
 
1747
- // packages/sdk/client-services/src/packlets/invitations/halo-invitations-service.ts
1748
- var HaloInvitationsServiceImpl = class extends AbstractInvitationsService {
1585
+ // packages/sdk/client-services/src/packlets/invitations/device-invitations-service.ts
1586
+ var DeviceInvitationsServiceImpl = class extends AbstractInvitationsService {
1749
1587
  // prettier-ignore
1750
1588
  constructor(identityManager, invitationsHandler) {
1751
1589
  super(identityManager, () => invitationsHandler);
@@ -1756,17 +1594,17 @@ var HaloInvitationsServiceImpl = class extends AbstractInvitationsService {
1756
1594
  };
1757
1595
 
1758
1596
  // packages/sdk/client-services/src/packlets/invitations/space-invitations-handler.ts
1759
- import assert9 from "@dxos/node-std/assert";
1597
+ import assert8 from "@dxos/node-std/assert";
1760
1598
  import { scheduleTask as scheduleTask2, sleep as sleep2, Trigger as Trigger3 } from "@dxos/async";
1761
1599
  import { Context as Context4 } from "@dxos/context";
1762
1600
  import { createAdmissionCredentials, generatePasscode as generatePasscode2, getCredentialAssertion } from "@dxos/credentials";
1763
1601
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
1764
1602
  import { PublicKey as PublicKey4 } from "@dxos/keys";
1765
- import { log as log8 } from "@dxos/log";
1603
+ import { log as log7 } from "@dxos/log";
1766
1604
  import { createTeleportProtocolFactory as createTeleportProtocolFactory2, StarTopology as StarTopology2 } from "@dxos/network-manager";
1767
1605
  import { schema as schema4 } from "@dxos/protocols";
1768
1606
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
1769
- import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
1607
+ import { AuthenticationResponse as AuthenticationResponse2, AuthMethod } from "@dxos/protocols/proto/dxos/halo/invitations";
1770
1608
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
1771
1609
  var MAX_OTP_ATTEMPTS = 3;
1772
1610
  var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
@@ -1780,16 +1618,19 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1780
1618
  * Creates an invitation and listens for a join request from the invited (guest) peer.
1781
1619
  */
1782
1620
  createInvitation(space, options) {
1621
+ var _a;
1783
1622
  let swarmConnection;
1784
1623
  const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
1785
- assert9(type !== Invitation5.Type.OFFLINE);
1786
- assert9(space);
1624
+ assert8(type !== Invitation5.Type.OFFLINE);
1625
+ assert8(space);
1787
1626
  const invitation = {
1788
1627
  type,
1789
1628
  invitationId: PublicKey4.random().toHex(),
1790
1629
  swarmKey: swarmKey != null ? swarmKey : PublicKey4.random(),
1791
1630
  spaceKey: space.key,
1631
+ authMethod: (_a = options == null ? void 0 : options.authMethod) != null ? _a : AuthMethod.SHARED_SECRET,
1792
1632
  authenticationCode: generatePasscode2(AUTHENTICATION_CODE_LENGTH)
1633
+ // TODO(dmaretskyi): Don't generate if authMethod === NONE .
1793
1634
  };
1794
1635
  const ctx = new Context4({
1795
1636
  onError: (err) => {
@@ -1800,44 +1641,76 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1800
1641
  const observable = new InvitationObservableProvider(async () => {
1801
1642
  await (swarmConnection == null ? void 0 : swarmConnection.close());
1802
1643
  });
1803
- let authenticationCode;
1644
+ let authenticationPassed = false;
1804
1645
  let authenticationRetry = 0;
1805
1646
  const createExtension = () => {
1806
1647
  const complete = new Trigger3();
1807
1648
  let guestProfile;
1808
1649
  const hostInvitationExtension = new HostSpaceInvitationExtension({
1809
1650
  introduce: async ({ profile }) => {
1810
- var _a, _b;
1811
- log8("guest introduced itself", {
1651
+ var _a2, _b;
1652
+ log7("guest introduced itself", {
1812
1653
  guestProfile: profile,
1813
1654
  host: this._signingContext.deviceKey,
1814
1655
  spaceKey: space.key
1815
1656
  }, {
1816
1657
  file: "space-invitations-handler.ts",
1817
- line: 98,
1658
+ line: 101,
1818
1659
  scope: this,
1819
1660
  callSite: (f, a) => f(...a)
1820
1661
  });
1821
1662
  guestProfile = profile;
1822
- (_b = (_a = observable.callback).onAuthenticating) == null ? void 0 : _b.call(_a, invitation);
1663
+ (_b = (_a2 = observable.callback).onAuthenticating) == null ? void 0 : _b.call(_a2, invitation);
1664
+ return {
1665
+ spaceKey: type === Invitation5.Type.INTERACTIVE_TESTING || type === Invitation5.Type.MULTIUSE_TESTING ? space.key : void 0,
1666
+ authMethod: invitation.authMethod
1667
+ };
1823
1668
  },
1824
1669
  authenticate: async ({ authenticationCode: code }) => {
1825
- log8("received authentication request", {
1670
+ log7("received authentication request", {
1826
1671
  authenticationCode: code
1827
1672
  }, {
1828
1673
  file: "space-invitations-handler.ts",
1829
- line: 112,
1674
+ line: 123,
1830
1675
  scope: this,
1831
1676
  callSite: (f, a) => f(...a)
1832
1677
  });
1833
1678
  let status = AuthenticationResponse2.Status.OK;
1834
- if (invitation.authenticationCode) {
1835
- if (authenticationRetry++ > MAX_OTP_ATTEMPTS) {
1836
- status = AuthenticationResponse2.Status.INVALID_OPT_ATTEMPTS;
1837
- } else if (code !== invitation.authenticationCode) {
1838
- status = AuthenticationResponse2.Status.INVALID_OTP;
1839
- } else {
1840
- authenticationCode = code;
1679
+ switch (invitation.authMethod) {
1680
+ case AuthMethod.NONE: {
1681
+ log7("authentication not required", {}, {
1682
+ file: "space-invitations-handler.ts",
1683
+ line: 128,
1684
+ scope: this,
1685
+ callSite: (f, a) => f(...a)
1686
+ });
1687
+ return {
1688
+ status: AuthenticationResponse2.Status.OK
1689
+ };
1690
+ }
1691
+ case AuthMethod.SHARED_SECRET: {
1692
+ if (invitation.authenticationCode) {
1693
+ if (authenticationRetry++ > MAX_OTP_ATTEMPTS) {
1694
+ status = AuthenticationResponse2.Status.INVALID_OPT_ATTEMPTS;
1695
+ } else if (code !== invitation.authenticationCode) {
1696
+ status = AuthenticationResponse2.Status.INVALID_OTP;
1697
+ } else {
1698
+ authenticationPassed = true;
1699
+ }
1700
+ }
1701
+ break;
1702
+ }
1703
+ default: {
1704
+ log7.error("invalid authentication method", {
1705
+ authMethod: invitation.authMethod
1706
+ }, {
1707
+ file: "space-invitations-handler.ts",
1708
+ line: 144,
1709
+ scope: this,
1710
+ callSite: (f, a) => f(...a)
1711
+ });
1712
+ status = AuthenticationResponse2.Status.INTERNAL_ERROR;
1713
+ break;
1841
1714
  }
1842
1715
  }
1843
1716
  return {
@@ -1846,24 +1719,22 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1846
1719
  },
1847
1720
  requestAdmission: async ({ identityKey, deviceKey, controlFeedKey, dataFeedKey }) => {
1848
1721
  try {
1849
- if (invitation.type !== Invitation5.Type.INTERACTIVE_TESTING && invitation.type !== Invitation5.Type.MULTIUSE_TESTING) {
1850
- if (invitation.authenticationCode === void 0 || invitation.authenticationCode !== authenticationCode) {
1851
- throw new Error(`invalid authentication code: ${authenticationCode}`);
1852
- }
1722
+ if (isAuthenticationRequired(invitation) && !authenticationPassed) {
1723
+ throw new Error("Not authenticated");
1853
1724
  }
1854
- log8("writing guest credentials", {
1725
+ log7("writing guest credentials", {
1855
1726
  host: this._signingContext.deviceKey,
1856
1727
  guest: deviceKey
1857
1728
  }, {
1858
1729
  file: "space-invitations-handler.ts",
1859
- line: 139,
1730
+ line: 160,
1860
1731
  scope: this,
1861
1732
  callSite: (f, a) => f(...a)
1862
1733
  });
1863
1734
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
1864
- assert9(credentials[0].credential);
1735
+ assert8(credentials[0].credential);
1865
1736
  const spaceMemberCredential = credentials[0].credential.credential;
1866
- assert9(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
1737
+ assert8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
1867
1738
  await writeMessages2(space.inner.controlPipeline.writer, credentials);
1868
1739
  complete.wake(deviceKey);
1869
1740
  return {
@@ -1876,35 +1747,35 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1876
1747
  },
1877
1748
  onOpen: () => {
1878
1749
  scheduleTask2(ctx, async () => {
1879
- var _a, _b;
1750
+ var _a2, _b;
1880
1751
  try {
1881
- log8("connected", {
1752
+ log7("connected", {
1882
1753
  host: this._signingContext.deviceKey
1883
1754
  }, {
1884
1755
  file: "space-invitations-handler.ts",
1885
- line: 170,
1756
+ line: 191,
1886
1757
  scope: this,
1887
1758
  callSite: (f, a) => f(...a)
1888
1759
  });
1889
- (_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
1760
+ (_b = (_a2 = observable.callback).onConnected) == null ? void 0 : _b.call(_a2, invitation);
1890
1761
  const deviceKey = await complete.wait({
1891
1762
  timeout
1892
1763
  });
1893
- log8("admitted guest", {
1764
+ log7("admitted guest", {
1894
1765
  host: this._signingContext.deviceKey,
1895
1766
  guest: deviceKey
1896
1767
  }, {
1897
1768
  file: "space-invitations-handler.ts",
1898
- line: 173,
1769
+ line: 194,
1899
1770
  scope: this,
1900
1771
  callSite: (f, a) => f(...a)
1901
1772
  });
1902
1773
  observable.callback.onSuccess(invitation);
1903
1774
  } catch (err) {
1904
1775
  if (!observable.cancelled) {
1905
- log8.error("failed", err, {
1776
+ log7.error("failed", err, {
1906
1777
  file: "space-invitations-handler.ts",
1907
- line: 177,
1778
+ line: 198,
1908
1779
  scope: this,
1909
1780
  callSite: (f, a) => f(...a)
1910
1781
  });
@@ -1922,7 +1793,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1922
1793
  return hostInvitationExtension;
1923
1794
  };
1924
1795
  scheduleTask2(ctx, async () => {
1925
- var _a, _b;
1796
+ var _a2, _b;
1926
1797
  const topic = invitation.swarmKey;
1927
1798
  const swarmConnection2 = await this._networkManager.joinSwarm({
1928
1799
  topic,
@@ -1933,7 +1804,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1933
1804
  topology: new StarTopology2(topic)
1934
1805
  });
1935
1806
  ctx.onDispose(() => swarmConnection2.close());
1936
- (_b = (_a = observable.callback).onConnecting) == null ? void 0 : _b.call(_a, invitation);
1807
+ (_b = (_a2 = observable.callback).onConnecting) == null ? void 0 : _b.call(_a2, invitation);
1937
1808
  });
1938
1809
  return observable;
1939
1810
  }
@@ -1965,46 +1836,60 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
1965
1836
  const extension = new GuestSpaceInvitationExtension({
1966
1837
  onOpen: () => {
1967
1838
  scheduleTask2(ctx, async () => {
1968
- var _a, _b, _c, _d;
1839
+ var _a, _b, _c, _d, _e, _f;
1969
1840
  try {
1970
1841
  if (++connectionCount > 1) {
1971
1842
  throw new Error(`multiple connections detected: ${connectionCount}`);
1972
1843
  }
1973
- log8("connected", {
1844
+ log7("connected", {
1974
1845
  guest: this._signingContext.deviceKey
1975
1846
  }, {
1976
1847
  file: "space-invitations-handler.ts",
1977
- line: 250,
1848
+ line: 271,
1978
1849
  scope: this,
1979
1850
  callSite: (f, a) => f(...a)
1980
1851
  });
1981
1852
  (_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
1982
- log8("introduce", {
1853
+ log7("introduce", {
1983
1854
  guest: this._signingContext.deviceKey
1984
1855
  }, {
1985
1856
  file: "space-invitations-handler.ts",
1986
- line: 254,
1857
+ line: 275,
1987
1858
  scope: this,
1988
1859
  callSite: (f, a) => f(...a)
1989
1860
  });
1990
- await extension.rpc.SpaceHostService.introduce({
1861
+ const introductionResponse = await extension.rpc.SpaceHostService.introduce({
1991
1862
  profile: this._signingContext.profile
1992
1863
  });
1993
- if (invitation.type === void 0 || invitation.type === Invitation5.Type.INTERACTIVE) {
1864
+ log7("introduce response", {
1865
+ guest: this._signingContext.deviceKey,
1866
+ response: introductionResponse
1867
+ }, {
1868
+ file: "space-invitations-handler.ts",
1869
+ line: 279,
1870
+ scope: this,
1871
+ callSite: (f, a) => f(...a)
1872
+ });
1873
+ invitation.authMethod = introductionResponse.authMethod;
1874
+ if (introductionResponse.spaceKey) {
1875
+ invitation.spaceKey = introductionResponse.spaceKey;
1876
+ }
1877
+ if (isAuthenticationRequired(invitation)) {
1878
+ (_d = (_c = observable.callback).onAuthenticating) == null ? void 0 : _d.call(_c, invitation);
1994
1879
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1995
- log8("guest waiting for authentication code...", {}, {
1880
+ log7("guest waiting for authentication code...", {}, {
1996
1881
  file: "space-invitations-handler.ts",
1997
- line: 263,
1882
+ line: 293,
1998
1883
  scope: this,
1999
1884
  callSite: (f, a) => f(...a)
2000
1885
  });
2001
- (_d = (_c = observable.callback).onAuthenticating) == null ? void 0 : _d.call(_c, invitation);
1886
+ (_f = (_e = observable.callback).onAuthenticating) == null ? void 0 : _f.call(_e, invitation);
2002
1887
  const authenticationCode = await authenticated.wait({
2003
1888
  timeout
2004
1889
  });
2005
- log8("sending authentication request", {}, {
1890
+ log7("sending authentication request", {}, {
2006
1891
  file: "space-invitations-handler.ts",
2007
- line: 267,
1892
+ line: 297,
2008
1893
  scope: this,
2009
1894
  callSite: (f, a) => f(...a)
2010
1895
  });
@@ -2018,11 +1903,11 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2018
1903
  if (attempt === MAX_OTP_ATTEMPTS) {
2019
1904
  throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2020
1905
  } else {
2021
- log8("retrying invalid code", {
1906
+ log7("retrying invalid code", {
2022
1907
  attempt
2023
1908
  }, {
2024
1909
  file: "space-invitations-handler.ts",
2025
- line: 277,
1910
+ line: 307,
2026
1911
  scope: this,
2027
1912
  callSite: (f, a) => f(...a)
2028
1913
  });
@@ -2033,11 +1918,11 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2033
1918
  }
2034
1919
  const controlFeedKey = await this._keyring.createKey();
2035
1920
  const dataFeedKey = await this._keyring.createKey();
2036
- log8("request admission", {
1921
+ log7("request admission", {
2037
1922
  guest: this._signingContext.deviceKey
2038
1923
  }, {
2039
1924
  file: "space-invitations-handler.ts",
2040
- line: 288,
1925
+ line: 318,
2041
1926
  scope: this,
2042
1927
  callSite: (f, a) => f(...a)
2043
1928
  });
@@ -2048,28 +1933,28 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2048
1933
  dataFeedKey
2049
1934
  });
2050
1935
  const assertion = getCredentialAssertion(credential);
2051
- assert9(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2052
- assert9(credential.subject.id.equals(this._signingContext.identityKey));
1936
+ assert8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
1937
+ assert8(credential.subject.id.equals(this._signingContext.identityKey));
2053
1938
  const space = await this._spaceManager.acceptSpace({
2054
1939
  spaceKey: assertion.spaceKey,
2055
1940
  genesisFeedKey: assertion.genesisFeedKey
2056
1941
  });
2057
1942
  await this._signingContext.recordCredential(credential);
2058
- log8("admitted by host", {
1943
+ log7("admitted by host", {
2059
1944
  guest: this._signingContext.deviceKey,
2060
1945
  spaceKey: space.key
2061
1946
  }, {
2062
1947
  file: "space-invitations-handler.ts",
2063
- line: 310,
1948
+ line: 340,
2064
1949
  scope: this,
2065
1950
  callSite: (f, a) => f(...a)
2066
1951
  });
2067
1952
  complete.wake();
2068
1953
  } catch (err) {
2069
1954
  if (!observable.cancelled) {
2070
- log8.warn("auth failed", err, {
1955
+ log7.warn("auth failed", err, {
2071
1956
  file: "space-invitations-handler.ts",
2072
- line: 314,
1957
+ line: 344,
2073
1958
  scope: this,
2074
1959
  callSite: (f, a) => f(...a)
2075
1960
  });
@@ -2085,7 +1970,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2085
1970
  };
2086
1971
  scheduleTask2(ctx, async () => {
2087
1972
  var _a, _b;
2088
- assert9(invitation.swarmKey);
1973
+ assert8(invitation.swarmKey);
2089
1974
  const topic = invitation.swarmKey;
2090
1975
  const swarmConnection = await this._networkManager.joinSwarm({
2091
1976
  topic,
@@ -2104,6 +1989,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
2104
1989
  return observable;
2105
1990
  }
2106
1991
  };
1992
+ var isAuthenticationRequired = (invitation) => invitation.authMethod !== AuthMethod.NONE && invitation.type !== Invitation5.Type.INTERACTIVE_TESTING && invitation.type !== Invitation5.Type.MULTIUSE_TESTING;
2107
1993
  var HostSpaceInvitationExtension = class extends RpcExtension2 {
2108
1994
  constructor(_callbacks) {
2109
1995
  super({
@@ -2163,7 +2049,7 @@ var SpaceInvitationsProxy = class extends AbstractInvitationsProxy {
2163
2049
  };
2164
2050
 
2165
2051
  // packages/sdk/client-services/src/packlets/invitations/space-invitations-service.ts
2166
- import assert10 from "@dxos/node-std/assert";
2052
+ import assert9 from "@dxos/node-std/assert";
2167
2053
  var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
2168
2054
  // prettier-ignore
2169
2055
  constructor(identityManager, invitationsHandler, _getSpaceManager) {
@@ -2172,10 +2058,10 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
2172
2058
  this._getSpaceManager = _getSpaceManager;
2173
2059
  }
2174
2060
  getContext(invitation) {
2175
- assert10(invitation.spaceKey);
2061
+ assert9(invitation.spaceKey);
2176
2062
  const spaceManager = this._getSpaceManager();
2177
2063
  const space = spaceManager.spaces.get(invitation.spaceKey);
2178
- assert10(space);
2064
+ assert9(space);
2179
2065
  return space;
2180
2066
  }
2181
2067
  };
@@ -2184,19 +2070,19 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
2184
2070
  import { Trigger as Trigger5 } from "@dxos/async";
2185
2071
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2186
2072
  import { failUndefined as failUndefined2 } from "@dxos/debug";
2187
- import { valueEncoding, DataServiceSubscriptions, MetadataStore, SpaceManager, SnapshotStore } from "@dxos/echo-db";
2073
+ import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
2188
2074
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
2189
2075
  import { Keyring } from "@dxos/keyring";
2190
- import { log as log11 } from "@dxos/log";
2076
+ import { log as log10 } from "@dxos/log";
2191
2077
 
2192
2078
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2193
- import assert12 from "@dxos/node-std/assert";
2079
+ import assert11 from "@dxos/node-std/assert";
2194
2080
  import { Event as Event4, synchronized, trackLeaks as trackLeaks2 } from "@dxos/async";
2195
2081
  import { Context as Context7 } from "@dxos/context";
2196
2082
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
2197
- import { spaceGenesis, SnapshotManager } from "@dxos/echo-db";
2083
+ import { spaceGenesis, SnapshotManager } from "@dxos/echo-pipeline";
2198
2084
  import { PublicKey as PublicKey7 } from "@dxos/keys";
2199
- import { log as log10 } from "@dxos/log";
2085
+ import { log as log9 } from "@dxos/log";
2200
2086
  import { Presence } from "@dxos/teleport-extension-presence";
2201
2087
  import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxos/util";
2202
2088
 
@@ -2204,17 +2090,17 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
2204
2090
  import { trackLeaks } from "@dxos/async";
2205
2091
  import { Context as Context6 } from "@dxos/context";
2206
2092
  import { timed } from "@dxos/debug";
2207
- import { DataPipelineControllerImpl, createMappedFeedWriter } from "@dxos/echo-db";
2093
+ import { DataPipelineControllerImpl, createMappedFeedWriter } from "@dxos/echo-pipeline";
2208
2094
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2209
2095
  import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
2210
2096
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
2211
2097
 
2212
2098
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2213
- import assert11 from "@dxos/node-std/assert";
2099
+ import assert10 from "@dxos/node-std/assert";
2214
2100
  import { DeferredTask, Event as Event3, scheduleTask as scheduleTask3, TimeoutError, Trigger as Trigger4 } from "@dxos/async";
2215
2101
  import { Context as Context5 } from "@dxos/context";
2216
2102
  import { PublicKey as PublicKey5 } from "@dxos/keys";
2217
- import { log as log9 } from "@dxos/log";
2103
+ import { log as log8 } from "@dxos/log";
2218
2104
  import { schema as schema5 } from "@dxos/protocols";
2219
2105
  import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
2220
2106
  import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
@@ -2237,7 +2123,7 @@ var NotarizationPlugin = class {
2237
2123
  * Request credentials to be notarized.
2238
2124
  */
2239
2125
  async notarize(credentials) {
2240
- log9("notarize", {
2126
+ log8("notarize", {
2241
2127
  credentials
2242
2128
  }, {
2243
2129
  file: "notarization-plugin.ts",
@@ -2245,11 +2131,11 @@ var NotarizationPlugin = class {
2245
2131
  scope: this,
2246
2132
  callSite: (f, a) => f(...a)
2247
2133
  });
2248
- assert11(credentials.every((credential) => credential.id), "Credentials must have an id");
2134
+ assert10(credentials.every((credential) => credential.id), "Credentials must have an id");
2249
2135
  const errors = new Trigger4();
2250
2136
  const ctx = this._ctx.derive({
2251
2137
  onError: (err) => {
2252
- log9.warn("Notarization error", {
2138
+ log8.warn("Notarization error", {
2253
2139
  err
2254
2140
  }, {
2255
2141
  file: "notarization-plugin.ts",
@@ -2262,7 +2148,7 @@ var NotarizationPlugin = class {
2262
2148
  }
2263
2149
  });
2264
2150
  scheduleTask3(ctx, () => {
2265
- log9.warn("Notarization timeout", {}, {
2151
+ log8.warn("Notarization timeout", {}, {
2266
2152
  file: "notarization-plugin.ts",
2267
2153
  line: 61,
2268
2154
  scope: this,
@@ -2276,7 +2162,7 @@ var NotarizationPlugin = class {
2276
2162
  const notarizeTask = new DeferredTask(ctx, async () => {
2277
2163
  try {
2278
2164
  if (this._extensions.size === 0) {
2279
- log9.warn("No peers to notarize with", {}, {
2165
+ log8.warn("No peers to notarize with", {}, {
2280
2166
  file: "notarization-plugin.ts",
2281
2167
  line: 76,
2282
2168
  scope: this,
@@ -2288,7 +2174,7 @@ var NotarizationPlugin = class {
2288
2174
  ...this._extensions
2289
2175
  ].find((peer2) => !peersTried.has(peer2));
2290
2176
  if (!peer) {
2291
- log9.warn("Exhausted all peers to notarize with", {
2177
+ log8.warn("Exhausted all peers to notarize with", {
2292
2178
  retryIn: RETRY_TIMEOUT
2293
2179
  }, {
2294
2180
  file: "notarization-plugin.ts",
@@ -2301,7 +2187,7 @@ var NotarizationPlugin = class {
2301
2187
  return;
2302
2188
  }
2303
2189
  peersTried.add(peer);
2304
- log9("try notarizing", {
2190
+ log8("try notarizing", {
2305
2191
  peer: peer.localPeerId,
2306
2192
  credentialId: credentials.map((credential) => credential.id)
2307
2193
  }, {
@@ -2313,14 +2199,14 @@ var NotarizationPlugin = class {
2313
2199
  await peer.rpc.NotarizationService.notarize({
2314
2200
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2315
2201
  });
2316
- log9("success", {}, {
2202
+ log8("success", {}, {
2317
2203
  file: "notarization-plugin.ts",
2318
2204
  line: 94,
2319
2205
  scope: this,
2320
2206
  callSite: (f, a) => f(...a)
2321
2207
  });
2322
2208
  } catch (err) {
2323
- log9.warn("error notarizing (recoverable)", err, {
2209
+ log8.warn("error notarizing (recoverable)", err, {
2324
2210
  file: "notarization-plugin.ts",
2325
2211
  line: 96,
2326
2212
  scope: this,
@@ -2336,7 +2222,7 @@ var NotarizationPlugin = class {
2336
2222
  allNotarized,
2337
2223
  errors.wait()
2338
2224
  ]);
2339
- log9("done", {}, {
2225
+ log8("done", {}, {
2340
2226
  file: "notarization-plugin.ts",
2341
2227
  line: 107,
2342
2228
  scope: this,
@@ -2359,7 +2245,7 @@ var NotarizationPlugin = class {
2359
2245
  this._processCredentialsTriggers.delete(credential.id);
2360
2246
  }
2361
2247
  setWriter(writer) {
2362
- assert11(!this._writer, "Writer already set.");
2248
+ assert10(!this._writer, "Writer already set.");
2363
2249
  this._writer = writer;
2364
2250
  }
2365
2251
  async _waitUntilProcessed(id) {
@@ -2377,7 +2263,7 @@ var NotarizationPlugin = class {
2377
2263
  throw new Error("Writer not set");
2378
2264
  }
2379
2265
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2380
- assert11(credential.id, "Credential must have an id");
2266
+ assert10(credential.id, "Credential must have an id");
2381
2267
  if (this._processedCredentials.has(credential.id)) {
2382
2268
  continue;
2383
2269
  }
@@ -2387,7 +2273,7 @@ var NotarizationPlugin = class {
2387
2273
  createExtension() {
2388
2274
  const extension = new NotarizationTeleportExtension({
2389
2275
  onOpen: async () => {
2390
- log9("extension opened", {
2276
+ log8("extension opened", {
2391
2277
  peer: extension.localPeerId
2392
2278
  }, {
2393
2279
  file: "notarization-plugin.ts",
@@ -2399,7 +2285,7 @@ var NotarizationPlugin = class {
2399
2285
  this._extensionOpened.emit();
2400
2286
  },
2401
2287
  onClose: async () => {
2402
- log9("extension closed", {
2288
+ log8("extension closed", {
2403
2289
  peer: extension.localPeerId
2404
2290
  }, {
2405
2291
  file: "notarization-plugin.ts",
@@ -2609,7 +2495,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2609
2495
  }
2610
2496
  async open() {
2611
2497
  await this._metadataStore.load();
2612
- log10("metadata loaded", {
2498
+ log9("metadata loaded", {
2613
2499
  spaces: this._metadataStore.spaces.length
2614
2500
  }, {
2615
2501
  file: "data-space-manager.ts",
@@ -2618,7 +2504,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2618
2504
  callSite: (f, a) => f(...a)
2619
2505
  });
2620
2506
  for (const spaceMetadata of this._metadataStore.spaces) {
2621
- log10("load space", {
2507
+ log9("load space", {
2622
2508
  spaceMetadata
2623
2509
  }, {
2624
2510
  file: "data-space-manager.ts",
@@ -2629,7 +2515,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2629
2515
  const space = await this._constructSpace(spaceMetadata);
2630
2516
  await space.initializeDataPipeline();
2631
2517
  if (spaceMetadata.dataTimeframe) {
2632
- log10("waiting for latest timeframe", {
2518
+ log9("waiting for latest timeframe", {
2633
2519
  spaceMetadata
2634
2520
  }, {
2635
2521
  file: "data-space-manager.ts",
@@ -2664,7 +2550,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2664
2550
  controlFeedKey,
2665
2551
  dataFeedKey
2666
2552
  };
2667
- log10("creating space...", {
2553
+ log9("creating space...", {
2668
2554
  spaceKey
2669
2555
  }, {
2670
2556
  file: "data-space-manager.ts",
@@ -2676,7 +2562,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2676
2562
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
2677
2563
  await this._metadataStore.addSpace(metadata);
2678
2564
  const memberCredential = credentials[1];
2679
- assert12(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2565
+ assert11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2680
2566
  await this._signingContext.recordCredential(memberCredential);
2681
2567
  await space.initializeDataPipeline();
2682
2568
  this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
@@ -2685,7 +2571,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2685
2571
  }
2686
2572
  // TODO(burdon): Rename join space.
2687
2573
  async acceptSpace(opts) {
2688
- assert12(!this._spaces.has(opts.spaceKey), "Space already exists.");
2574
+ assert11(!this._spaces.has(opts.spaceKey), "Space already exists.");
2689
2575
  const metadata = {
2690
2576
  key: opts.spaceKey,
2691
2577
  genesisFeedKey: opts.genesisFeedKey
@@ -2787,7 +2673,7 @@ var ServiceContext = class {
2787
2673
  networkManager: this.networkManager
2788
2674
  });
2789
2675
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
2790
- this.haloInvitations = new HaloInvitationsHandler({
2676
+ this.deviceInvitations = new DeviceInvitationsHandler({
2791
2677
  networkManager: this.networkManager,
2792
2678
  getIdentity: () => {
2793
2679
  var _a;
@@ -2798,7 +2684,7 @@ var ServiceContext = class {
2798
2684
  });
2799
2685
  }
2800
2686
  async open() {
2801
- log11("opening...", {}, {
2687
+ log10("opening...", {}, {
2802
2688
  file: "service-context.ts",
2803
2689
  line: 94,
2804
2690
  scope: this,
@@ -2810,7 +2696,7 @@ var ServiceContext = class {
2810
2696
  if (this.identityManager.identity) {
2811
2697
  await this._initialize();
2812
2698
  }
2813
- log11("opened", {}, {
2699
+ log10("opened", {}, {
2814
2700
  file: "service-context.ts",
2815
2701
  line: 101,
2816
2702
  scope: this,
@@ -2819,7 +2705,7 @@ var ServiceContext = class {
2819
2705
  }
2820
2706
  async close() {
2821
2707
  var _a, _b;
2822
- log11("closing...", {}, {
2708
+ log10("closing...", {}, {
2823
2709
  file: "service-context.ts",
2824
2710
  line: 105,
2825
2711
  scope: this,
@@ -2832,7 +2718,7 @@ var ServiceContext = class {
2832
2718
  await this.feedStore.close();
2833
2719
  await this.networkManager.close();
2834
2720
  this.dataServiceSubscriptions.clear();
2835
- log11("closed", {}, {
2721
+ log10("closed", {}, {
2836
2722
  file: "service-context.ts",
2837
2723
  line: 113,
2838
2724
  scope: this,
@@ -2840,7 +2726,7 @@ var ServiceContext = class {
2840
2726
  });
2841
2727
  }
2842
2728
  async reset() {
2843
- log11("resetting...", {}, {
2729
+ log10("resetting...", {}, {
2844
2730
  file: "service-context.ts",
2845
2731
  line: 117,
2846
2732
  scope: this,
@@ -2848,7 +2734,7 @@ var ServiceContext = class {
2848
2734
  });
2849
2735
  await this.close();
2850
2736
  await this.storage.reset();
2851
- log11("reset", {}, {
2737
+ log10("reset", {}, {
2852
2738
  file: "service-context.ts",
2853
2739
  line: 120,
2854
2740
  scope: this,
@@ -2868,7 +2754,7 @@ var ServiceContext = class {
2868
2754
  // Called when identity is created.
2869
2755
  async _initialize() {
2870
2756
  var _a;
2871
- log11("initializing spaces...", {}, {
2757
+ log10("initializing spaces...", {}, {
2872
2758
  file: "service-context.ts",
2873
2759
  line: 139,
2874
2760
  scope: this,
@@ -2902,7 +2788,7 @@ var ServiceContext = class {
2902
2788
  return;
2903
2789
  }
2904
2790
  if (!this.dataSpaceManager) {
2905
- log11("dataSpaceManager not initialized yet, ignoring space admission", {
2791
+ log10("dataSpaceManager not initialized yet, ignoring space admission", {
2906
2792
  details: assertion
2907
2793
  }, {
2908
2794
  file: "service-context.ts",
@@ -2913,7 +2799,7 @@ var ServiceContext = class {
2913
2799
  return;
2914
2800
  }
2915
2801
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
2916
- log11("space already exists, ignoring space admission", {
2802
+ log10("space already exists, ignoring space admission", {
2917
2803
  details: assertion
2918
2804
  }, {
2919
2805
  file: "service-context.ts",
@@ -2924,7 +2810,7 @@ var ServiceContext = class {
2924
2810
  return;
2925
2811
  }
2926
2812
  try {
2927
- log11("accepting space recorded in halo", {
2813
+ log10("accepting space recorded in halo", {
2928
2814
  details: assertion
2929
2815
  }, {
2930
2816
  file: "service-context.ts",
@@ -2937,7 +2823,7 @@ var ServiceContext = class {
2937
2823
  genesisFeedKey: assertion.genesisFeedKey
2938
2824
  });
2939
2825
  } catch (err) {
2940
- log11.catch(err, {}, {
2826
+ log10.catch(err, {}, {
2941
2827
  file: "service-context.ts",
2942
2828
  line: 197,
2943
2829
  scope: this,
@@ -2954,16 +2840,15 @@ var ServiceContext = class {
2954
2840
  import { schema as schema6 } from "@dxos/protocols";
2955
2841
  import { createServiceBundle } from "@dxos/rpc";
2956
2842
  var clientServiceBundle = createServiceBundle({
2957
- HaloInvitationsService: schema6.getService("dxos.client.services.HaloInvitationsService"),
2843
+ SystemService: schema6.getService("dxos.client.services.SystemService"),
2844
+ IdentityService: schema6.getService("dxos.client.services.IdentityService"),
2845
+ DeviceInvitationsService: schema6.getService("dxos.client.services.DeviceInvitationsService"),
2958
2846
  DevicesService: schema6.getService("dxos.client.services.DevicesService"),
2959
2847
  SpaceInvitationsService: schema6.getService("dxos.client.services.SpaceInvitationsService"),
2960
2848
  SpacesService: schema6.getService("dxos.client.services.SpacesService"),
2849
+ DataService: schema6.getService("dxos.echo.service.DataService"),
2961
2850
  NetworkService: schema6.getService("dxos.client.services.NetworkService"),
2962
2851
  // TODO(burdon): Deprecated.
2963
- SpaceService: schema6.getService("dxos.client.SpaceService"),
2964
- DataService: schema6.getService("dxos.echo.service.DataService"),
2965
- ProfileService: schema6.getService("dxos.client.ProfileService"),
2966
- SystemService: schema6.getService("dxos.client.SystemService"),
2967
2852
  DevtoolsHost: schema6.getService("dxos.devtools.host.DevtoolsHost"),
2968
2853
  TracingService: schema6.getService("dxos.devtools.host.TracingService")
2969
2854
  });
@@ -3013,34 +2898,155 @@ var toStorageType = (type) => {
3013
2898
  }
3014
2899
  };
3015
2900
 
2901
+ // packages/sdk/client-services/src/packlets/vault/services.ts
2902
+ import { schema as schema7 } from "@dxos/protocols";
2903
+ var iframeServiceBundle = {
2904
+ IframeService: schema7.getService("dxos.iframe.IframeService"),
2905
+ BridgeService: schema7.getService("dxos.mesh.bridge.BridgeService")
2906
+ };
2907
+ var workerServiceBundle = {
2908
+ WorkerService: schema7.getService("dxos.iframe.WorkerService")
2909
+ };
2910
+ var appServiceBundle = {
2911
+ AppService: schema7.getService("dxos.iframe.AppService")
2912
+ };
2913
+ var shellServiceBundle = {
2914
+ ShellService: schema7.getService("dxos.iframe.ShellService")
2915
+ };
2916
+
2917
+ // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
2918
+ import assert12 from "@dxos/node-std/assert";
2919
+ import { Event as Event5 } from "@dxos/async";
2920
+ import { ShellLayout } from "@dxos/protocols/proto/dxos/iframe";
2921
+ import { createProtoRpcPeer } from "@dxos/rpc";
2922
+ var ShellRuntimeImpl = class {
2923
+ constructor(_port) {
2924
+ this._port = _port;
2925
+ this.layoutUpdate = new Event5();
2926
+ this._layout = ShellLayout.DEFAULT;
2927
+ }
2928
+ get layout() {
2929
+ return this._layout;
2930
+ }
2931
+ get invitationCode() {
2932
+ return this._invitationCode;
2933
+ }
2934
+ get spaceKey() {
2935
+ return this._spaceKey;
2936
+ }
2937
+ setLayout(layout, options = {}) {
2938
+ this._layout = layout;
2939
+ this._invitationCode = options.invitationCode;
2940
+ this._spaceKey = options.spaceKey;
2941
+ this.layoutUpdate.emit({
2942
+ layout,
2943
+ ...options
2944
+ });
2945
+ }
2946
+ async setAppContext(context) {
2947
+ assert12(this._appRpc, "runtime not open");
2948
+ await this._appRpc.rpc.AppService.setContext(context);
2949
+ }
2950
+ async open() {
2951
+ this._appRpc = createProtoRpcPeer({
2952
+ requested: appServiceBundle,
2953
+ exposed: shellServiceBundle,
2954
+ handlers: {
2955
+ ShellService: {
2956
+ setLayout: async (request) => {
2957
+ this._layout = request.layout;
2958
+ this._invitationCode = request.invitationCode;
2959
+ this._spaceKey = request.spaceKey;
2960
+ this.layoutUpdate.emit(request);
2961
+ }
2962
+ }
2963
+ },
2964
+ port: this._port
2965
+ });
2966
+ await this._appRpc.open();
2967
+ }
2968
+ async close() {
2969
+ var _a;
2970
+ await ((_a = this._appRpc) == null ? void 0 : _a.close());
2971
+ this._appRpc = void 0;
2972
+ }
2973
+ };
2974
+ var MemoryShellRuntime = class {
2975
+ constructor({ layout, invitationCode, spaceKey } = {}) {
2976
+ this.layoutUpdate = new Event5();
2977
+ this.contextUpdate = new Event5();
2978
+ this._layout = layout != null ? layout : ShellLayout.DEFAULT;
2979
+ this._invitationCode = invitationCode;
2980
+ this._spaceKey = spaceKey;
2981
+ }
2982
+ get layout() {
2983
+ return this._layout;
2984
+ }
2985
+ get invitationCode() {
2986
+ return this._invitationCode;
2987
+ }
2988
+ get spaceKey() {
2989
+ return this._spaceKey;
2990
+ }
2991
+ setLayout(layout, options = {}) {
2992
+ this._layout = layout;
2993
+ this._invitationCode = options.invitationCode;
2994
+ this._spaceKey = options.spaceKey;
2995
+ this.layoutUpdate.emit({
2996
+ layout,
2997
+ ...options
2998
+ });
2999
+ }
3000
+ async setAppContext(context) {
3001
+ this.contextUpdate.emit(context);
3002
+ }
3003
+ };
3004
+
3016
3005
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3017
3006
  import { Trigger as Trigger9 } from "@dxos/async";
3018
- import { log as log16, logInfo as logInfo2 } from "@dxos/log";
3007
+ import { log as log17, logInfo as logInfo2 } from "@dxos/log";
3019
3008
  import { MemorySignalManager as MemorySignalManager2, MemorySignalManagerContext as MemorySignalManagerContext2, WebsocketSignalManager as WebsocketSignalManager2 } from "@dxos/messaging";
3020
3009
  import { createWebRTCTransportFactory, NetworkManager as NetworkManager2 } from "@dxos/network-manager";
3021
- import { createProtoRpcPeer as createProtoRpcPeer4 } from "@dxos/rpc";
3010
+ import { createProtoRpcPeer as createProtoRpcPeer6 } from "@dxos/rpc";
3011
+ import { getAsyncValue } from "@dxos/util";
3022
3012
 
3023
3013
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3014
+ import assert14 from "@dxos/node-std/assert";
3015
+ import { Event as Event7 } from "@dxos/async";
3024
3016
  import { raise as raise2 } from "@dxos/debug";
3025
3017
  import { DocumentModel } from "@dxos/document-model";
3026
- import { DataServiceImpl } from "@dxos/echo-db";
3027
- import { log as log15 } from "@dxos/log";
3018
+ import { DataServiceImpl } from "@dxos/echo-pipeline";
3019
+ import { log as log16 } from "@dxos/log";
3028
3020
  import { ModelFactory } from "@dxos/model-factory";
3029
- import { Status } from "@dxos/protocols/proto/dxos/client";
3021
+ import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
3030
3022
  import { TextModel } from "@dxos/text-model";
3031
3023
 
3032
- // packages/sdk/client-services/src/packlets/identity/devices-service-impl.ts
3024
+ // packages/sdk/client-services/src/packlets/deprecated/tracing.ts
3025
+ var TracingServiceImpl = class {
3026
+ constructor(_config) {
3027
+ this._config = _config;
3028
+ }
3029
+ async setTracingOptions() {
3030
+ throw new Error("Tracing not available.");
3031
+ }
3032
+ subscribeToRpcTrace() {
3033
+ throw new Error("Tracing not available.");
3034
+ }
3035
+ };
3036
+
3037
+ // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3033
3038
  import { EventSubscriptions as EventSubscriptions2 } from "@dxos/async";
3034
- import { Stream as Stream9 } from "@dxos/codec-protobuf";
3039
+ import { Stream as Stream8 } from "@dxos/codec-protobuf";
3040
+ import { DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
3035
3041
  var DevicesServiceImpl = class {
3036
3042
  constructor(_identityManager) {
3037
3043
  this._identityManager = _identityManager;
3038
3044
  }
3039
- updateDevice() {
3045
+ updateDevice(request) {
3040
3046
  throw new Error("Method not implemented.");
3041
3047
  }
3042
3048
  queryDevices() {
3043
- return new Stream9(({ next }) => {
3049
+ return new Stream8(({ next }) => {
3044
3050
  const update = () => {
3045
3051
  var _a;
3046
3052
  const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
@@ -3050,35 +3056,39 @@ var DevicesServiceImpl = class {
3050
3056
  });
3051
3057
  } else {
3052
3058
  next({
3053
- devices: Array.from(deviceKeys.values()).map((key) => ({
3054
- deviceKey: key
3055
- }))
3059
+ devices: Array.from(deviceKeys.values()).map((key) => {
3060
+ var _a2;
3061
+ return {
3062
+ deviceKey: key,
3063
+ kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
3064
+ };
3065
+ })
3056
3066
  });
3057
3067
  }
3058
3068
  };
3059
- const dispose = new EventSubscriptions2();
3060
- dispose.add(this._identityManager.stateUpdate.on(() => {
3069
+ const subscriptions = new EventSubscriptions2();
3070
+ subscriptions.add(this._identityManager.stateUpdate.on(() => {
3061
3071
  update();
3062
3072
  if (this._identityManager.identity) {
3063
- dispose.add(this._identityManager.identity.stateUpdate.on(() => {
3073
+ subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
3064
3074
  update();
3065
3075
  }));
3066
3076
  }
3067
3077
  }));
3068
3078
  update();
3069
- return () => dispose.clear();
3079
+ return () => subscriptions.clear();
3070
3080
  });
3071
3081
  }
3072
3082
  };
3073
3083
 
3074
3084
  // packages/sdk/client-services/src/packlets/network/network-service.ts
3075
- import { Stream as Stream10 } from "@dxos/codec-protobuf";
3085
+ import { Stream as Stream9 } from "@dxos/codec-protobuf";
3076
3086
  var NetworkServiceImpl = class {
3077
3087
  constructor(networkManager) {
3078
3088
  this.networkManager = networkManager;
3079
3089
  }
3080
3090
  subscribeToNetworkStatus() {
3081
- return new Stream10(({ next }) => {
3091
+ return new Stream9(({ next }) => {
3082
3092
  const unsubscribe = this.networkManager.connectionStateChanged.on((state) => next({
3083
3093
  state
3084
3094
  }));
@@ -3094,25 +3104,80 @@ var NetworkServiceImpl = class {
3094
3104
  };
3095
3105
 
3096
3106
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
3097
- import { scheduleTask as scheduleTask4 } from "@dxos/async";
3098
- import { Stream as Stream11 } from "@dxos/codec-protobuf";
3099
- import { raise } from "@dxos/debug";
3100
- import { SpaceNotFoundError } from "@dxos/echo-db";
3107
+ import { EventSubscriptions as EventSubscriptions3, scheduleTask as scheduleTask4 } from "@dxos/async";
3108
+ import { Stream as Stream10 } from "@dxos/codec-protobuf";
3109
+ import { raise, todo as todo2 } from "@dxos/debug";
3110
+ import { SpaceNotFoundError } from "@dxos/echo-pipeline";
3111
+ import { log as log11 } from "@dxos/log";
3112
+ import { SpaceMember, SpaceStatus } from "@dxos/protocols/proto/dxos/client/services";
3113
+ import { humanize } from "@dxos/util";
3101
3114
  var SpacesServiceImpl = class {
3102
- constructor(_spaceManager) {
3115
+ constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
3116
+ this._identityManager = _identityManager;
3103
3117
  this._spaceManager = _spaceManager;
3118
+ this._dataServiceSubscriptions = _dataServiceSubscriptions;
3119
+ this._getDataSpaceManager = _getDataSpaceManager;
3104
3120
  }
3105
3121
  async createSpace() {
3106
- throw new Error();
3122
+ if (!this._identityManager.identity) {
3123
+ throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
3124
+ }
3125
+ const dataSpaceManager = await this._getDataSpaceManager();
3126
+ const space = await dataSpaceManager.createSpace();
3127
+ return this._transformSpace(space);
3107
3128
  }
3108
- querySpaces() {
3109
- throw new Error();
3129
+ async updateSpace(request) {
3130
+ todo2();
3110
3131
  }
3111
- queryMembers(query) {
3112
- throw new Error();
3132
+ querySpaces() {
3133
+ return new Stream10(({ next, ctx }) => {
3134
+ const onUpdate = async () => {
3135
+ const dataSpaceManager = await this._getDataSpaceManager();
3136
+ const spaces = Array.from(dataSpaceManager.spaces.values()).filter((space) => this._dataServiceSubscriptions.getDataService(space.key)).map((space) => this._transformSpace(space));
3137
+ log11("update", {
3138
+ spaces
3139
+ }, {
3140
+ file: "spaces-service.ts",
3141
+ line: 59,
3142
+ scope: this,
3143
+ callSite: (f, a) => f(...a)
3144
+ });
3145
+ next({
3146
+ spaces
3147
+ });
3148
+ };
3149
+ setTimeout(async () => {
3150
+ const dataSpaceManager = await this._getDataSpaceManager();
3151
+ const subscriptions = new EventSubscriptions3();
3152
+ const subscribeSpaces = () => {
3153
+ subscriptions.clear();
3154
+ for (const space of dataSpaceManager.spaces.values()) {
3155
+ if (!this._dataServiceSubscriptions.getDataService(space.key)) {
3156
+ continue;
3157
+ }
3158
+ subscriptions.add(space.stateUpdate.on(ctx, onUpdate));
3159
+ subscriptions.add(space.presence.updated.on(ctx, onUpdate));
3160
+ }
3161
+ };
3162
+ dataSpaceManager.updated.on(ctx, () => {
3163
+ subscribeSpaces();
3164
+ void onUpdate();
3165
+ });
3166
+ ctx.onDispose(() => subscriptions.clear());
3167
+ scheduleTask4(ctx, () => {
3168
+ subscribeSpaces();
3169
+ void onUpdate();
3170
+ });
3171
+ });
3172
+ if (!this._identityManager.identity) {
3173
+ next({
3174
+ spaces: []
3175
+ });
3176
+ }
3177
+ });
3113
3178
  }
3114
3179
  queryCredentials({ spaceKey }) {
3115
- return new Stream11(({ ctx, next }) => {
3180
+ return new Stream10(({ ctx, next }) => {
3116
3181
  var _a;
3117
3182
  const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
3118
3183
  const processor = space.spaceState.registerProcessor({
@@ -3135,30 +3200,74 @@ var SpacesServiceImpl = class {
3135
3200
  });
3136
3201
  }
3137
3202
  }
3203
+ _transformSpace(space) {
3204
+ return {
3205
+ spaceKey: space.key,
3206
+ status: space.isOpen ? SpaceStatus.ACTIVE : SpaceStatus.INACTIVE,
3207
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => {
3208
+ var _a, _b, _c;
3209
+ return {
3210
+ identity: {
3211
+ identityKey: member.key,
3212
+ profile: {
3213
+ displayName: (_b = (_a = member.assertion.profile) == null ? void 0 : _a.displayName) != null ? _b : humanize(member.key)
3214
+ }
3215
+ },
3216
+ presence: ((_c = this._identityManager.identity) == null ? void 0 : _c.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
3217
+ };
3218
+ })
3219
+ };
3220
+ }
3138
3221
  };
3139
3222
 
3140
- // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
3141
- import { WebRTCTransportService } from "@dxos/network-manager";
3142
- import { createProtoRpcPeer } from "@dxos/rpc";
3143
-
3144
- // packages/sdk/client-services/src/packlets/vault/services.ts
3145
- import { schema as schema7 } from "@dxos/protocols";
3146
- var iframeServiceBundle = {
3147
- IframeService: schema7.getService("dxos.iframe.IframeService"),
3148
- BridgeService: schema7.getService("dxos.mesh.bridge.BridgeService")
3149
- };
3150
- var workerServiceBundle = {
3151
- WorkerService: schema7.getService("dxos.iframe.WorkerService")
3223
+ // packages/sdk/client-services/src/packlets/system/system-service.ts
3224
+ import { Stream as Stream11 } from "@dxos/codec-protobuf";
3225
+ var SystemServiceImpl = class {
3226
+ constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
3227
+ this._config = config;
3228
+ this._statusUpdate = statusUpdate;
3229
+ this._getCurrentStatus = getCurrentStatus;
3230
+ this._onUpdateStatus = onUpdateStatus;
3231
+ this._onReset = onReset;
3232
+ }
3233
+ async getConfig() {
3234
+ return this._config.values;
3235
+ }
3236
+ async updateStatus({ status }) {
3237
+ await this._onUpdateStatus(status);
3238
+ }
3239
+ queryStatus() {
3240
+ return new Stream11(({ next }) => {
3241
+ const update = () => {
3242
+ next({
3243
+ status: this._getCurrentStatus()
3244
+ });
3245
+ };
3246
+ update();
3247
+ const unsubscribe = this._statusUpdate.on(() => update());
3248
+ const interval = setInterval(update, 3e3);
3249
+ return () => {
3250
+ clearInterval(interval);
3251
+ unsubscribe();
3252
+ };
3253
+ });
3254
+ }
3255
+ async reset() {
3256
+ await this._onReset();
3257
+ }
3152
3258
  };
3153
3259
 
3154
3260
  // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
3261
+ import { WebRTCTransportService } from "@dxos/network-manager";
3262
+ import { createProtoRpcPeer as createProtoRpcPeer2 } from "@dxos/rpc";
3155
3263
  var IFrameProxyRuntime = class {
3156
- constructor({ systemPort, workerAppPort, windowAppPort }) {
3264
+ constructor({ systemPort, workerAppPort, windowAppPort, shellPort }) {
3157
3265
  this._transportService = new WebRTCTransportService();
3158
3266
  this._systemPort = systemPort;
3159
3267
  this._windowAppPort = windowAppPort;
3160
3268
  this._workerAppPort = workerAppPort;
3161
- this._systemRpc = createProtoRpcPeer({
3269
+ this._shellPort = shellPort;
3270
+ this._systemRpc = createProtoRpcPeer2({
3162
3271
  requested: workerServiceBundle,
3163
3272
  exposed: iframeServiceBundle,
3164
3273
  handlers: {
@@ -3173,22 +3282,95 @@ var IFrameProxyRuntime = class {
3173
3282
  });
3174
3283
  this._workerAppPort.subscribe((msg) => this._windowAppPort.send(msg));
3175
3284
  this._windowAppPort.subscribe((msg) => this._workerAppPort.send(msg));
3285
+ if (this._shellPort) {
3286
+ this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3287
+ }
3288
+ }
3289
+ get shell() {
3290
+ return this._shellRuntime;
3176
3291
  }
3177
3292
  async open(origin) {
3293
+ var _a;
3178
3294
  await this._systemRpc.open();
3179
3295
  await this._systemRpc.rpc.WorkerService.start({
3180
3296
  origin
3181
3297
  });
3298
+ await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
3182
3299
  }
3183
3300
  async close() {
3301
+ var _a;
3302
+ await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
3184
3303
  await this._systemRpc.rpc.WorkerService.stop();
3185
3304
  await this._systemRpc.close();
3186
3305
  }
3187
3306
  };
3188
3307
 
3308
+ // packages/sdk/client-services/src/packlets/vault/shell-controller.ts
3309
+ import { Event as Event6 } from "@dxos/async";
3310
+ import { log as log12 } from "@dxos/log";
3311
+ import { ShellDisplay } from "@dxos/protocols/proto/dxos/iframe";
3312
+ import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
3313
+ var ShellController = class {
3314
+ constructor(_port) {
3315
+ this._port = _port;
3316
+ this.contextUpdate = new Event6();
3317
+ this._display = ShellDisplay.NONE;
3318
+ }
3319
+ get display() {
3320
+ return this._display;
3321
+ }
3322
+ async setLayout(layout, options = {}) {
3323
+ var _a;
3324
+ log12("set layout", {
3325
+ layout,
3326
+ ...options
3327
+ }, {
3328
+ file: "shell-controller.ts",
3329
+ line: 27,
3330
+ scope: this,
3331
+ callSite: (f, a) => f(...a)
3332
+ });
3333
+ this._display = ShellDisplay.FULLSCREEN;
3334
+ this.contextUpdate.emit({
3335
+ display: this._display
3336
+ });
3337
+ await ((_a = this._shellRpc) == null ? void 0 : _a.rpc.ShellService.setLayout({
3338
+ layout,
3339
+ ...options
3340
+ }));
3341
+ }
3342
+ async open() {
3343
+ this._shellRpc = createProtoRpcPeer3({
3344
+ requested: shellServiceBundle,
3345
+ exposed: appServiceBundle,
3346
+ handlers: {
3347
+ AppService: {
3348
+ setContext: async (request) => {
3349
+ log12("set context", request, {
3350
+ file: "shell-controller.ts",
3351
+ line: 40,
3352
+ scope: this,
3353
+ callSite: (f, a) => f(...a)
3354
+ });
3355
+ this._display = request.display;
3356
+ this.contextUpdate.emit(request);
3357
+ }
3358
+ }
3359
+ },
3360
+ port: this._port
3361
+ });
3362
+ await this._shellRpc.open();
3363
+ }
3364
+ async close() {
3365
+ var _a;
3366
+ await ((_a = this._shellRpc) == null ? void 0 : _a.close());
3367
+ this._shellRpc = void 0;
3368
+ }
3369
+ };
3370
+
3189
3371
  // packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
3190
3372
  import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
3191
- import { log as log12 } from "@dxos/log";
3373
+ import { log as log13 } from "@dxos/log";
3192
3374
  var Message;
3193
3375
  (function(Message2) {
3194
3376
  Message2["ACQUIRING"] = "acquiring";
@@ -3221,7 +3403,7 @@ var VaultResourceLock = class {
3221
3403
  }
3222
3404
  }
3223
3405
  async _requestLock(steal = false) {
3224
- log12("requesting lock...", {
3406
+ log13("requesting lock...", {
3225
3407
  steal
3226
3408
  }, {
3227
3409
  file: "vault-resource-lock.ts",
@@ -3238,14 +3420,14 @@ var VaultResourceLock = class {
3238
3420
  acquired.wake();
3239
3421
  this._releaseTrigger = new Trigger6();
3240
3422
  await this._releaseTrigger.wait();
3241
- log12("releasing lock...", {}, {
3423
+ log13("releasing lock...", {}, {
3242
3424
  file: "vault-resource-lock.ts",
3243
3425
  line: 65,
3244
3426
  scope: this,
3245
3427
  callSite: (f, a) => f(...a)
3246
3428
  });
3247
3429
  await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3248
- log12("released lock", {}, {
3430
+ log13("released lock", {}, {
3249
3431
  file: "vault-resource-lock.ts",
3250
3432
  line: 67,
3251
3433
  scope: this,
@@ -3256,7 +3438,7 @@ var VaultResourceLock = class {
3256
3438
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3257
3439
  });
3258
3440
  await acquired.wait();
3259
- log12("recieved lock", {
3441
+ log13("recieved lock", {
3260
3442
  steal
3261
3443
  }, {
3262
3444
  file: "vault-resource-lock.ts",
@@ -3269,15 +3451,15 @@ var VaultResourceLock = class {
3269
3451
 
3270
3452
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
3271
3453
  import { Trigger as Trigger8 } from "@dxos/async";
3272
- import { log as log14 } from "@dxos/log";
3454
+ import { log as log15 } from "@dxos/log";
3273
3455
  import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from "@dxos/messaging";
3274
3456
  import { NetworkManager, WebRTCTransportProxyFactory } from "@dxos/network-manager";
3275
3457
 
3276
3458
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
3277
3459
  import assert13 from "@dxos/node-std/assert";
3278
- import { Trigger as Trigger7 } from "@dxos/async";
3279
- import { log as log13, logInfo } from "@dxos/log";
3280
- import { createProtoRpcPeer as createProtoRpcPeer2 } from "@dxos/rpc";
3460
+ import { asyncTimeout as asyncTimeout2, Trigger as Trigger7 } from "@dxos/async";
3461
+ import { log as log14, logInfo } from "@dxos/log";
3462
+ import { createProtoRpcPeer as createProtoRpcPeer4 } from "@dxos/rpc";
3281
3463
  import { Callback } from "@dxos/util";
3282
3464
  var __decorate3 = function(decorators, target, key, desc) {
3283
3465
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -3290,7 +3472,7 @@ var __decorate3 = function(decorators, target, key, desc) {
3290
3472
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3291
3473
  };
3292
3474
  var WorkerSession = class {
3293
- constructor({ getService, systemPort, appPort, options = {
3475
+ constructor({ getService, systemPort, appPort, shellPort, options = {
3294
3476
  heartbeatInterval: 1e3
3295
3477
  } }) {
3296
3478
  this._startTrigger = new Trigger7();
@@ -3299,24 +3481,29 @@ var WorkerSession = class {
3299
3481
  assert13(getService);
3300
3482
  this._options = options;
3301
3483
  this._getService = getService;
3302
- this._clientRpc = createProtoRpcPeer2({
3484
+ const handlers = {
3485
+ DataService: () => this._getService((services) => services.DataService),
3486
+ DeviceInvitationsService: () => this._getService((services) => services.DeviceInvitationsService),
3487
+ DevicesService: () => this._getService((services) => services.DevicesService),
3488
+ DevtoolsHost: () => this._getService((services) => services.DevtoolsHost),
3489
+ NetworkService: () => this._getService((services) => services.NetworkService),
3490
+ IdentityService: () => this._getService((services) => services.IdentityService),
3491
+ SpaceInvitationsService: () => this._getService((services) => services.SpaceInvitationsService),
3492
+ SpacesService: () => this._getService((services) => services.SpacesService),
3493
+ SystemService: () => this._getService((services) => services.SystemService),
3494
+ TracingService: () => this._getService((services) => services.TracingService)
3495
+ };
3496
+ this._clientRpc = createProtoRpcPeer4({
3303
3497
  exposed: clientServiceBundle,
3304
- handlers: {
3305
- DataService: async () => await this._getService((services) => services.DataService),
3306
- DevicesService: async () => await this._getService((services) => services.DevicesService),
3307
- DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
3308
- HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
3309
- NetworkService: async () => await this._getService((services) => services.NetworkService),
3310
- ProfileService: async () => await this._getService((services) => services.ProfileService),
3311
- SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
3312
- SpaceService: async () => await this._getService((services) => services.SpaceService),
3313
- SpacesService: async () => await this._getService((services) => services.SpacesService),
3314
- SystemService: async () => await this._getService((services) => services.SystemService),
3315
- TracingService: async () => await this._getService((services) => services.TracingService)
3316
- },
3498
+ handlers,
3317
3499
  port: appPort
3318
3500
  });
3319
- this._iframeRpc = createProtoRpcPeer2({
3501
+ this._shellClientRpc = createProtoRpcPeer4({
3502
+ exposed: clientServiceBundle,
3503
+ handlers,
3504
+ port: shellPort
3505
+ });
3506
+ this._iframeRpc = createProtoRpcPeer4({
3320
3507
  requested: iframeServiceBundle,
3321
3508
  exposed: workerServiceBundle,
3322
3509
  handlers: {
@@ -3330,9 +3517,9 @@ var WorkerSession = class {
3330
3517
  try {
3331
3518
  await this.close();
3332
3519
  } catch (err) {
3333
- log13.catch(err, {}, {
3520
+ log14.catch(err, {}, {
3334
3521
  file: "worker-session.ts",
3335
- line: 90,
3522
+ line: 91,
3336
3523
  scope: this,
3337
3524
  callSite: (f, a) => f(...a)
3338
3525
  });
@@ -3348,15 +3535,16 @@ var WorkerSession = class {
3348
3535
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
3349
3536
  }
3350
3537
  async open() {
3351
- log13.info("opening..", {}, {
3538
+ log14.info("opening..", {}, {
3352
3539
  file: "worker-session.ts",
3353
- line: 104,
3540
+ line: 105,
3354
3541
  scope: this,
3355
3542
  callSite: (f, a) => f(...a)
3356
3543
  });
3357
3544
  await Promise.all([
3358
3545
  this._clientRpc.open(),
3359
- this._iframeRpc.open()
3546
+ this._iframeRpc.open(),
3547
+ this._maybeOpenShell()
3360
3548
  ]);
3361
3549
  await this._startTrigger.wait({
3362
3550
  timeout: 3e3
@@ -3365,20 +3553,20 @@ var WorkerSession = class {
3365
3553
  try {
3366
3554
  await this._iframeRpc.rpc.IframeService.heartbeat();
3367
3555
  } catch (err1) {
3368
- log13.warn("Heartbeat failed", {
3556
+ log14.warn("Heartbeat failed", {
3369
3557
  err: err1
3370
3558
  }, {
3371
3559
  file: "worker-session.ts",
3372
- line: 116,
3560
+ line: 117,
3373
3561
  scope: this,
3374
3562
  callSite: (f, a) => f(...a)
3375
3563
  });
3376
3564
  try {
3377
3565
  await this.close();
3378
3566
  } catch (err) {
3379
- log13.catch(err, {}, {
3567
+ log14.catch(err, {}, {
3380
3568
  file: "worker-session.ts",
3381
- line: 120,
3569
+ line: 121,
3382
3570
  scope: this,
3383
3571
  callSite: (f, a) => f(...a)
3384
3572
  });
@@ -3387,18 +3575,18 @@ var WorkerSession = class {
3387
3575
  }, this._options.heartbeatInterval);
3388
3576
  }
3389
3577
  async close() {
3390
- log13.info("closing..", {}, {
3578
+ log14.info("closing..", {}, {
3391
3579
  file: "worker-session.ts",
3392
- line: 127,
3580
+ line: 128,
3393
3581
  scope: this,
3394
3582
  callSite: (f, a) => f(...a)
3395
3583
  });
3396
3584
  try {
3397
3585
  await this.onClose.callIfSet();
3398
3586
  } catch (err) {
3399
- log13.catch(err, {}, {
3587
+ log14.catch(err, {}, {
3400
3588
  file: "worker-session.ts",
3401
- line: 131,
3589
+ line: 132,
3402
3590
  scope: this,
3403
3591
  callSite: (f, a) => f(...a)
3404
3592
  });
@@ -3411,6 +3599,18 @@ var WorkerSession = class {
3411
3599
  this._iframeRpc.close()
3412
3600
  ]);
3413
3601
  }
3602
+ async _maybeOpenShell() {
3603
+ try {
3604
+ await asyncTimeout2(this._shellClientRpc.open(), 1e3);
3605
+ } catch (e) {
3606
+ log14.info("No shell connected.", {}, {
3607
+ file: "worker-session.ts",
3608
+ line: 146,
3609
+ scope: this,
3610
+ callSite: (f, a) => f(...a)
3611
+ });
3612
+ }
3613
+ }
3414
3614
  };
3415
3615
  __decorate3([
3416
3616
  logInfo
@@ -3426,9 +3626,9 @@ var WorkerRuntime = class {
3426
3626
  this.sessions = /* @__PURE__ */ new Set();
3427
3627
  }
3428
3628
  async start() {
3429
- log14("starting...", {}, {
3629
+ log15("starting...", {}, {
3430
3630
  file: "worker-runtime.ts",
3431
- line: 41,
3631
+ line: 42,
3432
3632
  scope: this,
3433
3633
  callSite: (f, a) => f(...a)
3434
3634
  });
@@ -3447,17 +3647,17 @@ var WorkerRuntime = class {
3447
3647
  });
3448
3648
  await this._clientServices.open();
3449
3649
  this._ready.wake(void 0);
3450
- log14("started", {}, {
3650
+ log15("started", {}, {
3451
3651
  file: "worker-runtime.ts",
3452
- line: 58,
3652
+ line: 59,
3453
3653
  scope: this,
3454
3654
  callSite: (f, a) => f(...a)
3455
3655
  });
3456
3656
  } catch (err) {
3457
3657
  this._ready.wake(err);
3458
- log14.catch(err, {}, {
3658
+ log15.catch(err, {}, {
3459
3659
  file: "worker-runtime.ts",
3460
- line: 61,
3660
+ line: 62,
3461
3661
  scope: this,
3462
3662
  callSite: (f, a) => f(...a)
3463
3663
  });
@@ -3469,7 +3669,7 @@ var WorkerRuntime = class {
3469
3669
  /**
3470
3670
  * Create a new session.
3471
3671
  */
3472
- async createSession({ appPort, systemPort }) {
3672
+ async createSession({ appPort, systemPort, shellPort }) {
3473
3673
  const session = new WorkerSession({
3474
3674
  getService: async (find) => {
3475
3675
  const error = await this._ready.wait();
@@ -3484,6 +3684,7 @@ var WorkerRuntime = class {
3484
3684
  },
3485
3685
  appPort,
3486
3686
  systemPort,
3687
+ shellPort,
3487
3688
  readySignal: this._ready
3488
3689
  });
3489
3690
  session.onClose.set(async () => {
@@ -3544,8 +3745,10 @@ var ClientServicesHost = class {
3544
3745
  // TODO(burdon): Create ApolloLink abstraction (see Client).
3545
3746
  networkManager,
3546
3747
  storage = createStorageObjects(config.get("runtime.client.storage", {})).storage,
3748
+ // TODO(wittjosiah): Turn this on by default.
3547
3749
  lockKey
3548
3750
  }) {
3751
+ this._statusUpdate = new Event7();
3549
3752
  this._open = false;
3550
3753
  this._config = config;
3551
3754
  this._modelFactory = modelFactory;
@@ -3558,23 +3761,19 @@ var ClientServicesHost = class {
3558
3761
  }) : void 0;
3559
3762
  this._systemService = new SystemServiceImpl({
3560
3763
  config: this._config,
3561
- onInit: async () => {
3562
- var _a;
3563
- await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
3564
- },
3565
- onStatus: async () => {
3566
- if (!this.isOpen) {
3567
- return {
3568
- status: Status.INACTIVE
3569
- };
3764
+ statusUpdate: this._statusUpdate,
3765
+ getCurrentStatus: () => this.isOpen ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
3766
+ onUpdateStatus: async (status) => {
3767
+ var _a, _b;
3768
+ if (!this.isOpen && status === SystemStatus.ACTIVE) {
3769
+ await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
3770
+ } else if (this.isOpen && status === SystemStatus.INACTIVE) {
3771
+ await ((_b = this._resourceLock) == null ? void 0 : _b.release());
3570
3772
  }
3571
- return {
3572
- status: Status.ACTIVE
3573
- };
3574
3773
  },
3575
3774
  onReset: async () => {
3576
- var _a;
3577
- await ((_a = this._serviceContext) == null ? void 0 : _a.reset());
3775
+ assert14(this._serviceContext, "service host is closed");
3776
+ await this._serviceContext.reset();
3578
3777
  }
3579
3778
  });
3580
3779
  this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
@@ -3591,22 +3790,23 @@ var ClientServicesHost = class {
3591
3790
  return this._serviceRegistry.services;
3592
3791
  }
3593
3792
  async open() {
3594
- var _a;
3793
+ var _a, _b;
3595
3794
  if (this._open) {
3596
3795
  return;
3597
3796
  }
3598
- log15("opening...", {}, {
3797
+ log16("opening...", {}, {
3599
3798
  file: "service-host.ts",
3600
- line: 125,
3799
+ line: 133,
3601
3800
  scope: this,
3602
3801
  callSite: (f, a) => f(...a)
3603
3802
  });
3803
+ await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
3604
3804
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
3605
3805
  this._serviceRegistry.setServices({
3606
- // TODO(burdon): Move to new protobuf definitions.
3607
3806
  SystemService: this._systemService,
3608
- HaloInvitationsService: new HaloInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.haloInvitations),
3807
+ IdentityService: new IdentityServiceImpl(this._serviceContext),
3609
3808
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
3809
+ DeviceInvitationsService: new DeviceInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.deviceInvitations),
3610
3810
  SpaceInvitationsService: new SpaceInvitationsServiceImpl(this._serviceContext.identityManager, () => {
3611
3811
  var _a2;
3612
3812
  return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : raise2(new Error("SpaceInvitations not initialized"));
@@ -3614,13 +3814,13 @@ var ClientServicesHost = class {
3614
3814
  var _a2;
3615
3815
  return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : raise2(new Error("SpaceManager not initialized"));
3616
3816
  }),
3617
- SpacesService: new SpacesServiceImpl(this._serviceContext.spaceManager),
3817
+ SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
3818
+ await this._serviceContext.initialized.wait();
3819
+ return this._serviceContext.dataSpaceManager;
3820
+ }),
3618
3821
  DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
3619
3822
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
3620
3823
  // TODO(burdon): Move to new protobuf definitions.
3621
- ProfileService: new ProfileServiceImpl(this._serviceContext),
3622
- // TODO(burdon): Port old SubscribeSpaces to QueryServices>
3623
- SpaceService: new SpaceServiceImpl(this._serviceContext),
3624
3824
  TracingService: new TracingServiceImpl(this._config),
3625
3825
  DevtoolsHost: new DevtoolsServiceImpl({
3626
3826
  events: new DevtoolsHostEvents(),
@@ -3630,12 +3830,13 @@ var ClientServicesHost = class {
3630
3830
  });
3631
3831
  await this._serviceContext.open();
3632
3832
  this._open = true;
3633
- const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
3634
- log15("opened", {
3833
+ this._statusUpdate.emit();
3834
+ const deviceKey = (_b = this._serviceContext.identityManager.identity) == null ? void 0 : _b.deviceKey;
3835
+ log16("opened", {
3635
3836
  deviceKey
3636
3837
  }, {
3637
3838
  file: "service-host.ts",
3638
- line: 172,
3839
+ line: 186,
3639
3840
  scope: this,
3640
3841
  callSite: (f, a) => f(...a)
3641
3842
  });
@@ -3646,11 +3847,11 @@ var ClientServicesHost = class {
3646
3847
  return;
3647
3848
  }
3648
3849
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
3649
- log15("closing...", {
3850
+ log16("closing...", {
3650
3851
  deviceKey
3651
3852
  }, {
3652
3853
  file: "service-host.ts",
3653
- line: 181,
3854
+ line: 195,
3654
3855
  scope: this,
3655
3856
  callSite: (f, a) => f(...a)
3656
3857
  });
@@ -3659,11 +3860,12 @@ var ClientServicesHost = class {
3659
3860
  });
3660
3861
  await this._serviceContext.close();
3661
3862
  this._open = false;
3662
- log15("closed", {
3863
+ this._statusUpdate.emit();
3864
+ log16("closed", {
3663
3865
  deviceKey
3664
3866
  }, {
3665
3867
  file: "service-host.ts",
3666
- line: 185,
3868
+ line: 200,
3667
3869
  scope: this,
3668
3870
  callSite: (f, a) => f(...a)
3669
3871
  });
@@ -3671,14 +3873,14 @@ var ClientServicesHost = class {
3671
3873
  };
3672
3874
 
3673
3875
  // packages/sdk/client-services/src/packlets/services/service-proxy.ts
3674
- import { asyncTimeout as asyncTimeout2 } from "@dxos/async";
3876
+ import { asyncTimeout as asyncTimeout3 } from "@dxos/async";
3675
3877
  import { RemoteServiceConnectionTimeout } from "@dxos/errors";
3676
- import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
3878
+ import { createProtoRpcPeer as createProtoRpcPeer5 } from "@dxos/rpc";
3677
3879
  var ClientServicesProxy = class {
3678
3880
  // prettier-ignore
3679
3881
  constructor(port, _timeout = 3e4) {
3680
3882
  this._timeout = _timeout;
3681
- this._proxy = createProtoRpcPeer3({
3883
+ this._proxy = createProtoRpcPeer5({
3682
3884
  requested: clientServiceBundle,
3683
3885
  exposed: {},
3684
3886
  handlers: {},
@@ -3695,7 +3897,7 @@ var ClientServicesProxy = class {
3695
3897
  return this._proxy.rpc;
3696
3898
  }
3697
3899
  async open() {
3698
- await asyncTimeout2(this._proxy.open(), this._timeout, new RemoteServiceConnectionTimeout());
3900
+ await asyncTimeout3(this._proxy.open(), this._timeout, new RemoteServiceConnectionTimeout());
3699
3901
  }
3700
3902
  async close() {
3701
3903
  await this._proxy.close();
@@ -3715,11 +3917,12 @@ var __decorate4 = function(decorators, target, key, desc) {
3715
3917
  };
3716
3918
  var LOCK_KEY = "DXOS_RESOURCE_LOCK";
3717
3919
  var IFrameHostRuntime = class {
3718
- constructor({ configProvider, appPort }) {
3920
+ constructor({ configProvider, appPort, shellPort }) {
3719
3921
  this._transportFactory = createWebRTCTransportFactory();
3720
3922
  this._ready = new Trigger9();
3721
3923
  this._configProvider = configProvider;
3722
3924
  this._appPort = appPort;
3925
+ this._shellPort = shellPort;
3723
3926
  this._getService = async (find) => {
3724
3927
  const error = await this._ready.wait();
3725
3928
  if (error) {
@@ -3731,16 +3934,26 @@ var IFrameHostRuntime = class {
3731
3934
  }
3732
3935
  return service;
3733
3936
  };
3937
+ if (this._shellPort) {
3938
+ this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3939
+ }
3940
+ }
3941
+ get services() {
3942
+ return this._clientServices;
3943
+ }
3944
+ get shell() {
3945
+ return this._shellRuntime;
3734
3946
  }
3735
3947
  async start() {
3736
- log16("starting...", {}, {
3948
+ var _a;
3949
+ log17("starting...", {}, {
3737
3950
  file: "iframe-host-runtime.ts",
3738
- line: 63,
3951
+ line: 81,
3739
3952
  scope: this,
3740
3953
  callSite: (f, a) => f(...a)
3741
3954
  });
3742
3955
  try {
3743
- this._config = await this._configProvider();
3956
+ this._config = await getAsyncValue(this._configProvider);
3744
3957
  const signalServer = this._config.get("runtime.services.signal.server");
3745
3958
  this._clientServices = new ClientServicesHost({
3746
3959
  lockKey: LOCK_KEY,
@@ -3753,17 +3966,16 @@ var IFrameHostRuntime = class {
3753
3966
  transportFactory: this._transportFactory
3754
3967
  })
3755
3968
  });
3756
- this._clientRpc = createProtoRpcPeer4({
3969
+ this._clientRpc = createProtoRpcPeer6({
3757
3970
  exposed: clientServiceBundle,
3758
3971
  handlers: {
3759
3972
  DataService: async () => await this._getService((services) => services.DataService),
3973
+ DeviceInvitationsService: async () => await this._getService((services) => services.DeviceInvitationsService),
3760
3974
  DevicesService: async () => await this._getService((services) => services.DevicesService),
3761
3975
  DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
3762
- HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
3763
3976
  NetworkService: async () => await this._getService((services) => services.NetworkService),
3764
- ProfileService: async () => await this._getService((services) => services.ProfileService),
3977
+ IdentityService: async () => await this._getService((services) => services.IdentityService),
3765
3978
  SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
3766
- SpaceService: async () => await this._getService((services) => services.SpaceService),
3767
3979
  SpacesService: async () => await this._getService((services) => services.SpacesService),
3768
3980
  SystemService: async () => await this._getService((services) => services.SystemService),
3769
3981
  TracingService: async () => await this._getService((services) => services.TracingService)
@@ -3772,37 +3984,40 @@ var IFrameHostRuntime = class {
3772
3984
  });
3773
3985
  await Promise.all([
3774
3986
  this._clientServices.open(),
3775
- this._clientRpc.open()
3987
+ this._clientRpc.open(),
3988
+ (_a = this._shellRuntime) == null ? void 0 : _a.open()
3776
3989
  ]);
3777
3990
  this._ready.wake(void 0);
3778
- log16("started", {}, {
3991
+ log17("started", {}, {
3779
3992
  file: "iframe-host-runtime.ts",
3780
- line: 99,
3993
+ line: 116,
3781
3994
  scope: this,
3782
3995
  callSite: (f, a) => f(...a)
3783
3996
  });
3784
3997
  } catch (err) {
3785
3998
  this._ready.wake(err);
3786
- log16.catch(err, {}, {
3999
+ log17.catch(err, {}, {
3787
4000
  file: "iframe-host-runtime.ts",
3788
- line: 102,
4001
+ line: 119,
3789
4002
  scope: this,
3790
4003
  callSite: (f, a) => f(...a)
3791
4004
  });
3792
4005
  }
3793
4006
  }
3794
4007
  async stop() {
3795
- log16("stopping...", {}, {
4008
+ var _a;
4009
+ log17("stopping...", {}, {
3796
4010
  file: "iframe-host-runtime.ts",
3797
- line: 107,
4011
+ line: 124,
3798
4012
  scope: this,
3799
4013
  callSite: (f, a) => f(...a)
3800
4014
  });
3801
4015
  await this._clientRpc.close();
3802
4016
  await this._clientServices.close();
3803
- log16("stopped", {}, {
4017
+ await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
4018
+ log17("stopped", {}, {
3804
4019
  file: "iframe-host-runtime.ts",
3805
- line: 110,
4020
+ line: 128,
3806
4021
  scope: this,
3807
4022
  callSite: (f, a) => f(...a)
3808
4023
  });
@@ -3813,10 +4028,6 @@ __decorate4([
3813
4028
  ], IFrameHostRuntime.prototype, "origin", void 0);
3814
4029
 
3815
4030
  export {
3816
- SpaceServiceImpl,
3817
- ProfileServiceImpl,
3818
- SystemServiceImpl,
3819
- TracingServiceImpl,
3820
4031
  subscribeToFeeds,
3821
4032
  subscribeToFeedBlocks,
3822
4033
  subscribeToNetworkStatus,
@@ -3831,6 +4042,7 @@ export {
3831
4042
  TrustedKeySetAuthVerifier,
3832
4043
  Identity,
3833
4044
  IdentityManager,
4045
+ IdentityServiceImpl,
3834
4046
  InvitationEncoder,
3835
4047
  AUTHENTICATION_CODE_LENGTH,
3836
4048
  INVITATION_TIMEOUT,
@@ -3839,21 +4051,26 @@ export {
3839
4051
  AuthenticatingInvitationProvider,
3840
4052
  wrapObservable,
3841
4053
  AbstractInvitationsHandler,
3842
- HaloInvitationsHandler,
4054
+ DeviceInvitationsHandler,
3843
4055
  AbstractInvitationsProxy,
3844
- HaloInvitationsProxy,
4056
+ DeviceInvitationsProxy,
3845
4057
  AbstractInvitationsService,
3846
- HaloInvitationsServiceImpl,
4058
+ DeviceInvitationsServiceImpl,
3847
4059
  SpaceInvitationsHandler,
3848
4060
  SpaceInvitationsProxy,
3849
4061
  SpaceInvitationsServiceImpl,
3850
4062
  ServiceContext,
3851
4063
  clientServiceBundle,
3852
4064
  createStorageObjects,
3853
- IFrameHostRuntime,
3854
4065
  iframeServiceBundle,
3855
4066
  workerServiceBundle,
4067
+ appServiceBundle,
4068
+ shellServiceBundle,
4069
+ ShellRuntimeImpl,
4070
+ MemoryShellRuntime,
4071
+ IFrameHostRuntime,
3856
4072
  IFrameProxyRuntime,
4073
+ ShellController,
3857
4074
  VaultResourceLock,
3858
4075
  WorkerSession,
3859
4076
  WorkerRuntime,
@@ -3862,4 +4079,4 @@ export {
3862
4079
  ClientServicesHost,
3863
4080
  ClientServicesProxy
3864
4081
  };
3865
- //# sourceMappingURL=chunk-R2FEBB66.mjs.map
4082
+ //# sourceMappingURL=chunk-OTSGRZZI.mjs.map