@dxos/client-services 0.4.10-main.e2d2318 → 0.4.10-main.e6ba7bc
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-HAFART26.mjs → chunk-NE6FWMYP.mjs} +631 -511
- package/dist/lib/browser/chunk-NE6FWMYP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +127 -113
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-5YDVC6TU.cjs → chunk-3EKN7HG6.cjs} +699 -580
- package/dist/lib/node/chunk-3EKN7HG6.cjs.map +7 -0
- package/dist/lib/node/index.cjs +44 -42
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +127 -116
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/indexing/util.d.ts +2 -6
- package/dist/types/src/packlets/indexing/util.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-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 +4 -2
- 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/service-context.d.ts +2 -0
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +3 -2
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.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 +6 -4
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -34
- package/src/packlets/identity/identity-manager.ts +1 -0
- package/src/packlets/identity/identity.test.ts +3 -0
- package/src/packlets/indexing/util.ts +9 -66
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -1
- package/src/packlets/invitations/index.ts +1 -0
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitations-handler.ts +11 -73
- 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/services/automerge-host.test.ts +1 -1
- package/src/packlets/services/service-context.ts +17 -5
- package/src/packlets/services/service-host.ts +13 -17
- package/src/packlets/spaces/data-space-manager.ts +48 -2
- package/src/packlets/spaces/data-space.ts +1 -1
- package/src/packlets/testing/invitation-utils.ts +100 -97
- package/src/packlets/testing/test-builder.ts +23 -5
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-HAFART26.mjs.map +0 -7
- package/dist/lib/node/chunk-5YDVC6TU.cjs.map +0 -7
|
@@ -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_3EKN7HG6 = require("../../chunk-3EKN7HG6.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");
|
|
@@ -46,6 +46,7 @@ var import_feed_store = require("@dxos/feed-store");
|
|
|
46
46
|
var import_keyring = require("@dxos/keyring");
|
|
47
47
|
var import_messaging = require("@dxos/messaging");
|
|
48
48
|
var import_network_manager = require("@dxos/network-manager");
|
|
49
|
+
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
49
50
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
50
51
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
51
52
|
var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.createCredential)({
|
|
@@ -68,134 +69,135 @@ var performInvitation = ({ host, guest, options, hooks, guestDeviceProfile }) =>
|
|
|
68
69
|
const hostComplete = new import_async.Trigger();
|
|
69
70
|
const guestComplete = new import_async.Trigger();
|
|
70
71
|
const authCode = new import_async.Trigger();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
void createInvitation(host, options).then((hostObservable) => {
|
|
73
|
+
hostObservable.subscribe(async (hostInvitation) => {
|
|
74
|
+
switch (hostInvitation.state) {
|
|
75
|
+
case import_services.Invitation.State.CONNECTING: {
|
|
76
|
+
if (hooks?.host?.onConnecting?.(hostObservable)) {
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
const guestObservable = acceptInvitation(guest, hostInvitation, guestDeviceProfile);
|
|
80
|
+
guestObservable.subscribe(async (guestInvitation) => {
|
|
81
|
+
switch (guestInvitation.state) {
|
|
82
|
+
case import_services.Invitation.State.CONNECTING: {
|
|
83
|
+
if (hooks?.guest?.onConnecting?.(guestObservable)) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
(0, import_invariant.invariant)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey), void 0, {
|
|
87
|
+
F: __dxlog_file,
|
|
88
|
+
L: 79,
|
|
89
|
+
S: void 0,
|
|
90
|
+
A: [
|
|
91
|
+
"hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!)",
|
|
92
|
+
""
|
|
93
|
+
]
|
|
94
|
+
});
|
|
83
95
|
break;
|
|
84
96
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
L: 79,
|
|
88
|
-
S: void 0,
|
|
89
|
-
A: [
|
|
90
|
-
"hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!)",
|
|
91
|
-
""
|
|
92
|
-
]
|
|
93
|
-
});
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
case import_services.Invitation.State.CONNECTED: {
|
|
97
|
-
hooks?.guest?.onConnected?.(guestObservable);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
case import_services.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
101
|
-
if (hooks?.guest?.onReady?.(guestObservable)) {
|
|
97
|
+
case import_services.Invitation.State.CONNECTED: {
|
|
98
|
+
hooks?.guest?.onConnected?.(guestObservable);
|
|
102
99
|
break;
|
|
103
100
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
case import_services.Invitation.State.SUCCESS: {
|
|
112
|
-
if (hooks?.guest?.onSuccess?.(guestObservable)) {
|
|
101
|
+
case import_services.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
102
|
+
if (hooks?.guest?.onReady?.(guestObservable)) {
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
await guestObservable.authenticate(await authCode.wait());
|
|
113
106
|
break;
|
|
114
107
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
case import_services.Invitation.State.CANCELLED: {
|
|
121
|
-
if (hooks?.guest?.onCancelled?.(guestObservable)) {
|
|
108
|
+
case import_services.Invitation.State.AUTHENTICATING: {
|
|
109
|
+
hooks?.guest?.onAuthenticating?.(guestObservable);
|
|
122
110
|
break;
|
|
123
111
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
112
|
+
case import_services.Invitation.State.SUCCESS: {
|
|
113
|
+
if (hooks?.guest?.onSuccess?.(guestObservable)) {
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
guestComplete.wake({
|
|
117
|
+
invitation: guestInvitation
|
|
118
|
+
});
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case import_services.Invitation.State.CANCELLED: {
|
|
122
|
+
if (hooks?.guest?.onCancelled?.(guestObservable)) {
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
guestComplete.wake({
|
|
126
|
+
invitation: guestInvitation
|
|
127
|
+
});
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case import_services.Invitation.State.TIMEOUT: {
|
|
131
|
+
if (hooks?.guest?.onTimeout?.(guestObservable)) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
guestComplete.wake({
|
|
135
|
+
invitation: guestInvitation
|
|
136
|
+
});
|
|
132
137
|
}
|
|
133
|
-
guestComplete.wake({
|
|
134
|
-
invitation: guestInvitation
|
|
135
|
-
});
|
|
136
138
|
}
|
|
139
|
+
}, (error) => {
|
|
140
|
+
if (hooks?.guest?.onError?.(guestObservable)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
guestComplete.wake({
|
|
144
|
+
error
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case import_services.Invitation.State.CONNECTED: {
|
|
150
|
+
hooks?.host?.onConnected?.(hostObservable);
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case import_services.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
154
|
+
if (hooks?.host?.onReady?.(hostObservable)) {
|
|
155
|
+
break;
|
|
137
156
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return;
|
|
157
|
+
if (hostInvitation.authCode) {
|
|
158
|
+
authCode.wake(hostInvitation.authCode);
|
|
141
159
|
}
|
|
142
|
-
guestComplete.wake({
|
|
143
|
-
error
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
case import_services.Invitation.State.CONNECTED: {
|
|
149
|
-
hooks?.host?.onConnected?.(hostObservable);
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
case import_services.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
153
|
-
if (hooks?.host?.onReady?.(hostObservable)) {
|
|
154
160
|
break;
|
|
155
161
|
}
|
|
156
|
-
|
|
157
|
-
|
|
162
|
+
case import_services.Invitation.State.AUTHENTICATING: {
|
|
163
|
+
hooks?.host?.onAuthenticating?.(hostObservable);
|
|
164
|
+
break;
|
|
158
165
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (hooks?.host?.onSuccess?.(hostObservable)) {
|
|
166
|
+
case import_services.Invitation.State.SUCCESS: {
|
|
167
|
+
if (hooks?.host?.onSuccess?.(hostObservable)) {
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
hostComplete.wake({
|
|
171
|
+
invitation: hostInvitation
|
|
172
|
+
});
|
|
167
173
|
break;
|
|
168
174
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
case import_services.Invitation.State.CANCELLED: {
|
|
176
|
+
if (hooks?.host?.onCancelled?.(hostObservable)) {
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
hostComplete.wake({
|
|
180
|
+
invitation: hostInvitation
|
|
181
|
+
});
|
|
176
182
|
break;
|
|
177
183
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
case import_services.Invitation.State.TIMEOUT: {
|
|
185
|
+
if (hooks?.host?.onTimeout?.(hostObservable)) {
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
hostComplete.wake({
|
|
189
|
+
invitation: hostInvitation
|
|
190
|
+
});
|
|
185
191
|
break;
|
|
186
192
|
}
|
|
187
|
-
hostComplete.wake({
|
|
188
|
-
invitation: hostInvitation
|
|
189
|
-
});
|
|
190
|
-
break;
|
|
191
193
|
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
}, (error) => {
|
|
195
|
+
if (hooks?.host?.onError?.(hostObservable)) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
hostComplete.wake({
|
|
199
|
+
error
|
|
200
|
+
});
|
|
199
201
|
});
|
|
200
202
|
});
|
|
201
203
|
return [
|
|
@@ -203,23 +205,22 @@ var performInvitation = ({ host, guest, options, hooks, guestDeviceProfile }) =>
|
|
|
203
205
|
guestComplete.wait()
|
|
204
206
|
];
|
|
205
207
|
};
|
|
206
|
-
var createInvitation = (host, options) => {
|
|
208
|
+
var createInvitation = async (host, options) => {
|
|
207
209
|
options ??= {
|
|
208
210
|
authMethod: import_services.Invitation.AuthMethod.NONE,
|
|
209
211
|
...options ?? {}
|
|
210
212
|
};
|
|
211
|
-
if (host instanceof
|
|
212
|
-
|
|
213
|
+
if (host instanceof import_chunk_3EKN7HG6.ServiceContext) {
|
|
214
|
+
return host.invitationsManager.createInvitation({
|
|
213
215
|
kind: import_services.Invitation.Kind.SPACE,
|
|
214
216
|
...options
|
|
215
217
|
});
|
|
216
|
-
return host.invitations.createInvitation(hostHandler, options);
|
|
217
218
|
}
|
|
218
219
|
return host.share(options);
|
|
219
220
|
};
|
|
220
221
|
var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
221
222
|
invitation = sanitizeInvitation(invitation);
|
|
222
|
-
if (guest instanceof
|
|
223
|
+
if (guest instanceof import_chunk_3EKN7HG6.ServiceContext) {
|
|
223
224
|
const guestHandler = guest.getInvitationHandler({
|
|
224
225
|
kind: invitation.kind
|
|
225
226
|
});
|
|
@@ -228,7 +229,7 @@ var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
|
228
229
|
return guest.join(invitation, guestDeviceProfile);
|
|
229
230
|
};
|
|
230
231
|
var createServiceHost = (config, signalManagerContext) => {
|
|
231
|
-
return new
|
|
232
|
+
return new import_chunk_3EKN7HG6.ClientServicesHost({
|
|
232
233
|
config,
|
|
233
234
|
signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
|
|
234
235
|
transportFactory: import_network_manager.MemoryTransportFactory
|
|
@@ -244,7 +245,7 @@ var createServiceContext = async ({ signalContext = new import_messaging.MemoryS
|
|
|
244
245
|
});
|
|
245
246
|
const level = (0, import_testing.createTestLevel)();
|
|
246
247
|
await level.open();
|
|
247
|
-
return new
|
|
248
|
+
return new import_chunk_3EKN7HG6.ServiceContext(storage, level, networkManager, signalManager);
|
|
248
249
|
};
|
|
249
250
|
var createPeers = async (numPeers) => {
|
|
250
251
|
const signalContext = new import_messaging.MemorySignalManagerContext();
|
|
@@ -336,16 +337,26 @@ var TestPeer = class {
|
|
|
336
337
|
}
|
|
337
338
|
get automergeHost() {
|
|
338
339
|
return this._props.automergeHost ??= new import_echo_pipeline.AutomergeHost({
|
|
339
|
-
db:
|
|
340
|
+
db: this.level.sublevel("automerge")
|
|
340
341
|
});
|
|
341
342
|
}
|
|
342
343
|
get dataSpaceManager() {
|
|
343
|
-
return this._props.dataSpaceManager ??= new
|
|
344
|
+
return this._props.dataSpaceManager ??= new import_chunk_3EKN7HG6.DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, this.identity, this.feedStore, this.automergeHost, this.invitationsManager);
|
|
345
|
+
}
|
|
346
|
+
get invitationsManager() {
|
|
347
|
+
return this._props.invitationsManager ??= new import_chunk_3EKN7HG6.InvitationsManager(new import_chunk_3EKN7HG6.InvitationsHandler(this.networkManager), (invitation) => {
|
|
348
|
+
if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
|
|
349
|
+
return new import_chunk_3EKN7HG6.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
|
|
350
|
+
} else {
|
|
351
|
+
throw new Error("not implemented");
|
|
352
|
+
}
|
|
353
|
+
}, this.metadataStore);
|
|
344
354
|
}
|
|
345
355
|
async createIdentity() {
|
|
346
356
|
this._props.signingContext ??= await createSigningContext(this.keyring);
|
|
347
357
|
}
|
|
348
358
|
async destroy() {
|
|
359
|
+
await this.level.close();
|
|
349
360
|
await this.storage.reset();
|
|
350
361
|
}
|
|
351
362
|
};
|
|
@@ -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 {\n AutomergeHost,\n MetadataStore,\n type MyLevel,\n SnapshotStore,\n SpaceManager,\n valueEncoding,\n} 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 { createStorage, StorageType, type Storage } from '@dxos/random-access-storage';\nimport { BlobStore } from '@dxos/teleport-extension-object-sync';\nimport { type MaybePromise } from '@dxos/util';\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 = 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?: MaybePromise<MyLevel>;\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 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 automergeHost() {\n return (this._props.automergeHost ??= new AutomergeHost({\n db: Promise.resolve(this.level).then((level) => level.sublevel('automerge')),\n }));\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,2BAOO;AACP,qBAAgC;AAChC,wBAAuC;AACvC,qBAAwB;AACxB,uBAAgE;AAChE,6BAAuD;AACvD,mCAAyD;AACzD,4CAA0B;
|
|
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 {\n AutomergeHost,\n MetadataStore,\n type LevelDB,\n SnapshotStore,\n SpaceManager,\n valueEncoding,\n} 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 automergeHost?: AutomergeHost;\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 automergeHost() {\n return (this._props.automergeHost ??= new AutomergeHost({\n db: this.level.sublevel('automerge'),\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.automergeHost,\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,2BAOO;AACP,qBAAgC;AAChC,wBAAuC;AACvC,qBAAwB;AACxB,uBAAgE;AAChE,6BAAuD;AACvD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;AAEO,IAAMF,uBAAuB,OAAOhC,YAAAA;AACzC,QAAMmC,cAAc,MAAMnC,QAAQoC,UAAS;AAC3C,QAAMC,YAAY,MAAMrC,QAAQoC,UAAS;AAEzC,SAAO;IACLD;IACAE;IACAC,sBAAkBC,qDAChBvC,SACA;MACEwC,YAAY,MAAM,IAAIC,wCAAoBzC,SAASmC,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", "automergeHost", "AutomergeHost", "db", "sublevel", "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":"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,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAc,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAEL,KAAK,qBAAqB,EAE1B,KAAK,eAAe,EACrB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAYtC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,SAAS,CAAC;IACvB,SAAS,EAAE,SAAS,CAAC;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
|
6
|
-
export declare const createSelectedDocumentsIterator: (automergeHost: AutomergeHost) => (ids:
|
|
6
|
+
export declare const createSelectedDocumentsIterator: (automergeHost: AutomergeHost) => (ids: ObjectPointerEncoded[]) => AsyncGenerator<{
|
|
7
7
|
id: string;
|
|
8
8
|
object: any;
|
|
9
9
|
currentHash: string;
|
|
10
10
|
}[], void, unknown>;
|
|
11
|
-
/**
|
|
12
|
-
* Factory for `getAllDocuments` iterator.
|
|
13
|
-
*/
|
|
14
|
-
export declare const createDocumentsIterator: (automergeHost: AutomergeHost) => () => AsyncGenerator<ObjectSnapshot[], void, 'done'>;
|
|
15
11
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/indexing/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/indexing/util.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,KAAK,oBAAoB,EAAW,MAAM,iBAAiB,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,+BAA+B,kBAAmB,aAAa,WAMvC,oBAAoB,EAAE;;;;mBAaxD,CAAC"}
|
|
@@ -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>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/device-invitation-protocol.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAErE,qBAAa,wBAAyB,YAAW,kBAAkB;IAE/D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,MAAM,QAAQ,EAC5B,eAAe,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,QAAQ,CAAC;IAGvF,MAAM,IAAI,MAAM;IAIhB,oBA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IAIpD,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAejF,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;IAW/C,kBAAkB,IAAI,mBAAmB;IAInC,sBAAsB,CAAC,aAAa,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAexF,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;CAsBnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/index.ts"],"names":[],"mappings":"AAIA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/index.ts"],"names":[],"mappings":"AAIA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PublicKey } from '@dxos/keys';
|
|
1
2
|
import type { ApiError } from '@dxos/protocols';
|
|
2
3
|
import type { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
3
4
|
import type { ProfileDocument, DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
@@ -14,7 +15,11 @@ export interface InvitationProtocol {
|
|
|
14
15
|
/**
|
|
15
16
|
* Once authentication is successful, the host can admit the guest to the requested resource.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
delegate(invitation: Invitation): Promise<PublicKey>;
|
|
19
|
+
/**
|
|
20
|
+
* Once authentication is successful, the host can admit the guest to the requested resource.
|
|
21
|
+
*/
|
|
22
|
+
admit(invitation: Invitation, request: AdmissionRequest, guestProfile?: ProfileDocument): Promise<AdmissionResponse>;
|
|
18
23
|
/**
|
|
19
24
|
* Check if the invitation is valid.
|
|
20
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitation-protocol.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAC1G,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,6CAA6C,CAAC;AAErD,MAAM,WAAW,kBAAkB;IAKjC;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC;IAMjB;;OAEG;IACH,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAEvE;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitation-protocol.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAC1G,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,6CAA6C,CAAC;AAErD,MAAM,WAAW,kBAAkB;IAKjC;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC;IAMjB;;OAEG;IACH,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAEvE;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAErD;;OAEG;IACH,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAMrH;;;;OAIG;IACH,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,SAAS,CAAC;IAEvE;;OAEG;IACH,kBAAkB,IAAI,mBAAmB,CAAC;IAE1C;;OAEG;IACH,sBAAsB,CAAC,aAAa,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEzF;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;CAC9F"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PushStream } from '@dxos/async';
|
|
2
|
+
import { AuthenticatingInvitation } from '@dxos/client-protocol';
|
|
3
|
+
import { Context } from '@dxos/context';
|
|
2
4
|
import { type AdmissionKeypair, Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
3
5
|
import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
4
6
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
@@ -31,7 +33,7 @@ import { type InvitationProtocol } from './invitation-protocol';
|
|
|
31
33
|
*/
|
|
32
34
|
export declare class InvitationsHandler {
|
|
33
35
|
private readonly _networkManager;
|
|
34
|
-
|
|
36
|
+
handleInvitationFlow(ctx: Context, stream: PushStream<Invitation>, protocol: InvitationProtocol, invitation: Invitation): void;
|
|
35
37
|
acceptInvitation(protocol: InvitationProtocol, invitation: Invitation, deviceProfile?: DeviceProfileDocument): AuthenticatingInvitation;
|
|
36
38
|
private _handleGuestOtpAuth;
|
|
37
39
|
private _handleGuestKpkAuth;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitations-handler.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitations-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invitations-handler.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitations-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAuC,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAsB,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAYxC,OAAO,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AASzF,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,kBAAkB;IAIjB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAE5C,oBAAoB,CAClB,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,EAC9B,QAAQ,EAAE,kBAAkB,EAC5B,UAAU,EAAE,UAAU,GACrB,IAAI;IAoHP,gBAAgB,CACd,QAAQ,EAAE,kBAAkB,EAC5B,UAAU,EAAE,UAAU,EACtB,aAAa,CAAC,EAAE,qBAAqB,GACpC,wBAAwB;YAyKb,mBAAmB;YA6BnB,mBAAmB;CAsBlC;AAED,eAAO,MAAM,sBAAsB,QAAO,gBAGzC,CAAC"}
|