@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
@@ -0,0 +1,121 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import assert from 'node:assert';
6
+
7
+ import { Event } from '@dxos/async';
8
+ import { PublicKey } from '@dxos/keys';
9
+ import { AppContextRequest, LayoutRequest, ShellLayout } from '@dxos/protocols/proto/dxos/iframe';
10
+ import { createProtoRpcPeer, ProtoRpcPeer, RpcPort } from '@dxos/rpc';
11
+
12
+ import { AppServiceBundle, appServiceBundle, shellServiceBundle } from './services';
13
+
14
+ export interface ShellRuntime {
15
+ layoutUpdate: Event<LayoutRequest>;
16
+ layout: ShellLayout;
17
+ invitationCode?: string;
18
+ spaceKey?: PublicKey;
19
+ setLayout: (layout: ShellLayout, options?: Omit<LayoutRequest, 'layout'>) => void;
20
+ setAppContext: (context: AppContextRequest) => Promise<void>;
21
+ }
22
+
23
+ /**
24
+ * Endpoint that handles shell services.
25
+ */
26
+ export class ShellRuntimeImpl implements ShellRuntime {
27
+ readonly layoutUpdate = new Event<LayoutRequest>();
28
+ private _appRpc?: ProtoRpcPeer<AppServiceBundle>;
29
+ private _layout = ShellLayout.DEFAULT;
30
+ private _invitationCode?: string;
31
+ private _spaceKey?: PublicKey;
32
+
33
+ constructor(private readonly _port: RpcPort) {}
34
+
35
+ get layout() {
36
+ return this._layout;
37
+ }
38
+
39
+ get invitationCode() {
40
+ return this._invitationCode;
41
+ }
42
+
43
+ get spaceKey() {
44
+ return this._spaceKey;
45
+ }
46
+
47
+ setLayout(layout: ShellLayout, options: Omit<LayoutRequest, 'layout'> = {}) {
48
+ this._layout = layout;
49
+ this._invitationCode = options.invitationCode;
50
+ this._spaceKey = options.spaceKey;
51
+ this.layoutUpdate.emit({ layout, ...options });
52
+ }
53
+
54
+ async setAppContext(context: AppContextRequest) {
55
+ assert(this._appRpc, 'runtime not open');
56
+
57
+ await this._appRpc.rpc.AppService.setContext(context);
58
+ }
59
+
60
+ async open() {
61
+ this._appRpc = createProtoRpcPeer({
62
+ requested: appServiceBundle,
63
+ exposed: shellServiceBundle,
64
+ handlers: {
65
+ ShellService: {
66
+ setLayout: async (request) => {
67
+ this._layout = request.layout;
68
+ this._invitationCode = request.invitationCode;
69
+ this._spaceKey = request.spaceKey;
70
+ this.layoutUpdate.emit(request);
71
+ }
72
+ }
73
+ },
74
+ port: this._port
75
+ });
76
+
77
+ await this._appRpc.open();
78
+ }
79
+
80
+ async close() {
81
+ await this._appRpc?.close();
82
+ this._appRpc = undefined;
83
+ }
84
+ }
85
+
86
+ export class MemoryShellRuntime implements ShellRuntime {
87
+ readonly layoutUpdate = new Event<LayoutRequest>();
88
+ readonly contextUpdate = new Event<AppContextRequest>();
89
+ private _layout: ShellLayout;
90
+ private _invitationCode?: string;
91
+ private _spaceKey?: PublicKey;
92
+
93
+ constructor({ layout, invitationCode, spaceKey }: Partial<LayoutRequest> & Partial<AppContextRequest> = {}) {
94
+ this._layout = layout ?? ShellLayout.DEFAULT;
95
+ this._invitationCode = invitationCode;
96
+ this._spaceKey = spaceKey;
97
+ }
98
+
99
+ get layout() {
100
+ return this._layout;
101
+ }
102
+
103
+ get invitationCode() {
104
+ return this._invitationCode;
105
+ }
106
+
107
+ get spaceKey() {
108
+ return this._spaceKey;
109
+ }
110
+
111
+ setLayout(layout: ShellLayout, options: Omit<LayoutRequest, 'layout'> = {}) {
112
+ this._layout = layout;
113
+ this._invitationCode = options.invitationCode;
114
+ this._spaceKey = options.spaceKey;
115
+ this.layoutUpdate.emit({ layout, ...options });
116
+ }
117
+
118
+ async setAppContext(context: AppContextRequest) {
119
+ this.contextUpdate.emit(context);
120
+ }
121
+ }
@@ -17,6 +17,7 @@ import { WorkerSession } from './worker-session';
17
17
  export type CreateSessionParams = {
18
18
  appPort: RpcPort;
19
19
  systemPort: RpcPort;
20
+ shellPort: RpcPort;
20
21
  };
21
22
 
22
23
  /**
@@ -70,7 +71,7 @@ export class WorkerRuntime {
70
71
  /**
71
72
  * Create a new session.
72
73
  */
