@dxos/client-services 0.4.10-main.3e0c8a5 → 0.4.10-main.3f5e2d2
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.
- package/dist/lib/browser/{chunk-6GHZYBUW.mjs → chunk-HIQTBJPW.mjs} +1452 -1145
- package/dist/lib/browser/chunk-HIQTBJPW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -6
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +141 -119
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-D5VK6MZQ.cjs → chunk-JGUWA36I.cjs} +1349 -1126
- package/dist/lib/node/chunk-JGUWA36I.cjs.map +7 -0
- package/dist/lib/node/index.cjs +55 -41
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +139 -120
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +15 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -0
- package/dist/types/src/packlets/{services → diagnostics}/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts +4 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +3 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts +1 -0
- package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts +1 -0
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +6 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +8 -4
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +44 -0
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +7 -23
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +1 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +12 -10
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +5 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +1 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +8 -3
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +4 -3
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/index.d.ts +1 -0
- package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts +4 -0
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/util.d.ts +4 -0
- package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +10 -4
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -34
- package/src/index.ts +1 -0
- package/src/packlets/devices/devices-service.test.ts +1 -1
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
- package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
- package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
- package/src/packlets/diagnostics/index.ts +7 -0
- package/src/packlets/identity/identity-manager.ts +1 -0
- package/src/packlets/identity/identity-service.test.ts +1 -1
- package/src/packlets/identity/identity.test.ts +3 -0
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -1
- package/src/packlets/invitations/index.ts +1 -0
- package/src/packlets/invitations/invitation-extension.ts +28 -1
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitations-handler.ts +75 -96
- package/src/packlets/invitations/invitations-manager.ts +271 -0
- package/src/packlets/invitations/invitations-service.ts +23 -168
- package/src/packlets/invitations/space-invitation-protocol.ts +45 -3
- package/src/packlets/network/network-service.test.ts +1 -1
- package/src/packlets/services/automerge-host.test.ts +13 -7
- package/src/packlets/services/index.ts +1 -1
- package/src/packlets/services/service-context.test.ts +9 -6
- package/src/packlets/services/service-context.ts +31 -26
- package/src/packlets/services/service-host.test.ts +6 -0
- package/src/packlets/services/service-host.ts +48 -32
- package/src/packlets/services/service-registry.test.ts +1 -1
- package/src/packlets/services/util.ts +2 -0
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/spaces/data-space-manager.ts +56 -13
- package/src/packlets/spaces/data-space.ts +14 -19
- package/src/packlets/spaces/spaces-service.test.ts +1 -1
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/level.ts +19 -0
- package/src/packlets/storage/storage.ts +3 -9
- package/src/packlets/storage/util.ts +19 -0
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/invitation-utils.ts +100 -97
- package/src/packlets/testing/test-builder.ts +40 -9
- package/src/packlets/vault/worker-runtime.ts +3 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-6GHZYBUW.mjs.map +0 -7
- package/dist/lib/node/chunk-D5VK6MZQ.cjs.map +0 -7
- package/dist/types/src/packlets/indexing/index.d.ts +0 -2
- package/dist/types/src/packlets/indexing/index.d.ts.map +0 -1
- package/dist/types/src/packlets/indexing/util.d.ts +0 -15
- package/dist/types/src/packlets/indexing/util.d.ts.map +0 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
- package/src/packlets/indexing/index.ts +0 -5
- package/src/packlets/indexing/util.ts +0 -89
|
@@ -30,7 +30,7 @@ __export(testing_exports, {
|
|
|
30
30
|
sanitizeInvitation: () => sanitizeInvitation
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(testing_exports);
|
|
33
|
-
var
|
|
33
|
+
var import_chunk_JGUWA36I = require("../../chunk-JGUWA36I.cjs");
|
|
34
34
|
var import_credentials = require("@dxos/credentials");
|
|
35
35
|
var import_keys = require("@dxos/keys");
|
|
36
36
|
var import_async = require("@dxos/async");
|
|
@@ -40,11 +40,14 @@ var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
40
40
|
var import_context = require("@dxos/context");
|
|
41
41
|
var import_credentials2 = require("@dxos/credentials");
|
|
42
42
|
var import_debug = require("@dxos/debug");
|
|
43
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
43
44
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
45
|
+
var import_testing = require("@dxos/echo-pipeline/testing");
|
|
44
46
|
var import_feed_store = require("@dxos/feed-store");
|
|
45
47
|
var import_keyring = require("@dxos/keyring");
|
|
46
48
|
var import_messaging = require("@dxos/messaging");
|
|
47
49
|
var import_network_manager = require("@dxos/network-manager");
|
|
50
|
+
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
48
51
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
49
52
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
50
53
|
var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.createCredential)({
|
|
@@ -67,134 +70,135 @@ var performInvitation = ({ host, guest, options, hooks, guestDeviceProfile }) =>
|
|
|
67
70
|
const hostComplete = new import_async.Trigger();
|
|
68
71
|
const guestComplete = new import_async.Trigger();
|
|
69
72
|
const authCode = new import_async.Trigger();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
void createInvitation(host, options).then((hostObservable) => {
|
|
74
|
+
hostObservable.subscribe(async (hostInvitation) => {
|
|
75
|
+
switch (hostInvitation.state) {
|
|
76
|
+
case import_services.Invitation.State.CONNECTING: {
|
|
77
|
+
if (hooks?.host?.onConnecting?.(hostObservable)) {
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
const guestObservable = acceptInvitation(guest, hostInvitation, guestDeviceProfile);
|
|
81
|
+
guestObservable.subscribe(async (guestInvitation) => {
|
|
82
|
+
switch (guestInvitation.state) {
|
|
83
|
+
case import_services.Invitation.State.CONNECTING: {
|
|
84
|
+
if (hooks?.guest?.onConnecting?.(guestObservable)) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
(0, import_invariant.invariant)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey), void 0, {
|
|
88
|
+
F: __dxlog_file,
|
|
89
|
+
L: 79,
|
|
90
|
+
S: void 0,
|
|
91
|
+
A: [
|
|
92
|
+
"hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!)",
|
|
93
|
+
""
|
|
94
|
+
]
|
|
95
|
+
});
|
|
82
96
|
break;
|
|
83
97
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
L: 79,
|
|
87
|
-
S: void 0,
|
|
88
|
-
A: [
|
|
89
|
-
"hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!)",
|
|
90
|
-
""
|
|
91
|
-
]
|
|
92
|
-
});
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case import_services.Invitation.State.CONNECTED: {
|
|
96
|
-
hooks?.guest?.onConnected?.(guestObservable);
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
case import_services.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
100
|
-
if (hooks?.guest?.onReady?.(guestObservable)) {
|
|
98
|
+
case import_services.Invitation.State.CONNECTED: {
|
|
99
|
+
hooks?.guest?.onConnected?.(guestObservable);
|
|
101
100
|
break;
|
|
102
101
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
case import_services.Invitation.State.SUCCESS: {
|
|
111
|
-
if (hooks?.guest?.onSuccess?.(guestObservable)) {
|
|
102
|
+
case import_services.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
103
|
+
if (hooks?.guest?.onReady?.(guestObservable)) {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
await guestObservable.authenticate(await authCode.wait());
|
|
112
107
|
break;
|
|
113
108
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
case import_services.Invitation.State.CANCELLED: {
|
|
120
|
-
if (hooks?.guest?.onCancelled?.(guestObservable)) {
|
|
109
|
+
case import_services.Invitation.State.AUTHENTICATING: {
|
|
110
|
+
hooks?.guest?.onAuthenticating?.(guestObservable);
|
|
121
111
|
break;
|
|
122
112
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
113
|
+
case import_services.Invitation.State.SUCCESS: {
|
|
114
|
+
if (hooks?.guest?.onSuccess?.(guestObservable)) {
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
guestComplete.wake({
|
|
118
|
+
invitation: guestInvitation
|
|
119
|
+
});
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case import_services.Invitation.State.CANCELLED: {
|
|
123
|
+
if (hooks?.guest?.onCancelled?.(guestObservable)) {
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
guestComplete.wake({
|
|
127
|
+
invitation: guestInvitation
|
|
128
|
+
});
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case import_services.Invitation.State.TIMEOUT: {
|
|
132
|
+
if (hooks?.guest?.onTimeout?.(guestObservable)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
guestComplete.wake({
|
|
136
|
+
invitation: guestInvitation
|
|
137
|
+
});
|
|
131
138
|
}
|
|
132
|
-
guestComplete.wake({
|
|
133
|
-
invitation: guestInvitation
|
|
134
|
-
});
|
|
135
139
|
}
|
|
140
|
+
}, (error) => {
|
|
141
|
+
if (hooks?.guest?.onError?.(guestObservable)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
guestComplete.wake({
|
|
145
|
+
error
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
case import_services.Invitation.State.CONNECTED: {
|
|
151
|
+
hooks?.host?.onConnected?.(hostObservable);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case import_services.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
155
|
+
if (hooks?.host?.onReady?.(hostObservable)) {
|
|
156
|
+
break;
|
|
136
157
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return;
|
|
158
|
+
if (hostInvitation.authCode) {
|
|
159
|
+
authCode.wake(hostInvitation.authCode);
|
|
140
160
|
}
|
|
141
|
-
guestComplete.wake({
|
|
142
|
-
error
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case import_services.Invitation.State.CONNECTED: {
|
|
148
|
-
hooks?.host?.onConnected?.(hostObservable);
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
case import_services.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
152
|
-
if (hooks?.host?.onReady?.(hostObservable)) {
|
|
153
161
|
break;
|
|
154
162
|
}
|
|
155
|
-
|
|
156
|
-
|
|
163
|
+
case import_services.Invitation.State.AUTHENTICATING: {
|
|
164
|
+
hooks?.host?.onAuthenticating?.(hostObservable);
|
|
165
|
+
break;
|
|
157
166
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (hooks?.host?.onSuccess?.(hostObservable)) {
|
|
167
|
+
case import_services.Invitation.State.SUCCESS: {
|
|
168
|
+
if (hooks?.host?.onSuccess?.(hostObservable)) {
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
hostComplete.wake({
|
|
172
|
+
invitation: hostInvitation
|
|
173
|
+
});
|
|
166
174
|
break;
|
|
167
175
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
case import_services.Invitation.State.CANCELLED: {
|
|
177
|
+
if (hooks?.host?.onCancelled?.(hostObservable)) {
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
hostComplete.wake({
|
|
181
|
+
invitation: hostInvitation
|
|
182
|
+
});
|
|
175
183
|
break;
|
|
176
184
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
case import_services.Invitation.State.TIMEOUT: {
|
|
186
|
+
if (hooks?.host?.onTimeout?.(hostObservable)) {
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
hostComplete.wake({
|
|
190
|
+
invitation: hostInvitation
|
|
191
|
+
});
|
|
184
192
|
break;
|
|
185
193
|
}
|
|
186
|
-
hostComplete.wake({
|
|
187
|
-
invitation: hostInvitation
|
|
188
|
-
});
|
|
189
|
-
break;
|
|
190
194
|
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
}, (error) => {
|
|
196
|
+
if (hooks?.host?.onError?.(hostObservable)) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
hostComplete.wake({
|
|
200
|
+
error
|
|
201
|
+
});
|
|
198
202
|
});
|
|
199
203
|
});
|
|
200
204
|
return [
|
|
@@ -202,23 +206,22 @@ var performInvitation = ({ host, guest, options, hooks, guestDeviceProfile }) =>
|
|
|
202
206
|
guestComplete.wait()
|
|
203
207
|
];
|
|
204
208
|
};
|
|
205
|
-
var createInvitation = (host, options) => {
|
|
209
|
+
var createInvitation = async (host, options) => {
|
|
206
210
|
options ??= {
|
|
207
211
|
authMethod: import_services.Invitation.AuthMethod.NONE,
|
|
208
212
|
...options ?? {}
|
|
209
213
|
};
|
|
210
|
-
if (host instanceof
|
|
211
|
-
|
|
214
|
+
if (host instanceof import_chunk_JGUWA36I.ServiceContext) {
|
|
215
|
+
return host.invitationsManager.createInvitation({
|
|
212
216
|
kind: import_services.Invitation.Kind.SPACE,
|
|
213
217
|
...options
|
|
214
218
|
});
|
|
215
|
-
return host.invitations.createInvitation(hostHandler, options);
|
|
216
219
|
}
|
|
217
220
|
return host.share(options);
|
|
218
221
|
};
|
|
219
222
|
var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
220
223
|
invitation = sanitizeInvitation(invitation);
|
|
221
|
-
if (guest instanceof
|
|
224
|
+
if (guest instanceof import_chunk_JGUWA36I.ServiceContext) {
|
|
222
225
|
const guestHandler = guest.getInvitationHandler({
|
|
223
226
|
kind: invitation.kind
|
|
224
227
|
});
|
|
@@ -227,13 +230,13 @@ var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
|
227
230
|
return guest.join(invitation, guestDeviceProfile);
|
|
228
231
|
};
|
|
229
232
|
var createServiceHost = (config, signalManagerContext) => {
|
|
230
|
-
return new
|
|
233
|
+
return new import_chunk_JGUWA36I.ClientServicesHost({
|
|
231
234
|
config,
|
|
232
235
|
signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
|
|
233
236
|
transportFactory: import_network_manager.MemoryTransportFactory
|
|
234
237
|
});
|
|
235
238
|
};
|
|
236
|
-
var createServiceContext = ({ signalContext = new import_messaging.MemorySignalManagerContext(), storage = (0, import_random_access_storage.createStorage)({
|
|
239
|
+
var createServiceContext = async ({ signalContext = new import_messaging.MemorySignalManagerContext(), storage = (0, import_random_access_storage.createStorage)({
|
|
237
240
|
type: import_random_access_storage.StorageType.RAM
|
|
238
241
|
}) } = {}) => {
|
|
239
242
|
const signalManager = new import_messaging.MemorySignalManager(signalContext);
|
|
@@ -241,12 +244,14 @@ var createServiceContext = ({ signalContext = new import_messaging.MemorySignalM
|
|
|
241
244
|
signalManager,
|
|
242
245
|
transportFactory: import_network_manager.MemoryTransportFactory
|
|
243
246
|
});
|
|
244
|
-
|
|
247
|
+
const level = (0, import_testing.createTestLevel)();
|
|
248
|
+
await level.open();
|
|
249
|
+
return new import_chunk_JGUWA36I.ServiceContext(storage, level, networkManager, signalManager);
|
|
245
250
|
};
|
|
246
251
|
var createPeers = async (numPeers) => {
|
|
247
252
|
const signalContext = new import_messaging.MemorySignalManagerContext();
|
|
248
253
|
return await Promise.all(Array.from(Array(numPeers)).map(async () => {
|
|
249
|
-
const peer = createServiceContext({
|
|
254
|
+
const peer = await createServiceContext({
|
|
250
255
|
signalContext
|
|
251
256
|
});
|
|
252
257
|
await peer.open(new import_context.Context());
|
|
@@ -290,6 +295,9 @@ var TestPeer = class {
|
|
|
290
295
|
get keyring() {
|
|
291
296
|
return this._props.keyring ??= new import_keyring.Keyring(this.storage.createDirectory("keyring"));
|
|
292
297
|
}
|
|
298
|
+
get level() {
|
|
299
|
+
return this._props.level ??= (0, import_testing.createTestLevel)();
|
|
300
|
+
}
|
|
293
301
|
get feedStore() {
|
|
294
302
|
return this._props.feedStore ??= new import_feed_store.FeedStore({
|
|
295
303
|
factory: new import_feed_store.FeedFactory({
|
|
@@ -328,18 +336,29 @@ var TestPeer = class {
|
|
|
328
336
|
get identity() {
|
|
329
337
|
return this._props.signingContext ?? (0, import_debug.failUndefined)();
|
|
330
338
|
}
|
|
331
|
-
get
|
|
332
|
-
return this._props.
|
|
333
|
-
|
|
339
|
+
get echoHost() {
|
|
340
|
+
return this._props.echoHost ??= new import_echo_db.EchoHost({
|
|
341
|
+
kv: this.level,
|
|
342
|
+
storage: this.storage
|
|
334
343
|
});
|
|
335
344
|
}
|
|
336
345
|
get dataSpaceManager() {
|
|
337
|
-
return this._props.dataSpaceManager ??= new
|
|
346
|
+
return this._props.dataSpaceManager ??= new import_chunk_JGUWA36I.DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, this.identity, this.feedStore, this.echoHost, this.invitationsManager);
|
|
347
|
+
}
|
|
348
|
+
get invitationsManager() {
|
|
349
|
+
return this._props.invitationsManager ??= new import_chunk_JGUWA36I.InvitationsManager(new import_chunk_JGUWA36I.InvitationsHandler(this.networkManager), (invitation) => {
|
|
350
|
+
if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
|
|
351
|
+
return new import_chunk_JGUWA36I.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
|
|
352
|
+
} else {
|
|
353
|
+
throw new Error("not implemented");
|
|
354
|
+
}
|
|
355
|
+
}, this.metadataStore);
|
|
338
356
|
}
|
|
339
357
|
async createIdentity() {
|
|
340
358
|
this._props.signingContext ??= await createSigningContext(this.keyring);
|
|
341
359
|
}
|
|
342
360
|
async destroy() {
|
|
361
|
+
await this.level.close();
|
|
343
362
|
await this.storage.reset();
|
|
344
363
|
}
|
|
345
364
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/packlets/testing/credential-utils.ts", "../../../../../src/packlets/testing/invitation-utils.ts", "../../../../../src/packlets/testing/test-builder.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { createCredential } from '@dxos/credentials';\nimport { type Signer } from '@dxos/crypto';\nimport { PublicKey } from '@dxos/keys';\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nexport const createMockCredential = async ({\n signer,\n issuer,\n}: {\n signer: Signer;\n issuer: PublicKey;\n}): Promise<Credential> =>\n createCredential({\n signer,\n issuer,\n subject: new PublicKey(Buffer.from('test')),\n assertion: {\n '@type': 'example.testing.rpc.MessageWithAny',\n payload: {\n '@type': 'google.protobuf.Any',\n value: Buffer.from('test'),\n },\n },\n });\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Trigger } from '@dxos/async';\nimport { InvitationEncoder, type AuthenticatingInvitation, type CancellableInvitation } from '@dxos/client-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\nimport { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nimport { ServiceContext } from '../services';\n\n/**\n * Strip secrets from invitation before giving it to the peer.\n */\nexport const sanitizeInvitation = (invitation: Invitation): Invitation => {\n return InvitationEncoder.decode(InvitationEncoder.encode(invitation));\n};\n\nexport type InvitationHost = {\n share(options?: Partial<Invitation>): CancellableInvitation;\n};\n\nexport type InvitationGuest = {\n join(invitation: Invitation | string, deviceProfile?: DeviceProfileDocument): AuthenticatingInvitation;\n};\n\nexport type PerformInvitationCallbacks<T> = {\n onConnecting?: (value: T) => boolean | void;\n onConnected?: (value: T) => boolean | void;\n onReady?: (value: T) => boolean | void;\n onAuthenticating?: (value: T) => boolean | void;\n onSuccess?: (value: T) => boolean | void;\n onCancelled?: (value: T) => boolean | void;\n onTimeout?: (value: T) => boolean | void;\n onError?: (value: T) => boolean | void;\n};\n\nexport type PerformInvitationParams = {\n host: ServiceContext | InvitationHost;\n guest: ServiceContext | InvitationGuest;\n options?: Partial<Invitation>;\n hooks?: {\n host?: PerformInvitationCallbacks<CancellableInvitation>;\n guest?: PerformInvitationCallbacks<AuthenticatingInvitation>;\n };\n guestDeviceProfile?: DeviceProfileDocument;\n};\n\nexport type Result = { invitation?: Invitation; error?: Error };\n\nexport const performInvitation = ({\n host,\n guest,\n options,\n hooks,\n guestDeviceProfile,\n}: PerformInvitationParams): [Promise<Result>, Promise<Result>] => {\n const hostComplete = new Trigger<Result>();\n const guestComplete = new Trigger<Result>();\n const authCode = new Trigger<string>();\n\n const hostObservable = createInvitation(host, options);\n hostObservable.subscribe(\n async (hostInvitation: Invitation) => {\n switch (hostInvitation.state) {\n case Invitation.State.CONNECTING: {\n if (hooks?.host?.onConnecting?.(hostObservable)) {\n break;\n }\n const guestObservable = acceptInvitation(guest, hostInvitation, guestDeviceProfile);\n guestObservable.subscribe(\n async (guestInvitation: Invitation) => {\n switch (guestInvitation.state) {\n case Invitation.State.CONNECTING: {\n if (hooks?.guest?.onConnecting?.(guestObservable)) {\n break;\n }\n invariant(hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!));\n break;\n }\n\n case Invitation.State.CONNECTED: {\n hooks?.guest?.onConnected?.(guestObservable);\n break;\n }\n\n case Invitation.State.READY_FOR_AUTHENTICATION: {\n if (hooks?.guest?.onReady?.(guestObservable)) {\n break;\n }\n await guestObservable.authenticate(await authCode.wait());\n break;\n }\n\n case Invitation.State.AUTHENTICATING: {\n hooks?.guest?.onAuthenticating?.(guestObservable);\n break;\n }\n\n case Invitation.State.SUCCESS: {\n if (hooks?.guest?.onSuccess?.(guestObservable)) {\n break;\n }\n guestComplete.wake({ invitation: guestInvitation });\n break;\n }\n\n case Invitation.State.CANCELLED: {\n if (hooks?.guest?.onCancelled?.(guestObservable)) {\n break;\n }\n guestComplete.wake({ invitation: guestInvitation });\n break;\n }\n\n case Invitation.State.TIMEOUT: {\n if (hooks?.guest?.onTimeout?.(guestObservable)) {\n return;\n }\n guestComplete.wake({ invitation: guestInvitation });\n }\n }\n },\n (error: Error) => {\n if (hooks?.guest?.onError?.(guestObservable)) {\n return;\n }\n guestComplete.wake({ error });\n },\n );\n break;\n }\n\n case Invitation.State.CONNECTED: {\n hooks?.host?.onConnected?.(hostObservable);\n break;\n }\n\n case Invitation.State.READY_FOR_AUTHENTICATION: {\n if (hooks?.host?.onReady?.(hostObservable)) {\n break;\n }\n if (hostInvitation.authCode) {\n authCode.wake(hostInvitation.authCode);\n }\n break;\n }\n\n case Invitation.State.AUTHENTICATING: {\n hooks?.host?.onAuthenticating?.(hostObservable);\n break;\n }\n\n case Invitation.State.SUCCESS: {\n if (hooks?.host?.onSuccess?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n\n case Invitation.State.CANCELLED: {\n if (hooks?.host?.onCancelled?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n\n case Invitation.State.TIMEOUT: {\n if (hooks?.host?.onTimeout?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n }\n },\n (error: Error) => {\n if (hooks?.host?.onError?.(hostObservable)) {\n return;\n }\n hostComplete.wake({ error });\n },\n );\n\n return [hostComplete.wait(), guestComplete.wait()];\n};\n\nconst createInvitation = (\n host: ServiceContext | InvitationHost,\n options?: Partial<Invitation>,\n): CancellableInvitation => {\n options ??= {\n authMethod: Invitation.AuthMethod.NONE,\n ...(options ?? {}),\n };\n\n if (host instanceof ServiceContext) {\n const hostHandler = host.getInvitationHandler({ kind: Invitation.Kind.SPACE, ...options });\n return host.invitations.createInvitation(hostHandler, options);\n }\n\n return host.share(options);\n};\n\nconst acceptInvitation = (\n guest: ServiceContext | InvitationGuest,\n invitation: Invitation,\n guestDeviceProfile?: DeviceProfileDocument,\n): AuthenticatingInvitation => {\n invitation = sanitizeInvitation(invitation);\n\n if (guest instanceof ServiceContext) {\n const guestHandler = guest.getInvitationHandler({ kind: invitation.kind });\n return guest.invitations.acceptInvitation(guestHandler, invitation, guestDeviceProfile);\n }\n\n return guest.join(invitation, guestDeviceProfile);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Config } from '@dxos/config';\nimport { Context } from '@dxos/context';\nimport { createCredentialSignerWithChain, CredentialGenerator } from '@dxos/credentials';\nimport { failUndefined } from '@dxos/debug';\nimport { AutomergeHost, MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from '@dxos/echo-pipeline';\nimport { FeedFactory, FeedStore } from '@dxos/feed-store';\nimport { Keyring } from '@dxos/keyring';\nimport { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';\nimport { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';\nimport { createStorage, StorageType, type Storage } from '@dxos/random-access-storage';\nimport { BlobStore } from '@dxos/teleport-extension-object-sync';\n\nimport { ClientServicesHost, ServiceContext } from '../services';\nimport { DataSpaceManager, type SigningContext } from '../spaces';\n\n//\n// TODO(burdon): Replace with test builder.\n//\n\nexport const createServiceHost = (config: Config, signalManagerContext: MemorySignalManagerContext) => {\n return new ClientServicesHost({\n config,\n signalManager: new MemorySignalManager(signalManagerContext),\n transportFactory: MemoryTransportFactory,\n });\n};\n\nexport const createServiceContext = ({\n signalContext = new MemorySignalManagerContext(),\n storage = createStorage({ type: StorageType.RAM }),\n}: {\n signalContext?: MemorySignalManagerContext;\n storage?: Storage;\n} = {}) => {\n const signalManager = new MemorySignalManager(signalContext);\n const networkManager = new NetworkManager({\n signalManager,\n transportFactory: MemoryTransportFactory,\n });\n\n return new ServiceContext(storage, networkManager, signalManager);\n};\n\nexport const createPeers = async (numPeers: number) => {\n const signalContext = new MemorySignalManagerContext();\n\n return await Promise.all(\n Array.from(Array(numPeers)).map(async () => {\n const peer = createServiceContext({ signalContext });\n await peer.open(new Context());\n return peer;\n }),\n );\n};\n\nexport const createIdentity = async (peer: ServiceContext) => {\n await peer.createIdentity();\n return peer;\n};\n\nexport class TestBuilder {\n public readonly signalContext = new MemorySignalManagerContext();\n private readonly _ctx = new Context();\n\n createPeer(peerOptions?: TestPeerOpts): TestPeer {\n const peer = new TestPeer(this.signalContext, peerOptions);\n this._ctx.onDispose(async () => peer.destroy());\n return peer;\n }\n\n async destroy() {\n await this._ctx.dispose();\n }\n}\n\nexport type TestPeerOpts = {\n dataStore?: StorageType;\n};\n\nexport type TestPeerProps = {\n storage?: Storage;\n feedStore?: FeedStore<any>;\n metadataStore?: MetadataStore;\n keyring?: Keyring;\n networkManager?: NetworkManager;\n spaceManager?: SpaceManager;\n dataSpaceManager?: DataSpaceManager;\n snapshotStore?: SnapshotStore;\n signingContext?: SigningContext;\n blobStore?: BlobStore;\n automergeHost?: AutomergeHost;\n};\n\nexport class TestPeer {\n private _props: TestPeerProps = {};\n\n constructor(\n private readonly signalContext: MemorySignalManagerContext,\n private readonly opts: TestPeerOpts = { dataStore: StorageType.RAM },\n ) {}\n\n get props() {\n return this._props;\n }\n\n get storage() {\n return (this._props.storage ??= createStorage({ type: this.opts.dataStore }));\n }\n\n get keyring() {\n return (this._props.keyring ??= new Keyring(this.storage.createDirectory('keyring')));\n }\n\n get feedStore() {\n return (this._props.feedStore ??= new FeedStore({\n factory: new FeedFactory({\n root: this.storage.createDirectory('feeds'),\n signer: this.keyring,\n hypercore: {\n valueEncoding,\n },\n }),\n }));\n }\n\n get metadataStore() {\n return (this._props.metadataStore ??= new MetadataStore(this.storage.createDirectory('metadata')));\n }\n\n get blobStore() {\n return (this._props.blobStore ??= new BlobStore(this.storage.createDirectory('blobs')));\n }\n\n get snapshotStore() {\n return (this._props.snapshotStore ??= new SnapshotStore(this.storage.createDirectory('snapshots')));\n }\n\n get networkManager() {\n return (this._props.networkManager ??= new NetworkManager({\n signalManager: new MemorySignalManager(this.signalContext),\n transportFactory: MemoryTransportFactory,\n }));\n }\n\n get spaceManager() {\n return (this._props.spaceManager ??= new SpaceManager({\n feedStore: this.feedStore,\n networkManager: this.networkManager,\n metadataStore: this.metadataStore,\n snapshotStore: this.snapshotStore,\n blobStore: this.blobStore,\n }));\n }\n\n get identity() {\n return this._props.signingContext ?? failUndefined();\n }\n\n get automergeHost() {\n return (this._props.automergeHost ??= new AutomergeHost({ directory: this.storage.createDirectory('automerge') }));\n }\n\n get dataSpaceManager() {\n return (this._props.dataSpaceManager ??= new DataSpaceManager(\n this.spaceManager,\n this.metadataStore,\n this.keyring,\n this.identity,\n this.feedStore,\n this.automergeHost,\n ));\n }\n\n async createIdentity() {\n this._props.signingContext ??= await createSigningContext(this.keyring);\n }\n\n async destroy() {\n await this.storage.reset();\n }\n}\n\nexport const createSigningContext = async (keyring: Keyring): Promise<SigningContext> => {\n const identityKey = await keyring.createKey();\n const deviceKey = await keyring.createKey();\n\n return {\n identityKey,\n deviceKey,\n credentialSigner: createCredentialSignerWithChain(\n keyring,\n {\n credential: await new CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey),\n },\n deviceKey,\n ),\n recordCredential: async () => {}, // No-op.\n getProfile: () => undefined,\n };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAiC;AAEjC,kBAA0B;ACF1B,mBAAwB;AACxB,6BAA6F;AAC7F,uBAA0B;AAC1B,sBAA2B;ACF3B,qBAAwB;AACxB,IAAAA,sBAAqE;AACrE,mBAA8B;AAC9B,
|
|
6
|
-
"names": ["import_credentials", "createMockCredential", "signer", "issuer", "createCredential", "subject", "PublicKey", "Buffer", "from", "assertion", "payload", "value", "sanitizeInvitation", "invitation", "InvitationEncoder", "decode", "encode", "performInvitation", "host", "guest", "options", "hooks", "guestDeviceProfile", "hostComplete", "Trigger", "guestComplete", "authCode", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { createCredential } from '@dxos/credentials';\nimport { type Signer } from '@dxos/crypto';\nimport { PublicKey } from '@dxos/keys';\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nexport const createMockCredential = async ({\n signer,\n issuer,\n}: {\n signer: Signer;\n issuer: PublicKey;\n}): Promise<Credential> =>\n createCredential({\n signer,\n issuer,\n subject: new PublicKey(Buffer.from('test')),\n assertion: {\n '@type': 'example.testing.rpc.MessageWithAny',\n payload: {\n '@type': 'google.protobuf.Any',\n value: Buffer.from('test'),\n },\n },\n });\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Trigger } from '@dxos/async';\nimport { InvitationEncoder, type AuthenticatingInvitation, type CancellableInvitation } from '@dxos/client-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\nimport { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nimport { ServiceContext } from '../services';\n\n/**\n * Strip secrets from invitation before giving it to the peer.\n */\nexport const sanitizeInvitation = (invitation: Invitation): Invitation => {\n return InvitationEncoder.decode(InvitationEncoder.encode(invitation));\n};\n\nexport type InvitationHost = {\n share(options?: Partial<Invitation>): CancellableInvitation;\n};\n\nexport type InvitationGuest = {\n join(invitation: Invitation | string, deviceProfile?: DeviceProfileDocument): AuthenticatingInvitation;\n};\n\nexport type PerformInvitationCallbacks<T> = {\n onConnecting?: (value: T) => boolean | void;\n onConnected?: (value: T) => boolean | void;\n onReady?: (value: T) => boolean | void;\n onAuthenticating?: (value: T) => boolean | void;\n onSuccess?: (value: T) => boolean | void;\n onCancelled?: (value: T) => boolean | void;\n onTimeout?: (value: T) => boolean | void;\n onError?: (value: T) => boolean | void;\n};\n\nexport type PerformInvitationParams = {\n host: ServiceContext | InvitationHost;\n guest: ServiceContext | InvitationGuest;\n options?: Partial<Invitation>;\n hooks?: {\n host?: PerformInvitationCallbacks<CancellableInvitation>;\n guest?: PerformInvitationCallbacks<AuthenticatingInvitation>;\n };\n guestDeviceProfile?: DeviceProfileDocument;\n};\n\nexport type Result = { invitation?: Invitation; error?: Error };\n\nexport const performInvitation = ({\n host,\n guest,\n options,\n hooks,\n guestDeviceProfile,\n}: PerformInvitationParams): [Promise<Result>, Promise<Result>] => {\n const hostComplete = new Trigger<Result>();\n const guestComplete = new Trigger<Result>();\n const authCode = new Trigger<string>();\n\n void createInvitation(host, options).then((hostObservable) => {\n hostObservable.subscribe(\n async (hostInvitation: Invitation) => {\n switch (hostInvitation.state) {\n case Invitation.State.CONNECTING: {\n if (hooks?.host?.onConnecting?.(hostObservable)) {\n break;\n }\n const guestObservable = acceptInvitation(guest, hostInvitation, guestDeviceProfile);\n guestObservable.subscribe(\n async (guestInvitation: Invitation) => {\n switch (guestInvitation.state) {\n case Invitation.State.CONNECTING: {\n if (hooks?.guest?.onConnecting?.(guestObservable)) {\n break;\n }\n invariant(hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!));\n break;\n }\n\n case Invitation.State.CONNECTED: {\n hooks?.guest?.onConnected?.(guestObservable);\n break;\n }\n\n case Invitation.State.READY_FOR_AUTHENTICATION: {\n if (hooks?.guest?.onReady?.(guestObservable)) {\n break;\n }\n await guestObservable.authenticate(await authCode.wait());\n break;\n }\n\n case Invitation.State.AUTHENTICATING: {\n hooks?.guest?.onAuthenticating?.(guestObservable);\n break;\n }\n\n case Invitation.State.SUCCESS: {\n if (hooks?.guest?.onSuccess?.(guestObservable)) {\n break;\n }\n guestComplete.wake({ invitation: guestInvitation });\n break;\n }\n\n case Invitation.State.CANCELLED: {\n if (hooks?.guest?.onCancelled?.(guestObservable)) {\n break;\n }\n guestComplete.wake({ invitation: guestInvitation });\n break;\n }\n\n case Invitation.State.TIMEOUT: {\n if (hooks?.guest?.onTimeout?.(guestObservable)) {\n return;\n }\n guestComplete.wake({ invitation: guestInvitation });\n }\n }\n },\n (error: Error) => {\n if (hooks?.guest?.onError?.(guestObservable)) {\n return;\n }\n guestComplete.wake({ error });\n },\n );\n break;\n }\n\n case Invitation.State.CONNECTED: {\n hooks?.host?.onConnected?.(hostObservable);\n break;\n }\n\n case Invitation.State.READY_FOR_AUTHENTICATION: {\n if (hooks?.host?.onReady?.(hostObservable)) {\n break;\n }\n if (hostInvitation.authCode) {\n authCode.wake(hostInvitation.authCode);\n }\n break;\n }\n\n case Invitation.State.AUTHENTICATING: {\n hooks?.host?.onAuthenticating?.(hostObservable);\n break;\n }\n\n case Invitation.State.SUCCESS: {\n if (hooks?.host?.onSuccess?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n\n case Invitation.State.CANCELLED: {\n if (hooks?.host?.onCancelled?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n\n case Invitation.State.TIMEOUT: {\n if (hooks?.host?.onTimeout?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n }\n },\n (error: Error) => {\n if (hooks?.host?.onError?.(hostObservable)) {\n return;\n }\n hostComplete.wake({ error });\n },\n );\n });\n\n return [hostComplete.wait(), guestComplete.wait()];\n};\n\nconst createInvitation = async (\n host: ServiceContext | InvitationHost,\n options?: Partial<Invitation>,\n): Promise<CancellableInvitation> => {\n options ??= {\n authMethod: Invitation.AuthMethod.NONE,\n ...(options ?? {}),\n };\n\n if (host instanceof ServiceContext) {\n return host.invitationsManager.createInvitation({\n kind: Invitation.Kind.SPACE,\n ...options,\n });\n }\n\n return host.share(options);\n};\n\nconst acceptInvitation = (\n guest: ServiceContext | InvitationGuest,\n invitation: Invitation,\n guestDeviceProfile?: DeviceProfileDocument,\n): AuthenticatingInvitation => {\n invitation = sanitizeInvitation(invitation);\n\n if (guest instanceof ServiceContext) {\n const guestHandler = guest.getInvitationHandler({ kind: invitation.kind });\n return guest.invitations.acceptInvitation(guestHandler, invitation, guestDeviceProfile);\n }\n\n return guest.join(invitation, guestDeviceProfile);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Config } from '@dxos/config';\nimport { Context } from '@dxos/context';\nimport { createCredentialSignerWithChain, CredentialGenerator } from '@dxos/credentials';\nimport { failUndefined } from '@dxos/debug';\nimport { EchoHost } from '@dxos/echo-db';\nimport { MetadataStore, type LevelDB, SnapshotStore, SpaceManager, valueEncoding } from '@dxos/echo-pipeline';\nimport { createTestLevel } from '@dxos/echo-pipeline/testing';\nimport { FeedFactory, FeedStore } from '@dxos/feed-store';\nimport { Keyring } from '@dxos/keyring';\nimport { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';\nimport { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\nimport { createStorage, StorageType, type Storage } from '@dxos/random-access-storage';\nimport { BlobStore } from '@dxos/teleport-extension-object-sync';\n\nimport { InvitationsHandler, InvitationsManager, SpaceInvitationProtocol } from '../invitations';\nimport { ClientServicesHost, ServiceContext } from '../services';\nimport { DataSpaceManager, type SigningContext } from '../spaces';\n\n//\n// TODO(burdon): Replace with test builder.\n//\n\nexport const createServiceHost = (config: Config, signalManagerContext: MemorySignalManagerContext) => {\n return new ClientServicesHost({\n config,\n signalManager: new MemorySignalManager(signalManagerContext),\n transportFactory: MemoryTransportFactory,\n });\n};\n\nexport const createServiceContext = async ({\n signalContext = new MemorySignalManagerContext(),\n storage = createStorage({ type: StorageType.RAM }),\n}: {\n signalContext?: MemorySignalManagerContext;\n storage?: Storage;\n} = {}) => {\n const signalManager = new MemorySignalManager(signalContext);\n const networkManager = new NetworkManager({\n signalManager,\n transportFactory: MemoryTransportFactory,\n });\n const level = createTestLevel();\n await level.open();\n\n return new ServiceContext(storage, level, networkManager, signalManager);\n};\n\nexport const createPeers = async (numPeers: number) => {\n const signalContext = new MemorySignalManagerContext();\n\n return await Promise.all(\n Array.from(Array(numPeers)).map(async () => {\n const peer = await createServiceContext({ signalContext });\n await peer.open(new Context());\n return peer;\n }),\n );\n};\n\nexport const createIdentity = async (peer: ServiceContext) => {\n await peer.createIdentity();\n return peer;\n};\n\nexport class TestBuilder {\n public readonly signalContext = new MemorySignalManagerContext();\n private readonly _ctx = new Context();\n\n createPeer(peerOptions?: TestPeerOpts): TestPeer {\n const peer = new TestPeer(this.signalContext, peerOptions);\n this._ctx.onDispose(async () => peer.destroy());\n return peer;\n }\n\n async destroy() {\n await this._ctx.dispose();\n }\n}\n\nexport type TestPeerOpts = {\n dataStore?: StorageType;\n};\n\nexport type TestPeerProps = {\n storage?: Storage;\n level?: LevelDB;\n feedStore?: FeedStore<any>;\n metadataStore?: MetadataStore;\n keyring?: Keyring;\n networkManager?: NetworkManager;\n spaceManager?: SpaceManager;\n dataSpaceManager?: DataSpaceManager;\n snapshotStore?: SnapshotStore;\n signingContext?: SigningContext;\n blobStore?: BlobStore;\n echoHost?: EchoHost;\n invitationsManager?: InvitationsManager;\n};\n\nexport class TestPeer {\n private _props: TestPeerProps = {};\n\n constructor(\n private readonly signalContext: MemorySignalManagerContext,\n private readonly opts: TestPeerOpts = { dataStore: StorageType.RAM },\n ) {}\n\n get props() {\n return this._props;\n }\n\n get storage() {\n return (this._props.storage ??= createStorage({ type: this.opts.dataStore }));\n }\n\n get keyring() {\n return (this._props.keyring ??= new Keyring(this.storage.createDirectory('keyring')));\n }\n\n get level() {\n return (this._props.level ??= createTestLevel());\n }\n\n get feedStore() {\n return (this._props.feedStore ??= new FeedStore({\n factory: new FeedFactory({\n root: this.storage.createDirectory('feeds'),\n signer: this.keyring,\n hypercore: {\n valueEncoding,\n },\n }),\n }));\n }\n\n get metadataStore() {\n return (this._props.metadataStore ??= new MetadataStore(this.storage.createDirectory('metadata')));\n }\n\n get blobStore() {\n return (this._props.blobStore ??= new BlobStore(this.storage.createDirectory('blobs')));\n }\n\n get snapshotStore() {\n return (this._props.snapshotStore ??= new SnapshotStore(this.storage.createDirectory('snapshots')));\n }\n\n get networkManager() {\n return (this._props.networkManager ??= new NetworkManager({\n signalManager: new MemorySignalManager(this.signalContext),\n transportFactory: MemoryTransportFactory,\n }));\n }\n\n get spaceManager() {\n return (this._props.spaceManager ??= new SpaceManager({\n feedStore: this.feedStore,\n networkManager: this.networkManager,\n metadataStore: this.metadataStore,\n snapshotStore: this.snapshotStore,\n blobStore: this.blobStore,\n }));\n }\n\n get identity() {\n return this._props.signingContext ?? failUndefined();\n }\n\n get echoHost() {\n return (this._props.echoHost ??= new EchoHost({\n kv: this.level,\n storage: this.storage,\n }));\n }\n\n get dataSpaceManager(): DataSpaceManager {\n return (this._props.dataSpaceManager ??= new DataSpaceManager(\n this.spaceManager,\n this.metadataStore,\n this.keyring,\n this.identity,\n this.feedStore,\n this.echoHost,\n this.invitationsManager,\n ));\n }\n\n get invitationsManager() {\n return (this._props.invitationsManager ??= new InvitationsManager(\n new InvitationsHandler(this.networkManager),\n (invitation) => {\n if (invitation.kind === Invitation.Kind.SPACE) {\n return new SpaceInvitationProtocol(this.dataSpaceManager, this.identity!, this.keyring, invitation.spaceKey!);\n } else {\n throw new Error('not implemented');\n }\n },\n this.metadataStore,\n ));\n }\n\n async createIdentity() {\n this._props.signingContext ??= await createSigningContext(this.keyring);\n }\n\n async destroy() {\n await this.level.close();\n await this.storage.reset();\n }\n}\n\nexport const createSigningContext = async (keyring: Keyring): Promise<SigningContext> => {\n const identityKey = await keyring.createKey();\n const deviceKey = await keyring.createKey();\n\n return {\n identityKey,\n deviceKey,\n credentialSigner: createCredentialSignerWithChain(\n keyring,\n {\n credential: await new CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey),\n },\n deviceKey,\n ),\n recordCredential: async () => {}, // No-op.\n getProfile: () => undefined,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAiC;AAEjC,kBAA0B;ACF1B,mBAAwB;AACxB,6BAA6F;AAC7F,uBAA0B;AAC1B,sBAA2B;ACF3B,qBAAwB;AACxB,IAAAA,sBAAqE;AACrE,mBAA8B;AAC9B,qBAAyB;AACzB,2BAAwF;AACxF,qBAAgC;AAChC,wBAAuC;AACvC,qBAAwB;AACxB,uBAAgE;AAChE,6BAAuD;AACvD,IAAAC,mBAA2B;AAC3B,mCAAyD;AACzD,4CAA0B;AFRnB,IAAMC,uBAAuB,OAAO,EACzCC,QACAC,OAAM,UAKNC,qCAAiB;EACfF;EACAC;EACAE,SAAS,IAAIC,sBAAUC,OAAOC,KAAK,MAAA,CAAA;EACnCC,WAAW;IACT,SAAS;IACTC,SAAS;MACP,SAAS;MACTC,OAAOJ,OAAOC,KAAK,MAAA;IACrB;EACF;AACF,CAAA;;ACZK,IAAMI,qBAAqB,CAACC,eAAAA;AACjC,SAAOC,yCAAkBC,OAAOD,yCAAkBE,OAAOH,UAAAA,CAAAA;AAC3D;AAkCO,IAAMI,oBAAoB,CAAC,EAChCC,MACAC,OACAC,SACAC,OACAC,mBAAkB,MACM;AACxB,QAAMC,eAAe,IAAIC,qBAAAA;AACzB,QAAMC,gBAAgB,IAAID,qBAAAA;AAC1B,QAAME,WAAW,IAAIF,qBAAAA;AAErB,OAAKG,iBAAiBT,MAAME,OAAAA,EAASQ,KAAK,CAACC,mBAAAA;AACzCA,mBAAeC,UACb,OAAOC,mBAAAA;AACL,cAAQA,eAAeC,OAAK;QAC1B,KAAKC,2BAAWC,MAAM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AKkD,OAAOlD,uBAAuB,IAAI8E,yCAC7C,IAAIC,yCAAmB,KAAKtD,cAAc,GAC1C,CAAC5E,eAAAA;AACC,UAAIA,WAAWoD,SAAShC,iBAAAA,WAAWiC,KAAKC,OAAO;AAC7C,eAAO,IAAI6E,8CAAwB,KAAKJ,kBAAkB,KAAKN,UAAW,KAAKlB,SAASvG,WAAWoI,QAAQ;MAC7G,OAAO;AACL,cAAM,IAAIC,MAAM,iBAAA;MAClB;IACF,GACA,KAAKpB,aAAa;EAEtB;EAEA,MAAMxB,iBAAiB;AACrB,SAAKY,OAAOqB,mBAAmB,MAAMY,qBAAqB,KAAK/B,OAAO;EACxE;EAEA,MAAMP,UAAU;AACd,UAAM,KAAKlB,MAAMyD,MAAK;AACtB,UAAM,KAAKhE,QAAQiE,MAAK;EAC1B;AACF;AAEO,IAAMF,uBAAuB,OAAO/B,YAAAA;AACzC,QAAMkC,cAAc,MAAMlC,QAAQmC,UAAS;AAC3C,QAAMC,YAAY,MAAMpC,QAAQmC,UAAS;AAEzC,SAAO;IACLD;IACAE;IACAC,sBAAkBC,qDAChBtC,SACA;MACEuC,YAAY,MAAM,IAAIC,wCAAoBxC,SAASkC,aAAaE,SAAAA,EAAWK,0BAA0BL,SAAAA;IACvG,GACAA,SAAAA;IAEFM,kBAAkB,YAAA;IAAa;IAC/BC,YAAY,MAAMC;EACpB;AACF;",
|
|
6
|
+
"names": ["import_credentials", "import_services", "createMockCredential", "signer", "issuer", "createCredential", "subject", "PublicKey", "Buffer", "from", "assertion", "payload", "value", "sanitizeInvitation", "invitation", "InvitationEncoder", "decode", "encode", "performInvitation", "host", "guest", "options", "hooks", "guestDeviceProfile", "hostComplete", "Trigger", "guestComplete", "authCode", "createInvitation", "then", "hostObservable", "subscribe", "hostInvitation", "state", "Invitation", "State", "CONNECTING", "onConnecting", "guestObservable", "acceptInvitation", "guestInvitation", "invariant", "swarmKey", "equals", "CONNECTED", "onConnected", "READY_FOR_AUTHENTICATION", "onReady", "authenticate", "wait", "AUTHENTICATING", "onAuthenticating", "SUCCESS", "onSuccess", "wake", "CANCELLED", "onCancelled", "TIMEOUT", "onTimeout", "error", "onError", "authMethod", "AuthMethod", "NONE", "ServiceContext", "invitationsManager", "kind", "Kind", "SPACE", "share", "guestHandler", "getInvitationHandler", "invitations", "join", "createServiceHost", "config", "signalManagerContext", "ClientServicesHost", "signalManager", "MemorySignalManager", "transportFactory", "MemoryTransportFactory", "createServiceContext", "signalContext", "MemorySignalManagerContext", "storage", "createStorage", "type", "StorageType", "RAM", "networkManager", "NetworkManager", "level", "createTestLevel", "open", "createPeers", "numPeers", "Promise", "all", "Array", "map", "peer", "Context", "createIdentity", "TestBuilder", "_ctx", "createPeer", "peerOptions", "TestPeer", "onDispose", "destroy", "dispose", "constructor", "opts", "dataStore", "_props", "props", "keyring", "Keyring", "createDirectory", "feedStore", "FeedStore", "factory", "FeedFactory", "root", "hypercore", "valueEncoding", "metadataStore", "MetadataStore", "blobStore", "BlobStore", "snapshotStore", "SnapshotStore", "spaceManager", "SpaceManager", "identity", "signingContext", "failUndefined", "echoHost", "EchoHost", "kv", "dataSpaceManager", "DataSpaceManager", "InvitationsManager", "InvitationsHandler", "SpaceInvitationProtocol", "spaceKey", "Error", "createSigningContext", "close", "reset", "identityKey", "createKey", "deviceKey", "credentialSigner", "createCredentialSignerWithChain", "credential", "CredentialGenerator", "createDeviceAuthorization", "recordCredential", "getProfile", "undefined"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type SystemService } from '@dxos/protocols/proto/dxos/client/services';
|
|
2
|
+
import { type CollectDiagnosticsBroadcastSender, type CollectDiagnosticsBroadcastHandler } from './diagnostics-collector';
|
|
3
|
+
export declare const createCollectDiagnosticsBroadcastSender: () => CollectDiagnosticsBroadcastSender;
|
|
4
|
+
export declare const createCollectDiagnosticsBroadcastHandler: (systemService: SystemService) => CollectDiagnosticsBroadcastHandler;
|
|
5
|
+
//# sourceMappingURL=browser-diagnostics-broadcast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-diagnostics-broadcast.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/diagnostics/browser-diagnostics-broadcast.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAEhF,OAAO,EACL,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EACxC,MAAM,yBAAyB,CAAC;AAgBjC,eAAO,MAAM,uCAAuC,QAAO,iCA4B1D,CAAC;AAEF,eAAO,MAAM,wCAAwC,kBACpC,aAAa,KAC3B,kCA0BF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type SystemService } from '@dxos/protocols/proto/dxos/client/services';
|
|
2
|
+
import { type CollectDiagnosticsBroadcastSender, type CollectDiagnosticsBroadcastHandler } from './diagnostics-collector';
|
|
3
|
+
export declare const createCollectDiagnosticsBroadcastSender: () => CollectDiagnosticsBroadcastSender;
|
|
4
|
+
export declare const createCollectDiagnosticsBroadcastHandler: (_: SystemService) => CollectDiagnosticsBroadcastHandler;
|
|
5
|
+
//# sourceMappingURL=diagnostics-broadcast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics-broadcast.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/diagnostics/diagnostics-broadcast.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAEhF,OAAO,EACL,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EACxC,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,uCAAuC,QAAO,iCAE1D,CAAC;AAEF,eAAO,MAAM,wCAAwC,MAAO,aAAa,KAAG,kCAK3E,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ClientServicesProvider } from '@dxos/client-protocol';
|
|
2
|
+
import { type Config } from '@dxos/config';
|
|
3
|
+
import { type JsonKeyOptions } from '@dxos/util';
|
|
4
|
+
export interface CollectDiagnosticsBroadcastSender {
|
|
5
|
+
broadcastDiagnosticsRequest(): any;
|
|
6
|
+
}
|
|
7
|
+
export interface CollectDiagnosticsBroadcastHandler {
|
|
8
|
+
start(): void;
|
|
9
|
+
stop(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class DiagnosticsCollector {
|
|
12
|
+
private static broadcastSender;
|
|
13
|
+
static collect(config?: Config | Config[], services?: ClientServicesProvider | null, options?: JsonKeyOptions): Promise<any>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=diagnostics-collector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics-collector.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/diagnostics/diagnostics-collector.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,KAAK,MAAM,EAAkB,MAAM,cAAc,CAAC;AAG3D,OAAO,EAAE,KAAK,cAAc,EAAgC,MAAM,YAAY,CAAC;AAK/E,MAAM,WAAW,iCAAiC;IAChD,2BAA2B,IAAI,GAAG,CAAC;CACpC;AAED,MAAM,WAAW,kCAAkC;IACjD,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,IAAI,IAAI,CAAC;CACd;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,eAAe,CAA6C;WAEvD,OAAO,CACzB,MAAM,GAAE,MAAM,GAAG,MAAM,EAAkB,EACzC,QAAQ,GAAE,sBAAsB,GAAG,IAAkC,EACrE,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,GAAG,CAAC;CAwBhB"}
|
|
@@ -6,7 +6,7 @@ import { type SubscribeToFeedsResponse } from '@dxos/protocols/proto/dxos/devtoo
|
|
|
6
6
|
import { type SwarmInfo } from '@dxos/protocols/proto/dxos/devtools/swarm';
|
|
7
7
|
import { type Epoch } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
8
8
|
import { type Resource, type Span } from '@dxos/protocols/proto/dxos/tracing';
|
|
9
|
-
import { type ServiceContext } from '
|
|
9
|
+
import { type ServiceContext } from '../services';
|
|
10
10
|
export type Diagnostics = {
|
|
11
11
|
client: {
|
|
12
12
|
config: ConfigProto;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/diagnostics/diagnostics.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAG7D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EACL,WAAW,EACX,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,QAAQ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AAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,IAAI,EAAE,QAAQ,EAAE,CAAC;CAClB,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,SAAS,CAAC;IACf,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,EAAE,CAAC,EAAE;QACH,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,GAAG;QAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,MAAM,CAAC,EAAE,CAAC,KAAK,GAAG;QAAE,EAAE,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,EAAE,CAAC;IACxC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,UAAU,CAAC,aAAa,CAAC;CACrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,mBACZ,QAAQ,cAAc,CAAC,kBACvB,cAAc,UACtB,MAAM,KACb,QAAQ,WAAW,CAAC,UAAU,CAAC,CAsFjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/diagnostics/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-manager.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/identity/identity-manager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,E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,EAAE,4BAA4B;IAUvC,IAAI,QAAQ,yBAEX;IAGK,IAAI,CAAC,GAAG,EAAE,OAAO;IAoBjB,KAAK;IAIL,cAAc,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,GAAE,qBAA0B;IAgF/E,0BAA0B,IAAI,qBAAqB;IAyBnD;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,kBAAkB;IAmC/C;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE,eAAe;IAiBtC,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;YA0B5D,kBAAkB;YAwDlB,eAAe;CAoB9B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Keyring } from '@dxos/keyring';
|
|
2
|
+
import { type PublicKey } from '@dxos/keys';
|
|
2
3
|
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
3
4
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
4
5
|
import type { DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
@@ -12,7 +13,8 @@ export declare class DeviceInvitationProtocol implements InvitationProtocol {
|
|
|
12
13
|
constructor(_keyring: Keyring, _getIdentity: () => Identity, _acceptIdentity: (identity: JoinIdentityParams) => Promise<Identity>);
|
|
13
14
|
toJSON(): object;
|
|
14
15
|
getInvitationContext(): Partial<Invitation> & Pick<Invitation, 'kind'>;
|
|
15
|
-
|
|
16
|
+
delegate(invitation: Invitation): Promise<PublicKey>;
|
|
17
|
+
admit(_: Invitation, request: AdmissionRequest): Promise<AdmissionResponse>;
|
|
16
18
|
checkInvitation(invitation: Partial<Invitation>): AlreadyJoinedError | undefined;
|
|
17
19
|
createIntroduction(): IntroductionRequest;
|
|
18
20
|
createAdmissionRequest(deviceProfile?: DeviceProfileDocument): Promise<AdmissionRequest>;
|