@dxos/client-services 0.1.56-main.09ca29d → 0.1.56-main.0e9f69e
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-FD4L7N4K.mjs → chunk-II6TDINB.mjs} +782 -511
- package/dist/lib/browser/chunk-II6TDINB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +30 -31
- 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 +31 -46
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +918 -649
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +1198 -939
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts +7 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +7 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts +16 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +7 -3
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +6 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +12 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +2 -0
- package/dist/types/src/version.d.ts.map +1 -0
- package/package.json +34 -33
- package/src/packlets/devices/devices-service.test.ts +2 -1
- package/src/packlets/identity/identity-manager.test.ts +15 -3
- package/src/packlets/identity/identity-manager.ts +27 -6
- package/src/packlets/identity/identity-service.test.ts +17 -2
- package/src/packlets/identity/identity-service.ts +23 -14
- package/src/packlets/identity/identity.test.ts +7 -6
- package/src/packlets/identity/identity.ts +8 -3
- package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
- package/src/packlets/logging/logging-service.ts +17 -9
- package/src/packlets/network/network-service.test.ts +2 -1
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/diagnostics.ts +211 -0
- package/src/packlets/services/index.ts +1 -0
- package/src/packlets/services/platform.ts +48 -0
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +16 -9
- package/src/packlets/services/service-host.test.ts +11 -10
- package/src/packlets/services/service-host.ts +38 -18
- package/src/packlets/services/service-registry.test.ts +3 -1
- package/src/packlets/services/util.ts +33 -0
- package/src/packlets/spaces/data-space-manager.test.ts +80 -22
- package/src/packlets/spaces/data-space.ts +17 -5
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/system/system-service.test.ts +1 -0
- package/src/packlets/system/system-service.ts +34 -2
- package/src/packlets/testing/test-builder.ts +1 -1
- package/src/packlets/vault/iframe-host-runtime.ts +2 -1
- package/src/packlets/vault/worker-runtime.ts +3 -2
- package/src/packlets/vault/worker-session.ts +6 -1
- package/src/version.ts +1 -0
- package/dist/lib/browser/chunk-FD4L7N4K.mjs.map +0 -7
|
@@ -52,36 +52,197 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
|
|
|
52
52
|
|
|
53
53
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
54
54
|
var import_async18 = require("@dxos/async");
|
|
55
|
-
var
|
|
56
|
-
var
|
|
55
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
56
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
57
57
|
|
|
58
58
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
59
59
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
60
60
|
var import_debug = require("@dxos/debug");
|
|
61
61
|
var import_rpc = require("@dxos/rpc");
|
|
62
62
|
|
|
63
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
64
|
+
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
65
|
+
var import_credentials2 = require("@dxos/credentials");
|
|
66
|
+
var import_document_model = require("@dxos/document-model");
|
|
67
|
+
var import_invariant = require("@dxos/invariant");
|
|
68
|
+
var import_log = require("@dxos/log");
|
|
69
|
+
var import_protocols = require("@dxos/protocols");
|
|
70
|
+
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
71
|
+
|
|
72
|
+
// packages/sdk/client-services/src/version.ts
|
|
73
|
+
var DXOS_VERSION = "0.1.56-main.0e9f69e";
|
|
74
|
+
|
|
75
|
+
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
76
|
+
var getPlatform = () => {
|
|
77
|
+
if (process.browser) {
|
|
78
|
+
if (typeof window !== "undefined") {
|
|
79
|
+
const { userAgent } = window.navigator;
|
|
80
|
+
return {
|
|
81
|
+
type: "browser",
|
|
82
|
+
userAgent,
|
|
83
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
84
|
+
};
|
|
85
|
+
} else {
|
|
86
|
+
return {
|
|
87
|
+
type: "shared-worker",
|
|
88
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
const { platform, version, arch } = process;
|
|
93
|
+
return {
|
|
94
|
+
type: "node",
|
|
95
|
+
platform: `${platform} ${version} ${arch}`,
|
|
96
|
+
runtime: process.version,
|
|
97
|
+
uptime: Math.floor(process.uptime()),
|
|
98
|
+
memory: process.memoryUsage()
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
104
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
105
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
106
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
107
|
+
const diagnostics = {
|
|
108
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
109
|
+
platform: getPlatform(),
|
|
110
|
+
client: {
|
|
111
|
+
version: DXOS_VERSION,
|
|
112
|
+
storage: {
|
|
113
|
+
version: import_protocols.STORAGE_VERSION
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
{
|
|
118
|
+
(0, import_invariant.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
119
|
+
F: __dxlog_file,
|
|
120
|
+
L: 87,
|
|
121
|
+
S: void 0,
|
|
122
|
+
A: [
|
|
123
|
+
"clientServices.LoggingService",
|
|
124
|
+
"'SystemService is not available.'"
|
|
125
|
+
]
|
|
126
|
+
});
|
|
127
|
+
diagnostics.metrics = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
128
|
+
timeout: DEFAULT_TIMEOUT
|
|
129
|
+
}).catch(() => void 0);
|
|
130
|
+
}
|
|
131
|
+
const identity = serviceContext.identityManager.identity;
|
|
132
|
+
if (identity) {
|
|
133
|
+
diagnostics.identity = {
|
|
134
|
+
identityKey: identity.identityKey,
|
|
135
|
+
spaceKey: identity.space.key,
|
|
136
|
+
profile: identity.profileDocument
|
|
137
|
+
};
|
|
138
|
+
const { devices } = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
139
|
+
timeout: DEFAULT_TIMEOUT
|
|
140
|
+
}).catch(() => void 0) ?? {};
|
|
141
|
+
diagnostics.devices = devices;
|
|
142
|
+
if (serviceContext.dataSpaceManager) {
|
|
143
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
144
|
+
}
|
|
145
|
+
const { feeds = [] } = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
146
|
+
timeout: DEFAULT_TIMEOUT
|
|
147
|
+
}).catch(() => void 0) ?? {};
|
|
148
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
149
|
+
feedKey,
|
|
150
|
+
bytes,
|
|
151
|
+
length
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
diagnostics.config = config.values;
|
|
155
|
+
return diagnostics;
|
|
156
|
+
};
|
|
157
|
+
var getProperties = (space) => {
|
|
158
|
+
let properties = {};
|
|
159
|
+
try {
|
|
160
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === import_document_model.DocumentModel.meta.type && item.state?.type === "dxos.sdk.client.Properties");
|
|
161
|
+
const state = propertiesItem?.state;
|
|
162
|
+
properties = state?.data;
|
|
163
|
+
} catch (err) {
|
|
164
|
+
import_log.log.warn(err.message, void 0, {
|
|
165
|
+
F: __dxlog_file,
|
|
166
|
+
L: 144,
|
|
167
|
+
S: void 0,
|
|
168
|
+
C: (f, a) => f(...a)
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return properties;
|
|
172
|
+
};
|
|
173
|
+
var getSpaceStats = async (space) => {
|
|
174
|
+
const stats = {
|
|
175
|
+
key: space.key,
|
|
176
|
+
metrics: space.metrics,
|
|
177
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials2.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
178
|
+
...credential.subject.assertion,
|
|
179
|
+
id: credential.id
|
|
180
|
+
})),
|
|
181
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
182
|
+
identity: {
|
|
183
|
+
identityKey: member.key,
|
|
184
|
+
profile: {
|
|
185
|
+
displayName: member.assertion.profile?.displayName
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services.SpaceMember.PresenceState.ONLINE : import_services.SpaceMember.PresenceState.OFFLINE
|
|
189
|
+
})),
|
|
190
|
+
pipeline: {
|
|
191
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
192
|
+
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
193
|
+
// appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
194
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
195
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
196
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
197
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
198
|
+
// TODO(burdon): Empty?
|
|
199
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
200
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
201
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
202
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
203
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
if (space.dataPipeline.itemManager) {
|
|
207
|
+
Object.assign(stats, {
|
|
208
|
+
properties: getProperties(space),
|
|
209
|
+
db: {
|
|
210
|
+
objects: space.dataPipeline.itemManager.entities.size
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
if (stats.metrics) {
|
|
215
|
+
const { open, ready } = stats.metrics;
|
|
216
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
217
|
+
}
|
|
218
|
+
return stats;
|
|
219
|
+
};
|
|
220
|
+
|
|
63
221
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
64
222
|
var import_async11 = require("@dxos/async");
|
|
65
|
-
var
|
|
223
|
+
var import_context8 = require("@dxos/context");
|
|
224
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
66
225
|
var import_debug7 = require("@dxos/debug");
|
|
67
226
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
68
227
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
69
|
-
var
|
|
228
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
70
229
|
var import_keyring = require("@dxos/keyring");
|
|
71
230
|
var import_keys8 = require("@dxos/keys");
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
231
|
+
var import_log13 = require("@dxos/log");
|
|
232
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
233
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
75
234
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
235
|
+
var import_tracing3 = require("@dxos/tracing");
|
|
236
|
+
var import_util6 = require("@dxos/util");
|
|
76
237
|
|
|
77
238
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
78
239
|
var import_async = require("@dxos/async");
|
|
79
240
|
var import_context = require("@dxos/context");
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var Credential =
|
|
241
|
+
var import_credentials3 = require("@dxos/credentials");
|
|
242
|
+
var import_log2 = require("@dxos/log");
|
|
243
|
+
var import_protocols2 = require("@dxos/protocols");
|
|
244
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
245
|
+
var Credential = import_protocols2.schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
85
246
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
86
247
|
const credential = await signer.createCredential({
|
|
87
248
|
assertion: {
|
|
@@ -104,20 +265,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
104
265
|
get verifier() {
|
|
105
266
|
return async (nonce, auth) => {
|
|
106
267
|
const credential = Credential.decode(auth);
|
|
107
|
-
(0,
|
|
268
|
+
(0, import_log2.log)("authenticating...", {
|
|
108
269
|
credential
|
|
109
270
|
}, {
|
|
110
|
-
F:
|
|
271
|
+
F: __dxlog_file2,
|
|
111
272
|
L: 59,
|
|
112
273
|
S: this,
|
|
113
274
|
C: (f, a) => f(...a)
|
|
114
275
|
});
|
|
115
|
-
const result = await (0,
|
|
276
|
+
const result = await (0, import_credentials3.verifyCredential)(credential);
|
|
116
277
|
if (result.kind === "fail") {
|
|
117
|
-
(0,
|
|
278
|
+
(0, import_log2.log)("Invalid credential", {
|
|
118
279
|
result
|
|
119
280
|
}, {
|
|
120
|
-
F:
|
|
281
|
+
F: __dxlog_file2,
|
|
121
282
|
L: 63,
|
|
122
283
|
S: this,
|
|
123
284
|
C: (f, a) => f(...a)
|
|
@@ -125,11 +286,11 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
125
286
|
return false;
|
|
126
287
|
}
|
|
127
288
|
if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
|
|
128
|
-
(0,
|
|
289
|
+
(0, import_log2.log)("Invalid nonce", {
|
|
129
290
|
nonce,
|
|
130
291
|
credential
|
|
131
292
|
}, {
|
|
132
|
-
F:
|
|
293
|
+
F: __dxlog_file2,
|
|
133
294
|
L: 68,
|
|
134
295
|
S: this,
|
|
135
296
|
C: (f, a) => f(...a)
|
|
@@ -137,10 +298,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
137
298
|
return false;
|
|
138
299
|
}
|
|
139
300
|
if (this._isTrustedKey(credential.issuer)) {
|
|
140
|
-
(0,
|
|
301
|
+
(0, import_log2.log)("key is not currently in trusted set, waiting...", {
|
|
141
302
|
key: credential.issuer
|
|
142
303
|
}, {
|
|
143
|
-
F:
|
|
304
|
+
F: __dxlog_file2,
|
|
144
305
|
L: 73,
|
|
145
306
|
S: this,
|
|
146
307
|
C: (f, a) => f(...a)
|
|
@@ -153,20 +314,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
153
314
|
});
|
|
154
315
|
const clear = this._params.update.on(this._ctx, () => {
|
|
155
316
|
if (this._isTrustedKey(credential.issuer)) {
|
|
156
|
-
(0,
|
|
317
|
+
(0, import_log2.log)("auth success", {
|
|
157
318
|
key: credential.issuer
|
|
158
319
|
}, {
|
|
159
|
-
F:
|
|
320
|
+
F: __dxlog_file2,
|
|
160
321
|
L: 84,
|
|
161
322
|
S: this,
|
|
162
323
|
C: (f, a) => f(...a)
|
|
163
324
|
});
|
|
164
325
|
trigger.wake(true);
|
|
165
326
|
} else {
|
|
166
|
-
(0,
|
|
327
|
+
(0, import_log2.log)("key is not currently in trusted set, waiting...", {
|
|
167
328
|
key: credential.issuer
|
|
168
329
|
}, {
|
|
169
|
-
F:
|
|
330
|
+
F: __dxlog_file2,
|
|
170
331
|
L: 87,
|
|
171
332
|
S: this,
|
|
172
333
|
C: (f, a) => f(...a)
|
|
@@ -177,7 +338,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
177
338
|
return await trigger.wait({
|
|
178
339
|
timeout: this._params.authTimeout
|
|
179
340
|
});
|
|
180
|
-
} catch
|
|
341
|
+
} catch {
|
|
181
342
|
return false;
|
|
182
343
|
} finally {
|
|
183
344
|
clear();
|
|
@@ -193,26 +354,37 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
193
354
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
194
355
|
var import_async2 = require("@dxos/async");
|
|
195
356
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
196
|
-
var
|
|
357
|
+
var import_credentials4 = require("@dxos/credentials");
|
|
197
358
|
var import_debug2 = require("@dxos/debug");
|
|
198
359
|
var import_feed_store = require("@dxos/feed-store");
|
|
199
|
-
var
|
|
200
|
-
var
|
|
201
|
-
var
|
|
202
|
-
var
|
|
203
|
-
|
|
360
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
361
|
+
var import_log3 = require("@dxos/log");
|
|
362
|
+
var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
363
|
+
var import_tracing = require("@dxos/tracing");
|
|
364
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
365
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
366
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
367
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
368
|
+
else
|
|
369
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
370
|
+
if (d = decorators[i])
|
|
371
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
372
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
373
|
+
}
|
|
374
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
375
|
+
var Identity = class Identity2 {
|
|
204
376
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
205
377
|
this.stateUpdate = new import_async2.Event();
|
|
206
378
|
this.space = space;
|
|
207
379
|
this._signer = signer;
|
|
208
380
|
this.identityKey = identityKey;
|
|
209
381
|
this.deviceKey = deviceKey;
|
|
210
|
-
this._deviceStateMachine = new
|
|
382
|
+
this._deviceStateMachine = new import_credentials4.DeviceStateMachine({
|
|
211
383
|
identityKey: this.identityKey,
|
|
212
384
|
deviceKey: this.deviceKey,
|
|
213
385
|
onUpdate: () => this.stateUpdate.emit()
|
|
214
386
|
});
|
|
215
|
-
this._profileStateMachine = new
|
|
387
|
+
this._profileStateMachine = new import_credentials4.ProfileStateMachine({
|
|
216
388
|
identityKey: this.identityKey,
|
|
217
389
|
onUpdate: () => this.stateUpdate.emit()
|
|
218
390
|
});
|
|
@@ -226,12 +398,12 @@ var Identity = class {
|
|
|
226
398
|
get authorizedDeviceKeys() {
|
|
227
399
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
228
400
|
}
|
|
229
|
-
async open() {
|
|
401
|
+
async open(ctx) {
|
|
230
402
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
231
403
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
232
|
-
await this.space.open();
|
|
404
|
+
await this.space.open(ctx);
|
|
233
405
|
}
|
|
234
|
-
async close() {
|
|
406
|
+
async close(ctx) {
|
|
235
407
|
await this.authVerifier.close();
|
|
236
408
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
237
409
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
@@ -262,11 +434,10 @@ var Identity = class {
|
|
|
262
434
|
return this._deviceStateMachine.deviceCredentialChain;
|
|
263
435
|
}
|
|
264
436
|
getAdmissionCredentials() {
|
|
265
|
-
var _a, _b;
|
|
266
437
|
return {
|
|
267
438
|
deviceKey: this.deviceKey,
|
|
268
|
-
controlFeedKey:
|
|
269
|
-
dataFeedKey:
|
|
439
|
+
controlFeedKey: this.space.controlFeedKey ?? (0, import_debug2.failUndefined)(),
|
|
440
|
+
dataFeedKey: this.space.dataFeedKey ?? (0, import_debug2.failUndefined)()
|
|
270
441
|
};
|
|
271
442
|
}
|
|
272
443
|
/**
|
|
@@ -274,33 +445,33 @@ var Identity = class {
|
|
|
274
445
|
* Requires identity to be ready.
|
|
275
446
|
*/
|
|
276
447
|
getIdentityCredentialSigner() {
|
|
277
|
-
(0,
|
|
278
|
-
F:
|
|
279
|
-
L:
|
|
448
|
+
(0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
449
|
+
F: __dxlog_file3,
|
|
450
|
+
L: 139,
|
|
280
451
|
S: this,
|
|
281
452
|
A: [
|
|
282
453
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
283
454
|
"'Device credential chain is not ready.'"
|
|
284
455
|
]
|
|
285
456
|
});
|
|
286
|
-
return (0,
|
|
457
|
+
return (0, import_credentials4.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
287
458
|
}
|
|
288
459
|
/**
|
|
289
460
|
* Issues credentials as device.
|
|
290
461
|
*/
|
|
291
462
|
getDeviceCredentialSigner() {
|
|
292
|
-
return (0,
|
|
463
|
+
return (0, import_credentials4.createCredentialSignerWithKey)(this._signer, this.deviceKey);
|
|
293
464
|
}
|
|
294
465
|
async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
|
|
295
|
-
(0,
|
|
466
|
+
(0, import_log3.log)("Admitting device:", {
|
|
296
467
|
identityKey: this.identityKey,
|
|
297
468
|
hostDevice: this.deviceKey,
|
|
298
469
|
deviceKey,
|
|
299
470
|
controlFeedKey,
|
|
300
471
|
dataFeedKey
|
|
301
472
|
}, {
|
|
302
|
-
F:
|
|
303
|
-
L:
|
|
473
|
+
F: __dxlog_file3,
|
|
474
|
+
L: 155,
|
|
304
475
|
S: this,
|
|
305
476
|
C: (f, a) => f(...a)
|
|
306
477
|
});
|
|
@@ -321,7 +492,7 @@ var Identity = class {
|
|
|
321
492
|
spaceKey: this.haloSpaceKey,
|
|
322
493
|
deviceKey,
|
|
323
494
|
identityKey: this.identityKey,
|
|
324
|
-
designation:
|
|
495
|
+
designation: import_credentials5.AdmittedFeed.Designation.CONTROL
|
|
325
496
|
}
|
|
326
497
|
}),
|
|
327
498
|
await signer.createCredential({
|
|
@@ -331,7 +502,7 @@ var Identity = class {
|
|
|
331
502
|
spaceKey: this.haloSpaceKey,
|
|
332
503
|
deviceKey,
|
|
333
504
|
identityKey: this.identityKey,
|
|
334
|
-
designation:
|
|
505
|
+
designation: import_credentials5.AdmittedFeed.Designation.DATA
|
|
335
506
|
}
|
|
336
507
|
})
|
|
337
508
|
].map((credential) => ({
|
|
@@ -341,18 +512,40 @@ var Identity = class {
|
|
|
341
512
|
})));
|
|
342
513
|
}
|
|
343
514
|
};
|
|
515
|
+
_ts_decorate([
|
|
516
|
+
import_tracing.trace.span()
|
|
517
|
+
], Identity.prototype, "open", null);
|
|
518
|
+
_ts_decorate([
|
|
519
|
+
import_tracing.trace.span()
|
|
520
|
+
], Identity.prototype, "close", null);
|
|
521
|
+
Identity = _ts_decorate([
|
|
522
|
+
import_tracing.trace.resource()
|
|
523
|
+
], Identity);
|
|
344
524
|
|
|
345
525
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
346
526
|
var import_async3 = require("@dxos/async");
|
|
347
|
-
var
|
|
348
|
-
var
|
|
527
|
+
var import_context2 = require("@dxos/context");
|
|
528
|
+
var import_credentials6 = require("@dxos/credentials");
|
|
529
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
349
530
|
var import_keys2 = require("@dxos/keys");
|
|
350
|
-
var
|
|
351
|
-
var
|
|
352
|
-
var
|
|
531
|
+
var import_log4 = require("@dxos/log");
|
|
532
|
+
var import_protocols3 = require("@dxos/protocols");
|
|
533
|
+
var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
534
|
+
var import_timeframe = require("@dxos/timeframe");
|
|
535
|
+
var import_tracing2 = require("@dxos/tracing");
|
|
353
536
|
var import_util = require("@dxos/util");
|
|
354
|
-
|
|
355
|
-
var
|
|
537
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
538
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
539
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
540
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
541
|
+
else
|
|
542
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
543
|
+
if (d = decorators[i])
|
|
544
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
545
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
546
|
+
}
|
|
547
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
548
|
+
var IdentityManager = class IdentityManager2 {
|
|
356
549
|
// TODO(burdon): IdentityManagerParams.
|
|
357
550
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
358
551
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -365,69 +558,66 @@ var IdentityManager = class {
|
|
|
365
558
|
get identity() {
|
|
366
559
|
return this._identity;
|
|
367
560
|
}
|
|
368
|
-
async open() {
|
|
369
|
-
var _a;
|
|
561
|
+
async open(ctx) {
|
|
370
562
|
const traceId = import_keys2.PublicKey.random().toHex();
|
|
371
|
-
|
|
563
|
+
import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
|
|
372
564
|
id: traceId
|
|
373
565
|
}), {
|
|
374
|
-
F:
|
|
375
|
-
L:
|
|
566
|
+
F: __dxlog_file4,
|
|
567
|
+
L: 73,
|
|
376
568
|
S: this,
|
|
377
569
|
C: (f, a) => f(...a)
|
|
378
570
|
});
|
|
379
571
|
await this._metadataStore.load();
|
|
380
572
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
381
|
-
(0,
|
|
573
|
+
(0, import_log4.log)("identity record", {
|
|
382
574
|
identityRecord
|
|
383
575
|
}, {
|
|
384
|
-
F:
|
|
385
|
-
L:
|
|
576
|
+
F: __dxlog_file4,
|
|
577
|
+
L: 77,
|
|
386
578
|
S: this,
|
|
387
579
|
C: (f, a) => f(...a)
|
|
388
580
|
});
|
|
389
581
|
if (identityRecord) {
|
|
390
582
|
this._identity = await this._constructIdentity(identityRecord);
|
|
391
|
-
await this._identity.open();
|
|
583
|
+
await this._identity.open(ctx);
|
|
392
584
|
await this._identity.ready();
|
|
393
|
-
|
|
585
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
394
586
|
identityKey: identityRecord.identityKey,
|
|
395
|
-
displayName:
|
|
587
|
+
displayName: this._identity.profileDocument?.displayName
|
|
396
588
|
}, {
|
|
397
|
-
F:
|
|
398
|
-
L:
|
|
589
|
+
F: __dxlog_file4,
|
|
590
|
+
L: 82,
|
|
399
591
|
S: this,
|
|
400
592
|
C: (f, a) => f(...a)
|
|
401
593
|
});
|
|
402
594
|
this.stateUpdate.emit();
|
|
403
595
|
}
|
|
404
|
-
|
|
596
|
+
import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
|
|
405
597
|
id: traceId
|
|
406
598
|
}), {
|
|
407
|
-
F:
|
|
408
|
-
L:
|
|
599
|
+
F: __dxlog_file4,
|
|
600
|
+
L: 88,
|
|
409
601
|
S: this,
|
|
410
602
|
C: (f, a) => f(...a)
|
|
411
603
|
});
|
|
412
604
|
}
|
|
413
605
|
async close() {
|
|
414
|
-
|
|
415
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
606
|
+
await this._identity?.close(new import_context2.Context());
|
|
416
607
|
}
|
|
417
608
|
async createIdentity({ displayName } = {}) {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
L: 92,
|
|
609
|
+
(0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
|
|
610
|
+
F: __dxlog_file4,
|
|
611
|
+
L: 96,
|
|
422
612
|
S: this,
|
|
423
613
|
A: [
|
|
424
614
|
"!this._identity",
|
|
425
615
|
"'Identity already exists.'"
|
|
426
616
|
]
|
|
427
617
|
});
|
|
428
|
-
(0,
|
|
429
|
-
F:
|
|
430
|
-
L:
|
|
618
|
+
(0, import_log4.log)("creating identity...", void 0, {
|
|
619
|
+
F: __dxlog_file4,
|
|
620
|
+
L: 97,
|
|
431
621
|
S: this,
|
|
432
622
|
C: (f, a) => f(...a)
|
|
433
623
|
});
|
|
@@ -443,21 +633,21 @@ var IdentityManager = class {
|
|
|
443
633
|
}
|
|
444
634
|
};
|
|
445
635
|
const identity = await this._constructIdentity(identityRecord);
|
|
446
|
-
await identity.open();
|
|
636
|
+
await identity.open(new import_context2.Context());
|
|
447
637
|
{
|
|
448
|
-
const generator = new
|
|
449
|
-
(0,
|
|
450
|
-
F:
|
|
451
|
-
L:
|
|
638
|
+
const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
639
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
640
|
+
F: __dxlog_file4,
|
|
641
|
+
L: 116,
|
|
452
642
|
S: this,
|
|
453
643
|
A: [
|
|
454
644
|
"identityRecord.haloSpace.genesisFeedKey",
|
|
455
645
|
"'Genesis feed key is required.'"
|
|
456
646
|
]
|
|
457
647
|
});
|
|
458
|
-
(0,
|
|
459
|
-
F:
|
|
460
|
-
L:
|
|
648
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
649
|
+
F: __dxlog_file4,
|
|
650
|
+
L: 117,
|
|
461
651
|
S: this,
|
|
462
652
|
A: [
|
|
463
653
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -468,7 +658,7 @@ var IdentityManager = class {
|
|
|
468
658
|
// Space genesis.
|
|
469
659
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
470
660
|
// Feed admission.
|
|
471
|
-
await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey,
|
|
661
|
+
await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials7.AdmittedFeed.Designation.DATA)
|
|
472
662
|
];
|
|
473
663
|
if (displayName) {
|
|
474
664
|
credentials.push(await generator.createProfileCredential({
|
|
@@ -487,22 +677,22 @@ var IdentityManager = class {
|
|
|
487
677
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
488
678
|
this._identity = identity;
|
|
489
679
|
await this._identity.ready();
|
|
490
|
-
|
|
680
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
491
681
|
identityKey: identityRecord.identityKey,
|
|
492
|
-
displayName:
|
|
682
|
+
displayName: this._identity.profileDocument?.displayName
|
|
493
683
|
}, {
|
|
494
|
-
F:
|
|
495
|
-
L:
|
|
684
|
+
F: __dxlog_file4,
|
|
685
|
+
L: 152,
|
|
496
686
|
S: this,
|
|
497
687
|
C: (f, a) => f(...a)
|
|
498
688
|
});
|
|
499
689
|
this.stateUpdate.emit();
|
|
500
|
-
(0,
|
|
690
|
+
(0, import_log4.log)("created identity", {
|
|
501
691
|
identityKey: identity.identityKey,
|
|
502
692
|
deviceKey: identity.deviceKey
|
|
503
693
|
}, {
|
|
504
|
-
F:
|
|
505
|
-
L:
|
|
694
|
+
F: __dxlog_file4,
|
|
695
|
+
L: 158,
|
|
506
696
|
S: this,
|
|
507
697
|
C: (f, a) => f(...a)
|
|
508
698
|
});
|
|
@@ -512,18 +702,17 @@ var IdentityManager = class {
|
|
|
512
702
|
* Accept an existing identity. Expects it's device key to be authorized (now or later).
|
|
513
703
|
*/
|
|
514
704
|
async acceptIdentity(params) {
|
|
515
|
-
|
|
516
|
-
(0, import_log3.log)("accepting identity", {
|
|
705
|
+
(0, import_log4.log)("accepting identity", {
|
|
517
706
|
params
|
|
518
707
|
}, {
|
|
519
|
-
F:
|
|
520
|
-
L:
|
|
708
|
+
F: __dxlog_file4,
|
|
709
|
+
L: 166,
|
|
521
710
|
S: this,
|
|
522
711
|
C: (f, a) => f(...a)
|
|
523
712
|
});
|
|
524
|
-
(0,
|
|
525
|
-
F:
|
|
526
|
-
L:
|
|
713
|
+
(0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
|
|
714
|
+
F: __dxlog_file4,
|
|
715
|
+
L: 167,
|
|
527
716
|
S: this,
|
|
528
717
|
A: [
|
|
529
718
|
"!this._identity",
|
|
@@ -542,52 +731,84 @@ var IdentityManager = class {
|
|
|
542
731
|
}
|
|
543
732
|
};
|
|
544
733
|
const identity = await this._constructIdentity(identityRecord);
|
|
545
|
-
await identity.open();
|
|
734
|
+
await identity.open(new import_context2.Context());
|
|
546
735
|
this._identity = identity;
|
|
547
736
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
548
737
|
await this._identity.ready();
|
|
549
|
-
|
|
738
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
550
739
|
identityKey: identityRecord.identityKey,
|
|
551
|
-
displayName:
|
|
740
|
+
displayName: this._identity.profileDocument?.displayName
|
|
552
741
|
}, {
|
|
553
|
-
F:
|
|
554
|
-
L:
|
|
742
|
+
F: __dxlog_file4,
|
|
743
|
+
L: 186,
|
|
555
744
|
S: this,
|
|
556
745
|
C: (f, a) => f(...a)
|
|
557
746
|
});
|
|
558
747
|
this.stateUpdate.emit();
|
|
559
|
-
(0,
|
|
748
|
+
(0, import_log4.log)("accepted identity", {
|
|
560
749
|
identityKey: identity.identityKey,
|
|
561
750
|
deviceKey: identity.deviceKey
|
|
562
751
|
}, {
|
|
563
|
-
F:
|
|
564
|
-
L:
|
|
752
|
+
F: __dxlog_file4,
|
|
753
|
+
L: 192,
|
|
565
754
|
S: this,
|
|
566
755
|
C: (f, a) => f(...a)
|
|
567
756
|
});
|
|
568
757
|
return identity;
|
|
569
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* Update the profile document of an existing identity.
|
|
761
|
+
*/
|
|
762
|
+
async updateProfile(profile) {
|
|
763
|
+
(0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
|
|
764
|
+
F: __dxlog_file4,
|
|
765
|
+
L: 200,
|
|
766
|
+
S: this,
|
|
767
|
+
A: [
|
|
768
|
+
"this._identity",
|
|
769
|
+
"'Identity not initialized.'"
|
|
770
|
+
]
|
|
771
|
+
});
|
|
772
|
+
const credential = await this._identity.getIdentityCredentialSigner().createCredential({
|
|
773
|
+
subject: this._identity.identityKey,
|
|
774
|
+
assertion: {
|
|
775
|
+
"@type": "dxos.halo.credentials.IdentityProfile",
|
|
776
|
+
profile
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
const receipt = await this._identity.controlPipeline.writer.write({
|
|
780
|
+
credential: {
|
|
781
|
+
credential
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
|
|
785
|
+
[
|
|
786
|
+
receipt.feedKey,
|
|
787
|
+
receipt.seq
|
|
788
|
+
]
|
|
789
|
+
]));
|
|
790
|
+
}
|
|
570
791
|
async _constructIdentity(identityRecord) {
|
|
571
|
-
(0,
|
|
572
|
-
F:
|
|
573
|
-
L:
|
|
792
|
+
(0, import_invariant3.invariant)(!this._identity, void 0, {
|
|
793
|
+
F: __dxlog_file4,
|
|
794
|
+
L: 214,
|
|
574
795
|
S: this,
|
|
575
796
|
A: [
|
|
576
797
|
"!this._identity",
|
|
577
798
|
""
|
|
578
799
|
]
|
|
579
800
|
});
|
|
580
|
-
(0,
|
|
801
|
+
(0, import_log4.log)("constructing identity", {
|
|
581
802
|
identityRecord
|
|
582
803
|
}, {
|
|
583
|
-
F:
|
|
584
|
-
L:
|
|
804
|
+
F: __dxlog_file4,
|
|
805
|
+
L: 215,
|
|
585
806
|
S: this,
|
|
586
807
|
C: (f, a) => f(...a)
|
|
587
808
|
});
|
|
588
|
-
(0,
|
|
589
|
-
F:
|
|
590
|
-
L:
|
|
809
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
810
|
+
F: __dxlog_file4,
|
|
811
|
+
L: 218,
|
|
591
812
|
S: this,
|
|
592
813
|
A: [
|
|
593
814
|
"identityRecord.haloSpace.controlFeedKey",
|
|
@@ -597,9 +818,9 @@ var IdentityManager = class {
|
|
|
597
818
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
598
819
|
writable: true
|
|
599
820
|
});
|
|
600
|
-
(0,
|
|
601
|
-
F:
|
|
602
|
-
L:
|
|
821
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
822
|
+
F: __dxlog_file4,
|
|
823
|
+
L: 222,
|
|
603
824
|
S: this,
|
|
604
825
|
A: [
|
|
605
826
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -614,7 +835,7 @@ var IdentityManager = class {
|
|
|
614
835
|
spaceRecord: identityRecord.haloSpace,
|
|
615
836
|
swarmIdentity: {
|
|
616
837
|
peerKey: identityRecord.deviceKey,
|
|
617
|
-
credentialProvider: createAuthProvider((0,
|
|
838
|
+
credentialProvider: createAuthProvider((0, import_credentials6.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
|
|
618
839
|
credentialAuthenticator: (0, import_util.deferFunction)(() => identity.authVerifier.verifier)
|
|
619
840
|
},
|
|
620
841
|
identityKey: identityRecord.identityKey
|
|
@@ -627,11 +848,11 @@ var IdentityManager = class {
|
|
|
627
848
|
identityKey: identityRecord.identityKey,
|
|
628
849
|
deviceKey: identityRecord.deviceKey
|
|
629
850
|
});
|
|
630
|
-
(0,
|
|
851
|
+
(0, import_log4.log)("done", {
|
|
631
852
|
identityKey: identityRecord.identityKey
|
|
632
853
|
}, {
|
|
633
|
-
F:
|
|
634
|
-
L:
|
|
854
|
+
F: __dxlog_file4,
|
|
855
|
+
L: 246,
|
|
635
856
|
S: this,
|
|
636
857
|
C: (f, a) => f(...a)
|
|
637
858
|
});
|
|
@@ -650,9 +871,9 @@ var IdentityManager = class {
|
|
|
650
871
|
onNetworkConnection: () => {
|
|
651
872
|
},
|
|
652
873
|
onAuthFailure: () => {
|
|
653
|
-
|
|
654
|
-
F:
|
|
655
|
-
L:
|
|
874
|
+
import_log4.log.warn("auth failure", void 0, {
|
|
875
|
+
F: __dxlog_file4,
|
|
876
|
+
L: 265,
|
|
656
877
|
S: this,
|
|
657
878
|
C: (f, a) => f(...a)
|
|
658
879
|
});
|
|
@@ -661,68 +882,88 @@ var IdentityManager = class {
|
|
|
661
882
|
});
|
|
662
883
|
}
|
|
663
884
|
};
|
|
885
|
+
_ts_decorate2([
|
|
886
|
+
import_tracing2.trace.span()
|
|
887
|
+
], IdentityManager.prototype, "open", null);
|
|
888
|
+
IdentityManager = _ts_decorate2([
|
|
889
|
+
import_tracing2.trace.resource()
|
|
890
|
+
], IdentityManager);
|
|
664
891
|
|
|
665
892
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
666
|
-
var
|
|
667
|
-
var
|
|
893
|
+
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
894
|
+
var import_credentials8 = require("@dxos/credentials");
|
|
668
895
|
var import_debug3 = require("@dxos/debug");
|
|
669
|
-
var
|
|
670
|
-
var
|
|
896
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
897
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
671
898
|
var IdentityServiceImpl = class {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
this.
|
|
899
|
+
constructor(_createIdentity, _identityManager, _keyring) {
|
|
900
|
+
this._createIdentity = _createIdentity;
|
|
901
|
+
this._identityManager = _identityManager;
|
|
902
|
+
this._keyring = _keyring;
|
|
675
903
|
}
|
|
676
904
|
async createIdentity(request) {
|
|
677
|
-
await this.
|
|
905
|
+
await this._createIdentity(request);
|
|
678
906
|
return this._getIdentity();
|
|
679
907
|
}
|
|
680
908
|
async recoverIdentity(request) {
|
|
681
909
|
return (0, import_debug3.todo)();
|
|
682
910
|
}
|
|
683
911
|
queryIdentity() {
|
|
684
|
-
return new
|
|
912
|
+
return new import_codec_protobuf3.Stream(({ next }) => {
|
|
685
913
|
const emitNext = () => next({
|
|
686
914
|
identity: this._getIdentity()
|
|
687
915
|
});
|
|
688
916
|
emitNext();
|
|
689
|
-
return this.
|
|
917
|
+
return this._identityManager.stateUpdate.on(emitNext);
|
|
690
918
|
});
|
|
691
919
|
}
|
|
692
920
|
_getIdentity() {
|
|
693
|
-
if (!this.
|
|
921
|
+
if (!this._identityManager.identity) {
|
|
694
922
|
return void 0;
|
|
695
923
|
}
|
|
696
924
|
return {
|
|
697
|
-
identityKey: this.
|
|
698
|
-
spaceKey: this.
|
|
699
|
-
profile: this.
|
|
925
|
+
identityKey: this._identityManager.identity.identityKey,
|
|
926
|
+
spaceKey: this._identityManager.identity.space.key,
|
|
927
|
+
profile: this._identityManager.identity.profileDocument
|
|
700
928
|
};
|
|
701
929
|
}
|
|
930
|
+
async updateProfile(profile) {
|
|
931
|
+
(0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
932
|
+
F: __dxlog_file5,
|
|
933
|
+
L: 59,
|
|
934
|
+
S: this,
|
|
935
|
+
A: [
|
|
936
|
+
"this._identityManager.identity",
|
|
937
|
+
"'Identity not initialized.'"
|
|
938
|
+
]
|
|
939
|
+
});
|
|
940
|
+
await this._identityManager.updateProfile(profile);
|
|
941
|
+
return this._getIdentity();
|
|
942
|
+
}
|
|
702
943
|
async signPresentation({ presentation, nonce }) {
|
|
703
|
-
(0,
|
|
704
|
-
F:
|
|
705
|
-
L:
|
|
944
|
+
(0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
945
|
+
F: __dxlog_file5,
|
|
946
|
+
L: 65,
|
|
706
947
|
S: this,
|
|
707
948
|
A: [
|
|
708
|
-
"this.
|
|
949
|
+
"this._identityManager.identity",
|
|
709
950
|
"'Identity not initialized.'"
|
|
710
951
|
]
|
|
711
952
|
});
|
|
712
|
-
return await (0,
|
|
953
|
+
return await (0, import_credentials8.signPresentation)({
|
|
713
954
|
presentation,
|
|
714
|
-
signer: this.
|
|
715
|
-
signerKey: this.
|
|
716
|
-
chain: this.
|
|
955
|
+
signer: this._keyring,
|
|
956
|
+
signerKey: this._identityManager.identity.deviceKey,
|
|
957
|
+
chain: this._identityManager.identity.deviceCredentialChain,
|
|
717
958
|
nonce
|
|
718
959
|
});
|
|
719
960
|
}
|
|
720
961
|
};
|
|
721
962
|
|
|
722
963
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
723
|
-
var
|
|
724
|
-
var
|
|
725
|
-
var
|
|
964
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
965
|
+
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
966
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
726
967
|
var DeviceInvitationProtocol = class {
|
|
727
968
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
728
969
|
this._keyring = _keyring;
|
|
@@ -734,12 +975,12 @@ var DeviceInvitationProtocol = class {
|
|
|
734
975
|
}
|
|
735
976
|
getInvitationContext() {
|
|
736
977
|
return {
|
|
737
|
-
kind:
|
|
978
|
+
kind: import_services2.Invitation.Kind.DEVICE
|
|
738
979
|
};
|
|
739
980
|
}
|
|
740
981
|
async admit(request) {
|
|
741
|
-
(0,
|
|
742
|
-
F:
|
|
982
|
+
(0, import_invariant5.invariant)(request.device, void 0, {
|
|
983
|
+
F: __dxlog_file6,
|
|
743
984
|
L: 31,
|
|
744
985
|
S: this,
|
|
745
986
|
A: [
|
|
@@ -774,8 +1015,8 @@ var DeviceInvitationProtocol = class {
|
|
|
774
1015
|
};
|
|
775
1016
|
}
|
|
776
1017
|
async accept(response, request) {
|
|
777
|
-
(0,
|
|
778
|
-
F:
|
|
1018
|
+
(0, import_invariant5.invariant)(response.device, void 0, {
|
|
1019
|
+
F: __dxlog_file6,
|
|
779
1020
|
L: 64,
|
|
780
1021
|
S: this,
|
|
781
1022
|
A: [
|
|
@@ -784,8 +1025,8 @@ var DeviceInvitationProtocol = class {
|
|
|
784
1025
|
]
|
|
785
1026
|
});
|
|
786
1027
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
787
|
-
(0,
|
|
788
|
-
F:
|
|
1028
|
+
(0, import_invariant5.invariant)(request.device, void 0, {
|
|
1029
|
+
F: __dxlog_file6,
|
|
789
1030
|
L: 67,
|
|
790
1031
|
S: this,
|
|
791
1032
|
A: [
|
|
@@ -812,43 +1053,43 @@ var DeviceInvitationProtocol = class {
|
|
|
812
1053
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
813
1054
|
var import_async5 = require("@dxos/async");
|
|
814
1055
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
815
|
-
var
|
|
816
|
-
var
|
|
1056
|
+
var import_context4 = require("@dxos/context");
|
|
1057
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
817
1058
|
var import_errors2 = require("@dxos/errors");
|
|
818
|
-
var
|
|
1059
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
819
1060
|
var import_keys4 = require("@dxos/keys");
|
|
820
|
-
var
|
|
1061
|
+
var import_log6 = require("@dxos/log");
|
|
821
1062
|
var import_network_manager = require("@dxos/network-manager");
|
|
822
|
-
var
|
|
823
|
-
var
|
|
1063
|
+
var import_protocols5 = require("@dxos/protocols");
|
|
1064
|
+
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
824
1065
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
825
1066
|
|
|
826
1067
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
827
1068
|
var import_async4 = require("@dxos/async");
|
|
828
|
-
var
|
|
1069
|
+
var import_context3 = require("@dxos/context");
|
|
829
1070
|
var import_errors = require("@dxos/errors");
|
|
830
|
-
var
|
|
1071
|
+
var import_invariant6 = require("@dxos/invariant");
|
|
831
1072
|
var import_keys3 = require("@dxos/keys");
|
|
832
|
-
var
|
|
833
|
-
var
|
|
834
|
-
var
|
|
1073
|
+
var import_log5 = require("@dxos/log");
|
|
1074
|
+
var import_protocols4 = require("@dxos/protocols");
|
|
1075
|
+
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
835
1076
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
836
1077
|
var import_teleport = require("@dxos/teleport");
|
|
837
|
-
var
|
|
1078
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
838
1079
|
var OPTIONS_TIMEOUT = 1e4;
|
|
839
1080
|
var MAX_OTP_ATTEMPTS = 3;
|
|
840
1081
|
var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
841
1082
|
constructor(_callbacks) {
|
|
842
1083
|
super({
|
|
843
1084
|
requested: {
|
|
844
|
-
InvitationHostService:
|
|
1085
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
845
1086
|
},
|
|
846
1087
|
exposed: {
|
|
847
|
-
InvitationHostService:
|
|
1088
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
848
1089
|
}
|
|
849
1090
|
});
|
|
850
1091
|
this._callbacks = _callbacks;
|
|
851
|
-
this._ctx = new
|
|
1092
|
+
this._ctx = new import_context3.Context();
|
|
852
1093
|
this._remoteOptionsTrigger = new import_async4.Trigger();
|
|
853
1094
|
this.invitation = void 0;
|
|
854
1095
|
this.guestProfile = void 0;
|
|
@@ -862,8 +1103,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
862
1103
|
// Perhaps in the future we will have more complex logic here.
|
|
863
1104
|
InvitationHostService: {
|
|
864
1105
|
options: async (options) => {
|
|
865
|
-
(0,
|
|
866
|
-
F:
|
|
1106
|
+
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1107
|
+
F: __dxlog_file7,
|
|
867
1108
|
L: 88,
|
|
868
1109
|
S: this,
|
|
869
1110
|
A: [
|
|
@@ -877,34 +1118,34 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
877
1118
|
introduce: async (request) => {
|
|
878
1119
|
const { profile, invitationId } = request;
|
|
879
1120
|
const traceId = import_keys3.PublicKey.random().toHex();
|
|
880
|
-
|
|
1121
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols4.trace.begin({
|
|
881
1122
|
id: traceId
|
|
882
1123
|
}), {
|
|
883
|
-
F:
|
|
1124
|
+
F: __dxlog_file7,
|
|
884
1125
|
L: 97,
|
|
885
1126
|
S: this,
|
|
886
1127
|
C: (f, a) => f(...a)
|
|
887
1128
|
});
|
|
888
1129
|
const invitation = await this._callbacks.resolveInvitation(request);
|
|
889
1130
|
if (!invitation) {
|
|
890
|
-
|
|
1131
|
+
import_log5.log.warn("invitation not found", {
|
|
891
1132
|
invitationId
|
|
892
1133
|
}, {
|
|
893
|
-
F:
|
|
1134
|
+
F: __dxlog_file7,
|
|
894
1135
|
L: 101,
|
|
895
1136
|
S: this,
|
|
896
1137
|
C: (f, a) => f(...a)
|
|
897
1138
|
});
|
|
898
1139
|
this._callbacks.onError(new Error("Invitation not found."));
|
|
899
1140
|
return {
|
|
900
|
-
authMethod:
|
|
1141
|
+
authMethod: import_services3.Invitation.AuthMethod.NONE
|
|
901
1142
|
};
|
|
902
1143
|
}
|
|
903
1144
|
this.invitation = invitation;
|
|
904
|
-
(0,
|
|
1145
|
+
(0, import_log5.log)("guest introduced itself", {
|
|
905
1146
|
guestProfile: profile
|
|
906
1147
|
}, {
|
|
907
|
-
F:
|
|
1148
|
+
F: __dxlog_file7,
|
|
908
1149
|
L: 110,
|
|
909
1150
|
S: this,
|
|
910
1151
|
C: (f, a) => f(...a)
|
|
@@ -912,42 +1153,42 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
912
1153
|
this.guestProfile = profile;
|
|
913
1154
|
this._callbacks.onStateUpdate({
|
|
914
1155
|
...this.invitation,
|
|
915
|
-
state:
|
|
1156
|
+
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
916
1157
|
});
|
|
917
|
-
|
|
1158
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols4.trace.end({
|
|
918
1159
|
id: traceId
|
|
919
1160
|
}), {
|
|
920
|
-
F:
|
|
1161
|
+
F: __dxlog_file7,
|
|
921
1162
|
L: 117,
|
|
922
1163
|
S: this,
|
|
923
1164
|
C: (f, a) => f(...a)
|
|
924
1165
|
});
|
|
925
1166
|
return {
|
|
926
|
-
spaceKey: this.invitation.authMethod ===
|
|
1167
|
+
spaceKey: this.invitation.authMethod === import_services3.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
|
|
927
1168
|
authMethod: this.invitation.authMethod
|
|
928
1169
|
};
|
|
929
1170
|
},
|
|
930
1171
|
authenticate: async ({ authCode: code }) => {
|
|
931
1172
|
const traceId = import_keys3.PublicKey.random().toHex();
|
|
932
|
-
|
|
1173
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols4.trace.begin({
|
|
933
1174
|
id: traceId
|
|
934
1175
|
}), {
|
|
935
|
-
F:
|
|
1176
|
+
F: __dxlog_file7,
|
|
936
1177
|
L: 126,
|
|
937
1178
|
S: this,
|
|
938
1179
|
C: (f, a) => f(...a)
|
|
939
1180
|
});
|
|
940
|
-
(0,
|
|
1181
|
+
(0, import_log5.log)("received authentication request", {
|
|
941
1182
|
authCode: code
|
|
942
1183
|
}, {
|
|
943
|
-
F:
|
|
1184
|
+
F: __dxlog_file7,
|
|
944
1185
|
L: 127,
|
|
945
1186
|
S: this,
|
|
946
1187
|
C: (f, a) => f(...a)
|
|
947
1188
|
});
|
|
948
1189
|
let status = import_invitations.AuthenticationResponse.Status.OK;
|
|
949
|
-
(0,
|
|
950
|
-
F:
|
|
1190
|
+
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1191
|
+
F: __dxlog_file7,
|
|
951
1192
|
L: 130,
|
|
952
1193
|
S: this,
|
|
953
1194
|
A: [
|
|
@@ -956,9 +1197,9 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
956
1197
|
]
|
|
957
1198
|
});
|
|
958
1199
|
switch (this.invitation.authMethod) {
|
|
959
|
-
case
|
|
960
|
-
(0,
|
|
961
|
-
F:
|
|
1200
|
+
case import_services3.Invitation.AuthMethod.NONE: {
|
|
1201
|
+
(0, import_log5.log)("authentication not required", void 0, {
|
|
1202
|
+
F: __dxlog_file7,
|
|
962
1203
|
L: 133,
|
|
963
1204
|
S: this,
|
|
964
1205
|
C: (f, a) => f(...a)
|
|
@@ -967,7 +1208,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
967
1208
|
status: import_invitations.AuthenticationResponse.Status.OK
|
|
968
1209
|
};
|
|
969
1210
|
}
|
|
970
|
-
case
|
|
1211
|
+
case import_services3.Invitation.AuthMethod.SHARED_SECRET: {
|
|
971
1212
|
if (this.invitation.authCode) {
|
|
972
1213
|
if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
|
|
973
1214
|
status = import_invitations.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
|
|
@@ -980,10 +1221,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
980
1221
|
break;
|
|
981
1222
|
}
|
|
982
1223
|
default: {
|
|
983
|
-
|
|
1224
|
+
import_log5.log.error("invalid authentication method", {
|
|
984
1225
|
authMethod: this.invitation.authMethod
|
|
985
1226
|
}, {
|
|
986
|
-
F:
|
|
1227
|
+
F: __dxlog_file7,
|
|
987
1228
|
L: 151,
|
|
988
1229
|
S: this,
|
|
989
1230
|
C: (f, a) => f(...a)
|
|
@@ -992,13 +1233,13 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
992
1233
|
break;
|
|
993
1234
|
}
|
|
994
1235
|
}
|
|
995
|
-
|
|
1236
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols4.trace.end({
|
|
996
1237
|
id: traceId,
|
|
997
1238
|
data: {
|
|
998
1239
|
status
|
|
999
1240
|
}
|
|
1000
1241
|
}), {
|
|
1001
|
-
F:
|
|
1242
|
+
F: __dxlog_file7,
|
|
1002
1243
|
L: 157,
|
|
1003
1244
|
S: this,
|
|
1004
1245
|
C: (f, a) => f(...a)
|
|
@@ -1009,17 +1250,17 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1009
1250
|
},
|
|
1010
1251
|
admit: async (request) => {
|
|
1011
1252
|
const traceId = import_keys3.PublicKey.random().toHex();
|
|
1012
|
-
|
|
1253
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols4.trace.begin({
|
|
1013
1254
|
id: traceId
|
|
1014
1255
|
}), {
|
|
1015
|
-
F:
|
|
1256
|
+
F: __dxlog_file7,
|
|
1016
1257
|
L: 163,
|
|
1017
1258
|
S: this,
|
|
1018
1259
|
C: (f, a) => f(...a)
|
|
1019
1260
|
});
|
|
1020
1261
|
try {
|
|
1021
|
-
(0,
|
|
1022
|
-
F:
|
|
1262
|
+
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1263
|
+
F: __dxlog_file7,
|
|
1023
1264
|
L: 166,
|
|
1024
1265
|
S: this,
|
|
1025
1266
|
A: [
|
|
@@ -1031,10 +1272,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1031
1272
|
throw new Error("Not authenticated");
|
|
1032
1273
|
}
|
|
1033
1274
|
const response = await this._callbacks.admit(request);
|
|
1034
|
-
|
|
1275
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols4.trace.end({
|
|
1035
1276
|
id: traceId
|
|
1036
1277
|
}), {
|
|
1037
|
-
F:
|
|
1278
|
+
F: __dxlog_file7,
|
|
1038
1279
|
L: 174,
|
|
1039
1280
|
S: this,
|
|
1040
1281
|
C: (f, a) => f(...a)
|
|
@@ -1049,16 +1290,15 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1049
1290
|
};
|
|
1050
1291
|
}
|
|
1051
1292
|
async onOpen(context) {
|
|
1052
|
-
var _a;
|
|
1053
1293
|
await super.onOpen(context);
|
|
1054
1294
|
try {
|
|
1055
1295
|
await this.rpc.InvitationHostService.options({
|
|
1056
1296
|
role: import_invitations.Options.Role.HOST
|
|
1057
1297
|
});
|
|
1058
|
-
await (0,
|
|
1298
|
+
await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1059
1299
|
timeout: OPTIONS_TIMEOUT
|
|
1060
1300
|
}));
|
|
1061
|
-
if (
|
|
1301
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.GUEST) {
|
|
1062
1302
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1063
1303
|
expected: import_invitations.Options.Role.GUEST,
|
|
1064
1304
|
remoteOptions: this._remoteOptions
|
|
@@ -1077,22 +1317,22 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1077
1317
|
constructor(_callbacks) {
|
|
1078
1318
|
super({
|
|
1079
1319
|
requested: {
|
|
1080
|
-
InvitationHostService:
|
|
1320
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1081
1321
|
},
|
|
1082
1322
|
exposed: {
|
|
1083
|
-
InvitationHostService:
|
|
1323
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1084
1324
|
}
|
|
1085
1325
|
});
|
|
1086
1326
|
this._callbacks = _callbacks;
|
|
1087
|
-
this._ctx = new
|
|
1327
|
+
this._ctx = new import_context3.Context();
|
|
1088
1328
|
this._remoteOptionsTrigger = new import_async4.Trigger();
|
|
1089
1329
|
}
|
|
1090
1330
|
async getHandlers() {
|
|
1091
1331
|
return {
|
|
1092
1332
|
InvitationHostService: {
|
|
1093
1333
|
options: async (options) => {
|
|
1094
|
-
(0,
|
|
1095
|
-
F:
|
|
1334
|
+
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1335
|
+
F: __dxlog_file7,
|
|
1096
1336
|
L: 241,
|
|
1097
1337
|
S: this,
|
|
1098
1338
|
A: [
|
|
@@ -1116,28 +1356,27 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1116
1356
|
};
|
|
1117
1357
|
}
|
|
1118
1358
|
async onOpen(context) {
|
|
1119
|
-
var _a;
|
|
1120
1359
|
await super.onOpen(context);
|
|
1121
1360
|
try {
|
|
1122
|
-
(0,
|
|
1123
|
-
F:
|
|
1361
|
+
(0, import_log5.log)("begin options", void 0, {
|
|
1362
|
+
F: __dxlog_file7,
|
|
1124
1363
|
L: 262,
|
|
1125
1364
|
S: this,
|
|
1126
1365
|
C: (f, a) => f(...a)
|
|
1127
1366
|
});
|
|
1128
|
-
await (0,
|
|
1367
|
+
await (0, import_context3.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1129
1368
|
role: import_invitations.Options.Role.GUEST
|
|
1130
1369
|
}));
|
|
1131
|
-
await (0,
|
|
1370
|
+
await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1132
1371
|
timeout: OPTIONS_TIMEOUT
|
|
1133
1372
|
}));
|
|
1134
|
-
(0,
|
|
1135
|
-
F:
|
|
1373
|
+
(0, import_log5.log)("end options", void 0, {
|
|
1374
|
+
F: __dxlog_file7,
|
|
1136
1375
|
L: 265,
|
|
1137
1376
|
S: this,
|
|
1138
1377
|
C: (f, a) => f(...a)
|
|
1139
1378
|
});
|
|
1140
|
-
if (
|
|
1379
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.HOST) {
|
|
1141
1380
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1142
1381
|
expected: import_invitations.Options.Role.HOST,
|
|
1143
1382
|
remoteOptions: this._remoteOptions
|
|
@@ -1145,8 +1384,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1145
1384
|
}
|
|
1146
1385
|
this._callbacks.onOpen(this._ctx);
|
|
1147
1386
|
} catch (err) {
|
|
1148
|
-
(0,
|
|
1149
|
-
F:
|
|
1387
|
+
(0, import_log5.log)("openError", err, {
|
|
1388
|
+
F: __dxlog_file7,
|
|
1150
1389
|
L: 275,
|
|
1151
1390
|
S: this,
|
|
1152
1391
|
C: (f, a) => f(...a)
|
|
@@ -1155,8 +1394,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1155
1394
|
}
|
|
1156
1395
|
}
|
|
1157
1396
|
async onClose() {
|
|
1158
|
-
(0,
|
|
1159
|
-
F:
|
|
1397
|
+
(0, import_log5.log)("onClose", void 0, {
|
|
1398
|
+
F: __dxlog_file7,
|
|
1160
1399
|
L: 281,
|
|
1161
1400
|
S: this,
|
|
1162
1401
|
C: (f, a) => f(...a)
|
|
@@ -1164,10 +1403,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1164
1403
|
await this._ctx.dispose();
|
|
1165
1404
|
}
|
|
1166
1405
|
};
|
|
1167
|
-
var isAuthenticationRequired = (invitation) => invitation.authMethod !==
|
|
1406
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services3.Invitation.AuthMethod.NONE;
|
|
1168
1407
|
|
|
1169
1408
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1170
|
-
var
|
|
1409
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1171
1410
|
var InvitationsHandler = class {
|
|
1172
1411
|
/**
|
|
1173
1412
|
* @internal
|
|
@@ -1176,11 +1415,10 @@ var InvitationsHandler = class {
|
|
|
1176
1415
|
this._networkManager = _networkManager;
|
|
1177
1416
|
}
|
|
1178
1417
|
createInvitation(protocol, options) {
|
|
1179
|
-
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
F: __dxlog_file7,
|
|
1418
|
+
const { invitationId = import_keys4.PublicKey.random().toHex(), type = import_services4.Invitation.Type.INTERACTIVE, authMethod = import_services4.Invitation.AuthMethod.SHARED_SECRET, state = import_services4.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys4.PublicKey.random() } = options ?? {};
|
|
1419
|
+
const authCode = options?.authCode ?? (authMethod === import_services4.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1420
|
+
(0, import_invariant7.invariant)(protocol, void 0, {
|
|
1421
|
+
F: __dxlog_file8,
|
|
1184
1422
|
L: 76,
|
|
1185
1423
|
S: this,
|
|
1186
1424
|
A: [
|
|
@@ -1199,17 +1437,17 @@ var InvitationsHandler = class {
|
|
|
1199
1437
|
...protocol.getInvitationContext()
|
|
1200
1438
|
};
|
|
1201
1439
|
const stream = new import_async5.PushStream();
|
|
1202
|
-
const ctx = new
|
|
1440
|
+
const ctx = new import_context4.Context({
|
|
1203
1441
|
onError: (err) => {
|
|
1204
1442
|
void ctx.dispose();
|
|
1205
1443
|
stream.error(err);
|
|
1206
1444
|
}
|
|
1207
1445
|
});
|
|
1208
1446
|
ctx.onDispose(() => {
|
|
1209
|
-
(0,
|
|
1447
|
+
(0, import_log6.log)("complete", {
|
|
1210
1448
|
...protocol.toJSON()
|
|
1211
1449
|
}, {
|
|
1212
|
-
F:
|
|
1450
|
+
F: __dxlog_file8,
|
|
1213
1451
|
L: 98,
|
|
1214
1452
|
S: this,
|
|
1215
1453
|
C: (f, a) => f(...a)
|
|
@@ -1221,7 +1459,7 @@ var InvitationsHandler = class {
|
|
|
1221
1459
|
onStateUpdate: (invitation2) => {
|
|
1222
1460
|
stream.next({
|
|
1223
1461
|
...invitation2,
|
|
1224
|
-
state:
|
|
1462
|
+
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1225
1463
|
});
|
|
1226
1464
|
},
|
|
1227
1465
|
resolveInvitation: async ({ invitationId: invitationId2 }) => {
|
|
@@ -1231,11 +1469,10 @@ var InvitationsHandler = class {
|
|
|
1231
1469
|
return invitation;
|
|
1232
1470
|
},
|
|
1233
1471
|
admit: async (admissionRequest) => {
|
|
1234
|
-
var _a2, _b, _c;
|
|
1235
1472
|
try {
|
|
1236
|
-
const deviceKey =
|
|
1237
|
-
(0,
|
|
1238
|
-
F:
|
|
1473
|
+
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1474
|
+
(0, import_invariant7.invariant)(deviceKey, void 0, {
|
|
1475
|
+
F: __dxlog_file8,
|
|
1239
1476
|
L: 119,
|
|
1240
1477
|
S: this,
|
|
1241
1478
|
A: [
|
|
@@ -1255,84 +1492,84 @@ var InvitationsHandler = class {
|
|
|
1255
1492
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1256
1493
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
1257
1494
|
try {
|
|
1258
|
-
|
|
1495
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
|
|
1259
1496
|
id: traceId
|
|
1260
1497
|
}), {
|
|
1261
|
-
F:
|
|
1498
|
+
F: __dxlog_file8,
|
|
1262
1499
|
L: 137,
|
|
1263
1500
|
S: this,
|
|
1264
1501
|
C: (f, a) => f(...a)
|
|
1265
1502
|
});
|
|
1266
|
-
(0,
|
|
1503
|
+
(0, import_log6.log)("connected", {
|
|
1267
1504
|
...protocol.toJSON()
|
|
1268
1505
|
}, {
|
|
1269
|
-
F:
|
|
1506
|
+
F: __dxlog_file8,
|
|
1270
1507
|
L: 138,
|
|
1271
1508
|
S: this,
|
|
1272
1509
|
C: (f, a) => f(...a)
|
|
1273
1510
|
});
|
|
1274
1511
|
stream.next({
|
|
1275
1512
|
...invitation,
|
|
1276
|
-
state:
|
|
1513
|
+
state: import_services4.Invitation.State.CONNECTED
|
|
1277
1514
|
});
|
|
1278
1515
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1279
1516
|
timeout
|
|
1280
1517
|
});
|
|
1281
|
-
(0,
|
|
1518
|
+
(0, import_log6.log)("admitted guest", {
|
|
1282
1519
|
guest: deviceKey,
|
|
1283
1520
|
...protocol.toJSON()
|
|
1284
1521
|
}, {
|
|
1285
|
-
F:
|
|
1522
|
+
F: __dxlog_file8,
|
|
1286
1523
|
L: 141,
|
|
1287
1524
|
S: this,
|
|
1288
1525
|
C: (f, a) => f(...a)
|
|
1289
1526
|
});
|
|
1290
1527
|
stream.next({
|
|
1291
1528
|
...invitation,
|
|
1292
|
-
state:
|
|
1529
|
+
state: import_services4.Invitation.State.SUCCESS
|
|
1293
1530
|
});
|
|
1294
|
-
|
|
1531
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
|
|
1295
1532
|
id: traceId
|
|
1296
1533
|
}), {
|
|
1297
|
-
F:
|
|
1534
|
+
F: __dxlog_file8,
|
|
1298
1535
|
L: 143,
|
|
1299
1536
|
S: this,
|
|
1300
1537
|
C: (f, a) => f(...a)
|
|
1301
1538
|
});
|
|
1302
1539
|
} catch (err) {
|
|
1303
1540
|
if (err instanceof import_async5.TimeoutError) {
|
|
1304
|
-
(0,
|
|
1541
|
+
(0, import_log6.log)("timeout", {
|
|
1305
1542
|
...protocol.toJSON()
|
|
1306
1543
|
}, {
|
|
1307
|
-
F:
|
|
1544
|
+
F: __dxlog_file8,
|
|
1308
1545
|
L: 146,
|
|
1309
1546
|
S: this,
|
|
1310
1547
|
C: (f, a) => f(...a)
|
|
1311
1548
|
});
|
|
1312
1549
|
stream.next({
|
|
1313
1550
|
...invitation,
|
|
1314
|
-
state:
|
|
1551
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1315
1552
|
});
|
|
1316
1553
|
} else {
|
|
1317
|
-
|
|
1318
|
-
F:
|
|
1554
|
+
import_log6.log.error("failed", err, {
|
|
1555
|
+
F: __dxlog_file8,
|
|
1319
1556
|
L: 149,
|
|
1320
1557
|
S: this,
|
|
1321
1558
|
C: (f, a) => f(...a)
|
|
1322
1559
|
});
|
|
1323
1560
|
stream.error(err);
|
|
1324
1561
|
}
|
|
1325
|
-
|
|
1562
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
|
|
1326
1563
|
id: traceId,
|
|
1327
1564
|
error: err
|
|
1328
1565
|
}), {
|
|
1329
|
-
F:
|
|
1566
|
+
F: __dxlog_file8,
|
|
1330
1567
|
L: 152,
|
|
1331
1568
|
S: this,
|
|
1332
1569
|
C: (f, a) => f(...a)
|
|
1333
1570
|
});
|
|
1334
1571
|
} finally {
|
|
1335
|
-
if (type !==
|
|
1572
|
+
if (type !== import_services4.Invitation.Type.MULTIUSE) {
|
|
1336
1573
|
await swarmConnection.close();
|
|
1337
1574
|
await ctx.dispose();
|
|
1338
1575
|
}
|
|
@@ -1344,21 +1581,21 @@ var InvitationsHandler = class {
|
|
|
1344
1581
|
return;
|
|
1345
1582
|
}
|
|
1346
1583
|
if (err instanceof import_async5.TimeoutError) {
|
|
1347
|
-
(0,
|
|
1584
|
+
(0, import_log6.log)("timeout", {
|
|
1348
1585
|
...protocol.toJSON()
|
|
1349
1586
|
}, {
|
|
1350
|
-
F:
|
|
1587
|
+
F: __dxlog_file8,
|
|
1351
1588
|
L: 167,
|
|
1352
1589
|
S: this,
|
|
1353
1590
|
C: (f, a) => f(...a)
|
|
1354
1591
|
});
|
|
1355
1592
|
stream.next({
|
|
1356
1593
|
...invitation,
|
|
1357
|
-
state:
|
|
1594
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1358
1595
|
});
|
|
1359
1596
|
} else {
|
|
1360
|
-
|
|
1361
|
-
F:
|
|
1597
|
+
import_log6.log.error("failed", err, {
|
|
1598
|
+
F: __dxlog_file8,
|
|
1362
1599
|
L: 170,
|
|
1363
1600
|
S: this,
|
|
1364
1601
|
C: (f, a) => f(...a)
|
|
@@ -1383,7 +1620,7 @@ var InvitationsHandler = class {
|
|
|
1383
1620
|
ctx.onDispose(() => swarmConnection.close());
|
|
1384
1621
|
stream.next({
|
|
1385
1622
|
...invitation,
|
|
1386
|
-
state:
|
|
1623
|
+
state: import_services4.Invitation.State.CONNECTING
|
|
1387
1624
|
});
|
|
1388
1625
|
});
|
|
1389
1626
|
const observable = new import_client_protocol2.CancellableInvitationObservable({
|
|
@@ -1392,7 +1629,7 @@ var InvitationsHandler = class {
|
|
|
1392
1629
|
onCancel: async () => {
|
|
1393
1630
|
stream.next({
|
|
1394
1631
|
...invitation,
|
|
1395
|
-
state:
|
|
1632
|
+
state: import_services4.Invitation.State.CANCELLED
|
|
1396
1633
|
});
|
|
1397
1634
|
await ctx.dispose();
|
|
1398
1635
|
}
|
|
@@ -1401,8 +1638,8 @@ var InvitationsHandler = class {
|
|
|
1401
1638
|
}
|
|
1402
1639
|
acceptInvitation(protocol, invitation) {
|
|
1403
1640
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1404
|
-
(0,
|
|
1405
|
-
F:
|
|
1641
|
+
(0, import_invariant7.invariant)(protocol, void 0, {
|
|
1642
|
+
F: __dxlog_file8,
|
|
1406
1643
|
L: 210,
|
|
1407
1644
|
S: this,
|
|
1408
1645
|
A: [
|
|
@@ -1415,8 +1652,8 @@ var InvitationsHandler = class {
|
|
|
1415
1652
|
let currentState;
|
|
1416
1653
|
const stream = new import_async5.PushStream();
|
|
1417
1654
|
const setState = (newData) => {
|
|
1418
|
-
(0,
|
|
1419
|
-
F:
|
|
1655
|
+
(0, import_invariant7.invariant)(newData.state !== void 0, void 0, {
|
|
1656
|
+
F: __dxlog_file8,
|
|
1420
1657
|
L: 221,
|
|
1421
1658
|
S: this,
|
|
1422
1659
|
A: [
|
|
@@ -1430,23 +1667,23 @@ var InvitationsHandler = class {
|
|
|
1430
1667
|
...newData
|
|
1431
1668
|
});
|
|
1432
1669
|
};
|
|
1433
|
-
const ctx = new
|
|
1670
|
+
const ctx = new import_context4.Context({
|
|
1434
1671
|
onError: (err) => {
|
|
1435
1672
|
if (err instanceof import_async5.TimeoutError) {
|
|
1436
|
-
(0,
|
|
1673
|
+
(0, import_log6.log)("timeout", {
|
|
1437
1674
|
...protocol.toJSON()
|
|
1438
1675
|
}, {
|
|
1439
|
-
F:
|
|
1676
|
+
F: __dxlog_file8,
|
|
1440
1677
|
L: 229,
|
|
1441
1678
|
S: this,
|
|
1442
1679
|
C: (f, a) => f(...a)
|
|
1443
1680
|
});
|
|
1444
1681
|
setState({
|
|
1445
|
-
state:
|
|
1682
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1446
1683
|
});
|
|
1447
1684
|
} else {
|
|
1448
|
-
|
|
1449
|
-
F:
|
|
1685
|
+
import_log6.log.warn("auth failed", err, {
|
|
1686
|
+
F: __dxlog_file8,
|
|
1450
1687
|
L: 232,
|
|
1451
1688
|
S: this,
|
|
1452
1689
|
C: (f, a) => f(...a)
|
|
@@ -1457,10 +1694,10 @@ var InvitationsHandler = class {
|
|
|
1457
1694
|
}
|
|
1458
1695
|
});
|
|
1459
1696
|
ctx.onDispose(() => {
|
|
1460
|
-
(0,
|
|
1697
|
+
(0, import_log6.log)("complete", {
|
|
1461
1698
|
...protocol.toJSON()
|
|
1462
1699
|
}, {
|
|
1463
|
-
F:
|
|
1700
|
+
F: __dxlog_file8,
|
|
1464
1701
|
L: 240,
|
|
1465
1702
|
S: this,
|
|
1466
1703
|
C: (f, a) => f(...a)
|
|
@@ -1472,10 +1709,10 @@ var InvitationsHandler = class {
|
|
|
1472
1709
|
const extension = new InvitationGuestExtension({
|
|
1473
1710
|
onOpen: (extensionCtx) => {
|
|
1474
1711
|
extensionCtx.onDispose(async () => {
|
|
1475
|
-
(0,
|
|
1712
|
+
(0, import_log6.log)("extension disposed", {
|
|
1476
1713
|
currentState
|
|
1477
1714
|
}, {
|
|
1478
|
-
F:
|
|
1715
|
+
F: __dxlog_file8,
|
|
1479
1716
|
L: 250,
|
|
1480
1717
|
S: this,
|
|
1481
1718
|
C: (f, a) => f(...a)
|
|
@@ -1487,10 +1724,10 @@ var InvitationsHandler = class {
|
|
|
1487
1724
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1488
1725
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
1489
1726
|
try {
|
|
1490
|
-
|
|
1727
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
|
|
1491
1728
|
id: traceId
|
|
1492
1729
|
}), {
|
|
1493
|
-
F:
|
|
1730
|
+
F: __dxlog_file8,
|
|
1494
1731
|
L: 259,
|
|
1495
1732
|
S: this,
|
|
1496
1733
|
C: (f, a) => f(...a)
|
|
@@ -1499,31 +1736,31 @@ var InvitationsHandler = class {
|
|
|
1499
1736
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
1500
1737
|
}
|
|
1501
1738
|
(0, import_async5.scheduleTask)(ctx, () => ctx.raise(new import_async5.TimeoutError(timeout)), timeout);
|
|
1502
|
-
(0,
|
|
1739
|
+
(0, import_log6.log)("connected", {
|
|
1503
1740
|
...protocol.toJSON()
|
|
1504
1741
|
}, {
|
|
1505
|
-
F:
|
|
1742
|
+
F: __dxlog_file8,
|
|
1506
1743
|
L: 267,
|
|
1507
1744
|
S: this,
|
|
1508
1745
|
C: (f, a) => f(...a)
|
|
1509
1746
|
});
|
|
1510
1747
|
setState({
|
|
1511
|
-
state:
|
|
1748
|
+
state: import_services4.Invitation.State.CONNECTED
|
|
1512
1749
|
});
|
|
1513
|
-
(0,
|
|
1750
|
+
(0, import_log6.log)("introduce", {
|
|
1514
1751
|
...protocol.toJSON()
|
|
1515
1752
|
}, {
|
|
1516
|
-
F:
|
|
1753
|
+
F: __dxlog_file8,
|
|
1517
1754
|
L: 271,
|
|
1518
1755
|
S: this,
|
|
1519
1756
|
C: (f, a) => f(...a)
|
|
1520
1757
|
});
|
|
1521
1758
|
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
1522
|
-
(0,
|
|
1759
|
+
(0, import_log6.log)("introduce response", {
|
|
1523
1760
|
...protocol.toJSON(),
|
|
1524
1761
|
response: introductionResponse
|
|
1525
1762
|
}, {
|
|
1526
|
-
F:
|
|
1763
|
+
F: __dxlog_file8,
|
|
1527
1764
|
L: 275,
|
|
1528
1765
|
S: this,
|
|
1529
1766
|
C: (f, a) => f(...a)
|
|
@@ -1534,26 +1771,26 @@ var InvitationsHandler = class {
|
|
|
1534
1771
|
}
|
|
1535
1772
|
if (isAuthenticationRequired(invitation)) {
|
|
1536
1773
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1537
|
-
(0,
|
|
1538
|
-
F:
|
|
1774
|
+
(0, import_log6.log)("guest waiting for authentication code...", void 0, {
|
|
1775
|
+
F: __dxlog_file8,
|
|
1539
1776
|
L: 284,
|
|
1540
1777
|
S: this,
|
|
1541
1778
|
C: (f, a) => f(...a)
|
|
1542
1779
|
});
|
|
1543
1780
|
setState({
|
|
1544
|
-
state:
|
|
1781
|
+
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1545
1782
|
});
|
|
1546
1783
|
const authCode = await authenticated.wait({
|
|
1547
1784
|
timeout
|
|
1548
1785
|
});
|
|
1549
|
-
(0,
|
|
1550
|
-
F:
|
|
1786
|
+
(0, import_log6.log)("sending authentication request", void 0, {
|
|
1787
|
+
F: __dxlog_file8,
|
|
1551
1788
|
L: 288,
|
|
1552
1789
|
S: this,
|
|
1553
1790
|
C: (f, a) => f(...a)
|
|
1554
1791
|
});
|
|
1555
1792
|
setState({
|
|
1556
|
-
state:
|
|
1793
|
+
state: import_services4.Invitation.State.AUTHENTICATING
|
|
1557
1794
|
});
|
|
1558
1795
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
1559
1796
|
authCode
|
|
@@ -1565,10 +1802,10 @@ var InvitationsHandler = class {
|
|
|
1565
1802
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
1566
1803
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
1567
1804
|
} else {
|
|
1568
|
-
(0,
|
|
1805
|
+
(0, import_log6.log)("retrying invalid code", {
|
|
1569
1806
|
attempt
|
|
1570
1807
|
}, {
|
|
1571
|
-
F:
|
|
1808
|
+
F: __dxlog_file8,
|
|
1572
1809
|
L: 299,
|
|
1573
1810
|
S: this,
|
|
1574
1811
|
C: (f, a) => f(...a)
|
|
@@ -1579,13 +1816,13 @@ var InvitationsHandler = class {
|
|
|
1579
1816
|
}
|
|
1580
1817
|
} else {
|
|
1581
1818
|
setState({
|
|
1582
|
-
state:
|
|
1819
|
+
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1583
1820
|
});
|
|
1584
1821
|
}
|
|
1585
|
-
(0,
|
|
1822
|
+
(0, import_log6.log)("request admission", {
|
|
1586
1823
|
...protocol.toJSON()
|
|
1587
1824
|
}, {
|
|
1588
|
-
F:
|
|
1825
|
+
F: __dxlog_file8,
|
|
1589
1826
|
L: 310,
|
|
1590
1827
|
S: this,
|
|
1591
1828
|
C: (f, a) => f(...a)
|
|
@@ -1594,53 +1831,53 @@ var InvitationsHandler = class {
|
|
|
1594
1831
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
1595
1832
|
admitted = true;
|
|
1596
1833
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
1597
|
-
(0,
|
|
1834
|
+
(0, import_log6.log)("admitted by host", {
|
|
1598
1835
|
...protocol.toJSON()
|
|
1599
1836
|
}, {
|
|
1600
|
-
F:
|
|
1837
|
+
F: __dxlog_file8,
|
|
1601
1838
|
L: 321,
|
|
1602
1839
|
S: this,
|
|
1603
1840
|
C: (f, a) => f(...a)
|
|
1604
1841
|
});
|
|
1605
1842
|
setState({
|
|
1606
1843
|
...result,
|
|
1607
|
-
state:
|
|
1844
|
+
state: import_services4.Invitation.State.SUCCESS
|
|
1608
1845
|
});
|
|
1609
|
-
|
|
1846
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
|
|
1610
1847
|
id: traceId
|
|
1611
1848
|
}), {
|
|
1612
|
-
F:
|
|
1849
|
+
F: __dxlog_file8,
|
|
1613
1850
|
L: 323,
|
|
1614
1851
|
S: this,
|
|
1615
1852
|
C: (f, a) => f(...a)
|
|
1616
1853
|
});
|
|
1617
1854
|
} catch (err) {
|
|
1618
1855
|
if (err instanceof import_async5.TimeoutError) {
|
|
1619
|
-
(0,
|
|
1856
|
+
(0, import_log6.log)("timeout", {
|
|
1620
1857
|
...protocol.toJSON()
|
|
1621
1858
|
}, {
|
|
1622
|
-
F:
|
|
1859
|
+
F: __dxlog_file8,
|
|
1623
1860
|
L: 326,
|
|
1624
1861
|
S: this,
|
|
1625
1862
|
C: (f, a) => f(...a)
|
|
1626
1863
|
});
|
|
1627
1864
|
setState({
|
|
1628
|
-
state:
|
|
1865
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1629
1866
|
});
|
|
1630
1867
|
} else {
|
|
1631
|
-
(0,
|
|
1632
|
-
F:
|
|
1868
|
+
(0, import_log6.log)("auth failed", err, {
|
|
1869
|
+
F: __dxlog_file8,
|
|
1633
1870
|
L: 329,
|
|
1634
1871
|
S: this,
|
|
1635
1872
|
C: (f, a) => f(...a)
|
|
1636
1873
|
});
|
|
1637
1874
|
stream.error(err);
|
|
1638
1875
|
}
|
|
1639
|
-
|
|
1876
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
|
|
1640
1877
|
id: traceId,
|
|
1641
1878
|
error: err
|
|
1642
1879
|
}), {
|
|
1643
|
-
F:
|
|
1880
|
+
F: __dxlog_file8,
|
|
1644
1881
|
L: 332,
|
|
1645
1882
|
S: this,
|
|
1646
1883
|
C: (f, a) => f(...a)
|
|
@@ -1655,20 +1892,20 @@ var InvitationsHandler = class {
|
|
|
1655
1892
|
return;
|
|
1656
1893
|
}
|
|
1657
1894
|
if (err instanceof import_async5.TimeoutError) {
|
|
1658
|
-
(0,
|
|
1895
|
+
(0, import_log6.log)("timeout", {
|
|
1659
1896
|
...protocol.toJSON()
|
|
1660
1897
|
}, {
|
|
1661
|
-
F:
|
|
1898
|
+
F: __dxlog_file8,
|
|
1662
1899
|
L: 343,
|
|
1663
1900
|
S: this,
|
|
1664
1901
|
C: (f, a) => f(...a)
|
|
1665
1902
|
});
|
|
1666
1903
|
setState({
|
|
1667
|
-
state:
|
|
1904
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1668
1905
|
});
|
|
1669
1906
|
} else {
|
|
1670
|
-
(0,
|
|
1671
|
-
F:
|
|
1907
|
+
(0, import_log6.log)("auth failed", err, {
|
|
1908
|
+
F: __dxlog_file8,
|
|
1672
1909
|
L: 346,
|
|
1673
1910
|
S: this,
|
|
1674
1911
|
C: (f, a) => f(...a)
|
|
@@ -1680,8 +1917,8 @@ var InvitationsHandler = class {
|
|
|
1680
1917
|
return extension;
|
|
1681
1918
|
};
|
|
1682
1919
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1683
|
-
(0,
|
|
1684
|
-
F:
|
|
1920
|
+
(0, import_invariant7.invariant)(invitation.swarmKey, void 0, {
|
|
1921
|
+
F: __dxlog_file8,
|
|
1685
1922
|
L: 356,
|
|
1686
1923
|
S: this,
|
|
1687
1924
|
A: [
|
|
@@ -1700,7 +1937,7 @@ var InvitationsHandler = class {
|
|
|
1700
1937
|
});
|
|
1701
1938
|
ctx.onDispose(() => swarmConnection.close());
|
|
1702
1939
|
setState({
|
|
1703
|
-
state:
|
|
1940
|
+
state: import_services4.Invitation.State.CONNECTING
|
|
1704
1941
|
});
|
|
1705
1942
|
});
|
|
1706
1943
|
const observable = new import_client_protocol2.AuthenticatingInvitationObservable({
|
|
@@ -1708,7 +1945,7 @@ var InvitationsHandler = class {
|
|
|
1708
1945
|
subscriber: stream.observable,
|
|
1709
1946
|
onCancel: async () => {
|
|
1710
1947
|
setState({
|
|
1711
|
-
state:
|
|
1948
|
+
state: import_services4.Invitation.State.CANCELLED
|
|
1712
1949
|
});
|
|
1713
1950
|
await ctx.dispose();
|
|
1714
1951
|
},
|
|
@@ -1722,11 +1959,11 @@ var InvitationsHandler = class {
|
|
|
1722
1959
|
|
|
1723
1960
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1724
1961
|
var import_async6 = require("@dxos/async");
|
|
1725
|
-
var
|
|
1726
|
-
var
|
|
1727
|
-
var
|
|
1728
|
-
var
|
|
1729
|
-
var
|
|
1962
|
+
var import_codec_protobuf4 = require("@dxos/codec-protobuf");
|
|
1963
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
1964
|
+
var import_log7 = require("@dxos/log");
|
|
1965
|
+
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1966
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1730
1967
|
var InvitationsServiceImpl = class {
|
|
1731
1968
|
constructor(_invitationsHandler, _getHandler) {
|
|
1732
1969
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1753,7 +1990,7 @@ var InvitationsServiceImpl = class {
|
|
|
1753
1990
|
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
1754
1991
|
this._invitationCreated.emit(invitation.get());
|
|
1755
1992
|
}
|
|
1756
|
-
return new
|
|
1993
|
+
return new import_codec_protobuf4.Stream(({ next, close }) => {
|
|
1757
1994
|
invitation.subscribe((invitation2) => {
|
|
1758
1995
|
next(invitation2);
|
|
1759
1996
|
}, (err) => {
|
|
@@ -1775,7 +2012,7 @@ var InvitationsServiceImpl = class {
|
|
|
1775
2012
|
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
1776
2013
|
this._invitationAccepted.emit(invitation.get());
|
|
1777
2014
|
}
|
|
1778
|
-
return new
|
|
2015
|
+
return new import_codec_protobuf4.Stream(({ next, close }) => {
|
|
1779
2016
|
invitation.subscribe((invitation2) => {
|
|
1780
2017
|
next(invitation2);
|
|
1781
2018
|
}, (err) => {
|
|
@@ -1787,14 +2024,14 @@ var InvitationsServiceImpl = class {
|
|
|
1787
2024
|
});
|
|
1788
2025
|
}
|
|
1789
2026
|
async authenticate({ invitationId, authCode }) {
|
|
1790
|
-
(0,
|
|
1791
|
-
F:
|
|
2027
|
+
(0, import_log7.log)("authenticating...", void 0, {
|
|
2028
|
+
F: __dxlog_file9,
|
|
1792
2029
|
L: 102,
|
|
1793
2030
|
S: this,
|
|
1794
2031
|
C: (f, a) => f(...a)
|
|
1795
2032
|
});
|
|
1796
|
-
(0,
|
|
1797
|
-
F:
|
|
2033
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2034
|
+
F: __dxlog_file9,
|
|
1798
2035
|
L: 103,
|
|
1799
2036
|
S: this,
|
|
1800
2037
|
A: [
|
|
@@ -1804,10 +2041,10 @@ var InvitationsServiceImpl = class {
|
|
|
1804
2041
|
});
|
|
1805
2042
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1806
2043
|
if (!observable) {
|
|
1807
|
-
|
|
2044
|
+
import_log7.log.warn("invalid invitation", {
|
|
1808
2045
|
invitationId
|
|
1809
2046
|
}, {
|
|
1810
|
-
F:
|
|
2047
|
+
F: __dxlog_file9,
|
|
1811
2048
|
L: 106,
|
|
1812
2049
|
S: this,
|
|
1813
2050
|
C: (f, a) => f(...a)
|
|
@@ -1817,14 +2054,14 @@ var InvitationsServiceImpl = class {
|
|
|
1817
2054
|
}
|
|
1818
2055
|
}
|
|
1819
2056
|
async cancelInvitation({ invitationId }) {
|
|
1820
|
-
(0,
|
|
1821
|
-
F:
|
|
2057
|
+
(0, import_log7.log)("deleting...", void 0, {
|
|
2058
|
+
F: __dxlog_file9,
|
|
1822
2059
|
L: 113,
|
|
1823
2060
|
S: this,
|
|
1824
2061
|
C: (f, a) => f(...a)
|
|
1825
2062
|
});
|
|
1826
|
-
(0,
|
|
1827
|
-
F:
|
|
2063
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2064
|
+
F: __dxlog_file9,
|
|
1828
2065
|
L: 114,
|
|
1829
2066
|
S: this,
|
|
1830
2067
|
A: [
|
|
@@ -1843,10 +2080,10 @@ var InvitationsServiceImpl = class {
|
|
|
1843
2080
|
this._acceptInvitations.delete(invitationId);
|
|
1844
2081
|
this._removedAccepted.emit(accepted.get());
|
|
1845
2082
|
} else {
|
|
1846
|
-
|
|
2083
|
+
import_log7.log.warn("invalid invitation", {
|
|
1847
2084
|
invitationId
|
|
1848
2085
|
}, {
|
|
1849
|
-
F:
|
|
2086
|
+
F: __dxlog_file9,
|
|
1850
2087
|
L: 126,
|
|
1851
2088
|
S: this,
|
|
1852
2089
|
C: (f, a) => f(...a)
|
|
@@ -1854,11 +2091,11 @@ var InvitationsServiceImpl = class {
|
|
|
1854
2091
|
}
|
|
1855
2092
|
}
|
|
1856
2093
|
queryInvitations() {
|
|
1857
|
-
return new
|
|
2094
|
+
return new import_codec_protobuf4.Stream(({ next, ctx }) => {
|
|
1858
2095
|
this._invitationCreated.on(ctx, (invitation) => {
|
|
1859
2096
|
next({
|
|
1860
|
-
action:
|
|
1861
|
-
type:
|
|
2097
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2098
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
1862
2099
|
invitations: [
|
|
1863
2100
|
invitation
|
|
1864
2101
|
]
|
|
@@ -1866,8 +2103,8 @@ var InvitationsServiceImpl = class {
|
|
|
1866
2103
|
});
|
|
1867
2104
|
this._invitationAccepted.on(ctx, (invitation) => {
|
|
1868
2105
|
next({
|
|
1869
|
-
action:
|
|
1870
|
-
type:
|
|
2106
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2107
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
1871
2108
|
invitations: [
|
|
1872
2109
|
invitation
|
|
1873
2110
|
]
|
|
@@ -1875,8 +2112,8 @@ var InvitationsServiceImpl = class {
|
|
|
1875
2112
|
});
|
|
1876
2113
|
this._removedCreated.on(ctx, (invitation) => {
|
|
1877
2114
|
next({
|
|
1878
|
-
action:
|
|
1879
|
-
type:
|
|
2115
|
+
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2116
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
1880
2117
|
invitations: [
|
|
1881
2118
|
invitation
|
|
1882
2119
|
]
|
|
@@ -1884,21 +2121,21 @@ var InvitationsServiceImpl = class {
|
|
|
1884
2121
|
});
|
|
1885
2122
|
this._removedAccepted.on(ctx, (invitation) => {
|
|
1886
2123
|
next({
|
|
1887
|
-
action:
|
|
1888
|
-
type:
|
|
2124
|
+
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2125
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
1889
2126
|
invitations: [
|
|
1890
2127
|
invitation
|
|
1891
2128
|
]
|
|
1892
2129
|
});
|
|
1893
2130
|
});
|
|
1894
2131
|
next({
|
|
1895
|
-
action:
|
|
1896
|
-
type:
|
|
2132
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2133
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
1897
2134
|
invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get())
|
|
1898
2135
|
});
|
|
1899
2136
|
next({
|
|
1900
|
-
action:
|
|
1901
|
-
type:
|
|
2137
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2138
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
1902
2139
|
invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get())
|
|
1903
2140
|
});
|
|
1904
2141
|
});
|
|
@@ -1906,12 +2143,12 @@ var InvitationsServiceImpl = class {
|
|
|
1906
2143
|
};
|
|
1907
2144
|
|
|
1908
2145
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1909
|
-
var
|
|
2146
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
1910
2147
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
1911
|
-
var
|
|
1912
|
-
var
|
|
1913
|
-
var
|
|
1914
|
-
var
|
|
2148
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
2149
|
+
var import_log8 = require("@dxos/log");
|
|
2150
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2151
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
1915
2152
|
var SpaceInvitationProtocol = class {
|
|
1916
2153
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
1917
2154
|
this._spaceManager = _spaceManager;
|
|
@@ -1927,14 +2164,13 @@ var SpaceInvitationProtocol = class {
|
|
|
1927
2164
|
}
|
|
1928
2165
|
getInvitationContext() {
|
|
1929
2166
|
return {
|
|
1930
|
-
kind:
|
|
2167
|
+
kind: import_services6.Invitation.Kind.SPACE,
|
|
1931
2168
|
spaceKey: this._spaceKey
|
|
1932
2169
|
};
|
|
1933
2170
|
}
|
|
1934
2171
|
async admit(request, guestProfile) {
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
F: __dxlog_file9,
|
|
2172
|
+
(0, import_invariant9.invariant)(this._spaceKey, void 0, {
|
|
2173
|
+
F: __dxlog_file10,
|
|
1938
2174
|
L: 42,
|
|
1939
2175
|
S: this,
|
|
1940
2176
|
A: [
|
|
@@ -1943,8 +2179,8 @@ var SpaceInvitationProtocol = class {
|
|
|
1943
2179
|
]
|
|
1944
2180
|
});
|
|
1945
2181
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
1946
|
-
(0,
|
|
1947
|
-
F:
|
|
2182
|
+
(0, import_invariant9.invariant)(space, void 0, {
|
|
2183
|
+
F: __dxlog_file10,
|
|
1948
2184
|
L: 44,
|
|
1949
2185
|
S: this,
|
|
1950
2186
|
A: [
|
|
@@ -1952,8 +2188,8 @@ var SpaceInvitationProtocol = class {
|
|
|
1952
2188
|
""
|
|
1953
2189
|
]
|
|
1954
2190
|
});
|
|
1955
|
-
(0,
|
|
1956
|
-
F:
|
|
2191
|
+
(0, import_invariant9.invariant)(request.space, void 0, {
|
|
2192
|
+
F: __dxlog_file10,
|
|
1957
2193
|
L: 46,
|
|
1958
2194
|
S: this,
|
|
1959
2195
|
A: [
|
|
@@ -1962,18 +2198,18 @@ var SpaceInvitationProtocol = class {
|
|
|
1962
2198
|
]
|
|
1963
2199
|
});
|
|
1964
2200
|
const { identityKey, deviceKey } = request.space;
|
|
1965
|
-
(0,
|
|
2201
|
+
(0, import_log8.log)("writing guest credentials", {
|
|
1966
2202
|
host: this._signingContext.deviceKey,
|
|
1967
2203
|
guest: deviceKey
|
|
1968
2204
|
}, {
|
|
1969
|
-
F:
|
|
2205
|
+
F: __dxlog_file10,
|
|
1970
2206
|
L: 49,
|
|
1971
2207
|
S: this,
|
|
1972
2208
|
C: (f, a) => f(...a)
|
|
1973
2209
|
});
|
|
1974
|
-
const credentials = await (0,
|
|
1975
|
-
(0,
|
|
1976
|
-
F:
|
|
2210
|
+
const credentials = await (0, import_credentials10.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2211
|
+
(0, import_invariant9.invariant)(credentials[0].credential, void 0, {
|
|
2212
|
+
F: __dxlog_file10,
|
|
1977
2213
|
L: 60,
|
|
1978
2214
|
S: this,
|
|
1979
2215
|
A: [
|
|
@@ -1982,8 +2218,8 @@ var SpaceInvitationProtocol = class {
|
|
|
1982
2218
|
]
|
|
1983
2219
|
});
|
|
1984
2220
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1985
|
-
(0,
|
|
1986
|
-
F:
|
|
2221
|
+
(0, import_invariant9.invariant)((0, import_credentials10.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2222
|
+
F: __dxlog_file10,
|
|
1987
2223
|
L: 62,
|
|
1988
2224
|
S: this,
|
|
1989
2225
|
A: [
|
|
@@ -1996,7 +2232,7 @@ var SpaceInvitationProtocol = class {
|
|
|
1996
2232
|
space: {
|
|
1997
2233
|
credential: spaceMemberCredential,
|
|
1998
2234
|
controlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
1999
|
-
dataTimeframe:
|
|
2235
|
+
dataTimeframe: space.dataPipeline.pipelineState?.timeframe
|
|
2000
2236
|
}
|
|
2001
2237
|
};
|
|
2002
2238
|
}
|
|
@@ -2018,8 +2254,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2018
2254
|
};
|
|
2019
2255
|
}
|
|
2020
2256
|
async accept(response) {
|
|
2021
|
-
(0,
|
|
2022
|
-
F:
|
|
2257
|
+
(0, import_invariant9.invariant)(response.space, void 0, {
|
|
2258
|
+
F: __dxlog_file10,
|
|
2023
2259
|
L: 97,
|
|
2024
2260
|
S: this,
|
|
2025
2261
|
A: [
|
|
@@ -2028,9 +2264,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2028
2264
|
]
|
|
2029
2265
|
});
|
|
2030
2266
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2031
|
-
const assertion = (0,
|
|
2032
|
-
(0,
|
|
2033
|
-
F:
|
|
2267
|
+
const assertion = (0, import_credentials10.getCredentialAssertion)(credential);
|
|
2268
|
+
(0, import_invariant9.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2269
|
+
F: __dxlog_file10,
|
|
2034
2270
|
L: 100,
|
|
2035
2271
|
S: this,
|
|
2036
2272
|
A: [
|
|
@@ -2038,8 +2274,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2038
2274
|
"'Invalid credential'"
|
|
2039
2275
|
]
|
|
2040
2276
|
});
|
|
2041
|
-
(0,
|
|
2042
|
-
F:
|
|
2277
|
+
(0, import_invariant9.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2278
|
+
F: __dxlog_file10,
|
|
2043
2279
|
L: 101,
|
|
2044
2280
|
S: this,
|
|
2045
2281
|
A: [
|
|
@@ -2062,47 +2298,47 @@ var SpaceInvitationProtocol = class {
|
|
|
2062
2298
|
|
|
2063
2299
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2064
2300
|
var import_async9 = require("@dxos/async");
|
|
2065
|
-
var
|
|
2066
|
-
var
|
|
2067
|
-
var
|
|
2301
|
+
var import_context7 = require("@dxos/context");
|
|
2302
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
2303
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
2068
2304
|
var import_keys7 = require("@dxos/keys");
|
|
2069
|
-
var
|
|
2070
|
-
var
|
|
2071
|
-
var
|
|
2305
|
+
var import_log11 = require("@dxos/log");
|
|
2306
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
2307
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2072
2308
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
2073
2309
|
var import_util4 = require("@dxos/util");
|
|
2074
2310
|
|
|
2075
2311
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2076
2312
|
var import_async8 = require("@dxos/async");
|
|
2077
2313
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
2078
|
-
var
|
|
2314
|
+
var import_context6 = require("@dxos/context");
|
|
2079
2315
|
var import_debug4 = require("@dxos/debug");
|
|
2080
2316
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2081
2317
|
var import_errors3 = require("@dxos/errors");
|
|
2082
2318
|
var import_keys6 = require("@dxos/keys");
|
|
2083
|
-
var
|
|
2084
|
-
var
|
|
2085
|
-
var
|
|
2086
|
-
var
|
|
2319
|
+
var import_log10 = require("@dxos/log");
|
|
2320
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2321
|
+
var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2322
|
+
var import_timeframe2 = require("@dxos/timeframe");
|
|
2087
2323
|
var import_util3 = require("@dxos/util");
|
|
2088
2324
|
|
|
2089
2325
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2090
2326
|
var import_async7 = require("@dxos/async");
|
|
2091
|
-
var
|
|
2092
|
-
var
|
|
2327
|
+
var import_context5 = require("@dxos/context");
|
|
2328
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
2093
2329
|
var import_keys5 = require("@dxos/keys");
|
|
2094
|
-
var
|
|
2095
|
-
var
|
|
2330
|
+
var import_log9 = require("@dxos/log");
|
|
2331
|
+
var import_protocols6 = require("@dxos/protocols");
|
|
2096
2332
|
var import_teleport2 = require("@dxos/teleport");
|
|
2097
2333
|
var import_util2 = require("@dxos/util");
|
|
2098
|
-
var
|
|
2334
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2099
2335
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2100
2336
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2101
2337
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
2102
2338
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2103
2339
|
var NotarizationPlugin = class {
|
|
2104
2340
|
constructor() {
|
|
2105
|
-
this._ctx = new
|
|
2341
|
+
this._ctx = new import_context5.Context();
|
|
2106
2342
|
this._extensionOpened = new import_async7.Event();
|
|
2107
2343
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2108
2344
|
this._processedCredentials = new import_util2.ComplexSet(import_keys5.PublicKey.hash);
|
|
@@ -2120,16 +2356,16 @@ var NotarizationPlugin = class {
|
|
|
2120
2356
|
* Request credentials to be notarized.
|
|
2121
2357
|
*/
|
|
2122
2358
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2123
|
-
(0,
|
|
2359
|
+
(0, import_log9.log)("notarize", {
|
|
2124
2360
|
credentials
|
|
2125
2361
|
}, {
|
|
2126
|
-
F:
|
|
2362
|
+
F: __dxlog_file11,
|
|
2127
2363
|
L: 90,
|
|
2128
2364
|
S: this,
|
|
2129
2365
|
C: (f, a) => f(...a)
|
|
2130
2366
|
});
|
|
2131
|
-
(0,
|
|
2132
|
-
F:
|
|
2367
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2368
|
+
F: __dxlog_file11,
|
|
2133
2369
|
L: 91,
|
|
2134
2370
|
S: this,
|
|
2135
2371
|
A: [
|
|
@@ -2140,10 +2376,10 @@ var NotarizationPlugin = class {
|
|
|
2140
2376
|
const errors = new import_async7.Trigger();
|
|
2141
2377
|
const ctx = this._ctx.derive({
|
|
2142
2378
|
onError: (err) => {
|
|
2143
|
-
|
|
2379
|
+
import_log9.log.warn("Notarization error", {
|
|
2144
2380
|
err
|
|
2145
2381
|
}, {
|
|
2146
|
-
F:
|
|
2382
|
+
F: __dxlog_file11,
|
|
2147
2383
|
L: 99,
|
|
2148
2384
|
S: this,
|
|
2149
2385
|
C: (f, a) => f(...a)
|
|
@@ -2152,14 +2388,14 @@ var NotarizationPlugin = class {
|
|
|
2152
2388
|
errors.throw(err);
|
|
2153
2389
|
}
|
|
2154
2390
|
});
|
|
2155
|
-
opCtx
|
|
2391
|
+
opCtx?.onDispose(() => ctx.dispose());
|
|
2156
2392
|
if (timeout !== 0) {
|
|
2157
2393
|
(0, import_async7.scheduleTask)(ctx, () => {
|
|
2158
|
-
|
|
2394
|
+
import_log9.log.warn("Notarization timeout", {
|
|
2159
2395
|
timeout,
|
|
2160
2396
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2161
2397
|
}, {
|
|
2162
|
-
F:
|
|
2398
|
+
F: __dxlog_file11,
|
|
2163
2399
|
L: 111,
|
|
2164
2400
|
S: this,
|
|
2165
2401
|
C: (f, a) => f(...a)
|
|
@@ -2179,10 +2415,10 @@ var NotarizationPlugin = class {
|
|
|
2179
2415
|
...this._extensions
|
|
2180
2416
|
].find((peer2) => !peersTried.has(peer2));
|
|
2181
2417
|
if (!peer) {
|
|
2182
|
-
|
|
2418
|
+
import_log9.log.warn("Exhausted all peers to notarize with", {
|
|
2183
2419
|
retryIn: retryTimeout
|
|
2184
2420
|
}, {
|
|
2185
|
-
F:
|
|
2421
|
+
F: __dxlog_file11,
|
|
2186
2422
|
L: 136,
|
|
2187
2423
|
S: this,
|
|
2188
2424
|
C: (f, a) => f(...a)
|
|
@@ -2192,11 +2428,11 @@ var NotarizationPlugin = class {
|
|
|
2192
2428
|
return;
|
|
2193
2429
|
}
|
|
2194
2430
|
peersTried.add(peer);
|
|
2195
|
-
(0,
|
|
2431
|
+
(0, import_log9.log)("try notarizing", {
|
|
2196
2432
|
peer: peer.localPeerId,
|
|
2197
2433
|
credentialId: credentials.map((credential) => credential.id)
|
|
2198
2434
|
}, {
|
|
2199
|
-
F:
|
|
2435
|
+
F: __dxlog_file11,
|
|
2200
2436
|
L: 143,
|
|
2201
2437
|
S: this,
|
|
2202
2438
|
C: (f, a) => f(...a)
|
|
@@ -2204,8 +2440,8 @@ var NotarizationPlugin = class {
|
|
|
2204
2440
|
await peer.rpc.NotarizationService.notarize({
|
|
2205
2441
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2206
2442
|
});
|
|
2207
|
-
(0,
|
|
2208
|
-
F:
|
|
2443
|
+
(0, import_log9.log)("success", void 0, {
|
|
2444
|
+
F: __dxlog_file11,
|
|
2209
2445
|
L: 147,
|
|
2210
2446
|
S: this,
|
|
2211
2447
|
C: (f, a) => f(...a)
|
|
@@ -2213,8 +2449,8 @@ var NotarizationPlugin = class {
|
|
|
2213
2449
|
await (0, import_async7.sleep)(successDelay);
|
|
2214
2450
|
} catch (err) {
|
|
2215
2451
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2216
|
-
|
|
2217
|
-
F:
|
|
2452
|
+
import_log9.log.warn("error notarizing (recoverable)", err, {
|
|
2453
|
+
F: __dxlog_file11,
|
|
2218
2454
|
L: 151,
|
|
2219
2455
|
S: this,
|
|
2220
2456
|
C: (f, a) => f(...a)
|
|
@@ -2227,12 +2463,12 @@ var NotarizationPlugin = class {
|
|
|
2227
2463
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
2228
2464
|
try {
|
|
2229
2465
|
await Promise.race([
|
|
2230
|
-
(0,
|
|
2466
|
+
(0, import_context5.rejectOnDispose)(ctx),
|
|
2231
2467
|
allNotarized,
|
|
2232
2468
|
errors.wait()
|
|
2233
2469
|
]);
|
|
2234
|
-
(0,
|
|
2235
|
-
F:
|
|
2470
|
+
(0, import_log9.log)("done", void 0, {
|
|
2471
|
+
F: __dxlog_file11,
|
|
2236
2472
|
L: 162,
|
|
2237
2473
|
S: this,
|
|
2238
2474
|
C: (f, a) => f(...a)
|
|
@@ -2245,17 +2481,16 @@ var NotarizationPlugin = class {
|
|
|
2245
2481
|
* Called with credentials arriving from the control pipeline.
|
|
2246
2482
|
*/
|
|
2247
2483
|
async processCredential(credential) {
|
|
2248
|
-
var _a;
|
|
2249
2484
|
if (!credential.id) {
|
|
2250
2485
|
return;
|
|
2251
2486
|
}
|
|
2252
|
-
|
|
2487
|
+
this._processCredentialsTriggers.get(credential.id)?.wake();
|
|
2253
2488
|
this._processedCredentials.add(credential.id);
|
|
2254
2489
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2255
2490
|
}
|
|
2256
2491
|
setWriter(writer) {
|
|
2257
|
-
(0,
|
|
2258
|
-
F:
|
|
2492
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
2493
|
+
F: __dxlog_file11,
|
|
2259
2494
|
L: 181,
|
|
2260
2495
|
S: this,
|
|
2261
2496
|
A: [
|
|
@@ -2275,13 +2510,12 @@ var NotarizationPlugin = class {
|
|
|
2275
2510
|
* Requests from other peers to notarize credentials.
|
|
2276
2511
|
*/
|
|
2277
2512
|
async _onNotarize(request) {
|
|
2278
|
-
var _a;
|
|
2279
2513
|
if (!this._writer) {
|
|
2280
2514
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2281
2515
|
}
|
|
2282
|
-
for (const credential of
|
|
2283
|
-
(0,
|
|
2284
|
-
F:
|
|
2516
|
+
for (const credential of request.credentials ?? []) {
|
|
2517
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
2518
|
+
F: __dxlog_file11,
|
|
2285
2519
|
L: 200,
|
|
2286
2520
|
S: this,
|
|
2287
2521
|
A: [
|
|
@@ -2298,10 +2532,10 @@ var NotarizationPlugin = class {
|
|
|
2298
2532
|
createExtension() {
|
|
2299
2533
|
const extension = new NotarizationTeleportExtension({
|
|
2300
2534
|
onOpen: async () => {
|
|
2301
|
-
(0,
|
|
2535
|
+
(0, import_log9.log)("extension opened", {
|
|
2302
2536
|
peer: extension.localPeerId
|
|
2303
2537
|
}, {
|
|
2304
|
-
F:
|
|
2538
|
+
F: __dxlog_file11,
|
|
2305
2539
|
L: 211,
|
|
2306
2540
|
S: this,
|
|
2307
2541
|
C: (f, a) => f(...a)
|
|
@@ -2310,10 +2544,10 @@ var NotarizationPlugin = class {
|
|
|
2310
2544
|
this._extensionOpened.emit();
|
|
2311
2545
|
},
|
|
2312
2546
|
onClose: async () => {
|
|
2313
|
-
(0,
|
|
2547
|
+
(0, import_log9.log)("extension closed", {
|
|
2314
2548
|
peer: extension.localPeerId
|
|
2315
2549
|
}, {
|
|
2316
|
-
F:
|
|
2550
|
+
F: __dxlog_file11,
|
|
2317
2551
|
L: 216,
|
|
2318
2552
|
S: this,
|
|
2319
2553
|
C: (f, a) => f(...a)
|
|
@@ -2329,10 +2563,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2329
2563
|
constructor(_params) {
|
|
2330
2564
|
super({
|
|
2331
2565
|
requested: {
|
|
2332
|
-
NotarizationService:
|
|
2566
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2333
2567
|
},
|
|
2334
2568
|
exposed: {
|
|
2335
|
-
NotarizationService:
|
|
2569
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2336
2570
|
}
|
|
2337
2571
|
});
|
|
2338
2572
|
this._params = _params;
|
|
@@ -2357,7 +2591,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2357
2591
|
};
|
|
2358
2592
|
|
|
2359
2593
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2360
|
-
function
|
|
2594
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2361
2595
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2362
2596
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2363
2597
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2367,19 +2601,19 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2367
2601
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2368
2602
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2369
2603
|
}
|
|
2370
|
-
var
|
|
2604
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2605
|
+
var ENABLE_FEED_PURGE = false;
|
|
2371
2606
|
var DataSpace = class DataSpace2 {
|
|
2372
2607
|
constructor(params) {
|
|
2373
|
-
this._ctx = new
|
|
2608
|
+
this._ctx = new import_context6.Context();
|
|
2374
2609
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2375
|
-
this._state =
|
|
2610
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2376
2611
|
/**
|
|
2377
2612
|
* Error for _state === SpaceState.ERROR.
|
|
2378
2613
|
*/
|
|
2379
2614
|
this.error = void 0;
|
|
2380
2615
|
this.stateUpdate = new import_async8.Event();
|
|
2381
2616
|
this.metrics = {};
|
|
2382
|
-
var _a;
|
|
2383
2617
|
this._inner = params.inner;
|
|
2384
2618
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2385
2619
|
this._gossip = params.gossip;
|
|
@@ -2388,7 +2622,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2388
2622
|
this._feedStore = params.feedStore;
|
|
2389
2623
|
this._metadataStore = params.metadataStore;
|
|
2390
2624
|
this._signingContext = params.signingContext;
|
|
2391
|
-
this._callbacks =
|
|
2625
|
+
this._callbacks = params.callbacks ?? {};
|
|
2392
2626
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2393
2627
|
trustedKeysProvider: () => new import_util3.ComplexSet(import_keys6.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2394
2628
|
update: this._inner.stateUpdate,
|
|
@@ -2428,21 +2662,20 @@ var DataSpace = class DataSpace2 {
|
|
|
2428
2662
|
async _open() {
|
|
2429
2663
|
await this._notarizationPlugin.open();
|
|
2430
2664
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2431
|
-
await this._inner.open();
|
|
2432
|
-
this._state =
|
|
2665
|
+
await this._inner.open(new import_context6.Context());
|
|
2666
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
2433
2667
|
this.stateUpdate.emit();
|
|
2434
2668
|
this.metrics = {};
|
|
2435
|
-
this.metrics.open = new Date();
|
|
2669
|
+
this.metrics.open = /* @__PURE__ */ new Date();
|
|
2436
2670
|
}
|
|
2437
2671
|
async close() {
|
|
2438
2672
|
await this._close();
|
|
2439
2673
|
}
|
|
2440
2674
|
async _close() {
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
this._state = import_services6.SpaceState.CLOSED;
|
|
2675
|
+
await this._callbacks.beforeClose?.();
|
|
2676
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2444
2677
|
await this._ctx.dispose();
|
|
2445
|
-
this._ctx = new
|
|
2678
|
+
this._ctx = new import_context6.Context();
|
|
2446
2679
|
await this.authVerifier.close();
|
|
2447
2680
|
await this._inner.close();
|
|
2448
2681
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
@@ -2461,47 +2694,46 @@ var DataSpace = class DataSpace2 {
|
|
|
2461
2694
|
initializeDataPipelineAsync() {
|
|
2462
2695
|
(0, import_async8.scheduleTask)(this._ctx, async () => {
|
|
2463
2696
|
try {
|
|
2464
|
-
this.metrics.pipelineInitBegin = new Date();
|
|
2697
|
+
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
2465
2698
|
await this.initializeDataPipeline();
|
|
2466
2699
|
} catch (err) {
|
|
2467
2700
|
if (err instanceof import_errors3.CancelledError) {
|
|
2468
|
-
(0,
|
|
2469
|
-
F:
|
|
2470
|
-
L:
|
|
2701
|
+
(0, import_log10.log)("data pipeline initialization cancelled", err, {
|
|
2702
|
+
F: __dxlog_file12,
|
|
2703
|
+
L: 199,
|
|
2471
2704
|
S: this,
|
|
2472
2705
|
C: (f, a) => f(...a)
|
|
2473
2706
|
});
|
|
2474
2707
|
return;
|
|
2475
2708
|
}
|
|
2476
|
-
|
|
2477
|
-
F:
|
|
2478
|
-
L:
|
|
2709
|
+
import_log10.log.error("Error initializing data pipeline", err, {
|
|
2710
|
+
F: __dxlog_file12,
|
|
2711
|
+
L: 203,
|
|
2479
2712
|
S: this,
|
|
2480
2713
|
C: (f, a) => f(...a)
|
|
2481
2714
|
});
|
|
2482
|
-
this._state =
|
|
2715
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
2483
2716
|
this.error = err;
|
|
2484
2717
|
this.stateUpdate.emit();
|
|
2485
2718
|
} finally {
|
|
2486
|
-
this.metrics.ready = new Date();
|
|
2719
|
+
this.metrics.ready = /* @__PURE__ */ new Date();
|
|
2487
2720
|
}
|
|
2488
2721
|
});
|
|
2489
2722
|
}
|
|
2490
2723
|
async initializeDataPipeline() {
|
|
2491
|
-
|
|
2492
|
-
if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
|
|
2724
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
2493
2725
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2494
2726
|
}
|
|
2495
|
-
this._state =
|
|
2727
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
2496
2728
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2497
2729
|
ctx: this._ctx,
|
|
2498
2730
|
breakOnStall: false
|
|
2499
2731
|
});
|
|
2500
|
-
this.metrics.controlPipelineReady = new Date();
|
|
2732
|
+
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
2501
2733
|
await this._createWritableFeeds();
|
|
2502
|
-
(0,
|
|
2503
|
-
F:
|
|
2504
|
-
L:
|
|
2734
|
+
(0, import_log10.log)("writable feeds created", void 0, {
|
|
2735
|
+
F: __dxlog_file12,
|
|
2736
|
+
L: 227,
|
|
2505
2737
|
S: this,
|
|
2506
2738
|
C: (f, a) => f(...a)
|
|
2507
2739
|
});
|
|
@@ -2514,11 +2746,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2514
2746
|
}), this._inner.controlPipeline.writer));
|
|
2515
2747
|
}
|
|
2516
2748
|
await this._inner.initializeDataPipeline();
|
|
2517
|
-
this.metrics.dataPipelineOpen = new Date();
|
|
2518
|
-
await (0,
|
|
2519
|
-
(0,
|
|
2520
|
-
F:
|
|
2521
|
-
L:
|
|
2749
|
+
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
2750
|
+
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2751
|
+
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2752
|
+
F: __dxlog_file12,
|
|
2753
|
+
L: 248,
|
|
2522
2754
|
S: this,
|
|
2523
2755
|
C: (f, a) => f(...a)
|
|
2524
2756
|
});
|
|
@@ -2526,17 +2758,17 @@ var DataSpace = class DataSpace2 {
|
|
|
2526
2758
|
ctx: this._ctx,
|
|
2527
2759
|
breakOnStall: false
|
|
2528
2760
|
});
|
|
2529
|
-
this.metrics.dataPipelineReady = new Date();
|
|
2530
|
-
(0,
|
|
2531
|
-
F:
|
|
2532
|
-
L:
|
|
2761
|
+
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
2762
|
+
(0, import_log10.log)("data pipeline ready", void 0, {
|
|
2763
|
+
F: __dxlog_file12,
|
|
2764
|
+
L: 257,
|
|
2533
2765
|
S: this,
|
|
2534
2766
|
C: (f, a) => f(...a)
|
|
2535
2767
|
});
|
|
2536
|
-
await
|
|
2537
|
-
this._state =
|
|
2768
|
+
await this._callbacks.beforeReady?.();
|
|
2769
|
+
this._state = import_services7.SpaceState.READY;
|
|
2538
2770
|
this.stateUpdate.emit();
|
|
2539
|
-
await
|
|
2771
|
+
await this._callbacks.afterReady?.();
|
|
2540
2772
|
}
|
|
2541
2773
|
async _createWritableFeeds() {
|
|
2542
2774
|
const credentials = [];
|
|
@@ -2552,7 +2784,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2552
2784
|
spaceKey: this.key,
|
|
2553
2785
|
deviceKey: this._signingContext.deviceKey,
|
|
2554
2786
|
identityKey: this._signingContext.identityKey,
|
|
2555
|
-
designation:
|
|
2787
|
+
designation: import_credentials11.AdmittedFeed.Designation.CONTROL
|
|
2556
2788
|
}
|
|
2557
2789
|
}));
|
|
2558
2790
|
}
|
|
@@ -2569,7 +2801,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2569
2801
|
spaceKey: this.key,
|
|
2570
2802
|
deviceKey: this._signingContext.deviceKey,
|
|
2571
2803
|
identityKey: this._signingContext.identityKey,
|
|
2572
|
-
designation:
|
|
2804
|
+
designation: import_credentials11.AdmittedFeed.Designation.DATA
|
|
2573
2805
|
}
|
|
2574
2806
|
}));
|
|
2575
2807
|
}
|
|
@@ -2583,7 +2815,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2583
2815
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
2584
2816
|
}
|
|
2585
2817
|
async createEpoch() {
|
|
2586
|
-
var _a, _b;
|
|
2587
2818
|
const epoch = await this.dataPipeline.createEpoch();
|
|
2588
2819
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
2589
2820
|
credential: {
|
|
@@ -2596,65 +2827,67 @@ var DataSpace = class DataSpace2 {
|
|
|
2596
2827
|
})
|
|
2597
2828
|
}
|
|
2598
2829
|
});
|
|
2599
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
2830
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
|
|
2600
2831
|
[
|
|
2601
2832
|
receipt.feedKey,
|
|
2602
2833
|
receipt.seq
|
|
2603
2834
|
]
|
|
2604
2835
|
]));
|
|
2605
|
-
|
|
2606
|
-
const
|
|
2607
|
-
|
|
2608
|
-
|
|
2836
|
+
if (ENABLE_FEED_PURGE) {
|
|
2837
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
2838
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
2839
|
+
if (indexBeforeEpoch === void 0) {
|
|
2840
|
+
continue;
|
|
2841
|
+
}
|
|
2842
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
2609
2843
|
}
|
|
2610
2844
|
}
|
|
2611
2845
|
}
|
|
2612
2846
|
async activate() {
|
|
2613
|
-
if (this._state !==
|
|
2847
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
2614
2848
|
return;
|
|
2615
2849
|
}
|
|
2616
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
2850
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
2617
2851
|
await this._open();
|
|
2618
2852
|
this.initializeDataPipelineAsync();
|
|
2619
2853
|
}
|
|
2620
2854
|
async deactivate() {
|
|
2621
|
-
if (this._state ===
|
|
2855
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
2622
2856
|
return;
|
|
2623
2857
|
}
|
|
2624
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
2858
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
2625
2859
|
await this._close();
|
|
2626
|
-
this._state =
|
|
2860
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
2627
2861
|
this.stateUpdate.emit();
|
|
2628
2862
|
}
|
|
2629
2863
|
};
|
|
2630
|
-
|
|
2864
|
+
_ts_decorate3([
|
|
2631
2865
|
import_async8.synchronized
|
|
2632
2866
|
], DataSpace.prototype, "open", null);
|
|
2633
|
-
|
|
2867
|
+
_ts_decorate3([
|
|
2634
2868
|
import_async8.synchronized
|
|
2635
2869
|
], DataSpace.prototype, "close", null);
|
|
2636
|
-
|
|
2870
|
+
_ts_decorate3([
|
|
2637
2871
|
(0, import_debug4.timed)(1e4)
|
|
2638
2872
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2639
|
-
|
|
2873
|
+
_ts_decorate3([
|
|
2640
2874
|
import_async8.synchronized
|
|
2641
2875
|
], DataSpace.prototype, "activate", null);
|
|
2642
|
-
|
|
2876
|
+
_ts_decorate3([
|
|
2643
2877
|
import_async8.synchronized
|
|
2644
2878
|
], DataSpace.prototype, "deactivate", null);
|
|
2645
|
-
DataSpace =
|
|
2879
|
+
DataSpace = _ts_decorate3([
|
|
2646
2880
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2647
2881
|
], DataSpace);
|
|
2648
2882
|
|
|
2649
2883
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
2650
|
-
var
|
|
2884
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
2651
2885
|
var import_debug5 = require("@dxos/debug");
|
|
2652
|
-
var
|
|
2653
|
-
var
|
|
2886
|
+
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2887
|
+
var import_timeframe3 = require("@dxos/timeframe");
|
|
2654
2888
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2655
|
-
var _a, _b, _c, _d;
|
|
2656
2889
|
const credentials = [
|
|
2657
|
-
await (0,
|
|
2890
|
+
await (0, import_credentials12.createCredential)({
|
|
2658
2891
|
signer: keyring,
|
|
2659
2892
|
issuer: space.key,
|
|
2660
2893
|
subject: space.key,
|
|
@@ -2663,45 +2896,45 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2663
2896
|
spaceKey: space.key
|
|
2664
2897
|
}
|
|
2665
2898
|
}),
|
|
2666
|
-
await (0,
|
|
2899
|
+
await (0, import_credentials12.createCredential)({
|
|
2667
2900
|
signer: keyring,
|
|
2668
2901
|
issuer: space.key,
|
|
2669
2902
|
subject: signingContext.identityKey,
|
|
2670
2903
|
assertion: {
|
|
2671
2904
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
2672
2905
|
spaceKey: space.key,
|
|
2673
|
-
role:
|
|
2906
|
+
role: import_credentials13.SpaceMember.Role.ADMIN,
|
|
2674
2907
|
profile: signingContext.profile,
|
|
2675
|
-
genesisFeedKey:
|
|
2908
|
+
genesisFeedKey: space.controlFeedKey ?? (0, import_debug5.failUndefined)()
|
|
2676
2909
|
}
|
|
2677
2910
|
}),
|
|
2678
2911
|
await signingContext.credentialSigner.createCredential({
|
|
2679
|
-
subject:
|
|
2912
|
+
subject: space.controlFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
2680
2913
|
assertion: {
|
|
2681
2914
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2682
2915
|
spaceKey: space.key,
|
|
2683
2916
|
identityKey: signingContext.identityKey,
|
|
2684
2917
|
deviceKey: signingContext.deviceKey,
|
|
2685
|
-
designation:
|
|
2918
|
+
designation: import_credentials13.AdmittedFeed.Designation.CONTROL
|
|
2686
2919
|
}
|
|
2687
2920
|
}),
|
|
2688
2921
|
await signingContext.credentialSigner.createCredential({
|
|
2689
|
-
subject:
|
|
2922
|
+
subject: space.dataFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
2690
2923
|
assertion: {
|
|
2691
2924
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2692
2925
|
spaceKey: space.key,
|
|
2693
2926
|
identityKey: signingContext.identityKey,
|
|
2694
2927
|
deviceKey: signingContext.deviceKey,
|
|
2695
|
-
designation:
|
|
2928
|
+
designation: import_credentials13.AdmittedFeed.Designation.DATA
|
|
2696
2929
|
}
|
|
2697
2930
|
}),
|
|
2698
2931
|
await signingContext.credentialSigner.createCredential({
|
|
2699
|
-
subject:
|
|
2932
|
+
subject: space.key ?? (0, import_debug5.failUndefined)(),
|
|
2700
2933
|
assertion: {
|
|
2701
2934
|
"@type": "dxos.halo.credentials.Epoch",
|
|
2702
2935
|
number: 0,
|
|
2703
2936
|
previousId: void 0,
|
|
2704
|
-
timeframe: new
|
|
2937
|
+
timeframe: new import_timeframe3.Timeframe(),
|
|
2705
2938
|
snapshotCid: void 0
|
|
2706
2939
|
}
|
|
2707
2940
|
})
|
|
@@ -2717,7 +2950,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2717
2950
|
};
|
|
2718
2951
|
|
|
2719
2952
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2720
|
-
function
|
|
2953
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
2721
2954
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2722
2955
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2723
2956
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2727,7 +2960,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
2727
2960
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2728
2961
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2729
2962
|
}
|
|
2730
|
-
var
|
|
2963
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2731
2964
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2732
2965
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2733
2966
|
this._spaceManager = _spaceManager;
|
|
@@ -2736,7 +2969,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2736
2969
|
this._keyring = _keyring;
|
|
2737
2970
|
this._signingContext = _signingContext;
|
|
2738
2971
|
this._feedStore = _feedStore;
|
|
2739
|
-
this._ctx = new
|
|
2972
|
+
this._ctx = new import_context7.Context();
|
|
2740
2973
|
this.updated = new import_async9.Event();
|
|
2741
2974
|
this._spaces = new import_util4.ComplexMap(import_keys7.PublicKey.hash);
|
|
2742
2975
|
this._isOpen = false;
|
|
@@ -2747,49 +2980,49 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2747
2980
|
return this._spaces;
|
|
2748
2981
|
}
|
|
2749
2982
|
async open() {
|
|
2750
|
-
(0,
|
|
2751
|
-
F:
|
|
2983
|
+
(0, import_log11.log)("open", void 0, {
|
|
2984
|
+
F: __dxlog_file13,
|
|
2752
2985
|
L: 79,
|
|
2753
2986
|
S: this,
|
|
2754
2987
|
C: (f, a) => f(...a)
|
|
2755
2988
|
});
|
|
2756
|
-
|
|
2989
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.begin({
|
|
2757
2990
|
id: this._instanceId
|
|
2758
2991
|
}), {
|
|
2759
|
-
F:
|
|
2992
|
+
F: __dxlog_file13,
|
|
2760
2993
|
L: 80,
|
|
2761
2994
|
S: this,
|
|
2762
2995
|
C: (f, a) => f(...a)
|
|
2763
2996
|
});
|
|
2764
2997
|
await this._metadataStore.load();
|
|
2765
|
-
(0,
|
|
2998
|
+
(0, import_log11.log)("metadata loaded", {
|
|
2766
2999
|
spaces: this._metadataStore.spaces.length
|
|
2767
3000
|
}, {
|
|
2768
|
-
F:
|
|
3001
|
+
F: __dxlog_file13,
|
|
2769
3002
|
L: 82,
|
|
2770
3003
|
S: this,
|
|
2771
3004
|
C: (f, a) => f(...a)
|
|
2772
3005
|
});
|
|
2773
3006
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2774
3007
|
try {
|
|
2775
|
-
(0,
|
|
3008
|
+
(0, import_log11.log)("load space", {
|
|
2776
3009
|
spaceMetadata
|
|
2777
3010
|
}, {
|
|
2778
|
-
F:
|
|
3011
|
+
F: __dxlog_file13,
|
|
2779
3012
|
L: 86,
|
|
2780
3013
|
S: this,
|
|
2781
3014
|
C: (f, a) => f(...a)
|
|
2782
3015
|
});
|
|
2783
3016
|
const space = await this._constructSpace(spaceMetadata);
|
|
2784
|
-
if (spaceMetadata.state !==
|
|
3017
|
+
if (spaceMetadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
2785
3018
|
space.initializeDataPipelineAsync();
|
|
2786
3019
|
}
|
|
2787
3020
|
} catch (err) {
|
|
2788
|
-
|
|
3021
|
+
import_log11.log.error("Error loading space", {
|
|
2789
3022
|
spaceMetadata,
|
|
2790
3023
|
err
|
|
2791
3024
|
}, {
|
|
2792
|
-
F:
|
|
3025
|
+
F: __dxlog_file13,
|
|
2793
3026
|
L: 92,
|
|
2794
3027
|
S: this,
|
|
2795
3028
|
C: (f, a) => f(...a)
|
|
@@ -2798,18 +3031,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2798
3031
|
}
|
|
2799
3032
|
this._isOpen = true;
|
|
2800
3033
|
this.updated.emit();
|
|
2801
|
-
|
|
3034
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.end({
|
|
2802
3035
|
id: this._instanceId
|
|
2803
3036
|
}), {
|
|
2804
|
-
F:
|
|
3037
|
+
F: __dxlog_file13,
|
|
2805
3038
|
L: 98,
|
|
2806
3039
|
S: this,
|
|
2807
3040
|
C: (f, a) => f(...a)
|
|
2808
3041
|
});
|
|
2809
3042
|
}
|
|
2810
3043
|
async close() {
|
|
2811
|
-
(0,
|
|
2812
|
-
F:
|
|
3044
|
+
(0, import_log11.log)("close", void 0, {
|
|
3045
|
+
F: __dxlog_file13,
|
|
2813
3046
|
L: 103,
|
|
2814
3047
|
S: this,
|
|
2815
3048
|
C: (f, a) => f(...a)
|
|
@@ -2824,8 +3057,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2824
3057
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2825
3058
|
*/
|
|
2826
3059
|
async createSpace() {
|
|
2827
|
-
(0,
|
|
2828
|
-
F:
|
|
3060
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3061
|
+
F: __dxlog_file13,
|
|
2829
3062
|
L: 116,
|
|
2830
3063
|
S: this,
|
|
2831
3064
|
A: [
|
|
@@ -2841,12 +3074,12 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2841
3074
|
genesisFeedKey: controlFeedKey,
|
|
2842
3075
|
controlFeedKey,
|
|
2843
3076
|
dataFeedKey,
|
|
2844
|
-
state:
|
|
3077
|
+
state: import_services8.SpaceState.ACTIVE
|
|
2845
3078
|
};
|
|
2846
|
-
(0,
|
|
3079
|
+
(0, import_log11.log)("creating space...", {
|
|
2847
3080
|
spaceKey
|
|
2848
3081
|
}, {
|
|
2849
|
-
F:
|
|
3082
|
+
F: __dxlog_file13,
|
|
2850
3083
|
L: 128,
|
|
2851
3084
|
S: this,
|
|
2852
3085
|
C: (f, a) => f(...a)
|
|
@@ -2855,8 +3088,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2855
3088
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2856
3089
|
await this._metadataStore.addSpace(metadata);
|
|
2857
3090
|
const memberCredential = credentials[1];
|
|
2858
|
-
(0,
|
|
2859
|
-
F:
|
|
3091
|
+
(0, import_invariant11.invariant)((0, import_credentials14.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3092
|
+
F: __dxlog_file13,
|
|
2860
3093
|
L: 135,
|
|
2861
3094
|
S: this,
|
|
2862
3095
|
A: [
|
|
@@ -2871,16 +3104,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2871
3104
|
}
|
|
2872
3105
|
// TODO(burdon): Rename join space.
|
|
2873
3106
|
async acceptSpace(opts) {
|
|
2874
|
-
(0,
|
|
3107
|
+
(0, import_log11.log)("accept space", {
|
|
2875
3108
|
opts
|
|
2876
3109
|
}, {
|
|
2877
|
-
F:
|
|
3110
|
+
F: __dxlog_file13,
|
|
2878
3111
|
L: 147,
|
|
2879
3112
|
S: this,
|
|
2880
3113
|
C: (f, a) => f(...a)
|
|
2881
3114
|
});
|
|
2882
|
-
(0,
|
|
2883
|
-
F:
|
|
3115
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3116
|
+
F: __dxlog_file13,
|
|
2884
3117
|
L: 148,
|
|
2885
3118
|
S: this,
|
|
2886
3119
|
A: [
|
|
@@ -2888,8 +3121,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2888
3121
|
"'Not open.'"
|
|
2889
3122
|
]
|
|
2890
3123
|
});
|
|
2891
|
-
(0,
|
|
2892
|
-
F:
|
|
3124
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3125
|
+
F: __dxlog_file13,
|
|
2893
3126
|
L: 149,
|
|
2894
3127
|
S: this,
|
|
2895
3128
|
A: [
|
|
@@ -2915,16 +3148,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2915
3148
|
* TODO(dmaretskyi): Consider removing.
|
|
2916
3149
|
*/
|
|
2917
3150
|
async waitUntilSpaceReady(spaceKey) {
|
|
2918
|
-
await (0,
|
|
3151
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
2919
3152
|
const space = this._spaces.get(spaceKey);
|
|
2920
|
-
return !!space && space.state ===
|
|
3153
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
2921
3154
|
}));
|
|
2922
3155
|
}
|
|
2923
3156
|
async _constructSpace(metadata) {
|
|
2924
|
-
(0,
|
|
3157
|
+
(0, import_log11.log)("construct space", {
|
|
2925
3158
|
metadata
|
|
2926
3159
|
}, {
|
|
2927
|
-
F:
|
|
3160
|
+
F: __dxlog_file13,
|
|
2928
3161
|
L: 182,
|
|
2929
3162
|
S: this,
|
|
2930
3163
|
C: (f, a) => f(...a)
|
|
@@ -2959,8 +3192,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2959
3192
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2960
3193
|
},
|
|
2961
3194
|
onAuthFailure: () => {
|
|
2962
|
-
|
|
2963
|
-
F:
|
|
3195
|
+
import_log11.log.warn("auth failure", void 0, {
|
|
3196
|
+
F: __dxlog_file13,
|
|
2964
3197
|
L: 213,
|
|
2965
3198
|
S: this,
|
|
2966
3199
|
C: (f, a) => f(...a)
|
|
@@ -2972,7 +3205,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2972
3205
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2973
3206
|
const dataSpace = new DataSpace({
|
|
2974
3207
|
inner: space,
|
|
2975
|
-
initialState: metadata.state ===
|
|
3208
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
2976
3209
|
metadataStore: this._metadataStore,
|
|
2977
3210
|
gossip,
|
|
2978
3211
|
presence,
|
|
@@ -2981,10 +3214,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2981
3214
|
signingContext: this._signingContext,
|
|
2982
3215
|
callbacks: {
|
|
2983
3216
|
beforeReady: async () => {
|
|
2984
|
-
(0,
|
|
3217
|
+
(0, import_log11.log)("before space ready", {
|
|
2985
3218
|
space: space.key
|
|
2986
3219
|
}, {
|
|
2987
|
-
F:
|
|
3220
|
+
F: __dxlog_file13,
|
|
2988
3221
|
L: 231,
|
|
2989
3222
|
S: this,
|
|
2990
3223
|
C: (f, a) => f(...a)
|
|
@@ -2992,11 +3225,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2992
3225
|
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2993
3226
|
},
|
|
2994
3227
|
afterReady: async () => {
|
|
2995
|
-
(0,
|
|
3228
|
+
(0, import_log11.log)("after space ready", {
|
|
2996
3229
|
space: space.key,
|
|
2997
3230
|
open: this._isOpen
|
|
2998
3231
|
}, {
|
|
2999
|
-
F:
|
|
3232
|
+
F: __dxlog_file13,
|
|
3000
3233
|
L: 238,
|
|
3001
3234
|
S: this,
|
|
3002
3235
|
C: (f, a) => f(...a)
|
|
@@ -3006,10 +3239,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3006
3239
|
}
|
|
3007
3240
|
},
|
|
3008
3241
|
beforeClose: async () => {
|
|
3009
|
-
(0,
|
|
3242
|
+
(0, import_log11.log)("before space close", {
|
|
3010
3243
|
space: space.key
|
|
3011
3244
|
}, {
|
|
3012
|
-
F:
|
|
3245
|
+
F: __dxlog_file13,
|
|
3013
3246
|
L: 244,
|
|
3014
3247
|
S: this,
|
|
3015
3248
|
C: (f, a) => f(...a)
|
|
@@ -3019,7 +3252,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3019
3252
|
},
|
|
3020
3253
|
cache: metadata.cache
|
|
3021
3254
|
});
|
|
3022
|
-
if (metadata.state !==
|
|
3255
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
3023
3256
|
await dataSpace.open();
|
|
3024
3257
|
}
|
|
3025
3258
|
if (metadata.controlTimeframe) {
|
|
@@ -3032,33 +3265,33 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3032
3265
|
return dataSpace;
|
|
3033
3266
|
}
|
|
3034
3267
|
};
|
|
3035
|
-
|
|
3268
|
+
_ts_decorate4([
|
|
3036
3269
|
import_async9.synchronized
|
|
3037
3270
|
], DataSpaceManager.prototype, "open", null);
|
|
3038
|
-
|
|
3271
|
+
_ts_decorate4([
|
|
3039
3272
|
import_async9.synchronized
|
|
3040
3273
|
], DataSpaceManager.prototype, "close", null);
|
|
3041
|
-
|
|
3274
|
+
_ts_decorate4([
|
|
3042
3275
|
import_async9.synchronized
|
|
3043
3276
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3044
|
-
|
|
3277
|
+
_ts_decorate4([
|
|
3045
3278
|
import_async9.synchronized
|
|
3046
3279
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3047
|
-
DataSpaceManager =
|
|
3280
|
+
DataSpaceManager = _ts_decorate4([
|
|
3048
3281
|
(0, import_async9.trackLeaks)("open", "close")
|
|
3049
3282
|
], DataSpaceManager);
|
|
3050
3283
|
|
|
3051
3284
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3052
3285
|
var import_async10 = require("@dxos/async");
|
|
3053
|
-
var
|
|
3286
|
+
var import_codec_protobuf5 = require("@dxos/codec-protobuf");
|
|
3054
3287
|
var import_debug6 = require("@dxos/debug");
|
|
3055
3288
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
3056
3289
|
var import_errors4 = require("@dxos/errors");
|
|
3057
|
-
var
|
|
3058
|
-
var
|
|
3059
|
-
var
|
|
3290
|
+
var import_log12 = require("@dxos/log");
|
|
3291
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
3292
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3060
3293
|
var import_util5 = require("@dxos/util");
|
|
3061
|
-
var
|
|
3294
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
3062
3295
|
var SpacesServiceImpl = class {
|
|
3063
3296
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
3064
3297
|
this._identityManager = _identityManager;
|
|
@@ -3075,15 +3308,14 @@ var SpacesServiceImpl = class {
|
|
|
3075
3308
|
return this._serializeSpace(space);
|
|
3076
3309
|
}
|
|
3077
3310
|
async updateSpace({ spaceKey, state }) {
|
|
3078
|
-
var _a;
|
|
3079
3311
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3080
|
-
const space =
|
|
3312
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3081
3313
|
if (state) {
|
|
3082
3314
|
switch (state) {
|
|
3083
|
-
case
|
|
3315
|
+
case import_services9.SpaceState.ACTIVE:
|
|
3084
3316
|
await space.activate();
|
|
3085
3317
|
break;
|
|
3086
|
-
case
|
|
3318
|
+
case import_services9.SpaceState.INACTIVE:
|
|
3087
3319
|
await space.deactivate();
|
|
3088
3320
|
break;
|
|
3089
3321
|
default:
|
|
@@ -3092,14 +3324,14 @@ var SpacesServiceImpl = class {
|
|
|
3092
3324
|
}
|
|
3093
3325
|
}
|
|
3094
3326
|
querySpaces() {
|
|
3095
|
-
return new
|
|
3327
|
+
return new import_codec_protobuf5.Stream(({ next, ctx }) => {
|
|
3096
3328
|
const scheduler = new import_async10.UpdateScheduler(ctx, async () => {
|
|
3097
3329
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3098
3330
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
3099
|
-
(0,
|
|
3331
|
+
(0, import_log12.log)("update", {
|
|
3100
3332
|
spaces
|
|
3101
3333
|
}, {
|
|
3102
|
-
F:
|
|
3334
|
+
F: __dxlog_file14,
|
|
3103
3335
|
L: 78,
|
|
3104
3336
|
S: this,
|
|
3105
3337
|
C: (f, a) => f(...a)
|
|
@@ -3141,17 +3373,15 @@ var SpacesServiceImpl = class {
|
|
|
3141
3373
|
});
|
|
3142
3374
|
}
|
|
3143
3375
|
async postMessage({ spaceKey, channel, message }) {
|
|
3144
|
-
var _a;
|
|
3145
3376
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3146
|
-
const space =
|
|
3377
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3147
3378
|
await space.postMessage(getChannelId(channel), message);
|
|
3148
3379
|
}
|
|
3149
3380
|
subscribeMessages({ spaceKey, channel }) {
|
|
3150
|
-
return new
|
|
3381
|
+
return new import_codec_protobuf5.Stream(({ ctx, next }) => {
|
|
3151
3382
|
(0, import_async10.scheduleTask)(ctx, async () => {
|
|
3152
|
-
var _a;
|
|
3153
3383
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3154
|
-
const space =
|
|
3384
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3155
3385
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3156
3386
|
next(message);
|
|
3157
3387
|
});
|
|
@@ -3160,9 +3390,8 @@ var SpacesServiceImpl = class {
|
|
|
3160
3390
|
});
|
|
3161
3391
|
}
|
|
3162
3392
|
queryCredentials({ spaceKey }) {
|
|
3163
|
-
return new
|
|
3164
|
-
|
|
3165
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3393
|
+
return new import_codec_protobuf5.Stream(({ ctx, next }) => {
|
|
3394
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3166
3395
|
const processor = {
|
|
3167
3396
|
processCredential: async (credential) => {
|
|
3168
3397
|
next(credential);
|
|
@@ -3173,9 +3402,8 @@ var SpacesServiceImpl = class {
|
|
|
3173
3402
|
});
|
|
3174
3403
|
}
|
|
3175
3404
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
for (const credential of credentials != null ? credentials : []) {
|
|
3405
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3406
|
+
for (const credential of credentials ?? []) {
|
|
3179
3407
|
await space.controlPipeline.writer.write({
|
|
3180
3408
|
credential: {
|
|
3181
3409
|
credential
|
|
@@ -3184,17 +3412,15 @@ var SpacesServiceImpl = class {
|
|
|
3184
3412
|
}
|
|
3185
3413
|
}
|
|
3186
3414
|
async createEpoch({ spaceKey }) {
|
|
3187
|
-
var _a;
|
|
3188
3415
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3189
|
-
const space =
|
|
3416
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3190
3417
|
await space.createEpoch();
|
|
3191
3418
|
}
|
|
3192
3419
|
_serializeSpace(space) {
|
|
3193
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3194
3420
|
return {
|
|
3195
3421
|
spaceKey: space.key,
|
|
3196
3422
|
state: space.state,
|
|
3197
|
-
error: space.error ? (0,
|
|
3423
|
+
error: space.error ? (0, import_protocols8.encodeError)(space.error) : void 0,
|
|
3198
3424
|
pipeline: {
|
|
3199
3425
|
currentEpoch: space.dataPipeline.currentEpoch,
|
|
3200
3426
|
appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
@@ -3202,16 +3428,15 @@ var SpacesServiceImpl = class {
|
|
|
3202
3428
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3203
3429
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
3204
3430
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
3205
|
-
dataFeeds:
|
|
3206
|
-
startDataTimeframe:
|
|
3207
|
-
currentDataTimeframe:
|
|
3208
|
-
targetDataTimeframe:
|
|
3209
|
-
totalDataTimeframe:
|
|
3431
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
3432
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
3433
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
3434
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
3435
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
3210
3436
|
},
|
|
3211
3437
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3212
|
-
var _a2, _b2, _c2;
|
|
3213
3438
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3214
|
-
const isMe =
|
|
3439
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
3215
3440
|
if (isMe) {
|
|
3216
3441
|
peers.push(space.presence.getLocalState());
|
|
3217
3442
|
}
|
|
@@ -3219,14 +3444,14 @@ var SpacesServiceImpl = class {
|
|
|
3219
3444
|
identity: {
|
|
3220
3445
|
identityKey: member.key,
|
|
3221
3446
|
profile: {
|
|
3222
|
-
displayName:
|
|
3447
|
+
displayName: member.assertion.profile?.displayName ?? (0, import_util5.humanize)(member.key)
|
|
3223
3448
|
}
|
|
3224
3449
|
},
|
|
3225
|
-
presence: isMe || peers.length > 0 ?
|
|
3450
|
+
presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
3226
3451
|
peerStates: peers
|
|
3227
3452
|
};
|
|
3228
3453
|
}),
|
|
3229
|
-
creator:
|
|
3454
|
+
creator: space.inner.spaceState.creator?.key,
|
|
3230
3455
|
cache: space.cache,
|
|
3231
3456
|
metrics: space.metrics
|
|
3232
3457
|
};
|
|
@@ -3235,8 +3460,18 @@ var SpacesServiceImpl = class {
|
|
|
3235
3460
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3236
3461
|
|
|
3237
3462
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3238
|
-
|
|
3239
|
-
var
|
|
3463
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
3464
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3465
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3466
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3467
|
+
else
|
|
3468
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3469
|
+
if (d = decorators[i])
|
|
3470
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3471
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3472
|
+
}
|
|
3473
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3474
|
+
var ServiceContext = class ServiceContext2 {
|
|
3240
3475
|
// prettier-ignore
|
|
3241
3476
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3242
3477
|
this.storage = storage;
|
|
@@ -3270,84 +3505,80 @@ var ServiceContext = class {
|
|
|
3270
3505
|
});
|
|
3271
3506
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3272
3507
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3273
|
-
this._handlerFactories.set(
|
|
3274
|
-
var _a;
|
|
3275
|
-
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
3276
|
-
}, this._acceptIdentity.bind(this)));
|
|
3508
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
3277
3509
|
}
|
|
3278
|
-
async open() {
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
L: 125,
|
|
3510
|
+
async open(ctx) {
|
|
3511
|
+
await this._checkStorageVersion();
|
|
3512
|
+
(0, import_log13.log)("opening...", void 0, {
|
|
3513
|
+
F: __dxlog_file15,
|
|
3514
|
+
L: 134,
|
|
3284
3515
|
S: this,
|
|
3285
3516
|
C: (f, a) => f(...a)
|
|
3286
3517
|
});
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3518
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.begin({
|
|
3519
|
+
id: this._instanceId
|
|
3520
|
+
}), {
|
|
3521
|
+
F: __dxlog_file15,
|
|
3522
|
+
L: 135,
|
|
3291
3523
|
S: this,
|
|
3292
3524
|
C: (f, a) => f(...a)
|
|
3293
3525
|
});
|
|
3294
3526
|
await this.signalManager.open();
|
|
3295
3527
|
await this.networkManager.open();
|
|
3296
3528
|
await this.spaceManager.open();
|
|
3297
|
-
await this.identityManager.open();
|
|
3529
|
+
await this.identityManager.open(ctx);
|
|
3298
3530
|
if (this.identityManager.identity) {
|
|
3299
|
-
await this._initialize();
|
|
3531
|
+
await this._initialize(ctx);
|
|
3300
3532
|
}
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3533
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
|
|
3534
|
+
id: this._instanceId
|
|
3535
|
+
}), {
|
|
3536
|
+
F: __dxlog_file15,
|
|
3537
|
+
L: 143,
|
|
3304
3538
|
S: this,
|
|
3305
3539
|
C: (f, a) => f(...a)
|
|
3306
3540
|
});
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
F: __dxlog_file14,
|
|
3311
|
-
L: 138,
|
|
3541
|
+
(0, import_log13.log)("opened", void 0, {
|
|
3542
|
+
F: __dxlog_file15,
|
|
3543
|
+
L: 144,
|
|
3312
3544
|
S: this,
|
|
3313
3545
|
C: (f, a) => f(...a)
|
|
3314
3546
|
});
|
|
3315
3547
|
}
|
|
3316
3548
|
async close() {
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
L: 142,
|
|
3549
|
+
(0, import_log13.log)("closing...", void 0, {
|
|
3550
|
+
F: __dxlog_file15,
|
|
3551
|
+
L: 148,
|
|
3321
3552
|
S: this,
|
|
3322
3553
|
C: (f, a) => f(...a)
|
|
3323
3554
|
});
|
|
3324
3555
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3325
3556
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3326
3557
|
}
|
|
3327
|
-
await
|
|
3558
|
+
await this.dataSpaceManager?.close();
|
|
3328
3559
|
await this.identityManager.close();
|
|
3329
3560
|
await this.spaceManager.close();
|
|
3330
3561
|
await this.feedStore.close();
|
|
3331
3562
|
await this.networkManager.close();
|
|
3332
3563
|
await this.signalManager.close();
|
|
3333
3564
|
this.dataServiceSubscriptions.clear();
|
|
3334
|
-
(0,
|
|
3335
|
-
F:
|
|
3336
|
-
L:
|
|
3565
|
+
(0, import_log13.log)("closed", void 0, {
|
|
3566
|
+
F: __dxlog_file15,
|
|
3567
|
+
L: 159,
|
|
3337
3568
|
S: this,
|
|
3338
3569
|
C: (f, a) => f(...a)
|
|
3339
3570
|
});
|
|
3340
3571
|
}
|
|
3341
3572
|
async createIdentity(params = {}) {
|
|
3342
3573
|
const identity = await this.identityManager.createIdentity(params);
|
|
3343
|
-
await this._initialize();
|
|
3574
|
+
await this._initialize(new import_context8.Context());
|
|
3344
3575
|
return identity;
|
|
3345
3576
|
}
|
|
3346
3577
|
getInvitationHandler(invitation) {
|
|
3347
3578
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3348
|
-
(0,
|
|
3349
|
-
F:
|
|
3350
|
-
L:
|
|
3579
|
+
(0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3580
|
+
F: __dxlog_file15,
|
|
3581
|
+
L: 171,
|
|
3351
3582
|
S: this,
|
|
3352
3583
|
A: [
|
|
3353
3584
|
"factory",
|
|
@@ -3358,25 +3589,24 @@ var ServiceContext = class {
|
|
|
3358
3589
|
}
|
|
3359
3590
|
async _acceptIdentity(params) {
|
|
3360
3591
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
3361
|
-
await this._initialize();
|
|
3592
|
+
await this._initialize(new import_context8.Context());
|
|
3362
3593
|
return identity;
|
|
3363
3594
|
}
|
|
3364
3595
|
async _checkStorageVersion() {
|
|
3365
3596
|
await this.metadataStore.load();
|
|
3366
|
-
if (this.metadataStore.version !==
|
|
3367
|
-
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${
|
|
3597
|
+
if (this.metadataStore.version !== import_protocols9.STORAGE_VERSION) {
|
|
3598
|
+
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols9.STORAGE_VERSION}`);
|
|
3368
3599
|
}
|
|
3369
3600
|
}
|
|
3370
3601
|
// Called when identity is created.
|
|
3371
|
-
async _initialize() {
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
L: 186,
|
|
3602
|
+
async _initialize(ctx) {
|
|
3603
|
+
(0, import_log13.log)("initializing spaces...", void 0, {
|
|
3604
|
+
F: __dxlog_file15,
|
|
3605
|
+
L: 193,
|
|
3376
3606
|
S: this,
|
|
3377
3607
|
C: (f, a) => f(...a)
|
|
3378
3608
|
});
|
|
3379
|
-
const identity =
|
|
3609
|
+
const identity = this.identityManager.identity ?? (0, import_debug7.failUndefined)();
|
|
3380
3610
|
const signingContext = {
|
|
3381
3611
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3382
3612
|
identityKey: identity.identityKey,
|
|
@@ -3392,10 +3622,10 @@ var ServiceContext = class {
|
|
|
3392
3622
|
};
|
|
3393
3623
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3394
3624
|
await this.dataSpaceManager.open();
|
|
3395
|
-
this._handlerFactories.set(
|
|
3396
|
-
(0,
|
|
3397
|
-
F:
|
|
3398
|
-
L:
|
|
3625
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
3626
|
+
(0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
3627
|
+
F: __dxlog_file15,
|
|
3628
|
+
L: 216,
|
|
3399
3629
|
S: this,
|
|
3400
3630
|
A: [
|
|
3401
3631
|
"this.dataSpaceManager",
|
|
@@ -3407,7 +3637,7 @@ var ServiceContext = class {
|
|
|
3407
3637
|
this.initialized.wake();
|
|
3408
3638
|
this._deviceSpaceSync = {
|
|
3409
3639
|
processCredential: async (credential) => {
|
|
3410
|
-
const assertion = (0,
|
|
3640
|
+
const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
|
|
3411
3641
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3412
3642
|
return;
|
|
3413
3643
|
}
|
|
@@ -3415,33 +3645,33 @@ var ServiceContext = class {
|
|
|
3415
3645
|
return;
|
|
3416
3646
|
}
|
|
3417
3647
|
if (!this.dataSpaceManager) {
|
|
3418
|
-
(0,
|
|
3648
|
+
(0, import_log13.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3419
3649
|
details: assertion
|
|
3420
3650
|
}, {
|
|
3421
|
-
F:
|
|
3422
|
-
L:
|
|
3651
|
+
F: __dxlog_file15,
|
|
3652
|
+
L: 232,
|
|
3423
3653
|
S: this,
|
|
3424
3654
|
C: (f, a) => f(...a)
|
|
3425
3655
|
});
|
|
3426
3656
|
return;
|
|
3427
3657
|
}
|
|
3428
3658
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3429
|
-
(0,
|
|
3659
|
+
(0, import_log13.log)("space already exists, ignoring space admission", {
|
|
3430
3660
|
details: assertion
|
|
3431
3661
|
}, {
|
|
3432
|
-
F:
|
|
3433
|
-
L:
|
|
3662
|
+
F: __dxlog_file15,
|
|
3663
|
+
L: 236,
|
|
3434
3664
|
S: this,
|
|
3435
3665
|
C: (f, a) => f(...a)
|
|
3436
3666
|
});
|
|
3437
3667
|
return;
|
|
3438
3668
|
}
|
|
3439
3669
|
try {
|
|
3440
|
-
(0,
|
|
3670
|
+
(0, import_log13.log)("accepting space recorded in halo", {
|
|
3441
3671
|
details: assertion
|
|
3442
3672
|
}, {
|
|
3443
|
-
F:
|
|
3444
|
-
L:
|
|
3673
|
+
F: __dxlog_file15,
|
|
3674
|
+
L: 241,
|
|
3445
3675
|
S: this,
|
|
3446
3676
|
C: (f, a) => f(...a)
|
|
3447
3677
|
});
|
|
@@ -3450,9 +3680,9 @@ var ServiceContext = class {
|
|
|
3450
3680
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3451
3681
|
});
|
|
3452
3682
|
} catch (err) {
|
|
3453
|
-
|
|
3454
|
-
F:
|
|
3455
|
-
L:
|
|
3683
|
+
import_log13.log.catch(err, void 0, {
|
|
3684
|
+
F: __dxlog_file15,
|
|
3685
|
+
L: 247,
|
|
3456
3686
|
S: this,
|
|
3457
3687
|
C: (f, a) => f(...a)
|
|
3458
3688
|
});
|
|
@@ -3462,26 +3692,38 @@ var ServiceContext = class {
|
|
|
3462
3692
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3463
3693
|
}
|
|
3464
3694
|
};
|
|
3695
|
+
_ts_decorate5([
|
|
3696
|
+
import_tracing3.trace.span()
|
|
3697
|
+
], ServiceContext.prototype, "open", null);
|
|
3698
|
+
_ts_decorate5([
|
|
3699
|
+
import_tracing3.trace.span()
|
|
3700
|
+
], ServiceContext.prototype, "_initialize", null);
|
|
3701
|
+
ServiceContext = _ts_decorate5([
|
|
3702
|
+
(0, import_util6.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
3703
|
+
import_tracing3.trace.resource()
|
|
3704
|
+
], ServiceContext);
|
|
3465
3705
|
|
|
3466
3706
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3467
3707
|
var import_async17 = require("@dxos/async");
|
|
3468
3708
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3469
|
-
var
|
|
3709
|
+
var import_context10 = require("@dxos/context");
|
|
3710
|
+
var import_document_model2 = require("@dxos/document-model");
|
|
3470
3711
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3471
|
-
var
|
|
3712
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
3472
3713
|
var import_keys12 = require("@dxos/keys");
|
|
3473
|
-
var
|
|
3714
|
+
var import_log16 = require("@dxos/log");
|
|
3474
3715
|
var import_messaging = require("@dxos/messaging");
|
|
3475
3716
|
var import_model_factory = require("@dxos/model-factory");
|
|
3476
3717
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3477
|
-
var
|
|
3478
|
-
var
|
|
3718
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
3719
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3479
3720
|
var import_text_model = require("@dxos/text-model");
|
|
3721
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
3480
3722
|
|
|
3481
3723
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3482
3724
|
var import_async12 = require("@dxos/async");
|
|
3483
|
-
var
|
|
3484
|
-
var
|
|
3725
|
+
var import_codec_protobuf6 = require("@dxos/codec-protobuf");
|
|
3726
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3485
3727
|
var DevicesServiceImpl = class {
|
|
3486
3728
|
constructor(_identityManager) {
|
|
3487
3729
|
this._identityManager = _identityManager;
|
|
@@ -3490,23 +3732,19 @@ var DevicesServiceImpl = class {
|
|
|
3490
3732
|
throw new Error("Method not implemented.");
|
|
3491
3733
|
}
|
|
3492
3734
|
queryDevices() {
|
|
3493
|
-
return new
|
|
3735
|
+
return new import_codec_protobuf6.Stream(({ next }) => {
|
|
3494
3736
|
const update = () => {
|
|
3495
|
-
|
|
3496
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
3737
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
3497
3738
|
if (!deviceKeys) {
|
|
3498
3739
|
next({
|
|
3499
3740
|
devices: []
|
|
3500
3741
|
});
|
|
3501
3742
|
} else {
|
|
3502
3743
|
next({
|
|
3503
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services10.DeviceKind.CURRENT : import_services10.DeviceKind.TRUSTED
|
|
3508
|
-
};
|
|
3509
|
-
})
|
|
3744
|
+
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
3745
|
+
deviceKey: key,
|
|
3746
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
3747
|
+
}))
|
|
3510
3748
|
});
|
|
3511
3749
|
}
|
|
3512
3750
|
};
|
|
@@ -3527,21 +3765,21 @@ var DevicesServiceImpl = class {
|
|
|
3527
3765
|
|
|
3528
3766
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
3529
3767
|
var import_async15 = require("@dxos/async");
|
|
3530
|
-
var
|
|
3768
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
3531
3769
|
|
|
3532
3770
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
3533
3771
|
var import_async13 = require("@dxos/async");
|
|
3534
|
-
var
|
|
3772
|
+
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
3535
3773
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3536
3774
|
var import_keys9 = require("@dxos/keys");
|
|
3537
|
-
var
|
|
3775
|
+
var import_util7 = require("@dxos/util");
|
|
3538
3776
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
3539
|
-
return new
|
|
3777
|
+
return new import_codec_protobuf7.Stream(({ next }) => {
|
|
3540
3778
|
const subscriptions = new import_async13.EventSubscriptions();
|
|
3541
|
-
const feedMap = new
|
|
3779
|
+
const feedMap = new import_util7.ComplexMap(import_keys9.PublicKey.hash);
|
|
3542
3780
|
const update = () => {
|
|
3543
3781
|
const { feeds } = feedStore;
|
|
3544
|
-
feeds.filter((feed) => !
|
|
3782
|
+
feeds.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
3545
3783
|
if (!feedMap.has(feed.key)) {
|
|
3546
3784
|
feedMap.set(feed.key, feed);
|
|
3547
3785
|
feed.on("close", update);
|
|
@@ -3549,15 +3787,12 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
3549
3787
|
}
|
|
3550
3788
|
});
|
|
3551
3789
|
next({
|
|
3552
|
-
feeds: Array.from(feedMap.values()).map((feed) => {
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
|
|
3559
|
-
};
|
|
3560
|
-
})
|
|
3790
|
+
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
3791
|
+
feedKey: feed.key,
|
|
3792
|
+
length: feed.properties.length,
|
|
3793
|
+
bytes: feed.core.byteLength,
|
|
3794
|
+
downloaded: feed.core.bitfield?.data.toBuffer() ?? new Uint8Array()
|
|
3795
|
+
}))
|
|
3561
3796
|
});
|
|
3562
3797
|
};
|
|
3563
3798
|
subscriptions.add(feedStore.feedOpened.on(update));
|
|
@@ -3568,7 +3803,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
3568
3803
|
});
|
|
3569
3804
|
};
|
|
3570
3805
|
var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
3571
|
-
return new
|
|
3806
|
+
return new import_codec_protobuf7.Stream(({ next }) => {
|
|
3572
3807
|
if (!feedKey) {
|
|
3573
3808
|
return;
|
|
3574
3809
|
}
|
|
@@ -3608,8 +3843,8 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
|
3608
3843
|
|
|
3609
3844
|
// packages/sdk/client-services/src/packlets/devtools/keys.ts
|
|
3610
3845
|
var import_async14 = require("@dxos/async");
|
|
3611
|
-
var
|
|
3612
|
-
var subscribeToKeyringKeys = ({ keyring }) => new
|
|
3846
|
+
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
3847
|
+
var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
3613
3848
|
const update = async () => {
|
|
3614
3849
|
next({
|
|
3615
3850
|
keys: await keyring.list()
|
|
@@ -3620,8 +3855,8 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf7.Stream(
|
|
|
3620
3855
|
});
|
|
3621
3856
|
|
|
3622
3857
|
// packages/sdk/client-services/src/packlets/devtools/metadata.ts
|
|
3623
|
-
var
|
|
3624
|
-
var subscribeToMetadata = ({ context }) => new
|
|
3858
|
+
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
3859
|
+
var subscribeToMetadata = ({ context }) => new import_codec_protobuf9.Stream(({ next, ctx }) => {
|
|
3625
3860
|
context.metadataStore.update.on(ctx, (data) => next({
|
|
3626
3861
|
metadata: data
|
|
3627
3862
|
}));
|
|
@@ -3631,10 +3866,10 @@ var subscribeToMetadata = ({ context }) => new import_codec_protobuf8.Stream(({
|
|
|
3631
3866
|
});
|
|
3632
3867
|
|
|
3633
3868
|
// packages/sdk/client-services/src/packlets/devtools/network.ts
|
|
3634
|
-
var
|
|
3635
|
-
var
|
|
3869
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
3870
|
+
var import_context9 = require("@dxos/context");
|
|
3636
3871
|
var import_keys10 = require("@dxos/keys");
|
|
3637
|
-
var subscribeToNetworkStatus = ({ signalManager }) => new
|
|
3872
|
+
var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next, close }) => {
|
|
3638
3873
|
const update = () => {
|
|
3639
3874
|
try {
|
|
3640
3875
|
const status = signalManager.getStatus();
|
|
@@ -3648,8 +3883,8 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf9
|
|
|
3648
3883
|
signalManager.statusChanged.on(() => update());
|
|
3649
3884
|
update();
|
|
3650
3885
|
});
|
|
3651
|
-
var subscribeToSignal = ({ signalManager }) => new
|
|
3652
|
-
const ctx = new
|
|
3886
|
+
var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next }) => {
|
|
3887
|
+
const ctx = new import_context9.Context();
|
|
3653
3888
|
signalManager.onMessage.on(ctx, (message) => {
|
|
3654
3889
|
next({
|
|
3655
3890
|
message: {
|
|
@@ -3657,51 +3892,49 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf9.Stream
|
|
|
3657
3892
|
recipient: message.recipient.asUint8Array(),
|
|
3658
3893
|
payload: message.payload
|
|
3659
3894
|
},
|
|
3660
|
-
receivedAt: new Date()
|
|
3895
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
3661
3896
|
});
|
|
3662
3897
|
});
|
|
3663
3898
|
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
3664
3899
|
next({
|
|
3665
3900
|
swarmEvent: swarmEvent.swarmEvent,
|
|
3666
|
-
receivedAt: new Date()
|
|
3901
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
3667
3902
|
});
|
|
3668
3903
|
});
|
|
3669
3904
|
return () => {
|
|
3670
3905
|
return ctx.dispose();
|
|
3671
3906
|
};
|
|
3672
3907
|
});
|
|
3673
|
-
var subscribeToSwarmInfo = ({ networkManager }) => new
|
|
3674
|
-
var _a;
|
|
3908
|
+
var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf10.Stream(({ next }) => {
|
|
3675
3909
|
const update = () => {
|
|
3676
|
-
|
|
3677
|
-
const info = (_a2 = networkManager.connectionLog) == null ? void 0 : _a2.swarms;
|
|
3910
|
+
const info = networkManager.connectionLog?.swarms;
|
|
3678
3911
|
if (info) {
|
|
3679
3912
|
next({
|
|
3680
3913
|
data: info
|
|
3681
3914
|
});
|
|
3682
3915
|
}
|
|
3683
3916
|
};
|
|
3684
|
-
|
|
3917
|
+
networkManager.connectionLog?.update.on(update);
|
|
3685
3918
|
update();
|
|
3686
3919
|
});
|
|
3687
3920
|
|
|
3688
3921
|
// packages/sdk/client-services/src/packlets/devtools/spaces.ts
|
|
3689
|
-
var
|
|
3922
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
3690
3923
|
var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
3691
|
-
return new
|
|
3924
|
+
return new import_codec_protobuf11.Stream(({ next }) => {
|
|
3692
3925
|
let unsubscribe;
|
|
3693
3926
|
const update = async () => {
|
|
3694
3927
|
const spaces = [
|
|
3695
3928
|
...context.spaceManager.spaces.values()
|
|
3696
3929
|
];
|
|
3697
|
-
const filteredSpaces = spaces.filter((space) => !
|
|
3930
|
+
const filteredSpaces = spaces.filter((space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
|
|
3698
3931
|
next({
|
|
3699
3932
|
spaces: filteredSpaces.map((space) => {
|
|
3700
3933
|
const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
|
|
3701
3934
|
return {
|
|
3702
3935
|
key: space.key,
|
|
3703
3936
|
isOpen: space.isOpen,
|
|
3704
|
-
timeframe: spaceMetadata
|
|
3937
|
+
timeframe: spaceMetadata?.dataTimeframe,
|
|
3705
3938
|
genesisFeed: space.genesisFeedKey,
|
|
3706
3939
|
controlFeed: space.controlFeedKey,
|
|
3707
3940
|
dataFeed: space.dataFeedKey
|
|
@@ -3715,7 +3948,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
3715
3948
|
await update();
|
|
3716
3949
|
});
|
|
3717
3950
|
return () => {
|
|
3718
|
-
unsubscribe
|
|
3951
|
+
unsubscribe?.();
|
|
3719
3952
|
clearTimeout(timeout);
|
|
3720
3953
|
};
|
|
3721
3954
|
});
|
|
@@ -3732,7 +3965,7 @@ var DevtoolsServiceImpl = class {
|
|
|
3732
3965
|
this.params = params;
|
|
3733
3966
|
}
|
|
3734
3967
|
events(request) {
|
|
3735
|
-
return new
|
|
3968
|
+
return new import_codec_protobuf12.Stream(({ next }) => {
|
|
3736
3969
|
this.params.events.ready.on(() => {
|
|
3737
3970
|
next({
|
|
3738
3971
|
ready: {}
|
|
@@ -3746,16 +3979,15 @@ var DevtoolsServiceImpl = class {
|
|
|
3746
3979
|
};
|
|
3747
3980
|
}
|
|
3748
3981
|
async getStorageInfo() {
|
|
3749
|
-
|
|
3750
|
-
const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
|
|
3982
|
+
const storageUsage = await this.params.context.storage.getDiskInfo?.() ?? {
|
|
3751
3983
|
used: 0
|
|
3752
3984
|
};
|
|
3753
3985
|
const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
|
|
3754
3986
|
return {
|
|
3755
3987
|
type: this.params.context.storage.type,
|
|
3756
3988
|
storageUsage: storageUsage.used,
|
|
3757
|
-
originUsage:
|
|
3758
|
-
usageQuota:
|
|
3989
|
+
originUsage: navigatorInfo?.usage ?? 0,
|
|
3990
|
+
usageQuota: navigatorInfo?.quota ?? 0
|
|
3759
3991
|
};
|
|
3760
3992
|
}
|
|
3761
3993
|
async getBlobs() {
|
|
@@ -3839,10 +4071,10 @@ var DevtoolsServiceImpl = class {
|
|
|
3839
4071
|
};
|
|
3840
4072
|
|
|
3841
4073
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3842
|
-
var
|
|
4074
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
3843
4075
|
var import_lock_file = require("@dxos/lock-file");
|
|
3844
|
-
var
|
|
3845
|
-
function
|
|
4076
|
+
var import_log14 = require("@dxos/log");
|
|
4077
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
3846
4078
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3847
4079
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3848
4080
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3852,7 +4084,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
3852
4084
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3853
4085
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3854
4086
|
}
|
|
3855
|
-
var
|
|
4087
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3856
4088
|
var Lock = class {
|
|
3857
4089
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3858
4090
|
this._lockPath = lockPath;
|
|
@@ -3863,27 +4095,25 @@ var Lock = class {
|
|
|
3863
4095
|
return this._lockPath;
|
|
3864
4096
|
}
|
|
3865
4097
|
async acquire() {
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
F: __dxlog_file15,
|
|
4098
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4099
|
+
F: __dxlog_file16,
|
|
3869
4100
|
L: 32,
|
|
3870
4101
|
S: this,
|
|
3871
4102
|
C: (f, a) => f(...a)
|
|
3872
4103
|
});
|
|
3873
4104
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3874
|
-
await
|
|
3875
|
-
(0,
|
|
3876
|
-
F:
|
|
4105
|
+
await this._onAcquire?.();
|
|
4106
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
4107
|
+
F: __dxlog_file16,
|
|
3877
4108
|
L: 37,
|
|
3878
4109
|
S: this,
|
|
3879
4110
|
C: (f, a) => f(...a)
|
|
3880
4111
|
});
|
|
3881
4112
|
}
|
|
3882
4113
|
async release() {
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
F: __dxlog_file15,
|
|
4114
|
+
await this._onRelease?.();
|
|
4115
|
+
(0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4116
|
+
F: __dxlog_file16,
|
|
3887
4117
|
L: 42,
|
|
3888
4118
|
S: this,
|
|
3889
4119
|
A: [
|
|
@@ -3894,78 +4124,83 @@ var Lock = class {
|
|
|
3894
4124
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3895
4125
|
}
|
|
3896
4126
|
};
|
|
3897
|
-
|
|
3898
|
-
|
|
4127
|
+
_ts_decorate6([
|
|
4128
|
+
import_log14.logInfo
|
|
3899
4129
|
], Lock.prototype, "lockKey", null);
|
|
3900
4130
|
|
|
3901
4131
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3902
4132
|
var import_async16 = require("@dxos/async");
|
|
3903
|
-
var
|
|
3904
|
-
var
|
|
3905
|
-
var
|
|
3906
|
-
var
|
|
4133
|
+
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
4134
|
+
var import_log15 = require("@dxos/log");
|
|
4135
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4136
|
+
var import_util8 = require("@dxos/util");
|
|
3907
4137
|
var LoggingServiceImpl = class {
|
|
3908
4138
|
constructor() {
|
|
3909
4139
|
this._logs = new import_async16.Event();
|
|
4140
|
+
this._started = /* @__PURE__ */ new Date();
|
|
3910
4141
|
this._logProcessor = (_config, entry2) => {
|
|
3911
4142
|
this._logs.emit(entry2);
|
|
3912
4143
|
};
|
|
3913
4144
|
}
|
|
3914
4145
|
async open() {
|
|
3915
|
-
|
|
4146
|
+
import_log15.log.runtimeConfig.processors.push(this._logProcessor);
|
|
3916
4147
|
}
|
|
3917
4148
|
async close() {
|
|
3918
|
-
const index =
|
|
3919
|
-
|
|
4149
|
+
const index = import_log15.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
4150
|
+
import_log15.log.runtimeConfig.processors.splice(index, 1);
|
|
3920
4151
|
}
|
|
3921
4152
|
async controlMetrics({ reset, record }) {
|
|
3922
4153
|
if (reset) {
|
|
3923
|
-
|
|
4154
|
+
import_util8.tracer.clear();
|
|
3924
4155
|
}
|
|
3925
4156
|
if (record === true) {
|
|
3926
|
-
|
|
4157
|
+
import_util8.tracer.start();
|
|
3927
4158
|
} else if (record === false) {
|
|
3928
|
-
|
|
4159
|
+
import_util8.tracer.stop();
|
|
3929
4160
|
}
|
|
3930
4161
|
return {
|
|
3931
|
-
recording:
|
|
4162
|
+
recording: import_util8.tracer.recording
|
|
3932
4163
|
};
|
|
3933
4164
|
}
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
4165
|
+
/**
|
|
4166
|
+
* @deprecated (Move to diagnostics).
|
|
4167
|
+
*/
|
|
4168
|
+
queryMetrics({ interval = 5e3 }) {
|
|
4169
|
+
const getNumericalValues = (key) => {
|
|
4170
|
+
const events = import_util8.tracer.get(key) ?? [];
|
|
3938
4171
|
return {
|
|
3939
4172
|
key,
|
|
3940
|
-
stats: (0,
|
|
4173
|
+
stats: (0, import_util8.numericalValues)(events, "duration")
|
|
3941
4174
|
};
|
|
3942
4175
|
};
|
|
3943
|
-
return new
|
|
4176
|
+
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
3944
4177
|
const update = () => {
|
|
3945
4178
|
const metrics = {
|
|
3946
|
-
timestamp: new Date(),
|
|
4179
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
3947
4180
|
values: [
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
]
|
|
4181
|
+
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4182
|
+
getNumericalValues("dxos.echo.pipeline.data")
|
|
4183
|
+
].filter(Boolean)
|
|
3951
4184
|
};
|
|
3952
|
-
next(
|
|
4185
|
+
next({
|
|
4186
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4187
|
+
metrics
|
|
4188
|
+
});
|
|
3953
4189
|
};
|
|
3954
4190
|
update();
|
|
3955
|
-
const i = setInterval(update, interval);
|
|
4191
|
+
const i = setInterval(update, Math.max(interval, 1e3));
|
|
3956
4192
|
return () => {
|
|
3957
4193
|
clearInterval(i);
|
|
3958
4194
|
};
|
|
3959
4195
|
});
|
|
3960
4196
|
}
|
|
3961
4197
|
queryLogs(request) {
|
|
3962
|
-
return new
|
|
4198
|
+
return new import_codec_protobuf13.Stream(({ ctx, next }) => {
|
|
3963
4199
|
const handler = (entry2) => {
|
|
3964
|
-
var _a, _b, _c, _d, _e;
|
|
3965
4200
|
if (LOG_PROCESSING > 0) {
|
|
3966
4201
|
return;
|
|
3967
4202
|
}
|
|
3968
|
-
if (
|
|
4203
|
+
if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
3969
4204
|
return;
|
|
3970
4205
|
}
|
|
3971
4206
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3973,12 +4208,12 @@ var LoggingServiceImpl = class {
|
|
|
3973
4208
|
}
|
|
3974
4209
|
const record = {
|
|
3975
4210
|
...entry2,
|
|
3976
|
-
context: (0,
|
|
3977
|
-
timestamp: new Date(),
|
|
4211
|
+
context: (0, import_util8.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
|
|
4212
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
3978
4213
|
meta: {
|
|
3979
4214
|
// TODO(dmaretskyi): Fix proto.
|
|
3980
|
-
file:
|
|
3981
|
-
line:
|
|
4215
|
+
file: entry2.meta?.F ?? "",
|
|
4216
|
+
line: entry2.meta?.L ?? 0
|
|
3982
4217
|
}
|
|
3983
4218
|
};
|
|
3984
4219
|
try {
|
|
@@ -3994,35 +4229,31 @@ var LoggingServiceImpl = class {
|
|
|
3994
4229
|
};
|
|
3995
4230
|
var matchFilter = (filter, level, path, options) => {
|
|
3996
4231
|
switch (options) {
|
|
3997
|
-
case
|
|
4232
|
+
case import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
3998
4233
|
return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3999
|
-
case
|
|
4234
|
+
case import_services12.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
4000
4235
|
return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
4001
4236
|
}
|
|
4002
4237
|
};
|
|
4003
4238
|
var shouldLog = (entry2, request) => {
|
|
4004
|
-
|
|
4005
|
-
const options = (_a = request.options) != null ? _a : import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4239
|
+
const options = request.options ?? import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4006
4240
|
if (request.filters === void 0) {
|
|
4007
|
-
return options ===
|
|
4241
|
+
return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4008
4242
|
} else {
|
|
4009
|
-
return request.filters.some((filter) =>
|
|
4010
|
-
var _a2, _b;
|
|
4011
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
4012
|
-
});
|
|
4243
|
+
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
4013
4244
|
}
|
|
4014
4245
|
};
|
|
4015
4246
|
var LOG_PROCESSING = 0;
|
|
4016
4247
|
|
|
4017
4248
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
4018
|
-
var
|
|
4249
|
+
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
4019
4250
|
var NetworkServiceImpl = class {
|
|
4020
4251
|
constructor(networkManager, signalManager) {
|
|
4021
4252
|
this.networkManager = networkManager;
|
|
4022
4253
|
this.signalManager = signalManager;
|
|
4023
4254
|
}
|
|
4024
4255
|
queryStatus() {
|
|
4025
|
-
return new
|
|
4256
|
+
return new import_codec_protobuf14.Stream(({ next }) => {
|
|
4026
4257
|
const update = () => {
|
|
4027
4258
|
next({
|
|
4028
4259
|
swarm: this.networkManager.connectionState,
|
|
@@ -4051,10 +4282,10 @@ var import_client_protocol4 = require("@dxos/client-protocol");
|
|
|
4051
4282
|
var import_errors5 = require("@dxos/errors");
|
|
4052
4283
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
4053
4284
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
4054
|
-
var
|
|
4285
|
+
var import_util9 = require("@dxos/util");
|
|
4055
4286
|
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4056
4287
|
var createStorageObjects = (config) => {
|
|
4057
|
-
const { path = (0,
|
|
4288
|
+
const { path = (0, import_util9.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
|
|
4058
4289
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
4059
4290
|
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4060
4291
|
}
|
|
@@ -4096,25 +4327,40 @@ var toStorageType = (type) => {
|
|
|
4096
4327
|
};
|
|
4097
4328
|
|
|
4098
4329
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
4099
|
-
var
|
|
4330
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
4331
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4332
|
+
var import_util10 = require("@dxos/util");
|
|
4100
4333
|
var SystemServiceImpl = class {
|
|
4101
|
-
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4334
|
+
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4102
4335
|
this._config = config;
|
|
4103
4336
|
this._statusUpdate = statusUpdate;
|
|
4104
4337
|
this._getCurrentStatus = getCurrentStatus;
|
|
4338
|
+
this._getDiagnostics = getDiagnostics;
|
|
4105
4339
|
this._onUpdateStatus = onUpdateStatus;
|
|
4106
4340
|
this._onReset = onReset;
|
|
4107
4341
|
}
|
|
4108
4342
|
async getConfig() {
|
|
4109
|
-
|
|
4110
|
-
|
|
4343
|
+
return this._config?.values ?? {};
|
|
4344
|
+
}
|
|
4345
|
+
/**
|
|
4346
|
+
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
4347
|
+
*/
|
|
4348
|
+
async getDiagnostics({ keys } = {}) {
|
|
4349
|
+
const diagnostics = await this._getDiagnostics();
|
|
4350
|
+
return {
|
|
4351
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4352
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
|
|
4353
|
+
truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4354
|
+
humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4355
|
+
})))
|
|
4356
|
+
};
|
|
4111
4357
|
}
|
|
4112
4358
|
async updateStatus({ status }) {
|
|
4113
4359
|
await this._onUpdateStatus(status);
|
|
4114
4360
|
}
|
|
4115
4361
|
// TODO(burdon): Standardize interval option in stream request?
|
|
4116
4362
|
queryStatus({ interval = 3e3 } = {}) {
|
|
4117
|
-
return new
|
|
4363
|
+
return new import_codec_protobuf15.Stream(({ next }) => {
|
|
4118
4364
|
const update = () => {
|
|
4119
4365
|
next({
|
|
4120
4366
|
status: this._getCurrentStatus()
|
|
@@ -4159,7 +4405,7 @@ var ServiceRegistry = class {
|
|
|
4159
4405
|
};
|
|
4160
4406
|
|
|
4161
4407
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4162
|
-
function
|
|
4408
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
4163
4409
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4164
4410
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4165
4411
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4169,23 +4415,22 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
4169
4415
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4170
4416
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4171
4417
|
}
|
|
4172
|
-
var
|
|
4418
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
4173
4419
|
var createDefaultModelFactory = () => {
|
|
4174
|
-
return new import_model_factory.ModelFactory().registerModel(
|
|
4420
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
|
|
4175
4421
|
};
|
|
4176
|
-
var ClientServicesHost = class {
|
|
4422
|
+
var ClientServicesHost = class ClientServicesHost2 {
|
|
4177
4423
|
constructor({
|
|
4178
4424
|
config,
|
|
4179
4425
|
modelFactory = createDefaultModelFactory(),
|
|
4180
|
-
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
4181
4426
|
transportFactory,
|
|
4182
4427
|
signalManager,
|
|
4183
|
-
connectionLog,
|
|
4184
4428
|
storage,
|
|
4185
4429
|
// TODO(wittjosiah): Turn this on by default.
|
|
4186
4430
|
lockKey,
|
|
4187
4431
|
callbacks
|
|
4188
4432
|
} = {}) {
|
|
4433
|
+
this._tracingService = import_tracing4.TRACE_PROCESSOR.createTraceSender();
|
|
4189
4434
|
this._statusUpdate = new import_async17.Event();
|
|
4190
4435
|
this._opening = false;
|
|
4191
4436
|
this._open = false;
|
|
@@ -4204,7 +4449,7 @@ var ClientServicesHost = class {
|
|
|
4204
4449
|
lockKey,
|
|
4205
4450
|
onAcquire: () => {
|
|
4206
4451
|
if (!this._opening) {
|
|
4207
|
-
void this.open();
|
|
4452
|
+
void this.open(new import_context10.Context());
|
|
4208
4453
|
}
|
|
4209
4454
|
},
|
|
4210
4455
|
onRelease: () => this.close()
|
|
@@ -4213,13 +4458,15 @@ var ClientServicesHost = class {
|
|
|
4213
4458
|
this._systemService = new SystemServiceImpl({
|
|
4214
4459
|
config: this._config,
|
|
4215
4460
|
statusUpdate: this._statusUpdate,
|
|
4216
|
-
getCurrentStatus: () => this.isOpen ?
|
|
4461
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
4462
|
+
getDiagnostics: () => {
|
|
4463
|
+
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4464
|
+
},
|
|
4217
4465
|
onUpdateStatus: async (status) => {
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
4466
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
4467
|
+
await this._resourceLock?.acquire();
|
|
4468
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
4469
|
+
await this._resourceLock?.release();
|
|
4223
4470
|
}
|
|
4224
4471
|
},
|
|
4225
4472
|
onReset: async () => {
|
|
@@ -4228,12 +4475,19 @@ var ClientServicesHost = class {
|
|
|
4228
4475
|
});
|
|
4229
4476
|
this._loggingService = new LoggingServiceImpl();
|
|
4230
4477
|
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
4231
|
-
SystemService: this._systemService
|
|
4478
|
+
SystemService: this._systemService,
|
|
4479
|
+
TracingService: this._tracingService
|
|
4232
4480
|
});
|
|
4233
4481
|
}
|
|
4234
4482
|
get isOpen() {
|
|
4235
4483
|
return this._open;
|
|
4236
4484
|
}
|
|
4485
|
+
get config() {
|
|
4486
|
+
return this._config;
|
|
4487
|
+
}
|
|
4488
|
+
get context() {
|
|
4489
|
+
return this._serviceContext;
|
|
4490
|
+
}
|
|
4237
4491
|
get serviceRegistry() {
|
|
4238
4492
|
return this._serviceRegistry;
|
|
4239
4493
|
}
|
|
@@ -4249,20 +4503,25 @@ var ClientServicesHost = class {
|
|
|
4249
4503
|
* Can only be called once.
|
|
4250
4504
|
*/
|
|
4251
4505
|
initialize({ config, ...options }) {
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
L: 167,
|
|
4506
|
+
(0, import_invariant14.invariant)(!this._open, "service host is open", {
|
|
4507
|
+
F: __dxlog_file17,
|
|
4508
|
+
L: 181,
|
|
4256
4509
|
S: this,
|
|
4257
4510
|
A: [
|
|
4258
4511
|
"!this._open",
|
|
4259
4512
|
"'service host is open'"
|
|
4260
4513
|
]
|
|
4261
4514
|
});
|
|
4515
|
+
(0, import_log16.log)("initializing...", void 0, {
|
|
4516
|
+
F: __dxlog_file17,
|
|
4517
|
+
L: 182,
|
|
4518
|
+
S: this,
|
|
4519
|
+
C: (f, a) => f(...a)
|
|
4520
|
+
});
|
|
4262
4521
|
if (config) {
|
|
4263
|
-
(0,
|
|
4264
|
-
F:
|
|
4265
|
-
L:
|
|
4522
|
+
(0, import_invariant14.invariant)(!this._config, "config already set", {
|
|
4523
|
+
F: __dxlog_file17,
|
|
4524
|
+
L: 185,
|
|
4266
4525
|
S: this,
|
|
4267
4526
|
A: [
|
|
4268
4527
|
"!this._config",
|
|
@@ -4275,12 +4534,12 @@ var ClientServicesHost = class {
|
|
|
4275
4534
|
}
|
|
4276
4535
|
}
|
|
4277
4536
|
const { connectionLog = true, transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
|
|
4278
|
-
iceServers:
|
|
4279
|
-
}), signalManager = new import_messaging.WebsocketSignalManager(
|
|
4537
|
+
iceServers: this._config?.get("runtime.services.ice")
|
|
4538
|
+
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4280
4539
|
this._signalManager = signalManager;
|
|
4281
|
-
(0,
|
|
4282
|
-
F:
|
|
4283
|
-
L:
|
|
4540
|
+
(0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
|
|
4541
|
+
F: __dxlog_file17,
|
|
4542
|
+
L: 201,
|
|
4284
4543
|
S: this,
|
|
4285
4544
|
A: [
|
|
4286
4545
|
"!this._networkManager",
|
|
@@ -4292,51 +4551,56 @@ var ClientServicesHost = class {
|
|
|
4292
4551
|
transportFactory,
|
|
4293
4552
|
signalManager
|
|
4294
4553
|
});
|
|
4554
|
+
(0, import_log16.log)("initialized", void 0, {
|
|
4555
|
+
F: __dxlog_file17,
|
|
4556
|
+
L: 208,
|
|
4557
|
+
S: this,
|
|
4558
|
+
C: (f, a) => f(...a)
|
|
4559
|
+
});
|
|
4295
4560
|
}
|
|
4296
|
-
async open() {
|
|
4297
|
-
var _a, _b, _c;
|
|
4561
|
+
async open(ctx) {
|
|
4298
4562
|
if (this._open) {
|
|
4299
4563
|
return;
|
|
4300
4564
|
}
|
|
4301
4565
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
4302
|
-
|
|
4566
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.begin({
|
|
4303
4567
|
id: traceId
|
|
4304
4568
|
}), {
|
|
4305
|
-
F:
|
|
4306
|
-
L:
|
|
4569
|
+
F: __dxlog_file17,
|
|
4570
|
+
L: 219,
|
|
4307
4571
|
S: this,
|
|
4308
4572
|
C: (f, a) => f(...a)
|
|
4309
4573
|
});
|
|
4310
|
-
(0,
|
|
4311
|
-
F:
|
|
4312
|
-
L:
|
|
4574
|
+
(0, import_invariant14.invariant)(this._config, "config not set", {
|
|
4575
|
+
F: __dxlog_file17,
|
|
4576
|
+
L: 221,
|
|
4313
4577
|
S: this,
|
|
4314
4578
|
A: [
|
|
4315
4579
|
"this._config",
|
|
4316
4580
|
"'config not set'"
|
|
4317
4581
|
]
|
|
4318
4582
|
});
|
|
4319
|
-
(0,
|
|
4320
|
-
F:
|
|
4321
|
-
L:
|
|
4583
|
+
(0, import_invariant14.invariant)(this._storage, "storage not set", {
|
|
4584
|
+
F: __dxlog_file17,
|
|
4585
|
+
L: 222,
|
|
4322
4586
|
S: this,
|
|
4323
4587
|
A: [
|
|
4324
4588
|
"this._storage",
|
|
4325
4589
|
"'storage not set'"
|
|
4326
4590
|
]
|
|
4327
4591
|
});
|
|
4328
|
-
(0,
|
|
4329
|
-
F:
|
|
4330
|
-
L:
|
|
4592
|
+
(0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
|
|
4593
|
+
F: __dxlog_file17,
|
|
4594
|
+
L: 223,
|
|
4331
4595
|
S: this,
|
|
4332
4596
|
A: [
|
|
4333
4597
|
"this._signalManager",
|
|
4334
4598
|
"'signal manager not set'"
|
|
4335
4599
|
]
|
|
4336
4600
|
});
|
|
4337
|
-
(0,
|
|
4338
|
-
F:
|
|
4339
|
-
L:
|
|
4601
|
+
(0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
|
|
4602
|
+
F: __dxlog_file17,
|
|
4603
|
+
L: 224,
|
|
4340
4604
|
S: this,
|
|
4341
4605
|
A: [
|
|
4342
4606
|
"this._networkManager",
|
|
@@ -4344,20 +4608,20 @@ var ClientServicesHost = class {
|
|
|
4344
4608
|
]
|
|
4345
4609
|
});
|
|
4346
4610
|
this._opening = true;
|
|
4347
|
-
(0,
|
|
4348
|
-
lockKey:
|
|
4611
|
+
(0, import_log16.log)("opening...", {
|
|
4612
|
+
lockKey: this._resourceLock?.lockKey
|
|
4349
4613
|
}, {
|
|
4350
|
-
F:
|
|
4351
|
-
L:
|
|
4614
|
+
F: __dxlog_file17,
|
|
4615
|
+
L: 227,
|
|
4352
4616
|
S: this,
|
|
4353
4617
|
C: (f, a) => f(...a)
|
|
4354
4618
|
});
|
|
4355
|
-
await
|
|
4619
|
+
await this._resourceLock?.acquire();
|
|
4356
4620
|
await this._loggingService.open();
|
|
4357
4621
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4358
4622
|
this._serviceRegistry.setServices({
|
|
4359
4623
|
SystemService: this._systemService,
|
|
4360
|
-
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
4624
|
+
IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
|
|
4361
4625
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4362
4626
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4363
4627
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4367,6 +4631,7 @@ var ClientServicesHost = class {
|
|
|
4367
4631
|
DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4368
4632
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4369
4633
|
LoggingService: this._loggingService,
|
|
4634
|
+
TracingService: this._tracingService,
|
|
4370
4635
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4371
4636
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4372
4637
|
events: new DevtoolsHostEvents(),
|
|
@@ -4374,39 +4639,38 @@ var ClientServicesHost = class {
|
|
|
4374
4639
|
context: this._serviceContext
|
|
4375
4640
|
})
|
|
4376
4641
|
});
|
|
4377
|
-
await this._serviceContext.open();
|
|
4642
|
+
await this._serviceContext.open(ctx);
|
|
4378
4643
|
this._opening = false;
|
|
4379
4644
|
this._open = true;
|
|
4380
4645
|
this._statusUpdate.emit();
|
|
4381
|
-
const deviceKey =
|
|
4382
|
-
(0,
|
|
4646
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4647
|
+
(0, import_log16.log)("opened", {
|
|
4383
4648
|
deviceKey
|
|
4384
4649
|
}, {
|
|
4385
|
-
F:
|
|
4386
|
-
L:
|
|
4650
|
+
F: __dxlog_file17,
|
|
4651
|
+
L: 284,
|
|
4387
4652
|
S: this,
|
|
4388
4653
|
C: (f, a) => f(...a)
|
|
4389
4654
|
});
|
|
4390
|
-
|
|
4655
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.end({
|
|
4391
4656
|
id: traceId
|
|
4392
4657
|
}), {
|
|
4393
|
-
F:
|
|
4394
|
-
L:
|
|
4658
|
+
F: __dxlog_file17,
|
|
4659
|
+
L: 285,
|
|
4395
4660
|
S: this,
|
|
4396
4661
|
C: (f, a) => f(...a)
|
|
4397
4662
|
});
|
|
4398
4663
|
}
|
|
4399
4664
|
async close() {
|
|
4400
|
-
var _a;
|
|
4401
4665
|
if (!this._open) {
|
|
4402
4666
|
return;
|
|
4403
4667
|
}
|
|
4404
|
-
const deviceKey =
|
|
4405
|
-
(0,
|
|
4668
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4669
|
+
(0, import_log16.log)("closing...", {
|
|
4406
4670
|
deviceKey
|
|
4407
4671
|
}, {
|
|
4408
|
-
F:
|
|
4409
|
-
L:
|
|
4672
|
+
F: __dxlog_file17,
|
|
4673
|
+
L: 296,
|
|
4410
4674
|
S: this,
|
|
4411
4675
|
C: (f, a) => f(...a)
|
|
4412
4676
|
});
|
|
@@ -4417,60 +4681,70 @@ var ClientServicesHost = class {
|
|
|
4417
4681
|
await this._serviceContext.close();
|
|
4418
4682
|
this._open = false;
|
|
4419
4683
|
this._statusUpdate.emit();
|
|
4420
|
-
(0,
|
|
4684
|
+
(0, import_log16.log)("closed", {
|
|
4421
4685
|
deviceKey
|
|
4422
4686
|
}, {
|
|
4423
|
-
F:
|
|
4424
|
-
L:
|
|
4687
|
+
F: __dxlog_file17,
|
|
4688
|
+
L: 302,
|
|
4425
4689
|
S: this,
|
|
4426
4690
|
C: (f, a) => f(...a)
|
|
4427
4691
|
});
|
|
4428
4692
|
}
|
|
4429
4693
|
async reset() {
|
|
4430
|
-
var _a, _b, _c;
|
|
4431
4694
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
4432
|
-
|
|
4695
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
|
|
4433
4696
|
id: traceId
|
|
4434
4697
|
}), {
|
|
4435
|
-
F:
|
|
4436
|
-
L:
|
|
4698
|
+
F: __dxlog_file17,
|
|
4699
|
+
L: 307,
|
|
4437
4700
|
S: this,
|
|
4438
4701
|
C: (f, a) => f(...a)
|
|
4439
4702
|
});
|
|
4440
|
-
(0,
|
|
4441
|
-
F:
|
|
4442
|
-
L:
|
|
4703
|
+
(0, import_log16.log)("resetting...", void 0, {
|
|
4704
|
+
F: __dxlog_file17,
|
|
4705
|
+
L: 309,
|
|
4443
4706
|
S: this,
|
|
4444
4707
|
C: (f, a) => f(...a)
|
|
4445
4708
|
});
|
|
4446
|
-
await
|
|
4709
|
+
await this._serviceContext?.close();
|
|
4447
4710
|
await this._storage.reset();
|
|
4448
|
-
(0,
|
|
4449
|
-
F:
|
|
4450
|
-
L:
|
|
4711
|
+
(0, import_log16.log)("reset", void 0, {
|
|
4712
|
+
F: __dxlog_file17,
|
|
4713
|
+
L: 312,
|
|
4451
4714
|
S: this,
|
|
4452
4715
|
C: (f, a) => f(...a)
|
|
4453
4716
|
});
|
|
4454
|
-
|
|
4717
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.end({
|
|
4455
4718
|
id: traceId
|
|
4456
4719
|
}), {
|
|
4457
|
-
F:
|
|
4458
|
-
L:
|
|
4720
|
+
F: __dxlog_file17,
|
|
4721
|
+
L: 313,
|
|
4459
4722
|
S: this,
|
|
4460
4723
|
C: (f, a) => f(...a)
|
|
4461
4724
|
});
|
|
4462
|
-
await
|
|
4725
|
+
await this._callbacks?.onReset?.();
|
|
4463
4726
|
}
|
|
4464
4727
|
};
|
|
4465
|
-
|
|
4466
|
-
|
|
4728
|
+
_ts_decorate7([
|
|
4729
|
+
import_tracing4.trace.info()
|
|
4730
|
+
], ClientServicesHost.prototype, "_opening", void 0);
|
|
4731
|
+
_ts_decorate7([
|
|
4732
|
+
import_tracing4.trace.info()
|
|
4733
|
+
], ClientServicesHost.prototype, "_open", void 0);
|
|
4734
|
+
_ts_decorate7([
|
|
4735
|
+
import_async17.synchronized,
|
|
4736
|
+
import_tracing4.trace.span()
|
|
4467
4737
|
], ClientServicesHost.prototype, "open", null);
|
|
4468
|
-
|
|
4469
|
-
import_async17.synchronized
|
|
4738
|
+
_ts_decorate7([
|
|
4739
|
+
import_async17.synchronized,
|
|
4740
|
+
import_tracing4.trace.span()
|
|
4470
4741
|
], ClientServicesHost.prototype, "close", null);
|
|
4742
|
+
ClientServicesHost = _ts_decorate7([
|
|
4743
|
+
import_tracing4.trace.resource()
|
|
4744
|
+
], ClientServicesHost);
|
|
4471
4745
|
|
|
4472
4746
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
4473
|
-
var
|
|
4747
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/invitation-utils.ts";
|
|
4474
4748
|
var sanitizeInvitation = (invitation) => {
|
|
4475
4749
|
return {
|
|
4476
4750
|
invitationId: invitation.invitationId,
|
|
@@ -4488,22 +4762,20 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4488
4762
|
const authCode = new import_async18.Trigger();
|
|
4489
4763
|
const hostObservable = createInvitation(host, options);
|
|
4490
4764
|
hostObservable.subscribe(async (hostInvitation) => {
|
|
4491
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
4492
4765
|
switch (hostInvitation.state) {
|
|
4493
|
-
case
|
|
4494
|
-
if (
|
|
4766
|
+
case import_services15.Invitation.State.CONNECTING: {
|
|
4767
|
+
if (hooks?.host?.onConnecting?.(hostObservable)) {
|
|
4495
4768
|
break;
|
|
4496
4769
|
}
|
|
4497
4770
|
const guestObservable = acceptInvitation(guest, hostInvitation);
|
|
4498
4771
|
guestObservable.subscribe(async (guestInvitation) => {
|
|
4499
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
4500
4772
|
switch (guestInvitation.state) {
|
|
4501
|
-
case
|
|
4502
|
-
if (
|
|
4773
|
+
case import_services15.Invitation.State.CONNECTING: {
|
|
4774
|
+
if (hooks?.guest?.onConnecting?.(guestObservable)) {
|
|
4503
4775
|
break;
|
|
4504
4776
|
}
|
|
4505
|
-
(0,
|
|
4506
|
-
F:
|
|
4777
|
+
(0, import_invariant15.invariant)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey), void 0, {
|
|
4778
|
+
F: __dxlog_file18,
|
|
4507
4779
|
L: 84,
|
|
4508
4780
|
S: void 0,
|
|
4509
4781
|
A: [
|
|
@@ -4513,23 +4785,23 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4513
4785
|
});
|
|
4514
4786
|
break;
|
|
4515
4787
|
}
|
|
4516
|
-
case
|
|
4517
|
-
|
|
4788
|
+
case import_services15.Invitation.State.CONNECTED: {
|
|
4789
|
+
hooks?.guest?.onConnected?.(guestObservable);
|
|
4518
4790
|
break;
|
|
4519
4791
|
}
|
|
4520
|
-
case
|
|
4521
|
-
if (
|
|
4792
|
+
case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
4793
|
+
if (hooks?.guest?.onReady?.(guestObservable)) {
|
|
4522
4794
|
break;
|
|
4523
4795
|
}
|
|
4524
4796
|
await guestObservable.authenticate(await authCode.wait());
|
|
4525
4797
|
break;
|
|
4526
4798
|
}
|
|
4527
|
-
case
|
|
4528
|
-
|
|
4799
|
+
case import_services15.Invitation.State.AUTHENTICATING: {
|
|
4800
|
+
hooks?.guest?.onAuthenticating?.(guestObservable);
|
|
4529
4801
|
break;
|
|
4530
4802
|
}
|
|
4531
|
-
case
|
|
4532
|
-
if (
|
|
4803
|
+
case import_services15.Invitation.State.SUCCESS: {
|
|
4804
|
+
if (hooks?.guest?.onSuccess?.(guestObservable)) {
|
|
4533
4805
|
break;
|
|
4534
4806
|
}
|
|
4535
4807
|
guestComplete.wake({
|
|
@@ -4537,8 +4809,8 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4537
4809
|
});
|
|
4538
4810
|
break;
|
|
4539
4811
|
}
|
|
4540
|
-
case
|
|
4541
|
-
if (
|
|
4812
|
+
case import_services15.Invitation.State.CANCELLED: {
|
|
4813
|
+
if (hooks?.guest?.onCancelled?.(guestObservable)) {
|
|
4542
4814
|
break;
|
|
4543
4815
|
}
|
|
4544
4816
|
guestComplete.wake({
|
|
@@ -4546,8 +4818,8 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4546
4818
|
});
|
|
4547
4819
|
break;
|
|
4548
4820
|
}
|
|
4549
|
-
case
|
|
4550
|
-
if (
|
|
4821
|
+
case import_services15.Invitation.State.TIMEOUT: {
|
|
4822
|
+
if (hooks?.guest?.onTimeout?.(guestObservable)) {
|
|
4551
4823
|
return;
|
|
4552
4824
|
}
|
|
4553
4825
|
guestComplete.wake({
|
|
@@ -4556,8 +4828,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4556
4828
|
}
|
|
4557
4829
|
}
|
|
4558
4830
|
}, (error) => {
|
|
4559
|
-
|
|
4560
|
-
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onError) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
4831
|
+
if (hooks?.guest?.onError?.(guestObservable)) {
|
|
4561
4832
|
return;
|
|
4562
4833
|
}
|
|
4563
4834
|
guestComplete.wake({
|
|
@@ -4566,12 +4837,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4566
4837
|
});
|
|
4567
4838
|
break;
|
|
4568
4839
|
}
|
|
4569
|
-
case
|
|
4570
|
-
|
|
4840
|
+
case import_services15.Invitation.State.CONNECTED: {
|
|
4841
|
+
hooks?.host?.onConnected?.(hostObservable);
|
|
4571
4842
|
break;
|
|
4572
4843
|
}
|
|
4573
|
-
case
|
|
4574
|
-
if (
|
|
4844
|
+
case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
4845
|
+
if (hooks?.host?.onReady?.(hostObservable)) {
|
|
4575
4846
|
break;
|
|
4576
4847
|
}
|
|
4577
4848
|
if (hostInvitation.authCode) {
|
|
@@ -4579,12 +4850,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4579
4850
|
}
|
|
4580
4851
|
break;
|
|
4581
4852
|
}
|
|
4582
|
-
case
|
|
4583
|
-
|
|
4853
|
+
case import_services15.Invitation.State.AUTHENTICATING: {
|
|
4854
|
+
hooks?.host?.onAuthenticating?.(hostObservable);
|
|
4584
4855
|
break;
|
|
4585
4856
|
}
|
|
4586
|
-
case
|
|
4587
|
-
if (
|
|
4857
|
+
case import_services15.Invitation.State.SUCCESS: {
|
|
4858
|
+
if (hooks?.host?.onSuccess?.(hostObservable)) {
|
|
4588
4859
|
break;
|
|
4589
4860
|
}
|
|
4590
4861
|
hostComplete.wake({
|
|
@@ -4592,8 +4863,8 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4592
4863
|
});
|
|
4593
4864
|
break;
|
|
4594
4865
|
}
|
|
4595
|
-
case
|
|
4596
|
-
if (
|
|
4866
|
+
case import_services15.Invitation.State.CANCELLED: {
|
|
4867
|
+
if (hooks?.host?.onCancelled?.(hostObservable)) {
|
|
4597
4868
|
break;
|
|
4598
4869
|
}
|
|
4599
4870
|
hostComplete.wake({
|
|
@@ -4601,8 +4872,8 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4601
4872
|
});
|
|
4602
4873
|
break;
|
|
4603
4874
|
}
|
|
4604
|
-
case
|
|
4605
|
-
if (
|
|
4875
|
+
case import_services15.Invitation.State.TIMEOUT: {
|
|
4876
|
+
if (hooks?.host?.onTimeout?.(hostObservable)) {
|
|
4606
4877
|
break;
|
|
4607
4878
|
}
|
|
4608
4879
|
hostComplete.wake({
|
|
@@ -4612,8 +4883,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4612
4883
|
}
|
|
4613
4884
|
}
|
|
4614
4885
|
}, (error) => {
|
|
4615
|
-
|
|
4616
|
-
if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, hostObservable)) {
|
|
4886
|
+
if (hooks?.host?.onError?.(hostObservable)) {
|
|
4617
4887
|
return;
|
|
4618
4888
|
}
|
|
4619
4889
|
hostComplete.wake({
|
|
@@ -4626,13 +4896,13 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4626
4896
|
];
|
|
4627
4897
|
};
|
|
4628
4898
|
var createInvitation = (host, options) => {
|
|
4629
|
-
options
|
|
4630
|
-
authMethod:
|
|
4631
|
-
...options
|
|
4899
|
+
options ??= {
|
|
4900
|
+
authMethod: import_services15.Invitation.AuthMethod.NONE,
|
|
4901
|
+
...options ?? {}
|
|
4632
4902
|
};
|
|
4633
4903
|
if (host instanceof ServiceContext) {
|
|
4634
4904
|
const hostHandler = host.getInvitationHandler({
|
|
4635
|
-
kind:
|
|
4905
|
+
kind: import_services15.Invitation.Kind.SPACE,
|
|
4636
4906
|
...options
|
|
4637
4907
|
});
|
|
4638
4908
|
return host.invitations.createInvitation(hostHandler, options);
|
|
@@ -4651,8 +4921,8 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4651
4921
|
};
|
|
4652
4922
|
|
|
4653
4923
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4654
|
-
var
|
|
4655
|
-
var
|
|
4924
|
+
var import_context11 = require("@dxos/context");
|
|
4925
|
+
var import_credentials16 = require("@dxos/credentials");
|
|
4656
4926
|
var import_debug8 = require("@dxos/debug");
|
|
4657
4927
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
4658
4928
|
var import_testing = require("@dxos/echo-pipeline/testing");
|
|
@@ -4686,7 +4956,7 @@ var createPeers = async (numPeers) => {
|
|
|
4686
4956
|
const peer = createServiceContext({
|
|
4687
4957
|
signalContext
|
|
4688
4958
|
});
|
|
4689
|
-
await peer.open();
|
|
4959
|
+
await peer.open(new import_context11.Context());
|
|
4690
4960
|
return peer;
|
|
4691
4961
|
}));
|
|
4692
4962
|
};
|
|
@@ -4701,7 +4971,7 @@ var syncItemsLocal = async (db1, db2) => {
|
|
|
4701
4971
|
var TestBuilder = class {
|
|
4702
4972
|
constructor() {
|
|
4703
4973
|
this.signalContext = new import_messaging2.MemorySignalManagerContext();
|
|
4704
|
-
this._ctx = new
|
|
4974
|
+
this._ctx = new import_context11.Context();
|
|
4705
4975
|
}
|
|
4706
4976
|
createPeer(peerOptions) {
|
|
4707
4977
|
const peer = new TestPeer(this.signalContext, peerOptions);
|
|
@@ -4724,18 +4994,15 @@ var TestPeer = class {
|
|
|
4724
4994
|
return this._props;
|
|
4725
4995
|
}
|
|
4726
4996
|
get storage() {
|
|
4727
|
-
|
|
4728
|
-
return (_b = (_a = this._props).storage) != null ? _b : _a.storage = (0, import_random_access_storage2.createStorage)({
|
|
4997
|
+
return this._props.storage ??= (0, import_random_access_storage2.createStorage)({
|
|
4729
4998
|
type: this.opts.storageType
|
|
4730
4999
|
});
|
|
4731
5000
|
}
|
|
4732
5001
|
get keyring() {
|
|
4733
|
-
|
|
4734
|
-
return (_b = (_a = this._props).keyring) != null ? _b : _a.keyring = new import_keyring2.Keyring(this.storage.createDirectory("keyring"));
|
|
5002
|
+
return this._props.keyring ??= new import_keyring2.Keyring(this.storage.createDirectory("keyring"));
|
|
4735
5003
|
}
|
|
4736
5004
|
get feedStore() {
|
|
4737
|
-
|
|
4738
|
-
return (_b = (_a = this._props).feedStore) != null ? _b : _a.feedStore = new import_feed_store5.FeedStore({
|
|
5005
|
+
return this._props.feedStore ??= new import_feed_store5.FeedStore({
|
|
4739
5006
|
factory: new import_feed_store5.FeedFactory({
|
|
4740
5007
|
root: this.storage.createDirectory("feeds"),
|
|
4741
5008
|
signer: this.keyring,
|
|
@@ -4746,27 +5013,22 @@ var TestPeer = class {
|
|
|
4746
5013
|
});
|
|
4747
5014
|
}
|
|
4748
5015
|
get metadataStore() {
|
|
4749
|
-
|
|
4750
|
-
return (_b = (_a = this._props).metadataStore) != null ? _b : _a.metadataStore = new import_echo_pipeline5.MetadataStore(this.storage.createDirectory("metadata"));
|
|
5016
|
+
return this._props.metadataStore ??= new import_echo_pipeline5.MetadataStore(this.storage.createDirectory("metadata"));
|
|
4751
5017
|
}
|
|
4752
5018
|
get blobStore() {
|
|
4753
|
-
|
|
4754
|
-
return (_b = (_a = this._props).blobStore) != null ? _b : _a.blobStore = new import_teleport_extension_object_sync2.BlobStore(this.storage.createDirectory("blobs"));
|
|
5019
|
+
return this._props.blobStore ??= new import_teleport_extension_object_sync2.BlobStore(this.storage.createDirectory("blobs"));
|
|
4755
5020
|
}
|
|
4756
5021
|
get snapshotStore() {
|
|
4757
|
-
|
|
4758
|
-
return (_b = (_a = this._props).snapshotStore) != null ? _b : _a.snapshotStore = new import_echo_pipeline5.SnapshotStore(this.storage.createDirectory("snapshots"));
|
|
5022
|
+
return this._props.snapshotStore ??= new import_echo_pipeline5.SnapshotStore(this.storage.createDirectory("snapshots"));
|
|
4759
5023
|
}
|
|
4760
5024
|
get networkManager() {
|
|
4761
|
-
|
|
4762
|
-
return (_b = (_a = this._props).networkManager) != null ? _b : _a.networkManager = new import_network_manager3.NetworkManager({
|
|
5025
|
+
return this._props.networkManager ??= new import_network_manager3.NetworkManager({
|
|
4763
5026
|
signalManager: new import_messaging2.MemorySignalManager(this.signalContext),
|
|
4764
5027
|
transportFactory: import_network_manager3.MemoryTransportFactory
|
|
4765
5028
|
});
|
|
4766
5029
|
}
|
|
4767
5030
|
get spaceManager() {
|
|
4768
|
-
|
|
4769
|
-
return (_b = (_a = this._props).spaceManager) != null ? _b : _a.spaceManager = new import_echo_pipeline5.SpaceManager({
|
|
5031
|
+
return this._props.spaceManager ??= new import_echo_pipeline5.SpaceManager({
|
|
4770
5032
|
feedStore: this.feedStore,
|
|
4771
5033
|
networkManager: this.networkManager,
|
|
4772
5034
|
metadataStore: this.metadataStore,
|
|
@@ -4776,16 +5038,13 @@ var TestPeer = class {
|
|
|
4776
5038
|
});
|
|
4777
5039
|
}
|
|
4778
5040
|
get identity() {
|
|
4779
|
-
|
|
4780
|
-
return (_a = this._props.signingContext) != null ? _a : (0, import_debug8.failUndefined)();
|
|
5041
|
+
return this._props.signingContext ?? (0, import_debug8.failUndefined)();
|
|
4781
5042
|
}
|
|
4782
5043
|
get dataSpaceManager() {
|
|
4783
|
-
|
|
4784
|
-
return (_b = (_a = this._props).dataSpaceManager) != null ? _b : _a.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, new import_echo_pipeline5.DataServiceSubscriptions(), this.keyring, this.identity, this.feedStore);
|
|
5044
|
+
return this._props.dataSpaceManager ??= new DataSpaceManager(this.spaceManager, this.metadataStore, new import_echo_pipeline5.DataServiceSubscriptions(), this.keyring, this.identity, this.feedStore);
|
|
4785
5045
|
}
|
|
4786
5046
|
async createIdentity() {
|
|
4787
|
-
|
|
4788
|
-
(_b = (_a = this._props).signingContext) != null ? _b : _a.signingContext = await createSigningContext(this.keyring);
|
|
5047
|
+
this._props.signingContext ??= await createSigningContext(this.keyring);
|
|
4789
5048
|
}
|
|
4790
5049
|
async destroy() {
|
|
4791
5050
|
await this.storage.reset();
|
|
@@ -4797,8 +5056,8 @@ var createSigningContext = async (keyring) => {
|
|
|
4797
5056
|
return {
|
|
4798
5057
|
identityKey,
|
|
4799
5058
|
deviceKey,
|
|
4800
|
-
credentialSigner: (0,
|
|
4801
|
-
credential: await new
|
|
5059
|
+
credentialSigner: (0, import_credentials16.createCredentialSignerWithChain)(keyring, {
|
|
5060
|
+
credential: await new import_credentials16.CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey)
|
|
4802
5061
|
}, deviceKey),
|
|
4803
5062
|
recordCredential: async () => {
|
|
4804
5063
|
}
|