73
- async createSession({ appPort, systemPort }: CreateSessionParams) {
74
+ async createSession({ appPort, systemPort, shellPort }: CreateSessionParams) {
74
75
  const session = new WorkerSession({
75
76
  getService: async (find) => {
76
77
  const error = await this._ready.wait();
@@ -87,6 +88,7 @@ export class WorkerRuntime {
87
88
  },
88
89
  appPort,
89
90
  systemPort,
91
+ shellPort,
90
92
  readySignal: this._ready
91
93
  });
92
94
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  import assert from 'node:assert';
6
6
 
7
- import { Trigger } from '@dxos/async';
7
+ import { asyncTimeout, Trigger } from '@dxos/async';
8
8
  import { log, logInfo } from '@dxos/log';
9
9
  import { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
10
10
  import { createProtoRpcPeer, ProtoRpcPeer, RpcPort } from '@dxos/rpc';
@@ -17,6 +17,7 @@ export type WorkerSessionParams = {
17
17
  getService: <Service>(find: (services: Partial<ClientServices>) => Service | undefined) => Promise<Service>;
18
18
  systemPort: RpcPort;
19
19
  appPort: RpcPort;
20
+ shellPort: RpcPort;
20
21
  readySignal: Trigger<Error | undefined>;
21
22
  options?: {
22
23
  heartbeatInterval: number;
@@ -28,6 +29,7 @@ export type WorkerSessionParams = {
28
29
  */
29
30
  export class WorkerSession {
30
31
  private readonly _clientRpc: ProtoRpcPeer<ClientServices>;
32
+ private readonly _shellClientRpc: ProtoRpcPeer<ClientServices>;
31
33
  private readonly _iframeRpc: ProtoRpcPeer<IframeServiceBundle>;
32
34
  private readonly _startTrigger = new Trigger();
33
35
  private readonly _getService: WorkerSessionParams['getService'];
@@ -45,6 +47,7 @@ export class WorkerSession {
45
47
  getService,
46
48
  systemPort,
47
49
  appPort,
50
+ shellPort,
48
51
  options = {
49
52
  heartbeatInterval: 1_000
50
53
  }
@@ -54,23 +57,21 @@ export class WorkerSession {
54
57
  this._options = options;
55
58
  this._getService = getService;
56
59
 
57
- this._clientRpc = createProtoRpcPeer({
58
- exposed: clientServiceBundle,
59
- handlers: {
60
- DataService: async () => await this._getService((services) => services.DataService),
61
- DevicesService: async () => await this._getService((services) => services.DevicesService),
62
- DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
63
- HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
64
- NetworkService: async () => await this._getService((services) => services.NetworkService),
65
- ProfileService: async () => await this._getService((services) => services.ProfileService),
66
- SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
67
- SpaceService: async () => await this._getService((services) => services.SpaceService),
68
- SpacesService: async () => await this._getService((services) => services.SpacesService),
69
- SystemService: async () => await this._getService((services) => services.SystemService),
70
- TracingService: async () => await this._getService((services) => services.TracingService)
71
- },
72
- port: appPort
73
- });
60
+ const handlers = {
61
+ DataService: () => this._getService((services) => services.DataService),
62
+ DeviceInvitationsService: () => this._getService((services) => services.DeviceInvitationsService),
63
+ DevicesService: () => this._getService((services) => services.DevicesService),
64
+ DevtoolsHost: () => this._getService((services) => services.DevtoolsHost),
65
+ NetworkService: () => this._getService((services) => services.NetworkService),
66
+ IdentityService: () => this._getService((services) => services.IdentityService),
67
+ SpaceInvitationsService: () => this._getService((services) => services.SpaceInvitationsService),
68
+ SpacesService: () => this._getService((services) => services.SpacesService),
69
+ SystemService: () => this._getService((services) => services.SystemService),
70
+ TracingService: () => this._getService((services) => services.TracingService)
71
+ };
72
+
73
+ this._clientRpc = createProtoRpcPeer({ exposed: clientServiceBundle, handlers, port: appPort });
74
+ this._shellClientRpc = createProtoRpcPeer({ exposed: clientServiceBundle, handlers, port: shellPort });
74
75
 
75
76
  this._iframeRpc = createProtoRpcPeer({
76
77
  requested: iframeServiceBundle,
@@ -102,7 +103,7 @@ export class WorkerSession {
102
103
 
103
104
  async open() {
104
105
  log.info('opening..');
105
- await Promise.all([this._clientRpc.open(), this._iframeRpc.open()]);
106
+ await Promise.all([this._clientRpc.open(), this._iframeRpc.open(), this._maybeOpenShell()]);
106
107
 
107
108
  await this._startTrigger.wait({ timeout: 3_000 });
108
109
 
@@ -137,4 +138,12 @@ export class WorkerSession {
137
138
 
138
139
  await Promise.all([this._clientRpc.close(), this._iframeRpc.close()]);
139
140
  }
141
+
142
+ private async _maybeOpenShell() {
143
+ try {
144
+ await asyncTimeout(this._shellClientRpc.open(), 1_000);
145
+ } catch {
146
+ log.info('No shell connected.');
147
+ }
148
+ }
140
149
  }